objc: update documetation and add test-case of
[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 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax:: Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments:: C++ comments are recognized.
67 * Dollar Signs:: Dollar sign is allowed in identifiers.
68 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
69 * Alignment:: Inquiring about the alignment of a type or variable.
70 * Inline:: Defining inline functions (as fast as macros).
71 * Volatiles:: What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
76 function.
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83 arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86 checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
89 * Other Builtins:: Other built-in functions.
90 * Target Builtins:: Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas:: Pragmas accepted by GCC.
93 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
94 * Thread-Local:: Per-thread variables.
95 * Binary constants:: Binary constants using the @samp{0b} prefix.
96 @end menu
97
98 @node Statement Exprs
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
104
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@. This allows you to use loops, switches, and local variables
109 within an expression.
110
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces. For
113 example:
114
115 @smallexample
116 (@{ int y = foo (); int z;
117 if (y > 0) z = y;
118 else z = - y;
119 z; @})
120 @end smallexample
121
122 @noindent
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
125
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct. (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
131
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once). For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
135 follows:
136
137 @smallexample
138 #define max(a,b) ((a) > (b) ? (a) : (b))
139 @end smallexample
140
141 @noindent
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects. In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
147
148 @smallexample
149 #define maxint(a,b) \
150 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 @end smallexample
152
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
156
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression. For instance, if @code{A} is a class, then
163
164 @smallexample
165 A a;
166
167 (@{a;@}).Foo ()
168 @end smallexample
169
170 @noindent
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 address of @code{a}.
175
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end. This makes statement
178 expressions inside macros slightly different from function calls. In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call. In the statement expression case they are destroyed during
182 the statement expression. For instance,
183
184 @smallexample
185 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
187
188 void foo ()
189 @{
190 macro (X ());
191 function (X ());
192 @}
193 @end smallexample
194
195 @noindent
196 has different places where temporaries are destroyed. For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}. In the @code{function} case that
199 temporary is destroyed when the function returns.
200
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++. (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
205 bug.)
206
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted. Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression. In any case, as with a function call, the evaluation of a
218 statement expression is not interleaved with the evaluation of other
219 parts of the containing expression. For example,
220
221 @smallexample
222 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
223 @end smallexample
224
225 @noindent
226 calls @code{foo} and @code{bar1} and does not call @code{baz} but
227 may or may not call @code{bar2}. If @code{bar2} is called, it is
228 called after @code{foo} and before @code{bar1}.
229
230 @node Local Labels
231 @section Locally Declared Labels
232 @cindex local labels
233 @cindex macros, local labels
234
235 GCC allows you to declare @dfn{local labels} in any nested block
236 scope. A local label is just like an ordinary label, but you can
237 only reference it (with a @code{goto} statement, or by taking its
238 address) within the block in which it is declared.
239
240 A local label declaration looks like this:
241
242 @smallexample
243 __label__ @var{label};
244 @end smallexample
245
246 @noindent
247 or
248
249 @smallexample
250 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
251 @end smallexample
252
253 Local label declarations must come at the beginning of the block,
254 before any ordinary declarations or statements.
255
256 The label declaration defines the label @emph{name}, but does not define
257 the label itself. You must do this in the usual way, with
258 @code{@var{label}:}, within the statements of the statement expression.
259
260 The local label feature is useful for complex macros. If a macro
261 contains nested loops, a @code{goto} can be useful for breaking out of
262 them. However, an ordinary label whose scope is the whole function
263 cannot be used: if the macro can be expanded several times in one
264 function, the label is multiply defined in that function. A
265 local label avoids this problem. For example:
266
267 @smallexample
268 #define SEARCH(value, array, target) \
269 do @{ \
270 __label__ found; \
271 typeof (target) _SEARCH_target = (target); \
272 typeof (*(array)) *_SEARCH_array = (array); \
273 int i, j; \
274 int value; \
275 for (i = 0; i < max; i++) \
276 for (j = 0; j < max; j++) \
277 if (_SEARCH_array[i][j] == _SEARCH_target) \
278 @{ (value) = i; goto found; @} \
279 (value) = -1; \
280 found:; \
281 @} while (0)
282 @end smallexample
283
284 This could also be written using a statement expression:
285
286 @smallexample
287 #define SEARCH(array, target) \
288 (@{ \
289 __label__ found; \
290 typeof (target) _SEARCH_target = (target); \
291 typeof (*(array)) *_SEARCH_array = (array); \
292 int i, j; \
293 int value; \
294 for (i = 0; i < max; i++) \
295 for (j = 0; j < max; j++) \
296 if (_SEARCH_array[i][j] == _SEARCH_target) \
297 @{ value = i; goto found; @} \
298 value = -1; \
299 found: \
300 value; \
301 @})
302 @end smallexample
303
304 Local label declarations also make the labels they declare visible to
305 nested functions, if there are any. @xref{Nested Functions}, for details.
306
307 @node Labels as Values
308 @section Labels as Values
309 @cindex labels as values
310 @cindex computed gotos
311 @cindex goto with computed label
312 @cindex address of a label
313
314 You can get the address of a label defined in the current function
315 (or a containing function) with the unary operator @samp{&&}. The
316 value has type @code{void *}. This value is a constant and can be used
317 wherever a constant of that type is valid. For example:
318
319 @smallexample
320 void *ptr;
321 /* @r{@dots{}} */
322 ptr = &&foo;
323 @end smallexample
324
325 To use these values, you need to be able to jump to one. This is done
326 with the computed goto statement@footnote{The analogous feature in
327 Fortran is called an assigned goto, but that name seems inappropriate in
328 C, where one can do more than simply store label addresses in label
329 variables.}, @code{goto *@var{exp};}. For example,
330
331 @smallexample
332 goto *ptr;
333 @end smallexample
334
335 @noindent
336 Any expression of type @code{void *} is allowed.
337
338 One way of using these constants is in initializing a static array that
339 serves as a jump table:
340
341 @smallexample
342 static void *array[] = @{ &&foo, &&bar, &&hack @};
343 @end smallexample
344
345 @noindent
346 Then you can select a label with indexing, like this:
347
348 @smallexample
349 goto *array[i];
350 @end smallexample
351
352 @noindent
353 Note that this does not check whether the subscript is in bounds---array
354 indexing in C never does that.
355
356 Such an array of label values serves a purpose much like that of the
357 @code{switch} statement. The @code{switch} statement is cleaner, so
358 use that rather than an array unless the problem does not fit a
359 @code{switch} statement very well.
360
361 Another use of label values is in an interpreter for threaded code.
362 The labels within the interpreter function can be stored in the
363 threaded code for super-fast dispatching.
364
365 You may not use this mechanism to jump to code in a different function.
366 If you do that, totally unpredictable things happen. The best way to
367 avoid this is to store the label address only in automatic variables and
368 never pass it as an argument.
369
370 An alternate way to write the above example is
371
372 @smallexample
373 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
374 &&hack - &&foo @};
375 goto *(&&foo + array[i]);
376 @end smallexample
377
378 @noindent
379 This is more friendly to code living in shared libraries, as it reduces
380 the number of dynamic relocations that are needed, and by consequence,
381 allows the data to be read-only.
382 This alternative with label differences is not supported for the AVR target,
383 please use the first approach for AVR programs.
384
385 The @code{&&foo} expressions for the same label might have different
386 values if the containing function is inlined or cloned. If a program
387 relies on them being always the same,
388 @code{__attribute__((__noinline__,__noclone__))} should be used to
389 prevent inlining and cloning. If @code{&&foo} is used in a static
390 variable initializer, inlining and cloning is forbidden.
391
392 @node Nested Functions
393 @section Nested Functions
394 @cindex nested functions
395 @cindex downward funargs
396 @cindex thunks
397
398 A @dfn{nested function} is a function defined inside another function.
399 Nested functions are supported as an extension in GNU C, but are not
400 supported by GNU C++.
401
402 The nested function's name is local to the block where it is defined.
403 For example, here we define a nested function named @code{square}, and
404 call it twice:
405
406 @smallexample
407 @group
408 foo (double a, double b)
409 @{
410 double square (double z) @{ return z * z; @}
411
412 return square (a) + square (b);
413 @}
414 @end group
415 @end smallexample
416
417 The nested function can access all the variables of the containing
418 function that are visible at the point of its definition. This is
419 called @dfn{lexical scoping}. For example, here we show a nested
420 function which uses an inherited variable named @code{offset}:
421
422 @smallexample
423 @group
424 bar (int *array, int offset, int size)
425 @{
426 int access (int *array, int index)
427 @{ return array[index + offset]; @}
428 int i;
429 /* @r{@dots{}} */
430 for (i = 0; i < size; i++)
431 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
432 @}
433 @end group
434 @end smallexample
435
436 Nested function definitions are permitted within functions in the places
437 where variable definitions are allowed; that is, in any block, mixed
438 with the other declarations and statements in the block.
439
440 It is possible to call the nested function from outside the scope of its
441 name by storing its address or passing the address to another function:
442
443 @smallexample
444 hack (int *array, int size)
445 @{
446 void store (int index, int value)
447 @{ array[index] = value; @}
448
449 intermediate (store, size);
450 @}
451 @end smallexample
452
453 Here, the function @code{intermediate} receives the address of
454 @code{store} as an argument. If @code{intermediate} calls @code{store},
455 the arguments given to @code{store} are used to store into @code{array}.
456 But this technique works only so long as the containing function
457 (@code{hack}, in this example) does not exit.
458
459 If you try to call the nested function through its address after the
460 containing function exits, all hell breaks loose. If you try
461 to call it after a containing scope level exits, and if it refers
462 to some of the variables that are no longer in scope, you may be lucky,
463 but it's not wise to take the risk. If, however, the nested function
464 does not refer to anything that has gone out of scope, you should be
465 safe.
466
467 GCC implements taking the address of a nested function using a technique
468 called @dfn{trampolines}. This technique was described in
469 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
470 C++ Conference Proceedings, October 17-21, 1988).
471
472 A nested function can jump to a label inherited from a containing
473 function, provided the label is explicitly declared in the containing
474 function (@pxref{Local Labels}). Such a jump returns instantly to the
475 containing function, exiting the nested function that did the
476 @code{goto} and any intermediate functions as well. Here is an example:
477
478 @smallexample
479 @group
480 bar (int *array, int offset, int size)
481 @{
482 __label__ failure;
483 int access (int *array, int index)
484 @{
485 if (index > size)
486 goto failure;
487 return array[index + offset];
488 @}
489 int i;
490 /* @r{@dots{}} */
491 for (i = 0; i < size; i++)
492 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
493 /* @r{@dots{}} */
494 return 0;
495
496 /* @r{Control comes here from @code{access}
497 if it detects an error.} */
498 failure:
499 return -1;
500 @}
501 @end group
502 @end smallexample
503
504 A nested function always has no linkage. Declaring one with
505 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
506 before its definition, use @code{auto} (which is otherwise meaningless
507 for function declarations).
508
509 @smallexample
510 bar (int *array, int offset, int size)
511 @{
512 __label__ failure;
513 auto int access (int *, int);
514 /* @r{@dots{}} */
515 int access (int *array, int index)
516 @{
517 if (index > size)
518 goto failure;
519 return array[index + offset];
520 @}
521 /* @r{@dots{}} */
522 @}
523 @end smallexample
524
525 @node Constructing Calls
526 @section Constructing Function Calls
527 @cindex constructing calls
528 @cindex forwarding calls
529
530 Using the built-in functions described below, you can record
531 the arguments a function received, and call another function
532 with the same arguments, without knowing the number or types
533 of the arguments.
534
535 You can also record the return value of that function call,
536 and later return that value, without knowing what data type
537 the function tried to return (as long as your caller expects
538 that data type).
539
540 However, these built-in functions may interact badly with some
541 sophisticated features or other extensions of the language. It
542 is, therefore, not recommended to use them outside very simple
543 functions acting as mere forwarders for their arguments.
544
545 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
546 This built-in function returns a pointer to data
547 describing how to perform a call with the same arguments as are passed
548 to the current function.
549
550 The function saves the arg pointer register, structure value address,
551 and all registers that might be used to pass arguments to a function
552 into a block of memory allocated on the stack. Then it returns the
553 address of that block.
554 @end deftypefn
555
556 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
557 This built-in function invokes @var{function}
558 with a copy of the parameters described by @var{arguments}
559 and @var{size}.
560
561 The value of @var{arguments} should be the value returned by
562 @code{__builtin_apply_args}. The argument @var{size} specifies the size
563 of the stack argument data, in bytes.
564
565 This function returns a pointer to data describing
566 how to return whatever value is returned by @var{function}. The data
567 is saved in a block of memory allocated on the stack.
568
569 It is not always simple to compute the proper value for @var{size}. The
570 value is used by @code{__builtin_apply} to compute the amount of data
571 that should be pushed on the stack and copied from the incoming argument
572 area.
573 @end deftypefn
574
575 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
576 This built-in function returns the value described by @var{result} from
577 the containing function. You should specify, for @var{result}, a value
578 returned by @code{__builtin_apply}.
579 @end deftypefn
580
581 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
582 This built-in function represents all anonymous arguments of an inline
583 function. It can be used only in inline functions that are always
584 inlined, never compiled as a separate function, such as those using
585 @code{__attribute__ ((__always_inline__))} or
586 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
587 It must be only passed as last argument to some other function
588 with variable arguments. This is useful for writing small wrapper
589 inlines for variable argument functions, when using preprocessor
590 macros is undesirable. For example:
591 @smallexample
592 extern int myprintf (FILE *f, const char *format, ...);
593 extern inline __attribute__ ((__gnu_inline__)) int
594 myprintf (FILE *f, const char *format, ...)
595 @{
596 int r = fprintf (f, "myprintf: ");
597 if (r < 0)
598 return r;
599 int s = fprintf (f, format, __builtin_va_arg_pack ());
600 if (s < 0)
601 return s;
602 return r + s;
603 @}
604 @end smallexample
605 @end deftypefn
606
607 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
608 This built-in function returns the number of anonymous arguments of
609 an inline function. It can be used only in inline functions that
610 are always inlined, never compiled as a separate function, such
611 as those using @code{__attribute__ ((__always_inline__))} or
612 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
613 For example following does link- or run-time checking of open
614 arguments for optimized code:
615 @smallexample
616 #ifdef __OPTIMIZE__
617 extern inline __attribute__((__gnu_inline__)) int
618 myopen (const char *path, int oflag, ...)
619 @{
620 if (__builtin_va_arg_pack_len () > 1)
621 warn_open_too_many_arguments ();
622
623 if (__builtin_constant_p (oflag))
624 @{
625 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
626 @{
627 warn_open_missing_mode ();
628 return __open_2 (path, oflag);
629 @}
630 return open (path, oflag, __builtin_va_arg_pack ());
631 @}
632
633 if (__builtin_va_arg_pack_len () < 1)
634 return __open_2 (path, oflag);
635
636 return open (path, oflag, __builtin_va_arg_pack ());
637 @}
638 #endif
639 @end smallexample
640 @end deftypefn
641
642 @node Typeof
643 @section Referring to a Type with @code{typeof}
644 @findex typeof
645 @findex sizeof
646 @cindex macros, types of arguments
647
648 Another way to refer to the type of an expression is with @code{typeof}.
649 The syntax of using of this keyword looks like @code{sizeof}, but the
650 construct acts semantically like a type name defined with @code{typedef}.
651
652 There are two ways of writing the argument to @code{typeof}: with an
653 expression or with a type. Here is an example with an expression:
654
655 @smallexample
656 typeof (x[0](1))
657 @end smallexample
658
659 @noindent
660 This assumes that @code{x} is an array of pointers to functions;
661 the type described is that of the values of the functions.
662
663 Here is an example with a typename as the argument:
664
665 @smallexample
666 typeof (int *)
667 @end smallexample
668
669 @noindent
670 Here the type described is that of pointers to @code{int}.
671
672 If you are writing a header file that must work when included in ISO C
673 programs, write @code{__typeof__} instead of @code{typeof}.
674 @xref{Alternate Keywords}.
675
676 A @code{typeof} construct can be used anywhere a typedef name can be
677 used. For example, you can use it in a declaration, in a cast, or inside
678 of @code{sizeof} or @code{typeof}.
679
680 The operand of @code{typeof} is evaluated for its side effects if and
681 only if it is an expression of variably modified type or the name of
682 such a type.
683
684 @code{typeof} is often useful in conjunction with
685 statement expressions (@pxref{Statement Exprs}).
686 Here is how the two together can
687 be used to define a safe ``maximum'' macro which operates on any
688 arithmetic type and evaluates each of its arguments exactly once:
689
690 @smallexample
691 #define max(a,b) \
692 (@{ typeof (a) _a = (a); \
693 typeof (b) _b = (b); \
694 _a > _b ? _a : _b; @})
695 @end smallexample
696
697 @cindex underscores in variables in macros
698 @cindex @samp{_} in variables in macros
699 @cindex local variables in macros
700 @cindex variables, local, in macros
701 @cindex macros, local variables in
702
703 The reason for using names that start with underscores for the local
704 variables is to avoid conflicts with variable names that occur within the
705 expressions that are substituted for @code{a} and @code{b}. Eventually we
706 hope to design a new form of declaration syntax that allows you to declare
707 variables whose scopes start only after their initializers; this will be a
708 more reliable way to prevent such conflicts.
709
710 @noindent
711 Some more examples of the use of @code{typeof}:
712
713 @itemize @bullet
714 @item
715 This declares @code{y} with the type of what @code{x} points to.
716
717 @smallexample
718 typeof (*x) y;
719 @end smallexample
720
721 @item
722 This declares @code{y} as an array of such values.
723
724 @smallexample
725 typeof (*x) y[4];
726 @end smallexample
727
728 @item
729 This declares @code{y} as an array of pointers to characters:
730
731 @smallexample
732 typeof (typeof (char *)[4]) y;
733 @end smallexample
734
735 @noindent
736 It is equivalent to the following traditional C declaration:
737
738 @smallexample
739 char *y[4];
740 @end smallexample
741
742 To see the meaning of the declaration using @code{typeof}, and why it
743 might be a useful way to write, rewrite it with these macros:
744
745 @smallexample
746 #define pointer(T) typeof(T *)
747 #define array(T, N) typeof(T [N])
748 @end smallexample
749
750 @noindent
751 Now the declaration can be rewritten this way:
752
753 @smallexample
754 array (pointer (char), 4) y;
755 @end smallexample
756
757 @noindent
758 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
759 pointers to @code{char}.
760 @end itemize
761
762 In GNU C, but not GNU C++, you may also declare the type of a variable
763 as @code{__auto_type}. In that case, the declaration must declare
764 only one variable, whose declarator must just be an identifier, the
765 declaration must be initialized, and the type of the variable is
766 determined by the initializer; the name of the variable is not in
767 scope until after the initializer. (In C++, you should use C++11
768 @code{auto} for this purpose.) Using @code{__auto_type}, the
769 ``maximum'' macro above could be written as:
770
771 @smallexample
772 #define max(a,b) \
773 (@{ __auto_type _a = (a); \
774 __auto_type _b = (b); \
775 _a > _b ? _a : _b; @})
776 @end smallexample
777
778 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779
780 @itemize @bullet
781 @item Each argument to the macro appears only once in the expansion of
782 the macro. This prevents the size of the macro expansion growing
783 exponentially when calls to such macros are nested inside arguments of
784 such macros.
785
786 @item If the argument to the macro has variably modified type, it is
787 evaluated only once when using @code{__auto_type}, but twice if
788 @code{typeof} is used.
789 @end itemize
790
791 @node Conditionals
792 @section Conditionals with Omitted Operands
793 @cindex conditional expressions, extensions
794 @cindex omitted middle-operands
795 @cindex middle-operands, omitted
796 @cindex extensions, @code{?:}
797 @cindex @code{?:} extensions
798
799 The middle operand in a conditional expression may be omitted. Then
800 if the first operand is nonzero, its value is the value of the conditional
801 expression.
802
803 Therefore, the expression
804
805 @smallexample
806 x ? : y
807 @end smallexample
808
809 @noindent
810 has the value of @code{x} if that is nonzero; otherwise, the value of
811 @code{y}.
812
813 This example is perfectly equivalent to
814
815 @smallexample
816 x ? x : y
817 @end smallexample
818
819 @cindex side effect in @code{?:}
820 @cindex @code{?:} side effect
821 @noindent
822 In this simple case, the ability to omit the middle operand is not
823 especially useful. When it becomes useful is when the first operand does,
824 or may (if it is a macro argument), contain a side effect. Then repeating
825 the operand in the middle would perform the side effect twice. Omitting
826 the middle operand uses the value already computed without the undesirable
827 effects of recomputing it.
828
829 @node __int128
830 @section 128-bit Integers
831 @cindex @code{__int128} data types
832
833 As an extension the integer scalar type @code{__int128} is supported for
834 targets which have an integer mode wide enough to hold 128 bits.
835 Simply write @code{__int128} for a signed 128-bit integer, or
836 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
837 support in GCC for expressing an integer constant of type @code{__int128}
838 for targets with @code{long long} integer less than 128 bits wide.
839
840 @node Long Long
841 @section Double-Word Integers
842 @cindex @code{long long} data types
843 @cindex double-word arithmetic
844 @cindex multiprecision arithmetic
845 @cindex @code{LL} integer suffix
846 @cindex @code{ULL} integer suffix
847
848 ISO C99 supports data types for integers that are at least 64 bits wide,
849 and as an extension GCC supports them in C90 mode and in C++.
850 Simply write @code{long long int} for a signed integer, or
851 @code{unsigned long long int} for an unsigned integer. To make an
852 integer constant of type @code{long long int}, add the suffix @samp{LL}
853 to the integer. To make an integer constant of type @code{unsigned long
854 long int}, add the suffix @samp{ULL} to the integer.
855
856 You can use these types in arithmetic like any other integer types.
857 Addition, subtraction, and bitwise boolean operations on these types
858 are open-coded on all types of machines. Multiplication is open-coded
859 if the machine supports a fullword-to-doubleword widening multiply
860 instruction. Division and shifts are open-coded only on machines that
861 provide special support. The operations that are not open-coded use
862 special library routines that come with GCC@.
863
864 There may be pitfalls when you use @code{long long} types for function
865 arguments without function prototypes. If a function
866 expects type @code{int} for its argument, and you pass a value of type
867 @code{long long int}, confusion results because the caller and the
868 subroutine disagree about the number of bytes for the argument.
869 Likewise, if the function expects @code{long long int} and you pass
870 @code{int}. The best way to avoid such problems is to use prototypes.
871
872 @node Complex
873 @section Complex Numbers
874 @cindex complex numbers
875 @cindex @code{_Complex} keyword
876 @cindex @code{__complex__} keyword
877
878 ISO C99 supports complex floating data types, and as an extension GCC
879 supports them in C90 mode and in C++. GCC also supports complex integer data
880 types which are not part of ISO C99. You can declare complex types
881 using the keyword @code{_Complex}. As an extension, the older GNU
882 keyword @code{__complex__} is also supported.
883
884 For example, @samp{_Complex double x;} declares @code{x} as a
885 variable whose real part and imaginary part are both of type
886 @code{double}. @samp{_Complex short int y;} declares @code{y} to
887 have real and imaginary parts of type @code{short int}; this is not
888 likely to be useful, but it shows that the set of complex types is
889 complete.
890
891 To write a constant with a complex data type, use the suffix @samp{i} or
892 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
893 has type @code{_Complex float} and @code{3i} has type
894 @code{_Complex int}. Such a constant always has a pure imaginary
895 value, but you can form any complex value you like by adding one to a
896 real constant. This is a GNU extension; if you have an ISO C99
897 conforming C library (such as the GNU C Library), and want to construct complex
898 constants of floating type, you should include @code{<complex.h>} and
899 use the macros @code{I} or @code{_Complex_I} instead.
900
901 @cindex @code{__real__} keyword
902 @cindex @code{__imag__} keyword
903 To extract the real part of a complex-valued expression @var{exp}, write
904 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
905 extract the imaginary part. This is a GNU extension; for values of
906 floating type, you should use the ISO C99 functions @code{crealf},
907 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
908 @code{cimagl}, declared in @code{<complex.h>} and also provided as
909 built-in functions by GCC@.
910
911 @cindex complex conjugation
912 The operator @samp{~} performs complex conjugation when used on a value
913 with a complex type. This is a GNU extension; for values of
914 floating type, you should use the ISO C99 functions @code{conjf},
915 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
916 provided as built-in functions by GCC@.
917
918 GCC can allocate complex automatic variables in a noncontiguous
919 fashion; it's even possible for the real part to be in a register while
920 the imaginary part is on the stack (or vice versa). Only the DWARF
921 debug info format can represent this, so use of DWARF is recommended.
922 If you are using the stabs debug info format, GCC describes a noncontiguous
923 complex variable as if it were two separate variables of noncomplex type.
924 If the variable's actual name is @code{foo}, the two fictitious
925 variables are named @code{foo$real} and @code{foo$imag}. You can
926 examine and set these two fictitious variables with your debugger.
927
928 @node Floating Types
929 @section Additional Floating Types
930 @cindex additional floating types
931 @cindex @code{_Float@var{n}} data types
932 @cindex @code{_Float@var{n}x} data types
933 @cindex @code{__float80} data type
934 @cindex @code{__float128} data type
935 @cindex @code{__ibm128} data type
936 @cindex @code{w} floating point suffix
937 @cindex @code{q} floating point suffix
938 @cindex @code{W} floating point suffix
939 @cindex @code{Q} floating point suffix
940
941 ISO/IEC TS 18661-3:2015 defines C support for additional floating
942 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
943 these type names; the set of types supported depends on the target
944 architecture. These types are not supported when compiling C++.
945 Constants with these types use suffixes @code{f@var{n}} or
946 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
947 names can be used together with @code{_Complex} to declare complex
948 types.
949
950 As an extension, GNU C and GNU C++ support additional floating
951 types, @code{__float80} and @code{__float128} to support 80-bit
952 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types; these are
953 aliases for the type names @code{_Float64x} and @code{_Float128}.
954 Support for additional types includes the arithmetic operators:
955 add, subtract, multiply, divide; unary arithmetic operators;
956 relational operators; equality operators; and conversions to and from
957 integer and other floating types. Use a suffix @samp{w} or @samp{W}
958 in a literal constant of type @code{__float80} or type
959 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
960
961 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
962 types using the corresponding internal complex type, @code{XCmode} for
963 @code{__float80} type and @code{TCmode} for @code{__float128} type:
964
965 @smallexample
966 typedef _Complex float __attribute__((mode(TC))) _Complex128;
967 typedef _Complex float __attribute__((mode(XC))) _Complex80;
968 @end smallexample
969
970 In order to use @code{_Float128}, @code{__float128} and
971 @code{__ibm128} on PowerPC Linux
972 systems, you must use the @option{-mfloat128}. It is expected in
973 future versions of GCC that @code{_Float128} and @code{__float128}
974 will be enabled
975 automatically. In addition, there are currently problems in using the
976 complex @code{__float128} type. When these problems are fixed, you
977 would use the following syntax to declare @code{_Complex128} to be a
978 complex @code{__float128} type:
979
980 On the PowerPC Linux VSX targets, you can declare complex types using
981 the corresponding internal complex type, @code{KCmode} for
982 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
983
984 @smallexample
985 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
986 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
987 @end smallexample
988
989 Not all targets support additional floating-point types.
990 @code{__float80} and @code{__float128} types are supported on x86 and
991 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
992 The @code{__float128} type is supported on PowerPC 64-bit Linux
993 systems by default if the vector scalar instruction set (VSX) is
994 enabled. The @code{_Float128} type is supported on all systems where
995 @code{__float128} is supported or where @code{long double} has the
996 IEEE binary128 format. The @code{_Float64x} type is supported on all
997 systems where @code{__float128} is supported. The @code{_Float32}
998 type is supported on all systems supporting IEEE binary32; the
999 @code{_Float64} and @code{Float32x} types are supported on all systems
1000 supporting IEEE binary64. GCC does not currently support
1001 @code{_Float16} or @code{_Float128x} on any systems.
1002
1003 On the PowerPC, @code{__ibm128} provides access to the IBM extended
1004 double format, and it is intended to be used by the library functions
1005 that handle conversions if/when long double is changed to be IEEE
1006 128-bit floating point.
1007
1008 @node Half-Precision
1009 @section Half-Precision Floating Point
1010 @cindex half-precision floating point
1011 @cindex @code{__fp16} data type
1012
1013 On ARM targets, GCC supports half-precision (16-bit) floating point via
1014 the @code{__fp16} type. You must enable this type explicitly
1015 with the @option{-mfp16-format} command-line option in order to use it.
1016
1017 ARM supports two incompatible representations for half-precision
1018 floating-point values. You must choose one of the representations and
1019 use it consistently in your program.
1020
1021 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1022 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1023 There are 11 bits of significand precision, approximately 3
1024 decimal digits.
1025
1026 Specifying @option{-mfp16-format=alternative} selects the ARM
1027 alternative format. This representation is similar to the IEEE
1028 format, but does not support infinities or NaNs. Instead, the range
1029 of exponents is extended, so that this format can represent normalized
1030 values in the range of @math{2^{-14}} to 131008.
1031
1032 The @code{__fp16} type is a storage format only. For purposes
1033 of arithmetic and other operations, @code{__fp16} values in C or C++
1034 expressions are automatically promoted to @code{float}. In addition,
1035 you cannot declare a function with a return value or parameters
1036 of type @code{__fp16}.
1037
1038 Note that conversions from @code{double} to @code{__fp16}
1039 involve an intermediate conversion to @code{float}. Because
1040 of rounding, this can sometimes produce a different result than a
1041 direct conversion.
1042
1043 ARM provides hardware support for conversions between
1044 @code{__fp16} and @code{float} values
1045 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1046 code using these hardware instructions if you compile with
1047 options to select an FPU that provides them;
1048 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1049 in addition to the @option{-mfp16-format} option to select
1050 a half-precision format.
1051
1052 Language-level support for the @code{__fp16} data type is
1053 independent of whether GCC generates code using hardware floating-point
1054 instructions. In cases where hardware support is not specified, GCC
1055 implements conversions between @code{__fp16} and @code{float} values
1056 as library calls.
1057
1058 @node Decimal Float
1059 @section Decimal Floating Types
1060 @cindex decimal floating types
1061 @cindex @code{_Decimal32} data type
1062 @cindex @code{_Decimal64} data type
1063 @cindex @code{_Decimal128} data type
1064 @cindex @code{df} integer suffix
1065 @cindex @code{dd} integer suffix
1066 @cindex @code{dl} integer suffix
1067 @cindex @code{DF} integer suffix
1068 @cindex @code{DD} integer suffix
1069 @cindex @code{DL} integer suffix
1070
1071 As an extension, GNU C supports decimal floating types as
1072 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1073 floating types in GCC will evolve as the draft technical report changes.
1074 Calling conventions for any target might also change. Not all targets
1075 support decimal floating types.
1076
1077 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1078 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1079 @code{float}, @code{double}, and @code{long double} whose radix is not
1080 specified by the C standard but is usually two.
1081
1082 Support for decimal floating types includes the arithmetic operators
1083 add, subtract, multiply, divide; unary arithmetic operators;
1084 relational operators; equality operators; and conversions to and from
1085 integer and other floating types. Use a suffix @samp{df} or
1086 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1087 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1088 @code{_Decimal128}.
1089
1090 GCC support of decimal float as specified by the draft technical report
1091 is incomplete:
1092
1093 @itemize @bullet
1094 @item
1095 When the value of a decimal floating type cannot be represented in the
1096 integer type to which it is being converted, the result is undefined
1097 rather than the result value specified by the draft technical report.
1098
1099 @item
1100 GCC does not provide the C library functionality associated with
1101 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1102 @file{wchar.h}, which must come from a separate C library implementation.
1103 Because of this the GNU C compiler does not define macro
1104 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1105 the technical report.
1106 @end itemize
1107
1108 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1109 are supported by the DWARF debug information format.
1110
1111 @node Hex Floats
1112 @section Hex Floats
1113 @cindex hex floats
1114
1115 ISO C99 supports floating-point numbers written not only in the usual
1116 decimal notation, such as @code{1.55e1}, but also numbers such as
1117 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1118 supports this in C90 mode (except in some cases when strictly
1119 conforming) and in C++. In that format the
1120 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1121 mandatory. The exponent is a decimal number that indicates the power of
1122 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1123 @tex
1124 $1 {15\over16}$,
1125 @end tex
1126 @ifnottex
1127 1 15/16,
1128 @end ifnottex
1129 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1130 is the same as @code{1.55e1}.
1131
1132 Unlike for floating-point numbers in the decimal notation the exponent
1133 is always required in the hexadecimal notation. Otherwise the compiler
1134 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1135 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1136 extension for floating-point constants of type @code{float}.
1137
1138 @node Fixed-Point
1139 @section Fixed-Point Types
1140 @cindex fixed-point types
1141 @cindex @code{_Fract} data type
1142 @cindex @code{_Accum} data type
1143 @cindex @code{_Sat} data type
1144 @cindex @code{hr} fixed-suffix
1145 @cindex @code{r} fixed-suffix
1146 @cindex @code{lr} fixed-suffix
1147 @cindex @code{llr} fixed-suffix
1148 @cindex @code{uhr} fixed-suffix
1149 @cindex @code{ur} fixed-suffix
1150 @cindex @code{ulr} fixed-suffix
1151 @cindex @code{ullr} fixed-suffix
1152 @cindex @code{hk} fixed-suffix
1153 @cindex @code{k} fixed-suffix
1154 @cindex @code{lk} fixed-suffix
1155 @cindex @code{llk} fixed-suffix
1156 @cindex @code{uhk} fixed-suffix
1157 @cindex @code{uk} fixed-suffix
1158 @cindex @code{ulk} fixed-suffix
1159 @cindex @code{ullk} fixed-suffix
1160 @cindex @code{HR} fixed-suffix
1161 @cindex @code{R} fixed-suffix
1162 @cindex @code{LR} fixed-suffix
1163 @cindex @code{LLR} fixed-suffix
1164 @cindex @code{UHR} fixed-suffix
1165 @cindex @code{UR} fixed-suffix
1166 @cindex @code{ULR} fixed-suffix
1167 @cindex @code{ULLR} fixed-suffix
1168 @cindex @code{HK} fixed-suffix
1169 @cindex @code{K} fixed-suffix
1170 @cindex @code{LK} fixed-suffix
1171 @cindex @code{LLK} fixed-suffix
1172 @cindex @code{UHK} fixed-suffix
1173 @cindex @code{UK} fixed-suffix
1174 @cindex @code{ULK} fixed-suffix
1175 @cindex @code{ULLK} fixed-suffix
1176
1177 As an extension, GNU C supports fixed-point types as
1178 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1179 types in GCC will evolve as the draft technical report changes.
1180 Calling conventions for any target might also change. Not all targets
1181 support fixed-point types.
1182
1183 The fixed-point types are
1184 @code{short _Fract},
1185 @code{_Fract},
1186 @code{long _Fract},
1187 @code{long long _Fract},
1188 @code{unsigned short _Fract},
1189 @code{unsigned _Fract},
1190 @code{unsigned long _Fract},
1191 @code{unsigned long long _Fract},
1192 @code{_Sat short _Fract},
1193 @code{_Sat _Fract},
1194 @code{_Sat long _Fract},
1195 @code{_Sat long long _Fract},
1196 @code{_Sat unsigned short _Fract},
1197 @code{_Sat unsigned _Fract},
1198 @code{_Sat unsigned long _Fract},
1199 @code{_Sat unsigned long long _Fract},
1200 @code{short _Accum},
1201 @code{_Accum},
1202 @code{long _Accum},
1203 @code{long long _Accum},
1204 @code{unsigned short _Accum},
1205 @code{unsigned _Accum},
1206 @code{unsigned long _Accum},
1207 @code{unsigned long long _Accum},
1208 @code{_Sat short _Accum},
1209 @code{_Sat _Accum},
1210 @code{_Sat long _Accum},
1211 @code{_Sat long long _Accum},
1212 @code{_Sat unsigned short _Accum},
1213 @code{_Sat unsigned _Accum},
1214 @code{_Sat unsigned long _Accum},
1215 @code{_Sat unsigned long long _Accum}.
1216
1217 Fixed-point data values contain fractional and optional integral parts.
1218 The format of fixed-point data varies and depends on the target machine.
1219
1220 Support for fixed-point types includes:
1221 @itemize @bullet
1222 @item
1223 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1224 @item
1225 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1226 @item
1227 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1228 @item
1229 binary shift operators (@code{<<}, @code{>>})
1230 @item
1231 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1232 @item
1233 equality operators (@code{==}, @code{!=})
1234 @item
1235 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1236 @code{<<=}, @code{>>=})
1237 @item
1238 conversions to and from integer, floating-point, or fixed-point types
1239 @end itemize
1240
1241 Use a suffix in a fixed-point literal constant:
1242 @itemize
1243 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1244 @code{_Sat short _Fract}
1245 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1246 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1247 @code{_Sat long _Fract}
1248 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1249 @code{_Sat long long _Fract}
1250 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1251 @code{_Sat unsigned short _Fract}
1252 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1253 @code{_Sat unsigned _Fract}
1254 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1255 @code{_Sat unsigned long _Fract}
1256 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1257 and @code{_Sat unsigned long long _Fract}
1258 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1259 @code{_Sat short _Accum}
1260 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1261 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1262 @code{_Sat long _Accum}
1263 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1264 @code{_Sat long long _Accum}
1265 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1266 @code{_Sat unsigned short _Accum}
1267 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1268 @code{_Sat unsigned _Accum}
1269 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1270 @code{_Sat unsigned long _Accum}
1271 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1272 and @code{_Sat unsigned long long _Accum}
1273 @end itemize
1274
1275 GCC support of fixed-point types as specified by the draft technical report
1276 is incomplete:
1277
1278 @itemize @bullet
1279 @item
1280 Pragmas to control overflow and rounding behaviors are not implemented.
1281 @end itemize
1282
1283 Fixed-point types are supported by the DWARF debug information format.
1284
1285 @node Named Address Spaces
1286 @section Named Address Spaces
1287 @cindex Named Address Spaces
1288
1289 As an extension, GNU C supports named address spaces as
1290 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1291 address spaces in GCC will evolve as the draft technical report
1292 changes. Calling conventions for any target might also change. At
1293 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1294 address spaces other than the generic address space.
1295
1296 Address space identifiers may be used exactly like any other C type
1297 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1298 document for more details.
1299
1300 @anchor{AVR Named Address Spaces}
1301 @subsection AVR Named Address Spaces
1302
1303 On the AVR target, there are several address spaces that can be used
1304 in order to put read-only data into the flash memory and access that
1305 data by means of the special instructions @code{LPM} or @code{ELPM}
1306 needed to read from flash.
1307
1308 Per default, any data including read-only data is located in RAM
1309 (the generic address space) so that non-generic address spaces are
1310 needed to locate read-only data in flash memory
1311 @emph{and} to generate the right instructions to access this data
1312 without using (inline) assembler code.
1313
1314 @table @code
1315 @item __flash
1316 @cindex @code{__flash} AVR Named Address Spaces
1317 The @code{__flash} qualifier locates data in the
1318 @code{.progmem.data} section. Data is read using the @code{LPM}
1319 instruction. Pointers to this address space are 16 bits wide.
1320
1321 @item __flash1
1322 @itemx __flash2
1323 @itemx __flash3
1324 @itemx __flash4
1325 @itemx __flash5
1326 @cindex @code{__flash1} AVR Named Address Spaces
1327 @cindex @code{__flash2} AVR Named Address Spaces
1328 @cindex @code{__flash3} AVR Named Address Spaces
1329 @cindex @code{__flash4} AVR Named Address Spaces
1330 @cindex @code{__flash5} AVR Named Address Spaces
1331 These are 16-bit address spaces locating data in section
1332 @code{.progmem@var{N}.data} where @var{N} refers to
1333 address space @code{__flash@var{N}}.
1334 The compiler sets the @code{RAMPZ} segment register appropriately
1335 before reading data by means of the @code{ELPM} instruction.
1336
1337 @item __memx
1338 @cindex @code{__memx} AVR Named Address Spaces
1339 This is a 24-bit address space that linearizes flash and RAM:
1340 If the high bit of the address is set, data is read from
1341 RAM using the lower two bytes as RAM address.
1342 If the high bit of the address is clear, data is read from flash
1343 with @code{RAMPZ} set according to the high byte of the address.
1344 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1345
1346 Objects in this address space are located in @code{.progmemx.data}.
1347 @end table
1348
1349 @b{Example}
1350
1351 @smallexample
1352 char my_read (const __flash char ** p)
1353 @{
1354 /* p is a pointer to RAM that points to a pointer to flash.
1355 The first indirection of p reads that flash pointer
1356 from RAM and the second indirection reads a char from this
1357 flash address. */
1358
1359 return **p;
1360 @}
1361
1362 /* Locate array[] in flash memory */
1363 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1364
1365 int i = 1;
1366
1367 int main (void)
1368 @{
1369 /* Return 17 by reading from flash memory */
1370 return array[array[i]];
1371 @}
1372 @end smallexample
1373
1374 @noindent
1375 For each named address space supported by avr-gcc there is an equally
1376 named but uppercase built-in macro defined.
1377 The purpose is to facilitate testing if respective address space
1378 support is available or not:
1379
1380 @smallexample
1381 #ifdef __FLASH
1382 const __flash int var = 1;
1383
1384 int read_var (void)
1385 @{
1386 return var;
1387 @}
1388 #else
1389 #include <avr/pgmspace.h> /* From AVR-LibC */
1390
1391 const int var PROGMEM = 1;
1392
1393 int read_var (void)
1394 @{
1395 return (int) pgm_read_word (&var);
1396 @}
1397 #endif /* __FLASH */
1398 @end smallexample
1399
1400 @noindent
1401 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1402 locates data in flash but
1403 accesses to these data read from generic address space, i.e.@:
1404 from RAM,
1405 so that you need special accessors like @code{pgm_read_byte}
1406 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1407 together with attribute @code{progmem}.
1408
1409 @noindent
1410 @b{Limitations and caveats}
1411
1412 @itemize
1413 @item
1414 Reading across the 64@tie{}KiB section boundary of
1415 the @code{__flash} or @code{__flash@var{N}} address spaces
1416 shows undefined behavior. The only address space that
1417 supports reading across the 64@tie{}KiB flash segment boundaries is
1418 @code{__memx}.
1419
1420 @item
1421 If you use one of the @code{__flash@var{N}} address spaces
1422 you must arrange your linker script to locate the
1423 @code{.progmem@var{N}.data} sections according to your needs.
1424
1425 @item
1426 Any data or pointers to the non-generic address spaces must
1427 be qualified as @code{const}, i.e.@: as read-only data.
1428 This still applies if the data in one of these address
1429 spaces like software version number or calibration lookup table are intended to
1430 be changed after load time by, say, a boot loader. In this case
1431 the right qualification is @code{const} @code{volatile} so that the compiler
1432 must not optimize away known values or insert them
1433 as immediates into operands of instructions.
1434
1435 @item
1436 The following code initializes a variable @code{pfoo}
1437 located in static storage with a 24-bit address:
1438 @smallexample
1439 extern const __memx char foo;
1440 const __memx void *pfoo = &foo;
1441 @end smallexample
1442
1443 @noindent
1444 Such code requires at least binutils 2.23, see
1445 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1446
1447 @item
1448 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1449 Data can be put into and read from flash memory by means of
1450 attribute @code{progmem}, see @ref{AVR Variable Attributes}.
1451
1452 @end itemize
1453
1454 @subsection M32C Named Address Spaces
1455 @cindex @code{__far} M32C Named Address Spaces
1456
1457 On the M32C target, with the R8C and M16C CPU variants, variables
1458 qualified with @code{__far} are accessed using 32-bit addresses in
1459 order to access memory beyond the first 64@tie{}Ki bytes. If
1460 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1461 effect.
1462
1463 @subsection RL78 Named Address Spaces
1464 @cindex @code{__far} RL78 Named Address Spaces
1465
1466 On the RL78 target, variables qualified with @code{__far} are accessed
1467 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1468 addresses. Non-far variables are assumed to appear in the topmost
1469 64@tie{}KiB of the address space.
1470
1471 @subsection SPU Named Address Spaces
1472 @cindex @code{__ea} SPU Named Address Spaces
1473
1474 On the SPU target variables may be declared as
1475 belonging to another address space by qualifying the type with the
1476 @code{__ea} address space identifier:
1477
1478 @smallexample
1479 extern int __ea i;
1480 @end smallexample
1481
1482 @noindent
1483 The compiler generates special code to access the variable @code{i}.
1484 It may use runtime library
1485 support, or generate special machine instructions to access that address
1486 space.
1487
1488 @subsection x86 Named Address Spaces
1489 @cindex x86 named address spaces
1490
1491 On the x86 target, variables may be declared as being relative
1492 to the @code{%fs} or @code{%gs} segments.
1493
1494 @table @code
1495 @item __seg_fs
1496 @itemx __seg_gs
1497 @cindex @code{__seg_fs} x86 named address space
1498 @cindex @code{__seg_gs} x86 named address space
1499 The object is accessed with the respective segment override prefix.
1500
1501 The respective segment base must be set via some method specific to
1502 the operating system. Rather than require an expensive system call
1503 to retrieve the segment base, these address spaces are not considered
1504 to be subspaces of the generic (flat) address space. This means that
1505 explicit casts are required to convert pointers between these address
1506 spaces and the generic address space. In practice the application
1507 should cast to @code{uintptr_t} and apply the segment base offset
1508 that it installed previously.
1509
1510 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1511 defined when these address spaces are supported.
1512 @end table
1513
1514 @node Zero Length
1515 @section Arrays of Length Zero
1516 @cindex arrays of length zero
1517 @cindex zero-length arrays
1518 @cindex length-zero arrays
1519 @cindex flexible array members
1520
1521 Zero-length arrays are allowed in GNU C@. They are very useful as the
1522 last element of a structure that is really a header for a variable-length
1523 object:
1524
1525 @smallexample
1526 struct line @{
1527 int length;
1528 char contents[0];
1529 @};
1530
1531 struct line *thisline = (struct line *)
1532 malloc (sizeof (struct line) + this_length);
1533 thisline->length = this_length;
1534 @end smallexample
1535
1536 In ISO C90, you would have to give @code{contents} a length of 1, which
1537 means either you waste space or complicate the argument to @code{malloc}.
1538
1539 In ISO C99, you would use a @dfn{flexible array member}, which is
1540 slightly different in syntax and semantics:
1541
1542 @itemize @bullet
1543 @item
1544 Flexible array members are written as @code{contents[]} without
1545 the @code{0}.
1546
1547 @item
1548 Flexible array members have incomplete type, and so the @code{sizeof}
1549 operator may not be applied. As a quirk of the original implementation
1550 of zero-length arrays, @code{sizeof} evaluates to zero.
1551
1552 @item
1553 Flexible array members may only appear as the last member of a
1554 @code{struct} that is otherwise non-empty.
1555
1556 @item
1557 A structure containing a flexible array member, or a union containing
1558 such a structure (possibly recursively), may not be a member of a
1559 structure or an element of an array. (However, these uses are
1560 permitted by GCC as extensions.)
1561 @end itemize
1562
1563 Non-empty initialization of zero-length
1564 arrays is treated like any case where there are more initializer
1565 elements than the array holds, in that a suitable warning about ``excess
1566 elements in array'' is given, and the excess elements (all of them, in
1567 this case) are ignored.
1568
1569 GCC allows static initialization of flexible array members.
1570 This is equivalent to defining a new structure containing the original
1571 structure followed by an array of sufficient size to contain the data.
1572 E.g.@: in the following, @code{f1} is constructed as if it were declared
1573 like @code{f2}.
1574
1575 @smallexample
1576 struct f1 @{
1577 int x; int y[];
1578 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1579
1580 struct f2 @{
1581 struct f1 f1; int data[3];
1582 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1583 @end smallexample
1584
1585 @noindent
1586 The convenience of this extension is that @code{f1} has the desired
1587 type, eliminating the need to consistently refer to @code{f2.f1}.
1588
1589 This has symmetry with normal static arrays, in that an array of
1590 unknown size is also written with @code{[]}.
1591
1592 Of course, this extension only makes sense if the extra data comes at
1593 the end of a top-level object, as otherwise we would be overwriting
1594 data at subsequent offsets. To avoid undue complication and confusion
1595 with initialization of deeply nested arrays, we simply disallow any
1596 non-empty initialization except when the structure is the top-level
1597 object. For example:
1598
1599 @smallexample
1600 struct foo @{ int x; int y[]; @};
1601 struct bar @{ struct foo z; @};
1602
1603 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1604 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1605 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1606 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1607 @end smallexample
1608
1609 @node Empty Structures
1610 @section Structures with No Members
1611 @cindex empty structures
1612 @cindex zero-size structures
1613
1614 GCC permits a C structure to have no members:
1615
1616 @smallexample
1617 struct empty @{
1618 @};
1619 @end smallexample
1620
1621 The structure has size zero. In C++, empty structures are part
1622 of the language. G++ treats empty structures as if they had a single
1623 member of type @code{char}.
1624
1625 @node Variable Length
1626 @section Arrays of Variable Length
1627 @cindex variable-length arrays
1628 @cindex arrays of variable length
1629 @cindex VLAs
1630
1631 Variable-length automatic arrays are allowed in ISO C99, and as an
1632 extension GCC accepts them in C90 mode and in C++. These arrays are
1633 declared like any other automatic arrays, but with a length that is not
1634 a constant expression. The storage is allocated at the point of
1635 declaration and deallocated when the block scope containing the declaration
1636 exits. For
1637 example:
1638
1639 @smallexample
1640 FILE *
1641 concat_fopen (char *s1, char *s2, char *mode)
1642 @{
1643 char str[strlen (s1) + strlen (s2) + 1];
1644 strcpy (str, s1);
1645 strcat (str, s2);
1646 return fopen (str, mode);
1647 @}
1648 @end smallexample
1649
1650 @cindex scope of a variable length array
1651 @cindex variable-length array scope
1652 @cindex deallocating variable length arrays
1653 Jumping or breaking out of the scope of the array name deallocates the
1654 storage. Jumping into the scope is not allowed; you get an error
1655 message for it.
1656
1657 @cindex variable-length array in a structure
1658 As an extension, GCC accepts variable-length arrays as a member of
1659 a structure or a union. For example:
1660
1661 @smallexample
1662 void
1663 foo (int n)
1664 @{
1665 struct S @{ int x[n]; @};
1666 @}
1667 @end smallexample
1668
1669 @cindex @code{alloca} vs variable-length arrays
1670 You can use the function @code{alloca} to get an effect much like
1671 variable-length arrays. The function @code{alloca} is available in
1672 many other C implementations (but not in all). On the other hand,
1673 variable-length arrays are more elegant.
1674
1675 There are other differences between these two methods. Space allocated
1676 with @code{alloca} exists until the containing @emph{function} returns.
1677 The space for a variable-length array is deallocated as soon as the array
1678 name's scope ends, unless you also use @code{alloca} in this scope.
1679
1680 You can also use variable-length arrays as arguments to functions:
1681
1682 @smallexample
1683 struct entry
1684 tester (int len, char data[len][len])
1685 @{
1686 /* @r{@dots{}} */
1687 @}
1688 @end smallexample
1689
1690 The length of an array is computed once when the storage is allocated
1691 and is remembered for the scope of the array in case you access it with
1692 @code{sizeof}.
1693
1694 If you want to pass the array first and the length afterward, you can
1695 use a forward declaration in the parameter list---another GNU extension.
1696
1697 @smallexample
1698 struct entry
1699 tester (int len; char data[len][len], int len)
1700 @{
1701 /* @r{@dots{}} */
1702 @}
1703 @end smallexample
1704
1705 @cindex parameter forward declaration
1706 The @samp{int len} before the semicolon is a @dfn{parameter forward
1707 declaration}, and it serves the purpose of making the name @code{len}
1708 known when the declaration of @code{data} is parsed.
1709
1710 You can write any number of such parameter forward declarations in the
1711 parameter list. They can be separated by commas or semicolons, but the
1712 last one must end with a semicolon, which is followed by the ``real''
1713 parameter declarations. Each forward declaration must match a ``real''
1714 declaration in parameter name and data type. ISO C99 does not support
1715 parameter forward declarations.
1716
1717 @node Variadic Macros
1718 @section Macros with a Variable Number of Arguments.
1719 @cindex variable number of arguments
1720 @cindex macro with variable arguments
1721 @cindex rest argument (in macro)
1722 @cindex variadic macros
1723
1724 In the ISO C standard of 1999, a macro can be declared to accept a
1725 variable number of arguments much as a function can. The syntax for
1726 defining the macro is similar to that of a function. Here is an
1727 example:
1728
1729 @smallexample
1730 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1731 @end smallexample
1732
1733 @noindent
1734 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1735 such a macro, it represents the zero or more tokens until the closing
1736 parenthesis that ends the invocation, including any commas. This set of
1737 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1738 wherever it appears. See the CPP manual for more information.
1739
1740 GCC has long supported variadic macros, and used a different syntax that
1741 allowed you to give a name to the variable arguments just like any other
1742 argument. Here is an example:
1743
1744 @smallexample
1745 #define debug(format, args...) fprintf (stderr, format, args)
1746 @end smallexample
1747
1748 @noindent
1749 This is in all ways equivalent to the ISO C example above, but arguably
1750 more readable and descriptive.
1751
1752 GNU CPP has two further variadic macro extensions, and permits them to
1753 be used with either of the above forms of macro definition.
1754
1755 In standard C, you are not allowed to leave the variable argument out
1756 entirely; but you are allowed to pass an empty argument. For example,
1757 this invocation is invalid in ISO C, because there is no comma after
1758 the string:
1759
1760 @smallexample
1761 debug ("A message")
1762 @end smallexample
1763
1764 GNU CPP permits you to completely omit the variable arguments in this
1765 way. In the above examples, the compiler would complain, though since
1766 the expansion of the macro still has the extra comma after the format
1767 string.
1768
1769 To help solve this problem, CPP behaves specially for variable arguments
1770 used with the token paste operator, @samp{##}. If instead you write
1771
1772 @smallexample
1773 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1774 @end smallexample
1775
1776 @noindent
1777 and if the variable arguments are omitted or empty, the @samp{##}
1778 operator causes the preprocessor to remove the comma before it. If you
1779 do provide some variable arguments in your macro invocation, GNU CPP
1780 does not complain about the paste operation and instead places the
1781 variable arguments after the comma. Just like any other pasted macro
1782 argument, these arguments are not macro expanded.
1783
1784 @node Escaped Newlines
1785 @section Slightly Looser Rules for Escaped Newlines
1786 @cindex escaped newlines
1787 @cindex newlines (escaped)
1788
1789 The preprocessor treatment of escaped newlines is more relaxed
1790 than that specified by the C90 standard, which requires the newline
1791 to immediately follow a backslash.
1792 GCC's implementation allows whitespace in the form
1793 of spaces, horizontal and vertical tabs, and form feeds between the
1794 backslash and the subsequent newline. The preprocessor issues a
1795 warning, but treats it as a valid escaped newline and combines the two
1796 lines to form a single logical line. This works within comments and
1797 tokens, as well as between tokens. Comments are @emph{not} treated as
1798 whitespace for the purposes of this relaxation, since they have not
1799 yet been replaced with spaces.
1800
1801 @node Subscripting
1802 @section Non-Lvalue Arrays May Have Subscripts
1803 @cindex subscripting
1804 @cindex arrays, non-lvalue
1805
1806 @cindex subscripting and function values
1807 In ISO C99, arrays that are not lvalues still decay to pointers, and
1808 may be subscripted, although they may not be modified or used after
1809 the next sequence point and the unary @samp{&} operator may not be
1810 applied to them. As an extension, GNU C allows such arrays to be
1811 subscripted in C90 mode, though otherwise they do not decay to
1812 pointers outside C99 mode. For example,
1813 this is valid in GNU C though not valid in C90:
1814
1815 @smallexample
1816 @group
1817 struct foo @{int a[4];@};
1818
1819 struct foo f();
1820
1821 bar (int index)
1822 @{
1823 return f().a[index];
1824 @}
1825 @end group
1826 @end smallexample
1827
1828 @node Pointer Arith
1829 @section Arithmetic on @code{void}- and Function-Pointers
1830 @cindex void pointers, arithmetic
1831 @cindex void, size of pointer to
1832 @cindex function pointers, arithmetic
1833 @cindex function, size of pointer to
1834
1835 In GNU C, addition and subtraction operations are supported on pointers to
1836 @code{void} and on pointers to functions. This is done by treating the
1837 size of a @code{void} or of a function as 1.
1838
1839 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1840 and on function types, and returns 1.
1841
1842 @opindex Wpointer-arith
1843 The option @option{-Wpointer-arith} requests a warning if these extensions
1844 are used.
1845
1846 @node Pointers to Arrays
1847 @section Pointers to Arrays with Qualifiers Work as Expected
1848 @cindex pointers to arrays
1849 @cindex const qualifier
1850
1851 In GNU C, pointers to arrays with qualifiers work similar to pointers
1852 to other qualified types. For example, a value of type @code{int (*)[5]}
1853 can be used to initialize a variable of type @code{const int (*)[5]}.
1854 These types are incompatible in ISO C because the @code{const} qualifier
1855 is formally attached to the element type of the array and not the
1856 array itself.
1857
1858 @smallexample
1859 extern void
1860 transpose (int N, int M, double out[M][N], const double in[N][M]);
1861 double x[3][2];
1862 double y[2][3];
1863 @r{@dots{}}
1864 transpose(3, 2, y, x);
1865 @end smallexample
1866
1867 @node Initializers
1868 @section Non-Constant Initializers
1869 @cindex initializers, non-constant
1870 @cindex non-constant initializers
1871
1872 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1873 automatic variable are not required to be constant expressions in GNU C@.
1874 Here is an example of an initializer with run-time varying elements:
1875
1876 @smallexample
1877 foo (float f, float g)
1878 @{
1879 float beat_freqs[2] = @{ f-g, f+g @};
1880 /* @r{@dots{}} */
1881 @}
1882 @end smallexample
1883
1884 @node Compound Literals
1885 @section Compound Literals
1886 @cindex constructor expressions
1887 @cindex initializations in expressions
1888 @cindex structures, constructor expression
1889 @cindex expressions, constructor
1890 @cindex compound literals
1891 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1892
1893 A compound literal looks like a cast of a brace-enclosed aggregate
1894 initializer list. Its value is an object of the type specified in
1895 the cast, containing the elements specified in the initializer.
1896 Unlike the result of a cast, a compound literal is an lvalue. ISO
1897 C99 and later support compound literals. As an extension, GCC
1898 supports compound literals also in C90 mode and in C++, although
1899 as explained below, the C++ semantics are somewhat different.
1900
1901 Usually, the specified type of a compound literal is a structure. Assume
1902 that @code{struct foo} and @code{structure} are declared as shown:
1903
1904 @smallexample
1905 struct foo @{int a; char b[2];@} structure;
1906 @end smallexample
1907
1908 @noindent
1909 Here is an example of constructing a @code{struct foo} with a compound literal:
1910
1911 @smallexample
1912 structure = ((struct foo) @{x + y, 'a', 0@});
1913 @end smallexample
1914
1915 @noindent
1916 This is equivalent to writing the following:
1917
1918 @smallexample
1919 @{
1920 struct foo temp = @{x + y, 'a', 0@};
1921 structure = temp;
1922 @}
1923 @end smallexample
1924
1925 You can also construct an array, though this is dangerous in C++, as
1926 explained below. If all the elements of the compound literal are
1927 (made up of) simple constant expressions suitable for use in
1928 initializers of objects of static storage duration, then the compound
1929 literal can be coerced to a pointer to its first element and used in
1930 such an initializer, as shown here:
1931
1932 @smallexample
1933 char **foo = (char *[]) @{ "x", "y", "z" @};
1934 @end smallexample
1935
1936 Compound literals for scalar types and union types are also allowed. In
1937 the following example the variable @code{i} is initialized to the value
1938 @code{2}, the result of incrementing the unnamed object created by
1939 the compound literal.
1940
1941 @smallexample
1942 int i = ++(int) @{ 1 @};
1943 @end smallexample
1944
1945 As a GNU extension, GCC allows initialization of objects with static storage
1946 duration by compound literals (which is not possible in ISO C99 because
1947 the initializer is not a constant).
1948 It is handled as if the object were initialized only with the brace-enclosed
1949 list if the types of the compound literal and the object match.
1950 The elements of the compound literal must be constant.
1951 If the object being initialized has array type of unknown size, the size is
1952 determined by the size of the compound literal.
1953
1954 @smallexample
1955 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1956 static int y[] = (int []) @{1, 2, 3@};
1957 static int z[] = (int [3]) @{1@};
1958 @end smallexample
1959
1960 @noindent
1961 The above lines are equivalent to the following:
1962 @smallexample
1963 static struct foo x = @{1, 'a', 'b'@};
1964 static int y[] = @{1, 2, 3@};
1965 static int z[] = @{1, 0, 0@};
1966 @end smallexample
1967
1968 In C, a compound literal designates an unnamed object with static or
1969 automatic storage duration. In C++, a compound literal designates a
1970 temporary object that only lives until the end of its full-expression.
1971 As a result, well-defined C code that takes the address of a subobject
1972 of a compound literal can be undefined in C++, so G++ rejects
1973 the conversion of a temporary array to a pointer. For instance, if
1974 the array compound literal example above appeared inside a function,
1975 any subsequent use of @code{foo} in C++ would have undefined behavior
1976 because the lifetime of the array ends after the declaration of @code{foo}.
1977
1978 As an optimization, G++ sometimes gives array compound literals longer
1979 lifetimes: when the array either appears outside a function or has
1980 a @code{const}-qualified type. If @code{foo} and its initializer had
1981 elements of type @code{char *const} rather than @code{char *}, or if
1982 @code{foo} were a global variable, the array would have static storage
1983 duration. But it is probably safest just to avoid the use of array
1984 compound literals in C++ code.
1985
1986 @node Designated Inits
1987 @section Designated Initializers
1988 @cindex initializers with labeled elements
1989 @cindex labeled elements in initializers
1990 @cindex case labels in initializers
1991 @cindex designated initializers
1992
1993 Standard C90 requires the elements of an initializer to appear in a fixed
1994 order, the same as the order of the elements in the array or structure
1995 being initialized.
1996
1997 In ISO C99 you can give the elements in any order, specifying the array
1998 indices or structure field names they apply to, and GNU C allows this as
1999 an extension in C90 mode as well. This extension is not
2000 implemented in GNU C++.
2001
2002 To specify an array index, write
2003 @samp{[@var{index}] =} before the element value. For example,
2004
2005 @smallexample
2006 int a[6] = @{ [4] = 29, [2] = 15 @};
2007 @end smallexample
2008
2009 @noindent
2010 is equivalent to
2011
2012 @smallexample
2013 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2014 @end smallexample
2015
2016 @noindent
2017 The index values must be constant expressions, even if the array being
2018 initialized is automatic.
2019
2020 An alternative syntax for this that has been obsolete since GCC 2.5 but
2021 GCC still accepts is to write @samp{[@var{index}]} before the element
2022 value, with no @samp{=}.
2023
2024 To initialize a range of elements to the same value, write
2025 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2026 extension. For example,
2027
2028 @smallexample
2029 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2030 @end smallexample
2031
2032 @noindent
2033 If the value in it has side-effects, the side-effects happen only once,
2034 not for each initialized field by the range initializer.
2035
2036 @noindent
2037 Note that the length of the array is the highest value specified
2038 plus one.
2039
2040 In a structure initializer, specify the name of a field to initialize
2041 with @samp{.@var{fieldname} =} before the element value. For example,
2042 given the following structure,
2043
2044 @smallexample
2045 struct point @{ int x, y; @};
2046 @end smallexample
2047
2048 @noindent
2049 the following initialization
2050
2051 @smallexample
2052 struct point p = @{ .y = yvalue, .x = xvalue @};
2053 @end smallexample
2054
2055 @noindent
2056 is equivalent to
2057
2058 @smallexample
2059 struct point p = @{ xvalue, yvalue @};
2060 @end smallexample
2061
2062 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2063 @samp{@var{fieldname}:}, as shown here:
2064
2065 @smallexample
2066 struct point p = @{ y: yvalue, x: xvalue @};
2067 @end smallexample
2068
2069 Omitted field members are implicitly initialized the same as objects
2070 that have static storage duration.
2071
2072 @cindex designators
2073 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2074 @dfn{designator}. You can also use a designator (or the obsolete colon
2075 syntax) when initializing a union, to specify which element of the union
2076 should be used. For example,
2077
2078 @smallexample
2079 union foo @{ int i; double d; @};
2080
2081 union foo f = @{ .d = 4 @};
2082 @end smallexample
2083
2084 @noindent
2085 converts 4 to a @code{double} to store it in the union using
2086 the second element. By contrast, casting 4 to type @code{union foo}
2087 stores it into the union as the integer @code{i}, since it is
2088 an integer. (@xref{Cast to Union}.)
2089
2090 You can combine this technique of naming elements with ordinary C
2091 initialization of successive elements. Each initializer element that
2092 does not have a designator applies to the next consecutive element of the
2093 array or structure. For example,
2094
2095 @smallexample
2096 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2097 @end smallexample
2098
2099 @noindent
2100 is equivalent to
2101
2102 @smallexample
2103 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2104 @end smallexample
2105
2106 Labeling the elements of an array initializer is especially useful
2107 when the indices are characters or belong to an @code{enum} type.
2108 For example:
2109
2110 @smallexample
2111 int whitespace[256]
2112 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2113 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2114 @end smallexample
2115
2116 @cindex designator lists
2117 You can also write a series of @samp{.@var{fieldname}} and
2118 @samp{[@var{index}]} designators before an @samp{=} to specify a
2119 nested subobject to initialize; the list is taken relative to the
2120 subobject corresponding to the closest surrounding brace pair. For
2121 example, with the @samp{struct point} declaration above:
2122
2123 @smallexample
2124 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2125 @end smallexample
2126
2127 @noindent
2128 If the same field is initialized multiple times, it has the value from
2129 the last initialization. If any such overridden initialization has
2130 side-effect, it is unspecified whether the side-effect happens or not.
2131 Currently, GCC discards them and issues a warning.
2132
2133 @node Case Ranges
2134 @section Case Ranges
2135 @cindex case ranges
2136 @cindex ranges in case statements
2137
2138 You can specify a range of consecutive values in a single @code{case} label,
2139 like this:
2140
2141 @smallexample
2142 case @var{low} ... @var{high}:
2143 @end smallexample
2144
2145 @noindent
2146 This has the same effect as the proper number of individual @code{case}
2147 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2148
2149 This feature is especially useful for ranges of ASCII character codes:
2150
2151 @smallexample
2152 case 'A' ... 'Z':
2153 @end smallexample
2154
2155 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2156 it may be parsed wrong when you use it with integer values. For example,
2157 write this:
2158
2159 @smallexample
2160 case 1 ... 5:
2161 @end smallexample
2162
2163 @noindent
2164 rather than this:
2165
2166 @smallexample
2167 case 1...5:
2168 @end smallexample
2169
2170 @node Cast to Union
2171 @section Cast to a Union Type
2172 @cindex cast to a union
2173 @cindex union, casting to a
2174
2175 A cast to union type looks similar to other casts, except that the type
2176 specified is a union type. You can specify the type either with the
2177 @code{union} keyword or with a @code{typedef} name that refers to
2178 a union. A cast to a union actually creates a compound literal and
2179 yields an lvalue, not an rvalue like true casts do.
2180 (@xref{Compound Literals}.)
2181
2182 The types that may be cast to the union type are those of the members
2183 of the union. Thus, given the following union and variables:
2184
2185 @smallexample
2186 union foo @{ int i; double d; @};
2187 int x;
2188 double y;
2189 @end smallexample
2190
2191 @noindent
2192 both @code{x} and @code{y} can be cast to type @code{union foo}.
2193
2194 Using the cast as the right-hand side of an assignment to a variable of
2195 union type is equivalent to storing in a member of the union:
2196
2197 @smallexample
2198 union foo u;
2199 /* @r{@dots{}} */
2200 u = (union foo) x @equiv{} u.i = x
2201 u = (union foo) y @equiv{} u.d = y
2202 @end smallexample
2203
2204 You can also use the union cast as a function argument:
2205
2206 @smallexample
2207 void hack (union foo);
2208 /* @r{@dots{}} */
2209 hack ((union foo) x);
2210 @end smallexample
2211
2212 @node Mixed Declarations
2213 @section Mixed Declarations and Code
2214 @cindex mixed declarations and code
2215 @cindex declarations, mixed with code
2216 @cindex code, mixed with declarations
2217
2218 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2219 within compound statements. As an extension, GNU C also allows this in
2220 C90 mode. For example, you could do:
2221
2222 @smallexample
2223 int i;
2224 /* @r{@dots{}} */
2225 i++;
2226 int j = i + 2;
2227 @end smallexample
2228
2229 Each identifier is visible from where it is declared until the end of
2230 the enclosing block.
2231
2232 @node Function Attributes
2233 @section Declaring Attributes of Functions
2234 @cindex function attributes
2235 @cindex declaring attributes of functions
2236 @cindex @code{volatile} applied to function
2237 @cindex @code{const} applied to function
2238
2239 In GNU C, you can use function attributes to declare certain things
2240 about functions called in your program which help the compiler
2241 optimize calls and check your code more carefully. For example, you
2242 can use attributes to declare that a function never returns
2243 (@code{noreturn}), returns a value depending only on its arguments
2244 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2245
2246 You can also use attributes to control memory placement, code
2247 generation options or call/return conventions within the function
2248 being annotated. Many of these attributes are target-specific. For
2249 example, many targets support attributes for defining interrupt
2250 handler functions, which typically must follow special register usage
2251 and return conventions.
2252
2253 Function attributes are introduced by the @code{__attribute__} keyword
2254 on a declaration, followed by an attribute specification inside double
2255 parentheses. You can specify multiple attributes in a declaration by
2256 separating them by commas within the double parentheses or by
2257 immediately following an attribute declaration with another attribute
2258 declaration. @xref{Attribute Syntax}, for the exact rules on
2259 attribute syntax and placement.
2260
2261 GCC also supports attributes on
2262 variable declarations (@pxref{Variable Attributes}),
2263 labels (@pxref{Label Attributes}),
2264 enumerators (@pxref{Enumerator Attributes}),
2265 statements (@pxref{Statement Attributes}),
2266 and types (@pxref{Type Attributes}).
2267
2268 There is some overlap between the purposes of attributes and pragmas
2269 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2270 found convenient to use @code{__attribute__} to achieve a natural
2271 attachment of attributes to their corresponding declarations, whereas
2272 @code{#pragma} is of use for compatibility with other compilers
2273 or constructs that do not naturally form part of the grammar.
2274
2275 In addition to the attributes documented here,
2276 GCC plugins may provide their own attributes.
2277
2278 @menu
2279 * Common Function Attributes::
2280 * AArch64 Function Attributes::
2281 * ARC Function Attributes::
2282 * ARM Function Attributes::
2283 * AVR Function Attributes::
2284 * Blackfin Function Attributes::
2285 * CR16 Function Attributes::
2286 * Epiphany Function Attributes::
2287 * H8/300 Function Attributes::
2288 * IA-64 Function Attributes::
2289 * M32C Function Attributes::
2290 * M32R/D Function Attributes::
2291 * m68k Function Attributes::
2292 * MCORE Function Attributes::
2293 * MeP Function Attributes::
2294 * MicroBlaze Function Attributes::
2295 * Microsoft Windows Function Attributes::
2296 * MIPS Function Attributes::
2297 * MSP430 Function Attributes::
2298 * NDS32 Function Attributes::
2299 * Nios II Function Attributes::
2300 * Nvidia PTX Function Attributes::
2301 * PowerPC Function Attributes::
2302 * RL78 Function Attributes::
2303 * RX Function Attributes::
2304 * S/390 Function Attributes::
2305 * SH Function Attributes::
2306 * SPU Function Attributes::
2307 * Symbian OS Function Attributes::
2308 * V850 Function Attributes::
2309 * Visium Function Attributes::
2310 * x86 Function Attributes::
2311 * Xstormy16 Function Attributes::
2312 @end menu
2313
2314 @node Common Function Attributes
2315 @subsection Common Function Attributes
2316
2317 The following attributes are supported on most targets.
2318
2319 @table @code
2320 @c Keep this table alphabetized by attribute name. Treat _ as space.
2321
2322 @item alias ("@var{target}")
2323 @cindex @code{alias} function attribute
2324 The @code{alias} attribute causes the declaration to be emitted as an
2325 alias for another symbol, which must be specified. For instance,
2326
2327 @smallexample
2328 void __f () @{ /* @r{Do something.} */; @}
2329 void f () __attribute__ ((weak, alias ("__f")));
2330 @end smallexample
2331
2332 @noindent
2333 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2334 mangled name for the target must be used. It is an error if @samp{__f}
2335 is not defined in the same translation unit.
2336
2337 This attribute requires assembler and object file support,
2338 and may not be available on all targets.
2339
2340 @item aligned (@var{alignment})
2341 @cindex @code{aligned} function attribute
2342 This attribute specifies a minimum alignment for the function,
2343 measured in bytes.
2344
2345 You cannot use this attribute to decrease the alignment of a function,
2346 only to increase it. However, when you explicitly specify a function
2347 alignment this overrides the effect of the
2348 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2349 function.
2350
2351 Note that the effectiveness of @code{aligned} attributes may be
2352 limited by inherent limitations in your linker. On many systems, the
2353 linker is only able to arrange for functions to be aligned up to a
2354 certain maximum alignment. (For some linkers, the maximum supported
2355 alignment may be very very small.) See your linker documentation for
2356 further information.
2357
2358 The @code{aligned} attribute can also be used for variables and fields
2359 (@pxref{Variable Attributes}.)
2360
2361 @item alloc_align
2362 @cindex @code{alloc_align} function attribute
2363 The @code{alloc_align} attribute is used to tell the compiler that the
2364 function return value points to memory, where the returned pointer minimum
2365 alignment is given by one of the functions parameters. GCC uses this
2366 information to improve pointer alignment analysis.
2367
2368 The function parameter denoting the allocated alignment is specified by
2369 one integer argument, whose number is the argument of the attribute.
2370 Argument numbering starts at one.
2371
2372 For instance,
2373
2374 @smallexample
2375 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2376 @end smallexample
2377
2378 @noindent
2379 declares that @code{my_memalign} returns memory with minimum alignment
2380 given by parameter 1.
2381
2382 @item alloc_size
2383 @cindex @code{alloc_size} function attribute
2384 The @code{alloc_size} attribute is used to tell the compiler that the
2385 function return value points to memory, where the size is given by
2386 one or two of the functions parameters. GCC uses this
2387 information to improve the correctness of @code{__builtin_object_size}.
2388
2389 The function parameter(s) denoting the allocated size are specified by
2390 one or two integer arguments supplied to the attribute. The allocated size
2391 is either the value of the single function argument specified or the product
2392 of the two function arguments specified. Argument numbering starts at
2393 one.
2394
2395 For instance,
2396
2397 @smallexample
2398 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2399 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2400 @end smallexample
2401
2402 @noindent
2403 declares that @code{my_calloc} returns memory of the size given by
2404 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2405 of the size given by parameter 2.
2406
2407 @item always_inline
2408 @cindex @code{always_inline} function attribute
2409 Generally, functions are not inlined unless optimization is specified.
2410 For functions declared inline, this attribute inlines the function
2411 independent of any restrictions that otherwise apply to inlining.
2412 Failure to inline such a function is diagnosed as an error.
2413 Note that if such a function is called indirectly the compiler may
2414 or may not inline it depending on optimization level and a failure
2415 to inline an indirect call may or may not be diagnosed.
2416
2417 @item artificial
2418 @cindex @code{artificial} function attribute
2419 This attribute is useful for small inline wrappers that if possible
2420 should appear during debugging as a unit. Depending on the debug
2421 info format it either means marking the function as artificial
2422 or using the caller location for all instructions within the inlined
2423 body.
2424
2425 @item assume_aligned
2426 @cindex @code{assume_aligned} function attribute
2427 The @code{assume_aligned} attribute is used to tell the compiler that the
2428 function return value points to memory, where the returned pointer minimum
2429 alignment is given by the first argument.
2430 If the attribute has two arguments, the second argument is misalignment offset.
2431
2432 For instance
2433
2434 @smallexample
2435 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2436 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2437 @end smallexample
2438
2439 @noindent
2440 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2441 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2442 to 8.
2443
2444 @item bnd_instrument
2445 @cindex @code{bnd_instrument} function attribute
2446 The @code{bnd_instrument} attribute on functions is used to inform the
2447 compiler that the function should be instrumented when compiled
2448 with the @option{-fchkp-instrument-marked-only} option.
2449
2450 @item bnd_legacy
2451 @cindex @code{bnd_legacy} function attribute
2452 @cindex Pointer Bounds Checker attributes
2453 The @code{bnd_legacy} attribute on functions is used to inform the
2454 compiler that the function should not be instrumented when compiled
2455 with the @option{-fcheck-pointer-bounds} option.
2456
2457 @item cold
2458 @cindex @code{cold} function attribute
2459 The @code{cold} attribute on functions is used to inform the compiler that
2460 the function is unlikely to be executed. The function is optimized for
2461 size rather than speed and on many targets it is placed into a special
2462 subsection of the text section so all cold functions appear close together,
2463 improving code locality of non-cold parts of program. The paths leading
2464 to calls of cold functions within code are marked as unlikely by the branch
2465 prediction mechanism. It is thus useful to mark functions used to handle
2466 unlikely conditions, such as @code{perror}, as cold to improve optimization
2467 of hot functions that do call marked functions in rare occasions.
2468
2469 When profile feedback is available, via @option{-fprofile-use}, cold functions
2470 are automatically detected and this attribute is ignored.
2471
2472 @item const
2473 @cindex @code{const} function attribute
2474 @cindex functions that have no side effects
2475 Many functions do not examine any values except their arguments, and
2476 have no effects except the return value. Basically this is just slightly
2477 more strict class than the @code{pure} attribute below, since function is not
2478 allowed to read global memory.
2479
2480 @cindex pointer arguments
2481 Note that a function that has pointer arguments and examines the data
2482 pointed to must @emph{not} be declared @code{const}. Likewise, a
2483 function that calls a non-@code{const} function usually must not be
2484 @code{const}. It does not make sense for a @code{const} function to
2485 return @code{void}.
2486
2487 @item constructor
2488 @itemx destructor
2489 @itemx constructor (@var{priority})
2490 @itemx destructor (@var{priority})
2491 @cindex @code{constructor} function attribute
2492 @cindex @code{destructor} function attribute
2493 The @code{constructor} attribute causes the function to be called
2494 automatically before execution enters @code{main ()}. Similarly, the
2495 @code{destructor} attribute causes the function to be called
2496 automatically after @code{main ()} completes or @code{exit ()} is
2497 called. Functions with these attributes are useful for
2498 initializing data that is used implicitly during the execution of
2499 the program.
2500
2501 You may provide an optional integer priority to control the order in
2502 which constructor and destructor functions are run. A constructor
2503 with a smaller priority number runs before a constructor with a larger
2504 priority number; the opposite relationship holds for destructors. So,
2505 if you have a constructor that allocates a resource and a destructor
2506 that deallocates the same resource, both functions typically have the
2507 same priority. The priorities for constructor and destructor
2508 functions are the same as those specified for namespace-scope C++
2509 objects (@pxref{C++ Attributes}).
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 ieee-fp
5485 @itemx no-ieee-fp
5486 @cindex @code{target("ieee-fp")} function attribute, x86
5487 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5488
5489 @item inline-all-stringops
5490 @itemx no-inline-all-stringops
5491 @cindex @code{target("inline-all-stringops")} function attribute, x86
5492 Enable/disable inlining of string operations.
5493
5494 @item inline-stringops-dynamically
5495 @itemx no-inline-stringops-dynamically
5496 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5497 Enable/disable the generation of the inline code to do small string
5498 operations and calling the library routines for large operations.
5499
5500 @item align-stringops
5501 @itemx no-align-stringops
5502 @cindex @code{target("align-stringops")} function attribute, x86
5503 Do/do not align destination of inlined string operations.
5504
5505 @item recip
5506 @itemx no-recip
5507 @cindex @code{target("recip")} function attribute, x86
5508 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5509 instructions followed an additional Newton-Raphson step instead of
5510 doing a floating-point division.
5511
5512 @item arch=@var{ARCH}
5513 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5514 Specify the architecture to generate code for in compiling the function.
5515
5516 @item tune=@var{TUNE}
5517 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5518 Specify the architecture to tune for in compiling the function.
5519
5520 @item fpmath=@var{FPMATH}
5521 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5522 Specify which floating-point unit to use. You must specify the
5523 @code{target("fpmath=sse,387")} option as
5524 @code{target("fpmath=sse+387")} because the comma would separate
5525 different options.
5526 @end table
5527
5528 On the x86, the inliner does not inline a
5529 function that has different target options than the caller, unless the
5530 callee has a subset of the target options of the caller. For example
5531 a function declared with @code{target("sse3")} can inline a function
5532 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5533 @end table
5534
5535 @node Xstormy16 Function Attributes
5536 @subsection Xstormy16 Function Attributes
5537
5538 These function attributes are supported by the Xstormy16 back end:
5539
5540 @table @code
5541 @item interrupt
5542 @cindex @code{interrupt} function attribute, Xstormy16
5543 Use this attribute to indicate
5544 that the specified function is an interrupt handler. The compiler generates
5545 function entry and exit sequences suitable for use in an interrupt handler
5546 when this attribute is present.
5547 @end table
5548
5549 @node Variable Attributes
5550 @section Specifying Attributes of Variables
5551 @cindex attribute of variables
5552 @cindex variable attributes
5553
5554 The keyword @code{__attribute__} allows you to specify special
5555 attributes of variables or structure fields. This keyword is followed
5556 by an attribute specification inside double parentheses. Some
5557 attributes are currently defined generically for variables.
5558 Other attributes are defined for variables on particular target
5559 systems. Other attributes are available for functions
5560 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5561 enumerators (@pxref{Enumerator Attributes}), statements
5562 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5563 Other front ends might define more attributes
5564 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5565
5566 @xref{Attribute Syntax}, for details of the exact syntax for using
5567 attributes.
5568
5569 @menu
5570 * Common Variable Attributes::
5571 * AVR Variable Attributes::
5572 * Blackfin Variable Attributes::
5573 * H8/300 Variable Attributes::
5574 * IA-64 Variable Attributes::
5575 * M32R/D Variable Attributes::
5576 * MeP Variable Attributes::
5577 * Microsoft Windows Variable Attributes::
5578 * MSP430 Variable Attributes::
5579 * PowerPC Variable Attributes::
5580 * RL78 Variable Attributes::
5581 * SPU Variable Attributes::
5582 * V850 Variable Attributes::
5583 * x86 Variable Attributes::
5584 * Xstormy16 Variable Attributes::
5585 @end menu
5586
5587 @node Common Variable Attributes
5588 @subsection Common Variable Attributes
5589
5590 The following attributes are supported on most targets.
5591
5592 @table @code
5593 @cindex @code{aligned} variable attribute
5594 @item aligned (@var{alignment})
5595 This attribute specifies a minimum alignment for the variable or
5596 structure field, measured in bytes. For example, the declaration:
5597
5598 @smallexample
5599 int x __attribute__ ((aligned (16))) = 0;
5600 @end smallexample
5601
5602 @noindent
5603 causes the compiler to allocate the global variable @code{x} on a
5604 16-byte boundary. On a 68040, this could be used in conjunction with
5605 an @code{asm} expression to access the @code{move16} instruction which
5606 requires 16-byte aligned operands.
5607
5608 You can also specify the alignment of structure fields. For example, to
5609 create a double-word aligned @code{int} pair, you could write:
5610
5611 @smallexample
5612 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5613 @end smallexample
5614
5615 @noindent
5616 This is an alternative to creating a union with a @code{double} member,
5617 which forces the union to be double-word aligned.
5618
5619 As in the preceding examples, you can explicitly specify the alignment
5620 (in bytes) that you wish the compiler to use for a given variable or
5621 structure field. Alternatively, you can leave out the alignment factor
5622 and just ask the compiler to align a variable or field to the
5623 default alignment for the target architecture you are compiling for.
5624 The default alignment is sufficient for all scalar types, but may not be
5625 enough for all vector types on a target that supports vector operations.
5626 The default alignment is fixed for a particular target ABI.
5627
5628 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5629 which is the largest alignment ever used for any data type on the
5630 target machine you are compiling for. For example, you could write:
5631
5632 @smallexample
5633 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5634 @end smallexample
5635
5636 The compiler automatically sets the alignment for the declared
5637 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5638 often make copy operations more efficient, because the compiler can
5639 use whatever instructions copy the biggest chunks of memory when
5640 performing copies to or from the variables or fields that you have
5641 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5642 may change depending on command-line options.
5643
5644 When used on a struct, or struct member, the @code{aligned} attribute can
5645 only increase the alignment; in order to decrease it, the @code{packed}
5646 attribute must be specified as well. When used as part of a typedef, the
5647 @code{aligned} attribute can both increase and decrease alignment, and
5648 specifying the @code{packed} attribute generates a warning.
5649
5650 Note that the effectiveness of @code{aligned} attributes may be limited
5651 by inherent limitations in your linker. On many systems, the linker is
5652 only able to arrange for variables to be aligned up to a certain maximum
5653 alignment. (For some linkers, the maximum supported alignment may
5654 be very very small.) If your linker is only able to align variables
5655 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5656 in an @code{__attribute__} still only provides you with 8-byte
5657 alignment. See your linker documentation for further information.
5658
5659 The @code{aligned} attribute can also be used for functions
5660 (@pxref{Common Function Attributes}.)
5661
5662 @item cleanup (@var{cleanup_function})
5663 @cindex @code{cleanup} variable attribute
5664 The @code{cleanup} attribute runs a function when the variable goes
5665 out of scope. This attribute can only be applied to auto function
5666 scope variables; it may not be applied to parameters or variables
5667 with static storage duration. The function must take one parameter,
5668 a pointer to a type compatible with the variable. The return value
5669 of the function (if any) is ignored.
5670
5671 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5672 is run during the stack unwinding that happens during the
5673 processing of the exception. Note that the @code{cleanup} attribute
5674 does not allow the exception to be caught, only to perform an action.
5675 It is undefined what happens if @var{cleanup_function} does not
5676 return normally.
5677
5678 @item common
5679 @itemx nocommon
5680 @cindex @code{common} variable attribute
5681 @cindex @code{nocommon} variable attribute
5682 @opindex fcommon
5683 @opindex fno-common
5684 The @code{common} attribute requests GCC to place a variable in
5685 ``common'' storage. The @code{nocommon} attribute requests the
5686 opposite---to allocate space for it directly.
5687
5688 These attributes override the default chosen by the
5689 @option{-fno-common} and @option{-fcommon} flags respectively.
5690
5691 @item deprecated
5692 @itemx deprecated (@var{msg})
5693 @cindex @code{deprecated} variable attribute
5694 The @code{deprecated} attribute results in a warning if the variable
5695 is used anywhere in the source file. This is useful when identifying
5696 variables that are expected to be removed in a future version of a
5697 program. The warning also includes the location of the declaration
5698 of the deprecated variable, to enable users to easily find further
5699 information about why the variable is deprecated, or what they should
5700 do instead. Note that the warning only occurs for uses:
5701
5702 @smallexample
5703 extern int old_var __attribute__ ((deprecated));
5704 extern int old_var;
5705 int new_fn () @{ return old_var; @}
5706 @end smallexample
5707
5708 @noindent
5709 results in a warning on line 3 but not line 2. The optional @var{msg}
5710 argument, which must be a string, is printed in the warning if
5711 present.
5712
5713 The @code{deprecated} attribute can also be used for functions and
5714 types (@pxref{Common Function Attributes},
5715 @pxref{Common Type Attributes}).
5716
5717 @item mode (@var{mode})
5718 @cindex @code{mode} variable attribute
5719 This attribute specifies the data type for the declaration---whichever
5720 type corresponds to the mode @var{mode}. This in effect lets you
5721 request an integer or floating-point type according to its width.
5722
5723 You may also specify a mode of @code{byte} or @code{__byte__} to
5724 indicate the mode corresponding to a one-byte integer, @code{word} or
5725 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5726 or @code{__pointer__} for the mode used to represent pointers.
5727
5728 @item packed
5729 @cindex @code{packed} variable attribute
5730 The @code{packed} attribute specifies that a variable or structure field
5731 should have the smallest possible alignment---one byte for a variable,
5732 and one bit for a field, unless you specify a larger value with the
5733 @code{aligned} attribute.
5734
5735 Here is a structure in which the field @code{x} is packed, so that it
5736 immediately follows @code{a}:
5737
5738 @smallexample
5739 struct foo
5740 @{
5741 char a;
5742 int x[2] __attribute__ ((packed));
5743 @};
5744 @end smallexample
5745
5746 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5747 @code{packed} attribute on bit-fields of type @code{char}. This has
5748 been fixed in GCC 4.4 but the change can lead to differences in the
5749 structure layout. See the documentation of
5750 @option{-Wpacked-bitfield-compat} for more information.
5751
5752 @item section ("@var{section-name}")
5753 @cindex @code{section} variable attribute
5754 Normally, the compiler places the objects it generates in sections like
5755 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5756 or you need certain particular variables to appear in special sections,
5757 for example to map to special hardware. The @code{section}
5758 attribute specifies that a variable (or function) lives in a particular
5759 section. For example, this small program uses several specific section names:
5760
5761 @smallexample
5762 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5763 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5764 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5765 int init_data __attribute__ ((section ("INITDATA")));
5766
5767 main()
5768 @{
5769 /* @r{Initialize stack pointer} */
5770 init_sp (stack + sizeof (stack));
5771
5772 /* @r{Initialize initialized data} */
5773 memcpy (&init_data, &data, &edata - &data);
5774
5775 /* @r{Turn on the serial ports} */
5776 init_duart (&a);
5777 init_duart (&b);
5778 @}
5779 @end smallexample
5780
5781 @noindent
5782 Use the @code{section} attribute with
5783 @emph{global} variables and not @emph{local} variables,
5784 as shown in the example.
5785
5786 You may use the @code{section} attribute with initialized or
5787 uninitialized global variables but the linker requires
5788 each object be defined once, with the exception that uninitialized
5789 variables tentatively go in the @code{common} (or @code{bss}) section
5790 and can be multiply ``defined''. Using the @code{section} attribute
5791 changes what section the variable goes into and may cause the
5792 linker to issue an error if an uninitialized variable has multiple
5793 definitions. You can force a variable to be initialized with the
5794 @option{-fno-common} flag or the @code{nocommon} attribute.
5795
5796 Some file formats do not support arbitrary sections so the @code{section}
5797 attribute is not available on all platforms.
5798 If you need to map the entire contents of a module to a particular
5799 section, consider using the facilities of the linker instead.
5800
5801 @item tls_model ("@var{tls_model}")
5802 @cindex @code{tls_model} variable attribute
5803 The @code{tls_model} attribute sets thread-local storage model
5804 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5805 overriding @option{-ftls-model=} command-line switch on a per-variable
5806 basis.
5807 The @var{tls_model} argument should be one of @code{global-dynamic},
5808 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5809
5810 Not all targets support this attribute.
5811
5812 @item unused
5813 @cindex @code{unused} variable attribute
5814 This attribute, attached to a variable, means that the variable is meant
5815 to be possibly unused. GCC does not produce a warning for this
5816 variable.
5817
5818 @item used
5819 @cindex @code{used} variable attribute
5820 This attribute, attached to a variable with static storage, means that
5821 the variable must be emitted even if it appears that the variable is not
5822 referenced.
5823
5824 When applied to a static data member of a C++ class template, the
5825 attribute also means that the member is instantiated if the
5826 class itself is instantiated.
5827
5828 @item vector_size (@var{bytes})
5829 @cindex @code{vector_size} variable attribute
5830 This attribute specifies the vector size for the variable, measured in
5831 bytes. For example, the declaration:
5832
5833 @smallexample
5834 int foo __attribute__ ((vector_size (16)));
5835 @end smallexample
5836
5837 @noindent
5838 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5839 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5840 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5841
5842 This attribute is only applicable to integral and float scalars,
5843 although arrays, pointers, and function return values are allowed in
5844 conjunction with this construct.
5845
5846 Aggregates with this attribute are invalid, even if they are of the same
5847 size as a corresponding scalar. For example, the declaration:
5848
5849 @smallexample
5850 struct S @{ int a; @};
5851 struct S __attribute__ ((vector_size (16))) foo;
5852 @end smallexample
5853
5854 @noindent
5855 is invalid even if the size of the structure is the same as the size of
5856 the @code{int}.
5857
5858 @item visibility ("@var{visibility_type}")
5859 @cindex @code{visibility} variable attribute
5860 This attribute affects the linkage of the declaration to which it is attached.
5861 The @code{visibility} attribute is described in
5862 @ref{Common Function Attributes}.
5863
5864 @item weak
5865 @cindex @code{weak} variable attribute
5866 The @code{weak} attribute is described in
5867 @ref{Common Function Attributes}.
5868
5869 @end table
5870
5871 @node AVR Variable Attributes
5872 @subsection AVR Variable Attributes
5873
5874 @table @code
5875 @item progmem
5876 @cindex @code{progmem} variable attribute, AVR
5877 The @code{progmem} attribute is used on the AVR to place read-only
5878 data in the non-volatile program memory (flash). The @code{progmem}
5879 attribute accomplishes this by putting respective variables into a
5880 section whose name starts with @code{.progmem}.
5881
5882 This attribute works similar to the @code{section} attribute
5883 but adds additional checking.
5884
5885 @table @asis
5886 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
5887 @code{progmem} affects the location
5888 of the data but not how this data is accessed.
5889 In order to read data located with the @code{progmem} attribute
5890 (inline) assembler must be used.
5891 @smallexample
5892 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5893 #include <avr/pgmspace.h>
5894
5895 /* Locate var in flash memory */
5896 const int var[2] PROGMEM = @{ 1, 2 @};
5897
5898 int read_var (int i)
5899 @{
5900 /* Access var[] by accessor macro from avr/pgmspace.h */
5901 return (int) pgm_read_word (& var[i]);
5902 @}
5903 @end smallexample
5904
5905 AVR is a Harvard architecture processor and data and read-only data
5906 normally resides in the data memory (RAM).
5907
5908 See also the @ref{AVR Named Address Spaces} section for
5909 an alternate way to locate and access data in flash memory.
5910
5911 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
5912 The compiler adds @code{0x4000}
5913 to the addresses of objects and declarations in @code{progmem} and locates
5914 the objects in flash memory, namely in section @code{.progmem.data}.
5915 The offset is needed because the flash memory is visible in the RAM
5916 address space starting at address @code{0x4000}.
5917
5918 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
5919 no special functions or macros are needed.
5920
5921 @smallexample
5922 /* var is located in flash memory */
5923 extern const int var[2] __attribute__((progmem));
5924
5925 int read_var (int i)
5926 @{
5927 return var[i];
5928 @}
5929 @end smallexample
5930
5931 @end table
5932
5933 @item io
5934 @itemx io (@var{addr})
5935 @cindex @code{io} variable attribute, AVR
5936 Variables with the @code{io} attribute are used to address
5937 memory-mapped peripherals in the io address range.
5938 If an address is specified, the variable
5939 is assigned that address, and the value is interpreted as an
5940 address in the data address space.
5941 Example:
5942
5943 @smallexample
5944 volatile int porta __attribute__((io (0x22)));
5945 @end smallexample
5946
5947 The address specified in the address in the data address range.
5948
5949 Otherwise, the variable it is not assigned an address, but the
5950 compiler will still use in/out instructions where applicable,
5951 assuming some other module assigns an address in the io address range.
5952 Example:
5953
5954 @smallexample
5955 extern volatile int porta __attribute__((io));
5956 @end smallexample
5957
5958 @item io_low
5959 @itemx io_low (@var{addr})
5960 @cindex @code{io_low} variable attribute, AVR
5961 This is like the @code{io} attribute, but additionally it informs the
5962 compiler that the object lies in the lower half of the I/O area,
5963 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5964 instructions.
5965
5966 @item address
5967 @itemx address (@var{addr})
5968 @cindex @code{address} variable attribute, AVR
5969 Variables with the @code{address} attribute are used to address
5970 memory-mapped peripherals that may lie outside the io address range.
5971
5972 @smallexample
5973 volatile int porta __attribute__((address (0x600)));
5974 @end smallexample
5975
5976 @end table
5977
5978 @node Blackfin Variable Attributes
5979 @subsection Blackfin Variable Attributes
5980
5981 Three attributes are currently defined for the Blackfin.
5982
5983 @table @code
5984 @item l1_data
5985 @itemx l1_data_A
5986 @itemx l1_data_B
5987 @cindex @code{l1_data} variable attribute, Blackfin
5988 @cindex @code{l1_data_A} variable attribute, Blackfin
5989 @cindex @code{l1_data_B} variable attribute, Blackfin
5990 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5991 Variables with @code{l1_data} attribute are put into the specific section
5992 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5993 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5994 attribute are put into the specific section named @code{.l1.data.B}.
5995
5996 @item l2
5997 @cindex @code{l2} variable attribute, Blackfin
5998 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5999 Variables with @code{l2} attribute are put into the specific section
6000 named @code{.l2.data}.
6001 @end table
6002
6003 @node H8/300 Variable Attributes
6004 @subsection H8/300 Variable Attributes
6005
6006 These variable attributes are available for H8/300 targets:
6007
6008 @table @code
6009 @item eightbit_data
6010 @cindex @code{eightbit_data} variable attribute, H8/300
6011 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6012 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6013 variable should be placed into the eight-bit data section.
6014 The compiler generates more efficient code for certain operations
6015 on data in the eight-bit data area. Note the eight-bit data area is limited to
6016 256 bytes of data.
6017
6018 You must use GAS and GLD from GNU binutils version 2.7 or later for
6019 this attribute to work correctly.
6020
6021 @item tiny_data
6022 @cindex @code{tiny_data} variable attribute, H8/300
6023 @cindex tiny data section on the H8/300H and H8S
6024 Use this attribute on the H8/300H and H8S to indicate that the specified
6025 variable should be placed into the tiny data section.
6026 The compiler generates more efficient code for loads and stores
6027 on data in the tiny data section. Note the tiny data area is limited to
6028 slightly under 32KB of data.
6029
6030 @end table
6031
6032 @node IA-64 Variable Attributes
6033 @subsection IA-64 Variable Attributes
6034
6035 The IA-64 back end supports the following variable attribute:
6036
6037 @table @code
6038 @item model (@var{model-name})
6039 @cindex @code{model} variable attribute, IA-64
6040
6041 On IA-64, use this attribute to set the addressability of an object.
6042 At present, the only supported identifier for @var{model-name} is
6043 @code{small}, indicating addressability via ``small'' (22-bit)
6044 addresses (so that their addresses can be loaded with the @code{addl}
6045 instruction). Caveat: such addressing is by definition not position
6046 independent and hence this attribute must not be used for objects
6047 defined by shared libraries.
6048
6049 @end table
6050
6051 @node M32R/D Variable Attributes
6052 @subsection M32R/D Variable Attributes
6053
6054 One attribute is currently defined for the M32R/D@.
6055
6056 @table @code
6057 @item model (@var{model-name})
6058 @cindex @code{model-name} variable attribute, M32R/D
6059 @cindex variable addressability on the M32R/D
6060 Use this attribute on the M32R/D to set the addressability of an object.
6061 The identifier @var{model-name} is one of @code{small}, @code{medium},
6062 or @code{large}, representing each of the code models.
6063
6064 Small model objects live in the lower 16MB of memory (so that their
6065 addresses can be loaded with the @code{ld24} instruction).
6066
6067 Medium and large model objects may live anywhere in the 32-bit address space
6068 (the compiler generates @code{seth/add3} instructions to load their
6069 addresses).
6070 @end table
6071
6072 @node MeP Variable Attributes
6073 @subsection MeP Variable Attributes
6074
6075 The MeP target has a number of addressing modes and busses. The
6076 @code{near} space spans the standard memory space's first 16 megabytes
6077 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6078 The @code{based} space is a 128-byte region in the memory space that
6079 is addressed relative to the @code{$tp} register. The @code{tiny}
6080 space is a 65536-byte region relative to the @code{$gp} register. In
6081 addition to these memory regions, the MeP target has a separate 16-bit
6082 control bus which is specified with @code{cb} attributes.
6083
6084 @table @code
6085
6086 @item based
6087 @cindex @code{based} variable attribute, MeP
6088 Any variable with the @code{based} attribute is assigned to the
6089 @code{.based} section, and is accessed with relative to the
6090 @code{$tp} register.
6091
6092 @item tiny
6093 @cindex @code{tiny} variable attribute, MeP
6094 Likewise, the @code{tiny} attribute assigned variables to the
6095 @code{.tiny} section, relative to the @code{$gp} register.
6096
6097 @item near
6098 @cindex @code{near} variable attribute, MeP
6099 Variables with the @code{near} attribute are assumed to have addresses
6100 that fit in a 24-bit addressing mode. This is the default for large
6101 variables (@code{-mtiny=4} is the default) but this attribute can
6102 override @code{-mtiny=} for small variables, or override @code{-ml}.
6103
6104 @item far
6105 @cindex @code{far} variable attribute, MeP
6106 Variables with the @code{far} attribute are addressed using a full
6107 32-bit address. Since this covers the entire memory space, this
6108 allows modules to make no assumptions about where variables might be
6109 stored.
6110
6111 @item io
6112 @cindex @code{io} variable attribute, MeP
6113 @itemx io (@var{addr})
6114 Variables with the @code{io} attribute are used to address
6115 memory-mapped peripherals. If an address is specified, the variable
6116 is assigned that address, else it is not assigned an address (it is
6117 assumed some other module assigns an address). Example:
6118
6119 @smallexample
6120 int timer_count __attribute__((io(0x123)));
6121 @end smallexample
6122
6123 @item cb
6124 @itemx cb (@var{addr})
6125 @cindex @code{cb} variable attribute, MeP
6126 Variables with the @code{cb} attribute are used to access the control
6127 bus, using special instructions. @code{addr} indicates the control bus
6128 address. Example:
6129
6130 @smallexample
6131 int cpu_clock __attribute__((cb(0x123)));
6132 @end smallexample
6133
6134 @end table
6135
6136 @node Microsoft Windows Variable Attributes
6137 @subsection Microsoft Windows Variable Attributes
6138
6139 You can use these attributes on Microsoft Windows targets.
6140 @ref{x86 Variable Attributes} for additional Windows compatibility
6141 attributes available on all x86 targets.
6142
6143 @table @code
6144 @item dllimport
6145 @itemx dllexport
6146 @cindex @code{dllimport} variable attribute
6147 @cindex @code{dllexport} variable attribute
6148 The @code{dllimport} and @code{dllexport} attributes are described in
6149 @ref{Microsoft Windows Function Attributes}.
6150
6151 @item selectany
6152 @cindex @code{selectany} variable attribute
6153 The @code{selectany} attribute causes an initialized global variable to
6154 have link-once semantics. When multiple definitions of the variable are
6155 encountered by the linker, the first is selected and the remainder are
6156 discarded. Following usage by the Microsoft compiler, the linker is told
6157 @emph{not} to warn about size or content differences of the multiple
6158 definitions.
6159
6160 Although the primary usage of this attribute is for POD types, the
6161 attribute can also be applied to global C++ objects that are initialized
6162 by a constructor. In this case, the static initialization and destruction
6163 code for the object is emitted in each translation defining the object,
6164 but the calls to the constructor and destructor are protected by a
6165 link-once guard variable.
6166
6167 The @code{selectany} attribute is only available on Microsoft Windows
6168 targets. You can use @code{__declspec (selectany)} as a synonym for
6169 @code{__attribute__ ((selectany))} for compatibility with other
6170 compilers.
6171
6172 @item shared
6173 @cindex @code{shared} variable attribute
6174 On Microsoft Windows, in addition to putting variable definitions in a named
6175 section, the section can also be shared among all running copies of an
6176 executable or DLL@. For example, this small program defines shared data
6177 by putting it in a named section @code{shared} and marking the section
6178 shareable:
6179
6180 @smallexample
6181 int foo __attribute__((section ("shared"), shared)) = 0;
6182
6183 int
6184 main()
6185 @{
6186 /* @r{Read and write foo. All running
6187 copies see the same value.} */
6188 return 0;
6189 @}
6190 @end smallexample
6191
6192 @noindent
6193 You may only use the @code{shared} attribute along with @code{section}
6194 attribute with a fully-initialized global definition because of the way
6195 linkers work. See @code{section} attribute for more information.
6196
6197 The @code{shared} attribute is only available on Microsoft Windows@.
6198
6199 @end table
6200
6201 @node MSP430 Variable Attributes
6202 @subsection MSP430 Variable Attributes
6203
6204 @table @code
6205 @item noinit
6206 @cindex @code{noinit} variable attribute, MSP430
6207 Any data with the @code{noinit} attribute will not be initialised by
6208 the C runtime startup code, or the program loader. Not initialising
6209 data in this way can reduce program startup times.
6210
6211 @item persistent
6212 @cindex @code{persistent} variable attribute, MSP430
6213 Any variable with the @code{persistent} attribute will not be
6214 initialised by the C runtime startup code. Instead its value will be
6215 set once, when the application is loaded, and then never initialised
6216 again, even if the processor is reset or the program restarts.
6217 Persistent data is intended to be placed into FLASH RAM, where its
6218 value will be retained across resets. The linker script being used to
6219 create the application should ensure that persistent data is correctly
6220 placed.
6221
6222 @item lower
6223 @itemx upper
6224 @itemx either
6225 @cindex @code{lower} variable attribute, MSP430
6226 @cindex @code{upper} variable attribute, MSP430
6227 @cindex @code{either} variable attribute, MSP430
6228 These attributes are the same as the MSP430 function attributes of the
6229 same name (@pxref{MSP430 Function Attributes}).
6230 These attributes can be applied to both functions and variables.
6231 @end table
6232
6233 @node PowerPC Variable Attributes
6234 @subsection PowerPC Variable Attributes
6235
6236 Three attributes currently are defined for PowerPC configurations:
6237 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6238
6239 @cindex @code{ms_struct} variable attribute, PowerPC
6240 @cindex @code{gcc_struct} variable attribute, PowerPC
6241 For full documentation of the struct attributes please see the
6242 documentation in @ref{x86 Variable Attributes}.
6243
6244 @cindex @code{altivec} variable attribute, PowerPC
6245 For documentation of @code{altivec} attribute please see the
6246 documentation in @ref{PowerPC Type Attributes}.
6247
6248 @node RL78 Variable Attributes
6249 @subsection RL78 Variable Attributes
6250
6251 @cindex @code{saddr} variable attribute, RL78
6252 The RL78 back end supports the @code{saddr} variable attribute. This
6253 specifies placement of the corresponding variable in the SADDR area,
6254 which can be accessed more efficiently than the default memory region.
6255
6256 @node SPU Variable Attributes
6257 @subsection SPU Variable Attributes
6258
6259 @cindex @code{spu_vector} variable attribute, SPU
6260 The SPU supports the @code{spu_vector} attribute for variables. For
6261 documentation of this attribute please see the documentation in
6262 @ref{SPU Type Attributes}.
6263
6264 @node V850 Variable Attributes
6265 @subsection V850 Variable Attributes
6266
6267 These variable attributes are supported by the V850 back end:
6268
6269 @table @code
6270
6271 @item sda
6272 @cindex @code{sda} variable attribute, V850
6273 Use this attribute to explicitly place a variable in the small data area,
6274 which can hold up to 64 kilobytes.
6275
6276 @item tda
6277 @cindex @code{tda} variable attribute, V850
6278 Use this attribute to explicitly place a variable in the tiny data area,
6279 which can hold up to 256 bytes in total.
6280
6281 @item zda
6282 @cindex @code{zda} variable attribute, V850
6283 Use this attribute to explicitly place a variable in the first 32 kilobytes
6284 of memory.
6285 @end table
6286
6287 @node x86 Variable Attributes
6288 @subsection x86 Variable Attributes
6289
6290 Two attributes are currently defined for x86 configurations:
6291 @code{ms_struct} and @code{gcc_struct}.
6292
6293 @table @code
6294 @item ms_struct
6295 @itemx gcc_struct
6296 @cindex @code{ms_struct} variable attribute, x86
6297 @cindex @code{gcc_struct} variable attribute, x86
6298
6299 If @code{packed} is used on a structure, or if bit-fields are used,
6300 it may be that the Microsoft ABI lays out the structure differently
6301 than the way GCC normally does. Particularly when moving packed
6302 data between functions compiled with GCC and the native Microsoft compiler
6303 (either via function call or as data in a file), it may be necessary to access
6304 either format.
6305
6306 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6307 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6308 command-line options, respectively;
6309 see @ref{x86 Options}, for details of how structure layout is affected.
6310 @xref{x86 Type Attributes}, for information about the corresponding
6311 attributes on types.
6312
6313 @end table
6314
6315 @node Xstormy16 Variable Attributes
6316 @subsection Xstormy16 Variable Attributes
6317
6318 One attribute is currently defined for xstormy16 configurations:
6319 @code{below100}.
6320
6321 @table @code
6322 @item below100
6323 @cindex @code{below100} variable attribute, Xstormy16
6324
6325 If a variable has the @code{below100} attribute (@code{BELOW100} is
6326 allowed also), GCC places the variable in the first 0x100 bytes of
6327 memory and use special opcodes to access it. Such variables are
6328 placed in either the @code{.bss_below100} section or the
6329 @code{.data_below100} section.
6330
6331 @end table
6332
6333 @node Type Attributes
6334 @section Specifying Attributes of Types
6335 @cindex attribute of types
6336 @cindex type attributes
6337
6338 The keyword @code{__attribute__} allows you to specify special
6339 attributes of types. Some type attributes apply only to @code{struct}
6340 and @code{union} types, while others can apply to any type defined
6341 via a @code{typedef} declaration. Other attributes are defined for
6342 functions (@pxref{Function Attributes}), labels (@pxref{Label
6343 Attributes}), enumerators (@pxref{Enumerator Attributes}),
6344 statements (@pxref{Statement Attributes}), and for
6345 variables (@pxref{Variable Attributes}).
6346
6347 The @code{__attribute__} keyword is followed by an attribute specification
6348 inside double parentheses.
6349
6350 You may specify type attributes in an enum, struct or union type
6351 declaration or definition by placing them immediately after the
6352 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6353 syntax is to place them just past the closing curly brace of the
6354 definition.
6355
6356 You can also include type attributes in a @code{typedef} declaration.
6357 @xref{Attribute Syntax}, for details of the exact syntax for using
6358 attributes.
6359
6360 @menu
6361 * Common Type Attributes::
6362 * ARM Type Attributes::
6363 * MeP Type Attributes::
6364 * PowerPC Type Attributes::
6365 * SPU Type Attributes::
6366 * x86 Type Attributes::
6367 @end menu
6368
6369 @node Common Type Attributes
6370 @subsection Common Type Attributes
6371
6372 The following type attributes are supported on most targets.
6373
6374 @table @code
6375 @cindex @code{aligned} type attribute
6376 @item aligned (@var{alignment})
6377 This attribute specifies a minimum alignment (in bytes) for variables
6378 of the specified type. For example, the declarations:
6379
6380 @smallexample
6381 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6382 typedef int more_aligned_int __attribute__ ((aligned (8)));
6383 @end smallexample
6384
6385 @noindent
6386 force the compiler to ensure (as far as it can) that each variable whose
6387 type is @code{struct S} or @code{more_aligned_int} is allocated and
6388 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6389 variables of type @code{struct S} aligned to 8-byte boundaries allows
6390 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6391 store) instructions when copying one variable of type @code{struct S} to
6392 another, thus improving run-time efficiency.
6393
6394 Note that the alignment of any given @code{struct} or @code{union} type
6395 is required by the ISO C standard to be at least a perfect multiple of
6396 the lowest common multiple of the alignments of all of the members of
6397 the @code{struct} or @code{union} in question. This means that you @emph{can}
6398 effectively adjust the alignment of a @code{struct} or @code{union}
6399 type by attaching an @code{aligned} attribute to any one of the members
6400 of such a type, but the notation illustrated in the example above is a
6401 more obvious, intuitive, and readable way to request the compiler to
6402 adjust the alignment of an entire @code{struct} or @code{union} type.
6403
6404 As in the preceding example, you can explicitly specify the alignment
6405 (in bytes) that you wish the compiler to use for a given @code{struct}
6406 or @code{union} type. Alternatively, you can leave out the alignment factor
6407 and just ask the compiler to align a type to the maximum
6408 useful alignment for the target machine you are compiling for. For
6409 example, you could write:
6410
6411 @smallexample
6412 struct S @{ short f[3]; @} __attribute__ ((aligned));
6413 @end smallexample
6414
6415 Whenever you leave out the alignment factor in an @code{aligned}
6416 attribute specification, the compiler automatically sets the alignment
6417 for the type to the largest alignment that is ever used for any data
6418 type on the target machine you are compiling for. Doing this can often
6419 make copy operations more efficient, because the compiler can use
6420 whatever instructions copy the biggest chunks of memory when performing
6421 copies to or from the variables that have types that you have aligned
6422 this way.
6423
6424 In the example above, if the size of each @code{short} is 2 bytes, then
6425 the size of the entire @code{struct S} type is 6 bytes. The smallest
6426 power of two that is greater than or equal to that is 8, so the
6427 compiler sets the alignment for the entire @code{struct S} type to 8
6428 bytes.
6429
6430 Note that although you can ask the compiler to select a time-efficient
6431 alignment for a given type and then declare only individual stand-alone
6432 objects of that type, the compiler's ability to select a time-efficient
6433 alignment is primarily useful only when you plan to create arrays of
6434 variables having the relevant (efficiently aligned) type. If you
6435 declare or use arrays of variables of an efficiently-aligned type, then
6436 it is likely that your program also does pointer arithmetic (or
6437 subscripting, which amounts to the same thing) on pointers to the
6438 relevant type, and the code that the compiler generates for these
6439 pointer arithmetic operations is often more efficient for
6440 efficiently-aligned types than for other types.
6441
6442 Note that the effectiveness of @code{aligned} attributes may be limited
6443 by inherent limitations in your linker. On many systems, the linker is
6444 only able to arrange for variables to be aligned up to a certain maximum
6445 alignment. (For some linkers, the maximum supported alignment may
6446 be very very small.) If your linker is only able to align variables
6447 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6448 in an @code{__attribute__} still only provides you with 8-byte
6449 alignment. See your linker documentation for further information.
6450
6451 The @code{aligned} attribute can only increase alignment. Alignment
6452 can be decreased by specifying the @code{packed} attribute. See below.
6453
6454 @item bnd_variable_size
6455 @cindex @code{bnd_variable_size} type attribute
6456 @cindex Pointer Bounds Checker attributes
6457 When applied to a structure field, this attribute tells Pointer
6458 Bounds Checker that the size of this field should not be computed
6459 using static type information. It may be used to mark variably-sized
6460 static array fields placed at the end of a structure.
6461
6462 @smallexample
6463 struct S
6464 @{
6465 int size;
6466 char data[1];
6467 @}
6468 S *p = (S *)malloc (sizeof(S) + 100);
6469 p->data[10] = 0; //Bounds violation
6470 @end smallexample
6471
6472 @noindent
6473 By using an attribute for the field we may avoid unwanted bound
6474 violation checks:
6475
6476 @smallexample
6477 struct S
6478 @{
6479 int size;
6480 char data[1] __attribute__((bnd_variable_size));
6481 @}
6482 S *p = (S *)malloc (sizeof(S) + 100);
6483 p->data[10] = 0; //OK
6484 @end smallexample
6485
6486 @item deprecated
6487 @itemx deprecated (@var{msg})
6488 @cindex @code{deprecated} type attribute
6489 The @code{deprecated} attribute results in a warning if the type
6490 is used anywhere in the source file. This is useful when identifying
6491 types that are expected to be removed in a future version of a program.
6492 If possible, the warning also includes the location of the declaration
6493 of the deprecated type, to enable users to easily find further
6494 information about why the type is deprecated, or what they should do
6495 instead. Note that the warnings only occur for uses and then only
6496 if the type is being applied to an identifier that itself is not being
6497 declared as deprecated.
6498
6499 @smallexample
6500 typedef int T1 __attribute__ ((deprecated));
6501 T1 x;
6502 typedef T1 T2;
6503 T2 y;
6504 typedef T1 T3 __attribute__ ((deprecated));
6505 T3 z __attribute__ ((deprecated));
6506 @end smallexample
6507
6508 @noindent
6509 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6510 warning is issued for line 4 because T2 is not explicitly
6511 deprecated. Line 5 has no warning because T3 is explicitly
6512 deprecated. Similarly for line 6. The optional @var{msg}
6513 argument, which must be a string, is printed in the warning if
6514 present.
6515
6516 The @code{deprecated} attribute can also be used for functions and
6517 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6518
6519 @item designated_init
6520 @cindex @code{designated_init} type attribute
6521 This attribute may only be applied to structure types. It indicates
6522 that any initialization of an object of this type must use designated
6523 initializers rather than positional initializers. The intent of this
6524 attribute is to allow the programmer to indicate that a structure's
6525 layout may change, and that therefore relying on positional
6526 initialization will result in future breakage.
6527
6528 GCC emits warnings based on this attribute by default; use
6529 @option{-Wno-designated-init} to suppress them.
6530
6531 @item may_alias
6532 @cindex @code{may_alias} type attribute
6533 Accesses through pointers to types with this attribute are not subject
6534 to type-based alias analysis, but are instead assumed to be able to alias
6535 any other type of objects.
6536 In the context of section 6.5 paragraph 7 of the C99 standard,
6537 an lvalue expression
6538 dereferencing such a pointer is treated like having a character type.
6539 See @option{-fstrict-aliasing} for more information on aliasing issues.
6540 This extension exists to support some vector APIs, in which pointers to
6541 one vector type are permitted to alias pointers to a different vector type.
6542
6543 Note that an object of a type with this attribute does not have any
6544 special semantics.
6545
6546 Example of use:
6547
6548 @smallexample
6549 typedef short __attribute__((__may_alias__)) short_a;
6550
6551 int
6552 main (void)
6553 @{
6554 int a = 0x12345678;
6555 short_a *b = (short_a *) &a;
6556
6557 b[1] = 0;
6558
6559 if (a == 0x12345678)
6560 abort();
6561
6562 exit(0);
6563 @}
6564 @end smallexample
6565
6566 @noindent
6567 If you replaced @code{short_a} with @code{short} in the variable
6568 declaration, the above program would abort when compiled with
6569 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6570 above.
6571
6572 @item packed
6573 @cindex @code{packed} type attribute
6574 This attribute, attached to @code{struct} or @code{union} type
6575 definition, specifies that each member (other than zero-width bit-fields)
6576 of the structure or union is placed to minimize the memory required. When
6577 attached to an @code{enum} definition, it indicates that the smallest
6578 integral type should be used.
6579
6580 @opindex fshort-enums
6581 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6582 types is equivalent to specifying the @code{packed} attribute on each
6583 of the structure or union members. Specifying the @option{-fshort-enums}
6584 flag on the command line is equivalent to specifying the @code{packed}
6585 attribute on all @code{enum} definitions.
6586
6587 In the following example @code{struct my_packed_struct}'s members are
6588 packed closely together, but the internal layout of its @code{s} member
6589 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6590 be packed too.
6591
6592 @smallexample
6593 struct my_unpacked_struct
6594 @{
6595 char c;
6596 int i;
6597 @};
6598
6599 struct __attribute__ ((__packed__)) my_packed_struct
6600 @{
6601 char c;
6602 int i;
6603 struct my_unpacked_struct s;
6604 @};
6605 @end smallexample
6606
6607 You may only specify the @code{packed} attribute attribute on the definition
6608 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6609 that does not also define the enumerated type, structure or union.
6610
6611 @item scalar_storage_order ("@var{endianness}")
6612 @cindex @code{scalar_storage_order} type attribute
6613 When attached to a @code{union} or a @code{struct}, this attribute sets
6614 the storage order, aka endianness, of the scalar fields of the type, as
6615 well as the array fields whose component is scalar. The supported
6616 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6617 has no effects on fields which are themselves a @code{union}, a @code{struct}
6618 or an array whose component is a @code{union} or a @code{struct}, and it is
6619 possible for these fields to have a different scalar storage order than the
6620 enclosing type.
6621
6622 This attribute is supported only for targets that use a uniform default
6623 scalar storage order (fortunately, most of them), i.e. targets that store
6624 the scalars either all in big-endian or all in little-endian.
6625
6626 Additional restrictions are enforced for types with the reverse scalar
6627 storage order with regard to the scalar storage order of the target:
6628
6629 @itemize
6630 @item Taking the address of a scalar field of a @code{union} or a
6631 @code{struct} with reverse scalar storage order is not permitted and yields
6632 an error.
6633 @item Taking the address of an array field, whose component is scalar, of
6634 a @code{union} or a @code{struct} with reverse scalar storage order is
6635 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6636 is specified.
6637 @item Taking the address of a @code{union} or a @code{struct} with reverse
6638 scalar storage order is permitted.
6639 @end itemize
6640
6641 These restrictions exist because the storage order attribute is lost when
6642 the address of a scalar or the address of an array with scalar component is
6643 taken, so storing indirectly through this address generally does not work.
6644 The second case is nevertheless allowed to be able to perform a block copy
6645 from or to the array.
6646
6647 Moreover, the use of type punning or aliasing to toggle the storage order
6648 is not supported; that is to say, a given scalar object cannot be accessed
6649 through distinct types that assign a different storage order to it.
6650
6651 @item transparent_union
6652 @cindex @code{transparent_union} type attribute
6653
6654 This attribute, attached to a @code{union} type definition, indicates
6655 that any function parameter having that union type causes calls to that
6656 function to be treated in a special way.
6657
6658 First, the argument corresponding to a transparent union type can be of
6659 any type in the union; no cast is required. Also, if the union contains
6660 a pointer type, the corresponding argument can be a null pointer
6661 constant or a void pointer expression; and if the union contains a void
6662 pointer type, the corresponding argument can be any pointer expression.
6663 If the union member type is a pointer, qualifiers like @code{const} on
6664 the referenced type must be respected, just as with normal pointer
6665 conversions.
6666
6667 Second, the argument is passed to the function using the calling
6668 conventions of the first member of the transparent union, not the calling
6669 conventions of the union itself. All members of the union must have the
6670 same machine representation; this is necessary for this argument passing
6671 to work properly.
6672
6673 Transparent unions are designed for library functions that have multiple
6674 interfaces for compatibility reasons. For example, suppose the
6675 @code{wait} function must accept either a value of type @code{int *} to
6676 comply with POSIX, or a value of type @code{union wait *} to comply with
6677 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6678 @code{wait} would accept both kinds of arguments, but it would also
6679 accept any other pointer type and this would make argument type checking
6680 less useful. Instead, @code{<sys/wait.h>} might define the interface
6681 as follows:
6682
6683 @smallexample
6684 typedef union __attribute__ ((__transparent_union__))
6685 @{
6686 int *__ip;
6687 union wait *__up;
6688 @} wait_status_ptr_t;
6689
6690 pid_t wait (wait_status_ptr_t);
6691 @end smallexample
6692
6693 @noindent
6694 This interface allows either @code{int *} or @code{union wait *}
6695 arguments to be passed, using the @code{int *} calling convention.
6696 The program can call @code{wait} with arguments of either type:
6697
6698 @smallexample
6699 int w1 () @{ int w; return wait (&w); @}
6700 int w2 () @{ union wait w; return wait (&w); @}
6701 @end smallexample
6702
6703 @noindent
6704 With this interface, @code{wait}'s implementation might look like this:
6705
6706 @smallexample
6707 pid_t wait (wait_status_ptr_t p)
6708 @{
6709 return waitpid (-1, p.__ip, 0);
6710 @}
6711 @end smallexample
6712
6713 @item unused
6714 @cindex @code{unused} type attribute
6715 When attached to a type (including a @code{union} or a @code{struct}),
6716 this attribute means that variables of that type are meant to appear
6717 possibly unused. GCC does not produce a warning for any variables of
6718 that type, even if the variable appears to do nothing. This is often
6719 the case with lock or thread classes, which are usually defined and then
6720 not referenced, but contain constructors and destructors that have
6721 nontrivial bookkeeping functions.
6722
6723 @item visibility
6724 @cindex @code{visibility} type attribute
6725 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6726 applied to class, struct, union and enum types. Unlike other type
6727 attributes, the attribute must appear between the initial keyword and
6728 the name of the type; it cannot appear after the body of the type.
6729
6730 Note that the type visibility is applied to vague linkage entities
6731 associated with the class (vtable, typeinfo node, etc.). In
6732 particular, if a class is thrown as an exception in one shared object
6733 and caught in another, the class must have default visibility.
6734 Otherwise the two shared objects are unable to use the same
6735 typeinfo node and exception handling will break.
6736
6737 @end table
6738
6739 To specify multiple attributes, separate them by commas within the
6740 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6741 packed))}.
6742
6743 @node ARM Type Attributes
6744 @subsection ARM Type Attributes
6745
6746 @cindex @code{notshared} type attribute, ARM
6747 On those ARM targets that support @code{dllimport} (such as Symbian
6748 OS), you can use the @code{notshared} attribute to indicate that the
6749 virtual table and other similar data for a class should not be
6750 exported from a DLL@. For example:
6751
6752 @smallexample
6753 class __declspec(notshared) C @{
6754 public:
6755 __declspec(dllimport) C();
6756 virtual void f();
6757 @}
6758
6759 __declspec(dllexport)
6760 C::C() @{@}
6761 @end smallexample
6762
6763 @noindent
6764 In this code, @code{C::C} is exported from the current DLL, but the
6765 virtual table for @code{C} is not exported. (You can use
6766 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6767 most Symbian OS code uses @code{__declspec}.)
6768
6769 @node MeP Type Attributes
6770 @subsection MeP Type Attributes
6771
6772 @cindex @code{based} type attribute, MeP
6773 @cindex @code{tiny} type attribute, MeP
6774 @cindex @code{near} type attribute, MeP
6775 @cindex @code{far} type attribute, MeP
6776 Many of the MeP variable attributes may be applied to types as well.
6777 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6778 @code{far} attributes may be applied to either. The @code{io} and
6779 @code{cb} attributes may not be applied to types.
6780
6781 @node PowerPC Type Attributes
6782 @subsection PowerPC Type Attributes
6783
6784 Three attributes currently are defined for PowerPC configurations:
6785 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6786
6787 @cindex @code{ms_struct} type attribute, PowerPC
6788 @cindex @code{gcc_struct} type attribute, PowerPC
6789 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6790 attributes please see the documentation in @ref{x86 Type Attributes}.
6791
6792 @cindex @code{altivec} type attribute, PowerPC
6793 The @code{altivec} attribute allows one to declare AltiVec vector data
6794 types supported by the AltiVec Programming Interface Manual. The
6795 attribute requires an argument to specify one of three vector types:
6796 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6797 and @code{bool__} (always followed by unsigned).
6798
6799 @smallexample
6800 __attribute__((altivec(vector__)))
6801 __attribute__((altivec(pixel__))) unsigned short
6802 __attribute__((altivec(bool__))) unsigned
6803 @end smallexample
6804
6805 These attributes mainly are intended to support the @code{__vector},
6806 @code{__pixel}, and @code{__bool} AltiVec keywords.
6807
6808 @node SPU Type Attributes
6809 @subsection SPU Type Attributes
6810
6811 @cindex @code{spu_vector} type attribute, SPU
6812 The SPU supports the @code{spu_vector} attribute for types. This attribute
6813 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6814 Language Extensions Specification. It is intended to support the
6815 @code{__vector} keyword.
6816
6817 @node x86 Type Attributes
6818 @subsection x86 Type Attributes
6819
6820 Two attributes are currently defined for x86 configurations:
6821 @code{ms_struct} and @code{gcc_struct}.
6822
6823 @table @code
6824
6825 @item ms_struct
6826 @itemx gcc_struct
6827 @cindex @code{ms_struct} type attribute, x86
6828 @cindex @code{gcc_struct} type attribute, x86
6829
6830 If @code{packed} is used on a structure, or if bit-fields are used
6831 it may be that the Microsoft ABI packs them differently
6832 than GCC normally packs them. Particularly when moving packed
6833 data between functions compiled with GCC and the native Microsoft compiler
6834 (either via function call or as data in a file), it may be necessary to access
6835 either format.
6836
6837 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6838 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6839 command-line options, respectively;
6840 see @ref{x86 Options}, for details of how structure layout is affected.
6841 @xref{x86 Variable Attributes}, for information about the corresponding
6842 attributes on variables.
6843
6844 @end table
6845
6846 @node Label Attributes
6847 @section Label Attributes
6848 @cindex Label Attributes
6849
6850 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6851 details of the exact syntax for using attributes. Other attributes are
6852 available for functions (@pxref{Function Attributes}), variables
6853 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6854 statements (@pxref{Statement Attributes}), and for types
6855 (@pxref{Type Attributes}).
6856
6857 This example uses the @code{cold} label attribute to indicate the
6858 @code{ErrorHandling} branch is unlikely to be taken and that the
6859 @code{ErrorHandling} label is unused:
6860
6861 @smallexample
6862
6863 asm goto ("some asm" : : : : NoError);
6864
6865 /* This branch (the fall-through from the asm) is less commonly used */
6866 ErrorHandling:
6867 __attribute__((cold, unused)); /* Semi-colon is required here */
6868 printf("error\n");
6869 return 0;
6870
6871 NoError:
6872 printf("no error\n");
6873 return 1;
6874 @end smallexample
6875
6876 @table @code
6877 @item unused
6878 @cindex @code{unused} label attribute
6879 This feature is intended for program-generated code that may contain
6880 unused labels, but which is compiled with @option{-Wall}. It is
6881 not normally appropriate to use in it human-written code, though it
6882 could be useful in cases where the code that jumps to the label is
6883 contained within an @code{#ifdef} conditional.
6884
6885 @item hot
6886 @cindex @code{hot} label attribute
6887 The @code{hot} attribute on a label is used to inform the compiler that
6888 the path following the label is more likely than paths that are not so
6889 annotated. This attribute is used in cases where @code{__builtin_expect}
6890 cannot be used, for instance with computed goto or @code{asm goto}.
6891
6892 @item cold
6893 @cindex @code{cold} label attribute
6894 The @code{cold} attribute on labels is used to inform the compiler that
6895 the path following the label is unlikely to be executed. This attribute
6896 is used in cases where @code{__builtin_expect} cannot be used, for instance
6897 with computed goto or @code{asm goto}.
6898
6899 @end table
6900
6901 @node Enumerator Attributes
6902 @section Enumerator Attributes
6903 @cindex Enumerator Attributes
6904
6905 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6906 details of the exact syntax for using attributes. Other attributes are
6907 available for functions (@pxref{Function Attributes}), variables
6908 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
6909 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6910
6911 This example uses the @code{deprecated} enumerator attribute to indicate the
6912 @code{oldval} enumerator is deprecated:
6913
6914 @smallexample
6915 enum E @{
6916 oldval __attribute__((deprecated)),
6917 newval
6918 @};
6919
6920 int
6921 fn (void)
6922 @{
6923 return oldval;
6924 @}
6925 @end smallexample
6926
6927 @table @code
6928 @item deprecated
6929 @cindex @code{deprecated} enumerator attribute
6930 The @code{deprecated} attribute results in a warning if the enumerator
6931 is used anywhere in the source file. This is useful when identifying
6932 enumerators that are expected to be removed in a future version of a
6933 program. The warning also includes the location of the declaration
6934 of the deprecated enumerator, to enable users to easily find further
6935 information about why the enumerator is deprecated, or what they should
6936 do instead. Note that the warnings only occurs for uses.
6937
6938 @end table
6939
6940 @node Statement Attributes
6941 @section Statement Attributes
6942 @cindex Statement Attributes
6943
6944 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
6945 for details of the exact syntax for using attributes. Other attributes are
6946 available for functions (@pxref{Function Attributes}), variables
6947 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
6948 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
6949
6950 This example uses the @code{fallthrough} statement attribute to indicate that
6951 the @option{-Wimplicit-fallthrough} warning should not be emitted:
6952
6953 @smallexample
6954 switch (cond)
6955 @{
6956 case 1:
6957 bar (1);
6958 __attribute__((fallthrough));
6959 case 2:
6960 @dots{}
6961 @}
6962 @end smallexample
6963
6964 @table @code
6965 @item fallthrough
6966 @cindex @code{fallthrough} statement attribute
6967 The @code{fallthrough} attribute with a null statement serves as a
6968 fallthrough statement. It hints to the compiler that a statement
6969 that falls through to another case label, or user-defined label
6970 in a switch statement is intentional and thus the
6971 @option{-Wimplicit-fallthrough} warning must not trigger. The
6972 fallthrough attribute may appear at most once in each attribute
6973 list, and may not be mixed with other attributes. It can only
6974 be used in a switch statement (the compiler will issue an error
6975 otherwise), after a preceding statement and before a logically
6976 succeeding case label, or user-defined label.
6977
6978 @end table
6979
6980 @node Attribute Syntax
6981 @section Attribute Syntax
6982 @cindex attribute syntax
6983
6984 This section describes the syntax with which @code{__attribute__} may be
6985 used, and the constructs to which attribute specifiers bind, for the C
6986 language. Some details may vary for C++ and Objective-C@. Because of
6987 infelicities in the grammar for attributes, some forms described here
6988 may not be successfully parsed in all cases.
6989
6990 There are some problems with the semantics of attributes in C++. For
6991 example, there are no manglings for attributes, although they may affect
6992 code generation, so problems may arise when attributed types are used in
6993 conjunction with templates or overloading. Similarly, @code{typeid}
6994 does not distinguish between types with different attributes. Support
6995 for attributes in C++ may be restricted in future to attributes on
6996 declarations only, but not on nested declarators.
6997
6998 @xref{Function Attributes}, for details of the semantics of attributes
6999 applying to functions. @xref{Variable Attributes}, for details of the
7000 semantics of attributes applying to variables. @xref{Type Attributes},
7001 for details of the semantics of attributes applying to structure, union
7002 and enumerated types.
7003 @xref{Label Attributes}, for details of the semantics of attributes
7004 applying to labels.
7005 @xref{Enumerator Attributes}, for details of the semantics of attributes
7006 applying to enumerators.
7007 @xref{Statement Attributes}, for details of the semantics of attributes
7008 applying to statements.
7009
7010 An @dfn{attribute specifier} is of the form
7011 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
7012 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7013 each attribute is one of the following:
7014
7015 @itemize @bullet
7016 @item
7017 Empty. Empty attributes are ignored.
7018
7019 @item
7020 An attribute name
7021 (which may be an identifier such as @code{unused}, or a reserved
7022 word such as @code{const}).
7023
7024 @item
7025 An attribute name followed by a parenthesized list of
7026 parameters for the attribute.
7027 These parameters take one of the following forms:
7028
7029 @itemize @bullet
7030 @item
7031 An identifier. For example, @code{mode} attributes use this form.
7032
7033 @item
7034 An identifier followed by a comma and a non-empty comma-separated list
7035 of expressions. For example, @code{format} attributes use this form.
7036
7037 @item
7038 A possibly empty comma-separated list of expressions. For example,
7039 @code{format_arg} attributes use this form with the list being a single
7040 integer constant expression, and @code{alias} attributes use this form
7041 with the list being a single string constant.
7042 @end itemize
7043 @end itemize
7044
7045 An @dfn{attribute specifier list} is a sequence of one or more attribute
7046 specifiers, not separated by any other tokens.
7047
7048 You may optionally specify attribute names with @samp{__}
7049 preceding and following the name.
7050 This allows you to use them in header files without
7051 being concerned about a possible macro of the same name. For example,
7052 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7053
7054
7055 @subsubheading Label Attributes
7056
7057 In GNU C, an attribute specifier list may appear after the colon following a
7058 label, other than a @code{case} or @code{default} label. GNU C++ only permits
7059 attributes on labels if the attribute specifier is immediately
7060 followed by a semicolon (i.e., the label applies to an empty
7061 statement). If the semicolon is missing, C++ label attributes are
7062 ambiguous, as it is permissible for a declaration, which could begin
7063 with an attribute list, to be labelled in C++. Declarations cannot be
7064 labelled in C90 or C99, so the ambiguity does not arise there.
7065
7066 @subsubheading Enumerator Attributes
7067
7068 In GNU C, an attribute specifier list may appear as part of an enumerator.
7069 The attribute goes after the enumeration constant, before @code{=}, if
7070 present. The optional attribute in the enumerator appertains to the
7071 enumeration constant. It is not possible to place the attribute after
7072 the constant expression, if present.
7073
7074 @subsubheading Statement Attributes
7075 In GNU C, an attribute specifier list may appear as part of a null
7076 statement. The attribute goes before the semicolon.
7077
7078 @subsubheading Type Attributes
7079
7080 An attribute specifier list may appear as part of a @code{struct},
7081 @code{union} or @code{enum} specifier. It may go either immediately
7082 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7083 the closing brace. The former syntax is preferred.
7084 Where attribute specifiers follow the closing brace, they are considered
7085 to relate to the structure, union or enumerated type defined, not to any
7086 enclosing declaration the type specifier appears in, and the type
7087 defined is not complete until after the attribute specifiers.
7088 @c Otherwise, there would be the following problems: a shift/reduce
7089 @c conflict between attributes binding the struct/union/enum and
7090 @c binding to the list of specifiers/qualifiers; and "aligned"
7091 @c attributes could use sizeof for the structure, but the size could be
7092 @c changed later by "packed" attributes.
7093
7094
7095 @subsubheading All other attributes
7096
7097 Otherwise, an attribute specifier appears as part of a declaration,
7098 counting declarations of unnamed parameters and type names, and relates
7099 to that declaration (which may be nested in another declaration, for
7100 example in the case of a parameter declaration), or to a particular declarator
7101 within a declaration. Where an
7102 attribute specifier is applied to a parameter declared as a function or
7103 an array, it should apply to the function or array rather than the
7104 pointer to which the parameter is implicitly converted, but this is not
7105 yet correctly implemented.
7106
7107 Any list of specifiers and qualifiers at the start of a declaration may
7108 contain attribute specifiers, whether or not such a list may in that
7109 context contain storage class specifiers. (Some attributes, however,
7110 are essentially in the nature of storage class specifiers, and only make
7111 sense where storage class specifiers may be used; for example,
7112 @code{section}.) There is one necessary limitation to this syntax: the
7113 first old-style parameter declaration in a function definition cannot
7114 begin with an attribute specifier, because such an attribute applies to
7115 the function instead by syntax described below (which, however, is not
7116 yet implemented in this case). In some other cases, attribute
7117 specifiers are permitted by this grammar but not yet supported by the
7118 compiler. All attribute specifiers in this place relate to the
7119 declaration as a whole. In the obsolescent usage where a type of
7120 @code{int} is implied by the absence of type specifiers, such a list of
7121 specifiers and qualifiers may be an attribute specifier list with no
7122 other specifiers or qualifiers.
7123
7124 At present, the first parameter in a function prototype must have some
7125 type specifier that is not an attribute specifier; this resolves an
7126 ambiguity in the interpretation of @code{void f(int
7127 (__attribute__((foo)) x))}, but is subject to change. At present, if
7128 the parentheses of a function declarator contain only attributes then
7129 those attributes are ignored, rather than yielding an error or warning
7130 or implying a single parameter of type int, but this is subject to
7131 change.
7132
7133 An attribute specifier list may appear immediately before a declarator
7134 (other than the first) in a comma-separated list of declarators in a
7135 declaration of more than one identifier using a single list of
7136 specifiers and qualifiers. Such attribute specifiers apply
7137 only to the identifier before whose declarator they appear. For
7138 example, in
7139
7140 @smallexample
7141 __attribute__((noreturn)) void d0 (void),
7142 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7143 d2 (void);
7144 @end smallexample
7145
7146 @noindent
7147 the @code{noreturn} attribute applies to all the functions
7148 declared; the @code{format} attribute only applies to @code{d1}.
7149
7150 An attribute specifier list may appear immediately before the comma,
7151 @code{=} or semicolon terminating the declaration of an identifier other
7152 than a function definition. Such attribute specifiers apply
7153 to the declared object or function. Where an
7154 assembler name for an object or function is specified (@pxref{Asm
7155 Labels}), the attribute must follow the @code{asm}
7156 specification.
7157
7158 An attribute specifier list may, in future, be permitted to appear after
7159 the declarator in a function definition (before any old-style parameter
7160 declarations or the function body).
7161
7162 Attribute specifiers may be mixed with type qualifiers appearing inside
7163 the @code{[]} of a parameter array declarator, in the C99 construct by
7164 which such qualifiers are applied to the pointer to which the array is
7165 implicitly converted. Such attribute specifiers apply to the pointer,
7166 not to the array, but at present this is not implemented and they are
7167 ignored.
7168
7169 An attribute specifier list may appear at the start of a nested
7170 declarator. At present, there are some limitations in this usage: the
7171 attributes correctly apply to the declarator, but for most individual
7172 attributes the semantics this implies are not implemented.
7173 When attribute specifiers follow the @code{*} of a pointer
7174 declarator, they may be mixed with any type qualifiers present.
7175 The following describes the formal semantics of this syntax. It makes the
7176 most sense if you are familiar with the formal specification of
7177 declarators in the ISO C standard.
7178
7179 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7180 D1}, where @code{T} contains declaration specifiers that specify a type
7181 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7182 contains an identifier @var{ident}. The type specified for @var{ident}
7183 for derived declarators whose type does not include an attribute
7184 specifier is as in the ISO C standard.
7185
7186 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7187 and the declaration @code{T D} specifies the type
7188 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7189 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7190 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7191
7192 If @code{D1} has the form @code{*
7193 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7194 declaration @code{T D} specifies the type
7195 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7196 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7197 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7198 @var{ident}.
7199
7200 For example,
7201
7202 @smallexample
7203 void (__attribute__((noreturn)) ****f) (void);
7204 @end smallexample
7205
7206 @noindent
7207 specifies the type ``pointer to pointer to pointer to pointer to
7208 non-returning function returning @code{void}''. As another example,
7209
7210 @smallexample
7211 char *__attribute__((aligned(8))) *f;
7212 @end smallexample
7213
7214 @noindent
7215 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7216 Note again that this does not work with most attributes; for example,
7217 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7218 is not yet supported.
7219
7220 For compatibility with existing code written for compiler versions that
7221 did not implement attributes on nested declarators, some laxity is
7222 allowed in the placing of attributes. If an attribute that only applies
7223 to types is applied to a declaration, it is treated as applying to
7224 the type of that declaration. If an attribute that only applies to
7225 declarations is applied to the type of a declaration, it is treated
7226 as applying to that declaration; and, for compatibility with code
7227 placing the attributes immediately before the identifier declared, such
7228 an attribute applied to a function return type is treated as
7229 applying to the function type, and such an attribute applied to an array
7230 element type is treated as applying to the array type. If an
7231 attribute that only applies to function types is applied to a
7232 pointer-to-function type, it is treated as applying to the pointer
7233 target type; if such an attribute is applied to a function return type
7234 that is not a pointer-to-function type, it is treated as applying
7235 to the function type.
7236
7237 @node Function Prototypes
7238 @section Prototypes and Old-Style Function Definitions
7239 @cindex function prototype declarations
7240 @cindex old-style function definitions
7241 @cindex promotion of formal parameters
7242
7243 GNU C extends ISO C to allow a function prototype to override a later
7244 old-style non-prototype definition. Consider the following example:
7245
7246 @smallexample
7247 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7248 #ifdef __STDC__
7249 #define P(x) x
7250 #else
7251 #define P(x) ()
7252 #endif
7253
7254 /* @r{Prototype function declaration.} */
7255 int isroot P((uid_t));
7256
7257 /* @r{Old-style function definition.} */
7258 int
7259 isroot (x) /* @r{??? lossage here ???} */
7260 uid_t x;
7261 @{
7262 return x == 0;
7263 @}
7264 @end smallexample
7265
7266 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7267 not allow this example, because subword arguments in old-style
7268 non-prototype definitions are promoted. Therefore in this example the
7269 function definition's argument is really an @code{int}, which does not
7270 match the prototype argument type of @code{short}.
7271
7272 This restriction of ISO C makes it hard to write code that is portable
7273 to traditional C compilers, because the programmer does not know
7274 whether the @code{uid_t} type is @code{short}, @code{int}, or
7275 @code{long}. Therefore, in cases like these GNU C allows a prototype
7276 to override a later old-style definition. More precisely, in GNU C, a
7277 function prototype argument type overrides the argument type specified
7278 by a later old-style definition if the former type is the same as the
7279 latter type before promotion. Thus in GNU C the above example is
7280 equivalent to the following:
7281
7282 @smallexample
7283 int isroot (uid_t);
7284
7285 int
7286 isroot (uid_t x)
7287 @{
7288 return x == 0;
7289 @}
7290 @end smallexample
7291
7292 @noindent
7293 GNU C++ does not support old-style function definitions, so this
7294 extension is irrelevant.
7295
7296 @node C++ Comments
7297 @section C++ Style Comments
7298 @cindex @code{//}
7299 @cindex C++ comments
7300 @cindex comments, C++ style
7301
7302 In GNU C, you may use C++ style comments, which start with @samp{//} and
7303 continue until the end of the line. Many other C implementations allow
7304 such comments, and they are included in the 1999 C standard. However,
7305 C++ style comments are not recognized if you specify an @option{-std}
7306 option specifying a version of ISO C before C99, or @option{-ansi}
7307 (equivalent to @option{-std=c90}).
7308
7309 @node Dollar Signs
7310 @section Dollar Signs in Identifier Names
7311 @cindex $
7312 @cindex dollar signs in identifier names
7313 @cindex identifier names, dollar signs in
7314
7315 In GNU C, you may normally use dollar signs in identifier names.
7316 This is because many traditional C implementations allow such identifiers.
7317 However, dollar signs in identifiers are not supported on a few target
7318 machines, typically because the target assembler does not allow them.
7319
7320 @node Character Escapes
7321 @section The Character @key{ESC} in Constants
7322
7323 You can use the sequence @samp{\e} in a string or character constant to
7324 stand for the ASCII character @key{ESC}.
7325
7326 @node Alignment
7327 @section Inquiring on Alignment of Types or Variables
7328 @cindex alignment
7329 @cindex type alignment
7330 @cindex variable alignment
7331
7332 The keyword @code{__alignof__} allows you to inquire about how an object
7333 is aligned, or the minimum alignment usually required by a type. Its
7334 syntax is just like @code{sizeof}.
7335
7336 For example, if the target machine requires a @code{double} value to be
7337 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7338 This is true on many RISC machines. On more traditional machine
7339 designs, @code{__alignof__ (double)} is 4 or even 2.
7340
7341 Some machines never actually require alignment; they allow reference to any
7342 data type even at an odd address. For these machines, @code{__alignof__}
7343 reports the smallest alignment that GCC gives the data type, usually as
7344 mandated by the target ABI.
7345
7346 If the operand of @code{__alignof__} is an lvalue rather than a type,
7347 its value is the required alignment for its type, taking into account
7348 any minimum alignment specified with GCC's @code{__attribute__}
7349 extension (@pxref{Variable Attributes}). For example, after this
7350 declaration:
7351
7352 @smallexample
7353 struct foo @{ int x; char y; @} foo1;
7354 @end smallexample
7355
7356 @noindent
7357 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7358 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7359
7360 It is an error to ask for the alignment of an incomplete type.
7361
7362
7363 @node Inline
7364 @section An Inline Function is As Fast As a Macro
7365 @cindex inline functions
7366 @cindex integrating function code
7367 @cindex open coding
7368 @cindex macros, inline alternative
7369
7370 By declaring a function inline, you can direct GCC to make
7371 calls to that function faster. One way GCC can achieve this is to
7372 integrate that function's code into the code for its callers. This
7373 makes execution faster by eliminating the function-call overhead; in
7374 addition, if any of the actual argument values are constant, their
7375 known values may permit simplifications at compile time so that not
7376 all of the inline function's code needs to be included. The effect on
7377 code size is less predictable; object code may be larger or smaller
7378 with function inlining, depending on the particular case. You can
7379 also direct GCC to try to integrate all ``simple enough'' functions
7380 into their callers with the option @option{-finline-functions}.
7381
7382 GCC implements three different semantics of declaring a function
7383 inline. One is available with @option{-std=gnu89} or
7384 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7385 on all inline declarations, another when
7386 @option{-std=c99}, @option{-std=c11},
7387 @option{-std=gnu99} or @option{-std=gnu11}
7388 (without @option{-fgnu89-inline}), and the third
7389 is used when compiling C++.
7390
7391 To declare a function inline, use the @code{inline} keyword in its
7392 declaration, like this:
7393
7394 @smallexample
7395 static inline int
7396 inc (int *a)
7397 @{
7398 return (*a)++;
7399 @}
7400 @end smallexample
7401
7402 If you are writing a header file to be included in ISO C90 programs, write
7403 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7404
7405 The three types of inlining behave similarly in two important cases:
7406 when the @code{inline} keyword is used on a @code{static} function,
7407 like the example above, and when a function is first declared without
7408 using the @code{inline} keyword and then is defined with
7409 @code{inline}, like this:
7410
7411 @smallexample
7412 extern int inc (int *a);
7413 inline int
7414 inc (int *a)
7415 @{
7416 return (*a)++;
7417 @}
7418 @end smallexample
7419
7420 In both of these common cases, the program behaves the same as if you
7421 had not used the @code{inline} keyword, except for its speed.
7422
7423 @cindex inline functions, omission of
7424 @opindex fkeep-inline-functions
7425 When a function is both inline and @code{static}, if all calls to the
7426 function are integrated into the caller, and the function's address is
7427 never used, then the function's own assembler code is never referenced.
7428 In this case, GCC does not actually output assembler code for the
7429 function, unless you specify the option @option{-fkeep-inline-functions}.
7430 If there is a nonintegrated call, then the function is compiled to
7431 assembler code as usual. The function must also be compiled as usual if
7432 the program refers to its address, because that can't be inlined.
7433
7434 @opindex Winline
7435 Note that certain usages in a function definition can make it unsuitable
7436 for inline substitution. Among these usages are: variadic functions,
7437 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7438 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7439 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7440 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7441 function marked @code{inline} could not be substituted, and gives the
7442 reason for the failure.
7443
7444 @cindex automatic @code{inline} for C++ member fns
7445 @cindex @code{inline} automatic for C++ member fns
7446 @cindex member fns, automatically @code{inline}
7447 @cindex C++ member fns, automatically @code{inline}
7448 @opindex fno-default-inline
7449 As required by ISO C++, GCC considers member functions defined within
7450 the body of a class to be marked inline even if they are
7451 not explicitly declared with the @code{inline} keyword. You can
7452 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7453 Options,,Options Controlling C++ Dialect}.
7454
7455 GCC does not inline any functions when not optimizing unless you specify
7456 the @samp{always_inline} attribute for the function, like this:
7457
7458 @smallexample
7459 /* @r{Prototype.} */
7460 inline void foo (const char) __attribute__((always_inline));
7461 @end smallexample
7462
7463 The remainder of this section is specific to GNU C90 inlining.
7464
7465 @cindex non-static inline function
7466 When an inline function is not @code{static}, then the compiler must assume
7467 that there may be calls from other source files; since a global symbol can
7468 be defined only once in any program, the function must not be defined in
7469 the other source files, so the calls therein cannot be integrated.
7470 Therefore, a non-@code{static} inline function is always compiled on its
7471 own in the usual fashion.
7472
7473 If you specify both @code{inline} and @code{extern} in the function
7474 definition, then the definition is used only for inlining. In no case
7475 is the function compiled on its own, not even if you refer to its
7476 address explicitly. Such an address becomes an external reference, as
7477 if you had only declared the function, and had not defined it.
7478
7479 This combination of @code{inline} and @code{extern} has almost the
7480 effect of a macro. The way to use it is to put a function definition in
7481 a header file with these keywords, and put another copy of the
7482 definition (lacking @code{inline} and @code{extern}) in a library file.
7483 The definition in the header file causes most calls to the function
7484 to be inlined. If any uses of the function remain, they refer to
7485 the single copy in the library.
7486
7487 @node Volatiles
7488 @section When is a Volatile Object Accessed?
7489 @cindex accessing volatiles
7490 @cindex volatile read
7491 @cindex volatile write
7492 @cindex volatile access
7493
7494 C has the concept of volatile objects. These are normally accessed by
7495 pointers and used for accessing hardware or inter-thread
7496 communication. The standard encourages compilers to refrain from
7497 optimizations concerning accesses to volatile objects, but leaves it
7498 implementation defined as to what constitutes a volatile access. The
7499 minimum requirement is that at a sequence point all previous accesses
7500 to volatile objects have stabilized and no subsequent accesses have
7501 occurred. Thus an implementation is free to reorder and combine
7502 volatile accesses that occur between sequence points, but cannot do
7503 so for accesses across a sequence point. The use of volatile does
7504 not allow you to violate the restriction on updating objects multiple
7505 times between two sequence points.
7506
7507 Accesses to non-volatile objects are not ordered with respect to
7508 volatile accesses. You cannot use a volatile object as a memory
7509 barrier to order a sequence of writes to non-volatile memory. For
7510 instance:
7511
7512 @smallexample
7513 int *ptr = @var{something};
7514 volatile int vobj;
7515 *ptr = @var{something};
7516 vobj = 1;
7517 @end smallexample
7518
7519 @noindent
7520 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7521 that the write to @var{*ptr} occurs by the time the update
7522 of @var{vobj} happens. If you need this guarantee, you must use
7523 a stronger memory barrier such as:
7524
7525 @smallexample
7526 int *ptr = @var{something};
7527 volatile int vobj;
7528 *ptr = @var{something};
7529 asm volatile ("" : : : "memory");
7530 vobj = 1;
7531 @end smallexample
7532
7533 A scalar volatile object is read when it is accessed in a void context:
7534
7535 @smallexample
7536 volatile int *src = @var{somevalue};
7537 *src;
7538 @end smallexample
7539
7540 Such expressions are rvalues, and GCC implements this as a
7541 read of the volatile object being pointed to.
7542
7543 Assignments are also expressions and have an rvalue. However when
7544 assigning to a scalar volatile, the volatile object is not reread,
7545 regardless of whether the assignment expression's rvalue is used or
7546 not. If the assignment's rvalue is used, the value is that assigned
7547 to the volatile object. For instance, there is no read of @var{vobj}
7548 in all the following cases:
7549
7550 @smallexample
7551 int obj;
7552 volatile int vobj;
7553 vobj = @var{something};
7554 obj = vobj = @var{something};
7555 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7556 obj = (@var{something}, vobj = @var{anotherthing});
7557 @end smallexample
7558
7559 If you need to read the volatile object after an assignment has
7560 occurred, you must use a separate expression with an intervening
7561 sequence point.
7562
7563 As bit-fields are not individually addressable, volatile bit-fields may
7564 be implicitly read when written to, or when adjacent bit-fields are
7565 accessed. Bit-field operations may be optimized such that adjacent
7566 bit-fields are only partially accessed, if they straddle a storage unit
7567 boundary. For these reasons it is unwise to use volatile bit-fields to
7568 access hardware.
7569
7570 @node Using Assembly Language with C
7571 @section How to Use Inline Assembly Language in C Code
7572 @cindex @code{asm} keyword
7573 @cindex assembly language in C
7574 @cindex inline assembly language
7575 @cindex mixing assembly language and C
7576
7577 The @code{asm} keyword allows you to embed assembler instructions
7578 within C code. GCC provides two forms of inline @code{asm}
7579 statements. A @dfn{basic @code{asm}} statement is one with no
7580 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7581 statement (@pxref{Extended Asm}) includes one or more operands.
7582 The extended form is preferred for mixing C and assembly language
7583 within a function, but to include assembly language at
7584 top level you must use basic @code{asm}.
7585
7586 You can also use the @code{asm} keyword to override the assembler name
7587 for a C symbol, or to place a C variable in a specific register.
7588
7589 @menu
7590 * Basic Asm:: Inline assembler without operands.
7591 * Extended Asm:: Inline assembler with operands.
7592 * Constraints:: Constraints for @code{asm} operands
7593 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7594 * Explicit Register Variables:: Defining variables residing in specified
7595 registers.
7596 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7597 @end menu
7598
7599 @node Basic Asm
7600 @subsection Basic Asm --- Assembler Instructions Without Operands
7601 @cindex basic @code{asm}
7602 @cindex assembly language in C, basic
7603
7604 A basic @code{asm} statement has the following syntax:
7605
7606 @example
7607 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7608 @end example
7609
7610 The @code{asm} keyword is a GNU extension.
7611 When writing code that can be compiled with @option{-ansi} and the
7612 various @option{-std} options, use @code{__asm__} instead of
7613 @code{asm} (@pxref{Alternate Keywords}).
7614
7615 @subsubheading Qualifiers
7616 @table @code
7617 @item volatile
7618 The optional @code{volatile} qualifier has no effect.
7619 All basic @code{asm} blocks are implicitly volatile.
7620 @end table
7621
7622 @subsubheading Parameters
7623 @table @var
7624
7625 @item AssemblerInstructions
7626 This is a literal string that specifies the assembler code. The string can
7627 contain any instructions recognized by the assembler, including directives.
7628 GCC does not parse the assembler instructions themselves and
7629 does not know what they mean or even whether they are valid assembler input.
7630
7631 You may place multiple assembler instructions together in a single @code{asm}
7632 string, separated by the characters normally used in assembly code for the
7633 system. A combination that works in most places is a newline to break the
7634 line, plus a tab character (written as @samp{\n\t}).
7635 Some assemblers allow semicolons as a line separator. However,
7636 note that some assembler dialects use semicolons to start a comment.
7637 @end table
7638
7639 @subsubheading Remarks
7640 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7641 smaller, safer, and more efficient code, and in most cases it is a
7642 better solution than basic @code{asm}. However, there are two
7643 situations where only basic @code{asm} can be used:
7644
7645 @itemize @bullet
7646 @item
7647 Extended @code{asm} statements have to be inside a C
7648 function, so to write inline assembly language at file scope (``top-level''),
7649 outside of C functions, you must use basic @code{asm}.
7650 You can use this technique to emit assembler directives,
7651 define assembly language macros that can be invoked elsewhere in the file,
7652 or write entire functions in assembly language.
7653
7654 @item
7655 Functions declared
7656 with the @code{naked} attribute also require basic @code{asm}
7657 (@pxref{Function Attributes}).
7658 @end itemize
7659
7660 Safely accessing C data and calling functions from basic @code{asm} is more
7661 complex than it may appear. To access C data, it is better to use extended
7662 @code{asm}.
7663
7664 Do not expect a sequence of @code{asm} statements to remain perfectly
7665 consecutive after compilation. If certain instructions need to remain
7666 consecutive in the output, put them in a single multi-instruction @code{asm}
7667 statement. Note that GCC's optimizers can move @code{asm} statements
7668 relative to other code, including across jumps.
7669
7670 @code{asm} statements may not perform jumps into other @code{asm} statements.
7671 GCC does not know about these jumps, and therefore cannot take
7672 account of them when deciding how to optimize. Jumps from @code{asm} to C
7673 labels are only supported in extended @code{asm}.
7674
7675 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7676 assembly code when optimizing. This can lead to unexpected duplicate
7677 symbol errors during compilation if your assembly code defines symbols or
7678 labels.
7679
7680 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7681 making it a potential source of incompatibilities between compilers. These
7682 incompatibilities may not produce compiler warnings/errors.
7683
7684 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7685 means there is no way to communicate to the compiler what is happening
7686 inside them. GCC has no visibility of symbols in the @code{asm} and may
7687 discard them as unreferenced. It also does not know about side effects of
7688 the assembler code, such as modifications to memory or registers. Unlike
7689 some compilers, GCC assumes that no changes to general purpose registers
7690 occur. This assumption may change in a future release.
7691
7692 To avoid complications from future changes to the semantics and the
7693 compatibility issues between compilers, consider replacing basic @code{asm}
7694 with extended @code{asm}. See
7695 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7696 from basic asm to extended asm} for information about how to perform this
7697 conversion.
7698
7699 The compiler copies the assembler instructions in a basic @code{asm}
7700 verbatim to the assembly language output file, without
7701 processing dialects or any of the @samp{%} operators that are available with
7702 extended @code{asm}. This results in minor differences between basic
7703 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7704 registers you might use @samp{%eax} in basic @code{asm} and
7705 @samp{%%eax} in extended @code{asm}.
7706
7707 On targets such as x86 that support multiple assembler dialects,
7708 all basic @code{asm} blocks use the assembler dialect specified by the
7709 @option{-masm} command-line option (@pxref{x86 Options}).
7710 Basic @code{asm} provides no
7711 mechanism to provide different assembler strings for different dialects.
7712
7713 For basic @code{asm} with non-empty assembler string GCC assumes
7714 the assembler block does not change any general purpose registers,
7715 but it may read or write any globally accessible variable.
7716
7717 Here is an example of basic @code{asm} for i386:
7718
7719 @example
7720 /* Note that this code will not compile with -masm=intel */
7721 #define DebugBreak() asm("int $3")
7722 @end example
7723
7724 @node Extended Asm
7725 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7726 @cindex extended @code{asm}
7727 @cindex assembly language in C, extended
7728
7729 With extended @code{asm} you can read and write C variables from
7730 assembler and perform jumps from assembler code to C labels.
7731 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7732 the operand parameters after the assembler template:
7733
7734 @example
7735 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7736 : @var{OutputOperands}
7737 @r{[} : @var{InputOperands}
7738 @r{[} : @var{Clobbers} @r{]} @r{]})
7739
7740 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7741 :
7742 : @var{InputOperands}
7743 : @var{Clobbers}
7744 : @var{GotoLabels})
7745 @end example
7746
7747 The @code{asm} keyword is a GNU extension.
7748 When writing code that can be compiled with @option{-ansi} and the
7749 various @option{-std} options, use @code{__asm__} instead of
7750 @code{asm} (@pxref{Alternate Keywords}).
7751
7752 @subsubheading Qualifiers
7753 @table @code
7754
7755 @item volatile
7756 The typical use of extended @code{asm} statements is to manipulate input
7757 values to produce output values. However, your @code{asm} statements may
7758 also produce side effects. If so, you may need to use the @code{volatile}
7759 qualifier to disable certain optimizations. @xref{Volatile}.
7760
7761 @item goto
7762 This qualifier informs the compiler that the @code{asm} statement may
7763 perform a jump to one of the labels listed in the @var{GotoLabels}.
7764 @xref{GotoLabels}.
7765 @end table
7766
7767 @subsubheading Parameters
7768 @table @var
7769 @item AssemblerTemplate
7770 This is a literal string that is the template for the assembler code. It is a
7771 combination of fixed text and tokens that refer to the input, output,
7772 and goto parameters. @xref{AssemblerTemplate}.
7773
7774 @item OutputOperands
7775 A comma-separated list of the C variables modified by the instructions in the
7776 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7777
7778 @item InputOperands
7779 A comma-separated list of C expressions read by the instructions in the
7780 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7781
7782 @item Clobbers
7783 A comma-separated list of registers or other values changed by the
7784 @var{AssemblerTemplate}, beyond those listed as outputs.
7785 An empty list is permitted. @xref{Clobbers}.
7786
7787 @item GotoLabels
7788 When you are using the @code{goto} form of @code{asm}, this section contains
7789 the list of all C labels to which the code in the
7790 @var{AssemblerTemplate} may jump.
7791 @xref{GotoLabels}.
7792
7793 @code{asm} statements may not perform jumps into other @code{asm} statements,
7794 only to the listed @var{GotoLabels}.
7795 GCC's optimizers do not know about other jumps; therefore they cannot take
7796 account of them when deciding how to optimize.
7797 @end table
7798
7799 The total number of input + output + goto operands is limited to 30.
7800
7801 @subsubheading Remarks
7802 The @code{asm} statement allows you to include assembly instructions directly
7803 within C code. This may help you to maximize performance in time-sensitive
7804 code or to access assembly instructions that are not readily available to C
7805 programs.
7806
7807 Note that extended @code{asm} statements must be inside a function. Only
7808 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7809 Functions declared with the @code{naked} attribute also require basic
7810 @code{asm} (@pxref{Function Attributes}).
7811
7812 While the uses of @code{asm} are many and varied, it may help to think of an
7813 @code{asm} statement as a series of low-level instructions that convert input
7814 parameters to output parameters. So a simple (if not particularly useful)
7815 example for i386 using @code{asm} might look like this:
7816
7817 @example
7818 int src = 1;
7819 int dst;
7820
7821 asm ("mov %1, %0\n\t"
7822 "add $1, %0"
7823 : "=r" (dst)
7824 : "r" (src));
7825
7826 printf("%d\n", dst);
7827 @end example
7828
7829 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7830
7831 @anchor{Volatile}
7832 @subsubsection Volatile
7833 @cindex volatile @code{asm}
7834 @cindex @code{asm} volatile
7835
7836 GCC's optimizers sometimes discard @code{asm} statements if they determine
7837 there is no need for the output variables. Also, the optimizers may move
7838 code out of loops if they believe that the code will always return the same
7839 result (i.e. none of its input values change between calls). Using the
7840 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7841 that have no output operands, including @code{asm goto} statements,
7842 are implicitly volatile.
7843
7844 This i386 code demonstrates a case that does not use (or require) the
7845 @code{volatile} qualifier. If it is performing assertion checking, this code
7846 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7847 unreferenced by any code. As a result, the optimizers can discard the
7848 @code{asm} statement, which in turn removes the need for the entire
7849 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7850 isn't needed you allow the optimizers to produce the most efficient code
7851 possible.
7852
7853 @example
7854 void DoCheck(uint32_t dwSomeValue)
7855 @{
7856 uint32_t dwRes;
7857
7858 // Assumes dwSomeValue is not zero.
7859 asm ("bsfl %1,%0"
7860 : "=r" (dwRes)
7861 : "r" (dwSomeValue)
7862 : "cc");
7863
7864 assert(dwRes > 3);
7865 @}
7866 @end example
7867
7868 The next example shows a case where the optimizers can recognize that the input
7869 (@code{dwSomeValue}) never changes during the execution of the function and can
7870 therefore move the @code{asm} outside the loop to produce more efficient code.
7871 Again, using @code{volatile} disables this type of optimization.
7872
7873 @example
7874 void do_print(uint32_t dwSomeValue)
7875 @{
7876 uint32_t dwRes;
7877
7878 for (uint32_t x=0; x < 5; x++)
7879 @{
7880 // Assumes dwSomeValue is not zero.
7881 asm ("bsfl %1,%0"
7882 : "=r" (dwRes)
7883 : "r" (dwSomeValue)
7884 : "cc");
7885
7886 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7887 @}
7888 @}
7889 @end example
7890
7891 The following example demonstrates a case where you need to use the
7892 @code{volatile} qualifier.
7893 It uses the x86 @code{rdtsc} instruction, which reads
7894 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7895 the optimizers might assume that the @code{asm} block will always return the
7896 same value and therefore optimize away the second call.
7897
7898 @example
7899 uint64_t msr;
7900
7901 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7902 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7903 "or %%rdx, %0" // 'Or' in the lower bits.
7904 : "=a" (msr)
7905 :
7906 : "rdx");
7907
7908 printf("msr: %llx\n", msr);
7909
7910 // Do other work...
7911
7912 // Reprint the timestamp
7913 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7914 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7915 "or %%rdx, %0" // 'Or' in the lower bits.
7916 : "=a" (msr)
7917 :
7918 : "rdx");
7919
7920 printf("msr: %llx\n", msr);
7921 @end example
7922
7923 GCC's optimizers do not treat this code like the non-volatile code in the
7924 earlier examples. They do not move it out of loops or omit it on the
7925 assumption that the result from a previous call is still valid.
7926
7927 Note that the compiler can move even volatile @code{asm} instructions relative
7928 to other code, including across jump instructions. For example, on many
7929 targets there is a system register that controls the rounding mode of
7930 floating-point operations. Setting it with a volatile @code{asm}, as in the
7931 following PowerPC example, does not work reliably.
7932
7933 @example
7934 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7935 sum = x + y;
7936 @end example
7937
7938 The compiler may move the addition back before the volatile @code{asm}. To
7939 make it work as expected, add an artificial dependency to the @code{asm} by
7940 referencing a variable in the subsequent code, for example:
7941
7942 @example
7943 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7944 sum = x + y;
7945 @end example
7946
7947 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7948 assembly code when optimizing. This can lead to unexpected duplicate symbol
7949 errors during compilation if your asm code defines symbols or labels.
7950 Using @samp{%=}
7951 (@pxref{AssemblerTemplate}) may help resolve this problem.
7952
7953 @anchor{AssemblerTemplate}
7954 @subsubsection Assembler Template
7955 @cindex @code{asm} assembler template
7956
7957 An assembler template is a literal string containing assembler instructions.
7958 The compiler replaces tokens in the template that refer
7959 to inputs, outputs, and goto labels,
7960 and then outputs the resulting string to the assembler. The
7961 string can contain any instructions recognized by the assembler, including
7962 directives. GCC does not parse the assembler instructions
7963 themselves and does not know what they mean or even whether they are valid
7964 assembler input. However, it does count the statements
7965 (@pxref{Size of an asm}).
7966
7967 You may place multiple assembler instructions together in a single @code{asm}
7968 string, separated by the characters normally used in assembly code for the
7969 system. A combination that works in most places is a newline to break the
7970 line, plus a tab character to move to the instruction field (written as
7971 @samp{\n\t}).
7972 Some assemblers allow semicolons as a line separator. However, note
7973 that some assembler dialects use semicolons to start a comment.
7974
7975 Do not expect a sequence of @code{asm} statements to remain perfectly
7976 consecutive after compilation, even when you are using the @code{volatile}
7977 qualifier. If certain instructions need to remain consecutive in the output,
7978 put them in a single multi-instruction asm statement.
7979
7980 Accessing data from C programs without using input/output operands (such as
7981 by using global symbols directly from the assembler template) may not work as
7982 expected. Similarly, calling functions directly from an assembler template
7983 requires a detailed understanding of the target assembler and ABI.
7984
7985 Since GCC does not parse the assembler template,
7986 it has no visibility of any
7987 symbols it references. This may result in GCC discarding those symbols as
7988 unreferenced unless they are also listed as input, output, or goto operands.
7989
7990 @subsubheading Special format strings
7991
7992 In addition to the tokens described by the input, output, and goto operands,
7993 these tokens have special meanings in the assembler template:
7994
7995 @table @samp
7996 @item %%
7997 Outputs a single @samp{%} into the assembler code.
7998
7999 @item %=
8000 Outputs a number that is unique to each instance of the @code{asm}
8001 statement in the entire compilation. This option is useful when creating local
8002 labels and referring to them multiple times in a single template that
8003 generates multiple assembler instructions.
8004
8005 @item %@{
8006 @itemx %|
8007 @itemx %@}
8008 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8009 into the assembler code. When unescaped, these characters have special
8010 meaning to indicate multiple assembler dialects, as described below.
8011 @end table
8012
8013 @subsubheading Multiple assembler dialects in @code{asm} templates
8014
8015 On targets such as x86, GCC supports multiple assembler dialects.
8016 The @option{-masm} option controls which dialect GCC uses as its
8017 default for inline assembler. The target-specific documentation for the
8018 @option{-masm} option contains the list of supported dialects, as well as the
8019 default dialect if the option is not specified. This information may be
8020 important to understand, since assembler code that works correctly when
8021 compiled using one dialect will likely fail if compiled using another.
8022 @xref{x86 Options}.
8023
8024 If your code needs to support multiple assembler dialects (for example, if
8025 you are writing public headers that need to support a variety of compilation
8026 options), use constructs of this form:
8027
8028 @example
8029 @{ dialect0 | dialect1 | dialect2... @}
8030 @end example
8031
8032 This construct outputs @code{dialect0}
8033 when using dialect #0 to compile the code,
8034 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
8035 braces than the number of dialects the compiler supports, the construct
8036 outputs nothing.
8037
8038 For example, if an x86 compiler supports two dialects
8039 (@samp{att}, @samp{intel}), an
8040 assembler template such as this:
8041
8042 @example
8043 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8044 @end example
8045
8046 @noindent
8047 is equivalent to one of
8048
8049 @example
8050 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
8051 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
8052 @end example
8053
8054 Using that same compiler, this code:
8055
8056 @example
8057 "xchg@{l@}\t@{%%@}ebx, %1"
8058 @end example
8059
8060 @noindent
8061 corresponds to either
8062
8063 @example
8064 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8065 "xchg\tebx, %1" @r{/* intel dialect */}
8066 @end example
8067
8068 There is no support for nesting dialect alternatives.
8069
8070 @anchor{OutputOperands}
8071 @subsubsection Output Operands
8072 @cindex @code{asm} output operands
8073
8074 An @code{asm} statement has zero or more output operands indicating the names
8075 of C variables modified by the assembler code.
8076
8077 In this i386 example, @code{old} (referred to in the template string as
8078 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8079 (@code{%2}) is an input:
8080
8081 @example
8082 bool old;
8083
8084 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8085 "sbb %0,%0" // Use the CF to calculate old.
8086 : "=r" (old), "+rm" (*Base)
8087 : "Ir" (Offset)
8088 : "cc");
8089
8090 return old;
8091 @end example
8092
8093 Operands are separated by commas. Each operand has this format:
8094
8095 @example
8096 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8097 @end example
8098
8099 @table @var
8100 @item asmSymbolicName
8101 Specifies a symbolic name for the operand.
8102 Reference the name in the assembler template
8103 by enclosing it in square brackets
8104 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8105 that contains the definition. Any valid C variable name is acceptable,
8106 including names already defined in the surrounding code. No two operands
8107 within the same @code{asm} statement can use the same symbolic name.
8108
8109 When not using an @var{asmSymbolicName}, use the (zero-based) position
8110 of the operand
8111 in the list of operands in the assembler template. For example if there are
8112 three output operands, use @samp{%0} in the template to refer to the first,
8113 @samp{%1} for the second, and @samp{%2} for the third.
8114
8115 @item constraint
8116 A string constant specifying constraints on the placement of the operand;
8117 @xref{Constraints}, for details.
8118
8119 Output constraints must begin with either @samp{=} (a variable overwriting an
8120 existing value) or @samp{+} (when reading and writing). When using
8121 @samp{=}, do not assume the location contains the existing value
8122 on entry to the @code{asm}, except
8123 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8124
8125 After the prefix, there must be one or more additional constraints
8126 (@pxref{Constraints}) that describe where the value resides. Common
8127 constraints include @samp{r} for register and @samp{m} for memory.
8128 When you list more than one possible location (for example, @code{"=rm"}),
8129 the compiler chooses the most efficient one based on the current context.
8130 If you list as many alternates as the @code{asm} statement allows, you permit
8131 the optimizers to produce the best possible code.
8132 If you must use a specific register, but your Machine Constraints do not
8133 provide sufficient control to select the specific register you want,
8134 local register variables may provide a solution (@pxref{Local Register
8135 Variables}).
8136
8137 @item cvariablename
8138 Specifies a C lvalue expression to hold the output, typically a variable name.
8139 The enclosing parentheses are a required part of the syntax.
8140
8141 @end table
8142
8143 When the compiler selects the registers to use to
8144 represent the output operands, it does not use any of the clobbered registers
8145 (@pxref{Clobbers}).
8146
8147 Output operand expressions must be lvalues. The compiler cannot check whether
8148 the operands have data types that are reasonable for the instruction being
8149 executed. For output expressions that are not directly addressable (for
8150 example a bit-field), the constraint must allow a register. In that case, GCC
8151 uses the register as the output of the @code{asm}, and then stores that
8152 register into the output.
8153
8154 Operands using the @samp{+} constraint modifier count as two operands
8155 (that is, both as input and output) towards the total maximum of 30 operands
8156 per @code{asm} statement.
8157
8158 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8159 operands that must not overlap an input. Otherwise,
8160 GCC may allocate the output operand in the same register as an unrelated
8161 input operand, on the assumption that the assembler code consumes its
8162 inputs before producing outputs. This assumption may be false if the assembler
8163 code actually consists of more than one instruction.
8164
8165 The same problem can occur if one output parameter (@var{a}) allows a register
8166 constraint and another output parameter (@var{b}) allows a memory constraint.
8167 The code generated by GCC to access the memory address in @var{b} can contain
8168 registers which @emph{might} be shared by @var{a}, and GCC considers those
8169 registers to be inputs to the asm. As above, GCC assumes that such input
8170 registers are consumed before any outputs are written. This assumption may
8171 result in incorrect behavior if the asm writes to @var{a} before using
8172 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8173 ensures that modifying @var{a} does not affect the address referenced by
8174 @var{b}. Otherwise, the location of @var{b}
8175 is undefined if @var{a} is modified before using @var{b}.
8176
8177 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8178 instead of simply @samp{%2}). Typically these qualifiers are hardware
8179 dependent. The list of supported modifiers for x86 is found at
8180 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8181
8182 If the C code that follows the @code{asm} makes no use of any of the output
8183 operands, use @code{volatile} for the @code{asm} statement to prevent the
8184 optimizers from discarding the @code{asm} statement as unneeded
8185 (see @ref{Volatile}).
8186
8187 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8188 references the first output operand as @code{%0} (were there a second, it
8189 would be @code{%1}, etc). The number of the first input operand is one greater
8190 than that of the last output operand. In this i386 example, that makes
8191 @code{Mask} referenced as @code{%1}:
8192
8193 @example
8194 uint32_t Mask = 1234;
8195 uint32_t Index;
8196
8197 asm ("bsfl %1, %0"
8198 : "=r" (Index)
8199 : "r" (Mask)
8200 : "cc");
8201 @end example
8202
8203 That code overwrites the variable @code{Index} (@samp{=}),
8204 placing the value in a register (@samp{r}).
8205 Using the generic @samp{r} constraint instead of a constraint for a specific
8206 register allows the compiler to pick the register to use, which can result
8207 in more efficient code. This may not be possible if an assembler instruction
8208 requires a specific register.
8209
8210 The following i386 example uses the @var{asmSymbolicName} syntax.
8211 It produces the
8212 same result as the code above, but some may consider it more readable or more
8213 maintainable since reordering index numbers is not necessary when adding or
8214 removing operands. The names @code{aIndex} and @code{aMask}
8215 are only used in this example to emphasize which
8216 names get used where.
8217 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8218
8219 @example
8220 uint32_t Mask = 1234;
8221 uint32_t Index;
8222
8223 asm ("bsfl %[aMask], %[aIndex]"
8224 : [aIndex] "=r" (Index)
8225 : [aMask] "r" (Mask)
8226 : "cc");
8227 @end example
8228
8229 Here are some more examples of output operands.
8230
8231 @example
8232 uint32_t c = 1;
8233 uint32_t d;
8234 uint32_t *e = &c;
8235
8236 asm ("mov %[e], %[d]"
8237 : [d] "=rm" (d)
8238 : [e] "rm" (*e));
8239 @end example
8240
8241 Here, @code{d} may either be in a register or in memory. Since the compiler
8242 might already have the current value of the @code{uint32_t} location
8243 pointed to by @code{e}
8244 in a register, you can enable it to choose the best location
8245 for @code{d} by specifying both constraints.
8246
8247 @anchor{FlagOutputOperands}
8248 @subsubsection Flag Output Operands
8249 @cindex @code{asm} flag output operands
8250
8251 Some targets have a special register that holds the ``flags'' for the
8252 result of an operation or comparison. Normally, the contents of that
8253 register are either unmodifed by the asm, or the asm is considered to
8254 clobber the contents.
8255
8256 On some targets, a special form of output operand exists by which
8257 conditions in the flags register may be outputs of the asm. The set of
8258 conditions supported are target specific, but the general rule is that
8259 the output variable must be a scalar integer, and the value is boolean.
8260 When supported, the target defines the preprocessor symbol
8261 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8262
8263 Because of the special nature of the flag output operands, the constraint
8264 may not include alternatives.
8265
8266 Most often, the target has only one flags register, and thus is an implied
8267 operand of many instructions. In this case, the operand should not be
8268 referenced within the assembler template via @code{%0} etc, as there's
8269 no corresponding text in the assembly language.
8270
8271 @table @asis
8272 @item x86 family
8273 The flag output constraints for the x86 family are of the form
8274 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8275 conditions defined in the ISA manual for @code{j@var{cc}} or
8276 @code{set@var{cc}}.
8277
8278 @table @code
8279 @item a
8280 ``above'' or unsigned greater than
8281 @item ae
8282 ``above or equal'' or unsigned greater than or equal
8283 @item b
8284 ``below'' or unsigned less than
8285 @item be
8286 ``below or equal'' or unsigned less than or equal
8287 @item c
8288 carry flag set
8289 @item e
8290 @itemx z
8291 ``equal'' or zero flag set
8292 @item g
8293 signed greater than
8294 @item ge
8295 signed greater than or equal
8296 @item l
8297 signed less than
8298 @item le
8299 signed less than or equal
8300 @item o
8301 overflow flag set
8302 @item p
8303 parity flag set
8304 @item s
8305 sign flag set
8306 @item na
8307 @itemx nae
8308 @itemx nb
8309 @itemx nbe
8310 @itemx nc
8311 @itemx ne
8312 @itemx ng
8313 @itemx nge
8314 @itemx nl
8315 @itemx nle
8316 @itemx no
8317 @itemx np
8318 @itemx ns
8319 @itemx nz
8320 ``not'' @var{flag}, or inverted versions of those above
8321 @end table
8322
8323 @end table
8324
8325 @anchor{InputOperands}
8326 @subsubsection Input Operands
8327 @cindex @code{asm} input operands
8328 @cindex @code{asm} expressions
8329
8330 Input operands make values from C variables and expressions available to the
8331 assembly code.
8332
8333 Operands are separated by commas. Each operand has this format:
8334
8335 @example
8336 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8337 @end example
8338
8339 @table @var
8340 @item asmSymbolicName
8341 Specifies a symbolic name for the operand.
8342 Reference the name in the assembler template
8343 by enclosing it in square brackets
8344 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8345 that contains the definition. Any valid C variable name is acceptable,
8346 including names already defined in the surrounding code. No two operands
8347 within the same @code{asm} statement can use the same symbolic name.
8348
8349 When not using an @var{asmSymbolicName}, use the (zero-based) position
8350 of the operand
8351 in the list of operands in the assembler template. For example if there are
8352 two output operands and three inputs,
8353 use @samp{%2} in the template to refer to the first input operand,
8354 @samp{%3} for the second, and @samp{%4} for the third.
8355
8356 @item constraint
8357 A string constant specifying constraints on the placement of the operand;
8358 @xref{Constraints}, for details.
8359
8360 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8361 When you list more than one possible location (for example, @samp{"irm"}),
8362 the compiler chooses the most efficient one based on the current context.
8363 If you must use a specific register, but your Machine Constraints do not
8364 provide sufficient control to select the specific register you want,
8365 local register variables may provide a solution (@pxref{Local Register
8366 Variables}).
8367
8368 Input constraints can also be digits (for example, @code{"0"}). This indicates
8369 that the specified input must be in the same place as the output constraint
8370 at the (zero-based) index in the output constraint list.
8371 When using @var{asmSymbolicName} syntax for the output operands,
8372 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8373
8374 @item cexpression
8375 This is the C variable or expression being passed to the @code{asm} statement
8376 as input. The enclosing parentheses are a required part of the syntax.
8377
8378 @end table
8379
8380 When the compiler selects the registers to use to represent the input
8381 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8382
8383 If there are no output operands but there are input operands, place two
8384 consecutive colons where the output operands would go:
8385
8386 @example
8387 __asm__ ("some instructions"
8388 : /* No outputs. */
8389 : "r" (Offset / 8));
8390 @end example
8391
8392 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8393 (except for inputs tied to outputs). The compiler assumes that on exit from
8394 the @code{asm} statement these operands contain the same values as they
8395 had before executing the statement.
8396 It is @emph{not} possible to use clobbers
8397 to inform the compiler that the values in these inputs are changing. One
8398 common work-around is to tie the changing input variable to an output variable
8399 that never gets used. Note, however, that if the code that follows the
8400 @code{asm} statement makes no use of any of the output operands, the GCC
8401 optimizers may discard the @code{asm} statement as unneeded
8402 (see @ref{Volatile}).
8403
8404 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8405 instead of simply @samp{%2}). Typically these qualifiers are hardware
8406 dependent. The list of supported modifiers for x86 is found at
8407 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8408
8409 In this example using the fictitious @code{combine} instruction, the
8410 constraint @code{"0"} for input operand 1 says that it must occupy the same
8411 location as output operand 0. Only input operands may use numbers in
8412 constraints, and they must each refer to an output operand. Only a number (or
8413 the symbolic assembler name) in the constraint can guarantee that one operand
8414 is in the same place as another. The mere fact that @code{foo} is the value of
8415 both operands is not enough to guarantee that they are in the same place in
8416 the generated assembler code.
8417
8418 @example
8419 asm ("combine %2, %0"
8420 : "=r" (foo)
8421 : "0" (foo), "g" (bar));
8422 @end example
8423
8424 Here is an example using symbolic names.
8425
8426 @example
8427 asm ("cmoveq %1, %2, %[result]"
8428 : [result] "=r"(result)
8429 : "r" (test), "r" (new), "[result]" (old));
8430 @end example
8431
8432 @anchor{Clobbers}
8433 @subsubsection Clobbers
8434 @cindex @code{asm} clobbers
8435
8436 While the compiler is aware of changes to entries listed in the output
8437 operands, the inline @code{asm} code may modify more than just the outputs. For
8438 example, calculations may require additional registers, or the processor may
8439 overwrite a register as a side effect of a particular assembler instruction.
8440 In order to inform the compiler of these changes, list them in the clobber
8441 list. Clobber list items are either register names or the special clobbers
8442 (listed below). Each clobber list item is a string constant
8443 enclosed in double quotes and separated by commas.
8444
8445 Clobber descriptions may not in any way overlap with an input or output
8446 operand. For example, you may not have an operand describing a register class
8447 with one member when listing that register in the clobber list. Variables
8448 declared to live in specific registers (@pxref{Explicit Register
8449 Variables}) and used
8450 as @code{asm} input or output operands must have no part mentioned in the
8451 clobber description. In particular, there is no way to specify that input
8452 operands get modified without also specifying them as output operands.
8453
8454 When the compiler selects which registers to use to represent input and output
8455 operands, it does not use any of the clobbered registers. As a result,
8456 clobbered registers are available for any use in the assembler code.
8457
8458 Here is a realistic example for the VAX showing the use of clobbered
8459 registers:
8460
8461 @example
8462 asm volatile ("movc3 %0, %1, %2"
8463 : /* No outputs. */
8464 : "g" (from), "g" (to), "g" (count)
8465 : "r0", "r1", "r2", "r3", "r4", "r5");
8466 @end example
8467
8468 Also, there are two special clobber arguments:
8469
8470 @table @code
8471 @item "cc"
8472 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8473 register. On some machines, GCC represents the condition codes as a specific
8474 hardware register; @code{"cc"} serves to name this register.
8475 On other machines, condition code handling is different,
8476 and specifying @code{"cc"} has no effect. But
8477 it is valid no matter what the target.
8478
8479 @item "memory"
8480 The @code{"memory"} clobber tells the compiler that the assembly code
8481 performs memory
8482 reads or writes to items other than those listed in the input and output
8483 operands (for example, accessing the memory pointed to by one of the input
8484 parameters). To ensure memory contains correct values, GCC may need to flush
8485 specific register values to memory before executing the @code{asm}. Further,
8486 the compiler does not assume that any values read from memory before an
8487 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8488 needed.
8489 Using the @code{"memory"} clobber effectively forms a read/write
8490 memory barrier for the compiler.
8491
8492 Note that this clobber does not prevent the @emph{processor} from doing
8493 speculative reads past the @code{asm} statement. To prevent that, you need
8494 processor-specific fence instructions.
8495
8496 Flushing registers to memory has performance implications and may be an issue
8497 for time-sensitive code. You can use a trick to avoid this if the size of
8498 the memory being accessed is known at compile time. For example, if accessing
8499 ten bytes of a string, use a memory input like:
8500
8501 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8502
8503 @end table
8504
8505 @anchor{GotoLabels}
8506 @subsubsection Goto Labels
8507 @cindex @code{asm} goto labels
8508
8509 @code{asm goto} allows assembly code to jump to one or more C labels. The
8510 @var{GotoLabels} section in an @code{asm goto} statement contains
8511 a comma-separated
8512 list of all C labels to which the assembler code may jump. GCC assumes that
8513 @code{asm} execution falls through to the next statement (if this is not the
8514 case, consider using the @code{__builtin_unreachable} intrinsic after the
8515 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8516 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8517 Attributes}).
8518
8519 An @code{asm goto} statement cannot have outputs.
8520 This is due to an internal restriction of
8521 the compiler: control transfer instructions cannot have outputs.
8522 If the assembler code does modify anything, use the @code{"memory"} clobber
8523 to force the
8524 optimizers to flush all register values to memory and reload them if
8525 necessary after the @code{asm} statement.
8526
8527 Also note that an @code{asm goto} statement is always implicitly
8528 considered volatile.
8529
8530 To reference a label in the assembler template,
8531 prefix it with @samp{%l} (lowercase @samp{L}) followed
8532 by its (zero-based) position in @var{GotoLabels} plus the number of input
8533 operands. For example, if the @code{asm} has three inputs and references two
8534 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8535
8536 Alternately, you can reference labels using the actual C label name enclosed
8537 in brackets. For example, to reference a label named @code{carry}, you can
8538 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8539 section when using this approach.
8540
8541 Here is an example of @code{asm goto} for i386:
8542
8543 @example
8544 asm goto (
8545 "btl %1, %0\n\t"
8546 "jc %l2"
8547 : /* No outputs. */
8548 : "r" (p1), "r" (p2)
8549 : "cc"
8550 : carry);
8551
8552 return 0;
8553
8554 carry:
8555 return 1;
8556 @end example
8557
8558 The following example shows an @code{asm goto} that uses a memory clobber.
8559
8560 @example
8561 int frob(int x)
8562 @{
8563 int y;
8564 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8565 : /* No outputs. */
8566 : "r"(x), "r"(&y)
8567 : "r5", "memory"
8568 : error);
8569 return y;
8570 error:
8571 return -1;
8572 @}
8573 @end example
8574
8575 @anchor{x86Operandmodifiers}
8576 @subsubsection x86 Operand Modifiers
8577
8578 References to input, output, and goto operands in the assembler template
8579 of extended @code{asm} statements can use
8580 modifiers to affect the way the operands are formatted in
8581 the code output to the assembler. For example, the
8582 following code uses the @samp{h} and @samp{b} modifiers for x86:
8583
8584 @example
8585 uint16_t num;
8586 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8587 @end example
8588
8589 @noindent
8590 These modifiers generate this assembler code:
8591
8592 @example
8593 xchg %ah, %al
8594 @end example
8595
8596 The rest of this discussion uses the following code for illustrative purposes.
8597
8598 @example
8599 int main()
8600 @{
8601 int iInt = 1;
8602
8603 top:
8604
8605 asm volatile goto ("some assembler instructions here"
8606 : /* No outputs. */
8607 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8608 : /* No clobbers. */
8609 : top);
8610 @}
8611 @end example
8612
8613 With no modifiers, this is what the output from the operands would be for the
8614 @samp{att} and @samp{intel} dialects of assembler:
8615
8616 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8617 @headitem Operand @tab masm=att @tab masm=intel
8618 @item @code{%0}
8619 @tab @code{%eax}
8620 @tab @code{eax}
8621 @item @code{%1}
8622 @tab @code{$2}
8623 @tab @code{2}
8624 @item @code{%2}
8625 @tab @code{$.L2}
8626 @tab @code{OFFSET FLAT:.L2}
8627 @end multitable
8628
8629 The table below shows the list of supported modifiers and their effects.
8630
8631 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8632 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8633 @item @code{z}
8634 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8635 @tab @code{%z0}
8636 @tab @code{l}
8637 @tab
8638 @item @code{b}
8639 @tab Print the QImode name of the register.
8640 @tab @code{%b0}
8641 @tab @code{%al}
8642 @tab @code{al}
8643 @item @code{h}
8644 @tab Print the QImode name for a ``high'' register.
8645 @tab @code{%h0}
8646 @tab @code{%ah}
8647 @tab @code{ah}
8648 @item @code{w}
8649 @tab Print the HImode name of the register.
8650 @tab @code{%w0}
8651 @tab @code{%ax}
8652 @tab @code{ax}
8653 @item @code{k}
8654 @tab Print the SImode name of the register.
8655 @tab @code{%k0}
8656 @tab @code{%eax}
8657 @tab @code{eax}
8658 @item @code{q}
8659 @tab Print the DImode name of the register.
8660 @tab @code{%q0}
8661 @tab @code{%rax}
8662 @tab @code{rax}
8663 @item @code{l}
8664 @tab Print the label name with no punctuation.
8665 @tab @code{%l2}
8666 @tab @code{.L2}
8667 @tab @code{.L2}
8668 @item @code{c}
8669 @tab Require a constant operand and print the constant expression with no punctuation.
8670 @tab @code{%c1}
8671 @tab @code{2}
8672 @tab @code{2}
8673 @end multitable
8674
8675 @anchor{x86floatingpointasmoperands}
8676 @subsubsection x86 Floating-Point @code{asm} Operands
8677
8678 On x86 targets, there are several rules on the usage of stack-like registers
8679 in the operands of an @code{asm}. These rules apply only to the operands
8680 that are stack-like registers:
8681
8682 @enumerate
8683 @item
8684 Given a set of input registers that die in an @code{asm}, it is
8685 necessary to know which are implicitly popped by the @code{asm}, and
8686 which must be explicitly popped by GCC@.
8687
8688 An input register that is implicitly popped by the @code{asm} must be
8689 explicitly clobbered, unless it is constrained to match an
8690 output operand.
8691
8692 @item
8693 For any input register that is implicitly popped by an @code{asm}, it is
8694 necessary to know how to adjust the stack to compensate for the pop.
8695 If any non-popped input is closer to the top of the reg-stack than
8696 the implicitly popped register, it would not be possible to know what the
8697 stack looked like---it's not clear how the rest of the stack ``slides
8698 up''.
8699
8700 All implicitly popped input registers must be closer to the top of
8701 the reg-stack than any input that is not implicitly popped.
8702
8703 It is possible that if an input dies in an @code{asm}, the compiler might
8704 use the input register for an output reload. Consider this example:
8705
8706 @smallexample
8707 asm ("foo" : "=t" (a) : "f" (b));
8708 @end smallexample
8709
8710 @noindent
8711 This code says that input @code{b} is not popped by the @code{asm}, and that
8712 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8713 deeper after the @code{asm} than it was before. But, it is possible that
8714 reload may think that it can use the same register for both the input and
8715 the output.
8716
8717 To prevent this from happening,
8718 if any input operand uses the @samp{f} constraint, all output register
8719 constraints must use the @samp{&} early-clobber modifier.
8720
8721 The example above is correctly written as:
8722
8723 @smallexample
8724 asm ("foo" : "=&t" (a) : "f" (b));
8725 @end smallexample
8726
8727 @item
8728 Some operands need to be in particular places on the stack. All
8729 output operands fall in this category---GCC has no other way to
8730 know which registers the outputs appear in unless you indicate
8731 this in the constraints.
8732
8733 Output operands must specifically indicate which register an output
8734 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8735 constraints must select a class with a single register.
8736
8737 @item
8738 Output operands may not be ``inserted'' between existing stack registers.
8739 Since no 387 opcode uses a read/write operand, all output operands
8740 are dead before the @code{asm}, and are pushed by the @code{asm}.
8741 It makes no sense to push anywhere but the top of the reg-stack.
8742
8743 Output operands must start at the top of the reg-stack: output
8744 operands may not ``skip'' a register.
8745
8746 @item
8747 Some @code{asm} statements may need extra stack space for internal
8748 calculations. This can be guaranteed by clobbering stack registers
8749 unrelated to the inputs and outputs.
8750
8751 @end enumerate
8752
8753 This @code{asm}
8754 takes one input, which is internally popped, and produces two outputs.
8755
8756 @smallexample
8757 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8758 @end smallexample
8759
8760 @noindent
8761 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8762 and replaces them with one output. The @code{st(1)} clobber is necessary
8763 for the compiler to know that @code{fyl2xp1} pops both inputs.
8764
8765 @smallexample
8766 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8767 @end smallexample
8768
8769 @lowersections
8770 @include md.texi
8771 @raisesections
8772
8773 @node Asm Labels
8774 @subsection Controlling Names Used in Assembler Code
8775 @cindex assembler names for identifiers
8776 @cindex names used in assembler code
8777 @cindex identifiers, names in assembler code
8778
8779 You can specify the name to be used in the assembler code for a C
8780 function or variable by writing the @code{asm} (or @code{__asm__})
8781 keyword after the declarator.
8782 It is up to you to make sure that the assembler names you choose do not
8783 conflict with any other assembler symbols, or reference registers.
8784
8785 @subsubheading Assembler names for data:
8786
8787 This sample shows how to specify the assembler name for data:
8788
8789 @smallexample
8790 int foo asm ("myfoo") = 2;
8791 @end smallexample
8792
8793 @noindent
8794 This specifies that the name to be used for the variable @code{foo} in
8795 the assembler code should be @samp{myfoo} rather than the usual
8796 @samp{_foo}.
8797
8798 On systems where an underscore is normally prepended to the name of a C
8799 variable, this feature allows you to define names for the
8800 linker that do not start with an underscore.
8801
8802 GCC does not support using this feature with a non-static local variable
8803 since such variables do not have assembler names. If you are
8804 trying to put the variable in a particular register, see
8805 @ref{Explicit Register Variables}.
8806
8807 @subsubheading Assembler names for functions:
8808
8809 To specify the assembler name for functions, write a declaration for the
8810 function before its definition and put @code{asm} there, like this:
8811
8812 @smallexample
8813 int func (int x, int y) asm ("MYFUNC");
8814
8815 int func (int x, int y)
8816 @{
8817 /* @r{@dots{}} */
8818 @end smallexample
8819
8820 @noindent
8821 This specifies that the name to be used for the function @code{func} in
8822 the assembler code should be @code{MYFUNC}.
8823
8824 @node Explicit Register Variables
8825 @subsection Variables in Specified Registers
8826 @anchor{Explicit Reg Vars}
8827 @cindex explicit register variables
8828 @cindex variables in specified registers
8829 @cindex specified registers
8830
8831 GNU C allows you to associate specific hardware registers with C
8832 variables. In almost all cases, allowing the compiler to assign
8833 registers produces the best code. However under certain unusual
8834 circumstances, more precise control over the variable storage is
8835 required.
8836
8837 Both global and local variables can be associated with a register. The
8838 consequences of performing this association are very different between
8839 the two, as explained in the sections below.
8840
8841 @menu
8842 * Global Register Variables:: Variables declared at global scope.
8843 * Local Register Variables:: Variables declared within a function.
8844 @end menu
8845
8846 @node Global Register Variables
8847 @subsubsection Defining Global Register Variables
8848 @anchor{Global Reg Vars}
8849 @cindex global register variables
8850 @cindex registers, global variables in
8851 @cindex registers, global allocation
8852
8853 You can define a global register variable and associate it with a specified
8854 register like this:
8855
8856 @smallexample
8857 register int *foo asm ("r12");
8858 @end smallexample
8859
8860 @noindent
8861 Here @code{r12} is the name of the register that should be used. Note that
8862 this is the same syntax used for defining local register variables, but for
8863 a global variable the declaration appears outside a function. The
8864 @code{register} keyword is required, and cannot be combined with
8865 @code{static}. The register name must be a valid register name for the
8866 target platform.
8867
8868 Registers are a scarce resource on most systems and allowing the
8869 compiler to manage their usage usually results in the best code. However,
8870 under special circumstances it can make sense to reserve some globally.
8871 For example this may be useful in programs such as programming language
8872 interpreters that have a couple of global variables that are accessed
8873 very often.
8874
8875 After defining a global register variable, for the current compilation
8876 unit:
8877
8878 @itemize @bullet
8879 @item The register is reserved entirely for this use, and will not be
8880 allocated for any other purpose.
8881 @item The register is not saved and restored by any functions.
8882 @item Stores into this register are never deleted even if they appear to be
8883 dead, but references may be deleted, moved or simplified.
8884 @end itemize
8885
8886 Note that these points @emph{only} apply to code that is compiled with the
8887 definition. The behavior of code that is merely linked in (for example
8888 code from libraries) is not affected.
8889
8890 If you want to recompile source files that do not actually use your global
8891 register variable so they do not use the specified register for any other
8892 purpose, you need not actually add the global register declaration to
8893 their source code. It suffices to specify the compiler option
8894 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8895 register.
8896
8897 @subsubheading Declaring the variable
8898
8899 Global register variables can not have initial values, because an
8900 executable file has no means to supply initial contents for a register.
8901
8902 When selecting a register, choose one that is normally saved and
8903 restored by function calls on your machine. This ensures that code
8904 which is unaware of this reservation (such as library routines) will
8905 restore it before returning.
8906
8907 On machines with register windows, be sure to choose a global
8908 register that is not affected magically by the function call mechanism.
8909
8910 @subsubheading Using the variable
8911
8912 @cindex @code{qsort}, and global register variables
8913 When calling routines that are not aware of the reservation, be
8914 cautious if those routines call back into code which uses them. As an
8915 example, if you call the system library version of @code{qsort}, it may
8916 clobber your registers during execution, but (if you have selected
8917 appropriate registers) it will restore them before returning. However
8918 it will @emph{not} restore them before calling @code{qsort}'s comparison
8919 function. As a result, global values will not reliably be available to
8920 the comparison function unless the @code{qsort} function itself is rebuilt.
8921
8922 Similarly, it is not safe to access the global register variables from signal
8923 handlers or from more than one thread of control. Unless you recompile
8924 them specially for the task at hand, the system library routines may
8925 temporarily use the register for other things.
8926
8927 @cindex register variable after @code{longjmp}
8928 @cindex global register after @code{longjmp}
8929 @cindex value after @code{longjmp}
8930 @findex longjmp
8931 @findex setjmp
8932 On most machines, @code{longjmp} restores to each global register
8933 variable the value it had at the time of the @code{setjmp}. On some
8934 machines, however, @code{longjmp} does not change the value of global
8935 register variables. To be portable, the function that called @code{setjmp}
8936 should make other arrangements to save the values of the global register
8937 variables, and to restore them in a @code{longjmp}. This way, the same
8938 thing happens regardless of what @code{longjmp} does.
8939
8940 Eventually there may be a way of asking the compiler to choose a register
8941 automatically, but first we need to figure out how it should choose and
8942 how to enable you to guide the choice. No solution is evident.
8943
8944 @node Local Register Variables
8945 @subsubsection Specifying Registers for Local Variables
8946 @anchor{Local Reg Vars}
8947 @cindex local variables, specifying registers
8948 @cindex specifying registers for local variables
8949 @cindex registers for local variables
8950
8951 You can define a local register variable and associate it with a specified
8952 register like this:
8953
8954 @smallexample
8955 register int *foo asm ("r12");
8956 @end smallexample
8957
8958 @noindent
8959 Here @code{r12} is the name of the register that should be used. Note
8960 that this is the same syntax used for defining global register variables,
8961 but for a local variable the declaration appears within a function. The
8962 @code{register} keyword is required, and cannot be combined with
8963 @code{static}. The register name must be a valid register name for the
8964 target platform.
8965
8966 As with global register variables, it is recommended that you choose
8967 a register that is normally saved and restored by function calls on your
8968 machine, so that calls to library routines will not clobber it.
8969
8970 The only supported use for this feature is to specify registers
8971 for input and output operands when calling Extended @code{asm}
8972 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8973 particular machine don't provide sufficient control to select the desired
8974 register. To force an operand into a register, create a local variable
8975 and specify the register name after the variable's declaration. Then use
8976 the local variable for the @code{asm} operand and specify any constraint
8977 letter that matches the register:
8978
8979 @smallexample
8980 register int *p1 asm ("r0") = @dots{};
8981 register int *p2 asm ("r1") = @dots{};
8982 register int *result asm ("r0");
8983 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8984 @end smallexample
8985
8986 @emph{Warning:} In the above example, be aware that a register (for example
8987 @code{r0}) can be call-clobbered by subsequent code, including function
8988 calls and library calls for arithmetic operators on other variables (for
8989 example the initialization of @code{p2}). In this case, use temporary
8990 variables for expressions between the register assignments:
8991
8992 @smallexample
8993 int t1 = @dots{};
8994 register int *p1 asm ("r0") = @dots{};
8995 register int *p2 asm ("r1") = t1;
8996 register int *result asm ("r0");
8997 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8998 @end smallexample
8999
9000 Defining a register variable does not reserve the register. Other than
9001 when invoking the Extended @code{asm}, the contents of the specified
9002 register are not guaranteed. For this reason, the following uses
9003 are explicitly @emph{not} supported. If they appear to work, it is only
9004 happenstance, and may stop working as intended due to (seemingly)
9005 unrelated changes in surrounding code, or even minor changes in the
9006 optimization of a future version of gcc:
9007
9008 @itemize @bullet
9009 @item Passing parameters to or from Basic @code{asm}
9010 @item Passing parameters to or from Extended @code{asm} without using input
9011 or output operands.
9012 @item Passing parameters to or from routines written in assembler (or
9013 other languages) using non-standard calling conventions.
9014 @end itemize
9015
9016 Some developers use Local Register Variables in an attempt to improve
9017 gcc's allocation of registers, especially in large functions. In this
9018 case the register name is essentially a hint to the register allocator.
9019 While in some instances this can generate better code, improvements are
9020 subject to the whims of the allocator/optimizers. Since there are no
9021 guarantees that your improvements won't be lost, this usage of Local
9022 Register Variables is discouraged.
9023
9024 On the MIPS platform, there is related use for local register variables
9025 with slightly different characteristics (@pxref{MIPS Coprocessors,,
9026 Defining coprocessor specifics for MIPS targets, gccint,
9027 GNU Compiler Collection (GCC) Internals}).
9028
9029 @node Size of an asm
9030 @subsection Size of an @code{asm}
9031
9032 Some targets require that GCC track the size of each instruction used
9033 in order to generate correct code. Because the final length of the
9034 code produced by an @code{asm} statement is only known by the
9035 assembler, GCC must make an estimate as to how big it will be. It
9036 does this by counting the number of instructions in the pattern of the
9037 @code{asm} and multiplying that by the length of the longest
9038 instruction supported by that processor. (When working out the number
9039 of instructions, it assumes that any occurrence of a newline or of
9040 whatever statement separator character is supported by the assembler --
9041 typically @samp{;} --- indicates the end of an instruction.)
9042
9043 Normally, GCC's estimate is adequate to ensure that correct
9044 code is generated, but it is possible to confuse the compiler if you use
9045 pseudo instructions or assembler macros that expand into multiple real
9046 instructions, or if you use assembler directives that expand to more
9047 space in the object file than is needed for a single instruction.
9048 If this happens then the assembler may produce a diagnostic saying that
9049 a label is unreachable.
9050
9051 @node Alternate Keywords
9052 @section Alternate Keywords
9053 @cindex alternate keywords
9054 @cindex keywords, alternate
9055
9056 @option{-ansi} and the various @option{-std} options disable certain
9057 keywords. This causes trouble when you want to use GNU C extensions, or
9058 a general-purpose header file that should be usable by all programs,
9059 including ISO C programs. The keywords @code{asm}, @code{typeof} and
9060 @code{inline} are not available in programs compiled with
9061 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9062 program compiled with @option{-std=c99} or @option{-std=c11}). The
9063 ISO C99 keyword
9064 @code{restrict} is only available when @option{-std=gnu99} (which will
9065 eventually be the default) or @option{-std=c99} (or the equivalent
9066 @option{-std=iso9899:1999}), or an option for a later standard
9067 version, is used.
9068
9069 The way to solve these problems is to put @samp{__} at the beginning and
9070 end of each problematical keyword. For example, use @code{__asm__}
9071 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9072
9073 Other C compilers won't accept these alternative keywords; if you want to
9074 compile with another compiler, you can define the alternate keywords as
9075 macros to replace them with the customary keywords. It looks like this:
9076
9077 @smallexample
9078 #ifndef __GNUC__
9079 #define __asm__ asm
9080 #endif
9081 @end smallexample
9082
9083 @findex __extension__
9084 @opindex pedantic
9085 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9086 You can
9087 prevent such warnings within one expression by writing
9088 @code{__extension__} before the expression. @code{__extension__} has no
9089 effect aside from this.
9090
9091 @node Incomplete Enums
9092 @section Incomplete @code{enum} Types
9093
9094 You can define an @code{enum} tag without specifying its possible values.
9095 This results in an incomplete type, much like what you get if you write
9096 @code{struct foo} without describing the elements. A later declaration
9097 that does specify the possible values completes the type.
9098
9099 You can't allocate variables or storage using the type while it is
9100 incomplete. However, you can work with pointers to that type.
9101
9102 This extension may not be very useful, but it makes the handling of
9103 @code{enum} more consistent with the way @code{struct} and @code{union}
9104 are handled.
9105
9106 This extension is not supported by GNU C++.
9107
9108 @node Function Names
9109 @section Function Names as Strings
9110 @cindex @code{__func__} identifier
9111 @cindex @code{__FUNCTION__} identifier
9112 @cindex @code{__PRETTY_FUNCTION__} identifier
9113
9114 GCC provides three magic constants that hold the name of the current
9115 function as a string. In C++11 and later modes, all three are treated
9116 as constant expressions and can be used in @code{constexpr} constexts.
9117 The first of these constants is @code{__func__}, which is part of
9118 the C99 standard:
9119
9120 The identifier @code{__func__} is implicitly declared by the translator
9121 as if, immediately following the opening brace of each function
9122 definition, the declaration
9123
9124 @smallexample
9125 static const char __func__[] = "function-name";
9126 @end smallexample
9127
9128 @noindent
9129 appeared, where function-name is the name of the lexically-enclosing
9130 function. This name is the unadorned name of the function. As an
9131 extension, at file (or, in C++, namespace scope), @code{__func__}
9132 evaluates to the empty string.
9133
9134 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9135 backward compatibility with old versions of GCC.
9136
9137 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9138 @code{__func__}, except that at file (or, in C++, namespace scope),
9139 it evaluates to the string @code{"top level"}. In addition, in C++,
9140 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9141 well as its bare name. For example, this program:
9142
9143 @smallexample
9144 extern "C" int printf (const char *, ...);
9145
9146 class a @{
9147 public:
9148 void sub (int i)
9149 @{
9150 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9151 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9152 @}
9153 @};
9154
9155 int
9156 main (void)
9157 @{
9158 a ax;
9159 ax.sub (0);
9160 return 0;
9161 @}
9162 @end smallexample
9163
9164 @noindent
9165 gives this output:
9166
9167 @smallexample
9168 __FUNCTION__ = sub
9169 __PRETTY_FUNCTION__ = void a::sub(int)
9170 @end smallexample
9171
9172 These identifiers are variables, not preprocessor macros, and may not
9173 be used to initialize @code{char} arrays or be concatenated with string
9174 literals.
9175
9176 @node Return Address
9177 @section Getting the Return or Frame Address of a Function
9178
9179 These functions may be used to get information about the callers of a
9180 function.
9181
9182 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9183 This function returns the return address of the current function, or of
9184 one of its callers. The @var{level} argument is number of frames to
9185 scan up the call stack. A value of @code{0} yields the return address
9186 of the current function, a value of @code{1} yields the return address
9187 of the caller of the current function, and so forth. When inlining
9188 the expected behavior is that the function returns the address of
9189 the function that is returned to. To work around this behavior use
9190 the @code{noinline} function attribute.
9191
9192 The @var{level} argument must be a constant integer.
9193
9194 On some machines it may be impossible to determine the return address of
9195 any function other than the current one; in such cases, or when the top
9196 of the stack has been reached, this function returns @code{0} or a
9197 random value. In addition, @code{__builtin_frame_address} may be used
9198 to determine if the top of the stack has been reached.
9199
9200 Additional post-processing of the returned value may be needed, see
9201 @code{__builtin_extract_return_addr}.
9202
9203 Calling this function with a nonzero argument can have unpredictable
9204 effects, including crashing the calling program. As a result, calls
9205 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9206 option is in effect. Such calls should only be made in debugging
9207 situations.
9208 @end deftypefn
9209
9210 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9211 The address as returned by @code{__builtin_return_address} may have to be fed
9212 through this function to get the actual encoded address. For example, on the
9213 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9214 platforms an offset has to be added for the true next instruction to be
9215 executed.
9216
9217 If no fixup is needed, this function simply passes through @var{addr}.
9218 @end deftypefn
9219
9220 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9221 This function does the reverse of @code{__builtin_extract_return_addr}.
9222 @end deftypefn
9223
9224 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9225 This function is similar to @code{__builtin_return_address}, but it
9226 returns the address of the function frame rather than the return address
9227 of the function. Calling @code{__builtin_frame_address} with a value of
9228 @code{0} yields the frame address of the current function, a value of
9229 @code{1} yields the frame address of the caller of the current function,
9230 and so forth.
9231
9232 The frame is the area on the stack that holds local variables and saved
9233 registers. The frame address is normally the address of the first word
9234 pushed on to the stack by the function. However, the exact definition
9235 depends upon the processor and the calling convention. If the processor
9236 has a dedicated frame pointer register, and the function has a frame,
9237 then @code{__builtin_frame_address} returns the value of the frame
9238 pointer register.
9239
9240 On some machines it may be impossible to determine the frame address of
9241 any function other than the current one; in such cases, or when the top
9242 of the stack has been reached, this function returns @code{0} if
9243 the first frame pointer is properly initialized by the startup code.
9244
9245 Calling this function with a nonzero argument can have unpredictable
9246 effects, including crashing the calling program. As a result, calls
9247 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9248 option is in effect. Such calls should only be made in debugging
9249 situations.
9250 @end deftypefn
9251
9252 @node Vector Extensions
9253 @section Using Vector Instructions through Built-in Functions
9254
9255 On some targets, the instruction set contains SIMD vector instructions which
9256 operate on multiple values contained in one large register at the same time.
9257 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9258 this way.
9259
9260 The first step in using these extensions is to provide the necessary data
9261 types. This should be done using an appropriate @code{typedef}:
9262
9263 @smallexample
9264 typedef int v4si __attribute__ ((vector_size (16)));
9265 @end smallexample
9266
9267 @noindent
9268 The @code{int} type specifies the base type, while the attribute specifies
9269 the vector size for the variable, measured in bytes. For example, the
9270 declaration above causes the compiler to set the mode for the @code{v4si}
9271 type to be 16 bytes wide and divided into @code{int} sized units. For
9272 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9273 corresponding mode of @code{foo} is @acronym{V4SI}.
9274
9275 The @code{vector_size} attribute is only applicable to integral and
9276 float scalars, although arrays, pointers, and function return values
9277 are allowed in conjunction with this construct. Only sizes that are
9278 a power of two are currently allowed.
9279
9280 All the basic integer types can be used as base types, both as signed
9281 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9282 @code{long long}. In addition, @code{float} and @code{double} can be
9283 used to build floating-point vector types.
9284
9285 Specifying a combination that is not valid for the current architecture
9286 causes GCC to synthesize the instructions using a narrower mode.
9287 For example, if you specify a variable of type @code{V4SI} and your
9288 architecture does not allow for this specific SIMD type, GCC
9289 produces code that uses 4 @code{SIs}.
9290
9291 The types defined in this manner can be used with a subset of normal C
9292 operations. Currently, GCC allows using the following operators
9293 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9294
9295 The operations behave like C++ @code{valarrays}. Addition is defined as
9296 the addition of the corresponding elements of the operands. For
9297 example, in the code below, each of the 4 elements in @var{a} is
9298 added to the corresponding 4 elements in @var{b} and the resulting
9299 vector is stored in @var{c}.
9300
9301 @smallexample
9302 typedef int v4si __attribute__ ((vector_size (16)));
9303
9304 v4si a, b, c;
9305
9306 c = a + b;
9307 @end smallexample
9308
9309 Subtraction, multiplication, division, and the logical operations
9310 operate in a similar manner. Likewise, the result of using the unary
9311 minus or complement operators on a vector type is a vector whose
9312 elements are the negative or complemented values of the corresponding
9313 elements in the operand.
9314
9315 It is possible to use shifting operators @code{<<}, @code{>>} on
9316 integer-type vectors. The operation is defined as following: @code{@{a0,
9317 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9318 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9319 elements.
9320
9321 For convenience, it is allowed to use a binary vector operation
9322 where one operand is a scalar. In that case the compiler transforms
9323 the scalar operand into a vector where each element is the scalar from
9324 the operation. The transformation happens only if the scalar could be
9325 safely converted to the vector-element type.
9326 Consider the following code.
9327
9328 @smallexample
9329 typedef int v4si __attribute__ ((vector_size (16)));
9330
9331 v4si a, b, c;
9332 long l;
9333
9334 a = b + 1; /* a = b + @{1,1,1,1@}; */
9335 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9336
9337 a = l + a; /* Error, cannot convert long to int. */
9338 @end smallexample
9339
9340 Vectors can be subscripted as if the vector were an array with
9341 the same number of elements and base type. Out of bound accesses
9342 invoke undefined behavior at run time. Warnings for out of bound
9343 accesses for vector subscription can be enabled with
9344 @option{-Warray-bounds}.
9345
9346 Vector comparison is supported with standard comparison
9347 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9348 vector expressions of integer-type or real-type. Comparison between
9349 integer-type vectors and real-type vectors are not supported. The
9350 result of the comparison is a vector of the same width and number of
9351 elements as the comparison operands with a signed integral element
9352 type.
9353
9354 Vectors are compared element-wise producing 0 when comparison is false
9355 and -1 (constant of the appropriate type where all bits are set)
9356 otherwise. Consider the following example.
9357
9358 @smallexample
9359 typedef int v4si __attribute__ ((vector_size (16)));
9360
9361 v4si a = @{1,2,3,4@};
9362 v4si b = @{3,2,1,4@};
9363 v4si c;
9364
9365 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9366 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9367 @end smallexample
9368
9369 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9370 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9371 integer vector with the same number of elements of the same size as @code{b}
9372 and @code{c}, computes all three arguments and creates a vector
9373 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9374 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9375 As in the case of binary operations, this syntax is also accepted when
9376 one of @code{b} or @code{c} is a scalar that is then transformed into a
9377 vector. If both @code{b} and @code{c} are scalars and the type of
9378 @code{true?b:c} has the same size as the element type of @code{a}, then
9379 @code{b} and @code{c} are converted to a vector type whose elements have
9380 this type and with the same number of elements as @code{a}.
9381
9382 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9383 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9384 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9385 For mixed operations between a scalar @code{s} and a vector @code{v},
9386 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9387 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9388
9389 Vector shuffling is available using functions
9390 @code{__builtin_shuffle (vec, mask)} and
9391 @code{__builtin_shuffle (vec0, vec1, mask)}.
9392 Both functions construct a permutation of elements from one or two
9393 vectors and return a vector of the same type as the input vector(s).
9394 The @var{mask} is an integral vector with the same width (@var{W})
9395 and element count (@var{N}) as the output vector.
9396
9397 The elements of the input vectors are numbered in memory ordering of
9398 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9399 elements of @var{mask} are considered modulo @var{N} in the single-operand
9400 case and modulo @math{2*@var{N}} in the two-operand case.
9401
9402 Consider the following example,
9403
9404 @smallexample
9405 typedef int v4si __attribute__ ((vector_size (16)));
9406
9407 v4si a = @{1,2,3,4@};
9408 v4si b = @{5,6,7,8@};
9409 v4si mask1 = @{0,1,1,3@};
9410 v4si mask2 = @{0,4,2,5@};
9411 v4si res;
9412
9413 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9414 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9415 @end smallexample
9416
9417 Note that @code{__builtin_shuffle} is intentionally semantically
9418 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9419
9420 You can declare variables and use them in function calls and returns, as
9421 well as in assignments and some casts. You can specify a vector type as
9422 a return type for a function. Vector types can also be used as function
9423 arguments. It is possible to cast from one vector type to another,
9424 provided they are of the same size (in fact, you can also cast vectors
9425 to and from other datatypes of the same size).
9426
9427 You cannot operate between vectors of different lengths or different
9428 signedness without a cast.
9429
9430 @node Offsetof
9431 @section Support for @code{offsetof}
9432 @findex __builtin_offsetof
9433
9434 GCC implements for both C and C++ a syntactic extension to implement
9435 the @code{offsetof} macro.
9436
9437 @smallexample
9438 primary:
9439 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9440
9441 offsetof_member_designator:
9442 @code{identifier}
9443 | offsetof_member_designator "." @code{identifier}
9444 | offsetof_member_designator "[" @code{expr} "]"
9445 @end smallexample
9446
9447 This extension is sufficient such that
9448
9449 @smallexample
9450 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9451 @end smallexample
9452
9453 @noindent
9454 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9455 may be dependent. In either case, @var{member} may consist of a single
9456 identifier, or a sequence of member accesses and array references.
9457
9458 @node __sync Builtins
9459 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9460
9461 The following built-in functions
9462 are intended to be compatible with those described
9463 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9464 section 7.4. As such, they depart from normal GCC practice by not using
9465 the @samp{__builtin_} prefix and also by being overloaded so that they
9466 work on multiple types.
9467
9468 The definition given in the Intel documentation allows only for the use of
9469 the types @code{int}, @code{long}, @code{long long} or their unsigned
9470 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9471 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9472 Operations on pointer arguments are performed as if the operands were
9473 of the @code{uintptr_t} type. That is, they are not scaled by the size
9474 of the type to which the pointer points.
9475
9476 These functions are implemented in terms of the @samp{__atomic}
9477 builtins (@pxref{__atomic Builtins}). They should not be used for new
9478 code which should use the @samp{__atomic} builtins instead.
9479
9480 Not all operations are supported by all target processors. If a particular
9481 operation cannot be implemented on the target processor, a warning is
9482 generated and a call to an external function is generated. The external
9483 function carries the same name as the built-in version,
9484 with an additional suffix
9485 @samp{_@var{n}} where @var{n} is the size of the data type.
9486
9487 @c ??? Should we have a mechanism to suppress this warning? This is almost
9488 @c useful for implementing the operation under the control of an external
9489 @c mutex.
9490
9491 In most cases, these built-in functions are considered a @dfn{full barrier}.
9492 That is,
9493 no memory operand is moved across the operation, either forward or
9494 backward. Further, instructions are issued as necessary to prevent the
9495 processor from speculating loads across the operation and from queuing stores
9496 after the operation.
9497
9498 All of the routines are described in the Intel documentation to take
9499 ``an optional list of variables protected by the memory barrier''. It's
9500 not clear what is meant by that; it could mean that @emph{only} the
9501 listed variables are protected, or it could mean a list of additional
9502 variables to be protected. The list is ignored by GCC which treats it as
9503 empty. GCC interprets an empty list as meaning that all globally
9504 accessible variables should be protected.
9505
9506 @table @code
9507 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9508 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9509 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9510 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9511 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9512 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9513 @findex __sync_fetch_and_add
9514 @findex __sync_fetch_and_sub
9515 @findex __sync_fetch_and_or
9516 @findex __sync_fetch_and_and
9517 @findex __sync_fetch_and_xor
9518 @findex __sync_fetch_and_nand
9519 These built-in functions perform the operation suggested by the name, and
9520 returns the value that had previously been in memory. That is, operations
9521 on integer operands have the following semantics. Operations on pointer
9522 arguments are performed as if the operands were of the @code{uintptr_t}
9523 type. That is, they are not scaled by the size of the type to which
9524 the pointer points.
9525
9526 @smallexample
9527 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9528 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9529 @end smallexample
9530
9531 The object pointed to by the first argument must be of integer or pointer
9532 type. It must not be a boolean type.
9533
9534 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9535 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9536
9537 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9538 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9539 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9540 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9541 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9542 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9543 @findex __sync_add_and_fetch
9544 @findex __sync_sub_and_fetch
9545 @findex __sync_or_and_fetch
9546 @findex __sync_and_and_fetch
9547 @findex __sync_xor_and_fetch
9548 @findex __sync_nand_and_fetch
9549 These built-in functions perform the operation suggested by the name, and
9550 return the new value. That is, operations on integer operands have
9551 the following semantics. Operations on pointer operands are performed as
9552 if the operand's type were @code{uintptr_t}.
9553
9554 @smallexample
9555 @{ *ptr @var{op}= value; return *ptr; @}
9556 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9557 @end smallexample
9558
9559 The same constraints on arguments apply as for the corresponding
9560 @code{__sync_op_and_fetch} built-in functions.
9561
9562 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9563 as @code{*ptr = ~(*ptr & value)} instead of
9564 @code{*ptr = ~*ptr & value}.
9565
9566 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9567 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9568 @findex __sync_bool_compare_and_swap
9569 @findex __sync_val_compare_and_swap
9570 These built-in functions perform an atomic compare and swap.
9571 That is, if the current
9572 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9573 @code{*@var{ptr}}.
9574
9575 The ``bool'' version returns true if the comparison is successful and
9576 @var{newval} is written. The ``val'' version returns the contents
9577 of @code{*@var{ptr}} before the operation.
9578
9579 @item __sync_synchronize (...)
9580 @findex __sync_synchronize
9581 This built-in function issues a full memory barrier.
9582
9583 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9584 @findex __sync_lock_test_and_set
9585 This built-in function, as described by Intel, is not a traditional test-and-set
9586 operation, but rather an atomic exchange operation. It writes @var{value}
9587 into @code{*@var{ptr}}, and returns the previous contents of
9588 @code{*@var{ptr}}.
9589
9590 Many targets have only minimal support for such locks, and do not support
9591 a full exchange operation. In this case, a target may support reduced
9592 functionality here by which the @emph{only} valid value to store is the
9593 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9594 is implementation defined.
9595
9596 This built-in function is not a full barrier,
9597 but rather an @dfn{acquire barrier}.
9598 This means that references after the operation cannot move to (or be
9599 speculated to) before the operation, but previous memory stores may not
9600 be globally visible yet, and previous memory loads may not yet be
9601 satisfied.
9602
9603 @item void __sync_lock_release (@var{type} *ptr, ...)
9604 @findex __sync_lock_release
9605 This built-in function releases the lock acquired by
9606 @code{__sync_lock_test_and_set}.
9607 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9608
9609 This built-in function is not a full barrier,
9610 but rather a @dfn{release barrier}.
9611 This means that all previous memory stores are globally visible, and all
9612 previous memory loads have been satisfied, but following memory reads
9613 are not prevented from being speculated to before the barrier.
9614 @end table
9615
9616 @node __atomic Builtins
9617 @section Built-in Functions for Memory Model Aware Atomic Operations
9618
9619 The following built-in functions approximately match the requirements
9620 for the C++11 memory model. They are all
9621 identified by being prefixed with @samp{__atomic} and most are
9622 overloaded so that they work with multiple types.
9623
9624 These functions are intended to replace the legacy @samp{__sync}
9625 builtins. The main difference is that the memory order that is requested
9626 is a parameter to the functions. New code should always use the
9627 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9628
9629 Note that the @samp{__atomic} builtins assume that programs will
9630 conform to the C++11 memory model. In particular, they assume
9631 that programs are free of data races. See the C++11 standard for
9632 detailed requirements.
9633
9634 The @samp{__atomic} builtins can be used with any integral scalar or
9635 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9636 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9637 supported by the architecture.
9638
9639 The four non-arithmetic functions (load, store, exchange, and
9640 compare_exchange) all have a generic version as well. This generic
9641 version works on any data type. It uses the lock-free built-in function
9642 if the specific data type size makes that possible; otherwise, an
9643 external call is left to be resolved at run time. This external call is
9644 the same format with the addition of a @samp{size_t} parameter inserted
9645 as the first parameter indicating the size of the object being pointed to.
9646 All objects must be the same size.
9647
9648 There are 6 different memory orders that can be specified. These map
9649 to the C++11 memory orders with the same names, see the C++11 standard
9650 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9651 on atomic synchronization} for detailed definitions. Individual
9652 targets may also support additional memory orders for use on specific
9653 architectures. Refer to the target documentation for details of
9654 these.
9655
9656 An atomic operation can both constrain code motion and
9657 be mapped to hardware instructions for synchronization between threads
9658 (e.g., a fence). To which extent this happens is controlled by the
9659 memory orders, which are listed here in approximately ascending order of
9660 strength. The description of each memory order is only meant to roughly
9661 illustrate the effects and is not a specification; see the C++11
9662 memory model for precise semantics.
9663
9664 @table @code
9665 @item __ATOMIC_RELAXED
9666 Implies no inter-thread ordering constraints.
9667 @item __ATOMIC_CONSUME
9668 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9669 memory order because of a deficiency in C++11's semantics for
9670 @code{memory_order_consume}.
9671 @item __ATOMIC_ACQUIRE
9672 Creates an inter-thread happens-before constraint from the release (or
9673 stronger) semantic store to this acquire load. Can prevent hoisting
9674 of code to before the operation.
9675 @item __ATOMIC_RELEASE
9676 Creates an inter-thread happens-before constraint to acquire (or stronger)
9677 semantic loads that read from this release store. Can prevent sinking
9678 of code to after the operation.
9679 @item __ATOMIC_ACQ_REL
9680 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9681 @code{__ATOMIC_RELEASE}.
9682 @item __ATOMIC_SEQ_CST
9683 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9684 @end table
9685
9686 Note that in the C++11 memory model, @emph{fences} (e.g.,
9687 @samp{__atomic_thread_fence}) take effect in combination with other
9688 atomic operations on specific memory locations (e.g., atomic loads);
9689 operations on specific memory locations do not necessarily affect other
9690 operations in the same way.
9691
9692 Target architectures are encouraged to provide their own patterns for
9693 each of the atomic built-in functions. If no target is provided, the original
9694 non-memory model set of @samp{__sync} atomic built-in functions are
9695 used, along with any required synchronization fences surrounding it in
9696 order to achieve the proper behavior. Execution in this case is subject
9697 to the same restrictions as those built-in functions.
9698
9699 If there is no pattern or mechanism to provide a lock-free instruction
9700 sequence, a call is made to an external routine with the same parameters
9701 to be resolved at run time.
9702
9703 When implementing patterns for these built-in functions, the memory order
9704 parameter can be ignored as long as the pattern implements the most
9705 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9706 orders execute correctly with this memory order but they may not execute as
9707 efficiently as they could with a more appropriate implementation of the
9708 relaxed requirements.
9709
9710 Note that the C++11 standard allows for the memory order parameter to be
9711 determined at run time rather than at compile time. These built-in
9712 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9713 than invoke a runtime library call or inline a switch statement. This is
9714 standard compliant, safe, and the simplest approach for now.
9715
9716 The memory order parameter is a signed int, but only the lower 16 bits are
9717 reserved for the memory order. The remainder of the signed int is reserved
9718 for target use and should be 0. Use of the predefined atomic values
9719 ensures proper usage.
9720
9721 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9722 This built-in function implements an atomic load operation. It returns the
9723 contents of @code{*@var{ptr}}.
9724
9725 The valid memory order variants are
9726 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9727 and @code{__ATOMIC_CONSUME}.
9728
9729 @end deftypefn
9730
9731 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9732 This is the generic version of an atomic load. It returns the
9733 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9734
9735 @end deftypefn
9736
9737 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9738 This built-in function implements an atomic store operation. It writes
9739 @code{@var{val}} into @code{*@var{ptr}}.
9740
9741 The valid memory order variants are
9742 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9743
9744 @end deftypefn
9745
9746 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9747 This is the generic version of an atomic store. It stores the value
9748 of @code{*@var{val}} into @code{*@var{ptr}}.
9749
9750 @end deftypefn
9751
9752 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9753 This built-in function implements an atomic exchange operation. It writes
9754 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9755 @code{*@var{ptr}}.
9756
9757 The valid memory order variants are
9758 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9759 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9760
9761 @end deftypefn
9762
9763 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9764 This is the generic version of an atomic exchange. It stores the
9765 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9766 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9767
9768 @end deftypefn
9769
9770 @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)
9771 This built-in function implements an atomic compare and exchange operation.
9772 This compares the contents of @code{*@var{ptr}} with the contents of
9773 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9774 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9775 equal, the operation is a @emph{read} and the current contents of
9776 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9777 for weak compare_exchange, which may fail spuriously, and false for
9778 the strong variation, which never fails spuriously. Many targets
9779 only offer the strong variation and ignore the parameter. When in doubt, use
9780 the strong variation.
9781
9782 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9783 and memory is affected according to the
9784 memory order specified by @var{success_memorder}. There are no
9785 restrictions on what memory order can be used here.
9786
9787 Otherwise, false is returned and memory is affected according
9788 to @var{failure_memorder}. This memory order cannot be
9789 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9790 stronger order than that specified by @var{success_memorder}.
9791
9792 @end deftypefn
9793
9794 @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)
9795 This built-in function implements the generic version of
9796 @code{__atomic_compare_exchange}. The function is virtually identical to
9797 @code{__atomic_compare_exchange_n}, except the desired value is also a
9798 pointer.
9799
9800 @end deftypefn
9801
9802 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9803 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9804 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9805 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9806 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9807 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9808 These built-in functions perform the operation suggested by the name, and
9809 return the result of the operation. Operations on pointer arguments are
9810 performed as if the operands were of the @code{uintptr_t} type. That is,
9811 they are not scaled by the size of the type to which the pointer points.
9812
9813 @smallexample
9814 @{ *ptr @var{op}= val; return *ptr; @}
9815 @end smallexample
9816
9817 The object pointed to by the first argument must be of integer or pointer
9818 type. It must not be a boolean type. All memory orders are valid.
9819
9820 @end deftypefn
9821
9822 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9823 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9824 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9825 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9826 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9827 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9828 These built-in functions perform the operation suggested by the name, and
9829 return the value that had previously been in @code{*@var{ptr}}. Operations
9830 on pointer arguments are performed as if the operands were of
9831 the @code{uintptr_t} type. That is, they are not scaled by the size of
9832 the type to which the pointer points.
9833
9834 @smallexample
9835 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9836 @end smallexample
9837
9838 The same constraints on arguments apply as for the corresponding
9839 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9840
9841 @end deftypefn
9842
9843 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9844
9845 This built-in function performs an atomic test-and-set operation on
9846 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9847 defined nonzero ``set'' value and the return value is @code{true} if and only
9848 if the previous contents were ``set''.
9849 It should be only used for operands of type @code{bool} or @code{char}. For
9850 other types only part of the value may be set.
9851
9852 All memory orders are valid.
9853
9854 @end deftypefn
9855
9856 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9857
9858 This built-in function performs an atomic clear operation on
9859 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9860 It should be only used for operands of type @code{bool} or @code{char} and
9861 in conjunction with @code{__atomic_test_and_set}.
9862 For other types it may only clear partially. If the type is not @code{bool}
9863 prefer using @code{__atomic_store}.
9864
9865 The valid memory order variants are
9866 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9867 @code{__ATOMIC_RELEASE}.
9868
9869 @end deftypefn
9870
9871 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9872
9873 This built-in function acts as a synchronization fence between threads
9874 based on the specified memory order.
9875
9876 All memory orders are valid.
9877
9878 @end deftypefn
9879
9880 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9881
9882 This built-in function acts as a synchronization fence between a thread
9883 and signal handlers based in the same thread.
9884
9885 All memory orders are valid.
9886
9887 @end deftypefn
9888
9889 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9890
9891 This built-in function returns true if objects of @var{size} bytes always
9892 generate lock-free atomic instructions for the target architecture.
9893 @var{size} must resolve to a compile-time constant and the result also
9894 resolves to a compile-time constant.
9895
9896 @var{ptr} is an optional pointer to the object that may be used to determine
9897 alignment. A value of 0 indicates typical alignment should be used. The
9898 compiler may also ignore this parameter.
9899
9900 @smallexample
9901 if (__atomic_always_lock_free (sizeof (long long), 0))
9902 @end smallexample
9903
9904 @end deftypefn
9905
9906 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9907
9908 This built-in function returns true if objects of @var{size} bytes always
9909 generate lock-free atomic instructions for the target architecture. If
9910 the built-in function is not known to be lock-free, a call is made to a
9911 runtime routine named @code{__atomic_is_lock_free}.
9912
9913 @var{ptr} is an optional pointer to the object that may be used to determine
9914 alignment. A value of 0 indicates typical alignment should be used. The
9915 compiler may also ignore this parameter.
9916 @end deftypefn
9917
9918 @node Integer Overflow Builtins
9919 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9920
9921 The following built-in functions allow performing simple arithmetic operations
9922 together with checking whether the operations overflowed.
9923
9924 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9925 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9926 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9927 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
9928 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9929 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9930 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
9931
9932 These built-in functions promote the first two operands into infinite precision signed
9933 type and perform addition on those promoted operands. The result is then
9934 cast to the type the third pointer argument points to and stored there.
9935 If the stored result is equal to the infinite precision result, the built-in
9936 functions return false, otherwise they return true. As the addition is
9937 performed in infinite signed precision, these built-in functions have fully defined
9938 behavior for all argument values.
9939
9940 The first built-in function allows arbitrary integral types for operands and
9941 the result type must be pointer to some integral type other than enumerated or
9942 boolean type, the rest of the built-in functions have explicit integer types.
9943
9944 The compiler will attempt to use hardware instructions to implement
9945 these built-in functions where possible, like conditional jump on overflow
9946 after addition, conditional jump on carry etc.
9947
9948 @end deftypefn
9949
9950 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9951 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9952 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9953 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
9954 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9955 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9956 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
9957
9958 These built-in functions are similar to the add overflow checking built-in
9959 functions above, except they perform subtraction, subtract the second argument
9960 from the first one, instead of addition.
9961
9962 @end deftypefn
9963
9964 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9965 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9966 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9967 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
9968 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9969 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9970 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
9971
9972 These built-in functions are similar to the add overflow checking built-in
9973 functions above, except they perform multiplication, instead of addition.
9974
9975 @end deftypefn
9976
9977 The following built-in functions allow checking if simple arithmetic operation
9978 would overflow.
9979
9980 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9981 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9982 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
9983
9984 These built-in functions are similar to @code{__builtin_add_overflow},
9985 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
9986 they don't store the result of the arithmetic operation anywhere and the
9987 last argument is not a pointer, but some expression with integral type other
9988 than enumerated or boolean type.
9989
9990 The built-in functions promote the first two operands into infinite precision signed type
9991 and perform addition on those promoted operands. The result is then
9992 cast to the type of the third argument. If the cast result is equal to the infinite
9993 precision result, the built-in functions return false, otherwise they return true.
9994 The value of the third argument is ignored, just the side-effects in the third argument
9995 are evaluated, and no integral argument promotions are performed on the last argument.
9996 If the third argument is a bit-field, the type used for the result cast has the
9997 precision and signedness of the given bit-field, rather than precision and signedness
9998 of the underlying type.
9999
10000 For example, the following macro can be used to portably check, at
10001 compile-time, whether or not adding two constant integers will overflow,
10002 and perform the addition only when it is known to be safe and not to trigger
10003 a @option{-Woverflow} warning.
10004
10005 @smallexample
10006 #define INT_ADD_OVERFLOW_P(a, b) \
10007 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10008
10009 enum @{
10010 A = INT_MAX, B = 3,
10011 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10012 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10013 @};
10014 @end smallexample
10015
10016 The compiler will attempt to use hardware instructions to implement
10017 these built-in functions where possible, like conditional jump on overflow
10018 after addition, conditional jump on carry etc.
10019
10020 @end deftypefn
10021
10022 @node x86 specific memory model extensions for transactional memory
10023 @section x86-Specific Memory Model Extensions for Transactional Memory
10024
10025 The x86 architecture supports additional memory ordering flags
10026 to mark lock critical sections for hardware lock elision.
10027 These must be specified in addition to an existing memory order to
10028 atomic intrinsics.
10029
10030 @table @code
10031 @item __ATOMIC_HLE_ACQUIRE
10032 Start lock elision on a lock variable.
10033 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10034 @item __ATOMIC_HLE_RELEASE
10035 End lock elision on a lock variable.
10036 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10037 @end table
10038
10039 When a lock acquire fails, it is required for good performance to abort
10040 the transaction quickly. This can be done with a @code{_mm_pause}.
10041
10042 @smallexample
10043 #include <immintrin.h> // For _mm_pause
10044
10045 int lockvar;
10046
10047 /* Acquire lock with lock elision */
10048 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10049 _mm_pause(); /* Abort failed transaction */
10050 ...
10051 /* Free lock with lock elision */
10052 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10053 @end smallexample
10054
10055 @node Object Size Checking
10056 @section Object Size Checking Built-in Functions
10057 @findex __builtin_object_size
10058 @findex __builtin___memcpy_chk
10059 @findex __builtin___mempcpy_chk
10060 @findex __builtin___memmove_chk
10061 @findex __builtin___memset_chk
10062 @findex __builtin___strcpy_chk
10063 @findex __builtin___stpcpy_chk
10064 @findex __builtin___strncpy_chk
10065 @findex __builtin___strcat_chk
10066 @findex __builtin___strncat_chk
10067 @findex __builtin___sprintf_chk
10068 @findex __builtin___snprintf_chk
10069 @findex __builtin___vsprintf_chk
10070 @findex __builtin___vsnprintf_chk
10071 @findex __builtin___printf_chk
10072 @findex __builtin___vprintf_chk
10073 @findex __builtin___fprintf_chk
10074 @findex __builtin___vfprintf_chk
10075
10076 GCC implements a limited buffer overflow protection mechanism that can
10077 prevent some buffer overflow attacks by determining the sizes of objects
10078 into which data is about to be written and preventing the writes when
10079 the size isn't sufficient. The built-in functions described below yield
10080 the best results when used together and when optimization is enabled.
10081 For example, to detect object sizes across function boundaries or to
10082 follow pointer assignments through non-trivial control flow they rely
10083 on various optimization passes enabled with @option{-O2}. However, to
10084 a limited extent, they can be used without optimization as well.
10085
10086 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
10087 is a built-in construct that returns a constant number of bytes from
10088 @var{ptr} to the end of the object @var{ptr} pointer points to
10089 (if known at compile time). @code{__builtin_object_size} never evaluates
10090 its arguments for side-effects. If there are any side-effects in them, it
10091 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10092 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10093 point to and all of them are known at compile time, the returned number
10094 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10095 0 and minimum if nonzero. If it is not possible to determine which objects
10096 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10097 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10098 for @var{type} 2 or 3.
10099
10100 @var{type} is an integer constant from 0 to 3. If the least significant
10101 bit is clear, objects are whole variables, if it is set, a closest
10102 surrounding subobject is considered the object a pointer points to.
10103 The second bit determines if maximum or minimum of remaining bytes
10104 is computed.
10105
10106 @smallexample
10107 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10108 char *p = &var.buf1[1], *q = &var.b;
10109
10110 /* Here the object p points to is var. */
10111 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10112 /* The subobject p points to is var.buf1. */
10113 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10114 /* The object q points to is var. */
10115 assert (__builtin_object_size (q, 0)
10116 == (char *) (&var + 1) - (char *) &var.b);
10117 /* The subobject q points to is var.b. */
10118 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10119 @end smallexample
10120 @end deftypefn
10121
10122 There are built-in functions added for many common string operation
10123 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10124 built-in is provided. This built-in has an additional last argument,
10125 which is the number of bytes remaining in object the @var{dest}
10126 argument points to or @code{(size_t) -1} if the size is not known.
10127
10128 The built-in functions are optimized into the normal string functions
10129 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10130 it is known at compile time that the destination object will not
10131 be overflown. If the compiler can determine at compile time the
10132 object will be always overflown, it issues a warning.
10133
10134 The intended use can be e.g.@:
10135
10136 @smallexample
10137 #undef memcpy
10138 #define bos0(dest) __builtin_object_size (dest, 0)
10139 #define memcpy(dest, src, n) \
10140 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10141
10142 char *volatile p;
10143 char buf[10];
10144 /* It is unknown what object p points to, so this is optimized
10145 into plain memcpy - no checking is possible. */
10146 memcpy (p, "abcde", n);
10147 /* Destination is known and length too. It is known at compile
10148 time there will be no overflow. */
10149 memcpy (&buf[5], "abcde", 5);
10150 /* Destination is known, but the length is not known at compile time.
10151 This will result in __memcpy_chk call that can check for overflow
10152 at run time. */
10153 memcpy (&buf[5], "abcde", n);
10154 /* Destination is known and it is known at compile time there will
10155 be overflow. There will be a warning and __memcpy_chk call that
10156 will abort the program at run time. */
10157 memcpy (&buf[6], "abcde", 5);
10158 @end smallexample
10159
10160 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10161 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10162 @code{strcat} and @code{strncat}.
10163
10164 There are also checking built-in functions for formatted output functions.
10165 @smallexample
10166 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10167 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10168 const char *fmt, ...);
10169 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10170 va_list ap);
10171 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10172 const char *fmt, va_list ap);
10173 @end smallexample
10174
10175 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10176 etc.@: functions and can contain implementation specific flags on what
10177 additional security measures the checking function might take, such as
10178 handling @code{%n} differently.
10179
10180 The @var{os} argument is the object size @var{s} points to, like in the
10181 other built-in functions. There is a small difference in the behavior
10182 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10183 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10184 the checking function is called with @var{os} argument set to
10185 @code{(size_t) -1}.
10186
10187 In addition to this, there are checking built-in functions
10188 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10189 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10190 These have just one additional argument, @var{flag}, right before
10191 format string @var{fmt}. If the compiler is able to optimize them to
10192 @code{fputc} etc.@: functions, it does, otherwise the checking function
10193 is called and the @var{flag} argument passed to it.
10194
10195 @node Pointer Bounds Checker builtins
10196 @section Pointer Bounds Checker Built-in Functions
10197 @cindex Pointer Bounds Checker builtins
10198 @findex __builtin___bnd_set_ptr_bounds
10199 @findex __builtin___bnd_narrow_ptr_bounds
10200 @findex __builtin___bnd_copy_ptr_bounds
10201 @findex __builtin___bnd_init_ptr_bounds
10202 @findex __builtin___bnd_null_ptr_bounds
10203 @findex __builtin___bnd_store_ptr_bounds
10204 @findex __builtin___bnd_chk_ptr_lbounds
10205 @findex __builtin___bnd_chk_ptr_ubounds
10206 @findex __builtin___bnd_chk_ptr_bounds
10207 @findex __builtin___bnd_get_ptr_lbound
10208 @findex __builtin___bnd_get_ptr_ubound
10209
10210 GCC provides a set of built-in functions to control Pointer Bounds Checker
10211 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10212 even if you compile with Pointer Bounds Checker off
10213 (@option{-fno-check-pointer-bounds}).
10214 The behavior may differ in such case as documented below.
10215
10216 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10217
10218 This built-in function returns a new pointer with the value of @var{q}, and
10219 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10220 Bounds Checker off, the built-in function just returns the first argument.
10221
10222 @smallexample
10223 extern void *__wrap_malloc (size_t n)
10224 @{
10225 void *p = (void *)__real_malloc (n);
10226 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10227 return __builtin___bnd_set_ptr_bounds (p, n);
10228 @}
10229 @end smallexample
10230
10231 @end deftypefn
10232
10233 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10234
10235 This built-in function returns a new pointer with the value of @var{p}
10236 and associates it with the narrowed bounds formed by the intersection
10237 of bounds associated with @var{q} and the bounds
10238 [@var{p}, @var{p} + @var{size} - 1].
10239 With Pointer Bounds Checker off, the built-in function just returns the first
10240 argument.
10241
10242 @smallexample
10243 void init_objects (object *objs, size_t size)
10244 @{
10245 size_t i;
10246 /* Initialize objects one-by-one passing pointers with bounds of
10247 an object, not the full array of objects. */
10248 for (i = 0; i < size; i++)
10249 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10250 sizeof(object)));
10251 @}
10252 @end smallexample
10253
10254 @end deftypefn
10255
10256 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10257
10258 This built-in function returns a new pointer with the value of @var{q},
10259 and associates it with the bounds already associated with pointer @var{r}.
10260 With Pointer Bounds Checker off, the built-in function just returns the first
10261 argument.
10262
10263 @smallexample
10264 /* Here is a way to get pointer to object's field but
10265 still with the full object's bounds. */
10266 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10267 objptr);
10268 @end smallexample
10269
10270 @end deftypefn
10271
10272 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10273
10274 This built-in function returns a new pointer with the value of @var{q}, and
10275 associates it with INIT (allowing full memory access) bounds. With Pointer
10276 Bounds Checker off, the built-in function just returns the first argument.
10277
10278 @end deftypefn
10279
10280 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10281
10282 This built-in function returns a new pointer with the value of @var{q}, and
10283 associates it with NULL (allowing no memory access) bounds. With Pointer
10284 Bounds Checker off, the built-in function just returns the first argument.
10285
10286 @end deftypefn
10287
10288 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10289
10290 This built-in function stores the bounds associated with pointer @var{ptr_val}
10291 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10292 bounds from legacy code without touching the associated pointer's memory when
10293 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10294 function call is ignored.
10295
10296 @end deftypefn
10297
10298 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10299
10300 This built-in function checks if the pointer @var{q} is within the lower
10301 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10302 function call is ignored.
10303
10304 @smallexample
10305 extern void *__wrap_memset (void *dst, int c, size_t len)
10306 @{
10307 if (len > 0)
10308 @{
10309 __builtin___bnd_chk_ptr_lbounds (dst);
10310 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10311 __real_memset (dst, c, len);
10312 @}
10313 return dst;
10314 @}
10315 @end smallexample
10316
10317 @end deftypefn
10318
10319 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10320
10321 This built-in function checks if the pointer @var{q} is within the upper
10322 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10323 function call is ignored.
10324
10325 @end deftypefn
10326
10327 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10328
10329 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10330 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10331 off, the built-in function call is ignored.
10332
10333 @smallexample
10334 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10335 @{
10336 if (n > 0)
10337 @{
10338 __bnd_chk_ptr_bounds (dst, n);
10339 __bnd_chk_ptr_bounds (src, n);
10340 __real_memcpy (dst, src, n);
10341 @}
10342 return dst;
10343 @}
10344 @end smallexample
10345
10346 @end deftypefn
10347
10348 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10349
10350 This built-in function returns the lower bound associated
10351 with the pointer @var{q}, as a pointer value.
10352 This is useful for debugging using @code{printf}.
10353 With Pointer Bounds Checker off, the built-in function returns 0.
10354
10355 @smallexample
10356 void *lb = __builtin___bnd_get_ptr_lbound (q);
10357 void *ub = __builtin___bnd_get_ptr_ubound (q);
10358 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10359 @end smallexample
10360
10361 @end deftypefn
10362
10363 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10364
10365 This built-in function returns the upper bound (which is a pointer) associated
10366 with the pointer @var{q}. With Pointer Bounds Checker off,
10367 the built-in function returns -1.
10368
10369 @end deftypefn
10370
10371 @node Cilk Plus Builtins
10372 @section Cilk Plus C/C++ Language Extension Built-in Functions
10373
10374 GCC provides support for the following built-in reduction functions if Cilk Plus
10375 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10376
10377 @itemize @bullet
10378 @item @code{__sec_implicit_index}
10379 @item @code{__sec_reduce}
10380 @item @code{__sec_reduce_add}
10381 @item @code{__sec_reduce_all_nonzero}
10382 @item @code{__sec_reduce_all_zero}
10383 @item @code{__sec_reduce_any_nonzero}
10384 @item @code{__sec_reduce_any_zero}
10385 @item @code{__sec_reduce_max}
10386 @item @code{__sec_reduce_min}
10387 @item @code{__sec_reduce_max_ind}
10388 @item @code{__sec_reduce_min_ind}
10389 @item @code{__sec_reduce_mul}
10390 @item @code{__sec_reduce_mutating}
10391 @end itemize
10392
10393 Further details and examples about these built-in functions are described
10394 in the Cilk Plus language manual which can be found at
10395 @uref{http://www.cilkplus.org}.
10396
10397 @node Other Builtins
10398 @section Other Built-in Functions Provided by GCC
10399 @cindex built-in functions
10400 @findex __builtin_alloca
10401 @findex __builtin_alloca_with_align
10402 @findex __builtin_call_with_static_chain
10403 @findex __builtin_fpclassify
10404 @findex __builtin_isfinite
10405 @findex __builtin_isnormal
10406 @findex __builtin_isgreater
10407 @findex __builtin_isgreaterequal
10408 @findex __builtin_isinf_sign
10409 @findex __builtin_isless
10410 @findex __builtin_islessequal
10411 @findex __builtin_islessgreater
10412 @findex __builtin_isunordered
10413 @findex __builtin_powi
10414 @findex __builtin_powif
10415 @findex __builtin_powil
10416 @findex _Exit
10417 @findex _exit
10418 @findex abort
10419 @findex abs
10420 @findex acos
10421 @findex acosf
10422 @findex acosh
10423 @findex acoshf
10424 @findex acoshl
10425 @findex acosl
10426 @findex alloca
10427 @findex asin
10428 @findex asinf
10429 @findex asinh
10430 @findex asinhf
10431 @findex asinhl
10432 @findex asinl
10433 @findex atan
10434 @findex atan2
10435 @findex atan2f
10436 @findex atan2l
10437 @findex atanf
10438 @findex atanh
10439 @findex atanhf
10440 @findex atanhl
10441 @findex atanl
10442 @findex bcmp
10443 @findex bzero
10444 @findex cabs
10445 @findex cabsf
10446 @findex cabsl
10447 @findex cacos
10448 @findex cacosf
10449 @findex cacosh
10450 @findex cacoshf
10451 @findex cacoshl
10452 @findex cacosl
10453 @findex calloc
10454 @findex carg
10455 @findex cargf
10456 @findex cargl
10457 @findex casin
10458 @findex casinf
10459 @findex casinh
10460 @findex casinhf
10461 @findex casinhl
10462 @findex casinl
10463 @findex catan
10464 @findex catanf
10465 @findex catanh
10466 @findex catanhf
10467 @findex catanhl
10468 @findex catanl
10469 @findex cbrt
10470 @findex cbrtf
10471 @findex cbrtl
10472 @findex ccos
10473 @findex ccosf
10474 @findex ccosh
10475 @findex ccoshf
10476 @findex ccoshl
10477 @findex ccosl
10478 @findex ceil
10479 @findex ceilf
10480 @findex ceill
10481 @findex cexp
10482 @findex cexpf
10483 @findex cexpl
10484 @findex cimag
10485 @findex cimagf
10486 @findex cimagl
10487 @findex clog
10488 @findex clogf
10489 @findex clogl
10490 @findex clog10
10491 @findex clog10f
10492 @findex clog10l
10493 @findex conj
10494 @findex conjf
10495 @findex conjl
10496 @findex copysign
10497 @findex copysignf
10498 @findex copysignl
10499 @findex cos
10500 @findex cosf
10501 @findex cosh
10502 @findex coshf
10503 @findex coshl
10504 @findex cosl
10505 @findex cpow
10506 @findex cpowf
10507 @findex cpowl
10508 @findex cproj
10509 @findex cprojf
10510 @findex cprojl
10511 @findex creal
10512 @findex crealf
10513 @findex creall
10514 @findex csin
10515 @findex csinf
10516 @findex csinh
10517 @findex csinhf
10518 @findex csinhl
10519 @findex csinl
10520 @findex csqrt
10521 @findex csqrtf
10522 @findex csqrtl
10523 @findex ctan
10524 @findex ctanf
10525 @findex ctanh
10526 @findex ctanhf
10527 @findex ctanhl
10528 @findex ctanl
10529 @findex dcgettext
10530 @findex dgettext
10531 @findex drem
10532 @findex dremf
10533 @findex dreml
10534 @findex erf
10535 @findex erfc
10536 @findex erfcf
10537 @findex erfcl
10538 @findex erff
10539 @findex erfl
10540 @findex exit
10541 @findex exp
10542 @findex exp10
10543 @findex exp10f
10544 @findex exp10l
10545 @findex exp2
10546 @findex exp2f
10547 @findex exp2l
10548 @findex expf
10549 @findex expl
10550 @findex expm1
10551 @findex expm1f
10552 @findex expm1l
10553 @findex fabs
10554 @findex fabsf
10555 @findex fabsl
10556 @findex fdim
10557 @findex fdimf
10558 @findex fdiml
10559 @findex ffs
10560 @findex floor
10561 @findex floorf
10562 @findex floorl
10563 @findex fma
10564 @findex fmaf
10565 @findex fmal
10566 @findex fmax
10567 @findex fmaxf
10568 @findex fmaxl
10569 @findex fmin
10570 @findex fminf
10571 @findex fminl
10572 @findex fmod
10573 @findex fmodf
10574 @findex fmodl
10575 @findex fprintf
10576 @findex fprintf_unlocked
10577 @findex fputs
10578 @findex fputs_unlocked
10579 @findex frexp
10580 @findex frexpf
10581 @findex frexpl
10582 @findex fscanf
10583 @findex gamma
10584 @findex gammaf
10585 @findex gammal
10586 @findex gamma_r
10587 @findex gammaf_r
10588 @findex gammal_r
10589 @findex gettext
10590 @findex hypot
10591 @findex hypotf
10592 @findex hypotl
10593 @findex ilogb
10594 @findex ilogbf
10595 @findex ilogbl
10596 @findex imaxabs
10597 @findex index
10598 @findex isalnum
10599 @findex isalpha
10600 @findex isascii
10601 @findex isblank
10602 @findex iscntrl
10603 @findex isdigit
10604 @findex isgraph
10605 @findex islower
10606 @findex isprint
10607 @findex ispunct
10608 @findex isspace
10609 @findex isupper
10610 @findex iswalnum
10611 @findex iswalpha
10612 @findex iswblank
10613 @findex iswcntrl
10614 @findex iswdigit
10615 @findex iswgraph
10616 @findex iswlower
10617 @findex iswprint
10618 @findex iswpunct
10619 @findex iswspace
10620 @findex iswupper
10621 @findex iswxdigit
10622 @findex isxdigit
10623 @findex j0
10624 @findex j0f
10625 @findex j0l
10626 @findex j1
10627 @findex j1f
10628 @findex j1l
10629 @findex jn
10630 @findex jnf
10631 @findex jnl
10632 @findex labs
10633 @findex ldexp
10634 @findex ldexpf
10635 @findex ldexpl
10636 @findex lgamma
10637 @findex lgammaf
10638 @findex lgammal
10639 @findex lgamma_r
10640 @findex lgammaf_r
10641 @findex lgammal_r
10642 @findex llabs
10643 @findex llrint
10644 @findex llrintf
10645 @findex llrintl
10646 @findex llround
10647 @findex llroundf
10648 @findex llroundl
10649 @findex log
10650 @findex log10
10651 @findex log10f
10652 @findex log10l
10653 @findex log1p
10654 @findex log1pf
10655 @findex log1pl
10656 @findex log2
10657 @findex log2f
10658 @findex log2l
10659 @findex logb
10660 @findex logbf
10661 @findex logbl
10662 @findex logf
10663 @findex logl
10664 @findex lrint
10665 @findex lrintf
10666 @findex lrintl
10667 @findex lround
10668 @findex lroundf
10669 @findex lroundl
10670 @findex malloc
10671 @findex memchr
10672 @findex memcmp
10673 @findex memcpy
10674 @findex mempcpy
10675 @findex memset
10676 @findex modf
10677 @findex modff
10678 @findex modfl
10679 @findex nearbyint
10680 @findex nearbyintf
10681 @findex nearbyintl
10682 @findex nextafter
10683 @findex nextafterf
10684 @findex nextafterl
10685 @findex nexttoward
10686 @findex nexttowardf
10687 @findex nexttowardl
10688 @findex pow
10689 @findex pow10
10690 @findex pow10f
10691 @findex pow10l
10692 @findex powf
10693 @findex powl
10694 @findex printf
10695 @findex printf_unlocked
10696 @findex putchar
10697 @findex puts
10698 @findex remainder
10699 @findex remainderf
10700 @findex remainderl
10701 @findex remquo
10702 @findex remquof
10703 @findex remquol
10704 @findex rindex
10705 @findex rint
10706 @findex rintf
10707 @findex rintl
10708 @findex round
10709 @findex roundf
10710 @findex roundl
10711 @findex scalb
10712 @findex scalbf
10713 @findex scalbl
10714 @findex scalbln
10715 @findex scalblnf
10716 @findex scalblnf
10717 @findex scalbn
10718 @findex scalbnf
10719 @findex scanfnl
10720 @findex signbit
10721 @findex signbitf
10722 @findex signbitl
10723 @findex signbitd32
10724 @findex signbitd64
10725 @findex signbitd128
10726 @findex significand
10727 @findex significandf
10728 @findex significandl
10729 @findex sin
10730 @findex sincos
10731 @findex sincosf
10732 @findex sincosl
10733 @findex sinf
10734 @findex sinh
10735 @findex sinhf
10736 @findex sinhl
10737 @findex sinl
10738 @findex snprintf
10739 @findex sprintf
10740 @findex sqrt
10741 @findex sqrtf
10742 @findex sqrtl
10743 @findex sscanf
10744 @findex stpcpy
10745 @findex stpncpy
10746 @findex strcasecmp
10747 @findex strcat
10748 @findex strchr
10749 @findex strcmp
10750 @findex strcpy
10751 @findex strcspn
10752 @findex strdup
10753 @findex strfmon
10754 @findex strftime
10755 @findex strlen
10756 @findex strncasecmp
10757 @findex strncat
10758 @findex strncmp
10759 @findex strncpy
10760 @findex strndup
10761 @findex strpbrk
10762 @findex strrchr
10763 @findex strspn
10764 @findex strstr
10765 @findex tan
10766 @findex tanf
10767 @findex tanh
10768 @findex tanhf
10769 @findex tanhl
10770 @findex tanl
10771 @findex tgamma
10772 @findex tgammaf
10773 @findex tgammal
10774 @findex toascii
10775 @findex tolower
10776 @findex toupper
10777 @findex towlower
10778 @findex towupper
10779 @findex trunc
10780 @findex truncf
10781 @findex truncl
10782 @findex vfprintf
10783 @findex vfscanf
10784 @findex vprintf
10785 @findex vscanf
10786 @findex vsnprintf
10787 @findex vsprintf
10788 @findex vsscanf
10789 @findex y0
10790 @findex y0f
10791 @findex y0l
10792 @findex y1
10793 @findex y1f
10794 @findex y1l
10795 @findex yn
10796 @findex ynf
10797 @findex ynl
10798
10799 GCC provides a large number of built-in functions other than the ones
10800 mentioned above. Some of these are for internal use in the processing
10801 of exceptions or variable-length argument lists and are not
10802 documented here because they may change from time to time; we do not
10803 recommend general use of these functions.
10804
10805 The remaining functions are provided for optimization purposes.
10806
10807 With the exception of built-ins that have library equivalents such as
10808 the standard C library functions discussed below, or that expand to
10809 library calls, GCC built-in functions are always expanded inline and
10810 thus do not have corresponding entry points and their address cannot
10811 be obtained. Attempting to use them in an expression other than
10812 a function call results in a compile-time error.
10813
10814 @opindex fno-builtin
10815 GCC includes built-in versions of many of the functions in the standard
10816 C library. These functions come in two forms: one whose names start with
10817 the @code{__builtin_} prefix, and the other without. Both forms have the
10818 same type (including prototype), the same address (when their address is
10819 taken), and the same meaning as the C library functions even if you specify
10820 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10821 functions are only optimized in certain cases; if they are not optimized in
10822 a particular case, a call to the library function is emitted.
10823
10824 @opindex ansi
10825 @opindex std
10826 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10827 @option{-std=c99} or @option{-std=c11}), the functions
10828 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10829 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10830 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10831 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10832 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10833 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10834 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10835 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10836 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10837 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10838 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10839 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10840 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10841 @code{significandl}, @code{significand}, @code{sincosf},
10842 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10843 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10844 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10845 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10846 @code{yn}
10847 may be handled as built-in functions.
10848 All these functions have corresponding versions
10849 prefixed with @code{__builtin_}, which may be used even in strict C90
10850 mode.
10851
10852 The ISO C99 functions
10853 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10854 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10855 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10856 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10857 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10858 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10859 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10860 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10861 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10862 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10863 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10864 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10865 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10866 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10867 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10868 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10869 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10870 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10871 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10872 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10873 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10874 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10875 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10876 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10877 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10878 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10879 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10880 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10881 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10882 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10883 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10884 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10885 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10886 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10887 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10888 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10889 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10890 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10891 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10892 are handled as built-in functions
10893 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10894
10895 There are also built-in versions of the ISO C99 functions
10896 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10897 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10898 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10899 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10900 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10901 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10902 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10903 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10904 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10905 that are recognized in any mode since ISO C90 reserves these names for
10906 the purpose to which ISO C99 puts them. All these functions have
10907 corresponding versions prefixed with @code{__builtin_}.
10908
10909 There are also built-in functions @code{__builtin_fabsf@var{n}},
10910 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
10911 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
10912 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
10913 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
10914 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
10915
10916 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10917 @code{clog10l} which names are reserved by ISO C99 for future use.
10918 All these functions have versions prefixed with @code{__builtin_}.
10919
10920 The ISO C94 functions
10921 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10922 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10923 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10924 @code{towupper}
10925 are handled as built-in functions
10926 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10927
10928 The ISO C90 functions
10929 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10930 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10931 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10932 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10933 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10934 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10935 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10936 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10937 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10938 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10939 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10940 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10941 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10942 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10943 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10944 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10945 are all recognized as built-in functions unless
10946 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10947 is specified for an individual function). All of these functions have
10948 corresponding versions prefixed with @code{__builtin_}.
10949
10950 GCC provides built-in versions of the ISO C99 floating-point comparison
10951 macros that avoid raising exceptions for unordered operands. They have
10952 the same names as the standard macros ( @code{isgreater},
10953 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10954 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10955 prefixed. We intend for a library implementor to be able to simply
10956 @code{#define} each standard macro to its built-in equivalent.
10957 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10958 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10959 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10960 built-in functions appear both with and without the @code{__builtin_} prefix.
10961
10962 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10963 The @code{__builtin_alloca} function must be called at block scope.
10964 The function allocates an object @var{size} bytes large on the stack
10965 of the calling function. The object is aligned on the default stack
10966 alignment boundary for the target determined by the
10967 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10968 function returns a pointer to the first byte of the allocated object.
10969 The lifetime of the allocated object ends just before the calling
10970 function returns to its caller. This is so even when
10971 @code{__builtin_alloca} is called within a nested block.
10972
10973 For example, the following function allocates eight objects of @code{n}
10974 bytes each on the stack, storing a pointer to each in consecutive elements
10975 of the array @code{a}. It then passes the array to function @code{g}
10976 which can safely use the storage pointed to by each of the array elements.
10977
10978 @smallexample
10979 void f (unsigned n)
10980 @{
10981 void *a [8];
10982 for (int i = 0; i != 8; ++i)
10983 a [i] = __builtin_alloca (n);
10984
10985 g (a, n); // @r{safe}
10986 @}
10987 @end smallexample
10988
10989 Since the @code{__builtin_alloca} function doesn't validate its argument
10990 it is the responsibility of its caller to make sure the argument doesn't
10991 cause it to exceed the stack size limit.
10992 The @code{__builtin_alloca} function is provided to make it possible to
10993 allocate on the stack arrays of bytes with an upper bound that may be
10994 computed at run time. Since C99 Variable Length Arrays offer
10995 similar functionality under a portable, more convenient, and safer
10996 interface they are recommended instead, in both C99 and C++ programs
10997 where GCC provides them as an extension.
10998 @xref{Variable Length}, for details.
10999
11000 @end deftypefn
11001
11002 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11003 The @code{__builtin_alloca_with_align} function must be called at block
11004 scope. The function allocates an object @var{size} bytes large on
11005 the stack of the calling function. The allocated object is aligned on
11006 the boundary specified by the argument @var{alignment} whose unit is given
11007 in bits (not bytes). The @var{size} argument must be positive and not
11008 exceed the stack size limit. The @var{alignment} argument must be a constant
11009 integer expression that evaluates to a power of 2 greater than or equal to
11010 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
11011 with other values are rejected with an error indicating the valid bounds.
11012 The function returns a pointer to the first byte of the allocated object.
11013 The lifetime of the allocated object ends at the end of the block in which
11014 the function was called. The allocated storage is released no later than
11015 just before the calling function returns to its caller, but may be released
11016 at the end of the block in which the function was called.
11017
11018 For example, in the following function the call to @code{g} is unsafe
11019 because when @code{overalign} is non-zero, the space allocated by
11020 @code{__builtin_alloca_with_align} may have been released at the end
11021 of the @code{if} statement in which it was called.
11022
11023 @smallexample
11024 void f (unsigned n, bool overalign)
11025 @{
11026 void *p;
11027 if (overalign)
11028 p = __builtin_alloca_with_align (n, 64 /* bits */);
11029 else
11030 p = __builtin_alloc (n);
11031
11032 g (p, n); // @r{unsafe}
11033 @}
11034 @end smallexample
11035
11036 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11037 @var{size} argument it is the responsibility of its caller to make sure
11038 the argument doesn't cause it to exceed the stack size limit.
11039 The @code{__builtin_alloca_with_align} function is provided to make
11040 it possible to allocate on the stack overaligned arrays of bytes with
11041 an upper bound that may be computed at run time. Since C99
11042 Variable Length Arrays offer the same functionality under
11043 a portable, more convenient, and safer interface they are recommended
11044 instead, in both C99 and C++ programs where GCC provides them as
11045 an extension. @xref{Variable Length}, for details.
11046
11047 @end deftypefn
11048
11049 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11050
11051 You can use the built-in function @code{__builtin_types_compatible_p} to
11052 determine whether two types are the same.
11053
11054 This built-in function returns 1 if the unqualified versions of the
11055 types @var{type1} and @var{type2} (which are types, not expressions) are
11056 compatible, 0 otherwise. The result of this built-in function can be
11057 used in integer constant expressions.
11058
11059 This built-in function ignores top level qualifiers (e.g., @code{const},
11060 @code{volatile}). For example, @code{int} is equivalent to @code{const
11061 int}.
11062
11063 The type @code{int[]} and @code{int[5]} are compatible. On the other
11064 hand, @code{int} and @code{char *} are not compatible, even if the size
11065 of their types, on the particular architecture are the same. Also, the
11066 amount of pointer indirection is taken into account when determining
11067 similarity. Consequently, @code{short *} is not similar to
11068 @code{short **}. Furthermore, two types that are typedefed are
11069 considered compatible if their underlying types are compatible.
11070
11071 An @code{enum} type is not considered to be compatible with another
11072 @code{enum} type even if both are compatible with the same integer
11073 type; this is what the C standard specifies.
11074 For example, @code{enum @{foo, bar@}} is not similar to
11075 @code{enum @{hot, dog@}}.
11076
11077 You typically use this function in code whose execution varies
11078 depending on the arguments' types. For example:
11079
11080 @smallexample
11081 #define foo(x) \
11082 (@{ \
11083 typeof (x) tmp = (x); \
11084 if (__builtin_types_compatible_p (typeof (x), long double)) \
11085 tmp = foo_long_double (tmp); \
11086 else if (__builtin_types_compatible_p (typeof (x), double)) \
11087 tmp = foo_double (tmp); \
11088 else if (__builtin_types_compatible_p (typeof (x), float)) \
11089 tmp = foo_float (tmp); \
11090 else \
11091 abort (); \
11092 tmp; \
11093 @})
11094 @end smallexample
11095
11096 @emph{Note:} This construct is only available for C@.
11097
11098 @end deftypefn
11099
11100 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11101
11102 The @var{call_exp} expression must be a function call, and the
11103 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11104 is passed to the function call in the target's static chain location.
11105 The result of builtin is the result of the function call.
11106
11107 @emph{Note:} This builtin is only available for C@.
11108 This builtin can be used to call Go closures from C.
11109
11110 @end deftypefn
11111
11112 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11113
11114 You can use the built-in function @code{__builtin_choose_expr} to
11115 evaluate code depending on the value of a constant expression. This
11116 built-in function returns @var{exp1} if @var{const_exp}, which is an
11117 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11118
11119 This built-in function is analogous to the @samp{? :} operator in C,
11120 except that the expression returned has its type unaltered by promotion
11121 rules. Also, the built-in function does not evaluate the expression
11122 that is not chosen. For example, if @var{const_exp} evaluates to true,
11123 @var{exp2} is not evaluated even if it has side-effects.
11124
11125 This built-in function can return an lvalue if the chosen argument is an
11126 lvalue.
11127
11128 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11129 type. Similarly, if @var{exp2} is returned, its return type is the same
11130 as @var{exp2}.
11131
11132 Example:
11133
11134 @smallexample
11135 #define foo(x) \
11136 __builtin_choose_expr ( \
11137 __builtin_types_compatible_p (typeof (x), double), \
11138 foo_double (x), \
11139 __builtin_choose_expr ( \
11140 __builtin_types_compatible_p (typeof (x), float), \
11141 foo_float (x), \
11142 /* @r{The void expression results in a compile-time error} \
11143 @r{when assigning the result to something.} */ \
11144 (void)0))
11145 @end smallexample
11146
11147 @emph{Note:} This construct is only available for C@. Furthermore, the
11148 unused expression (@var{exp1} or @var{exp2} depending on the value of
11149 @var{const_exp}) may still generate syntax errors. This may change in
11150 future revisions.
11151
11152 @end deftypefn
11153
11154 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11155
11156 The built-in function @code{__builtin_complex} is provided for use in
11157 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11158 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11159 real binary floating-point type, and the result has the corresponding
11160 complex type with real and imaginary parts @var{real} and @var{imag}.
11161 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11162 infinities, NaNs and negative zeros are involved.
11163
11164 @end deftypefn
11165
11166 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11167 You can use the built-in function @code{__builtin_constant_p} to
11168 determine if a value is known to be constant at compile time and hence
11169 that GCC can perform constant-folding on expressions involving that
11170 value. The argument of the function is the value to test. The function
11171 returns the integer 1 if the argument is known to be a compile-time
11172 constant and 0 if it is not known to be a compile-time constant. A
11173 return of 0 does not indicate that the value is @emph{not} a constant,
11174 but merely that GCC cannot prove it is a constant with the specified
11175 value of the @option{-O} option.
11176
11177 You typically use this function in an embedded application where
11178 memory is a critical resource. If you have some complex calculation,
11179 you may want it to be folded if it involves constants, but need to call
11180 a function if it does not. For example:
11181
11182 @smallexample
11183 #define Scale_Value(X) \
11184 (__builtin_constant_p (X) \
11185 ? ((X) * SCALE + OFFSET) : Scale (X))
11186 @end smallexample
11187
11188 You may use this built-in function in either a macro or an inline
11189 function. However, if you use it in an inlined function and pass an
11190 argument of the function as the argument to the built-in, GCC
11191 never returns 1 when you call the inline function with a string constant
11192 or compound literal (@pxref{Compound Literals}) and does not return 1
11193 when you pass a constant numeric value to the inline function unless you
11194 specify the @option{-O} option.
11195
11196 You may also use @code{__builtin_constant_p} in initializers for static
11197 data. For instance, you can write
11198
11199 @smallexample
11200 static const int table[] = @{
11201 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11202 /* @r{@dots{}} */
11203 @};
11204 @end smallexample
11205
11206 @noindent
11207 This is an acceptable initializer even if @var{EXPRESSION} is not a
11208 constant expression, including the case where
11209 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11210 folded to a constant but @var{EXPRESSION} contains operands that are
11211 not otherwise permitted in a static initializer (for example,
11212 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11213 built-in in this case, because it has no opportunity to perform
11214 optimization.
11215 @end deftypefn
11216
11217 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11218 @opindex fprofile-arcs
11219 You may use @code{__builtin_expect} to provide the compiler with
11220 branch prediction information. In general, you should prefer to
11221 use actual profile feedback for this (@option{-fprofile-arcs}), as
11222 programmers are notoriously bad at predicting how their programs
11223 actually perform. However, there are applications in which this
11224 data is hard to collect.
11225
11226 The return value is the value of @var{exp}, which should be an integral
11227 expression. The semantics of the built-in are that it is expected that
11228 @var{exp} == @var{c}. For example:
11229
11230 @smallexample
11231 if (__builtin_expect (x, 0))
11232 foo ();
11233 @end smallexample
11234
11235 @noindent
11236 indicates that we do not expect to call @code{foo}, since
11237 we expect @code{x} to be zero. Since you are limited to integral
11238 expressions for @var{exp}, you should use constructions such as
11239
11240 @smallexample
11241 if (__builtin_expect (ptr != NULL, 1))
11242 foo (*ptr);
11243 @end smallexample
11244
11245 @noindent
11246 when testing pointer or floating-point values.
11247 @end deftypefn
11248
11249 @deftypefn {Built-in Function} void __builtin_trap (void)
11250 This function causes the program to exit abnormally. GCC implements
11251 this function by using a target-dependent mechanism (such as
11252 intentionally executing an illegal instruction) or by calling
11253 @code{abort}. The mechanism used may vary from release to release so
11254 you should not rely on any particular implementation.
11255 @end deftypefn
11256
11257 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11258 If control flow reaches the point of the @code{__builtin_unreachable},
11259 the program is undefined. It is useful in situations where the
11260 compiler cannot deduce the unreachability of the code.
11261
11262 One such case is immediately following an @code{asm} statement that
11263 either never terminates, or one that transfers control elsewhere
11264 and never returns. In this example, without the
11265 @code{__builtin_unreachable}, GCC issues a warning that control
11266 reaches the end of a non-void function. It also generates code
11267 to return after the @code{asm}.
11268
11269 @smallexample
11270 int f (int c, int v)
11271 @{
11272 if (c)
11273 @{
11274 return v;
11275 @}
11276 else
11277 @{
11278 asm("jmp error_handler");
11279 __builtin_unreachable ();
11280 @}
11281 @}
11282 @end smallexample
11283
11284 @noindent
11285 Because the @code{asm} statement unconditionally transfers control out
11286 of the function, control never reaches the end of the function
11287 body. The @code{__builtin_unreachable} is in fact unreachable and
11288 communicates this fact to the compiler.
11289
11290 Another use for @code{__builtin_unreachable} is following a call a
11291 function that never returns but that is not declared
11292 @code{__attribute__((noreturn))}, as in this example:
11293
11294 @smallexample
11295 void function_that_never_returns (void);
11296
11297 int g (int c)
11298 @{
11299 if (c)
11300 @{
11301 return 1;
11302 @}
11303 else
11304 @{
11305 function_that_never_returns ();
11306 __builtin_unreachable ();
11307 @}
11308 @}
11309 @end smallexample
11310
11311 @end deftypefn
11312
11313 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11314 This function returns its first argument, and allows the compiler
11315 to assume that the returned pointer is at least @var{align} bytes
11316 aligned. This built-in can have either two or three arguments,
11317 if it has three, the third argument should have integer type, and
11318 if it is nonzero means misalignment offset. For example:
11319
11320 @smallexample
11321 void *x = __builtin_assume_aligned (arg, 16);
11322 @end smallexample
11323
11324 @noindent
11325 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11326 16-byte aligned, while:
11327
11328 @smallexample
11329 void *x = __builtin_assume_aligned (arg, 32, 8);
11330 @end smallexample
11331
11332 @noindent
11333 means that the compiler can assume for @code{x}, set to @code{arg}, that
11334 @code{(char *) x - 8} is 32-byte aligned.
11335 @end deftypefn
11336
11337 @deftypefn {Built-in Function} int __builtin_LINE ()
11338 This function is the equivalent of the preprocessor @code{__LINE__}
11339 macro and returns a constant integer expression that evaluates to
11340 the line number of the invocation of the built-in. When used as a C++
11341 default argument for a function @var{F}, it returns the line number
11342 of the call to @var{F}.
11343 @end deftypefn
11344
11345 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11346 This function is the equivalent of the @code{__FUNCTION__} symbol
11347 and returns an address constant pointing to the name of the function
11348 from which the built-in was invoked, or the empty string if
11349 the invocation is not at function scope. When used as a C++ default
11350 argument for a function @var{F}, it returns the name of @var{F}'s
11351 caller or the empty string if the call was not made at function
11352 scope.
11353 @end deftypefn
11354
11355 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11356 This function is the equivalent of the preprocessor @code{__FILE__}
11357 macro and returns an address constant pointing to the file name
11358 containing the invocation of the built-in, or the empty string if
11359 the invocation is not at function scope. When used as a C++ default
11360 argument for a function @var{F}, it returns the file name of the call
11361 to @var{F} or the empty string if the call was not made at function
11362 scope.
11363
11364 For example, in the following, each call to function @code{foo} will
11365 print a line similar to @code{"file.c:123: foo: message"} with the name
11366 of the file and the line number of the @code{printf} call, the name of
11367 the function @code{foo}, followed by the word @code{message}.
11368
11369 @smallexample
11370 const char*
11371 function (const char *func = __builtin_FUNCTION ())
11372 @{
11373 return func;
11374 @}
11375
11376 void foo (void)
11377 @{
11378 printf ("%s:%i: %s: message\n", file (), line (), function ());
11379 @}
11380 @end smallexample
11381
11382 @end deftypefn
11383
11384 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11385 This function is used to flush the processor's instruction cache for
11386 the region of memory between @var{begin} inclusive and @var{end}
11387 exclusive. Some targets require that the instruction cache be
11388 flushed, after modifying memory containing code, in order to obtain
11389 deterministic behavior.
11390
11391 If the target does not require instruction cache flushes,
11392 @code{__builtin___clear_cache} has no effect. Otherwise either
11393 instructions are emitted in-line to clear the instruction cache or a
11394 call to the @code{__clear_cache} function in libgcc is made.
11395 @end deftypefn
11396
11397 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11398 This function is used to minimize cache-miss latency by moving data into
11399 a cache before it is accessed.
11400 You can insert calls to @code{__builtin_prefetch} into code for which
11401 you know addresses of data in memory that is likely to be accessed soon.
11402 If the target supports them, data prefetch instructions are generated.
11403 If the prefetch is done early enough before the access then the data will
11404 be in the cache by the time it is accessed.
11405
11406 The value of @var{addr} is the address of the memory to prefetch.
11407 There are two optional arguments, @var{rw} and @var{locality}.
11408 The value of @var{rw} is a compile-time constant one or zero; one
11409 means that the prefetch is preparing for a write to the memory address
11410 and zero, the default, means that the prefetch is preparing for a read.
11411 The value @var{locality} must be a compile-time constant integer between
11412 zero and three. A value of zero means that the data has no temporal
11413 locality, so it need not be left in the cache after the access. A value
11414 of three means that the data has a high degree of temporal locality and
11415 should be left in all levels of cache possible. Values of one and two
11416 mean, respectively, a low or moderate degree of temporal locality. The
11417 default is three.
11418
11419 @smallexample
11420 for (i = 0; i < n; i++)
11421 @{
11422 a[i] = a[i] + b[i];
11423 __builtin_prefetch (&a[i+j], 1, 1);
11424 __builtin_prefetch (&b[i+j], 0, 1);
11425 /* @r{@dots{}} */
11426 @}
11427 @end smallexample
11428
11429 Data prefetch does not generate faults if @var{addr} is invalid, but
11430 the address expression itself must be valid. For example, a prefetch
11431 of @code{p->next} does not fault if @code{p->next} is not a valid
11432 address, but evaluation faults if @code{p} is not a valid address.
11433
11434 If the target does not support data prefetch, the address expression
11435 is evaluated if it includes side effects but no other code is generated
11436 and GCC does not issue a warning.
11437 @end deftypefn
11438
11439 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11440 Returns a positive infinity, if supported by the floating-point format,
11441 else @code{DBL_MAX}. This function is suitable for implementing the
11442 ISO C macro @code{HUGE_VAL}.
11443 @end deftypefn
11444
11445 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11446 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11447 @end deftypefn
11448
11449 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11450 Similar to @code{__builtin_huge_val}, except the return
11451 type is @code{long double}.
11452 @end deftypefn
11453
11454 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
11455 Similar to @code{__builtin_huge_val}, except the return type is
11456 @code{_Float@var{n}}.
11457 @end deftypefn
11458
11459 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
11460 Similar to @code{__builtin_huge_val}, except the return type is
11461 @code{_Float@var{n}x}.
11462 @end deftypefn
11463
11464 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11465 This built-in implements the C99 fpclassify functionality. The first
11466 five int arguments should be the target library's notion of the
11467 possible FP classes and are used for return values. They must be
11468 constant values and they must appear in this order: @code{FP_NAN},
11469 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11470 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11471 to classify. GCC treats the last argument as type-generic, which
11472 means it does not do default promotion from float to double.
11473 @end deftypefn
11474
11475 @deftypefn {Built-in Function} double __builtin_inf (void)
11476 Similar to @code{__builtin_huge_val}, except a warning is generated
11477 if the target floating-point format does not support infinities.
11478 @end deftypefn
11479
11480 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11481 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11482 @end deftypefn
11483
11484 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11485 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11486 @end deftypefn
11487
11488 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11489 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11490 @end deftypefn
11491
11492 @deftypefn {Built-in Function} float __builtin_inff (void)
11493 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11494 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11495 @end deftypefn
11496
11497 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11498 Similar to @code{__builtin_inf}, except the return
11499 type is @code{long double}.
11500 @end deftypefn
11501
11502 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
11503 Similar to @code{__builtin_inf}, except the return
11504 type is @code{_Float@var{n}}.
11505 @end deftypefn
11506
11507 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
11508 Similar to @code{__builtin_inf}, except the return
11509 type is @code{_Float@var{n}x}.
11510 @end deftypefn
11511
11512 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11513 Similar to @code{isinf}, except the return value is -1 for
11514 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11515 Note while the parameter list is an
11516 ellipsis, this function only accepts exactly one floating-point
11517 argument. GCC treats this parameter as type-generic, which means it
11518 does not do default promotion from float to double.
11519 @end deftypefn
11520
11521 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11522 This is an implementation of the ISO C99 function @code{nan}.
11523
11524 Since ISO C99 defines this function in terms of @code{strtod}, which we
11525 do not implement, a description of the parsing is in order. The string
11526 is parsed as by @code{strtol}; that is, the base is recognized by
11527 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11528 in the significand such that the least significant bit of the number
11529 is at the least significant bit of the significand. The number is
11530 truncated to fit the significand field provided. The significand is
11531 forced to be a quiet NaN@.
11532
11533 This function, if given a string literal all of which would have been
11534 consumed by @code{strtol}, is evaluated early enough that it is considered a
11535 compile-time constant.
11536 @end deftypefn
11537
11538 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11539 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11540 @end deftypefn
11541
11542 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11543 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11544 @end deftypefn
11545
11546 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11547 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11548 @end deftypefn
11549
11550 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11551 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11552 @end deftypefn
11553
11554 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11555 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11556 @end deftypefn
11557
11558 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
11559 Similar to @code{__builtin_nan}, except the return type is
11560 @code{_Float@var{n}}.
11561 @end deftypefn
11562
11563 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
11564 Similar to @code{__builtin_nan}, except the return type is
11565 @code{_Float@var{n}x}.
11566 @end deftypefn
11567
11568 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11569 Similar to @code{__builtin_nan}, except the significand is forced
11570 to be a signaling NaN@. The @code{nans} function is proposed by
11571 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11572 @end deftypefn
11573
11574 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11575 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11576 @end deftypefn
11577
11578 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11579 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11580 @end deftypefn
11581
11582 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
11583 Similar to @code{__builtin_nans}, except the return type is
11584 @code{_Float@var{n}}.
11585 @end deftypefn
11586
11587 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
11588 Similar to @code{__builtin_nans}, except the return type is
11589 @code{_Float@var{n}x}.
11590 @end deftypefn
11591
11592 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11593 Returns one plus the index of the least significant 1-bit of @var{x}, or
11594 if @var{x} is zero, returns zero.
11595 @end deftypefn
11596
11597 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11598 Returns the number of leading 0-bits in @var{x}, starting at the most
11599 significant bit position. If @var{x} is 0, the result is undefined.
11600 @end deftypefn
11601
11602 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11603 Returns the number of trailing 0-bits in @var{x}, starting at the least
11604 significant bit position. If @var{x} is 0, the result is undefined.
11605 @end deftypefn
11606
11607 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11608 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11609 number of bits following the most significant bit that are identical
11610 to it. There are no special cases for 0 or other values.
11611 @end deftypefn
11612
11613 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11614 Returns the number of 1-bits in @var{x}.
11615 @end deftypefn
11616
11617 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11618 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11619 modulo 2.
11620 @end deftypefn
11621
11622 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11623 Similar to @code{__builtin_ffs}, except the argument type is
11624 @code{long}.
11625 @end deftypefn
11626
11627 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11628 Similar to @code{__builtin_clz}, except the argument type is
11629 @code{unsigned long}.
11630 @end deftypefn
11631
11632 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11633 Similar to @code{__builtin_ctz}, except the argument type is
11634 @code{unsigned long}.
11635 @end deftypefn
11636
11637 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11638 Similar to @code{__builtin_clrsb}, except the argument type is
11639 @code{long}.
11640 @end deftypefn
11641
11642 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11643 Similar to @code{__builtin_popcount}, except the argument type is
11644 @code{unsigned long}.
11645 @end deftypefn
11646
11647 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11648 Similar to @code{__builtin_parity}, except the argument type is
11649 @code{unsigned long}.
11650 @end deftypefn
11651
11652 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11653 Similar to @code{__builtin_ffs}, except the argument type is
11654 @code{long long}.
11655 @end deftypefn
11656
11657 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11658 Similar to @code{__builtin_clz}, except the argument type is
11659 @code{unsigned long long}.
11660 @end deftypefn
11661
11662 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11663 Similar to @code{__builtin_ctz}, except the argument type is
11664 @code{unsigned long long}.
11665 @end deftypefn
11666
11667 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11668 Similar to @code{__builtin_clrsb}, except the argument type is
11669 @code{long long}.
11670 @end deftypefn
11671
11672 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11673 Similar to @code{__builtin_popcount}, except the argument type is
11674 @code{unsigned long long}.
11675 @end deftypefn
11676
11677 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11678 Similar to @code{__builtin_parity}, except the argument type is
11679 @code{unsigned long long}.
11680 @end deftypefn
11681
11682 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11683 Returns the first argument raised to the power of the second. Unlike the
11684 @code{pow} function no guarantees about precision and rounding are made.
11685 @end deftypefn
11686
11687 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11688 Similar to @code{__builtin_powi}, except the argument and return types
11689 are @code{float}.
11690 @end deftypefn
11691
11692 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11693 Similar to @code{__builtin_powi}, except the argument and return types
11694 are @code{long double}.
11695 @end deftypefn
11696
11697 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11698 Returns @var{x} with the order of the bytes reversed; for example,
11699 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11700 exactly 8 bits.
11701 @end deftypefn
11702
11703 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11704 Similar to @code{__builtin_bswap16}, except the argument and return types
11705 are 32 bit.
11706 @end deftypefn
11707
11708 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11709 Similar to @code{__builtin_bswap32}, except the argument and return types
11710 are 64 bit.
11711 @end deftypefn
11712
11713 @node Target Builtins
11714 @section Built-in Functions Specific to Particular Target Machines
11715
11716 On some target machines, GCC supports many built-in functions specific
11717 to those machines. Generally these generate calls to specific machine
11718 instructions, but allow the compiler to schedule those calls.
11719
11720 @menu
11721 * AArch64 Built-in Functions::
11722 * Alpha Built-in Functions::
11723 * Altera Nios II Built-in Functions::
11724 * ARC Built-in Functions::
11725 * ARC SIMD Built-in Functions::
11726 * ARM iWMMXt Built-in Functions::
11727 * ARM C Language Extensions (ACLE)::
11728 * ARM Floating Point Status and Control Intrinsics::
11729 * AVR Built-in Functions::
11730 * Blackfin Built-in Functions::
11731 * FR-V Built-in Functions::
11732 * MIPS DSP Built-in Functions::
11733 * MIPS Paired-Single Support::
11734 * MIPS Loongson Built-in Functions::
11735 * MIPS SIMD Architecture (MSA) Support::
11736 * Other MIPS Built-in Functions::
11737 * MSP430 Built-in Functions::
11738 * NDS32 Built-in Functions::
11739 * picoChip Built-in Functions::
11740 * PowerPC Built-in Functions::
11741 * PowerPC AltiVec/VSX Built-in Functions::
11742 * PowerPC Hardware Transactional Memory Built-in Functions::
11743 * RX Built-in Functions::
11744 * S/390 System z Built-in Functions::
11745 * SH Built-in Functions::
11746 * SPARC VIS Built-in Functions::
11747 * SPU Built-in Functions::
11748 * TI C6X Built-in Functions::
11749 * TILE-Gx Built-in Functions::
11750 * TILEPro Built-in Functions::
11751 * x86 Built-in Functions::
11752 * x86 transactional memory intrinsics::
11753 @end menu
11754
11755 @node AArch64 Built-in Functions
11756 @subsection AArch64 Built-in Functions
11757
11758 These built-in functions are available for the AArch64 family of
11759 processors.
11760 @smallexample
11761 unsigned int __builtin_aarch64_get_fpcr ()
11762 void __builtin_aarch64_set_fpcr (unsigned int)
11763 unsigned int __builtin_aarch64_get_fpsr ()
11764 void __builtin_aarch64_set_fpsr (unsigned int)
11765 @end smallexample
11766
11767 @node Alpha Built-in Functions
11768 @subsection Alpha Built-in Functions
11769
11770 These built-in functions are available for the Alpha family of
11771 processors, depending on the command-line switches used.
11772
11773 The following built-in functions are always available. They
11774 all generate the machine instruction that is part of the name.
11775
11776 @smallexample
11777 long __builtin_alpha_implver (void)
11778 long __builtin_alpha_rpcc (void)
11779 long __builtin_alpha_amask (long)
11780 long __builtin_alpha_cmpbge (long, long)
11781 long __builtin_alpha_extbl (long, long)
11782 long __builtin_alpha_extwl (long, long)
11783 long __builtin_alpha_extll (long, long)
11784 long __builtin_alpha_extql (long, long)
11785 long __builtin_alpha_extwh (long, long)
11786 long __builtin_alpha_extlh (long, long)
11787 long __builtin_alpha_extqh (long, long)
11788 long __builtin_alpha_insbl (long, long)
11789 long __builtin_alpha_inswl (long, long)
11790 long __builtin_alpha_insll (long, long)
11791 long __builtin_alpha_insql (long, long)
11792 long __builtin_alpha_inswh (long, long)
11793 long __builtin_alpha_inslh (long, long)
11794 long __builtin_alpha_insqh (long, long)
11795 long __builtin_alpha_mskbl (long, long)
11796 long __builtin_alpha_mskwl (long, long)
11797 long __builtin_alpha_mskll (long, long)
11798 long __builtin_alpha_mskql (long, long)
11799 long __builtin_alpha_mskwh (long, long)
11800 long __builtin_alpha_msklh (long, long)
11801 long __builtin_alpha_mskqh (long, long)
11802 long __builtin_alpha_umulh (long, long)
11803 long __builtin_alpha_zap (long, long)
11804 long __builtin_alpha_zapnot (long, long)
11805 @end smallexample
11806
11807 The following built-in functions are always with @option{-mmax}
11808 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11809 later. They all generate the machine instruction that is part
11810 of the name.
11811
11812 @smallexample
11813 long __builtin_alpha_pklb (long)
11814 long __builtin_alpha_pkwb (long)
11815 long __builtin_alpha_unpkbl (long)
11816 long __builtin_alpha_unpkbw (long)
11817 long __builtin_alpha_minub8 (long, long)
11818 long __builtin_alpha_minsb8 (long, long)
11819 long __builtin_alpha_minuw4 (long, long)
11820 long __builtin_alpha_minsw4 (long, long)
11821 long __builtin_alpha_maxub8 (long, long)
11822 long __builtin_alpha_maxsb8 (long, long)
11823 long __builtin_alpha_maxuw4 (long, long)
11824 long __builtin_alpha_maxsw4 (long, long)
11825 long __builtin_alpha_perr (long, long)
11826 @end smallexample
11827
11828 The following built-in functions are always with @option{-mcix}
11829 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11830 later. They all generate the machine instruction that is part
11831 of the name.
11832
11833 @smallexample
11834 long __builtin_alpha_cttz (long)
11835 long __builtin_alpha_ctlz (long)
11836 long __builtin_alpha_ctpop (long)
11837 @end smallexample
11838
11839 The following built-in functions are available on systems that use the OSF/1
11840 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11841 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11842 @code{rdval} and @code{wrval}.
11843
11844 @smallexample
11845 void *__builtin_thread_pointer (void)
11846 void __builtin_set_thread_pointer (void *)
11847 @end smallexample
11848
11849 @node Altera Nios II Built-in Functions
11850 @subsection Altera Nios II Built-in Functions
11851
11852 These built-in functions are available for the Altera Nios II
11853 family of processors.
11854
11855 The following built-in functions are always available. They
11856 all generate the machine instruction that is part of the name.
11857
11858 @example
11859 int __builtin_ldbio (volatile const void *)
11860 int __builtin_ldbuio (volatile const void *)
11861 int __builtin_ldhio (volatile const void *)
11862 int __builtin_ldhuio (volatile const void *)
11863 int __builtin_ldwio (volatile const void *)
11864 void __builtin_stbio (volatile void *, int)
11865 void __builtin_sthio (volatile void *, int)
11866 void __builtin_stwio (volatile void *, int)
11867 void __builtin_sync (void)
11868 int __builtin_rdctl (int)
11869 int __builtin_rdprs (int, int)
11870 void __builtin_wrctl (int, int)
11871 void __builtin_flushd (volatile void *)
11872 void __builtin_flushda (volatile void *)
11873 int __builtin_wrpie (int);
11874 void __builtin_eni (int);
11875 int __builtin_ldex (volatile const void *)
11876 int __builtin_stex (volatile void *, int)
11877 int __builtin_ldsex (volatile const void *)
11878 int __builtin_stsex (volatile void *, int)
11879 @end example
11880
11881 The following built-in functions are always available. They
11882 all generate a Nios II Custom Instruction. The name of the
11883 function represents the types that the function takes and
11884 returns. The letter before the @code{n} is the return type
11885 or void if absent. The @code{n} represents the first parameter
11886 to all the custom instructions, the custom instruction number.
11887 The two letters after the @code{n} represent the up to two
11888 parameters to the function.
11889
11890 The letters represent the following data types:
11891 @table @code
11892 @item <no letter>
11893 @code{void} for return type and no parameter for parameter types.
11894
11895 @item i
11896 @code{int} for return type and parameter type
11897
11898 @item f
11899 @code{float} for return type and parameter type
11900
11901 @item p
11902 @code{void *} for return type and parameter type
11903
11904 @end table
11905
11906 And the function names are:
11907 @example
11908 void __builtin_custom_n (void)
11909 void __builtin_custom_ni (int)
11910 void __builtin_custom_nf (float)
11911 void __builtin_custom_np (void *)
11912 void __builtin_custom_nii (int, int)
11913 void __builtin_custom_nif (int, float)
11914 void __builtin_custom_nip (int, void *)
11915 void __builtin_custom_nfi (float, int)
11916 void __builtin_custom_nff (float, float)
11917 void __builtin_custom_nfp (float, void *)
11918 void __builtin_custom_npi (void *, int)
11919 void __builtin_custom_npf (void *, float)
11920 void __builtin_custom_npp (void *, void *)
11921 int __builtin_custom_in (void)
11922 int __builtin_custom_ini (int)
11923 int __builtin_custom_inf (float)
11924 int __builtin_custom_inp (void *)
11925 int __builtin_custom_inii (int, int)
11926 int __builtin_custom_inif (int, float)
11927 int __builtin_custom_inip (int, void *)
11928 int __builtin_custom_infi (float, int)
11929 int __builtin_custom_inff (float, float)
11930 int __builtin_custom_infp (float, void *)
11931 int __builtin_custom_inpi (void *, int)
11932 int __builtin_custom_inpf (void *, float)
11933 int __builtin_custom_inpp (void *, void *)
11934 float __builtin_custom_fn (void)
11935 float __builtin_custom_fni (int)
11936 float __builtin_custom_fnf (float)
11937 float __builtin_custom_fnp (void *)
11938 float __builtin_custom_fnii (int, int)
11939 float __builtin_custom_fnif (int, float)
11940 float __builtin_custom_fnip (int, void *)
11941 float __builtin_custom_fnfi (float, int)
11942 float __builtin_custom_fnff (float, float)
11943 float __builtin_custom_fnfp (float, void *)
11944 float __builtin_custom_fnpi (void *, int)
11945 float __builtin_custom_fnpf (void *, float)
11946 float __builtin_custom_fnpp (void *, void *)
11947 void * __builtin_custom_pn (void)
11948 void * __builtin_custom_pni (int)
11949 void * __builtin_custom_pnf (float)
11950 void * __builtin_custom_pnp (void *)
11951 void * __builtin_custom_pnii (int, int)
11952 void * __builtin_custom_pnif (int, float)
11953 void * __builtin_custom_pnip (int, void *)
11954 void * __builtin_custom_pnfi (float, int)
11955 void * __builtin_custom_pnff (float, float)
11956 void * __builtin_custom_pnfp (float, void *)
11957 void * __builtin_custom_pnpi (void *, int)
11958 void * __builtin_custom_pnpf (void *, float)
11959 void * __builtin_custom_pnpp (void *, void *)
11960 @end example
11961
11962 @node ARC Built-in Functions
11963 @subsection ARC Built-in Functions
11964
11965 The following built-in functions are provided for ARC targets. The
11966 built-ins generate the corresponding assembly instructions. In the
11967 examples given below, the generated code often requires an operand or
11968 result to be in a register. Where necessary further code will be
11969 generated to ensure this is true, but for brevity this is not
11970 described in each case.
11971
11972 @emph{Note:} Using a built-in to generate an instruction not supported
11973 by a target may cause problems. At present the compiler is not
11974 guaranteed to detect such misuse, and as a result an internal compiler
11975 error may be generated.
11976
11977 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11978 Return 1 if @var{val} is known to have the byte alignment given
11979 by @var{alignval}, otherwise return 0.
11980 Note that this is different from
11981 @smallexample
11982 __alignof__(*(char *)@var{val}) >= alignval
11983 @end smallexample
11984 because __alignof__ sees only the type of the dereference, whereas
11985 __builtin_arc_align uses alignment information from the pointer
11986 as well as from the pointed-to type.
11987 The information available will depend on optimization level.
11988 @end deftypefn
11989
11990 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11991 Generates
11992 @example
11993 brk
11994 @end example
11995 @end deftypefn
11996
11997 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11998 The operand is the number of a register to be read. Generates:
11999 @example
12000 mov @var{dest}, r@var{regno}
12001 @end example
12002 where the value in @var{dest} will be the result returned from the
12003 built-in.
12004 @end deftypefn
12005
12006 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12007 The first operand is the number of a register to be written, the
12008 second operand is a compile time constant to write into that
12009 register. Generates:
12010 @example
12011 mov r@var{regno}, @var{val}
12012 @end example
12013 @end deftypefn
12014
12015 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12016 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12017 Generates:
12018 @example
12019 divaw @var{dest}, @var{a}, @var{b}
12020 @end example
12021 where the value in @var{dest} will be the result returned from the
12022 built-in.
12023 @end deftypefn
12024
12025 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12026 Generates
12027 @example
12028 flag @var{a}
12029 @end example
12030 @end deftypefn
12031
12032 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12033 The operand, @var{auxv}, is the address of an auxiliary register and
12034 must be a compile time constant. Generates:
12035 @example
12036 lr @var{dest}, [@var{auxr}]
12037 @end example
12038 Where the value in @var{dest} will be the result returned from the
12039 built-in.
12040 @end deftypefn
12041
12042 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12043 Only available with @option{-mmul64}. Generates:
12044 @example
12045 mul64 @var{a}, @var{b}
12046 @end example
12047 @end deftypefn
12048
12049 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12050 Only available with @option{-mmul64}. Generates:
12051 @example
12052 mulu64 @var{a}, @var{b}
12053 @end example
12054 @end deftypefn
12055
12056 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12057 Generates:
12058 @example
12059 nop
12060 @end example
12061 @end deftypefn
12062
12063 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12064 Only valid if the @samp{norm} instruction is available through the
12065 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12066 Generates:
12067 @example
12068 norm @var{dest}, @var{src}
12069 @end example
12070 Where the value in @var{dest} will be the result returned from the
12071 built-in.
12072 @end deftypefn
12073
12074 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
12075 Only valid if the @samp{normw} instruction is available through the
12076 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12077 Generates:
12078 @example
12079 normw @var{dest}, @var{src}
12080 @end example
12081 Where the value in @var{dest} will be the result returned from the
12082 built-in.
12083 @end deftypefn
12084
12085 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
12086 Generates:
12087 @example
12088 rtie
12089 @end example
12090 @end deftypefn
12091
12092 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
12093 Generates:
12094 @example
12095 sleep @var{a}
12096 @end example
12097 @end deftypefn
12098
12099 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12100 The first argument, @var{auxv}, is the address of an auxiliary
12101 register, the second argument, @var{val}, is a compile time constant
12102 to be written to the register. Generates:
12103 @example
12104 sr @var{auxr}, [@var{val}]
12105 @end example
12106 @end deftypefn
12107
12108 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
12109 Only valid with @option{-mswap}. Generates:
12110 @example
12111 swap @var{dest}, @var{src}
12112 @end example
12113 Where the value in @var{dest} will be the result returned from the
12114 built-in.
12115 @end deftypefn
12116
12117 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12118 Generates:
12119 @example
12120 swi
12121 @end example
12122 @end deftypefn
12123
12124 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12125 Only available with @option{-mcpu=ARC700}. Generates:
12126 @example
12127 sync
12128 @end example
12129 @end deftypefn
12130
12131 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12132 Only available with @option{-mcpu=ARC700}. Generates:
12133 @example
12134 trap_s @var{c}
12135 @end example
12136 @end deftypefn
12137
12138 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12139 Only available with @option{-mcpu=ARC700}. Generates:
12140 @example
12141 unimp_s
12142 @end example
12143 @end deftypefn
12144
12145 The instructions generated by the following builtins are not
12146 considered as candidates for scheduling. They are not moved around by
12147 the compiler during scheduling, and thus can be expected to appear
12148 where they are put in the C code:
12149 @example
12150 __builtin_arc_brk()
12151 __builtin_arc_core_read()
12152 __builtin_arc_core_write()
12153 __builtin_arc_flag()
12154 __builtin_arc_lr()
12155 __builtin_arc_sleep()
12156 __builtin_arc_sr()
12157 __builtin_arc_swi()
12158 @end example
12159
12160 @node ARC SIMD Built-in Functions
12161 @subsection ARC SIMD Built-in Functions
12162
12163 SIMD builtins provided by the compiler can be used to generate the
12164 vector instructions. This section describes the available builtins
12165 and their usage in programs. With the @option{-msimd} option, the
12166 compiler provides 128-bit vector types, which can be specified using
12167 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12168 can be included to use the following predefined types:
12169 @example
12170 typedef int __v4si __attribute__((vector_size(16)));
12171 typedef short __v8hi __attribute__((vector_size(16)));
12172 @end example
12173
12174 These types can be used to define 128-bit variables. The built-in
12175 functions listed in the following section can be used on these
12176 variables to generate the vector operations.
12177
12178 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12179 @file{arc-simd.h} also provides equivalent macros called
12180 @code{_@var{someinsn}} that can be used for programming ease and
12181 improved readability. The following macros for DMA control are also
12182 provided:
12183 @example
12184 #define _setup_dma_in_channel_reg _vdiwr
12185 #define _setup_dma_out_channel_reg _vdowr
12186 @end example
12187
12188 The following is a complete list of all the SIMD built-ins provided
12189 for ARC, grouped by calling signature.
12190
12191 The following take two @code{__v8hi} arguments and return a
12192 @code{__v8hi} result:
12193 @example
12194 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12195 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12196 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12197 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12198 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12199 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12200 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12201 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12202 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12203 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12204 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12205 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12206 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12207 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12208 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12209 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12210 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12211 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12212 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12213 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12214 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12215 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12216 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12217 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12218 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12219 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12220 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12221 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12222 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12223 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12224 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12225 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12226 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12227 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12228 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12229 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12230 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12231 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12232 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12233 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12234 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12235 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12236 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12237 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12238 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12239 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12240 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12241 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12242 @end example
12243
12244 The following take one @code{__v8hi} and one @code{int} argument and return a
12245 @code{__v8hi} result:
12246
12247 @example
12248 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12249 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12250 __v8hi __builtin_arc_vbminw (__v8hi, int)
12251 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12252 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12253 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12254 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12255 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12256 @end example
12257
12258 The following take one @code{__v8hi} argument and one @code{int} argument which
12259 must be a 3-bit compile time constant indicating a register number
12260 I0-I7. They return a @code{__v8hi} result.
12261 @example
12262 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12263 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12264 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12265 @end example
12266
12267 The following take one @code{__v8hi} argument and one @code{int}
12268 argument which must be a 6-bit compile time constant. They return a
12269 @code{__v8hi} result.
12270 @example
12271 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12272 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12273 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12274 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12275 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12276 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12277 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12278 @end example
12279
12280 The following take one @code{__v8hi} argument and one @code{int} argument which
12281 must be a 8-bit compile time constant. They return a @code{__v8hi}
12282 result.
12283 @example
12284 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12285 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12286 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12287 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12288 @end example
12289
12290 The following take two @code{int} arguments, the second of which which
12291 must be a 8-bit compile time constant. They return a @code{__v8hi}
12292 result:
12293 @example
12294 __v8hi __builtin_arc_vmovaw (int, const int)
12295 __v8hi __builtin_arc_vmovw (int, const int)
12296 __v8hi __builtin_arc_vmovzw (int, const int)
12297 @end example
12298
12299 The following take a single @code{__v8hi} argument and return a
12300 @code{__v8hi} result:
12301 @example
12302 __v8hi __builtin_arc_vabsaw (__v8hi)
12303 __v8hi __builtin_arc_vabsw (__v8hi)
12304 __v8hi __builtin_arc_vaddsuw (__v8hi)
12305 __v8hi __builtin_arc_vexch1 (__v8hi)
12306 __v8hi __builtin_arc_vexch2 (__v8hi)
12307 __v8hi __builtin_arc_vexch4 (__v8hi)
12308 __v8hi __builtin_arc_vsignw (__v8hi)
12309 __v8hi __builtin_arc_vupbaw (__v8hi)
12310 __v8hi __builtin_arc_vupbw (__v8hi)
12311 __v8hi __builtin_arc_vupsbaw (__v8hi)
12312 __v8hi __builtin_arc_vupsbw (__v8hi)
12313 @end example
12314
12315 The following take two @code{int} arguments and return no result:
12316 @example
12317 void __builtin_arc_vdirun (int, int)
12318 void __builtin_arc_vdorun (int, int)
12319 @end example
12320
12321 The following take two @code{int} arguments and return no result. The
12322 first argument must a 3-bit compile time constant indicating one of
12323 the DR0-DR7 DMA setup channels:
12324 @example
12325 void __builtin_arc_vdiwr (const int, int)
12326 void __builtin_arc_vdowr (const int, int)
12327 @end example
12328
12329 The following take an @code{int} argument and return no result:
12330 @example
12331 void __builtin_arc_vendrec (int)
12332 void __builtin_arc_vrec (int)
12333 void __builtin_arc_vrecrun (int)
12334 void __builtin_arc_vrun (int)
12335 @end example
12336
12337 The following take a @code{__v8hi} argument and two @code{int}
12338 arguments and return a @code{__v8hi} result. The second argument must
12339 be a 3-bit compile time constants, indicating one the registers I0-I7,
12340 and the third argument must be an 8-bit compile time constant.
12341
12342 @emph{Note:} Although the equivalent hardware instructions do not take
12343 an SIMD register as an operand, these builtins overwrite the relevant
12344 bits of the @code{__v8hi} register provided as the first argument with
12345 the value loaded from the @code{[Ib, u8]} location in the SDM.
12346
12347 @example
12348 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12349 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12350 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12351 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12352 @end example
12353
12354 The following take two @code{int} arguments and return a @code{__v8hi}
12355 result. The first argument must be a 3-bit compile time constants,
12356 indicating one the registers I0-I7, and the second argument must be an
12357 8-bit compile time constant.
12358
12359 @example
12360 __v8hi __builtin_arc_vld128 (const int, const int)
12361 __v8hi __builtin_arc_vld64w (const int, const int)
12362 @end example
12363
12364 The following take a @code{__v8hi} argument and two @code{int}
12365 arguments and return no result. The second argument must be a 3-bit
12366 compile time constants, indicating one the registers I0-I7, and the
12367 third argument must be an 8-bit compile time constant.
12368
12369 @example
12370 void __builtin_arc_vst128 (__v8hi, const int, const int)
12371 void __builtin_arc_vst64 (__v8hi, const int, const int)
12372 @end example
12373
12374 The following take a @code{__v8hi} argument and three @code{int}
12375 arguments and return no result. The second argument must be a 3-bit
12376 compile-time constant, identifying the 16-bit sub-register to be
12377 stored, the third argument must be a 3-bit compile time constants,
12378 indicating one the registers I0-I7, and the fourth argument must be an
12379 8-bit compile time constant.
12380
12381 @example
12382 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12383 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12384 @end example
12385
12386 @node ARM iWMMXt Built-in Functions
12387 @subsection ARM iWMMXt Built-in Functions
12388
12389 These built-in functions are available for the ARM family of
12390 processors when the @option{-mcpu=iwmmxt} switch is used:
12391
12392 @smallexample
12393 typedef int v2si __attribute__ ((vector_size (8)));
12394 typedef short v4hi __attribute__ ((vector_size (8)));
12395 typedef char v8qi __attribute__ ((vector_size (8)));
12396
12397 int __builtin_arm_getwcgr0 (void)
12398 void __builtin_arm_setwcgr0 (int)
12399 int __builtin_arm_getwcgr1 (void)
12400 void __builtin_arm_setwcgr1 (int)
12401 int __builtin_arm_getwcgr2 (void)
12402 void __builtin_arm_setwcgr2 (int)
12403 int __builtin_arm_getwcgr3 (void)
12404 void __builtin_arm_setwcgr3 (int)
12405 int __builtin_arm_textrmsb (v8qi, int)
12406 int __builtin_arm_textrmsh (v4hi, int)
12407 int __builtin_arm_textrmsw (v2si, int)
12408 int __builtin_arm_textrmub (v8qi, int)
12409 int __builtin_arm_textrmuh (v4hi, int)
12410 int __builtin_arm_textrmuw (v2si, int)
12411 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12412 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12413 v2si __builtin_arm_tinsrw (v2si, int, int)
12414 long long __builtin_arm_tmia (long long, int, int)
12415 long long __builtin_arm_tmiabb (long long, int, int)
12416 long long __builtin_arm_tmiabt (long long, int, int)
12417 long long __builtin_arm_tmiaph (long long, int, int)
12418 long long __builtin_arm_tmiatb (long long, int, int)
12419 long long __builtin_arm_tmiatt (long long, int, int)
12420 int __builtin_arm_tmovmskb (v8qi)
12421 int __builtin_arm_tmovmskh (v4hi)
12422 int __builtin_arm_tmovmskw (v2si)
12423 long long __builtin_arm_waccb (v8qi)
12424 long long __builtin_arm_wacch (v4hi)
12425 long long __builtin_arm_waccw (v2si)
12426 v8qi __builtin_arm_waddb (v8qi, v8qi)
12427 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12428 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12429 v4hi __builtin_arm_waddh (v4hi, v4hi)
12430 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12431 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12432 v2si __builtin_arm_waddw (v2si, v2si)
12433 v2si __builtin_arm_waddwss (v2si, v2si)
12434 v2si __builtin_arm_waddwus (v2si, v2si)
12435 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12436 long long __builtin_arm_wand(long long, long long)
12437 long long __builtin_arm_wandn (long long, long long)
12438 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12439 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12440 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12441 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12442 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12443 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12444 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12445 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12446 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12447 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12448 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12449 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12450 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12451 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12452 long long __builtin_arm_wmacsz (v4hi, v4hi)
12453 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12454 long long __builtin_arm_wmacuz (v4hi, v4hi)
12455 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12456 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12457 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12458 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12459 v2si __builtin_arm_wmaxsw (v2si, v2si)
12460 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12461 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12462 v2si __builtin_arm_wmaxuw (v2si, v2si)
12463 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12464 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12465 v2si __builtin_arm_wminsw (v2si, v2si)
12466 v8qi __builtin_arm_wminub (v8qi, v8qi)
12467 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12468 v2si __builtin_arm_wminuw (v2si, v2si)
12469 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12470 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12471 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12472 long long __builtin_arm_wor (long long, long long)
12473 v2si __builtin_arm_wpackdss (long long, long long)
12474 v2si __builtin_arm_wpackdus (long long, long long)
12475 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12476 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12477 v4hi __builtin_arm_wpackwss (v2si, v2si)
12478 v4hi __builtin_arm_wpackwus (v2si, v2si)
12479 long long __builtin_arm_wrord (long long, long long)
12480 long long __builtin_arm_wrordi (long long, int)
12481 v4hi __builtin_arm_wrorh (v4hi, long long)
12482 v4hi __builtin_arm_wrorhi (v4hi, int)
12483 v2si __builtin_arm_wrorw (v2si, long long)
12484 v2si __builtin_arm_wrorwi (v2si, int)
12485 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12486 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12487 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12488 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12489 v4hi __builtin_arm_wshufh (v4hi, int)
12490 long long __builtin_arm_wslld (long long, long long)
12491 long long __builtin_arm_wslldi (long long, int)
12492 v4hi __builtin_arm_wsllh (v4hi, long long)
12493 v4hi __builtin_arm_wsllhi (v4hi, int)
12494 v2si __builtin_arm_wsllw (v2si, long long)
12495 v2si __builtin_arm_wsllwi (v2si, int)
12496 long long __builtin_arm_wsrad (long long, long long)
12497 long long __builtin_arm_wsradi (long long, int)
12498 v4hi __builtin_arm_wsrah (v4hi, long long)
12499 v4hi __builtin_arm_wsrahi (v4hi, int)
12500 v2si __builtin_arm_wsraw (v2si, long long)
12501 v2si __builtin_arm_wsrawi (v2si, int)
12502 long long __builtin_arm_wsrld (long long, long long)
12503 long long __builtin_arm_wsrldi (long long, int)
12504 v4hi __builtin_arm_wsrlh (v4hi, long long)
12505 v4hi __builtin_arm_wsrlhi (v4hi, int)
12506 v2si __builtin_arm_wsrlw (v2si, long long)
12507 v2si __builtin_arm_wsrlwi (v2si, int)
12508 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12509 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12510 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12511 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12512 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12513 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12514 v2si __builtin_arm_wsubw (v2si, v2si)
12515 v2si __builtin_arm_wsubwss (v2si, v2si)
12516 v2si __builtin_arm_wsubwus (v2si, v2si)
12517 v4hi __builtin_arm_wunpckehsb (v8qi)
12518 v2si __builtin_arm_wunpckehsh (v4hi)
12519 long long __builtin_arm_wunpckehsw (v2si)
12520 v4hi __builtin_arm_wunpckehub (v8qi)
12521 v2si __builtin_arm_wunpckehuh (v4hi)
12522 long long __builtin_arm_wunpckehuw (v2si)
12523 v4hi __builtin_arm_wunpckelsb (v8qi)
12524 v2si __builtin_arm_wunpckelsh (v4hi)
12525 long long __builtin_arm_wunpckelsw (v2si)
12526 v4hi __builtin_arm_wunpckelub (v8qi)
12527 v2si __builtin_arm_wunpckeluh (v4hi)
12528 long long __builtin_arm_wunpckeluw (v2si)
12529 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12530 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12531 v2si __builtin_arm_wunpckihw (v2si, v2si)
12532 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12533 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12534 v2si __builtin_arm_wunpckilw (v2si, v2si)
12535 long long __builtin_arm_wxor (long long, long long)
12536 long long __builtin_arm_wzero ()
12537 @end smallexample
12538
12539
12540 @node ARM C Language Extensions (ACLE)
12541 @subsection ARM C Language Extensions (ACLE)
12542
12543 GCC implements extensions for C as described in the ARM C Language
12544 Extensions (ACLE) specification, which can be found at
12545 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12546
12547 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12548 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12549 intrinsics can be found at
12550 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12551 The built-in intrinsics for the Advanced SIMD extension are available when
12552 NEON is enabled.
12553
12554 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12555 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12556 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12557 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12558 intrinsics yet.
12559
12560 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12561 availability of extensions.
12562
12563 @node ARM Floating Point Status and Control Intrinsics
12564 @subsection ARM Floating Point Status and Control Intrinsics
12565
12566 These built-in functions are available for the ARM family of
12567 processors with floating-point unit.
12568
12569 @smallexample
12570 unsigned int __builtin_arm_get_fpscr ()
12571 void __builtin_arm_set_fpscr (unsigned int)
12572 @end smallexample
12573
12574 @node AVR Built-in Functions
12575 @subsection AVR Built-in Functions
12576
12577 For each built-in function for AVR, there is an equally named,
12578 uppercase built-in macro defined. That way users can easily query if
12579 or if not a specific built-in is implemented or not. For example, if
12580 @code{__builtin_avr_nop} is available the macro
12581 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12582
12583 The following built-in functions map to the respective machine
12584 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12585 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12586 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12587 as library call if no hardware multiplier is available.
12588
12589 @smallexample
12590 void __builtin_avr_nop (void)
12591 void __builtin_avr_sei (void)
12592 void __builtin_avr_cli (void)
12593 void __builtin_avr_sleep (void)
12594 void __builtin_avr_wdr (void)
12595 unsigned char __builtin_avr_swap (unsigned char)
12596 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12597 int __builtin_avr_fmuls (char, char)
12598 int __builtin_avr_fmulsu (char, unsigned char)
12599 @end smallexample
12600
12601 In order to delay execution for a specific number of cycles, GCC
12602 implements
12603 @smallexample
12604 void __builtin_avr_delay_cycles (unsigned long ticks)
12605 @end smallexample
12606
12607 @noindent
12608 @code{ticks} is the number of ticks to delay execution. Note that this
12609 built-in does not take into account the effect of interrupts that
12610 might increase delay time. @code{ticks} must be a compile-time
12611 integer constant; delays with a variable number of cycles are not supported.
12612
12613 @smallexample
12614 char __builtin_avr_flash_segment (const __memx void*)
12615 @end smallexample
12616
12617 @noindent
12618 This built-in takes a byte address to the 24-bit
12619 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12620 the number of the flash segment (the 64 KiB chunk) where the address
12621 points to. Counting starts at @code{0}.
12622 If the address does not point to flash memory, return @code{-1}.
12623
12624 @smallexample
12625 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12626 @end smallexample
12627
12628 @noindent
12629 Insert bits from @var{bits} into @var{val} and return the resulting
12630 value. The nibbles of @var{map} determine how the insertion is
12631 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12632 @enumerate
12633 @item If @var{X} is @code{0xf},
12634 then the @var{n}-th bit of @var{val} is returned unaltered.
12635
12636 @item If X is in the range 0@dots{}7,
12637 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12638
12639 @item If X is in the range 8@dots{}@code{0xe},
12640 then the @var{n}-th result bit is undefined.
12641 @end enumerate
12642
12643 @noindent
12644 One typical use case for this built-in is adjusting input and
12645 output values to non-contiguous port layouts. Some examples:
12646
12647 @smallexample
12648 // same as val, bits is unused
12649 __builtin_avr_insert_bits (0xffffffff, bits, val)
12650 @end smallexample
12651
12652 @smallexample
12653 // same as bits, val is unused
12654 __builtin_avr_insert_bits (0x76543210, bits, val)
12655 @end smallexample
12656
12657 @smallexample
12658 // same as rotating bits by 4
12659 __builtin_avr_insert_bits (0x32107654, bits, 0)
12660 @end smallexample
12661
12662 @smallexample
12663 // high nibble of result is the high nibble of val
12664 // low nibble of result is the low nibble of bits
12665 __builtin_avr_insert_bits (0xffff3210, bits, val)
12666 @end smallexample
12667
12668 @smallexample
12669 // reverse the bit order of bits
12670 __builtin_avr_insert_bits (0x01234567, bits, 0)
12671 @end smallexample
12672
12673 @smallexample
12674 void __builtin_avr_nops (unsigned count)
12675 @end smallexample
12676
12677 @noindent
12678 Insert @code{count} @code{NOP} instructions.
12679 The number of instructions must be a compile-time integer constant.
12680
12681 @node Blackfin Built-in Functions
12682 @subsection Blackfin Built-in Functions
12683
12684 Currently, there are two Blackfin-specific built-in functions. These are
12685 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12686 using inline assembly; by using these built-in functions the compiler can
12687 automatically add workarounds for hardware errata involving these
12688 instructions. These functions are named as follows:
12689
12690 @smallexample
12691 void __builtin_bfin_csync (void)
12692 void __builtin_bfin_ssync (void)
12693 @end smallexample
12694
12695 @node FR-V Built-in Functions
12696 @subsection FR-V Built-in Functions
12697
12698 GCC provides many FR-V-specific built-in functions. In general,
12699 these functions are intended to be compatible with those described
12700 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12701 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12702 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12703 pointer rather than by value.
12704
12705 Most of the functions are named after specific FR-V instructions.
12706 Such functions are said to be ``directly mapped'' and are summarized
12707 here in tabular form.
12708
12709 @menu
12710 * Argument Types::
12711 * Directly-mapped Integer Functions::
12712 * Directly-mapped Media Functions::
12713 * Raw read/write Functions::
12714 * Other Built-in Functions::
12715 @end menu
12716
12717 @node Argument Types
12718 @subsubsection Argument Types
12719
12720 The arguments to the built-in functions can be divided into three groups:
12721 register numbers, compile-time constants and run-time values. In order
12722 to make this classification clear at a glance, the arguments and return
12723 values are given the following pseudo types:
12724
12725 @multitable @columnfractions .20 .30 .15 .35
12726 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12727 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12728 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12729 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12730 @item @code{uw2} @tab @code{unsigned long long} @tab No
12731 @tab an unsigned doubleword
12732 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12733 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12734 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12735 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12736 @end multitable
12737
12738 These pseudo types are not defined by GCC, they are simply a notational
12739 convenience used in this manual.
12740
12741 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12742 and @code{sw2} are evaluated at run time. They correspond to
12743 register operands in the underlying FR-V instructions.
12744
12745 @code{const} arguments represent immediate operands in the underlying
12746 FR-V instructions. They must be compile-time constants.
12747
12748 @code{acc} arguments are evaluated at compile time and specify the number
12749 of an accumulator register. For example, an @code{acc} argument of 2
12750 selects the ACC2 register.
12751
12752 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12753 number of an IACC register. See @pxref{Other Built-in Functions}
12754 for more details.
12755
12756 @node Directly-mapped Integer Functions
12757 @subsubsection Directly-Mapped Integer Functions
12758
12759 The functions listed below map directly to FR-V I-type instructions.
12760
12761 @multitable @columnfractions .45 .32 .23
12762 @item Function prototype @tab Example usage @tab Assembly output
12763 @item @code{sw1 __ADDSS (sw1, sw1)}
12764 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12765 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12766 @item @code{sw1 __SCAN (sw1, sw1)}
12767 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12768 @tab @code{SCAN @var{a},@var{b},@var{c}}
12769 @item @code{sw1 __SCUTSS (sw1)}
12770 @tab @code{@var{b} = __SCUTSS (@var{a})}
12771 @tab @code{SCUTSS @var{a},@var{b}}
12772 @item @code{sw1 __SLASS (sw1, sw1)}
12773 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12774 @tab @code{SLASS @var{a},@var{b},@var{c}}
12775 @item @code{void __SMASS (sw1, sw1)}
12776 @tab @code{__SMASS (@var{a}, @var{b})}
12777 @tab @code{SMASS @var{a},@var{b}}
12778 @item @code{void __SMSSS (sw1, sw1)}
12779 @tab @code{__SMSSS (@var{a}, @var{b})}
12780 @tab @code{SMSSS @var{a},@var{b}}
12781 @item @code{void __SMU (sw1, sw1)}
12782 @tab @code{__SMU (@var{a}, @var{b})}
12783 @tab @code{SMU @var{a},@var{b}}
12784 @item @code{sw2 __SMUL (sw1, sw1)}
12785 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12786 @tab @code{SMUL @var{a},@var{b},@var{c}}
12787 @item @code{sw1 __SUBSS (sw1, sw1)}
12788 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12789 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12790 @item @code{uw2 __UMUL (uw1, uw1)}
12791 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12792 @tab @code{UMUL @var{a},@var{b},@var{c}}
12793 @end multitable
12794
12795 @node Directly-mapped Media Functions
12796 @subsubsection Directly-Mapped Media Functions
12797
12798 The functions listed below map directly to FR-V M-type instructions.
12799
12800 @multitable @columnfractions .45 .32 .23
12801 @item Function prototype @tab Example usage @tab Assembly output
12802 @item @code{uw1 __MABSHS (sw1)}
12803 @tab @code{@var{b} = __MABSHS (@var{a})}
12804 @tab @code{MABSHS @var{a},@var{b}}
12805 @item @code{void __MADDACCS (acc, acc)}
12806 @tab @code{__MADDACCS (@var{b}, @var{a})}
12807 @tab @code{MADDACCS @var{a},@var{b}}
12808 @item @code{sw1 __MADDHSS (sw1, sw1)}
12809 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12810 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12811 @item @code{uw1 __MADDHUS (uw1, uw1)}
12812 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12813 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12814 @item @code{uw1 __MAND (uw1, uw1)}
12815 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12816 @tab @code{MAND @var{a},@var{b},@var{c}}
12817 @item @code{void __MASACCS (acc, acc)}
12818 @tab @code{__MASACCS (@var{b}, @var{a})}
12819 @tab @code{MASACCS @var{a},@var{b}}
12820 @item @code{uw1 __MAVEH (uw1, uw1)}
12821 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12822 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12823 @item @code{uw2 __MBTOH (uw1)}
12824 @tab @code{@var{b} = __MBTOH (@var{a})}
12825 @tab @code{MBTOH @var{a},@var{b}}
12826 @item @code{void __MBTOHE (uw1 *, uw1)}
12827 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12828 @tab @code{MBTOHE @var{a},@var{b}}
12829 @item @code{void __MCLRACC (acc)}
12830 @tab @code{__MCLRACC (@var{a})}
12831 @tab @code{MCLRACC @var{a}}
12832 @item @code{void __MCLRACCA (void)}
12833 @tab @code{__MCLRACCA ()}
12834 @tab @code{MCLRACCA}
12835 @item @code{uw1 __Mcop1 (uw1, uw1)}
12836 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12837 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12838 @item @code{uw1 __Mcop2 (uw1, uw1)}
12839 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12840 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12841 @item @code{uw1 __MCPLHI (uw2, const)}
12842 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12843 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12844 @item @code{uw1 __MCPLI (uw2, const)}
12845 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12846 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12847 @item @code{void __MCPXIS (acc, sw1, sw1)}
12848 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12849 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12850 @item @code{void __MCPXIU (acc, uw1, uw1)}
12851 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12852 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12853 @item @code{void __MCPXRS (acc, sw1, sw1)}
12854 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12855 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12856 @item @code{void __MCPXRU (acc, uw1, uw1)}
12857 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12858 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12859 @item @code{uw1 __MCUT (acc, uw1)}
12860 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12861 @tab @code{MCUT @var{a},@var{b},@var{c}}
12862 @item @code{uw1 __MCUTSS (acc, sw1)}
12863 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12864 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12865 @item @code{void __MDADDACCS (acc, acc)}
12866 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12867 @tab @code{MDADDACCS @var{a},@var{b}}
12868 @item @code{void __MDASACCS (acc, acc)}
12869 @tab @code{__MDASACCS (@var{b}, @var{a})}
12870 @tab @code{MDASACCS @var{a},@var{b}}
12871 @item @code{uw2 __MDCUTSSI (acc, const)}
12872 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12873 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12874 @item @code{uw2 __MDPACKH (uw2, uw2)}
12875 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12876 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12877 @item @code{uw2 __MDROTLI (uw2, const)}
12878 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12879 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12880 @item @code{void __MDSUBACCS (acc, acc)}
12881 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12882 @tab @code{MDSUBACCS @var{a},@var{b}}
12883 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12884 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12885 @tab @code{MDUNPACKH @var{a},@var{b}}
12886 @item @code{uw2 __MEXPDHD (uw1, const)}
12887 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12888 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12889 @item @code{uw1 __MEXPDHW (uw1, const)}
12890 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12891 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12892 @item @code{uw1 __MHDSETH (uw1, const)}
12893 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12894 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12895 @item @code{sw1 __MHDSETS (const)}
12896 @tab @code{@var{b} = __MHDSETS (@var{a})}
12897 @tab @code{MHDSETS #@var{a},@var{b}}
12898 @item @code{uw1 __MHSETHIH (uw1, const)}
12899 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12900 @tab @code{MHSETHIH #@var{a},@var{b}}
12901 @item @code{sw1 __MHSETHIS (sw1, const)}
12902 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12903 @tab @code{MHSETHIS #@var{a},@var{b}}
12904 @item @code{uw1 __MHSETLOH (uw1, const)}
12905 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12906 @tab @code{MHSETLOH #@var{a},@var{b}}
12907 @item @code{sw1 __MHSETLOS (sw1, const)}
12908 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12909 @tab @code{MHSETLOS #@var{a},@var{b}}
12910 @item @code{uw1 __MHTOB (uw2)}
12911 @tab @code{@var{b} = __MHTOB (@var{a})}
12912 @tab @code{MHTOB @var{a},@var{b}}
12913 @item @code{void __MMACHS (acc, sw1, sw1)}
12914 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12915 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12916 @item @code{void __MMACHU (acc, uw1, uw1)}
12917 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12918 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12919 @item @code{void __MMRDHS (acc, sw1, sw1)}
12920 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12921 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12922 @item @code{void __MMRDHU (acc, uw1, uw1)}
12923 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12924 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12925 @item @code{void __MMULHS (acc, sw1, sw1)}
12926 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12927 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12928 @item @code{void __MMULHU (acc, uw1, uw1)}
12929 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12930 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12931 @item @code{void __MMULXHS (acc, sw1, sw1)}
12932 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12933 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12934 @item @code{void __MMULXHU (acc, uw1, uw1)}
12935 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12936 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12937 @item @code{uw1 __MNOT (uw1)}
12938 @tab @code{@var{b} = __MNOT (@var{a})}
12939 @tab @code{MNOT @var{a},@var{b}}
12940 @item @code{uw1 __MOR (uw1, uw1)}
12941 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12942 @tab @code{MOR @var{a},@var{b},@var{c}}
12943 @item @code{uw1 __MPACKH (uh, uh)}
12944 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12945 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12946 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12947 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12948 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12949 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12950 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12951 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12952 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12953 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12954 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12955 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12956 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12957 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12958 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12959 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12960 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12961 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12962 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12963 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12964 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12965 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12966 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12967 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12968 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12969 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12970 @item @code{void __MQMACHS (acc, sw2, sw2)}
12971 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12972 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12973 @item @code{void __MQMACHU (acc, uw2, uw2)}
12974 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12975 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12976 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12977 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12978 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12979 @item @code{void __MQMULHS (acc, sw2, sw2)}
12980 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12981 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12982 @item @code{void __MQMULHU (acc, uw2, uw2)}
12983 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12984 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12985 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12986 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12987 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12988 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12989 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12990 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12991 @item @code{sw2 __MQSATHS (sw2, sw2)}
12992 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12993 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12994 @item @code{uw2 __MQSLLHI (uw2, int)}
12995 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12996 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12997 @item @code{sw2 __MQSRAHI (sw2, int)}
12998 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12999 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13000 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13001 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13002 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13003 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13004 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13005 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13006 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13007 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13008 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13009 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13010 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13011 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13012 @item @code{uw1 __MRDACC (acc)}
13013 @tab @code{@var{b} = __MRDACC (@var{a})}
13014 @tab @code{MRDACC @var{a},@var{b}}
13015 @item @code{uw1 __MRDACCG (acc)}
13016 @tab @code{@var{b} = __MRDACCG (@var{a})}
13017 @tab @code{MRDACCG @var{a},@var{b}}
13018 @item @code{uw1 __MROTLI (uw1, const)}
13019 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13020 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13021 @item @code{uw1 __MROTRI (uw1, const)}
13022 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13023 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13024 @item @code{sw1 __MSATHS (sw1, sw1)}
13025 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13026 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13027 @item @code{uw1 __MSATHU (uw1, uw1)}
13028 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13029 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13030 @item @code{uw1 __MSLLHI (uw1, const)}
13031 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13032 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13033 @item @code{sw1 __MSRAHI (sw1, const)}
13034 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13035 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13036 @item @code{uw1 __MSRLHI (uw1, const)}
13037 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13038 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13039 @item @code{void __MSUBACCS (acc, acc)}
13040 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13041 @tab @code{MSUBACCS @var{a},@var{b}}
13042 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13043 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13044 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13045 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13046 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13047 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13048 @item @code{void __MTRAP (void)}
13049 @tab @code{__MTRAP ()}
13050 @tab @code{MTRAP}
13051 @item @code{uw2 __MUNPACKH (uw1)}
13052 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13053 @tab @code{MUNPACKH @var{a},@var{b}}
13054 @item @code{uw1 __MWCUT (uw2, uw1)}
13055 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13056 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13057 @item @code{void __MWTACC (acc, uw1)}
13058 @tab @code{__MWTACC (@var{b}, @var{a})}
13059 @tab @code{MWTACC @var{a},@var{b}}
13060 @item @code{void __MWTACCG (acc, uw1)}
13061 @tab @code{__MWTACCG (@var{b}, @var{a})}
13062 @tab @code{MWTACCG @var{a},@var{b}}
13063 @item @code{uw1 __MXOR (uw1, uw1)}
13064 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13065 @tab @code{MXOR @var{a},@var{b},@var{c}}
13066 @end multitable
13067
13068 @node Raw read/write Functions
13069 @subsubsection Raw Read/Write Functions
13070
13071 This sections describes built-in functions related to read and write
13072 instructions to access memory. These functions generate
13073 @code{membar} instructions to flush the I/O load and stores where
13074 appropriate, as described in Fujitsu's manual described above.
13075
13076 @table @code
13077
13078 @item unsigned char __builtin_read8 (void *@var{data})
13079 @item unsigned short __builtin_read16 (void *@var{data})
13080 @item unsigned long __builtin_read32 (void *@var{data})
13081 @item unsigned long long __builtin_read64 (void *@var{data})
13082
13083 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13084 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13085 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13086 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13087 @end table
13088
13089 @node Other Built-in Functions
13090 @subsubsection Other Built-in Functions
13091
13092 This section describes built-in functions that are not named after
13093 a specific FR-V instruction.
13094
13095 @table @code
13096 @item sw2 __IACCreadll (iacc @var{reg})
13097 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
13098 for future expansion and must be 0.
13099
13100 @item sw1 __IACCreadl (iacc @var{reg})
13101 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13102 Other values of @var{reg} are rejected as invalid.
13103
13104 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13105 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
13106 is reserved for future expansion and must be 0.
13107
13108 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13109 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13110 is 1. Other values of @var{reg} are rejected as invalid.
13111
13112 @item void __data_prefetch0 (const void *@var{x})
13113 Use the @code{dcpl} instruction to load the contents of address @var{x}
13114 into the data cache.
13115
13116 @item void __data_prefetch (const void *@var{x})
13117 Use the @code{nldub} instruction to load the contents of address @var{x}
13118 into the data cache. The instruction is issued in slot I1@.
13119 @end table
13120
13121 @node MIPS DSP Built-in Functions
13122 @subsection MIPS DSP Built-in Functions
13123
13124 The MIPS DSP Application-Specific Extension (ASE) includes new
13125 instructions that are designed to improve the performance of DSP and
13126 media applications. It provides instructions that operate on packed
13127 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13128
13129 GCC supports MIPS DSP operations using both the generic
13130 vector extensions (@pxref{Vector Extensions}) and a collection of
13131 MIPS-specific built-in functions. Both kinds of support are
13132 enabled by the @option{-mdsp} command-line option.
13133
13134 Revision 2 of the ASE was introduced in the second half of 2006.
13135 This revision adds extra instructions to the original ASE, but is
13136 otherwise backwards-compatible with it. You can select revision 2
13137 using the command-line option @option{-mdspr2}; this option implies
13138 @option{-mdsp}.
13139
13140 The SCOUNT and POS bits of the DSP control register are global. The
13141 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13142 POS bits. During optimization, the compiler does not delete these
13143 instructions and it does not delete calls to functions containing
13144 these instructions.
13145
13146 At present, GCC only provides support for operations on 32-bit
13147 vectors. The vector type associated with 8-bit integer data is
13148 usually called @code{v4i8}, the vector type associated with Q7
13149 is usually called @code{v4q7}, the vector type associated with 16-bit
13150 integer data is usually called @code{v2i16}, and the vector type
13151 associated with Q15 is usually called @code{v2q15}. They can be
13152 defined in C as follows:
13153
13154 @smallexample
13155 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13156 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13157 typedef short v2i16 __attribute__ ((vector_size(4)));
13158 typedef short v2q15 __attribute__ ((vector_size(4)));
13159 @end smallexample
13160
13161 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13162 initialized in the same way as aggregates. For example:
13163
13164 @smallexample
13165 v4i8 a = @{1, 2, 3, 4@};
13166 v4i8 b;
13167 b = (v4i8) @{5, 6, 7, 8@};
13168
13169 v2q15 c = @{0x0fcb, 0x3a75@};
13170 v2q15 d;
13171 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13172 @end smallexample
13173
13174 @emph{Note:} The CPU's endianness determines the order in which values
13175 are packed. On little-endian targets, the first value is the least
13176 significant and the last value is the most significant. The opposite
13177 order applies to big-endian targets. For example, the code above
13178 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13179 and @code{4} on big-endian targets.
13180
13181 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13182 representation. As shown in this example, the integer representation
13183 of a Q7 value can be obtained by multiplying the fractional value by
13184 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
13185 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
13186 @code{0x1.0p31}.
13187
13188 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13189 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
13190 and @code{c} and @code{d} are @code{v2q15} values.
13191
13192 @multitable @columnfractions .50 .50
13193 @item C code @tab MIPS instruction
13194 @item @code{a + b} @tab @code{addu.qb}
13195 @item @code{c + d} @tab @code{addq.ph}
13196 @item @code{a - b} @tab @code{subu.qb}
13197 @item @code{c - d} @tab @code{subq.ph}
13198 @end multitable
13199
13200 The table below lists the @code{v2i16} operation for which
13201 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
13202 @code{v2i16} values.
13203
13204 @multitable @columnfractions .50 .50
13205 @item C code @tab MIPS instruction
13206 @item @code{e * f} @tab @code{mul.ph}
13207 @end multitable
13208
13209 It is easier to describe the DSP built-in functions if we first define
13210 the following types:
13211
13212 @smallexample
13213 typedef int q31;
13214 typedef int i32;
13215 typedef unsigned int ui32;
13216 typedef long long a64;
13217 @end smallexample
13218
13219 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13220 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13221 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13222 @code{long long}, but we use @code{a64} to indicate values that are
13223 placed in one of the four DSP accumulators (@code{$ac0},
13224 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13225
13226 Also, some built-in functions prefer or require immediate numbers as
13227 parameters, because the corresponding DSP instructions accept both immediate
13228 numbers and register operands, or accept immediate numbers only. The
13229 immediate parameters are listed as follows.
13230
13231 @smallexample
13232 imm0_3: 0 to 3.
13233 imm0_7: 0 to 7.
13234 imm0_15: 0 to 15.
13235 imm0_31: 0 to 31.
13236 imm0_63: 0 to 63.
13237 imm0_255: 0 to 255.
13238 imm_n32_31: -32 to 31.
13239 imm_n512_511: -512 to 511.
13240 @end smallexample
13241
13242 The following built-in functions map directly to a particular MIPS DSP
13243 instruction. Please refer to the architecture specification
13244 for details on what each instruction does.
13245
13246 @smallexample
13247 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13248 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13249 q31 __builtin_mips_addq_s_w (q31, q31)
13250 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13251 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13252 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13253 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13254 q31 __builtin_mips_subq_s_w (q31, q31)
13255 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13256 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13257 i32 __builtin_mips_addsc (i32, i32)
13258 i32 __builtin_mips_addwc (i32, i32)
13259 i32 __builtin_mips_modsub (i32, i32)
13260 i32 __builtin_mips_raddu_w_qb (v4i8)
13261 v2q15 __builtin_mips_absq_s_ph (v2q15)
13262 q31 __builtin_mips_absq_s_w (q31)
13263 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13264 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13265 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13266 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13267 q31 __builtin_mips_preceq_w_phl (v2q15)
13268 q31 __builtin_mips_preceq_w_phr (v2q15)
13269 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13270 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13271 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13272 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13273 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13274 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13275 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13276 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13277 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13278 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13279 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13280 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13281 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13282 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13283 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13284 q31 __builtin_mips_shll_s_w (q31, i32)
13285 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13286 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13287 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13288 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13289 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13290 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13291 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13292 q31 __builtin_mips_shra_r_w (q31, i32)
13293 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13294 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13295 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13296 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13297 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13298 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13299 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13300 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13301 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13302 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13303 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13304 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13305 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13306 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13307 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13308 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13309 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13310 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13311 i32 __builtin_mips_bitrev (i32)
13312 i32 __builtin_mips_insv (i32, i32)
13313 v4i8 __builtin_mips_repl_qb (imm0_255)
13314 v4i8 __builtin_mips_repl_qb (i32)
13315 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13316 v2q15 __builtin_mips_repl_ph (i32)
13317 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13318 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13319 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13320 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13321 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13322 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13323 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13324 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13325 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13326 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13327 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13328 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13329 i32 __builtin_mips_extr_w (a64, imm0_31)
13330 i32 __builtin_mips_extr_w (a64, i32)
13331 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13332 i32 __builtin_mips_extr_s_h (a64, i32)
13333 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13334 i32 __builtin_mips_extr_rs_w (a64, i32)
13335 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13336 i32 __builtin_mips_extr_r_w (a64, i32)
13337 i32 __builtin_mips_extp (a64, imm0_31)
13338 i32 __builtin_mips_extp (a64, i32)
13339 i32 __builtin_mips_extpdp (a64, imm0_31)
13340 i32 __builtin_mips_extpdp (a64, i32)
13341 a64 __builtin_mips_shilo (a64, imm_n32_31)
13342 a64 __builtin_mips_shilo (a64, i32)
13343 a64 __builtin_mips_mthlip (a64, i32)
13344 void __builtin_mips_wrdsp (i32, imm0_63)
13345 i32 __builtin_mips_rddsp (imm0_63)
13346 i32 __builtin_mips_lbux (void *, i32)
13347 i32 __builtin_mips_lhx (void *, i32)
13348 i32 __builtin_mips_lwx (void *, i32)
13349 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13350 i32 __builtin_mips_bposge32 (void)
13351 a64 __builtin_mips_madd (a64, i32, i32);
13352 a64 __builtin_mips_maddu (a64, ui32, ui32);
13353 a64 __builtin_mips_msub (a64, i32, i32);
13354 a64 __builtin_mips_msubu (a64, ui32, ui32);
13355 a64 __builtin_mips_mult (i32, i32);
13356 a64 __builtin_mips_multu (ui32, ui32);
13357 @end smallexample
13358
13359 The following built-in functions map directly to a particular MIPS DSP REV 2
13360 instruction. Please refer to the architecture specification
13361 for details on what each instruction does.
13362
13363 @smallexample
13364 v4q7 __builtin_mips_absq_s_qb (v4q7);
13365 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13366 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13367 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13368 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13369 i32 __builtin_mips_append (i32, i32, imm0_31);
13370 i32 __builtin_mips_balign (i32, i32, imm0_3);
13371 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13372 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13373 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13374 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13375 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13376 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13377 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13378 q31 __builtin_mips_mulq_rs_w (q31, q31);
13379 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13380 q31 __builtin_mips_mulq_s_w (q31, q31);
13381 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13382 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13383 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13384 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13385 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13386 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13387 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13388 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13389 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13390 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13391 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13392 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13393 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13394 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13395 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13396 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13397 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13398 q31 __builtin_mips_addqh_w (q31, q31);
13399 q31 __builtin_mips_addqh_r_w (q31, q31);
13400 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13401 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13402 q31 __builtin_mips_subqh_w (q31, q31);
13403 q31 __builtin_mips_subqh_r_w (q31, q31);
13404 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13405 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13406 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13407 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13408 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13409 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13410 @end smallexample
13411
13412
13413 @node MIPS Paired-Single Support
13414 @subsection MIPS Paired-Single Support
13415
13416 The MIPS64 architecture includes a number of instructions that
13417 operate on pairs of single-precision floating-point values.
13418 Each pair is packed into a 64-bit floating-point register,
13419 with one element being designated the ``upper half'' and
13420 the other being designated the ``lower half''.
13421
13422 GCC supports paired-single operations using both the generic
13423 vector extensions (@pxref{Vector Extensions}) and a collection of
13424 MIPS-specific built-in functions. Both kinds of support are
13425 enabled by the @option{-mpaired-single} command-line option.
13426
13427 The vector type associated with paired-single values is usually
13428 called @code{v2sf}. It can be defined in C as follows:
13429
13430 @smallexample
13431 typedef float v2sf __attribute__ ((vector_size (8)));
13432 @end smallexample
13433
13434 @code{v2sf} values are initialized in the same way as aggregates.
13435 For example:
13436
13437 @smallexample
13438 v2sf a = @{1.5, 9.1@};
13439 v2sf b;
13440 float e, f;
13441 b = (v2sf) @{e, f@};
13442 @end smallexample
13443
13444 @emph{Note:} The CPU's endianness determines which value is stored in
13445 the upper half of a register and which value is stored in the lower half.
13446 On little-endian targets, the first value is the lower one and the second
13447 value is the upper one. The opposite order applies to big-endian targets.
13448 For example, the code above sets the lower half of @code{a} to
13449 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13450
13451 @node MIPS Loongson Built-in Functions
13452 @subsection MIPS Loongson Built-in Functions
13453
13454 GCC provides intrinsics to access the SIMD instructions provided by the
13455 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13456 available after inclusion of the @code{loongson.h} header file,
13457 operate on the following 64-bit vector types:
13458
13459 @itemize
13460 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13461 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13462 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13463 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13464 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13465 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13466 @end itemize
13467
13468 The intrinsics provided are listed below; each is named after the
13469 machine instruction to which it corresponds, with suffixes added as
13470 appropriate to distinguish intrinsics that expand to the same machine
13471 instruction yet have different argument types. Refer to the architecture
13472 documentation for a description of the functionality of each
13473 instruction.
13474
13475 @smallexample
13476 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13477 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13478 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13479 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13480 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13481 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13482 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13483 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13484 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13485 uint64_t paddd_u (uint64_t s, uint64_t t);
13486 int64_t paddd_s (int64_t s, int64_t t);
13487 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13488 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13489 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13490 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13491 uint64_t pandn_ud (uint64_t s, uint64_t t);
13492 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13493 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13494 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13495 int64_t pandn_sd (int64_t s, int64_t t);
13496 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13497 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13498 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13499 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13500 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13501 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13502 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13503 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13504 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13505 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13506 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13507 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13508 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13509 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13510 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13511 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13512 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13513 uint16x4_t pextrh_u (uint16x4_t s, int field);
13514 int16x4_t pextrh_s (int16x4_t s, int field);
13515 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13516 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13517 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13518 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13519 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13520 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13521 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13522 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13523 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13524 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13525 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13526 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13527 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13528 uint8x8_t pmovmskb_u (uint8x8_t s);
13529 int8x8_t pmovmskb_s (int8x8_t s);
13530 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13531 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13532 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13533 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13534 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13535 uint16x4_t biadd (uint8x8_t s);
13536 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13537 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13538 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13539 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13540 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13541 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13542 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13543 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13544 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13545 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13546 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13547 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13548 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13549 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13550 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13551 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13552 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13553 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13554 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13555 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13556 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13557 uint64_t psubd_u (uint64_t s, uint64_t t);
13558 int64_t psubd_s (int64_t s, int64_t t);
13559 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13560 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13561 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13562 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13563 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13564 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13565 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13566 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13567 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13568 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13569 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13570 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13571 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13572 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13573 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13574 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13575 @end smallexample
13576
13577 @menu
13578 * Paired-Single Arithmetic::
13579 * Paired-Single Built-in Functions::
13580 * MIPS-3D Built-in Functions::
13581 @end menu
13582
13583 @node Paired-Single Arithmetic
13584 @subsubsection Paired-Single Arithmetic
13585
13586 The table below lists the @code{v2sf} operations for which hardware
13587 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13588 values and @code{x} is an integral value.
13589
13590 @multitable @columnfractions .50 .50
13591 @item C code @tab MIPS instruction
13592 @item @code{a + b} @tab @code{add.ps}
13593 @item @code{a - b} @tab @code{sub.ps}
13594 @item @code{-a} @tab @code{neg.ps}
13595 @item @code{a * b} @tab @code{mul.ps}
13596 @item @code{a * b + c} @tab @code{madd.ps}
13597 @item @code{a * b - c} @tab @code{msub.ps}
13598 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13599 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13600 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13601 @end multitable
13602
13603 Note that the multiply-accumulate instructions can be disabled
13604 using the command-line option @code{-mno-fused-madd}.
13605
13606 @node Paired-Single Built-in Functions
13607 @subsubsection Paired-Single Built-in Functions
13608
13609 The following paired-single functions map directly to a particular
13610 MIPS instruction. Please refer to the architecture specification
13611 for details on what each instruction does.
13612
13613 @table @code
13614 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13615 Pair lower lower (@code{pll.ps}).
13616
13617 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13618 Pair upper lower (@code{pul.ps}).
13619
13620 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13621 Pair lower upper (@code{plu.ps}).
13622
13623 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13624 Pair upper upper (@code{puu.ps}).
13625
13626 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13627 Convert pair to paired single (@code{cvt.ps.s}).
13628
13629 @item float __builtin_mips_cvt_s_pl (v2sf)
13630 Convert pair lower to single (@code{cvt.s.pl}).
13631
13632 @item float __builtin_mips_cvt_s_pu (v2sf)
13633 Convert pair upper to single (@code{cvt.s.pu}).
13634
13635 @item v2sf __builtin_mips_abs_ps (v2sf)
13636 Absolute value (@code{abs.ps}).
13637
13638 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13639 Align variable (@code{alnv.ps}).
13640
13641 @emph{Note:} The value of the third parameter must be 0 or 4
13642 modulo 8, otherwise the result is unpredictable. Please read the
13643 instruction description for details.
13644 @end table
13645
13646 The following multi-instruction functions are also available.
13647 In each case, @var{cond} can be any of the 16 floating-point conditions:
13648 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13649 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13650 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13651
13652 @table @code
13653 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13654 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13655 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13656 @code{movt.ps}/@code{movf.ps}).
13657
13658 The @code{movt} functions return the value @var{x} computed by:
13659
13660 @smallexample
13661 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13662 mov.ps @var{x},@var{c}
13663 movt.ps @var{x},@var{d},@var{cc}
13664 @end smallexample
13665
13666 The @code{movf} functions are similar but use @code{movf.ps} instead
13667 of @code{movt.ps}.
13668
13669 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13670 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13671 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13672 @code{bc1t}/@code{bc1f}).
13673
13674 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13675 and return either the upper or lower half of the result. For example:
13676
13677 @smallexample
13678 v2sf a, b;
13679 if (__builtin_mips_upper_c_eq_ps (a, b))
13680 upper_halves_are_equal ();
13681 else
13682 upper_halves_are_unequal ();
13683
13684 if (__builtin_mips_lower_c_eq_ps (a, b))
13685 lower_halves_are_equal ();
13686 else
13687 lower_halves_are_unequal ();
13688 @end smallexample
13689 @end table
13690
13691 @node MIPS-3D Built-in Functions
13692 @subsubsection MIPS-3D Built-in Functions
13693
13694 The MIPS-3D Application-Specific Extension (ASE) includes additional
13695 paired-single instructions that are designed to improve the performance
13696 of 3D graphics operations. Support for these instructions is controlled
13697 by the @option{-mips3d} command-line option.
13698
13699 The functions listed below map directly to a particular MIPS-3D
13700 instruction. Please refer to the architecture specification for
13701 more details on what each instruction does.
13702
13703 @table @code
13704 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13705 Reduction add (@code{addr.ps}).
13706
13707 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13708 Reduction multiply (@code{mulr.ps}).
13709
13710 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13711 Convert paired single to paired word (@code{cvt.pw.ps}).
13712
13713 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13714 Convert paired word to paired single (@code{cvt.ps.pw}).
13715
13716 @item float __builtin_mips_recip1_s (float)
13717 @itemx double __builtin_mips_recip1_d (double)
13718 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13719 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13720
13721 @item float __builtin_mips_recip2_s (float, float)
13722 @itemx double __builtin_mips_recip2_d (double, double)
13723 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13724 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13725
13726 @item float __builtin_mips_rsqrt1_s (float)
13727 @itemx double __builtin_mips_rsqrt1_d (double)
13728 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13729 Reduced-precision reciprocal square root (sequence step 1)
13730 (@code{rsqrt1.@var{fmt}}).
13731
13732 @item float __builtin_mips_rsqrt2_s (float, float)
13733 @itemx double __builtin_mips_rsqrt2_d (double, double)
13734 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13735 Reduced-precision reciprocal square root (sequence step 2)
13736 (@code{rsqrt2.@var{fmt}}).
13737 @end table
13738
13739 The following multi-instruction functions are also available.
13740 In each case, @var{cond} can be any of the 16 floating-point conditions:
13741 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13742 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13743 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13744
13745 @table @code
13746 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13747 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13748 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13749 @code{bc1t}/@code{bc1f}).
13750
13751 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13752 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13753 For example:
13754
13755 @smallexample
13756 float a, b;
13757 if (__builtin_mips_cabs_eq_s (a, b))
13758 true ();
13759 else
13760 false ();
13761 @end smallexample
13762
13763 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13764 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13765 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13766 @code{bc1t}/@code{bc1f}).
13767
13768 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13769 and return either the upper or lower half of the result. For example:
13770
13771 @smallexample
13772 v2sf a, b;
13773 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13774 upper_halves_are_equal ();
13775 else
13776 upper_halves_are_unequal ();
13777
13778 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13779 lower_halves_are_equal ();
13780 else
13781 lower_halves_are_unequal ();
13782 @end smallexample
13783
13784 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13785 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13786 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13787 @code{movt.ps}/@code{movf.ps}).
13788
13789 The @code{movt} functions return the value @var{x} computed by:
13790
13791 @smallexample
13792 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13793 mov.ps @var{x},@var{c}
13794 movt.ps @var{x},@var{d},@var{cc}
13795 @end smallexample
13796
13797 The @code{movf} functions are similar but use @code{movf.ps} instead
13798 of @code{movt.ps}.
13799
13800 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13801 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13802 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13803 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13804 Comparison of two paired-single values
13805 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13806 @code{bc1any2t}/@code{bc1any2f}).
13807
13808 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13809 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13810 result is true and the @code{all} forms return true if both results are true.
13811 For example:
13812
13813 @smallexample
13814 v2sf a, b;
13815 if (__builtin_mips_any_c_eq_ps (a, b))
13816 one_is_true ();
13817 else
13818 both_are_false ();
13819
13820 if (__builtin_mips_all_c_eq_ps (a, b))
13821 both_are_true ();
13822 else
13823 one_is_false ();
13824 @end smallexample
13825
13826 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13827 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13828 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13829 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13830 Comparison of four paired-single values
13831 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13832 @code{bc1any4t}/@code{bc1any4f}).
13833
13834 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13835 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13836 The @code{any} forms return true if any of the four results are true
13837 and the @code{all} forms return true if all four results are true.
13838 For example:
13839
13840 @smallexample
13841 v2sf a, b, c, d;
13842 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13843 some_are_true ();
13844 else
13845 all_are_false ();
13846
13847 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13848 all_are_true ();
13849 else
13850 some_are_false ();
13851 @end smallexample
13852 @end table
13853
13854 @node MIPS SIMD Architecture (MSA) Support
13855 @subsection MIPS SIMD Architecture (MSA) Support
13856
13857 @menu
13858 * MIPS SIMD Architecture Built-in Functions::
13859 @end menu
13860
13861 GCC provides intrinsics to access the SIMD instructions provided by the
13862 MSA MIPS SIMD Architecture. The interface is made available by including
13863 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13864 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13865 @code{__msa_*}.
13866
13867 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13868 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13869 data elements. The following vectors typedefs are included in @code{msa.h}:
13870 @itemize
13871 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
13872 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
13873 @item @code{v8i16}, a vector of eight signed 16-bit integers;
13874 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
13875 @item @code{v4i32}, a vector of four signed 32-bit integers;
13876 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
13877 @item @code{v2i64}, a vector of two signed 64-bit integers;
13878 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
13879 @item @code{v4f32}, a vector of four 32-bit floats;
13880 @item @code{v2f64}, a vector of two 64-bit doubles.
13881 @end itemize
13882
13883 Intructions and corresponding built-ins may have additional restrictions and/or
13884 input/output values manipulated:
13885 @itemize
13886 @item @code{imm0_1}, an integer literal in range 0 to 1;
13887 @item @code{imm0_3}, an integer literal in range 0 to 3;
13888 @item @code{imm0_7}, an integer literal in range 0 to 7;
13889 @item @code{imm0_15}, an integer literal in range 0 to 15;
13890 @item @code{imm0_31}, an integer literal in range 0 to 31;
13891 @item @code{imm0_63}, an integer literal in range 0 to 63;
13892 @item @code{imm0_255}, an integer literal in range 0 to 255;
13893 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
13894 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
13895 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
13896 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
13897 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
13898 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
13899 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
13900 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
13901 @item @code{imm1_4}, an integer literal in range 1 to 4;
13902 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
13903 @end itemize
13904
13905 @smallexample
13906 @{
13907 typedef int i32;
13908 #if __LONG_MAX__ == __LONG_LONG_MAX__
13909 typedef long i64;
13910 #else
13911 typedef long long i64;
13912 #endif
13913
13914 typedef unsigned int u32;
13915 #if __LONG_MAX__ == __LONG_LONG_MAX__
13916 typedef unsigned long u64;
13917 #else
13918 typedef unsigned long long u64;
13919 #endif
13920
13921 typedef double f64;
13922 typedef float f32;
13923 @}
13924 @end smallexample
13925
13926 @node MIPS SIMD Architecture Built-in Functions
13927 @subsubsection MIPS SIMD Architecture Built-in Functions
13928
13929 The intrinsics provided are listed below; each is named after the
13930 machine instruction.
13931
13932 @smallexample
13933 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
13934 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
13935 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
13936 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
13937
13938 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
13939 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
13940 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
13941 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
13942
13943 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
13944 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
13945 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
13946 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
13947
13948 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
13949 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
13950 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
13951 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
13952
13953 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
13954 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
13955 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
13956 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
13957
13958 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
13959 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
13960 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
13961 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
13962
13963 v16u8 __builtin_msa_and_v (v16u8, v16u8);
13964
13965 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
13966
13967 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
13968 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
13969 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
13970 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
13971
13972 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
13973 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
13974 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
13975 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
13976
13977 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
13978 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
13979 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
13980 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
13981
13982 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
13983 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
13984 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
13985 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
13986
13987 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
13988 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
13989 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
13990 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
13991
13992 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
13993 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
13994 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
13995 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
13996
13997 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
13998 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
13999 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14000 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14001
14002 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14003 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14004 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14005 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14006
14007 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14008 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14009 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14010 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14011
14012 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14013 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14014 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14015 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14016
14017 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14018 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14019 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14020 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14021
14022 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14023 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14024 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14025 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14026
14027 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14028
14029 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14030
14031 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14032
14033 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14034
14035 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14036 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14037 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14038 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14039
14040 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14041 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14042 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14043 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14044
14045 i32 __builtin_msa_bnz_b (v16u8);
14046 i32 __builtin_msa_bnz_h (v8u16);
14047 i32 __builtin_msa_bnz_w (v4u32);
14048 i32 __builtin_msa_bnz_d (v2u64);
14049
14050 i32 __builtin_msa_bnz_v (v16u8);
14051
14052 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14053
14054 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14055
14056 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14057 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14058 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14059 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14060
14061 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14062 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14063 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14064 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14065
14066 i32 __builtin_msa_bz_b (v16u8);
14067 i32 __builtin_msa_bz_h (v8u16);
14068 i32 __builtin_msa_bz_w (v4u32);
14069 i32 __builtin_msa_bz_d (v2u64);
14070
14071 i32 __builtin_msa_bz_v (v16u8);
14072
14073 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14074 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14075 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14076 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14077
14078 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14079 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14080 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14081 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14082
14083 i32 __builtin_msa_cfcmsa (imm0_31);
14084
14085 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14086 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14087 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14088 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14089
14090 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14091 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14092 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14093 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14094
14095 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14096 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14097 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14098 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14099
14100 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14101 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14102 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14103 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14104
14105 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14106 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14107 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14108 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14109
14110 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14111 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14112 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14113 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14114
14115 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14116 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14117 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14118 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14119
14120 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14121 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14122 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14123 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14124
14125 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14126 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14127 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14128 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14129
14130 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14131 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14132 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14133 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14134
14135 void __builtin_msa_ctcmsa (imm0_31, i32);
14136
14137 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14138 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14139 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14140 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14141
14142 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14143 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14144 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14145 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14146
14147 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14148 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14149 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14150
14151 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14152 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14153 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14154
14155 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14156 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14157 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14158
14159 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14160 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14161 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14162
14163 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14164 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14165 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14166
14167 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14168 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14169 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14170
14171 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14172 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14173
14174 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14175 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14176
14177 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14178 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14179
14180 v4i32 __builtin_msa_fclass_w (v4f32);
14181 v2i64 __builtin_msa_fclass_d (v2f64);
14182
14183 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14184 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14185
14186 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14187 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14188
14189 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14190 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14191
14192 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14193 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14194
14195 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14196 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14197
14198 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14199 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14200
14201 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14202 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14203
14204 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14205 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14206
14207 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14208 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14209
14210 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14211 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14212
14213 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14214 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14215
14216 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14217 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14218
14219 v4f32 __builtin_msa_fexupl_w (v8i16);
14220 v2f64 __builtin_msa_fexupl_d (v4f32);
14221
14222 v4f32 __builtin_msa_fexupr_w (v8i16);
14223 v2f64 __builtin_msa_fexupr_d (v4f32);
14224
14225 v4f32 __builtin_msa_ffint_s_w (v4i32);
14226 v2f64 __builtin_msa_ffint_s_d (v2i64);
14227
14228 v4f32 __builtin_msa_ffint_u_w (v4u32);
14229 v2f64 __builtin_msa_ffint_u_d (v2u64);
14230
14231 v4f32 __builtin_msa_ffql_w (v8i16);
14232 v2f64 __builtin_msa_ffql_d (v4i32);
14233
14234 v4f32 __builtin_msa_ffqr_w (v8i16);
14235 v2f64 __builtin_msa_ffqr_d (v4i32);
14236
14237 v16i8 __builtin_msa_fill_b (i32);
14238 v8i16 __builtin_msa_fill_h (i32);
14239 v4i32 __builtin_msa_fill_w (i32);
14240 v2i64 __builtin_msa_fill_d (i64);
14241
14242 v4f32 __builtin_msa_flog2_w (v4f32);
14243 v2f64 __builtin_msa_flog2_d (v2f64);
14244
14245 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14246 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14247
14248 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14249 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14250
14251 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14252 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14253
14254 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14255 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14256
14257 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14258 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14259
14260 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14261 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14262
14263 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14264 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14265
14266 v4f32 __builtin_msa_frint_w (v4f32);
14267 v2f64 __builtin_msa_frint_d (v2f64);
14268
14269 v4f32 __builtin_msa_frcp_w (v4f32);
14270 v2f64 __builtin_msa_frcp_d (v2f64);
14271
14272 v4f32 __builtin_msa_frsqrt_w (v4f32);
14273 v2f64 __builtin_msa_frsqrt_d (v2f64);
14274
14275 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14276 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14277
14278 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14279 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14280
14281 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14282 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14283
14284 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14285 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14286
14287 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14288 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14289
14290 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14291 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14292
14293 v4f32 __builtin_msa_fsqrt_w (v4f32);
14294 v2f64 __builtin_msa_fsqrt_d (v2f64);
14295
14296 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14297 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14298
14299 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14300 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14301
14302 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14303 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14304
14305 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14306 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14307
14308 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14309 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14310
14311 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14312 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14313
14314 v4i32 __builtin_msa_ftint_s_w (v4f32);
14315 v2i64 __builtin_msa_ftint_s_d (v2f64);
14316
14317 v4u32 __builtin_msa_ftint_u_w (v4f32);
14318 v2u64 __builtin_msa_ftint_u_d (v2f64);
14319
14320 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14321 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14322
14323 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14324 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14325
14326 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14327 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14328
14329 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14330 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14331 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14332
14333 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14334 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14335 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14336
14337 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14338 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14339 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14340
14341 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14342 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14343 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14344
14345 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14346 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14347 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14348 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14349
14350 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14351 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14352 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14353 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14354
14355 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14356 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14357 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14358 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14359
14360 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14361 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14362 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14363 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14364
14365 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14366 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14367 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14368 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14369
14370 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14371 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14372 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14373 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14374
14375 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14376 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14377 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14378 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14379
14380 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14381 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14382 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14383 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14384
14385 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14386 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14387
14388 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14389 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14390
14391 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14392 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14393 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14394 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14395
14396 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14397 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14398 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14399 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14400
14401 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14402 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14403 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14404 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14405
14406 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14407 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14408 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14409 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14410
14411 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14412 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14413 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14414 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14415
14416 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14417 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14418 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14419 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14420
14421 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14422 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14423 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14424 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14425
14426 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14427 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14428 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14429 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14430
14431 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14432 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14433 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14434 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14435
14436 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14437 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14438 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14439 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14440
14441 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14442 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14443 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14444 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14445
14446 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14447 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14448 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14449 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14450
14451 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14452 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14453 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14454 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14455
14456 v16i8 __builtin_msa_move_v (v16i8);
14457
14458 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14459 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14460
14461 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14462 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14463
14464 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14465 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14466 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14467 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14468
14469 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14470 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14471
14472 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14473 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14474
14475 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14476 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14477 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14478 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14479
14480 v16i8 __builtin_msa_nloc_b (v16i8);
14481 v8i16 __builtin_msa_nloc_h (v8i16);
14482 v4i32 __builtin_msa_nloc_w (v4i32);
14483 v2i64 __builtin_msa_nloc_d (v2i64);
14484
14485 v16i8 __builtin_msa_nlzc_b (v16i8);
14486 v8i16 __builtin_msa_nlzc_h (v8i16);
14487 v4i32 __builtin_msa_nlzc_w (v4i32);
14488 v2i64 __builtin_msa_nlzc_d (v2i64);
14489
14490 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14491
14492 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14493
14494 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14495
14496 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14497
14498 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14499 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14500 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14501 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14502
14503 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14504 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14505 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14506 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14507
14508 v16i8 __builtin_msa_pcnt_b (v16i8);
14509 v8i16 __builtin_msa_pcnt_h (v8i16);
14510 v4i32 __builtin_msa_pcnt_w (v4i32);
14511 v2i64 __builtin_msa_pcnt_d (v2i64);
14512
14513 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14514 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14515 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14516 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14517
14518 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14519 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14520 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14521 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14522
14523 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14524 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14525 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14526
14527 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14528 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14529 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14530 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14531
14532 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14533 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14534 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14535 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14536
14537 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14538 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14539 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14540 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14541
14542 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14543 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14544 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14545 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14546
14547 v16i8 __builtin_msa_splat_b (v16i8, i32);
14548 v8i16 __builtin_msa_splat_h (v8i16, i32);
14549 v4i32 __builtin_msa_splat_w (v4i32, i32);
14550 v2i64 __builtin_msa_splat_d (v2i64, i32);
14551
14552 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14553 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14554 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14555 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14556
14557 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14558 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14559 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14560 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14561
14562 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14563 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14564 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14565 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14566
14567 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14568 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14569 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14570 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14571
14572 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14573 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14574 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14575 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14576
14577 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14578 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14579 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14580 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14581
14582 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14583 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14584 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14585 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14586
14587 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14588 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14589 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14590 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14591
14592 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14593 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14594 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14595 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14596
14597 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14598 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14599 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14600 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14601
14602 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14603 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14604 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14605 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14606
14607 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14608 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14609 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14610 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14611
14612 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14613 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14614 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14615 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14616
14617 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14618 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14619 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14620 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14621
14622 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14623 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14624 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14625 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14626
14627 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14628 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14629 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14630 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14631
14632 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14633 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14634 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14635 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14636
14637 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14638
14639 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14640 @end smallexample
14641
14642 @node Other MIPS Built-in Functions
14643 @subsection Other MIPS Built-in Functions
14644
14645 GCC provides other MIPS-specific built-in functions:
14646
14647 @table @code
14648 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14649 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14650 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14651 when this function is available.
14652
14653 @item unsigned int __builtin_mips_get_fcsr (void)
14654 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14655 Get and set the contents of the floating-point control and status register
14656 (FPU control register 31). These functions are only available in hard-float
14657 code but can be called in both MIPS16 and non-MIPS16 contexts.
14658
14659 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14660 register except the condition codes, which GCC assumes are preserved.
14661 @end table
14662
14663 @node MSP430 Built-in Functions
14664 @subsection MSP430 Built-in Functions
14665
14666 GCC provides a couple of special builtin functions to aid in the
14667 writing of interrupt handlers in C.
14668
14669 @table @code
14670 @item __bic_SR_register_on_exit (int @var{mask})
14671 This clears the indicated bits in the saved copy of the status register
14672 currently residing on the stack. This only works inside interrupt
14673 handlers and the changes to the status register will only take affect
14674 once the handler returns.
14675
14676 @item __bis_SR_register_on_exit (int @var{mask})
14677 This sets the indicated bits in the saved copy of the status register
14678 currently residing on the stack. This only works inside interrupt
14679 handlers and the changes to the status register will only take affect
14680 once the handler returns.
14681
14682 @item __delay_cycles (long long @var{cycles})
14683 This inserts an instruction sequence that takes exactly @var{cycles}
14684 cycles (between 0 and about 17E9) to complete. The inserted sequence
14685 may use jumps, loops, or no-ops, and does not interfere with any other
14686 instructions. Note that @var{cycles} must be a compile-time constant
14687 integer - that is, you must pass a number, not a variable that may be
14688 optimized to a constant later. The number of cycles delayed by this
14689 builtin is exact.
14690 @end table
14691
14692 @node NDS32 Built-in Functions
14693 @subsection NDS32 Built-in Functions
14694
14695 These built-in functions are available for the NDS32 target:
14696
14697 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14698 Insert an ISYNC instruction into the instruction stream where
14699 @var{addr} is an instruction address for serialization.
14700 @end deftypefn
14701
14702 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14703 Insert an ISB instruction into the instruction stream.
14704 @end deftypefn
14705
14706 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14707 Return the content of a system register which is mapped by @var{sr}.
14708 @end deftypefn
14709
14710 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14711 Return the content of a user space register which is mapped by @var{usr}.
14712 @end deftypefn
14713
14714 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14715 Move the @var{value} to a system register which is mapped by @var{sr}.
14716 @end deftypefn
14717
14718 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14719 Move the @var{value} to a user space register which is mapped by @var{usr}.
14720 @end deftypefn
14721
14722 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14723 Enable global interrupt.
14724 @end deftypefn
14725
14726 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14727 Disable global interrupt.
14728 @end deftypefn
14729
14730 @node picoChip Built-in Functions
14731 @subsection picoChip Built-in Functions
14732
14733 GCC provides an interface to selected machine instructions from the
14734 picoChip instruction set.
14735
14736 @table @code
14737 @item int __builtin_sbc (int @var{value})
14738 Sign bit count. Return the number of consecutive bits in @var{value}
14739 that have the same value as the sign bit. The result is the number of
14740 leading sign bits minus one, giving the number of redundant sign bits in
14741 @var{value}.
14742
14743 @item int __builtin_byteswap (int @var{value})
14744 Byte swap. Return the result of swapping the upper and lower bytes of
14745 @var{value}.
14746
14747 @item int __builtin_brev (int @var{value})
14748 Bit reversal. Return the result of reversing the bits in
14749 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14750 and so on.
14751
14752 @item int __builtin_adds (int @var{x}, int @var{y})
14753 Saturating addition. Return the result of adding @var{x} and @var{y},
14754 storing the value 32767 if the result overflows.
14755
14756 @item int __builtin_subs (int @var{x}, int @var{y})
14757 Saturating subtraction. Return the result of subtracting @var{y} from
14758 @var{x}, storing the value @minus{}32768 if the result overflows.
14759
14760 @item void __builtin_halt (void)
14761 Halt. The processor stops execution. This built-in is useful for
14762 implementing assertions.
14763
14764 @end table
14765
14766 @node PowerPC Built-in Functions
14767 @subsection PowerPC Built-in Functions
14768
14769 The following built-in functions are always available and can be used to
14770 check the PowerPC target platform type:
14771
14772 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14773 This function is a @code{nop} on the PowerPC platform and is included solely
14774 to maintain API compatibility with the x86 builtins.
14775 @end deftypefn
14776
14777 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14778 This function returns a value of @code{1} if the run-time CPU is of type
14779 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14780 detected:
14781
14782 @table @samp
14783 @item power9
14784 IBM POWER9 Server CPU.
14785 @item power8
14786 IBM POWER8 Server CPU.
14787 @item power7
14788 IBM POWER7 Server CPU.
14789 @item power6x
14790 IBM POWER6 Server CPU (RAW mode).
14791 @item power6
14792 IBM POWER6 Server CPU (Architected mode).
14793 @item power5+
14794 IBM POWER5+ Server CPU.
14795 @item power5
14796 IBM POWER5 Server CPU.
14797 @item ppc970
14798 IBM 970 Server CPU (ie, Apple G5).
14799 @item power4
14800 IBM POWER4 Server CPU.
14801 @item ppca2
14802 IBM A2 64-bit Embedded CPU
14803 @item ppc476
14804 IBM PowerPC 476FP 32-bit Embedded CPU.
14805 @item ppc464
14806 IBM PowerPC 464 32-bit Embedded CPU.
14807 @item ppc440
14808 PowerPC 440 32-bit Embedded CPU.
14809 @item ppc405
14810 PowerPC 405 32-bit Embedded CPU.
14811 @item ppc-cell-be
14812 IBM PowerPC Cell Broadband Engine Architecture CPU.
14813 @end table
14814
14815 Here is an example:
14816 @smallexample
14817 if (__builtin_cpu_is ("power8"))
14818 @{
14819 do_power8 (); // POWER8 specific implementation.
14820 @}
14821 else
14822 @{
14823 do_generic (); // Generic implementation.
14824 @}
14825 @end smallexample
14826 @end deftypefn
14827
14828 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14829 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14830 feature @var{feature} and returns @code{0} otherwise. The following features can be
14831 detected:
14832
14833 @table @samp
14834 @item 4xxmac
14835 4xx CPU has a Multiply Accumulator.
14836 @item altivec
14837 CPU has a SIMD/Vector Unit.
14838 @item arch_2_05
14839 CPU supports ISA 2.05 (eg, POWER6)
14840 @item arch_2_06
14841 CPU supports ISA 2.06 (eg, POWER7)
14842 @item arch_2_07
14843 CPU supports ISA 2.07 (eg, POWER8)
14844 @item arch_3_00
14845 CPU supports ISA 3.0 (eg, POWER9)
14846 @item archpmu
14847 CPU supports the set of compatible performance monitoring events.
14848 @item booke
14849 CPU supports the Embedded ISA category.
14850 @item cellbe
14851 CPU has a CELL broadband engine.
14852 @item dfp
14853 CPU has a decimal floating point unit.
14854 @item dscr
14855 CPU supports the data stream control register.
14856 @item ebb
14857 CPU supports event base branching.
14858 @item efpdouble
14859 CPU has a SPE double precision floating point unit.
14860 @item efpsingle
14861 CPU has a SPE single precision floating point unit.
14862 @item fpu
14863 CPU has a floating point unit.
14864 @item htm
14865 CPU has hardware transaction memory instructions.
14866 @item htm-nosc
14867 Kernel aborts hardware transactions when a syscall is made.
14868 @item ic_snoop
14869 CPU supports icache snooping capabilities.
14870 @item ieee128
14871 CPU supports 128-bit IEEE binary floating point instructions.
14872 @item isel
14873 CPU supports the integer select instruction.
14874 @item mmu
14875 CPU has a memory management unit.
14876 @item notb
14877 CPU does not have a timebase (eg, 601 and 403gx).
14878 @item pa6t
14879 CPU supports the PA Semi 6T CORE ISA.
14880 @item power4
14881 CPU supports ISA 2.00 (eg, POWER4)
14882 @item power5
14883 CPU supports ISA 2.02 (eg, POWER5)
14884 @item power5+
14885 CPU supports ISA 2.03 (eg, POWER5+)
14886 @item power6x
14887 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
14888 @item ppc32
14889 CPU supports 32-bit mode execution.
14890 @item ppc601
14891 CPU supports the old POWER ISA (eg, 601)
14892 @item ppc64
14893 CPU supports 64-bit mode execution.
14894 @item ppcle
14895 CPU supports a little-endian mode that uses address swizzling.
14896 @item smt
14897 CPU support simultaneous multi-threading.
14898 @item spe
14899 CPU has a signal processing extension unit.
14900 @item tar
14901 CPU supports the target address register.
14902 @item true_le
14903 CPU supports true little-endian mode.
14904 @item ucache
14905 CPU has unified I/D cache.
14906 @item vcrypto
14907 CPU supports the vector cryptography instructions.
14908 @item vsx
14909 CPU supports the vector-scalar extension.
14910 @end table
14911
14912 Here is an example:
14913 @smallexample
14914 if (__builtin_cpu_supports ("fpu"))
14915 @{
14916 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
14917 @}
14918 else
14919 @{
14920 dst = __fadd (src1, src2); // Software FP addition function.
14921 @}
14922 @end smallexample
14923 @end deftypefn
14924
14925 These built-in functions are available for the PowerPC family of
14926 processors:
14927 @smallexample
14928 float __builtin_recipdivf (float, float);
14929 float __builtin_rsqrtf (float);
14930 double __builtin_recipdiv (double, double);
14931 double __builtin_rsqrt (double);
14932 uint64_t __builtin_ppc_get_timebase ();
14933 unsigned long __builtin_ppc_mftb ();
14934 double __builtin_unpack_longdouble (long double, int);
14935 long double __builtin_pack_longdouble (double, double);
14936 @end smallexample
14937
14938 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
14939 @code{__builtin_rsqrtf} functions generate multiple instructions to
14940 implement the reciprocal sqrt functionality using reciprocal sqrt
14941 estimate instructions.
14942
14943 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
14944 functions generate multiple instructions to implement division using
14945 the reciprocal estimate instructions.
14946
14947 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
14948 functions generate instructions to read the Time Base Register. The
14949 @code{__builtin_ppc_get_timebase} function may generate multiple
14950 instructions and always returns the 64 bits of the Time Base Register.
14951 The @code{__builtin_ppc_mftb} function always generates one instruction and
14952 returns the Time Base Register value as an unsigned long, throwing away
14953 the most significant word on 32-bit environments.
14954
14955 Additional built-in functions are available for the 64-bit PowerPC
14956 family of processors, for efficient use of 128-bit floating point
14957 (@code{__float128}) values.
14958
14959 The following floating-point built-in functions are available with
14960 @code{-mfloat128} and Altivec support. All of them implement the
14961 function that is part of the name.
14962
14963 @smallexample
14964 __float128 __builtin_fabsq (__float128)
14965 __float128 __builtin_copysignq (__float128, __float128)
14966 @end smallexample
14967
14968 The following built-in functions are available with @code{-mfloat128}
14969 and Altivec support.
14970
14971 @table @code
14972 @item __float128 __builtin_infq (void)
14973 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
14974 @findex __builtin_infq
14975
14976 @item __float128 __builtin_huge_valq (void)
14977 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
14978 @findex __builtin_huge_valq
14979
14980 @item __float128 __builtin_nanq (void)
14981 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
14982 @findex __builtin_nanq
14983
14984 @item __float128 __builtin_nansq (void)
14985 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
14986 @findex __builtin_nansq
14987 @end table
14988
14989 The following built-in functions are available for the PowerPC family
14990 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
14991 or @option{-mpopcntd}):
14992 @smallexample
14993 long __builtin_bpermd (long, long);
14994 int __builtin_divwe (int, int);
14995 int __builtin_divweo (int, int);
14996 unsigned int __builtin_divweu (unsigned int, unsigned int);
14997 unsigned int __builtin_divweuo (unsigned int, unsigned int);
14998 long __builtin_divde (long, long);
14999 long __builtin_divdeo (long, long);
15000 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15001 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15002 unsigned int cdtbcd (unsigned int);
15003 unsigned int cbcdtd (unsigned int);
15004 unsigned int addg6s (unsigned int, unsigned int);
15005 @end smallexample
15006
15007 The @code{__builtin_divde}, @code{__builtin_divdeo},
15008 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15009 64-bit environment support ISA 2.06 or later.
15010
15011 The following built-in functions are available for the PowerPC family
15012 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15013 @smallexample
15014 long long __builtin_darn (void);
15015 long long __builtin_darn_raw (void);
15016 int __builtin_darn_32 (void);
15017
15018 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15019 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15020 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15021 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15022
15023 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15024 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15025 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15026 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15027
15028 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15029 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15030 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15031 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15032
15033 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15034 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15035 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15036 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15037
15038 unsigned int scalar_extract_exp (double source);
15039 unsigned long long int scalar_extract_sig (double source);
15040
15041 double
15042 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15043
15044 int scalar_cmp_exp_gt (double arg1, double arg2);
15045 int scalar_cmp_exp_lt (double arg1, double arg2);
15046 int scalar_cmp_exp_eq (double arg1, double arg2);
15047 int scalar_cmp_exp_unordered (double arg1, double arg2);
15048
15049 int scalar_test_data_class (float source, unsigned int condition);
15050 int scalar_test_data_class (double source, unsigned int condition);
15051
15052 int scalar_test_neg (float source);
15053 int scalar_test_neg (double source);
15054 @end smallexample
15055
15056 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15057 functions require a
15058 64-bit environment supporting ISA 3.0 or later.
15059 The @code{__builtin_darn} function provides a 64-bit conditioned
15060 random number. The @code{__builtin_darn_raw} function provides a
15061 64-bit raw random number. The @code{__builtin_darn_32} function
15062 provides a 32-bit random number.
15063
15064 The @code{scalar_extract_sig} and @code{scalar_insert_exp}
15065 functions require a 64-bit environment supporting ISA 3.0 or later.
15066 The @code{scalar_extract_exp} and @code{vec_extract_sig} built-in
15067 functions return the significand and exponent respectively of their
15068 @code{source} arguments. The
15069 @code{scalar_insert_exp} built-in function returns a double-precision
15070 floating point value that is constructed by assembling the values of its
15071 @code{significand} and @code{exponent} arguments. The sign of the
15072 result is copied from the most significant bit of the
15073 @code{significand} argument. The significand and exponent components
15074 of the result are composed of the least significant 11 bits of the
15075 @code{significand} argument and the least significant 52 bits of the
15076 @code{exponent} argument.
15077
15078 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15079 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15080 functions return a non-zero value if @code{arg1} is greater than, less
15081 than, equal to, or not comparable to @code{arg2} respectively. The
15082 arguments are not comparable if one or the other equals NaN (not a
15083 number).
15084
15085 The @code{scalar_test_data_class} built-in functions return a non-zero
15086 value if any of the condition tests enabled by the value of the
15087 @code{condition} variable are true. The
15088 @code{condition} argument must be an unsigned integer with value not
15089 exceeding 127. The
15090 @code{condition} argument is encoded as a bitmask with each bit
15091 enabling the testing of a different condition, as characterized by the
15092 following:
15093 @smallexample
15094 0x40 Test for NaN
15095 0x20 Test for +Infinity
15096 0x10 Test for -Infinity
15097 0x08 Test for +Zero
15098 0x04 Test for -Zero
15099 0x02 Test for +Denormal
15100 0x01 Test for -Denormal
15101 @end smallexample
15102
15103 If all of the enabled test conditions are false, the return value is 0.
15104
15105 The @code{scalar_test_neg} built-in functions return a non-zero value
15106 if their @code{source} argument holds a negative value.
15107
15108 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15109 if and only if the number of signficant digits of its @code{value} argument
15110 is less than its @code{comparison} argument. The
15111 @code{__builtin_dfp_dtstsfi_lt_dd} and
15112 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15113 require that the type of the @code{value} argument be
15114 @code{__Decimal64} and @code{__Decimal128} respectively.
15115
15116 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15117 if and only if the number of signficant digits of its @code{value} argument
15118 is greater than its @code{comparison} argument. The
15119 @code{__builtin_dfp_dtstsfi_gt_dd} and
15120 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15121 require that the type of the @code{value} argument be
15122 @code{__Decimal64} and @code{__Decimal128} respectively.
15123
15124 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15125 if and only if the number of signficant digits of its @code{value} argument
15126 equals its @code{comparison} argument. The
15127 @code{__builtin_dfp_dtstsfi_eq_dd} and
15128 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15129 require that the type of the @code{value} argument be
15130 @code{__Decimal64} and @code{__Decimal128} respectively.
15131
15132 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15133 if and only if its @code{value} argument has an undefined number of
15134 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15135 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15136 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15137 require that the type of the @code{value} argument be
15138 @code{__Decimal64} and @code{__Decimal128} respectively.
15139
15140 The following built-in functions are available for the PowerPC family
15141 of processors when hardware decimal floating point
15142 (@option{-mhard-dfp}) is available:
15143 @smallexample
15144 _Decimal64 __builtin_dxex (_Decimal64);
15145 _Decimal128 __builtin_dxexq (_Decimal128);
15146 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15147 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15148 _Decimal64 __builtin_denbcd (int, _Decimal64);
15149 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15150 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
15151 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
15152 _Decimal64 __builtin_dscli (_Decimal64, int);
15153 _Decimal128 __builtin_dscliq (_Decimal128, int);
15154 _Decimal64 __builtin_dscri (_Decimal64, int);
15155 _Decimal128 __builtin_dscriq (_Decimal128, int);
15156 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15157 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15158 @end smallexample
15159
15160 The following built-in functions are available for the PowerPC family
15161 of processors when the Vector Scalar (vsx) instruction set is
15162 available:
15163 @smallexample
15164 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
15165 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
15166 unsigned long long);
15167 @end smallexample
15168
15169 @node PowerPC AltiVec/VSX Built-in Functions
15170 @subsection PowerPC AltiVec Built-in Functions
15171
15172 GCC provides an interface for the PowerPC family of processors to access
15173 the AltiVec operations described in Motorola's AltiVec Programming
15174 Interface Manual. The interface is made available by including
15175 @code{<altivec.h>} and using @option{-maltivec} and
15176 @option{-mabi=altivec}. The interface supports the following vector
15177 types.
15178
15179 @smallexample
15180 vector unsigned char
15181 vector signed char
15182 vector bool char
15183
15184 vector unsigned short
15185 vector signed short
15186 vector bool short
15187 vector pixel
15188
15189 vector unsigned int
15190 vector signed int
15191 vector bool int
15192 vector float
15193 @end smallexample
15194
15195 If @option{-mvsx} is used the following additional vector types are
15196 implemented.
15197
15198 @smallexample
15199 vector unsigned long
15200 vector signed long
15201 vector double
15202 @end smallexample
15203
15204 The long types are only implemented for 64-bit code generation, and
15205 the long type is only used in the floating point/integer conversion
15206 instructions.
15207
15208 GCC's implementation of the high-level language interface available from
15209 C and C++ code differs from Motorola's documentation in several ways.
15210
15211 @itemize @bullet
15212
15213 @item
15214 A vector constant is a list of constant expressions within curly braces.
15215
15216 @item
15217 A vector initializer requires no cast if the vector constant is of the
15218 same type as the variable it is initializing.
15219
15220 @item
15221 If @code{signed} or @code{unsigned} is omitted, the signedness of the
15222 vector type is the default signedness of the base type. The default
15223 varies depending on the operating system, so a portable program should
15224 always specify the signedness.
15225
15226 @item
15227 Compiling with @option{-maltivec} adds keywords @code{__vector},
15228 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
15229 @code{bool}. When compiling ISO C, the context-sensitive substitution
15230 of the keywords @code{vector}, @code{pixel} and @code{bool} is
15231 disabled. To use them, you must include @code{<altivec.h>} instead.
15232
15233 @item
15234 GCC allows using a @code{typedef} name as the type specifier for a
15235 vector type.
15236
15237 @item
15238 For C, overloaded functions are implemented with macros so the following
15239 does not work:
15240
15241 @smallexample
15242 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
15243 @end smallexample
15244
15245 @noindent
15246 Since @code{vec_add} is a macro, the vector constant in the example
15247 is treated as four separate arguments. Wrap the entire argument in
15248 parentheses for this to work.
15249 @end itemize
15250
15251 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
15252 Internally, GCC uses built-in functions to achieve the functionality in
15253 the aforementioned header file, but they are not supported and are
15254 subject to change without notice.
15255
15256 The following interfaces are supported for the generic and specific
15257 AltiVec operations and the AltiVec predicates. In cases where there
15258 is a direct mapping between generic and specific operations, only the
15259 generic names are shown here, although the specific operations can also
15260 be used.
15261
15262 Arguments that are documented as @code{const int} require literal
15263 integral values within the range required for that operation.
15264
15265 @smallexample
15266 vector signed char vec_abs (vector signed char);
15267 vector signed short vec_abs (vector signed short);
15268 vector signed int vec_abs (vector signed int);
15269 vector float vec_abs (vector float);
15270
15271 vector signed char vec_abss (vector signed char);
15272 vector signed short vec_abss (vector signed short);
15273 vector signed int vec_abss (vector signed int);
15274
15275 vector signed char vec_add (vector bool char, vector signed char);
15276 vector signed char vec_add (vector signed char, vector bool char);
15277 vector signed char vec_add (vector signed char, vector signed char);
15278 vector unsigned char vec_add (vector bool char, vector unsigned char);
15279 vector unsigned char vec_add (vector unsigned char, vector bool char);
15280 vector unsigned char vec_add (vector unsigned char,
15281 vector unsigned char);
15282 vector signed short vec_add (vector bool short, vector signed short);
15283 vector signed short vec_add (vector signed short, vector bool short);
15284 vector signed short vec_add (vector signed short, vector signed short);
15285 vector unsigned short vec_add (vector bool short,
15286 vector unsigned short);
15287 vector unsigned short vec_add (vector unsigned short,
15288 vector bool short);
15289 vector unsigned short vec_add (vector unsigned short,
15290 vector unsigned short);
15291 vector signed int vec_add (vector bool int, vector signed int);
15292 vector signed int vec_add (vector signed int, vector bool int);
15293 vector signed int vec_add (vector signed int, vector signed int);
15294 vector unsigned int vec_add (vector bool int, vector unsigned int);
15295 vector unsigned int vec_add (vector unsigned int, vector bool int);
15296 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
15297 vector float vec_add (vector float, vector float);
15298
15299 vector float vec_vaddfp (vector float, vector float);
15300
15301 vector signed int vec_vadduwm (vector bool int, vector signed int);
15302 vector signed int vec_vadduwm (vector signed int, vector bool int);
15303 vector signed int vec_vadduwm (vector signed int, vector signed int);
15304 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
15305 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
15306 vector unsigned int vec_vadduwm (vector unsigned int,
15307 vector unsigned int);
15308
15309 vector signed short vec_vadduhm (vector bool short,
15310 vector signed short);
15311 vector signed short vec_vadduhm (vector signed short,
15312 vector bool short);
15313 vector signed short vec_vadduhm (vector signed short,
15314 vector signed short);
15315 vector unsigned short vec_vadduhm (vector bool short,
15316 vector unsigned short);
15317 vector unsigned short vec_vadduhm (vector unsigned short,
15318 vector bool short);
15319 vector unsigned short vec_vadduhm (vector unsigned short,
15320 vector unsigned short);
15321
15322 vector signed char vec_vaddubm (vector bool char, vector signed char);
15323 vector signed char vec_vaddubm (vector signed char, vector bool char);
15324 vector signed char vec_vaddubm (vector signed char, vector signed char);
15325 vector unsigned char vec_vaddubm (vector bool char,
15326 vector unsigned char);
15327 vector unsigned char vec_vaddubm (vector unsigned char,
15328 vector bool char);
15329 vector unsigned char vec_vaddubm (vector unsigned char,
15330 vector unsigned char);
15331
15332 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
15333
15334 vector unsigned char vec_adds (vector bool char, vector unsigned char);
15335 vector unsigned char vec_adds (vector unsigned char, vector bool char);
15336 vector unsigned char vec_adds (vector unsigned char,
15337 vector unsigned char);
15338 vector signed char vec_adds (vector bool char, vector signed char);
15339 vector signed char vec_adds (vector signed char, vector bool char);
15340 vector signed char vec_adds (vector signed char, vector signed char);
15341 vector unsigned short vec_adds (vector bool short,
15342 vector unsigned short);
15343 vector unsigned short vec_adds (vector unsigned short,
15344 vector bool short);
15345 vector unsigned short vec_adds (vector unsigned short,
15346 vector unsigned short);
15347 vector signed short vec_adds (vector bool short, vector signed short);
15348 vector signed short vec_adds (vector signed short, vector bool short);
15349 vector signed short vec_adds (vector signed short, vector signed short);
15350 vector unsigned int vec_adds (vector bool int, vector unsigned int);
15351 vector unsigned int vec_adds (vector unsigned int, vector bool int);
15352 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
15353 vector signed int vec_adds (vector bool int, vector signed int);
15354 vector signed int vec_adds (vector signed int, vector bool int);
15355 vector signed int vec_adds (vector signed int, vector signed int);
15356
15357 vector signed int vec_vaddsws (vector bool int, vector signed int);
15358 vector signed int vec_vaddsws (vector signed int, vector bool int);
15359 vector signed int vec_vaddsws (vector signed int, vector signed int);
15360
15361 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15362 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15363 vector unsigned int vec_vadduws (vector unsigned int,
15364 vector unsigned int);
15365
15366 vector signed short vec_vaddshs (vector bool short,
15367 vector signed short);
15368 vector signed short vec_vaddshs (vector signed short,
15369 vector bool short);
15370 vector signed short vec_vaddshs (vector signed short,
15371 vector signed short);
15372
15373 vector unsigned short vec_vadduhs (vector bool short,
15374 vector unsigned short);
15375 vector unsigned short vec_vadduhs (vector unsigned short,
15376 vector bool short);
15377 vector unsigned short vec_vadduhs (vector unsigned short,
15378 vector unsigned short);
15379
15380 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15381 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15382 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15383
15384 vector unsigned char vec_vaddubs (vector bool char,
15385 vector unsigned char);
15386 vector unsigned char vec_vaddubs (vector unsigned char,
15387 vector bool char);
15388 vector unsigned char vec_vaddubs (vector unsigned char,
15389 vector unsigned char);
15390
15391 vector float vec_and (vector float, vector float);
15392 vector float vec_and (vector float, vector bool int);
15393 vector float vec_and (vector bool int, vector float);
15394 vector bool int vec_and (vector bool int, vector bool int);
15395 vector signed int vec_and (vector bool int, vector signed int);
15396 vector signed int vec_and (vector signed int, vector bool int);
15397 vector signed int vec_and (vector signed int, vector signed int);
15398 vector unsigned int vec_and (vector bool int, vector unsigned int);
15399 vector unsigned int vec_and (vector unsigned int, vector bool int);
15400 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15401 vector bool short vec_and (vector bool short, vector bool short);
15402 vector signed short vec_and (vector bool short, vector signed short);
15403 vector signed short vec_and (vector signed short, vector bool short);
15404 vector signed short vec_and (vector signed short, vector signed short);
15405 vector unsigned short vec_and (vector bool short,
15406 vector unsigned short);
15407 vector unsigned short vec_and (vector unsigned short,
15408 vector bool short);
15409 vector unsigned short vec_and (vector unsigned short,
15410 vector unsigned short);
15411 vector signed char vec_and (vector bool char, vector signed char);
15412 vector bool char vec_and (vector bool char, vector bool char);
15413 vector signed char vec_and (vector signed char, vector bool char);
15414 vector signed char vec_and (vector signed char, vector signed char);
15415 vector unsigned char vec_and (vector bool char, vector unsigned char);
15416 vector unsigned char vec_and (vector unsigned char, vector bool char);
15417 vector unsigned char vec_and (vector unsigned char,
15418 vector unsigned char);
15419
15420 vector float vec_andc (vector float, vector float);
15421 vector float vec_andc (vector float, vector bool int);
15422 vector float vec_andc (vector bool int, vector float);
15423 vector bool int vec_andc (vector bool int, vector bool int);
15424 vector signed int vec_andc (vector bool int, vector signed int);
15425 vector signed int vec_andc (vector signed int, vector bool int);
15426 vector signed int vec_andc (vector signed int, vector signed int);
15427 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15428 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15429 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15430 vector bool short vec_andc (vector bool short, vector bool short);
15431 vector signed short vec_andc (vector bool short, vector signed short);
15432 vector signed short vec_andc (vector signed short, vector bool short);
15433 vector signed short vec_andc (vector signed short, vector signed short);
15434 vector unsigned short vec_andc (vector bool short,
15435 vector unsigned short);
15436 vector unsigned short vec_andc (vector unsigned short,
15437 vector bool short);
15438 vector unsigned short vec_andc (vector unsigned short,
15439 vector unsigned short);
15440 vector signed char vec_andc (vector bool char, vector signed char);
15441 vector bool char vec_andc (vector bool char, vector bool char);
15442 vector signed char vec_andc (vector signed char, vector bool char);
15443 vector signed char vec_andc (vector signed char, vector signed char);
15444 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15445 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15446 vector unsigned char vec_andc (vector unsigned char,
15447 vector unsigned char);
15448
15449 vector unsigned char vec_avg (vector unsigned char,
15450 vector unsigned char);
15451 vector signed char vec_avg (vector signed char, vector signed char);
15452 vector unsigned short vec_avg (vector unsigned short,
15453 vector unsigned short);
15454 vector signed short vec_avg (vector signed short, vector signed short);
15455 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15456 vector signed int vec_avg (vector signed int, vector signed int);
15457
15458 vector signed int vec_vavgsw (vector signed int, vector signed int);
15459
15460 vector unsigned int vec_vavguw (vector unsigned int,
15461 vector unsigned int);
15462
15463 vector signed short vec_vavgsh (vector signed short,
15464 vector signed short);
15465
15466 vector unsigned short vec_vavguh (vector unsigned short,
15467 vector unsigned short);
15468
15469 vector signed char vec_vavgsb (vector signed char, vector signed char);
15470
15471 vector unsigned char vec_vavgub (vector unsigned char,
15472 vector unsigned char);
15473
15474 vector float vec_copysign (vector float);
15475
15476 vector float vec_ceil (vector float);
15477
15478 vector signed int vec_cmpb (vector float, vector float);
15479
15480 vector bool char vec_cmpeq (vector signed char, vector signed char);
15481 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15482 vector bool short vec_cmpeq (vector signed short, vector signed short);
15483 vector bool short vec_cmpeq (vector unsigned short,
15484 vector unsigned short);
15485 vector bool int vec_cmpeq (vector signed int, vector signed int);
15486 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15487 vector bool int vec_cmpeq (vector float, vector float);
15488
15489 vector bool int vec_vcmpeqfp (vector float, vector float);
15490
15491 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15492 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15493
15494 vector bool short vec_vcmpequh (vector signed short,
15495 vector signed short);
15496 vector bool short vec_vcmpequh (vector unsigned short,
15497 vector unsigned short);
15498
15499 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15500 vector bool char vec_vcmpequb (vector unsigned char,
15501 vector unsigned char);
15502
15503 vector bool int vec_cmpge (vector float, vector float);
15504
15505 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15506 vector bool char vec_cmpgt (vector signed char, vector signed char);
15507 vector bool short vec_cmpgt (vector unsigned short,
15508 vector unsigned short);
15509 vector bool short vec_cmpgt (vector signed short, vector signed short);
15510 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15511 vector bool int vec_cmpgt (vector signed int, vector signed int);
15512 vector bool int vec_cmpgt (vector float, vector float);
15513
15514 vector bool int vec_vcmpgtfp (vector float, vector float);
15515
15516 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15517
15518 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15519
15520 vector bool short vec_vcmpgtsh (vector signed short,
15521 vector signed short);
15522
15523 vector bool short vec_vcmpgtuh (vector unsigned short,
15524 vector unsigned short);
15525
15526 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15527
15528 vector bool char vec_vcmpgtub (vector unsigned char,
15529 vector unsigned char);
15530
15531 vector bool int vec_cmple (vector float, vector float);
15532
15533 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15534 vector bool char vec_cmplt (vector signed char, vector signed char);
15535 vector bool short vec_cmplt (vector unsigned short,
15536 vector unsigned short);
15537 vector bool short vec_cmplt (vector signed short, vector signed short);
15538 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15539 vector bool int vec_cmplt (vector signed int, vector signed int);
15540 vector bool int vec_cmplt (vector float, vector float);
15541
15542 vector float vec_cpsgn (vector float, vector float);
15543
15544 vector float vec_ctf (vector unsigned int, const int);
15545 vector float vec_ctf (vector signed int, const int);
15546 vector double vec_ctf (vector unsigned long, const int);
15547 vector double vec_ctf (vector signed long, const int);
15548
15549 vector float vec_vcfsx (vector signed int, const int);
15550
15551 vector float vec_vcfux (vector unsigned int, const int);
15552
15553 vector signed int vec_cts (vector float, const int);
15554 vector signed long vec_cts (vector double, const int);
15555
15556 vector unsigned int vec_ctu (vector float, const int);
15557 vector unsigned long vec_ctu (vector double, const int);
15558
15559 void vec_dss (const int);
15560
15561 void vec_dssall (void);
15562
15563 void vec_dst (const vector unsigned char *, int, const int);
15564 void vec_dst (const vector signed char *, int, const int);
15565 void vec_dst (const vector bool char *, int, const int);
15566 void vec_dst (const vector unsigned short *, int, const int);
15567 void vec_dst (const vector signed short *, int, const int);
15568 void vec_dst (const vector bool short *, int, const int);
15569 void vec_dst (const vector pixel *, int, const int);
15570 void vec_dst (const vector unsigned int *, int, const int);
15571 void vec_dst (const vector signed int *, int, const int);
15572 void vec_dst (const vector bool int *, int, const int);
15573 void vec_dst (const vector float *, int, const int);
15574 void vec_dst (const unsigned char *, int, const int);
15575 void vec_dst (const signed char *, int, const int);
15576 void vec_dst (const unsigned short *, int, const int);
15577 void vec_dst (const short *, int, const int);
15578 void vec_dst (const unsigned int *, int, const int);
15579 void vec_dst (const int *, int, const int);
15580 void vec_dst (const unsigned long *, int, const int);
15581 void vec_dst (const long *, int, const int);
15582 void vec_dst (const float *, int, const int);
15583
15584 void vec_dstst (const vector unsigned char *, int, const int);
15585 void vec_dstst (const vector signed char *, int, const int);
15586 void vec_dstst (const vector bool char *, int, const int);
15587 void vec_dstst (const vector unsigned short *, int, const int);
15588 void vec_dstst (const vector signed short *, int, const int);
15589 void vec_dstst (const vector bool short *, int, const int);
15590 void vec_dstst (const vector pixel *, int, const int);
15591 void vec_dstst (const vector unsigned int *, int, const int);
15592 void vec_dstst (const vector signed int *, int, const int);
15593 void vec_dstst (const vector bool int *, int, const int);
15594 void vec_dstst (const vector float *, int, const int);
15595 void vec_dstst (const unsigned char *, int, const int);
15596 void vec_dstst (const signed char *, int, const int);
15597 void vec_dstst (const unsigned short *, int, const int);
15598 void vec_dstst (const short *, int, const int);
15599 void vec_dstst (const unsigned int *, int, const int);
15600 void vec_dstst (const int *, int, const int);
15601 void vec_dstst (const unsigned long *, int, const int);
15602 void vec_dstst (const long *, int, const int);
15603 void vec_dstst (const float *, int, const int);
15604
15605 void vec_dststt (const vector unsigned char *, int, const int);
15606 void vec_dststt (const vector signed char *, int, const int);
15607 void vec_dststt (const vector bool char *, int, const int);
15608 void vec_dststt (const vector unsigned short *, int, const int);
15609 void vec_dststt (const vector signed short *, int, const int);
15610 void vec_dststt (const vector bool short *, int, const int);
15611 void vec_dststt (const vector pixel *, int, const int);
15612 void vec_dststt (const vector unsigned int *, int, const int);
15613 void vec_dststt (const vector signed int *, int, const int);
15614 void vec_dststt (const vector bool int *, int, const int);
15615 void vec_dststt (const vector float *, int, const int);
15616 void vec_dststt (const unsigned char *, int, const int);
15617 void vec_dststt (const signed char *, int, const int);
15618 void vec_dststt (const unsigned short *, int, const int);
15619 void vec_dststt (const short *, int, const int);
15620 void vec_dststt (const unsigned int *, int, const int);
15621 void vec_dststt (const int *, int, const int);
15622 void vec_dststt (const unsigned long *, int, const int);
15623 void vec_dststt (const long *, int, const int);
15624 void vec_dststt (const float *, int, const int);
15625
15626 void vec_dstt (const vector unsigned char *, int, const int);
15627 void vec_dstt (const vector signed char *, int, const int);
15628 void vec_dstt (const vector bool char *, int, const int);
15629 void vec_dstt (const vector unsigned short *, int, const int);
15630 void vec_dstt (const vector signed short *, int, const int);
15631 void vec_dstt (const vector bool short *, int, const int);
15632 void vec_dstt (const vector pixel *, int, const int);
15633 void vec_dstt (const vector unsigned int *, int, const int);
15634 void vec_dstt (const vector signed int *, int, const int);
15635 void vec_dstt (const vector bool int *, int, const int);
15636 void vec_dstt (const vector float *, int, const int);
15637 void vec_dstt (const unsigned char *, int, const int);
15638 void vec_dstt (const signed char *, int, const int);
15639 void vec_dstt (const unsigned short *, int, const int);
15640 void vec_dstt (const short *, int, const int);
15641 void vec_dstt (const unsigned int *, int, const int);
15642 void vec_dstt (const int *, int, const int);
15643 void vec_dstt (const unsigned long *, int, const int);
15644 void vec_dstt (const long *, int, const int);
15645 void vec_dstt (const float *, int, const int);
15646
15647 vector float vec_expte (vector float);
15648
15649 vector float vec_floor (vector float);
15650
15651 vector float vec_ld (int, const vector float *);
15652 vector float vec_ld (int, const float *);
15653 vector bool int vec_ld (int, const vector bool int *);
15654 vector signed int vec_ld (int, const vector signed int *);
15655 vector signed int vec_ld (int, const int *);
15656 vector signed int vec_ld (int, const long *);
15657 vector unsigned int vec_ld (int, const vector unsigned int *);
15658 vector unsigned int vec_ld (int, const unsigned int *);
15659 vector unsigned int vec_ld (int, const unsigned long *);
15660 vector bool short vec_ld (int, const vector bool short *);
15661 vector pixel vec_ld (int, const vector pixel *);
15662 vector signed short vec_ld (int, const vector signed short *);
15663 vector signed short vec_ld (int, const short *);
15664 vector unsigned short vec_ld (int, const vector unsigned short *);
15665 vector unsigned short vec_ld (int, const unsigned short *);
15666 vector bool char vec_ld (int, const vector bool char *);
15667 vector signed char vec_ld (int, const vector signed char *);
15668 vector signed char vec_ld (int, const signed char *);
15669 vector unsigned char vec_ld (int, const vector unsigned char *);
15670 vector unsigned char vec_ld (int, const unsigned char *);
15671
15672 vector signed char vec_lde (int, const signed char *);
15673 vector unsigned char vec_lde (int, const unsigned char *);
15674 vector signed short vec_lde (int, const short *);
15675 vector unsigned short vec_lde (int, const unsigned short *);
15676 vector float vec_lde (int, const float *);
15677 vector signed int vec_lde (int, const int *);
15678 vector unsigned int vec_lde (int, const unsigned int *);
15679 vector signed int vec_lde (int, const long *);
15680 vector unsigned int vec_lde (int, const unsigned long *);
15681
15682 vector float vec_lvewx (int, float *);
15683 vector signed int vec_lvewx (int, int *);
15684 vector unsigned int vec_lvewx (int, unsigned int *);
15685 vector signed int vec_lvewx (int, long *);
15686 vector unsigned int vec_lvewx (int, unsigned long *);
15687
15688 vector signed short vec_lvehx (int, short *);
15689 vector unsigned short vec_lvehx (int, unsigned short *);
15690
15691 vector signed char vec_lvebx (int, char *);
15692 vector unsigned char vec_lvebx (int, unsigned char *);
15693
15694 vector float vec_ldl (int, const vector float *);
15695 vector float vec_ldl (int, const float *);
15696 vector bool int vec_ldl (int, const vector bool int *);
15697 vector signed int vec_ldl (int, const vector signed int *);
15698 vector signed int vec_ldl (int, const int *);
15699 vector signed int vec_ldl (int, const long *);
15700 vector unsigned int vec_ldl (int, const vector unsigned int *);
15701 vector unsigned int vec_ldl (int, const unsigned int *);
15702 vector unsigned int vec_ldl (int, const unsigned long *);
15703 vector bool short vec_ldl (int, const vector bool short *);
15704 vector pixel vec_ldl (int, const vector pixel *);
15705 vector signed short vec_ldl (int, const vector signed short *);
15706 vector signed short vec_ldl (int, const short *);
15707 vector unsigned short vec_ldl (int, const vector unsigned short *);
15708 vector unsigned short vec_ldl (int, const unsigned short *);
15709 vector bool char vec_ldl (int, const vector bool char *);
15710 vector signed char vec_ldl (int, const vector signed char *);
15711 vector signed char vec_ldl (int, const signed char *);
15712 vector unsigned char vec_ldl (int, const vector unsigned char *);
15713 vector unsigned char vec_ldl (int, const unsigned char *);
15714
15715 vector float vec_loge (vector float);
15716
15717 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
15718 vector unsigned char vec_lvsl (int, const volatile signed char *);
15719 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
15720 vector unsigned char vec_lvsl (int, const volatile short *);
15721 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
15722 vector unsigned char vec_lvsl (int, const volatile int *);
15723 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
15724 vector unsigned char vec_lvsl (int, const volatile long *);
15725 vector unsigned char vec_lvsl (int, const volatile float *);
15726
15727 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
15728 vector unsigned char vec_lvsr (int, const volatile signed char *);
15729 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
15730 vector unsigned char vec_lvsr (int, const volatile short *);
15731 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
15732 vector unsigned char vec_lvsr (int, const volatile int *);
15733 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
15734 vector unsigned char vec_lvsr (int, const volatile long *);
15735 vector unsigned char vec_lvsr (int, const volatile float *);
15736
15737 vector float vec_madd (vector float, vector float, vector float);
15738
15739 vector signed short vec_madds (vector signed short,
15740 vector signed short,
15741 vector signed short);
15742
15743 vector unsigned char vec_max (vector bool char, vector unsigned char);
15744 vector unsigned char vec_max (vector unsigned char, vector bool char);
15745 vector unsigned char vec_max (vector unsigned char,
15746 vector unsigned char);
15747 vector signed char vec_max (vector bool char, vector signed char);
15748 vector signed char vec_max (vector signed char, vector bool char);
15749 vector signed char vec_max (vector signed char, vector signed char);
15750 vector unsigned short vec_max (vector bool short,
15751 vector unsigned short);
15752 vector unsigned short vec_max (vector unsigned short,
15753 vector bool short);
15754 vector unsigned short vec_max (vector unsigned short,
15755 vector unsigned short);
15756 vector signed short vec_max (vector bool short, vector signed short);
15757 vector signed short vec_max (vector signed short, vector bool short);
15758 vector signed short vec_max (vector signed short, vector signed short);
15759 vector unsigned int vec_max (vector bool int, vector unsigned int);
15760 vector unsigned int vec_max (vector unsigned int, vector bool int);
15761 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
15762 vector signed int vec_max (vector bool int, vector signed int);
15763 vector signed int vec_max (vector signed int, vector bool int);
15764 vector signed int vec_max (vector signed int, vector signed int);
15765 vector float vec_max (vector float, vector float);
15766
15767 vector float vec_vmaxfp (vector float, vector float);
15768
15769 vector signed int vec_vmaxsw (vector bool int, vector signed int);
15770 vector signed int vec_vmaxsw (vector signed int, vector bool int);
15771 vector signed int vec_vmaxsw (vector signed int, vector signed int);
15772
15773 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
15774 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
15775 vector unsigned int vec_vmaxuw (vector unsigned int,
15776 vector unsigned int);
15777
15778 vector signed short vec_vmaxsh (vector bool short, vector signed short);
15779 vector signed short vec_vmaxsh (vector signed short, vector bool short);
15780 vector signed short vec_vmaxsh (vector signed short,
15781 vector signed short);
15782
15783 vector unsigned short vec_vmaxuh (vector bool short,
15784 vector unsigned short);
15785 vector unsigned short vec_vmaxuh (vector unsigned short,
15786 vector bool short);
15787 vector unsigned short vec_vmaxuh (vector unsigned short,
15788 vector unsigned short);
15789
15790 vector signed char vec_vmaxsb (vector bool char, vector signed char);
15791 vector signed char vec_vmaxsb (vector signed char, vector bool char);
15792 vector signed char vec_vmaxsb (vector signed char, vector signed char);
15793
15794 vector unsigned char vec_vmaxub (vector bool char,
15795 vector unsigned char);
15796 vector unsigned char vec_vmaxub (vector unsigned char,
15797 vector bool char);
15798 vector unsigned char vec_vmaxub (vector unsigned char,
15799 vector unsigned char);
15800
15801 vector bool char vec_mergeh (vector bool char, vector bool char);
15802 vector signed char vec_mergeh (vector signed char, vector signed char);
15803 vector unsigned char vec_mergeh (vector unsigned char,
15804 vector unsigned char);
15805 vector bool short vec_mergeh (vector bool short, vector bool short);
15806 vector pixel vec_mergeh (vector pixel, vector pixel);
15807 vector signed short vec_mergeh (vector signed short,
15808 vector signed short);
15809 vector unsigned short vec_mergeh (vector unsigned short,
15810 vector unsigned short);
15811 vector float vec_mergeh (vector float, vector float);
15812 vector bool int vec_mergeh (vector bool int, vector bool int);
15813 vector signed int vec_mergeh (vector signed int, vector signed int);
15814 vector unsigned int vec_mergeh (vector unsigned int,
15815 vector unsigned int);
15816
15817 vector float vec_vmrghw (vector float, vector float);
15818 vector bool int vec_vmrghw (vector bool int, vector bool int);
15819 vector signed int vec_vmrghw (vector signed int, vector signed int);
15820 vector unsigned int vec_vmrghw (vector unsigned int,
15821 vector unsigned int);
15822
15823 vector bool short vec_vmrghh (vector bool short, vector bool short);
15824 vector signed short vec_vmrghh (vector signed short,
15825 vector signed short);
15826 vector unsigned short vec_vmrghh (vector unsigned short,
15827 vector unsigned short);
15828 vector pixel vec_vmrghh (vector pixel, vector pixel);
15829
15830 vector bool char vec_vmrghb (vector bool char, vector bool char);
15831 vector signed char vec_vmrghb (vector signed char, vector signed char);
15832 vector unsigned char vec_vmrghb (vector unsigned char,
15833 vector unsigned char);
15834
15835 vector bool char vec_mergel (vector bool char, vector bool char);
15836 vector signed char vec_mergel (vector signed char, vector signed char);
15837 vector unsigned char vec_mergel (vector unsigned char,
15838 vector unsigned char);
15839 vector bool short vec_mergel (vector bool short, vector bool short);
15840 vector pixel vec_mergel (vector pixel, vector pixel);
15841 vector signed short vec_mergel (vector signed short,
15842 vector signed short);
15843 vector unsigned short vec_mergel (vector unsigned short,
15844 vector unsigned short);
15845 vector float vec_mergel (vector float, vector float);
15846 vector bool int vec_mergel (vector bool int, vector bool int);
15847 vector signed int vec_mergel (vector signed int, vector signed int);
15848 vector unsigned int vec_mergel (vector unsigned int,
15849 vector unsigned int);
15850
15851 vector float vec_vmrglw (vector float, vector float);
15852 vector signed int vec_vmrglw (vector signed int, vector signed int);
15853 vector unsigned int vec_vmrglw (vector unsigned int,
15854 vector unsigned int);
15855 vector bool int vec_vmrglw (vector bool int, vector bool int);
15856
15857 vector bool short vec_vmrglh (vector bool short, vector bool short);
15858 vector signed short vec_vmrglh (vector signed short,
15859 vector signed short);
15860 vector unsigned short vec_vmrglh (vector unsigned short,
15861 vector unsigned short);
15862 vector pixel vec_vmrglh (vector pixel, vector pixel);
15863
15864 vector bool char vec_vmrglb (vector bool char, vector bool char);
15865 vector signed char vec_vmrglb (vector signed char, vector signed char);
15866 vector unsigned char vec_vmrglb (vector unsigned char,
15867 vector unsigned char);
15868
15869 vector unsigned short vec_mfvscr (void);
15870
15871 vector unsigned char vec_min (vector bool char, vector unsigned char);
15872 vector unsigned char vec_min (vector unsigned char, vector bool char);
15873 vector unsigned char vec_min (vector unsigned char,
15874 vector unsigned char);
15875 vector signed char vec_min (vector bool char, vector signed char);
15876 vector signed char vec_min (vector signed char, vector bool char);
15877 vector signed char vec_min (vector signed char, vector signed char);
15878 vector unsigned short vec_min (vector bool short,
15879 vector unsigned short);
15880 vector unsigned short vec_min (vector unsigned short,
15881 vector bool short);
15882 vector unsigned short vec_min (vector unsigned short,
15883 vector unsigned short);
15884 vector signed short vec_min (vector bool short, vector signed short);
15885 vector signed short vec_min (vector signed short, vector bool short);
15886 vector signed short vec_min (vector signed short, vector signed short);
15887 vector unsigned int vec_min (vector bool int, vector unsigned int);
15888 vector unsigned int vec_min (vector unsigned int, vector bool int);
15889 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
15890 vector signed int vec_min (vector bool int, vector signed int);
15891 vector signed int vec_min (vector signed int, vector bool int);
15892 vector signed int vec_min (vector signed int, vector signed int);
15893 vector float vec_min (vector float, vector float);
15894
15895 vector float vec_vminfp (vector float, vector float);
15896
15897 vector signed int vec_vminsw (vector bool int, vector signed int);
15898 vector signed int vec_vminsw (vector signed int, vector bool int);
15899 vector signed int vec_vminsw (vector signed int, vector signed int);
15900
15901 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
15902 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
15903 vector unsigned int vec_vminuw (vector unsigned int,
15904 vector unsigned int);
15905
15906 vector signed short vec_vminsh (vector bool short, vector signed short);
15907 vector signed short vec_vminsh (vector signed short, vector bool short);
15908 vector signed short vec_vminsh (vector signed short,
15909 vector signed short);
15910
15911 vector unsigned short vec_vminuh (vector bool short,
15912 vector unsigned short);
15913 vector unsigned short vec_vminuh (vector unsigned short,
15914 vector bool short);
15915 vector unsigned short vec_vminuh (vector unsigned short,
15916 vector unsigned short);
15917
15918 vector signed char vec_vminsb (vector bool char, vector signed char);
15919 vector signed char vec_vminsb (vector signed char, vector bool char);
15920 vector signed char vec_vminsb (vector signed char, vector signed char);
15921
15922 vector unsigned char vec_vminub (vector bool char,
15923 vector unsigned char);
15924 vector unsigned char vec_vminub (vector unsigned char,
15925 vector bool char);
15926 vector unsigned char vec_vminub (vector unsigned char,
15927 vector unsigned char);
15928
15929 vector signed short vec_mladd (vector signed short,
15930 vector signed short,
15931 vector signed short);
15932 vector signed short vec_mladd (vector signed short,
15933 vector unsigned short,
15934 vector unsigned short);
15935 vector signed short vec_mladd (vector unsigned short,
15936 vector signed short,
15937 vector signed short);
15938 vector unsigned short vec_mladd (vector unsigned short,
15939 vector unsigned short,
15940 vector unsigned short);
15941
15942 vector signed short vec_mradds (vector signed short,
15943 vector signed short,
15944 vector signed short);
15945
15946 vector unsigned int vec_msum (vector unsigned char,
15947 vector unsigned char,
15948 vector unsigned int);
15949 vector signed int vec_msum (vector signed char,
15950 vector unsigned char,
15951 vector signed int);
15952 vector unsigned int vec_msum (vector unsigned short,
15953 vector unsigned short,
15954 vector unsigned int);
15955 vector signed int vec_msum (vector signed short,
15956 vector signed short,
15957 vector signed int);
15958
15959 vector signed int vec_vmsumshm (vector signed short,
15960 vector signed short,
15961 vector signed int);
15962
15963 vector unsigned int vec_vmsumuhm (vector unsigned short,
15964 vector unsigned short,
15965 vector unsigned int);
15966
15967 vector signed int vec_vmsummbm (vector signed char,
15968 vector unsigned char,
15969 vector signed int);
15970
15971 vector unsigned int vec_vmsumubm (vector unsigned char,
15972 vector unsigned char,
15973 vector unsigned int);
15974
15975 vector unsigned int vec_msums (vector unsigned short,
15976 vector unsigned short,
15977 vector unsigned int);
15978 vector signed int vec_msums (vector signed short,
15979 vector signed short,
15980 vector signed int);
15981
15982 vector signed int vec_vmsumshs (vector signed short,
15983 vector signed short,
15984 vector signed int);
15985
15986 vector unsigned int vec_vmsumuhs (vector unsigned short,
15987 vector unsigned short,
15988 vector unsigned int);
15989
15990 void vec_mtvscr (vector signed int);
15991 void vec_mtvscr (vector unsigned int);
15992 void vec_mtvscr (vector bool int);
15993 void vec_mtvscr (vector signed short);
15994 void vec_mtvscr (vector unsigned short);
15995 void vec_mtvscr (vector bool short);
15996 void vec_mtvscr (vector pixel);
15997 void vec_mtvscr (vector signed char);
15998 void vec_mtvscr (vector unsigned char);
15999 void vec_mtvscr (vector bool char);
16000
16001 vector unsigned short vec_mule (vector unsigned char,
16002 vector unsigned char);
16003 vector signed short vec_mule (vector signed char,
16004 vector signed char);
16005 vector unsigned int vec_mule (vector unsigned short,
16006 vector unsigned short);
16007 vector signed int vec_mule (vector signed short, vector signed short);
16008
16009 vector signed int vec_vmulesh (vector signed short,
16010 vector signed short);
16011
16012 vector unsigned int vec_vmuleuh (vector unsigned short,
16013 vector unsigned short);
16014
16015 vector signed short vec_vmulesb (vector signed char,
16016 vector signed char);
16017
16018 vector unsigned short vec_vmuleub (vector unsigned char,
16019 vector unsigned char);
16020
16021 vector unsigned short vec_mulo (vector unsigned char,
16022 vector unsigned char);
16023 vector signed short vec_mulo (vector signed char, vector signed char);
16024 vector unsigned int vec_mulo (vector unsigned short,
16025 vector unsigned short);
16026 vector signed int vec_mulo (vector signed short, vector signed short);
16027
16028 vector signed int vec_vmulosh (vector signed short,
16029 vector signed short);
16030
16031 vector unsigned int vec_vmulouh (vector unsigned short,
16032 vector unsigned short);
16033
16034 vector signed short vec_vmulosb (vector signed char,
16035 vector signed char);
16036
16037 vector unsigned short vec_vmuloub (vector unsigned char,
16038 vector unsigned char);
16039
16040 vector float vec_nmsub (vector float, vector float, vector float);
16041
16042 vector float vec_nor (vector float, vector float);
16043 vector signed int vec_nor (vector signed int, vector signed int);
16044 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16045 vector bool int vec_nor (vector bool int, vector bool int);
16046 vector signed short vec_nor (vector signed short, vector signed short);
16047 vector unsigned short vec_nor (vector unsigned short,
16048 vector unsigned short);
16049 vector bool short vec_nor (vector bool short, vector bool short);
16050 vector signed char vec_nor (vector signed char, vector signed char);
16051 vector unsigned char vec_nor (vector unsigned char,
16052 vector unsigned char);
16053 vector bool char vec_nor (vector bool char, vector bool char);
16054
16055 vector float vec_or (vector float, vector float);
16056 vector float vec_or (vector float, vector bool int);
16057 vector float vec_or (vector bool int, vector float);
16058 vector bool int vec_or (vector bool int, vector bool int);
16059 vector signed int vec_or (vector bool int, vector signed int);
16060 vector signed int vec_or (vector signed int, vector bool int);
16061 vector signed int vec_or (vector signed int, vector signed int);
16062 vector unsigned int vec_or (vector bool int, vector unsigned int);
16063 vector unsigned int vec_or (vector unsigned int, vector bool int);
16064 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16065 vector bool short vec_or (vector bool short, vector bool short);
16066 vector signed short vec_or (vector bool short, vector signed short);
16067 vector signed short vec_or (vector signed short, vector bool short);
16068 vector signed short vec_or (vector signed short, vector signed short);
16069 vector unsigned short vec_or (vector bool short, vector unsigned short);
16070 vector unsigned short vec_or (vector unsigned short, vector bool short);
16071 vector unsigned short vec_or (vector unsigned short,
16072 vector unsigned short);
16073 vector signed char vec_or (vector bool char, vector signed char);
16074 vector bool char vec_or (vector bool char, vector bool char);
16075 vector signed char vec_or (vector signed char, vector bool char);
16076 vector signed char vec_or (vector signed char, vector signed char);
16077 vector unsigned char vec_or (vector bool char, vector unsigned char);
16078 vector unsigned char vec_or (vector unsigned char, vector bool char);
16079 vector unsigned char vec_or (vector unsigned char,
16080 vector unsigned char);
16081
16082 vector signed char vec_pack (vector signed short, vector signed short);
16083 vector unsigned char vec_pack (vector unsigned short,
16084 vector unsigned short);
16085 vector bool char vec_pack (vector bool short, vector bool short);
16086 vector signed short vec_pack (vector signed int, vector signed int);
16087 vector unsigned short vec_pack (vector unsigned int,
16088 vector unsigned int);
16089 vector bool short vec_pack (vector bool int, vector bool int);
16090
16091 vector bool short vec_vpkuwum (vector bool int, vector bool int);
16092 vector signed short vec_vpkuwum (vector signed int, vector signed int);
16093 vector unsigned short vec_vpkuwum (vector unsigned int,
16094 vector unsigned int);
16095
16096 vector bool char vec_vpkuhum (vector bool short, vector bool short);
16097 vector signed char vec_vpkuhum (vector signed short,
16098 vector signed short);
16099 vector unsigned char vec_vpkuhum (vector unsigned short,
16100 vector unsigned short);
16101
16102 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
16103
16104 vector unsigned char vec_packs (vector unsigned short,
16105 vector unsigned short);
16106 vector signed char vec_packs (vector signed short, vector signed short);
16107 vector unsigned short vec_packs (vector unsigned int,
16108 vector unsigned int);
16109 vector signed short vec_packs (vector signed int, vector signed int);
16110
16111 vector signed short vec_vpkswss (vector signed int, vector signed int);
16112
16113 vector unsigned short vec_vpkuwus (vector unsigned int,
16114 vector unsigned int);
16115
16116 vector signed char vec_vpkshss (vector signed short,
16117 vector signed short);
16118
16119 vector unsigned char vec_vpkuhus (vector unsigned short,
16120 vector unsigned short);
16121
16122 vector unsigned char vec_packsu (vector unsigned short,
16123 vector unsigned short);
16124 vector unsigned char vec_packsu (vector signed short,
16125 vector signed short);
16126 vector unsigned short vec_packsu (vector unsigned int,
16127 vector unsigned int);
16128 vector unsigned short vec_packsu (vector signed int, vector signed int);
16129
16130 vector unsigned short vec_vpkswus (vector signed int,
16131 vector signed int);
16132
16133 vector unsigned char vec_vpkshus (vector signed short,
16134 vector signed short);
16135
16136 vector float vec_perm (vector float,
16137 vector float,
16138 vector unsigned char);
16139 vector signed int vec_perm (vector signed int,
16140 vector signed int,
16141 vector unsigned char);
16142 vector unsigned int vec_perm (vector unsigned int,
16143 vector unsigned int,
16144 vector unsigned char);
16145 vector bool int vec_perm (vector bool int,
16146 vector bool int,
16147 vector unsigned char);
16148 vector signed short vec_perm (vector signed short,
16149 vector signed short,
16150 vector unsigned char);
16151 vector unsigned short vec_perm (vector unsigned short,
16152 vector unsigned short,
16153 vector unsigned char);
16154 vector bool short vec_perm (vector bool short,
16155 vector bool short,
16156 vector unsigned char);
16157 vector pixel vec_perm (vector pixel,
16158 vector pixel,
16159 vector unsigned char);
16160 vector signed char vec_perm (vector signed char,
16161 vector signed char,
16162 vector unsigned char);
16163 vector unsigned char vec_perm (vector unsigned char,
16164 vector unsigned char,
16165 vector unsigned char);
16166 vector bool char vec_perm (vector bool char,
16167 vector bool char,
16168 vector unsigned char);
16169
16170 vector float vec_re (vector float);
16171
16172 vector signed char vec_rl (vector signed char,
16173 vector unsigned char);
16174 vector unsigned char vec_rl (vector unsigned char,
16175 vector unsigned char);
16176 vector signed short vec_rl (vector signed short, vector unsigned short);
16177 vector unsigned short vec_rl (vector unsigned short,
16178 vector unsigned short);
16179 vector signed int vec_rl (vector signed int, vector unsigned int);
16180 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
16181
16182 vector signed int vec_vrlw (vector signed int, vector unsigned int);
16183 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
16184
16185 vector signed short vec_vrlh (vector signed short,
16186 vector unsigned short);
16187 vector unsigned short vec_vrlh (vector unsigned short,
16188 vector unsigned short);
16189
16190 vector signed char vec_vrlb (vector signed char, vector unsigned char);
16191 vector unsigned char vec_vrlb (vector unsigned char,
16192 vector unsigned char);
16193
16194 vector float vec_round (vector float);
16195
16196 vector float vec_recip (vector float, vector float);
16197
16198 vector float vec_rsqrt (vector float);
16199
16200 vector float vec_rsqrte (vector float);
16201
16202 vector float vec_sel (vector float, vector float, vector bool int);
16203 vector float vec_sel (vector float, vector float, vector unsigned int);
16204 vector signed int vec_sel (vector signed int,
16205 vector signed int,
16206 vector bool int);
16207 vector signed int vec_sel (vector signed int,
16208 vector signed int,
16209 vector unsigned int);
16210 vector unsigned int vec_sel (vector unsigned int,
16211 vector unsigned int,
16212 vector bool int);
16213 vector unsigned int vec_sel (vector unsigned int,
16214 vector unsigned int,
16215 vector unsigned int);
16216 vector bool int vec_sel (vector bool int,
16217 vector bool int,
16218 vector bool int);
16219 vector bool int vec_sel (vector bool int,
16220 vector bool int,
16221 vector unsigned int);
16222 vector signed short vec_sel (vector signed short,
16223 vector signed short,
16224 vector bool short);
16225 vector signed short vec_sel (vector signed short,
16226 vector signed short,
16227 vector unsigned short);
16228 vector unsigned short vec_sel (vector unsigned short,
16229 vector unsigned short,
16230 vector bool short);
16231 vector unsigned short vec_sel (vector unsigned short,
16232 vector unsigned short,
16233 vector unsigned short);
16234 vector bool short vec_sel (vector bool short,
16235 vector bool short,
16236 vector bool short);
16237 vector bool short vec_sel (vector bool short,
16238 vector bool short,
16239 vector unsigned short);
16240 vector signed char vec_sel (vector signed char,
16241 vector signed char,
16242 vector bool char);
16243 vector signed char vec_sel (vector signed char,
16244 vector signed char,
16245 vector unsigned char);
16246 vector unsigned char vec_sel (vector unsigned char,
16247 vector unsigned char,
16248 vector bool char);
16249 vector unsigned char vec_sel (vector unsigned char,
16250 vector unsigned char,
16251 vector unsigned char);
16252 vector bool char vec_sel (vector bool char,
16253 vector bool char,
16254 vector bool char);
16255 vector bool char vec_sel (vector bool char,
16256 vector bool char,
16257 vector unsigned char);
16258
16259 vector signed char vec_sl (vector signed char,
16260 vector unsigned char);
16261 vector unsigned char vec_sl (vector unsigned char,
16262 vector unsigned char);
16263 vector signed short vec_sl (vector signed short, vector unsigned short);
16264 vector unsigned short vec_sl (vector unsigned short,
16265 vector unsigned short);
16266 vector signed int vec_sl (vector signed int, vector unsigned int);
16267 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
16268
16269 vector signed int vec_vslw (vector signed int, vector unsigned int);
16270 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
16271
16272 vector signed short vec_vslh (vector signed short,
16273 vector unsigned short);
16274 vector unsigned short vec_vslh (vector unsigned short,
16275 vector unsigned short);
16276
16277 vector signed char vec_vslb (vector signed char, vector unsigned char);
16278 vector unsigned char vec_vslb (vector unsigned char,
16279 vector unsigned char);
16280
16281 vector float vec_sld (vector float, vector float, const int);
16282 vector signed int vec_sld (vector signed int,
16283 vector signed int,
16284 const int);
16285 vector unsigned int vec_sld (vector unsigned int,
16286 vector unsigned int,
16287 const int);
16288 vector bool int vec_sld (vector bool int,
16289 vector bool int,
16290 const int);
16291 vector signed short vec_sld (vector signed short,
16292 vector signed short,
16293 const int);
16294 vector unsigned short vec_sld (vector unsigned short,
16295 vector unsigned short,
16296 const int);
16297 vector bool short vec_sld (vector bool short,
16298 vector bool short,
16299 const int);
16300 vector pixel vec_sld (vector pixel,
16301 vector pixel,
16302 const int);
16303 vector signed char vec_sld (vector signed char,
16304 vector signed char,
16305 const int);
16306 vector unsigned char vec_sld (vector unsigned char,
16307 vector unsigned char,
16308 const int);
16309 vector bool char vec_sld (vector bool char,
16310 vector bool char,
16311 const int);
16312
16313 vector signed int vec_sll (vector signed int,
16314 vector unsigned int);
16315 vector signed int vec_sll (vector signed int,
16316 vector unsigned short);
16317 vector signed int vec_sll (vector signed int,
16318 vector unsigned char);
16319 vector unsigned int vec_sll (vector unsigned int,
16320 vector unsigned int);
16321 vector unsigned int vec_sll (vector unsigned int,
16322 vector unsigned short);
16323 vector unsigned int vec_sll (vector unsigned int,
16324 vector unsigned char);
16325 vector bool int vec_sll (vector bool int,
16326 vector unsigned int);
16327 vector bool int vec_sll (vector bool int,
16328 vector unsigned short);
16329 vector bool int vec_sll (vector bool int,
16330 vector unsigned char);
16331 vector signed short vec_sll (vector signed short,
16332 vector unsigned int);
16333 vector signed short vec_sll (vector signed short,
16334 vector unsigned short);
16335 vector signed short vec_sll (vector signed short,
16336 vector unsigned char);
16337 vector unsigned short vec_sll (vector unsigned short,
16338 vector unsigned int);
16339 vector unsigned short vec_sll (vector unsigned short,
16340 vector unsigned short);
16341 vector unsigned short vec_sll (vector unsigned short,
16342 vector unsigned char);
16343 vector bool short vec_sll (vector bool short, vector unsigned int);
16344 vector bool short vec_sll (vector bool short, vector unsigned short);
16345 vector bool short vec_sll (vector bool short, vector unsigned char);
16346 vector pixel vec_sll (vector pixel, vector unsigned int);
16347 vector pixel vec_sll (vector pixel, vector unsigned short);
16348 vector pixel vec_sll (vector pixel, vector unsigned char);
16349 vector signed char vec_sll (vector signed char, vector unsigned int);
16350 vector signed char vec_sll (vector signed char, vector unsigned short);
16351 vector signed char vec_sll (vector signed char, vector unsigned char);
16352 vector unsigned char vec_sll (vector unsigned char,
16353 vector unsigned int);
16354 vector unsigned char vec_sll (vector unsigned char,
16355 vector unsigned short);
16356 vector unsigned char vec_sll (vector unsigned char,
16357 vector unsigned char);
16358 vector bool char vec_sll (vector bool char, vector unsigned int);
16359 vector bool char vec_sll (vector bool char, vector unsigned short);
16360 vector bool char vec_sll (vector bool char, vector unsigned char);
16361
16362 vector float vec_slo (vector float, vector signed char);
16363 vector float vec_slo (vector float, vector unsigned char);
16364 vector signed int vec_slo (vector signed int, vector signed char);
16365 vector signed int vec_slo (vector signed int, vector unsigned char);
16366 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16367 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16368 vector signed short vec_slo (vector signed short, vector signed char);
16369 vector signed short vec_slo (vector signed short, vector unsigned char);
16370 vector unsigned short vec_slo (vector unsigned short,
16371 vector signed char);
16372 vector unsigned short vec_slo (vector unsigned short,
16373 vector unsigned char);
16374 vector pixel vec_slo (vector pixel, vector signed char);
16375 vector pixel vec_slo (vector pixel, vector unsigned char);
16376 vector signed char vec_slo (vector signed char, vector signed char);
16377 vector signed char vec_slo (vector signed char, vector unsigned char);
16378 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16379 vector unsigned char vec_slo (vector unsigned char,
16380 vector unsigned char);
16381
16382 vector signed char vec_splat (vector signed char, const int);
16383 vector unsigned char vec_splat (vector unsigned char, const int);
16384 vector bool char vec_splat (vector bool char, const int);
16385 vector signed short vec_splat (vector signed short, const int);
16386 vector unsigned short vec_splat (vector unsigned short, const int);
16387 vector bool short vec_splat (vector bool short, const int);
16388 vector pixel vec_splat (vector pixel, const int);
16389 vector float vec_splat (vector float, const int);
16390 vector signed int vec_splat (vector signed int, const int);
16391 vector unsigned int vec_splat (vector unsigned int, const int);
16392 vector bool int vec_splat (vector bool int, const int);
16393 vector signed long vec_splat (vector signed long, const int);
16394 vector unsigned long vec_splat (vector unsigned long, const int);
16395
16396 vector signed char vec_splats (signed char);
16397 vector unsigned char vec_splats (unsigned char);
16398 vector signed short vec_splats (signed short);
16399 vector unsigned short vec_splats (unsigned short);
16400 vector signed int vec_splats (signed int);
16401 vector unsigned int vec_splats (unsigned int);
16402 vector float vec_splats (float);
16403
16404 vector float vec_vspltw (vector float, const int);
16405 vector signed int vec_vspltw (vector signed int, const int);
16406 vector unsigned int vec_vspltw (vector unsigned int, const int);
16407 vector bool int vec_vspltw (vector bool int, const int);
16408
16409 vector bool short vec_vsplth (vector bool short, const int);
16410 vector signed short vec_vsplth (vector signed short, const int);
16411 vector unsigned short vec_vsplth (vector unsigned short, const int);
16412 vector pixel vec_vsplth (vector pixel, const int);
16413
16414 vector signed char vec_vspltb (vector signed char, const int);
16415 vector unsigned char vec_vspltb (vector unsigned char, const int);
16416 vector bool char vec_vspltb (vector bool char, const int);
16417
16418 vector signed char vec_splat_s8 (const int);
16419
16420 vector signed short vec_splat_s16 (const int);
16421
16422 vector signed int vec_splat_s32 (const int);
16423
16424 vector unsigned char vec_splat_u8 (const int);
16425
16426 vector unsigned short vec_splat_u16 (const int);
16427
16428 vector unsigned int vec_splat_u32 (const int);
16429
16430 vector signed char vec_sr (vector signed char, vector unsigned char);
16431 vector unsigned char vec_sr (vector unsigned char,
16432 vector unsigned char);
16433 vector signed short vec_sr (vector signed short,
16434 vector unsigned short);
16435 vector unsigned short vec_sr (vector unsigned short,
16436 vector unsigned short);
16437 vector signed int vec_sr (vector signed int, vector unsigned int);
16438 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16439
16440 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16441 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16442
16443 vector signed short vec_vsrh (vector signed short,
16444 vector unsigned short);
16445 vector unsigned short vec_vsrh (vector unsigned short,
16446 vector unsigned short);
16447
16448 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16449 vector unsigned char vec_vsrb (vector unsigned char,
16450 vector unsigned char);
16451
16452 vector signed char vec_sra (vector signed char, vector unsigned char);
16453 vector unsigned char vec_sra (vector unsigned char,
16454 vector unsigned char);
16455 vector signed short vec_sra (vector signed short,
16456 vector unsigned short);
16457 vector unsigned short vec_sra (vector unsigned short,
16458 vector unsigned short);
16459 vector signed int vec_sra (vector signed int, vector unsigned int);
16460 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16461
16462 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16463 vector unsigned int vec_vsraw (vector unsigned int,
16464 vector unsigned int);
16465
16466 vector signed short vec_vsrah (vector signed short,
16467 vector unsigned short);
16468 vector unsigned short vec_vsrah (vector unsigned short,
16469 vector unsigned short);
16470
16471 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16472 vector unsigned char vec_vsrab (vector unsigned char,
16473 vector unsigned char);
16474
16475 vector signed int vec_srl (vector signed int, vector unsigned int);
16476 vector signed int vec_srl (vector signed int, vector unsigned short);
16477 vector signed int vec_srl (vector signed int, vector unsigned char);
16478 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16479 vector unsigned int vec_srl (vector unsigned int,
16480 vector unsigned short);
16481 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16482 vector bool int vec_srl (vector bool int, vector unsigned int);
16483 vector bool int vec_srl (vector bool int, vector unsigned short);
16484 vector bool int vec_srl (vector bool int, vector unsigned char);
16485 vector signed short vec_srl (vector signed short, vector unsigned int);
16486 vector signed short vec_srl (vector signed short,
16487 vector unsigned short);
16488 vector signed short vec_srl (vector signed short, vector unsigned char);
16489 vector unsigned short vec_srl (vector unsigned short,
16490 vector unsigned int);
16491 vector unsigned short vec_srl (vector unsigned short,
16492 vector unsigned short);
16493 vector unsigned short vec_srl (vector unsigned short,
16494 vector unsigned char);
16495 vector bool short vec_srl (vector bool short, vector unsigned int);
16496 vector bool short vec_srl (vector bool short, vector unsigned short);
16497 vector bool short vec_srl (vector bool short, vector unsigned char);
16498 vector pixel vec_srl (vector pixel, vector unsigned int);
16499 vector pixel vec_srl (vector pixel, vector unsigned short);
16500 vector pixel vec_srl (vector pixel, vector unsigned char);
16501 vector signed char vec_srl (vector signed char, vector unsigned int);
16502 vector signed char vec_srl (vector signed char, vector unsigned short);
16503 vector signed char vec_srl (vector signed char, vector unsigned char);
16504 vector unsigned char vec_srl (vector unsigned char,
16505 vector unsigned int);
16506 vector unsigned char vec_srl (vector unsigned char,
16507 vector unsigned short);
16508 vector unsigned char vec_srl (vector unsigned char,
16509 vector unsigned char);
16510 vector bool char vec_srl (vector bool char, vector unsigned int);
16511 vector bool char vec_srl (vector bool char, vector unsigned short);
16512 vector bool char vec_srl (vector bool char, vector unsigned char);
16513
16514 vector float vec_sro (vector float, vector signed char);
16515 vector float vec_sro (vector float, vector unsigned char);
16516 vector signed int vec_sro (vector signed int, vector signed char);
16517 vector signed int vec_sro (vector signed int, vector unsigned char);
16518 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16519 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16520 vector signed short vec_sro (vector signed short, vector signed char);
16521 vector signed short vec_sro (vector signed short, vector unsigned char);
16522 vector unsigned short vec_sro (vector unsigned short,
16523 vector signed char);
16524 vector unsigned short vec_sro (vector unsigned short,
16525 vector unsigned char);
16526 vector pixel vec_sro (vector pixel, vector signed char);
16527 vector pixel vec_sro (vector pixel, vector unsigned char);
16528 vector signed char vec_sro (vector signed char, vector signed char);
16529 vector signed char vec_sro (vector signed char, vector unsigned char);
16530 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16531 vector unsigned char vec_sro (vector unsigned char,
16532 vector unsigned char);
16533
16534 void vec_st (vector float, int, vector float *);
16535 void vec_st (vector float, int, float *);
16536 void vec_st (vector signed int, int, vector signed int *);
16537 void vec_st (vector signed int, int, int *);
16538 void vec_st (vector unsigned int, int, vector unsigned int *);
16539 void vec_st (vector unsigned int, int, unsigned int *);
16540 void vec_st (vector bool int, int, vector bool int *);
16541 void vec_st (vector bool int, int, unsigned int *);
16542 void vec_st (vector bool int, int, int *);
16543 void vec_st (vector signed short, int, vector signed short *);
16544 void vec_st (vector signed short, int, short *);
16545 void vec_st (vector unsigned short, int, vector unsigned short *);
16546 void vec_st (vector unsigned short, int, unsigned short *);
16547 void vec_st (vector bool short, int, vector bool short *);
16548 void vec_st (vector bool short, int, unsigned short *);
16549 void vec_st (vector pixel, int, vector pixel *);
16550 void vec_st (vector pixel, int, unsigned short *);
16551 void vec_st (vector pixel, int, short *);
16552 void vec_st (vector bool short, int, short *);
16553 void vec_st (vector signed char, int, vector signed char *);
16554 void vec_st (vector signed char, int, signed char *);
16555 void vec_st (vector unsigned char, int, vector unsigned char *);
16556 void vec_st (vector unsigned char, int, unsigned char *);
16557 void vec_st (vector bool char, int, vector bool char *);
16558 void vec_st (vector bool char, int, unsigned char *);
16559 void vec_st (vector bool char, int, signed char *);
16560
16561 void vec_ste (vector signed char, int, signed char *);
16562 void vec_ste (vector unsigned char, int, unsigned char *);
16563 void vec_ste (vector bool char, int, signed char *);
16564 void vec_ste (vector bool char, int, unsigned char *);
16565 void vec_ste (vector signed short, int, short *);
16566 void vec_ste (vector unsigned short, int, unsigned short *);
16567 void vec_ste (vector bool short, int, short *);
16568 void vec_ste (vector bool short, int, unsigned short *);
16569 void vec_ste (vector pixel, int, short *);
16570 void vec_ste (vector pixel, int, unsigned short *);
16571 void vec_ste (vector float, int, float *);
16572 void vec_ste (vector signed int, int, int *);
16573 void vec_ste (vector unsigned int, int, unsigned int *);
16574 void vec_ste (vector bool int, int, int *);
16575 void vec_ste (vector bool int, int, unsigned int *);
16576
16577 void vec_stvewx (vector float, int, float *);
16578 void vec_stvewx (vector signed int, int, int *);
16579 void vec_stvewx (vector unsigned int, int, unsigned int *);
16580 void vec_stvewx (vector bool int, int, int *);
16581 void vec_stvewx (vector bool int, int, unsigned int *);
16582
16583 void vec_stvehx (vector signed short, int, short *);
16584 void vec_stvehx (vector unsigned short, int, unsigned short *);
16585 void vec_stvehx (vector bool short, int, short *);
16586 void vec_stvehx (vector bool short, int, unsigned short *);
16587 void vec_stvehx (vector pixel, int, short *);
16588 void vec_stvehx (vector pixel, int, unsigned short *);
16589
16590 void vec_stvebx (vector signed char, int, signed char *);
16591 void vec_stvebx (vector unsigned char, int, unsigned char *);
16592 void vec_stvebx (vector bool char, int, signed char *);
16593 void vec_stvebx (vector bool char, int, unsigned char *);
16594
16595 void vec_stl (vector float, int, vector float *);
16596 void vec_stl (vector float, int, float *);
16597 void vec_stl (vector signed int, int, vector signed int *);
16598 void vec_stl (vector signed int, int, int *);
16599 void vec_stl (vector unsigned int, int, vector unsigned int *);
16600 void vec_stl (vector unsigned int, int, unsigned int *);
16601 void vec_stl (vector bool int, int, vector bool int *);
16602 void vec_stl (vector bool int, int, unsigned int *);
16603 void vec_stl (vector bool int, int, int *);
16604 void vec_stl (vector signed short, int, vector signed short *);
16605 void vec_stl (vector signed short, int, short *);
16606 void vec_stl (vector unsigned short, int, vector unsigned short *);
16607 void vec_stl (vector unsigned short, int, unsigned short *);
16608 void vec_stl (vector bool short, int, vector bool short *);
16609 void vec_stl (vector bool short, int, unsigned short *);
16610 void vec_stl (vector bool short, int, short *);
16611 void vec_stl (vector pixel, int, vector pixel *);
16612 void vec_stl (vector pixel, int, unsigned short *);
16613 void vec_stl (vector pixel, int, short *);
16614 void vec_stl (vector signed char, int, vector signed char *);
16615 void vec_stl (vector signed char, int, signed char *);
16616 void vec_stl (vector unsigned char, int, vector unsigned char *);
16617 void vec_stl (vector unsigned char, int, unsigned char *);
16618 void vec_stl (vector bool char, int, vector bool char *);
16619 void vec_stl (vector bool char, int, unsigned char *);
16620 void vec_stl (vector bool char, int, signed char *);
16621
16622 vector signed char vec_sub (vector bool char, vector signed char);
16623 vector signed char vec_sub (vector signed char, vector bool char);
16624 vector signed char vec_sub (vector signed char, vector signed char);
16625 vector unsigned char vec_sub (vector bool char, vector unsigned char);
16626 vector unsigned char vec_sub (vector unsigned char, vector bool char);
16627 vector unsigned char vec_sub (vector unsigned char,
16628 vector unsigned char);
16629 vector signed short vec_sub (vector bool short, vector signed short);
16630 vector signed short vec_sub (vector signed short, vector bool short);
16631 vector signed short vec_sub (vector signed short, vector signed short);
16632 vector unsigned short vec_sub (vector bool short,
16633 vector unsigned short);
16634 vector unsigned short vec_sub (vector unsigned short,
16635 vector bool short);
16636 vector unsigned short vec_sub (vector unsigned short,
16637 vector unsigned short);
16638 vector signed int vec_sub (vector bool int, vector signed int);
16639 vector signed int vec_sub (vector signed int, vector bool int);
16640 vector signed int vec_sub (vector signed int, vector signed int);
16641 vector unsigned int vec_sub (vector bool int, vector unsigned int);
16642 vector unsigned int vec_sub (vector unsigned int, vector bool int);
16643 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
16644 vector float vec_sub (vector float, vector float);
16645
16646 vector float vec_vsubfp (vector float, vector float);
16647
16648 vector signed int vec_vsubuwm (vector bool int, vector signed int);
16649 vector signed int vec_vsubuwm (vector signed int, vector bool int);
16650 vector signed int vec_vsubuwm (vector signed int, vector signed int);
16651 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
16652 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
16653 vector unsigned int vec_vsubuwm (vector unsigned int,
16654 vector unsigned int);
16655
16656 vector signed short vec_vsubuhm (vector bool short,
16657 vector signed short);
16658 vector signed short vec_vsubuhm (vector signed short,
16659 vector bool short);
16660 vector signed short vec_vsubuhm (vector signed short,
16661 vector signed short);
16662 vector unsigned short vec_vsubuhm (vector bool short,
16663 vector unsigned short);
16664 vector unsigned short vec_vsubuhm (vector unsigned short,
16665 vector bool short);
16666 vector unsigned short vec_vsubuhm (vector unsigned short,
16667 vector unsigned short);
16668
16669 vector signed char vec_vsububm (vector bool char, vector signed char);
16670 vector signed char vec_vsububm (vector signed char, vector bool char);
16671 vector signed char vec_vsububm (vector signed char, vector signed char);
16672 vector unsigned char vec_vsububm (vector bool char,
16673 vector unsigned char);
16674 vector unsigned char vec_vsububm (vector unsigned char,
16675 vector bool char);
16676 vector unsigned char vec_vsububm (vector unsigned char,
16677 vector unsigned char);
16678
16679 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
16680
16681 vector unsigned char vec_subs (vector bool char, vector unsigned char);
16682 vector unsigned char vec_subs (vector unsigned char, vector bool char);
16683 vector unsigned char vec_subs (vector unsigned char,
16684 vector unsigned char);
16685 vector signed char vec_subs (vector bool char, vector signed char);
16686 vector signed char vec_subs (vector signed char, vector bool char);
16687 vector signed char vec_subs (vector signed char, vector signed char);
16688 vector unsigned short vec_subs (vector bool short,
16689 vector unsigned short);
16690 vector unsigned short vec_subs (vector unsigned short,
16691 vector bool short);
16692 vector unsigned short vec_subs (vector unsigned short,
16693 vector unsigned short);
16694 vector signed short vec_subs (vector bool short, vector signed short);
16695 vector signed short vec_subs (vector signed short, vector bool short);
16696 vector signed short vec_subs (vector signed short, vector signed short);
16697 vector unsigned int vec_subs (vector bool int, vector unsigned int);
16698 vector unsigned int vec_subs (vector unsigned int, vector bool int);
16699 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
16700 vector signed int vec_subs (vector bool int, vector signed int);
16701 vector signed int vec_subs (vector signed int, vector bool int);
16702 vector signed int vec_subs (vector signed int, vector signed int);
16703
16704 vector signed int vec_vsubsws (vector bool int, vector signed int);
16705 vector signed int vec_vsubsws (vector signed int, vector bool int);
16706 vector signed int vec_vsubsws (vector signed int, vector signed int);
16707
16708 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
16709 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
16710 vector unsigned int vec_vsubuws (vector unsigned int,
16711 vector unsigned int);
16712
16713 vector signed short vec_vsubshs (vector bool short,
16714 vector signed short);
16715 vector signed short vec_vsubshs (vector signed short,
16716 vector bool short);
16717 vector signed short vec_vsubshs (vector signed short,
16718 vector signed short);
16719
16720 vector unsigned short vec_vsubuhs (vector bool short,
16721 vector unsigned short);
16722 vector unsigned short vec_vsubuhs (vector unsigned short,
16723 vector bool short);
16724 vector unsigned short vec_vsubuhs (vector unsigned short,
16725 vector unsigned short);
16726
16727 vector signed char vec_vsubsbs (vector bool char, vector signed char);
16728 vector signed char vec_vsubsbs (vector signed char, vector bool char);
16729 vector signed char vec_vsubsbs (vector signed char, vector signed char);
16730
16731 vector unsigned char vec_vsububs (vector bool char,
16732 vector unsigned char);
16733 vector unsigned char vec_vsububs (vector unsigned char,
16734 vector bool char);
16735 vector unsigned char vec_vsububs (vector unsigned char,
16736 vector unsigned char);
16737
16738 vector unsigned int vec_sum4s (vector unsigned char,
16739 vector unsigned int);
16740 vector signed int vec_sum4s (vector signed char, vector signed int);
16741 vector signed int vec_sum4s (vector signed short, vector signed int);
16742
16743 vector signed int vec_vsum4shs (vector signed short, vector signed int);
16744
16745 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
16746
16747 vector unsigned int vec_vsum4ubs (vector unsigned char,
16748 vector unsigned int);
16749
16750 vector signed int vec_sum2s (vector signed int, vector signed int);
16751
16752 vector signed int vec_sums (vector signed int, vector signed int);
16753
16754 vector float vec_trunc (vector float);
16755
16756 vector signed short vec_unpackh (vector signed char);
16757 vector bool short vec_unpackh (vector bool char);
16758 vector signed int vec_unpackh (vector signed short);
16759 vector bool int vec_unpackh (vector bool short);
16760 vector unsigned int vec_unpackh (vector pixel);
16761
16762 vector bool int vec_vupkhsh (vector bool short);
16763 vector signed int vec_vupkhsh (vector signed short);
16764
16765 vector unsigned int vec_vupkhpx (vector pixel);
16766
16767 vector bool short vec_vupkhsb (vector bool char);
16768 vector signed short vec_vupkhsb (vector signed char);
16769
16770 vector signed short vec_unpackl (vector signed char);
16771 vector bool short vec_unpackl (vector bool char);
16772 vector unsigned int vec_unpackl (vector pixel);
16773 vector signed int vec_unpackl (vector signed short);
16774 vector bool int vec_unpackl (vector bool short);
16775
16776 vector unsigned int vec_vupklpx (vector pixel);
16777
16778 vector bool int vec_vupklsh (vector bool short);
16779 vector signed int vec_vupklsh (vector signed short);
16780
16781 vector bool short vec_vupklsb (vector bool char);
16782 vector signed short vec_vupklsb (vector signed char);
16783
16784 vector float vec_xor (vector float, vector float);
16785 vector float vec_xor (vector float, vector bool int);
16786 vector float vec_xor (vector bool int, vector float);
16787 vector bool int vec_xor (vector bool int, vector bool int);
16788 vector signed int vec_xor (vector bool int, vector signed int);
16789 vector signed int vec_xor (vector signed int, vector bool int);
16790 vector signed int vec_xor (vector signed int, vector signed int);
16791 vector unsigned int vec_xor (vector bool int, vector unsigned int);
16792 vector unsigned int vec_xor (vector unsigned int, vector bool int);
16793 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
16794 vector bool short vec_xor (vector bool short, vector bool short);
16795 vector signed short vec_xor (vector bool short, vector signed short);
16796 vector signed short vec_xor (vector signed short, vector bool short);
16797 vector signed short vec_xor (vector signed short, vector signed short);
16798 vector unsigned short vec_xor (vector bool short,
16799 vector unsigned short);
16800 vector unsigned short vec_xor (vector unsigned short,
16801 vector bool short);
16802 vector unsigned short vec_xor (vector unsigned short,
16803 vector unsigned short);
16804 vector signed char vec_xor (vector bool char, vector signed char);
16805 vector bool char vec_xor (vector bool char, vector bool char);
16806 vector signed char vec_xor (vector signed char, vector bool char);
16807 vector signed char vec_xor (vector signed char, vector signed char);
16808 vector unsigned char vec_xor (vector bool char, vector unsigned char);
16809 vector unsigned char vec_xor (vector unsigned char, vector bool char);
16810 vector unsigned char vec_xor (vector unsigned char,
16811 vector unsigned char);
16812
16813 int vec_all_eq (vector signed char, vector bool char);
16814 int vec_all_eq (vector signed char, vector signed char);
16815 int vec_all_eq (vector unsigned char, vector bool char);
16816 int vec_all_eq (vector unsigned char, vector unsigned char);
16817 int vec_all_eq (vector bool char, vector bool char);
16818 int vec_all_eq (vector bool char, vector unsigned char);
16819 int vec_all_eq (vector bool char, vector signed char);
16820 int vec_all_eq (vector signed short, vector bool short);
16821 int vec_all_eq (vector signed short, vector signed short);
16822 int vec_all_eq (vector unsigned short, vector bool short);
16823 int vec_all_eq (vector unsigned short, vector unsigned short);
16824 int vec_all_eq (vector bool short, vector bool short);
16825 int vec_all_eq (vector bool short, vector unsigned short);
16826 int vec_all_eq (vector bool short, vector signed short);
16827 int vec_all_eq (vector pixel, vector pixel);
16828 int vec_all_eq (vector signed int, vector bool int);
16829 int vec_all_eq (vector signed int, vector signed int);
16830 int vec_all_eq (vector unsigned int, vector bool int);
16831 int vec_all_eq (vector unsigned int, vector unsigned int);
16832 int vec_all_eq (vector bool int, vector bool int);
16833 int vec_all_eq (vector bool int, vector unsigned int);
16834 int vec_all_eq (vector bool int, vector signed int);
16835 int vec_all_eq (vector float, vector float);
16836
16837 int vec_all_ge (vector bool char, vector unsigned char);
16838 int vec_all_ge (vector unsigned char, vector bool char);
16839 int vec_all_ge (vector unsigned char, vector unsigned char);
16840 int vec_all_ge (vector bool char, vector signed char);
16841 int vec_all_ge (vector signed char, vector bool char);
16842 int vec_all_ge (vector signed char, vector signed char);
16843 int vec_all_ge (vector bool short, vector unsigned short);
16844 int vec_all_ge (vector unsigned short, vector bool short);
16845 int vec_all_ge (vector unsigned short, vector unsigned short);
16846 int vec_all_ge (vector signed short, vector signed short);
16847 int vec_all_ge (vector bool short, vector signed short);
16848 int vec_all_ge (vector signed short, vector bool short);
16849 int vec_all_ge (vector bool int, vector unsigned int);
16850 int vec_all_ge (vector unsigned int, vector bool int);
16851 int vec_all_ge (vector unsigned int, vector unsigned int);
16852 int vec_all_ge (vector bool int, vector signed int);
16853 int vec_all_ge (vector signed int, vector bool int);
16854 int vec_all_ge (vector signed int, vector signed int);
16855 int vec_all_ge (vector float, vector float);
16856
16857 int vec_all_gt (vector bool char, vector unsigned char);
16858 int vec_all_gt (vector unsigned char, vector bool char);
16859 int vec_all_gt (vector unsigned char, vector unsigned char);
16860 int vec_all_gt (vector bool char, vector signed char);
16861 int vec_all_gt (vector signed char, vector bool char);
16862 int vec_all_gt (vector signed char, vector signed char);
16863 int vec_all_gt (vector bool short, vector unsigned short);
16864 int vec_all_gt (vector unsigned short, vector bool short);
16865 int vec_all_gt (vector unsigned short, vector unsigned short);
16866 int vec_all_gt (vector bool short, vector signed short);
16867 int vec_all_gt (vector signed short, vector bool short);
16868 int vec_all_gt (vector signed short, vector signed short);
16869 int vec_all_gt (vector bool int, vector unsigned int);
16870 int vec_all_gt (vector unsigned int, vector bool int);
16871 int vec_all_gt (vector unsigned int, vector unsigned int);
16872 int vec_all_gt (vector bool int, vector signed int);
16873 int vec_all_gt (vector signed int, vector bool int);
16874 int vec_all_gt (vector signed int, vector signed int);
16875 int vec_all_gt (vector float, vector float);
16876
16877 int vec_all_in (vector float, vector float);
16878
16879 int vec_all_le (vector bool char, vector unsigned char);
16880 int vec_all_le (vector unsigned char, vector bool char);
16881 int vec_all_le (vector unsigned char, vector unsigned char);
16882 int vec_all_le (vector bool char, vector signed char);
16883 int vec_all_le (vector signed char, vector bool char);
16884 int vec_all_le (vector signed char, vector signed char);
16885 int vec_all_le (vector bool short, vector unsigned short);
16886 int vec_all_le (vector unsigned short, vector bool short);
16887 int vec_all_le (vector unsigned short, vector unsigned short);
16888 int vec_all_le (vector bool short, vector signed short);
16889 int vec_all_le (vector signed short, vector bool short);
16890 int vec_all_le (vector signed short, vector signed short);
16891 int vec_all_le (vector bool int, vector unsigned int);
16892 int vec_all_le (vector unsigned int, vector bool int);
16893 int vec_all_le (vector unsigned int, vector unsigned int);
16894 int vec_all_le (vector bool int, vector signed int);
16895 int vec_all_le (vector signed int, vector bool int);
16896 int vec_all_le (vector signed int, vector signed int);
16897 int vec_all_le (vector float, vector float);
16898
16899 int vec_all_lt (vector bool char, vector unsigned char);
16900 int vec_all_lt (vector unsigned char, vector bool char);
16901 int vec_all_lt (vector unsigned char, vector unsigned char);
16902 int vec_all_lt (vector bool char, vector signed char);
16903 int vec_all_lt (vector signed char, vector bool char);
16904 int vec_all_lt (vector signed char, vector signed char);
16905 int vec_all_lt (vector bool short, vector unsigned short);
16906 int vec_all_lt (vector unsigned short, vector bool short);
16907 int vec_all_lt (vector unsigned short, vector unsigned short);
16908 int vec_all_lt (vector bool short, vector signed short);
16909 int vec_all_lt (vector signed short, vector bool short);
16910 int vec_all_lt (vector signed short, vector signed short);
16911 int vec_all_lt (vector bool int, vector unsigned int);
16912 int vec_all_lt (vector unsigned int, vector bool int);
16913 int vec_all_lt (vector unsigned int, vector unsigned int);
16914 int vec_all_lt (vector bool int, vector signed int);
16915 int vec_all_lt (vector signed int, vector bool int);
16916 int vec_all_lt (vector signed int, vector signed int);
16917 int vec_all_lt (vector float, vector float);
16918
16919 int vec_all_nan (vector float);
16920
16921 int vec_all_ne (vector signed char, vector bool char);
16922 int vec_all_ne (vector signed char, vector signed char);
16923 int vec_all_ne (vector unsigned char, vector bool char);
16924 int vec_all_ne (vector unsigned char, vector unsigned char);
16925 int vec_all_ne (vector bool char, vector bool char);
16926 int vec_all_ne (vector bool char, vector unsigned char);
16927 int vec_all_ne (vector bool char, vector signed char);
16928 int vec_all_ne (vector signed short, vector bool short);
16929 int vec_all_ne (vector signed short, vector signed short);
16930 int vec_all_ne (vector unsigned short, vector bool short);
16931 int vec_all_ne (vector unsigned short, vector unsigned short);
16932 int vec_all_ne (vector bool short, vector bool short);
16933 int vec_all_ne (vector bool short, vector unsigned short);
16934 int vec_all_ne (vector bool short, vector signed short);
16935 int vec_all_ne (vector pixel, vector pixel);
16936 int vec_all_ne (vector signed int, vector bool int);
16937 int vec_all_ne (vector signed int, vector signed int);
16938 int vec_all_ne (vector unsigned int, vector bool int);
16939 int vec_all_ne (vector unsigned int, vector unsigned int);
16940 int vec_all_ne (vector bool int, vector bool int);
16941 int vec_all_ne (vector bool int, vector unsigned int);
16942 int vec_all_ne (vector bool int, vector signed int);
16943 int vec_all_ne (vector float, vector float);
16944
16945 int vec_all_nge (vector float, vector float);
16946
16947 int vec_all_ngt (vector float, vector float);
16948
16949 int vec_all_nle (vector float, vector float);
16950
16951 int vec_all_nlt (vector float, vector float);
16952
16953 int vec_all_numeric (vector float);
16954
16955 int vec_any_eq (vector signed char, vector bool char);
16956 int vec_any_eq (vector signed char, vector signed char);
16957 int vec_any_eq (vector unsigned char, vector bool char);
16958 int vec_any_eq (vector unsigned char, vector unsigned char);
16959 int vec_any_eq (vector bool char, vector bool char);
16960 int vec_any_eq (vector bool char, vector unsigned char);
16961 int vec_any_eq (vector bool char, vector signed char);
16962 int vec_any_eq (vector signed short, vector bool short);
16963 int vec_any_eq (vector signed short, vector signed short);
16964 int vec_any_eq (vector unsigned short, vector bool short);
16965 int vec_any_eq (vector unsigned short, vector unsigned short);
16966 int vec_any_eq (vector bool short, vector bool short);
16967 int vec_any_eq (vector bool short, vector unsigned short);
16968 int vec_any_eq (vector bool short, vector signed short);
16969 int vec_any_eq (vector pixel, vector pixel);
16970 int vec_any_eq (vector signed int, vector bool int);
16971 int vec_any_eq (vector signed int, vector signed int);
16972 int vec_any_eq (vector unsigned int, vector bool int);
16973 int vec_any_eq (vector unsigned int, vector unsigned int);
16974 int vec_any_eq (vector bool int, vector bool int);
16975 int vec_any_eq (vector bool int, vector unsigned int);
16976 int vec_any_eq (vector bool int, vector signed int);
16977 int vec_any_eq (vector float, vector float);
16978
16979 int vec_any_ge (vector signed char, vector bool char);
16980 int vec_any_ge (vector unsigned char, vector bool char);
16981 int vec_any_ge (vector unsigned char, vector unsigned char);
16982 int vec_any_ge (vector signed char, vector signed char);
16983 int vec_any_ge (vector bool char, vector unsigned char);
16984 int vec_any_ge (vector bool char, vector signed char);
16985 int vec_any_ge (vector unsigned short, vector bool short);
16986 int vec_any_ge (vector unsigned short, vector unsigned short);
16987 int vec_any_ge (vector signed short, vector signed short);
16988 int vec_any_ge (vector signed short, vector bool short);
16989 int vec_any_ge (vector bool short, vector unsigned short);
16990 int vec_any_ge (vector bool short, vector signed short);
16991 int vec_any_ge (vector signed int, vector bool int);
16992 int vec_any_ge (vector unsigned int, vector bool int);
16993 int vec_any_ge (vector unsigned int, vector unsigned int);
16994 int vec_any_ge (vector signed int, vector signed int);
16995 int vec_any_ge (vector bool int, vector unsigned int);
16996 int vec_any_ge (vector bool int, vector signed int);
16997 int vec_any_ge (vector float, vector float);
16998
16999 int vec_any_gt (vector bool char, vector unsigned char);
17000 int vec_any_gt (vector unsigned char, vector bool char);
17001 int vec_any_gt (vector unsigned char, vector unsigned char);
17002 int vec_any_gt (vector bool char, vector signed char);
17003 int vec_any_gt (vector signed char, vector bool char);
17004 int vec_any_gt (vector signed char, vector signed char);
17005 int vec_any_gt (vector bool short, vector unsigned short);
17006 int vec_any_gt (vector unsigned short, vector bool short);
17007 int vec_any_gt (vector unsigned short, vector unsigned short);
17008 int vec_any_gt (vector bool short, vector signed short);
17009 int vec_any_gt (vector signed short, vector bool short);
17010 int vec_any_gt (vector signed short, vector signed short);
17011 int vec_any_gt (vector bool int, vector unsigned int);
17012 int vec_any_gt (vector unsigned int, vector bool int);
17013 int vec_any_gt (vector unsigned int, vector unsigned int);
17014 int vec_any_gt (vector bool int, vector signed int);
17015 int vec_any_gt (vector signed int, vector bool int);
17016 int vec_any_gt (vector signed int, vector signed int);
17017 int vec_any_gt (vector float, vector float);
17018
17019 int vec_any_le (vector bool char, vector unsigned char);
17020 int vec_any_le (vector unsigned char, vector bool char);
17021 int vec_any_le (vector unsigned char, vector unsigned char);
17022 int vec_any_le (vector bool char, vector signed char);
17023 int vec_any_le (vector signed char, vector bool char);
17024 int vec_any_le (vector signed char, vector signed char);
17025 int vec_any_le (vector bool short, vector unsigned short);
17026 int vec_any_le (vector unsigned short, vector bool short);
17027 int vec_any_le (vector unsigned short, vector unsigned short);
17028 int vec_any_le (vector bool short, vector signed short);
17029 int vec_any_le (vector signed short, vector bool short);
17030 int vec_any_le (vector signed short, vector signed short);
17031 int vec_any_le (vector bool int, vector unsigned int);
17032 int vec_any_le (vector unsigned int, vector bool int);
17033 int vec_any_le (vector unsigned int, vector unsigned int);
17034 int vec_any_le (vector bool int, vector signed int);
17035 int vec_any_le (vector signed int, vector bool int);
17036 int vec_any_le (vector signed int, vector signed int);
17037 int vec_any_le (vector float, vector float);
17038
17039 int vec_any_lt (vector bool char, vector unsigned char);
17040 int vec_any_lt (vector unsigned char, vector bool char);
17041 int vec_any_lt (vector unsigned char, vector unsigned char);
17042 int vec_any_lt (vector bool char, vector signed char);
17043 int vec_any_lt (vector signed char, vector bool char);
17044 int vec_any_lt (vector signed char, vector signed char);
17045 int vec_any_lt (vector bool short, vector unsigned short);
17046 int vec_any_lt (vector unsigned short, vector bool short);
17047 int vec_any_lt (vector unsigned short, vector unsigned short);
17048 int vec_any_lt (vector bool short, vector signed short);
17049 int vec_any_lt (vector signed short, vector bool short);
17050 int vec_any_lt (vector signed short, vector signed short);
17051 int vec_any_lt (vector bool int, vector unsigned int);
17052 int vec_any_lt (vector unsigned int, vector bool int);
17053 int vec_any_lt (vector unsigned int, vector unsigned int);
17054 int vec_any_lt (vector bool int, vector signed int);
17055 int vec_any_lt (vector signed int, vector bool int);
17056 int vec_any_lt (vector signed int, vector signed int);
17057 int vec_any_lt (vector float, vector float);
17058
17059 int vec_any_nan (vector float);
17060
17061 int vec_any_ne (vector signed char, vector bool char);
17062 int vec_any_ne (vector signed char, vector signed char);
17063 int vec_any_ne (vector unsigned char, vector bool char);
17064 int vec_any_ne (vector unsigned char, vector unsigned char);
17065 int vec_any_ne (vector bool char, vector bool char);
17066 int vec_any_ne (vector bool char, vector unsigned char);
17067 int vec_any_ne (vector bool char, vector signed char);
17068 int vec_any_ne (vector signed short, vector bool short);
17069 int vec_any_ne (vector signed short, vector signed short);
17070 int vec_any_ne (vector unsigned short, vector bool short);
17071 int vec_any_ne (vector unsigned short, vector unsigned short);
17072 int vec_any_ne (vector bool short, vector bool short);
17073 int vec_any_ne (vector bool short, vector unsigned short);
17074 int vec_any_ne (vector bool short, vector signed short);
17075 int vec_any_ne (vector pixel, vector pixel);
17076 int vec_any_ne (vector signed int, vector bool int);
17077 int vec_any_ne (vector signed int, vector signed int);
17078 int vec_any_ne (vector unsigned int, vector bool int);
17079 int vec_any_ne (vector unsigned int, vector unsigned int);
17080 int vec_any_ne (vector bool int, vector bool int);
17081 int vec_any_ne (vector bool int, vector unsigned int);
17082 int vec_any_ne (vector bool int, vector signed int);
17083 int vec_any_ne (vector float, vector float);
17084
17085 int vec_any_nge (vector float, vector float);
17086
17087 int vec_any_ngt (vector float, vector float);
17088
17089 int vec_any_nle (vector float, vector float);
17090
17091 int vec_any_nlt (vector float, vector float);
17092
17093 int vec_any_numeric (vector float);
17094
17095 int vec_any_out (vector float, vector float);
17096 @end smallexample
17097
17098 If the vector/scalar (VSX) instruction set is available, the following
17099 additional functions are available:
17100
17101 @smallexample
17102 vector double vec_abs (vector double);
17103 vector double vec_add (vector double, vector double);
17104 vector double vec_and (vector double, vector double);
17105 vector double vec_and (vector double, vector bool long);
17106 vector double vec_and (vector bool long, vector double);
17107 vector long vec_and (vector long, vector long);
17108 vector long vec_and (vector long, vector bool long);
17109 vector long vec_and (vector bool long, vector long);
17110 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
17111 vector unsigned long vec_and (vector unsigned long, vector bool long);
17112 vector unsigned long vec_and (vector bool long, vector unsigned long);
17113 vector double vec_andc (vector double, vector double);
17114 vector double vec_andc (vector double, vector bool long);
17115 vector double vec_andc (vector bool long, vector double);
17116 vector long vec_andc (vector long, vector long);
17117 vector long vec_andc (vector long, vector bool long);
17118 vector long vec_andc (vector bool long, vector long);
17119 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
17120 vector unsigned long vec_andc (vector unsigned long, vector bool long);
17121 vector unsigned long vec_andc (vector bool long, vector unsigned long);
17122 vector double vec_ceil (vector double);
17123 vector bool long vec_cmpeq (vector double, vector double);
17124 vector bool long vec_cmpge (vector double, vector double);
17125 vector bool long vec_cmpgt (vector double, vector double);
17126 vector bool long vec_cmple (vector double, vector double);
17127 vector bool long vec_cmplt (vector double, vector double);
17128 vector double vec_cpsgn (vector double, vector double);
17129 vector float vec_div (vector float, vector float);
17130 vector double vec_div (vector double, vector double);
17131 vector long vec_div (vector long, vector long);
17132 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
17133 vector double vec_floor (vector double);
17134 vector double vec_ld (int, const vector double *);
17135 vector double vec_ld (int, const double *);
17136 vector double vec_ldl (int, const vector double *);
17137 vector double vec_ldl (int, const double *);
17138 vector unsigned char vec_lvsl (int, const volatile double *);
17139 vector unsigned char vec_lvsr (int, const volatile double *);
17140 vector double vec_madd (vector double, vector double, vector double);
17141 vector double vec_max (vector double, vector double);
17142 vector signed long vec_mergeh (vector signed long, vector signed long);
17143 vector signed long vec_mergeh (vector signed long, vector bool long);
17144 vector signed long vec_mergeh (vector bool long, vector signed long);
17145 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
17146 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
17147 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
17148 vector signed long vec_mergel (vector signed long, vector signed long);
17149 vector signed long vec_mergel (vector signed long, vector bool long);
17150 vector signed long vec_mergel (vector bool long, vector signed long);
17151 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
17152 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
17153 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
17154 vector double vec_min (vector double, vector double);
17155 vector float vec_msub (vector float, vector float, vector float);
17156 vector double vec_msub (vector double, vector double, vector double);
17157 vector float vec_mul (vector float, vector float);
17158 vector double vec_mul (vector double, vector double);
17159 vector long vec_mul (vector long, vector long);
17160 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
17161 vector float vec_nearbyint (vector float);
17162 vector double vec_nearbyint (vector double);
17163 vector float vec_nmadd (vector float, vector float, vector float);
17164 vector double vec_nmadd (vector double, vector double, vector double);
17165 vector double vec_nmsub (vector double, vector double, vector double);
17166 vector double vec_nor (vector double, vector double);
17167 vector long vec_nor (vector long, vector long);
17168 vector long vec_nor (vector long, vector bool long);
17169 vector long vec_nor (vector bool long, vector long);
17170 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
17171 vector unsigned long vec_nor (vector unsigned long, vector bool long);
17172 vector unsigned long vec_nor (vector bool long, vector unsigned long);
17173 vector double vec_or (vector double, vector double);
17174 vector double vec_or (vector double, vector bool long);
17175 vector double vec_or (vector bool long, vector double);
17176 vector long vec_or (vector long, vector long);
17177 vector long vec_or (vector long, vector bool long);
17178 vector long vec_or (vector bool long, vector long);
17179 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
17180 vector unsigned long vec_or (vector unsigned long, vector bool long);
17181 vector unsigned long vec_or (vector bool long, vector unsigned long);
17182 vector double vec_perm (vector double, vector double, vector unsigned char);
17183 vector long vec_perm (vector long, vector long, vector unsigned char);
17184 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
17185 vector unsigned char);
17186 vector double vec_rint (vector double);
17187 vector double vec_recip (vector double, vector double);
17188 vector double vec_rsqrt (vector double);
17189 vector double vec_rsqrte (vector double);
17190 vector double vec_sel (vector double, vector double, vector bool long);
17191 vector double vec_sel (vector double, vector double, vector unsigned long);
17192 vector long vec_sel (vector long, vector long, vector long);
17193 vector long vec_sel (vector long, vector long, vector unsigned long);
17194 vector long vec_sel (vector long, vector long, vector bool long);
17195 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17196 vector long);
17197 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17198 vector unsigned long);
17199 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
17200 vector bool long);
17201 vector double vec_splats (double);
17202 vector signed long vec_splats (signed long);
17203 vector unsigned long vec_splats (unsigned long);
17204 vector float vec_sqrt (vector float);
17205 vector double vec_sqrt (vector double);
17206 void vec_st (vector double, int, vector double *);
17207 void vec_st (vector double, int, double *);
17208 vector double vec_sub (vector double, vector double);
17209 vector double vec_trunc (vector double);
17210 vector double vec_xl (int, vector double *);
17211 vector double vec_xl (int, double *);
17212 vector long long vec_xl (int, vector long long *);
17213 vector long long vec_xl (int, long long *);
17214 vector unsigned long long vec_xl (int, vector unsigned long long *);
17215 vector unsigned long long vec_xl (int, unsigned long long *);
17216 vector float vec_xl (int, vector float *);
17217 vector float vec_xl (int, float *);
17218 vector int vec_xl (int, vector int *);
17219 vector int vec_xl (int, int *);
17220 vector unsigned int vec_xl (int, vector unsigned int *);
17221 vector unsigned int vec_xl (int, unsigned int *);
17222 vector double vec_xor (vector double, vector double);
17223 vector double vec_xor (vector double, vector bool long);
17224 vector double vec_xor (vector bool long, vector double);
17225 vector long vec_xor (vector long, vector long);
17226 vector long vec_xor (vector long, vector bool long);
17227 vector long vec_xor (vector bool long, vector long);
17228 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
17229 vector unsigned long vec_xor (vector unsigned long, vector bool long);
17230 vector unsigned long vec_xor (vector bool long, vector unsigned long);
17231 void vec_xst (vector double, int, vector double *);
17232 void vec_xst (vector double, int, double *);
17233 void vec_xst (vector long long, int, vector long long *);
17234 void vec_xst (vector long long, int, long long *);
17235 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
17236 void vec_xst (vector unsigned long long, int, unsigned long long *);
17237 void vec_xst (vector float, int, vector float *);
17238 void vec_xst (vector float, int, float *);
17239 void vec_xst (vector int, int, vector int *);
17240 void vec_xst (vector int, int, int *);
17241 void vec_xst (vector unsigned int, int, vector unsigned int *);
17242 void vec_xst (vector unsigned int, int, unsigned int *);
17243 int vec_all_eq (vector double, vector double);
17244 int vec_all_ge (vector double, vector double);
17245 int vec_all_gt (vector double, vector double);
17246 int vec_all_le (vector double, vector double);
17247 int vec_all_lt (vector double, vector double);
17248 int vec_all_nan (vector double);
17249 int vec_all_ne (vector double, vector double);
17250 int vec_all_nge (vector double, vector double);
17251 int vec_all_ngt (vector double, vector double);
17252 int vec_all_nle (vector double, vector double);
17253 int vec_all_nlt (vector double, vector double);
17254 int vec_all_numeric (vector double);
17255 int vec_any_eq (vector double, vector double);
17256 int vec_any_ge (vector double, vector double);
17257 int vec_any_gt (vector double, vector double);
17258 int vec_any_le (vector double, vector double);
17259 int vec_any_lt (vector double, vector double);
17260 int vec_any_nan (vector double);
17261 int vec_any_ne (vector double, vector double);
17262 int vec_any_nge (vector double, vector double);
17263 int vec_any_ngt (vector double, vector double);
17264 int vec_any_nle (vector double, vector double);
17265 int vec_any_nlt (vector double, vector double);
17266 int vec_any_numeric (vector double);
17267
17268 vector double vec_vsx_ld (int, const vector double *);
17269 vector double vec_vsx_ld (int, const double *);
17270 vector float vec_vsx_ld (int, const vector float *);
17271 vector float vec_vsx_ld (int, const float *);
17272 vector bool int vec_vsx_ld (int, const vector bool int *);
17273 vector signed int vec_vsx_ld (int, const vector signed int *);
17274 vector signed int vec_vsx_ld (int, const int *);
17275 vector signed int vec_vsx_ld (int, const long *);
17276 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
17277 vector unsigned int vec_vsx_ld (int, const unsigned int *);
17278 vector unsigned int vec_vsx_ld (int, const unsigned long *);
17279 vector bool short vec_vsx_ld (int, const vector bool short *);
17280 vector pixel vec_vsx_ld (int, const vector pixel *);
17281 vector signed short vec_vsx_ld (int, const vector signed short *);
17282 vector signed short vec_vsx_ld (int, const short *);
17283 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
17284 vector unsigned short vec_vsx_ld (int, const unsigned short *);
17285 vector bool char vec_vsx_ld (int, const vector bool char *);
17286 vector signed char vec_vsx_ld (int, const vector signed char *);
17287 vector signed char vec_vsx_ld (int, const signed char *);
17288 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
17289 vector unsigned char vec_vsx_ld (int, const unsigned char *);
17290
17291 void vec_vsx_st (vector double, int, vector double *);
17292 void vec_vsx_st (vector double, int, double *);
17293 void vec_vsx_st (vector float, int, vector float *);
17294 void vec_vsx_st (vector float, int, float *);
17295 void vec_vsx_st (vector signed int, int, vector signed int *);
17296 void vec_vsx_st (vector signed int, int, int *);
17297 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
17298 void vec_vsx_st (vector unsigned int, int, unsigned int *);
17299 void vec_vsx_st (vector bool int, int, vector bool int *);
17300 void vec_vsx_st (vector bool int, int, unsigned int *);
17301 void vec_vsx_st (vector bool int, int, int *);
17302 void vec_vsx_st (vector signed short, int, vector signed short *);
17303 void vec_vsx_st (vector signed short, int, short *);
17304 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
17305 void vec_vsx_st (vector unsigned short, int, unsigned short *);
17306 void vec_vsx_st (vector bool short, int, vector bool short *);
17307 void vec_vsx_st (vector bool short, int, unsigned short *);
17308 void vec_vsx_st (vector pixel, int, vector pixel *);
17309 void vec_vsx_st (vector pixel, int, unsigned short *);
17310 void vec_vsx_st (vector pixel, int, short *);
17311 void vec_vsx_st (vector bool short, int, short *);
17312 void vec_vsx_st (vector signed char, int, vector signed char *);
17313 void vec_vsx_st (vector signed char, int, signed char *);
17314 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
17315 void vec_vsx_st (vector unsigned char, int, unsigned char *);
17316 void vec_vsx_st (vector bool char, int, vector bool char *);
17317 void vec_vsx_st (vector bool char, int, unsigned char *);
17318 void vec_vsx_st (vector bool char, int, signed char *);
17319
17320 vector double vec_xxpermdi (vector double, vector double, int);
17321 vector float vec_xxpermdi (vector float, vector float, int);
17322 vector long long vec_xxpermdi (vector long long, vector long long, int);
17323 vector unsigned long long vec_xxpermdi (vector unsigned long long,
17324 vector unsigned long long, int);
17325 vector int vec_xxpermdi (vector int, vector int, int);
17326 vector unsigned int vec_xxpermdi (vector unsigned int,
17327 vector unsigned int, int);
17328 vector short vec_xxpermdi (vector short, vector short, int);
17329 vector unsigned short vec_xxpermdi (vector unsigned short,
17330 vector unsigned short, int);
17331 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
17332 vector unsigned char vec_xxpermdi (vector unsigned char,
17333 vector unsigned char, int);
17334
17335 vector double vec_xxsldi (vector double, vector double, int);
17336 vector float vec_xxsldi (vector float, vector float, int);
17337 vector long long vec_xxsldi (vector long long, vector long long, int);
17338 vector unsigned long long vec_xxsldi (vector unsigned long long,
17339 vector unsigned long long, int);
17340 vector int vec_xxsldi (vector int, vector int, int);
17341 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
17342 vector short vec_xxsldi (vector short, vector short, int);
17343 vector unsigned short vec_xxsldi (vector unsigned short,
17344 vector unsigned short, int);
17345 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
17346 vector unsigned char vec_xxsldi (vector unsigned char,
17347 vector unsigned char, int);
17348 @end smallexample
17349
17350 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
17351 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
17352 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
17353 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
17354 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
17355
17356 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17357 instruction set are available, the following additional functions are
17358 available for both 32-bit and 64-bit targets. For 64-bit targets, you
17359 can use @var{vector long} instead of @var{vector long long},
17360 @var{vector bool long} instead of @var{vector bool long long}, and
17361 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17362
17363 @smallexample
17364 vector long long vec_abs (vector long long);
17365
17366 vector long long vec_add (vector long long, vector long long);
17367 vector unsigned long long vec_add (vector unsigned long long,
17368 vector unsigned long long);
17369
17370 int vec_all_eq (vector long long, vector long long);
17371 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17372 int vec_all_ge (vector long long, vector long long);
17373 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17374 int vec_all_gt (vector long long, vector long long);
17375 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17376 int vec_all_le (vector long long, vector long long);
17377 int vec_all_le (vector unsigned long long, vector unsigned long long);
17378 int vec_all_lt (vector long long, vector long long);
17379 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17380 int vec_all_ne (vector long long, vector long long);
17381 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17382
17383 int vec_any_eq (vector long long, vector long long);
17384 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17385 int vec_any_ge (vector long long, vector long long);
17386 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17387 int vec_any_gt (vector long long, vector long long);
17388 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17389 int vec_any_le (vector long long, vector long long);
17390 int vec_any_le (vector unsigned long long, vector unsigned long long);
17391 int vec_any_lt (vector long long, vector long long);
17392 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17393 int vec_any_ne (vector long long, vector long long);
17394 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17395
17396 vector long long vec_eqv (vector long long, vector long long);
17397 vector long long vec_eqv (vector bool long long, vector long long);
17398 vector long long vec_eqv (vector long long, vector bool long long);
17399 vector unsigned long long vec_eqv (vector unsigned long long,
17400 vector unsigned long long);
17401 vector unsigned long long vec_eqv (vector bool long long,
17402 vector unsigned long long);
17403 vector unsigned long long vec_eqv (vector unsigned long long,
17404 vector bool long long);
17405 vector int vec_eqv (vector int, vector int);
17406 vector int vec_eqv (vector bool int, vector int);
17407 vector int vec_eqv (vector int, vector bool int);
17408 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17409 vector unsigned int vec_eqv (vector bool unsigned int,
17410 vector unsigned int);
17411 vector unsigned int vec_eqv (vector unsigned int,
17412 vector bool unsigned int);
17413 vector short vec_eqv (vector short, vector short);
17414 vector short vec_eqv (vector bool short, vector short);
17415 vector short vec_eqv (vector short, vector bool short);
17416 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17417 vector unsigned short vec_eqv (vector bool unsigned short,
17418 vector unsigned short);
17419 vector unsigned short vec_eqv (vector unsigned short,
17420 vector bool unsigned short);
17421 vector signed char vec_eqv (vector signed char, vector signed char);
17422 vector signed char vec_eqv (vector bool signed char, vector signed char);
17423 vector signed char vec_eqv (vector signed char, vector bool signed char);
17424 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17425 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17426 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17427
17428 vector long long vec_max (vector long long, vector long long);
17429 vector unsigned long long vec_max (vector unsigned long long,
17430 vector unsigned long long);
17431
17432 vector signed int vec_mergee (vector signed int, vector signed int);
17433 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17434 vector bool int vec_mergee (vector bool int, vector bool int);
17435
17436 vector signed int vec_mergeo (vector signed int, vector signed int);
17437 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17438 vector bool int vec_mergeo (vector bool int, vector bool int);
17439
17440 vector long long vec_min (vector long long, vector long long);
17441 vector unsigned long long vec_min (vector unsigned long long,
17442 vector unsigned long long);
17443
17444 vector long long vec_nand (vector long long, vector long long);
17445 vector long long vec_nand (vector bool long long, vector long long);
17446 vector long long vec_nand (vector long long, vector bool long long);
17447 vector unsigned long long vec_nand (vector unsigned long long,
17448 vector unsigned long long);
17449 vector unsigned long long vec_nand (vector bool long long,
17450 vector unsigned long long);
17451 vector unsigned long long vec_nand (vector unsigned long long,
17452 vector bool long long);
17453 vector int vec_nand (vector int, vector int);
17454 vector int vec_nand (vector bool int, vector int);
17455 vector int vec_nand (vector int, vector bool int);
17456 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17457 vector unsigned int vec_nand (vector bool unsigned int,
17458 vector unsigned int);
17459 vector unsigned int vec_nand (vector unsigned int,
17460 vector bool unsigned int);
17461 vector short vec_nand (vector short, vector short);
17462 vector short vec_nand (vector bool short, vector short);
17463 vector short vec_nand (vector short, vector bool short);
17464 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17465 vector unsigned short vec_nand (vector bool unsigned short,
17466 vector unsigned short);
17467 vector unsigned short vec_nand (vector unsigned short,
17468 vector bool unsigned short);
17469 vector signed char vec_nand (vector signed char, vector signed char);
17470 vector signed char vec_nand (vector bool signed char, vector signed char);
17471 vector signed char vec_nand (vector signed char, vector bool signed char);
17472 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17473 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17474 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17475
17476 vector long long vec_orc (vector long long, vector long long);
17477 vector long long vec_orc (vector bool long long, vector long long);
17478 vector long long vec_orc (vector long long, vector bool long long);
17479 vector unsigned long long vec_orc (vector unsigned long long,
17480 vector unsigned long long);
17481 vector unsigned long long vec_orc (vector bool long long,
17482 vector unsigned long long);
17483 vector unsigned long long vec_orc (vector unsigned long long,
17484 vector bool long long);
17485 vector int vec_orc (vector int, vector int);
17486 vector int vec_orc (vector bool int, vector int);
17487 vector int vec_orc (vector int, vector bool int);
17488 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17489 vector unsigned int vec_orc (vector bool unsigned int,
17490 vector unsigned int);
17491 vector unsigned int vec_orc (vector unsigned int,
17492 vector bool unsigned int);
17493 vector short vec_orc (vector short, vector short);
17494 vector short vec_orc (vector bool short, vector short);
17495 vector short vec_orc (vector short, vector bool short);
17496 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17497 vector unsigned short vec_orc (vector bool unsigned short,
17498 vector unsigned short);
17499 vector unsigned short vec_orc (vector unsigned short,
17500 vector bool unsigned short);
17501 vector signed char vec_orc (vector signed char, vector signed char);
17502 vector signed char vec_orc (vector bool signed char, vector signed char);
17503 vector signed char vec_orc (vector signed char, vector bool signed char);
17504 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17505 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17506 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17507
17508 vector int vec_pack (vector long long, vector long long);
17509 vector unsigned int vec_pack (vector unsigned long long,
17510 vector unsigned long long);
17511 vector bool int vec_pack (vector bool long long, vector bool long long);
17512
17513 vector int vec_packs (vector long long, vector long long);
17514 vector unsigned int vec_packs (vector unsigned long long,
17515 vector unsigned long long);
17516
17517 vector unsigned int vec_packsu (vector long long, vector long long);
17518 vector unsigned int vec_packsu (vector unsigned long long,
17519 vector unsigned long long);
17520
17521 vector long long vec_rl (vector long long,
17522 vector unsigned long long);
17523 vector long long vec_rl (vector unsigned long long,
17524 vector unsigned long long);
17525
17526 vector long long vec_sl (vector long long, vector unsigned long long);
17527 vector long long vec_sl (vector unsigned long long,
17528 vector unsigned long long);
17529
17530 vector long long vec_sr (vector long long, vector unsigned long long);
17531 vector unsigned long long char vec_sr (vector unsigned long long,
17532 vector unsigned long long);
17533
17534 vector long long vec_sra (vector long long, vector unsigned long long);
17535 vector unsigned long long vec_sra (vector unsigned long long,
17536 vector unsigned long long);
17537
17538 vector long long vec_sub (vector long long, vector long long);
17539 vector unsigned long long vec_sub (vector unsigned long long,
17540 vector unsigned long long);
17541
17542 vector long long vec_unpackh (vector int);
17543 vector unsigned long long vec_unpackh (vector unsigned int);
17544
17545 vector long long vec_unpackl (vector int);
17546 vector unsigned long long vec_unpackl (vector unsigned int);
17547
17548 vector long long vec_vaddudm (vector long long, vector long long);
17549 vector long long vec_vaddudm (vector bool long long, vector long long);
17550 vector long long vec_vaddudm (vector long long, vector bool long long);
17551 vector unsigned long long vec_vaddudm (vector unsigned long long,
17552 vector unsigned long long);
17553 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17554 vector unsigned long long);
17555 vector unsigned long long vec_vaddudm (vector unsigned long long,
17556 vector bool unsigned long long);
17557
17558 vector long long vec_vbpermq (vector signed char, vector signed char);
17559 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17560
17561 vector long long vec_cntlz (vector long long);
17562 vector unsigned long long vec_cntlz (vector unsigned long long);
17563 vector int vec_cntlz (vector int);
17564 vector unsigned int vec_cntlz (vector int);
17565 vector short vec_cntlz (vector short);
17566 vector unsigned short vec_cntlz (vector unsigned short);
17567 vector signed char vec_cntlz (vector signed char);
17568 vector unsigned char vec_cntlz (vector unsigned char);
17569
17570 vector long long vec_vclz (vector long long);
17571 vector unsigned long long vec_vclz (vector unsigned long long);
17572 vector int vec_vclz (vector int);
17573 vector unsigned int vec_vclz (vector int);
17574 vector short vec_vclz (vector short);
17575 vector unsigned short vec_vclz (vector unsigned short);
17576 vector signed char vec_vclz (vector signed char);
17577 vector unsigned char vec_vclz (vector unsigned char);
17578
17579 vector signed char vec_vclzb (vector signed char);
17580 vector unsigned char vec_vclzb (vector unsigned char);
17581
17582 vector long long vec_vclzd (vector long long);
17583 vector unsigned long long vec_vclzd (vector unsigned long long);
17584
17585 vector short vec_vclzh (vector short);
17586 vector unsigned short vec_vclzh (vector unsigned short);
17587
17588 vector int vec_vclzw (vector int);
17589 vector unsigned int vec_vclzw (vector int);
17590
17591 vector signed char vec_vgbbd (vector signed char);
17592 vector unsigned char vec_vgbbd (vector unsigned char);
17593
17594 vector long long vec_vmaxsd (vector long long, vector long long);
17595
17596 vector unsigned long long vec_vmaxud (vector unsigned long long,
17597 unsigned vector long long);
17598
17599 vector long long vec_vminsd (vector long long, vector long long);
17600
17601 vector unsigned long long vec_vminud (vector long long,
17602 vector long long);
17603
17604 vector int vec_vpksdss (vector long long, vector long long);
17605 vector unsigned int vec_vpksdss (vector long long, vector long long);
17606
17607 vector unsigned int vec_vpkudus (vector unsigned long long,
17608 vector unsigned long long);
17609
17610 vector int vec_vpkudum (vector long long, vector long long);
17611 vector unsigned int vec_vpkudum (vector unsigned long long,
17612 vector unsigned long long);
17613 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
17614
17615 vector long long vec_vpopcnt (vector long long);
17616 vector unsigned long long vec_vpopcnt (vector unsigned long long);
17617 vector int vec_vpopcnt (vector int);
17618 vector unsigned int vec_vpopcnt (vector int);
17619 vector short vec_vpopcnt (vector short);
17620 vector unsigned short vec_vpopcnt (vector unsigned short);
17621 vector signed char vec_vpopcnt (vector signed char);
17622 vector unsigned char vec_vpopcnt (vector unsigned char);
17623
17624 vector signed char vec_vpopcntb (vector signed char);
17625 vector unsigned char vec_vpopcntb (vector unsigned char);
17626
17627 vector long long vec_vpopcntd (vector long long);
17628 vector unsigned long long vec_vpopcntd (vector unsigned long long);
17629
17630 vector short vec_vpopcnth (vector short);
17631 vector unsigned short vec_vpopcnth (vector unsigned short);
17632
17633 vector int vec_vpopcntw (vector int);
17634 vector unsigned int vec_vpopcntw (vector int);
17635
17636 vector long long vec_vrld (vector long long, vector unsigned long long);
17637 vector unsigned long long vec_vrld (vector unsigned long long,
17638 vector unsigned long long);
17639
17640 vector long long vec_vsld (vector long long, vector unsigned long long);
17641 vector long long vec_vsld (vector unsigned long long,
17642 vector unsigned long long);
17643
17644 vector long long vec_vsrad (vector long long, vector unsigned long long);
17645 vector unsigned long long vec_vsrad (vector unsigned long long,
17646 vector unsigned long long);
17647
17648 vector long long vec_vsrd (vector long long, vector unsigned long long);
17649 vector unsigned long long char vec_vsrd (vector unsigned long long,
17650 vector unsigned long long);
17651
17652 vector long long vec_vsubudm (vector long long, vector long long);
17653 vector long long vec_vsubudm (vector bool long long, vector long long);
17654 vector long long vec_vsubudm (vector long long, vector bool long long);
17655 vector unsigned long long vec_vsubudm (vector unsigned long long,
17656 vector unsigned long long);
17657 vector unsigned long long vec_vsubudm (vector bool long long,
17658 vector unsigned long long);
17659 vector unsigned long long vec_vsubudm (vector unsigned long long,
17660 vector bool long long);
17661
17662 vector long long vec_vupkhsw (vector int);
17663 vector unsigned long long vec_vupkhsw (vector unsigned int);
17664
17665 vector long long vec_vupklsw (vector int);
17666 vector unsigned long long vec_vupklsw (vector int);
17667 @end smallexample
17668
17669 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17670 instruction set are available, the following additional functions are
17671 available for 64-bit targets. New vector types
17672 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
17673 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
17674 builtins.
17675
17676 The normal vector extract, and set operations work on
17677 @var{vector __int128_t} and @var{vector __uint128_t} types,
17678 but the index value must be 0.
17679
17680 @smallexample
17681 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
17682 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
17683
17684 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
17685 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
17686
17687 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
17688 vector __int128_t);
17689 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
17690 vector __uint128_t);
17691
17692 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
17693 vector __int128_t);
17694 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
17695 vector __uint128_t);
17696
17697 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
17698 vector __int128_t);
17699 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
17700 vector __uint128_t);
17701
17702 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
17703 vector __int128_t);
17704 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
17705 vector __uint128_t);
17706
17707 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
17708 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
17709
17710 __int128_t vec_vsubuqm (__int128_t, __int128_t);
17711 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
17712
17713 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
17714 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
17715 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
17716 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
17717 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
17718 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
17719 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
17720 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
17721 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
17722 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
17723 @end smallexample
17724
17725 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
17726 are available:
17727
17728 @smallexample
17729 vector long long vec_vctz (vector long long);
17730 vector unsigned long long vec_vctz (vector unsigned long long);
17731 vector int vec_vctz (vector int);
17732 vector unsigned int vec_vctz (vector int);
17733 vector short vec_vctz (vector short);
17734 vector unsigned short vec_vctz (vector unsigned short);
17735 vector signed char vec_vctz (vector signed char);
17736 vector unsigned char vec_vctz (vector unsigned char);
17737
17738 vector signed char vec_vctzb (vector signed char);
17739 vector unsigned char vec_vctzb (vector unsigned char);
17740
17741 vector long long vec_vctzd (vector long long);
17742 vector unsigned long long vec_vctzd (vector unsigned long long);
17743
17744 vector short vec_vctzh (vector short);
17745 vector unsigned short vec_vctzh (vector unsigned short);
17746
17747 vector int vec_vctzw (vector int);
17748 vector unsigned int vec_vctzw (vector int);
17749
17750 vector int vec_vprtyb (vector int);
17751 vector unsigned int vec_vprtyb (vector unsigned int);
17752 vector long long vec_vprtyb (vector long long);
17753 vector unsigned long long vec_vprtyb (vector unsigned long long);
17754
17755 vector int vec_vprtybw (vector int);
17756 vector unsigned int vec_vprtybw (vector unsigned int);
17757
17758 vector long long vec_vprtybd (vector long long);
17759 vector unsigned long long vec_vprtybd (vector unsigned long long);
17760 @end smallexample
17761
17762 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
17763 are available:
17764
17765 @smallexample
17766 vector long vec_vprtyb (vector long);
17767 vector unsigned long vec_vprtyb (vector unsigned long);
17768 vector __int128_t vec_vprtyb (vector __int128_t);
17769 vector __uint128_t vec_vprtyb (vector __uint128_t);
17770
17771 vector long vec_vprtybd (vector long);
17772 vector unsigned long vec_vprtybd (vector unsigned long);
17773
17774 vector __int128_t vec_vprtybq (vector __int128_t);
17775 vector __uint128_t vec_vprtybd (vector __uint128_t);
17776 @end smallexample
17777
17778 The following built-in vector functions are available for the PowerPC family
17779 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17780 @smallexample
17781 __vector unsigned char
17782 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
17783 __vector unsigned char
17784 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
17785 @end smallexample
17786
17787 The @code{vec_slv} and @code{vec_srv} functions operate on
17788 all of the bytes of their @code{src} and @code{shift_distance}
17789 arguments in parallel. The behavior of the @code{vec_slv} is as if
17790 there existed a temporary array of 17 unsigned characters
17791 @code{slv_array} within which elements 0 through 15 are the same as
17792 the entries in the @code{src} array and element 16 equals 0. The
17793 result returned from the @code{vec_slv} function is a
17794 @code{__vector} of 16 unsigned characters within which element
17795 @code{i} is computed using the C expression
17796 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
17797 shift_distance[i]))},
17798 with this resulting value coerced to the @code{unsigned char} type.
17799 The behavior of the @code{vec_srv} is as if
17800 there existed a temporary array of 17 unsigned characters
17801 @code{srv_array} within which element 0 equals zero and
17802 elements 1 through 16 equal the elements 0 through 15 of
17803 the @code{src} array. The
17804 result returned from the @code{vec_srv} function is a
17805 @code{__vector} of 16 unsigned characters within which element
17806 @code{i} is computed using the C expression
17807 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
17808 (0x07 & shift_distance[i]))},
17809 with this resulting value coerced to the @code{unsigned char} type.
17810
17811 The following built-in functions are available for the PowerPC family
17812 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17813 @smallexample
17814 __vector unsigned char
17815 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
17816 __vector unsigned short
17817 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
17818 __vector unsigned int
17819 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
17820
17821 __vector unsigned char
17822 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
17823 __vector unsigned short
17824 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
17825 __vector unsigned int
17826 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
17827 @end smallexample
17828
17829 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
17830 @code{vec_absdw} built-in functions each computes the absolute
17831 differences of the pairs of vector elements supplied in its two vector
17832 arguments, placing the absolute differences into the corresponding
17833 elements of the vector result.
17834
17835 The following built-in functions are available for the PowerPC family
17836 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
17837 @smallexample
17838 __vector int
17839 vec_extract_exp (__vector float source);
17840 __vector long long int
17841 vec_extract_exp (__vector double source);
17842
17843 __vector int
17844 vec_extract_sig (__vector float source);
17845 __vector long long int
17846 vec_extract_sig (__vector double source);
17847
17848 __vector float
17849 vec_insert_exp (__vector unsigned int significands, __vector unsigned int exponents);
17850 __vector double
17851 vec_insert_exp (__vector unsigned long long int significands,
17852 __vector unsigned long long int exponents);
17853
17854 __vector int vec_test_data_class (__vector float source, unsigned int condition);
17855 __vector long long int vec_test_data_class (__vector double source, unsigned int condition);
17856 @end smallexample
17857
17858 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
17859 functions return vectors representing the significands and exponents
17860 of their @code{source} arguments respectively. The
17861 @code{vec_insert_exp} built-in functions return a vector of single- or
17862 double-precision floating
17863 point values constructed by assembling the values of their
17864 @code{significands} and @code{exponents} arguments into the
17865 corresponding elements of the returned vector. The sign of each
17866 element of the result is copied from the most significant bit of the
17867 corresponding entry within the @code{significands} argument. The
17868 significand and exponent components of each element of the result are
17869 composed of the least significant bits of the corresponding
17870 @code{significands} element and the least significant bits of the
17871 corresponding @code{exponents} element.
17872
17873 The @code{vec_test_data_class} built-in function returns a vector
17874 representing the results of testing the @code{source} vector for the
17875 condition selected by the @code{condition} argument. The
17876 @code{condition} argument must be an unsigned integer with value not
17877 exceeding 127. The
17878 @code{condition} argument is encoded as a bitmask with each bit
17879 enabling the testing of a different condition, as characterized by the
17880 following:
17881 @smallexample
17882 0x40 Test for NaN
17883 0x20 Test for +Infinity
17884 0x10 Test for -Infinity
17885 0x08 Test for +Zero
17886 0x04 Test for -Zero
17887 0x02 Test for +Denormal
17888 0x01 Test for -Denormal
17889 @end smallexample
17890
17891 If any of the enabled test conditions is true, the corresponding entry
17892 in the result vector is -1. Otherwise (all of the enabled test
17893 conditions are false), the corresponding entry of the result vector is 0.
17894
17895 If the cryptographic instructions are enabled (@option{-mcrypto} or
17896 @option{-mcpu=power8}), the following builtins are enabled.
17897
17898 @smallexample
17899 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
17900
17901 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
17902 vector unsigned long long);
17903
17904 vector unsigned long long __builtin_crypto_vcipherlast
17905 (vector unsigned long long,
17906 vector unsigned long long);
17907
17908 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
17909 vector unsigned long long);
17910
17911 vector unsigned long long __builtin_crypto_vncipherlast
17912 (vector unsigned long long,
17913 vector unsigned long long);
17914
17915 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
17916 vector unsigned char,
17917 vector unsigned char);
17918
17919 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
17920 vector unsigned short,
17921 vector unsigned short);
17922
17923 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
17924 vector unsigned int,
17925 vector unsigned int);
17926
17927 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
17928 vector unsigned long long,
17929 vector unsigned long long);
17930
17931 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
17932 vector unsigned char);
17933
17934 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
17935 vector unsigned short);
17936
17937 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
17938 vector unsigned int);
17939
17940 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
17941 vector unsigned long long);
17942
17943 vector unsigned long long __builtin_crypto_vshasigmad
17944 (vector unsigned long long, int, int);
17945
17946 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
17947 int, int);
17948 @end smallexample
17949
17950 The second argument to the @var{__builtin_crypto_vshasigmad} and
17951 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
17952 integer that is 0 or 1. The third argument to these builtin functions
17953 must be a constant integer in the range of 0 to 15.
17954
17955 If the ISA 3.0 instruction set additions
17956 are enabled (@option{-mcpu=power9}), the following additional
17957 functions are available for both 32-bit and 64-bit targets.
17958
17959 vector short vec_xl (int, vector short *);
17960 vector short vec_xl (int, short *);
17961 vector unsigned short vec_xl (int, vector unsigned short *);
17962 vector unsigned short vec_xl (int, unsigned short *);
17963 vector char vec_xl (int, vector char *);
17964 vector char vec_xl (int, char *);
17965 vector unsigned char vec_xl (int, vector unsigned char *);
17966 vector unsigned char vec_xl (int, unsigned char *);
17967
17968 void vec_xst (vector short, int, vector short *);
17969 void vec_xst (vector short, int, short *);
17970 void vec_xst (vector unsigned short, int, vector unsigned short *);
17971 void vec_xst (vector unsigned short, int, unsigned short *);
17972 void vec_xst (vector char, int, vector char *);
17973 void vec_xst (vector char, int, char *);
17974 void vec_xst (vector unsigned char, int, vector unsigned char *);
17975 void vec_xst (vector unsigned char, int, unsigned char *);
17976
17977 @node PowerPC Hardware Transactional Memory Built-in Functions
17978 @subsection PowerPC Hardware Transactional Memory Built-in Functions
17979 GCC provides two interfaces for accessing the Hardware Transactional
17980 Memory (HTM) instructions available on some of the PowerPC family
17981 of processors (eg, POWER8). The two interfaces come in a low level
17982 interface, consisting of built-in functions specific to PowerPC and a
17983 higher level interface consisting of inline functions that are common
17984 between PowerPC and S/390.
17985
17986 @subsubsection PowerPC HTM Low Level Built-in Functions
17987
17988 The following low level built-in functions are available with
17989 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
17990 They all generate the machine instruction that is part of the name.
17991
17992 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
17993 the full 4-bit condition register value set by their associated hardware
17994 instruction. The header file @code{htmintrin.h} defines some macros that can
17995 be used to decipher the return value. The @code{__builtin_tbegin} builtin
17996 returns a simple true or false value depending on whether a transaction was
17997 successfully started or not. The arguments of the builtins match exactly the
17998 type and order of the associated hardware instruction's operands, except for
17999 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
18000 Refer to the ISA manual for a description of each instruction's operands.
18001
18002 @smallexample
18003 unsigned int __builtin_tbegin (unsigned int)
18004 unsigned int __builtin_tend (unsigned int)
18005
18006 unsigned int __builtin_tabort (unsigned int)
18007 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
18008 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
18009 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
18010 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
18011
18012 unsigned int __builtin_tcheck (void)
18013 unsigned int __builtin_treclaim (unsigned int)
18014 unsigned int __builtin_trechkpt (void)
18015 unsigned int __builtin_tsr (unsigned int)
18016 @end smallexample
18017
18018 In addition to the above HTM built-ins, we have added built-ins for
18019 some common extended mnemonics of the HTM instructions:
18020
18021 @smallexample
18022 unsigned int __builtin_tendall (void)
18023 unsigned int __builtin_tresume (void)
18024 unsigned int __builtin_tsuspend (void)
18025 @end smallexample
18026
18027 Note that the semantics of the above HTM builtins are required to mimic
18028 the locking semantics used for critical sections. Builtins that are used
18029 to create a new transaction or restart a suspended transaction must have
18030 lock acquisition like semantics while those builtins that end or suspend a
18031 transaction must have lock release like semantics. Specifically, this must
18032 mimic lock semantics as specified by C++11, for example: Lock acquisition is
18033 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
18034 that returns 0, and lock release is as-if an execution of
18035 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
18036 implicit implementation-defined lock used for all transactions. The HTM
18037 instructions associated with with the builtins inherently provide the
18038 correct acquisition and release hardware barriers required. However,
18039 the compiler must also be prohibited from moving loads and stores across
18040 the builtins in a way that would violate their semantics. This has been
18041 accomplished by adding memory barriers to the associated HTM instructions
18042 (which is a conservative approach to provide acquire and release semantics).
18043 Earlier versions of the compiler did not treat the HTM instructions as
18044 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
18045 be used to determine whether the current compiler treats HTM instructions
18046 as memory barriers or not. This allows the user to explicitly add memory
18047 barriers to their code when using an older version of the compiler.
18048
18049 The following set of built-in functions are available to gain access
18050 to the HTM specific special purpose registers.
18051
18052 @smallexample
18053 unsigned long __builtin_get_texasr (void)
18054 unsigned long __builtin_get_texasru (void)
18055 unsigned long __builtin_get_tfhar (void)
18056 unsigned long __builtin_get_tfiar (void)
18057
18058 void __builtin_set_texasr (unsigned long);
18059 void __builtin_set_texasru (unsigned long);
18060 void __builtin_set_tfhar (unsigned long);
18061 void __builtin_set_tfiar (unsigned long);
18062 @end smallexample
18063
18064 Example usage of these low level built-in functions may look like:
18065
18066 @smallexample
18067 #include <htmintrin.h>
18068
18069 int num_retries = 10;
18070
18071 while (1)
18072 @{
18073 if (__builtin_tbegin (0))
18074 @{
18075 /* Transaction State Initiated. */
18076 if (is_locked (lock))
18077 __builtin_tabort (0);
18078 ... transaction code...
18079 __builtin_tend (0);
18080 break;
18081 @}
18082 else
18083 @{
18084 /* Transaction State Failed. Use locks if the transaction
18085 failure is "persistent" or we've tried too many times. */
18086 if (num_retries-- <= 0
18087 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
18088 @{
18089 acquire_lock (lock);
18090 ... non transactional fallback path...
18091 release_lock (lock);
18092 break;
18093 @}
18094 @}
18095 @}
18096 @end smallexample
18097
18098 One final built-in function has been added that returns the value of
18099 the 2-bit Transaction State field of the Machine Status Register (MSR)
18100 as stored in @code{CR0}.
18101
18102 @smallexample
18103 unsigned long __builtin_ttest (void)
18104 @end smallexample
18105
18106 This built-in can be used to determine the current transaction state
18107 using the following code example:
18108
18109 @smallexample
18110 #include <htmintrin.h>
18111
18112 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
18113
18114 if (tx_state == _HTM_TRANSACTIONAL)
18115 @{
18116 /* Code to use in transactional state. */
18117 @}
18118 else if (tx_state == _HTM_NONTRANSACTIONAL)
18119 @{
18120 /* Code to use in non-transactional state. */
18121 @}
18122 else if (tx_state == _HTM_SUSPENDED)
18123 @{
18124 /* Code to use in transaction suspended state. */
18125 @}
18126 @end smallexample
18127
18128 @subsubsection PowerPC HTM High Level Inline Functions
18129
18130 The following high level HTM interface is made available by including
18131 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
18132 where CPU is `power8' or later. This interface is common between PowerPC
18133 and S/390, allowing users to write one HTM source implementation that
18134 can be compiled and executed on either system.
18135
18136 @smallexample
18137 long __TM_simple_begin (void)
18138 long __TM_begin (void* const TM_buff)
18139 long __TM_end (void)
18140 void __TM_abort (void)
18141 void __TM_named_abort (unsigned char const code)
18142 void __TM_resume (void)
18143 void __TM_suspend (void)
18144
18145 long __TM_is_user_abort (void* const TM_buff)
18146 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
18147 long __TM_is_illegal (void* const TM_buff)
18148 long __TM_is_footprint_exceeded (void* const TM_buff)
18149 long __TM_nesting_depth (void* const TM_buff)
18150 long __TM_is_nested_too_deep(void* const TM_buff)
18151 long __TM_is_conflict(void* const TM_buff)
18152 long __TM_is_failure_persistent(void* const TM_buff)
18153 long __TM_failure_address(void* const TM_buff)
18154 long long __TM_failure_code(void* const TM_buff)
18155 @end smallexample
18156
18157 Using these common set of HTM inline functions, we can create
18158 a more portable version of the HTM example in the previous
18159 section that will work on either PowerPC or S/390:
18160
18161 @smallexample
18162 #include <htmxlintrin.h>
18163
18164 int num_retries = 10;
18165 TM_buff_type TM_buff;
18166
18167 while (1)
18168 @{
18169 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
18170 @{
18171 /* Transaction State Initiated. */
18172 if (is_locked (lock))
18173 __TM_abort ();
18174 ... transaction code...
18175 __TM_end ();
18176 break;
18177 @}
18178 else
18179 @{
18180 /* Transaction State Failed. Use locks if the transaction
18181 failure is "persistent" or we've tried too many times. */
18182 if (num_retries-- <= 0
18183 || __TM_is_failure_persistent (TM_buff))
18184 @{
18185 acquire_lock (lock);
18186 ... non transactional fallback path...
18187 release_lock (lock);
18188 break;
18189 @}
18190 @}
18191 @}
18192 @end smallexample
18193
18194 @node RX Built-in Functions
18195 @subsection RX Built-in Functions
18196 GCC supports some of the RX instructions which cannot be expressed in
18197 the C programming language via the use of built-in functions. The
18198 following functions are supported:
18199
18200 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
18201 Generates the @code{brk} machine instruction.
18202 @end deftypefn
18203
18204 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
18205 Generates the @code{clrpsw} machine instruction to clear the specified
18206 bit in the processor status word.
18207 @end deftypefn
18208
18209 @deftypefn {Built-in Function} void __builtin_rx_int (int)
18210 Generates the @code{int} machine instruction to generate an interrupt
18211 with the specified value.
18212 @end deftypefn
18213
18214 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
18215 Generates the @code{machi} machine instruction to add the result of
18216 multiplying the top 16 bits of the two arguments into the
18217 accumulator.
18218 @end deftypefn
18219
18220 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
18221 Generates the @code{maclo} machine instruction to add the result of
18222 multiplying the bottom 16 bits of the two arguments into the
18223 accumulator.
18224 @end deftypefn
18225
18226 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
18227 Generates the @code{mulhi} machine instruction to place the result of
18228 multiplying the top 16 bits of the two arguments into the
18229 accumulator.
18230 @end deftypefn
18231
18232 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
18233 Generates the @code{mullo} machine instruction to place the result of
18234 multiplying the bottom 16 bits of the two arguments into the
18235 accumulator.
18236 @end deftypefn
18237
18238 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
18239 Generates the @code{mvfachi} machine instruction to read the top
18240 32 bits of the accumulator.
18241 @end deftypefn
18242
18243 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
18244 Generates the @code{mvfacmi} machine instruction to read the middle
18245 32 bits of the accumulator.
18246 @end deftypefn
18247
18248 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
18249 Generates the @code{mvfc} machine instruction which reads the control
18250 register specified in its argument and returns its value.
18251 @end deftypefn
18252
18253 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
18254 Generates the @code{mvtachi} machine instruction to set the top
18255 32 bits of the accumulator.
18256 @end deftypefn
18257
18258 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
18259 Generates the @code{mvtaclo} machine instruction to set the bottom
18260 32 bits of the accumulator.
18261 @end deftypefn
18262
18263 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
18264 Generates the @code{mvtc} machine instruction which sets control
18265 register number @code{reg} to @code{val}.
18266 @end deftypefn
18267
18268 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
18269 Generates the @code{mvtipl} machine instruction set the interrupt
18270 priority level.
18271 @end deftypefn
18272
18273 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
18274 Generates the @code{racw} machine instruction to round the accumulator
18275 according to the specified mode.
18276 @end deftypefn
18277
18278 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
18279 Generates the @code{revw} machine instruction which swaps the bytes in
18280 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
18281 and also bits 16--23 occupy bits 24--31 and vice versa.
18282 @end deftypefn
18283
18284 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
18285 Generates the @code{rmpa} machine instruction which initiates a
18286 repeated multiply and accumulate sequence.
18287 @end deftypefn
18288
18289 @deftypefn {Built-in Function} void __builtin_rx_round (float)
18290 Generates the @code{round} machine instruction which returns the
18291 floating-point argument rounded according to the current rounding mode
18292 set in the floating-point status word register.
18293 @end deftypefn
18294
18295 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
18296 Generates the @code{sat} machine instruction which returns the
18297 saturated value of the argument.
18298 @end deftypefn
18299
18300 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
18301 Generates the @code{setpsw} machine instruction to set the specified
18302 bit in the processor status word.
18303 @end deftypefn
18304
18305 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
18306 Generates the @code{wait} machine instruction.
18307 @end deftypefn
18308
18309 @node S/390 System z Built-in Functions
18310 @subsection S/390 System z Built-in Functions
18311 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
18312 Generates the @code{tbegin} machine instruction starting a
18313 non-constrained hardware transaction. If the parameter is non-NULL the
18314 memory area is used to store the transaction diagnostic buffer and
18315 will be passed as first operand to @code{tbegin}. This buffer can be
18316 defined using the @code{struct __htm_tdb} C struct defined in
18317 @code{htmintrin.h} and must reside on a double-word boundary. The
18318 second tbegin operand is set to @code{0xff0c}. This enables
18319 save/restore of all GPRs and disables aborts for FPR and AR
18320 manipulations inside the transaction body. The condition code set by
18321 the tbegin instruction is returned as integer value. The tbegin
18322 instruction by definition overwrites the content of all FPRs. The
18323 compiler will generate code which saves and restores the FPRs. For
18324 soft-float code it is recommended to used the @code{*_nofloat}
18325 variant. In order to prevent a TDB from being written it is required
18326 to pass a constant zero value as parameter. Passing a zero value
18327 through a variable is not sufficient. Although modifications of
18328 access registers inside the transaction will not trigger an
18329 transaction abort it is not supported to actually modify them. Access
18330 registers do not get saved when entering a transaction. They will have
18331 undefined state when reaching the abort code.
18332 @end deftypefn
18333
18334 Macros for the possible return codes of tbegin are defined in the
18335 @code{htmintrin.h} header file:
18336
18337 @table @code
18338 @item _HTM_TBEGIN_STARTED
18339 @code{tbegin} has been executed as part of normal processing. The
18340 transaction body is supposed to be executed.
18341 @item _HTM_TBEGIN_INDETERMINATE
18342 The transaction was aborted due to an indeterminate condition which
18343 might be persistent.
18344 @item _HTM_TBEGIN_TRANSIENT
18345 The transaction aborted due to a transient failure. The transaction
18346 should be re-executed in that case.
18347 @item _HTM_TBEGIN_PERSISTENT
18348 The transaction aborted due to a persistent failure. Re-execution
18349 under same circumstances will not be productive.
18350 @end table
18351
18352 @defmac _HTM_FIRST_USER_ABORT_CODE
18353 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
18354 specifies the first abort code which can be used for
18355 @code{__builtin_tabort}. Values below this threshold are reserved for
18356 machine use.
18357 @end defmac
18358
18359 @deftp {Data type} {struct __htm_tdb}
18360 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
18361 the structure of the transaction diagnostic block as specified in the
18362 Principles of Operation manual chapter 5-91.
18363 @end deftp
18364
18365 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
18366 Same as @code{__builtin_tbegin} but without FPR saves and restores.
18367 Using this variant in code making use of FPRs will leave the FPRs in
18368 undefined state when entering the transaction abort handler code.
18369 @end deftypefn
18370
18371 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
18372 In addition to @code{__builtin_tbegin} a loop for transient failures
18373 is generated. If tbegin returns a condition code of 2 the transaction
18374 will be retried as often as specified in the second argument. The
18375 perform processor assist instruction is used to tell the CPU about the
18376 number of fails so far.
18377 @end deftypefn
18378
18379 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
18380 Same as @code{__builtin_tbegin_retry} but without FPR saves and
18381 restores. Using this variant in code making use of FPRs will leave
18382 the FPRs in undefined state when entering the transaction abort
18383 handler code.
18384 @end deftypefn
18385
18386 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
18387 Generates the @code{tbeginc} machine instruction starting a constrained
18388 hardware transaction. The second operand is set to @code{0xff08}.
18389 @end deftypefn
18390
18391 @deftypefn {Built-in Function} int __builtin_tend (void)
18392 Generates the @code{tend} machine instruction finishing a transaction
18393 and making the changes visible to other threads. The condition code
18394 generated by tend is returned as integer value.
18395 @end deftypefn
18396
18397 @deftypefn {Built-in Function} void __builtin_tabort (int)
18398 Generates the @code{tabort} machine instruction with the specified
18399 abort code. Abort codes from 0 through 255 are reserved and will
18400 result in an error message.
18401 @end deftypefn
18402
18403 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
18404 Generates the @code{ppa rX,rY,1} machine instruction. Where the
18405 integer parameter is loaded into rX and a value of zero is loaded into
18406 rY. The integer parameter specifies the number of times the
18407 transaction repeatedly aborted.
18408 @end deftypefn
18409
18410 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
18411 Generates the @code{etnd} machine instruction. The current nesting
18412 depth is returned as integer value. For a nesting depth of 0 the code
18413 is not executed as part of an transaction.
18414 @end deftypefn
18415
18416 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
18417
18418 Generates the @code{ntstg} machine instruction. The second argument
18419 is written to the first arguments location. The store operation will
18420 not be rolled-back in case of an transaction abort.
18421 @end deftypefn
18422
18423 @node SH Built-in Functions
18424 @subsection SH Built-in Functions
18425 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
18426 families of processors:
18427
18428 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
18429 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
18430 used by system code that manages threads and execution contexts. The compiler
18431 normally does not generate code that modifies the contents of @samp{GBR} and
18432 thus the value is preserved across function calls. Changing the @samp{GBR}
18433 value in user code must be done with caution, since the compiler might use
18434 @samp{GBR} in order to access thread local variables.
18435
18436 @end deftypefn
18437
18438 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
18439 Returns the value that is currently set in the @samp{GBR} register.
18440 Memory loads and stores that use the thread pointer as a base address are
18441 turned into @samp{GBR} based displacement loads and stores, if possible.
18442 For example:
18443 @smallexample
18444 struct my_tcb
18445 @{
18446 int a, b, c, d, e;
18447 @};
18448
18449 int get_tcb_value (void)
18450 @{
18451 // Generate @samp{mov.l @@(8,gbr),r0} instruction
18452 return ((my_tcb*)__builtin_thread_pointer ())->c;
18453 @}
18454
18455 @end smallexample
18456 @end deftypefn
18457
18458 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18459 Returns the value that is currently set in the @samp{FPSCR} register.
18460 @end deftypefn
18461
18462 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18463 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18464 preserving the current values of the FR, SZ and PR bits.
18465 @end deftypefn
18466
18467 @node SPARC VIS Built-in Functions
18468 @subsection SPARC VIS Built-in Functions
18469
18470 GCC supports SIMD operations on the SPARC using both the generic vector
18471 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18472 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
18473 switch, the VIS extension is exposed as the following built-in functions:
18474
18475 @smallexample
18476 typedef int v1si __attribute__ ((vector_size (4)));
18477 typedef int v2si __attribute__ ((vector_size (8)));
18478 typedef short v4hi __attribute__ ((vector_size (8)));
18479 typedef short v2hi __attribute__ ((vector_size (4)));
18480 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
18481 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
18482
18483 void __builtin_vis_write_gsr (int64_t);
18484 int64_t __builtin_vis_read_gsr (void);
18485
18486 void * __builtin_vis_alignaddr (void *, long);
18487 void * __builtin_vis_alignaddrl (void *, long);
18488 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
18489 v2si __builtin_vis_faligndatav2si (v2si, v2si);
18490 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
18491 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
18492
18493 v4hi __builtin_vis_fexpand (v4qi);
18494
18495 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
18496 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
18497 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
18498 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
18499 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
18500 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
18501 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
18502
18503 v4qi __builtin_vis_fpack16 (v4hi);
18504 v8qi __builtin_vis_fpack32 (v2si, v8qi);
18505 v2hi __builtin_vis_fpackfix (v2si);
18506 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
18507
18508 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
18509
18510 long __builtin_vis_edge8 (void *, void *);
18511 long __builtin_vis_edge8l (void *, void *);
18512 long __builtin_vis_edge16 (void *, void *);
18513 long __builtin_vis_edge16l (void *, void *);
18514 long __builtin_vis_edge32 (void *, void *);
18515 long __builtin_vis_edge32l (void *, void *);
18516
18517 long __builtin_vis_fcmple16 (v4hi, v4hi);
18518 long __builtin_vis_fcmple32 (v2si, v2si);
18519 long __builtin_vis_fcmpne16 (v4hi, v4hi);
18520 long __builtin_vis_fcmpne32 (v2si, v2si);
18521 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
18522 long __builtin_vis_fcmpgt32 (v2si, v2si);
18523 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
18524 long __builtin_vis_fcmpeq32 (v2si, v2si);
18525
18526 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
18527 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
18528 v2si __builtin_vis_fpadd32 (v2si, v2si);
18529 v1si __builtin_vis_fpadd32s (v1si, v1si);
18530 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
18531 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
18532 v2si __builtin_vis_fpsub32 (v2si, v2si);
18533 v1si __builtin_vis_fpsub32s (v1si, v1si);
18534
18535 long __builtin_vis_array8 (long, long);
18536 long __builtin_vis_array16 (long, long);
18537 long __builtin_vis_array32 (long, long);
18538 @end smallexample
18539
18540 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
18541 functions also become available:
18542
18543 @smallexample
18544 long __builtin_vis_bmask (long, long);
18545 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
18546 v2si __builtin_vis_bshufflev2si (v2si, v2si);
18547 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
18548 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
18549
18550 long __builtin_vis_edge8n (void *, void *);
18551 long __builtin_vis_edge8ln (void *, void *);
18552 long __builtin_vis_edge16n (void *, void *);
18553 long __builtin_vis_edge16ln (void *, void *);
18554 long __builtin_vis_edge32n (void *, void *);
18555 long __builtin_vis_edge32ln (void *, void *);
18556 @end smallexample
18557
18558 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
18559 functions also become available:
18560
18561 @smallexample
18562 void __builtin_vis_cmask8 (long);
18563 void __builtin_vis_cmask16 (long);
18564 void __builtin_vis_cmask32 (long);
18565
18566 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
18567
18568 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
18569 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
18570 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
18571 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
18572 v2si __builtin_vis_fsll16 (v2si, v2si);
18573 v2si __builtin_vis_fslas16 (v2si, v2si);
18574 v2si __builtin_vis_fsrl16 (v2si, v2si);
18575 v2si __builtin_vis_fsra16 (v2si, v2si);
18576
18577 long __builtin_vis_pdistn (v8qi, v8qi);
18578
18579 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
18580
18581 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
18582 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
18583
18584 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
18585 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
18586 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
18587 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
18588 v2si __builtin_vis_fpadds32 (v2si, v2si);
18589 v1si __builtin_vis_fpadds32s (v1si, v1si);
18590 v2si __builtin_vis_fpsubs32 (v2si, v2si);
18591 v1si __builtin_vis_fpsubs32s (v1si, v1si);
18592
18593 long __builtin_vis_fucmple8 (v8qi, v8qi);
18594 long __builtin_vis_fucmpne8 (v8qi, v8qi);
18595 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
18596 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
18597
18598 float __builtin_vis_fhadds (float, float);
18599 double __builtin_vis_fhaddd (double, double);
18600 float __builtin_vis_fhsubs (float, float);
18601 double __builtin_vis_fhsubd (double, double);
18602 float __builtin_vis_fnhadds (float, float);
18603 double __builtin_vis_fnhaddd (double, double);
18604
18605 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
18606 int64_t __builtin_vis_xmulx (int64_t, int64_t);
18607 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
18608 @end smallexample
18609
18610 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
18611 functions also become available:
18612
18613 @smallexample
18614 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
18615 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
18616 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
18617 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
18618
18619 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
18620 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
18621 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
18622 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
18623
18624 long __builtin_vis_fpcmple8 (v8qi, v8qi);
18625 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
18626 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
18627 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
18628 long __builtin_vis_fpcmpule32 (v2si, v2si);
18629 long __builtin_vis_fpcmpugt32 (v2si, v2si);
18630
18631 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
18632 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
18633 v2si __builtin_vis_fpmax32 (v2si, v2si);
18634
18635 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
18636 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
18637 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
18638
18639
18640 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
18641 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
18642 v2si __builtin_vis_fpmin32 (v2si, v2si);
18643
18644 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
18645 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
18646 v2si __builtin_vis_fpminu32 (v2si, v2si);
18647 @end smallexample
18648
18649 @node SPU Built-in Functions
18650 @subsection SPU Built-in Functions
18651
18652 GCC provides extensions for the SPU processor as described in the
18653 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
18654 implementation differs in several ways.
18655
18656 @itemize @bullet
18657
18658 @item
18659 The optional extension of specifying vector constants in parentheses is
18660 not supported.
18661
18662 @item
18663 A vector initializer requires no cast if the vector constant is of the
18664 same type as the variable it is initializing.
18665
18666 @item
18667 If @code{signed} or @code{unsigned} is omitted, the signedness of the
18668 vector type is the default signedness of the base type. The default
18669 varies depending on the operating system, so a portable program should
18670 always specify the signedness.
18671
18672 @item
18673 By default, the keyword @code{__vector} is added. The macro
18674 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
18675 undefined.
18676
18677 @item
18678 GCC allows using a @code{typedef} name as the type specifier for a
18679 vector type.
18680
18681 @item
18682 For C, overloaded functions are implemented with macros so the following
18683 does not work:
18684
18685 @smallexample
18686 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
18687 @end smallexample
18688
18689 @noindent
18690 Since @code{spu_add} is a macro, the vector constant in the example
18691 is treated as four separate arguments. Wrap the entire argument in
18692 parentheses for this to work.
18693
18694 @item
18695 The extended version of @code{__builtin_expect} is not supported.
18696
18697 @end itemize
18698
18699 @emph{Note:} Only the interface described in the aforementioned
18700 specification is supported. Internally, GCC uses built-in functions to
18701 implement the required functionality, but these are not supported and
18702 are subject to change without notice.
18703
18704 @node TI C6X Built-in Functions
18705 @subsection TI C6X Built-in Functions
18706
18707 GCC provides intrinsics to access certain instructions of the TI C6X
18708 processors. These intrinsics, listed below, are available after
18709 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
18710 to C6X instructions.
18711
18712 @smallexample
18713
18714 int _sadd (int, int)
18715 int _ssub (int, int)
18716 int _sadd2 (int, int)
18717 int _ssub2 (int, int)
18718 long long _mpy2 (int, int)
18719 long long _smpy2 (int, int)
18720 int _add4 (int, int)
18721 int _sub4 (int, int)
18722 int _saddu4 (int, int)
18723
18724 int _smpy (int, int)
18725 int _smpyh (int, int)
18726 int _smpyhl (int, int)
18727 int _smpylh (int, int)
18728
18729 int _sshl (int, int)
18730 int _subc (int, int)
18731
18732 int _avg2 (int, int)
18733 int _avgu4 (int, int)
18734
18735 int _clrr (int, int)
18736 int _extr (int, int)
18737 int _extru (int, int)
18738 int _abs (int)
18739 int _abs2 (int)
18740
18741 @end smallexample
18742
18743 @node TILE-Gx Built-in Functions
18744 @subsection TILE-Gx Built-in Functions
18745
18746 GCC provides intrinsics to access every instruction of the TILE-Gx
18747 processor. The intrinsics are of the form:
18748
18749 @smallexample
18750
18751 unsigned long long __insn_@var{op} (...)
18752
18753 @end smallexample
18754
18755 Where @var{op} is the name of the instruction. Refer to the ISA manual
18756 for the complete list of instructions.
18757
18758 GCC also provides intrinsics to directly access the network registers.
18759 The intrinsics are:
18760
18761 @smallexample
18762
18763 unsigned long long __tile_idn0_receive (void)
18764 unsigned long long __tile_idn1_receive (void)
18765 unsigned long long __tile_udn0_receive (void)
18766 unsigned long long __tile_udn1_receive (void)
18767 unsigned long long __tile_udn2_receive (void)
18768 unsigned long long __tile_udn3_receive (void)
18769 void __tile_idn_send (unsigned long long)
18770 void __tile_udn_send (unsigned long long)
18771
18772 @end smallexample
18773
18774 The intrinsic @code{void __tile_network_barrier (void)} is used to
18775 guarantee that no network operations before it are reordered with
18776 those after it.
18777
18778 @node TILEPro Built-in Functions
18779 @subsection TILEPro Built-in Functions
18780
18781 GCC provides intrinsics to access every instruction of the TILEPro
18782 processor. The intrinsics are of the form:
18783
18784 @smallexample
18785
18786 unsigned __insn_@var{op} (...)
18787
18788 @end smallexample
18789
18790 @noindent
18791 where @var{op} is the name of the instruction. Refer to the ISA manual
18792 for the complete list of instructions.
18793
18794 GCC also provides intrinsics to directly access the network registers.
18795 The intrinsics are:
18796
18797 @smallexample
18798
18799 unsigned __tile_idn0_receive (void)
18800 unsigned __tile_idn1_receive (void)
18801 unsigned __tile_sn_receive (void)
18802 unsigned __tile_udn0_receive (void)
18803 unsigned __tile_udn1_receive (void)
18804 unsigned __tile_udn2_receive (void)
18805 unsigned __tile_udn3_receive (void)
18806 void __tile_idn_send (unsigned)
18807 void __tile_sn_send (unsigned)
18808 void __tile_udn_send (unsigned)
18809
18810 @end smallexample
18811
18812 The intrinsic @code{void __tile_network_barrier (void)} is used to
18813 guarantee that no network operations before it are reordered with
18814 those after it.
18815
18816 @node x86 Built-in Functions
18817 @subsection x86 Built-in Functions
18818
18819 These built-in functions are available for the x86-32 and x86-64 family
18820 of computers, depending on the command-line switches used.
18821
18822 If you specify command-line switches such as @option{-msse},
18823 the compiler could use the extended instruction sets even if the built-ins
18824 are not used explicitly in the program. For this reason, applications
18825 that perform run-time CPU detection must compile separate files for each
18826 supported architecture, using the appropriate flags. In particular,
18827 the file containing the CPU detection code should be compiled without
18828 these options.
18829
18830 The following machine modes are available for use with MMX built-in functions
18831 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
18832 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
18833 vector of eight 8-bit integers. Some of the built-in functions operate on
18834 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
18835
18836 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
18837 of two 32-bit floating-point values.
18838
18839 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
18840 floating-point values. Some instructions use a vector of four 32-bit
18841 integers, these use @code{V4SI}. Finally, some instructions operate on an
18842 entire vector register, interpreting it as a 128-bit integer, these use mode
18843 @code{TI}.
18844
18845 The x86-32 and x86-64 family of processors use additional built-in
18846 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
18847 floating point and @code{TC} 128-bit complex floating-point values.
18848
18849 The following floating-point built-in functions are always available. All
18850 of them implement the function that is part of the name.
18851
18852 @smallexample
18853 __float128 __builtin_fabsq (__float128)
18854 __float128 __builtin_copysignq (__float128, __float128)
18855 @end smallexample
18856
18857 The following built-in functions are always available.
18858
18859 @table @code
18860 @item __float128 __builtin_infq (void)
18861 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
18862 @findex __builtin_infq
18863
18864 @item __float128 __builtin_huge_valq (void)
18865 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
18866 @findex __builtin_huge_valq
18867
18868 @item __float128 __builtin_nanq (void)
18869 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
18870 @findex __builtin_nanq
18871
18872 @item __float128 __builtin_nansq (void)
18873 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
18874 @findex __builtin_nansq
18875 @end table
18876
18877 The following built-in function is always available.
18878
18879 @table @code
18880 @item void __builtin_ia32_pause (void)
18881 Generates the @code{pause} machine instruction with a compiler memory
18882 barrier.
18883 @end table
18884
18885 The following built-in functions are always available and can be used to
18886 check the target platform type.
18887
18888 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
18889 This function runs the CPU detection code to check the type of CPU and the
18890 features supported. This built-in function needs to be invoked along with the built-in functions
18891 to check CPU type and features, @code{__builtin_cpu_is} and
18892 @code{__builtin_cpu_supports}, only when used in a function that is
18893 executed before any constructors are called. The CPU detection code is
18894 automatically executed in a very high priority constructor.
18895
18896 For example, this function has to be used in @code{ifunc} resolvers that
18897 check for CPU type using the built-in functions @code{__builtin_cpu_is}
18898 and @code{__builtin_cpu_supports}, or in constructors on targets that
18899 don't support constructor priority.
18900 @smallexample
18901
18902 static void (*resolve_memcpy (void)) (void)
18903 @{
18904 // ifunc resolvers fire before constructors, explicitly call the init
18905 // function.
18906 __builtin_cpu_init ();
18907 if (__builtin_cpu_supports ("ssse3"))
18908 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
18909 else
18910 return default_memcpy;
18911 @}
18912
18913 void *memcpy (void *, const void *, size_t)
18914 __attribute__ ((ifunc ("resolve_memcpy")));
18915 @end smallexample
18916
18917 @end deftypefn
18918
18919 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
18920 This function returns a positive integer if the run-time CPU
18921 is of type @var{cpuname}
18922 and returns @code{0} otherwise. The following CPU names can be detected:
18923
18924 @table @samp
18925 @item intel
18926 Intel CPU.
18927
18928 @item atom
18929 Intel Atom CPU.
18930
18931 @item core2
18932 Intel Core 2 CPU.
18933
18934 @item corei7
18935 Intel Core i7 CPU.
18936
18937 @item nehalem
18938 Intel Core i7 Nehalem CPU.
18939
18940 @item westmere
18941 Intel Core i7 Westmere CPU.
18942
18943 @item sandybridge
18944 Intel Core i7 Sandy Bridge CPU.
18945
18946 @item amd
18947 AMD CPU.
18948
18949 @item amdfam10h
18950 AMD Family 10h CPU.
18951
18952 @item barcelona
18953 AMD Family 10h Barcelona CPU.
18954
18955 @item shanghai
18956 AMD Family 10h Shanghai CPU.
18957
18958 @item istanbul
18959 AMD Family 10h Istanbul CPU.
18960
18961 @item btver1
18962 AMD Family 14h CPU.
18963
18964 @item amdfam15h
18965 AMD Family 15h CPU.
18966
18967 @item bdver1
18968 AMD Family 15h Bulldozer version 1.
18969
18970 @item bdver2
18971 AMD Family 15h Bulldozer version 2.
18972
18973 @item bdver3
18974 AMD Family 15h Bulldozer version 3.
18975
18976 @item bdver4
18977 AMD Family 15h Bulldozer version 4.
18978
18979 @item btver2
18980 AMD Family 16h CPU.
18981
18982 @item znver1
18983 AMD Family 17h CPU.
18984 @end table
18985
18986 Here is an example:
18987 @smallexample
18988 if (__builtin_cpu_is ("corei7"))
18989 @{
18990 do_corei7 (); // Core i7 specific implementation.
18991 @}
18992 else
18993 @{
18994 do_generic (); // Generic implementation.
18995 @}
18996 @end smallexample
18997 @end deftypefn
18998
18999 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
19000 This function returns a positive integer if the run-time CPU
19001 supports @var{feature}
19002 and returns @code{0} otherwise. The following features can be detected:
19003
19004 @table @samp
19005 @item cmov
19006 CMOV instruction.
19007 @item mmx
19008 MMX instructions.
19009 @item popcnt
19010 POPCNT instruction.
19011 @item sse
19012 SSE instructions.
19013 @item sse2
19014 SSE2 instructions.
19015 @item sse3
19016 SSE3 instructions.
19017 @item ssse3
19018 SSSE3 instructions.
19019 @item sse4.1
19020 SSE4.1 instructions.
19021 @item sse4.2
19022 SSE4.2 instructions.
19023 @item avx
19024 AVX instructions.
19025 @item avx2
19026 AVX2 instructions.
19027 @item avx512f
19028 AVX512F instructions.
19029 @end table
19030
19031 Here is an example:
19032 @smallexample
19033 if (__builtin_cpu_supports ("popcnt"))
19034 @{
19035 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
19036 @}
19037 else
19038 @{
19039 count = generic_countbits (n); //generic implementation.
19040 @}
19041 @end smallexample
19042 @end deftypefn
19043
19044
19045 The following built-in functions are made available by @option{-mmmx}.
19046 All of them generate the machine instruction that is part of the name.
19047
19048 @smallexample
19049 v8qi __builtin_ia32_paddb (v8qi, v8qi)
19050 v4hi __builtin_ia32_paddw (v4hi, v4hi)
19051 v2si __builtin_ia32_paddd (v2si, v2si)
19052 v8qi __builtin_ia32_psubb (v8qi, v8qi)
19053 v4hi __builtin_ia32_psubw (v4hi, v4hi)
19054 v2si __builtin_ia32_psubd (v2si, v2si)
19055 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
19056 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
19057 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
19058 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
19059 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
19060 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
19061 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
19062 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
19063 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
19064 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
19065 di __builtin_ia32_pand (di, di)
19066 di __builtin_ia32_pandn (di,di)
19067 di __builtin_ia32_por (di, di)
19068 di __builtin_ia32_pxor (di, di)
19069 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
19070 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
19071 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
19072 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
19073 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
19074 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
19075 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
19076 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
19077 v2si __builtin_ia32_punpckhdq (v2si, v2si)
19078 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
19079 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
19080 v2si __builtin_ia32_punpckldq (v2si, v2si)
19081 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
19082 v4hi __builtin_ia32_packssdw (v2si, v2si)
19083 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
19084
19085 v4hi __builtin_ia32_psllw (v4hi, v4hi)
19086 v2si __builtin_ia32_pslld (v2si, v2si)
19087 v1di __builtin_ia32_psllq (v1di, v1di)
19088 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
19089 v2si __builtin_ia32_psrld (v2si, v2si)
19090 v1di __builtin_ia32_psrlq (v1di, v1di)
19091 v4hi __builtin_ia32_psraw (v4hi, v4hi)
19092 v2si __builtin_ia32_psrad (v2si, v2si)
19093 v4hi __builtin_ia32_psllwi (v4hi, int)
19094 v2si __builtin_ia32_pslldi (v2si, int)
19095 v1di __builtin_ia32_psllqi (v1di, int)
19096 v4hi __builtin_ia32_psrlwi (v4hi, int)
19097 v2si __builtin_ia32_psrldi (v2si, int)
19098 v1di __builtin_ia32_psrlqi (v1di, int)
19099 v4hi __builtin_ia32_psrawi (v4hi, int)
19100 v2si __builtin_ia32_psradi (v2si, int)
19101
19102 @end smallexample
19103
19104 The following built-in functions are made available either with
19105 @option{-msse}, or with a combination of @option{-m3dnow} and
19106 @option{-march=athlon}. All of them generate the machine
19107 instruction that is part of the name.
19108
19109 @smallexample
19110 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
19111 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
19112 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
19113 v1di __builtin_ia32_psadbw (v8qi, v8qi)
19114 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
19115 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
19116 v8qi __builtin_ia32_pminub (v8qi, v8qi)
19117 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
19118 int __builtin_ia32_pmovmskb (v8qi)
19119 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
19120 void __builtin_ia32_movntq (di *, di)
19121 void __builtin_ia32_sfence (void)
19122 @end smallexample
19123
19124 The following built-in functions are available when @option{-msse} is used.
19125 All of them generate the machine instruction that is part of the name.
19126
19127 @smallexample
19128 int __builtin_ia32_comieq (v4sf, v4sf)
19129 int __builtin_ia32_comineq (v4sf, v4sf)
19130 int __builtin_ia32_comilt (v4sf, v4sf)
19131 int __builtin_ia32_comile (v4sf, v4sf)
19132 int __builtin_ia32_comigt (v4sf, v4sf)
19133 int __builtin_ia32_comige (v4sf, v4sf)
19134 int __builtin_ia32_ucomieq (v4sf, v4sf)
19135 int __builtin_ia32_ucomineq (v4sf, v4sf)
19136 int __builtin_ia32_ucomilt (v4sf, v4sf)
19137 int __builtin_ia32_ucomile (v4sf, v4sf)
19138 int __builtin_ia32_ucomigt (v4sf, v4sf)
19139 int __builtin_ia32_ucomige (v4sf, v4sf)
19140 v4sf __builtin_ia32_addps (v4sf, v4sf)
19141 v4sf __builtin_ia32_subps (v4sf, v4sf)
19142 v4sf __builtin_ia32_mulps (v4sf, v4sf)
19143 v4sf __builtin_ia32_divps (v4sf, v4sf)
19144 v4sf __builtin_ia32_addss (v4sf, v4sf)
19145 v4sf __builtin_ia32_subss (v4sf, v4sf)
19146 v4sf __builtin_ia32_mulss (v4sf, v4sf)
19147 v4sf __builtin_ia32_divss (v4sf, v4sf)
19148 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
19149 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
19150 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
19151 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
19152 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
19153 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
19154 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
19155 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
19156 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
19157 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
19158 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
19159 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
19160 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
19161 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
19162 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
19163 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
19164 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
19165 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
19166 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
19167 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
19168 v4sf __builtin_ia32_maxps (v4sf, v4sf)
19169 v4sf __builtin_ia32_maxss (v4sf, v4sf)
19170 v4sf __builtin_ia32_minps (v4sf, v4sf)
19171 v4sf __builtin_ia32_minss (v4sf, v4sf)
19172 v4sf __builtin_ia32_andps (v4sf, v4sf)
19173 v4sf __builtin_ia32_andnps (v4sf, v4sf)
19174 v4sf __builtin_ia32_orps (v4sf, v4sf)
19175 v4sf __builtin_ia32_xorps (v4sf, v4sf)
19176 v4sf __builtin_ia32_movss (v4sf, v4sf)
19177 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
19178 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
19179 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
19180 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
19181 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
19182 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
19183 v2si __builtin_ia32_cvtps2pi (v4sf)
19184 int __builtin_ia32_cvtss2si (v4sf)
19185 v2si __builtin_ia32_cvttps2pi (v4sf)
19186 int __builtin_ia32_cvttss2si (v4sf)
19187 v4sf __builtin_ia32_rcpps (v4sf)
19188 v4sf __builtin_ia32_rsqrtps (v4sf)
19189 v4sf __builtin_ia32_sqrtps (v4sf)
19190 v4sf __builtin_ia32_rcpss (v4sf)
19191 v4sf __builtin_ia32_rsqrtss (v4sf)
19192 v4sf __builtin_ia32_sqrtss (v4sf)
19193 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
19194 void __builtin_ia32_movntps (float *, v4sf)
19195 int __builtin_ia32_movmskps (v4sf)
19196 @end smallexample
19197
19198 The following built-in functions are available when @option{-msse} is used.
19199
19200 @table @code
19201 @item v4sf __builtin_ia32_loadups (float *)
19202 Generates the @code{movups} machine instruction as a load from memory.
19203 @item void __builtin_ia32_storeups (float *, v4sf)
19204 Generates the @code{movups} machine instruction as a store to memory.
19205 @item v4sf __builtin_ia32_loadss (float *)
19206 Generates the @code{movss} machine instruction as a load from memory.
19207 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
19208 Generates the @code{movhps} machine instruction as a load from memory.
19209 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
19210 Generates the @code{movlps} machine instruction as a load from memory
19211 @item void __builtin_ia32_storehps (v2sf *, v4sf)
19212 Generates the @code{movhps} machine instruction as a store to memory.
19213 @item void __builtin_ia32_storelps (v2sf *, v4sf)
19214 Generates the @code{movlps} machine instruction as a store to memory.
19215 @end table
19216
19217 The following built-in functions are available when @option{-msse2} is used.
19218 All of them generate the machine instruction that is part of the name.
19219
19220 @smallexample
19221 int __builtin_ia32_comisdeq (v2df, v2df)
19222 int __builtin_ia32_comisdlt (v2df, v2df)
19223 int __builtin_ia32_comisdle (v2df, v2df)
19224 int __builtin_ia32_comisdgt (v2df, v2df)
19225 int __builtin_ia32_comisdge (v2df, v2df)
19226 int __builtin_ia32_comisdneq (v2df, v2df)
19227 int __builtin_ia32_ucomisdeq (v2df, v2df)
19228 int __builtin_ia32_ucomisdlt (v2df, v2df)
19229 int __builtin_ia32_ucomisdle (v2df, v2df)
19230 int __builtin_ia32_ucomisdgt (v2df, v2df)
19231 int __builtin_ia32_ucomisdge (v2df, v2df)
19232 int __builtin_ia32_ucomisdneq (v2df, v2df)
19233 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
19234 v2df __builtin_ia32_cmpltpd (v2df, v2df)
19235 v2df __builtin_ia32_cmplepd (v2df, v2df)
19236 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
19237 v2df __builtin_ia32_cmpgepd (v2df, v2df)
19238 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
19239 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
19240 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
19241 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
19242 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
19243 v2df __builtin_ia32_cmpngepd (v2df, v2df)
19244 v2df __builtin_ia32_cmpordpd (v2df, v2df)
19245 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
19246 v2df __builtin_ia32_cmpltsd (v2df, v2df)
19247 v2df __builtin_ia32_cmplesd (v2df, v2df)
19248 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
19249 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
19250 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
19251 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
19252 v2df __builtin_ia32_cmpordsd (v2df, v2df)
19253 v2di __builtin_ia32_paddq (v2di, v2di)
19254 v2di __builtin_ia32_psubq (v2di, v2di)
19255 v2df __builtin_ia32_addpd (v2df, v2df)
19256 v2df __builtin_ia32_subpd (v2df, v2df)
19257 v2df __builtin_ia32_mulpd (v2df, v2df)
19258 v2df __builtin_ia32_divpd (v2df, v2df)
19259 v2df __builtin_ia32_addsd (v2df, v2df)
19260 v2df __builtin_ia32_subsd (v2df, v2df)
19261 v2df __builtin_ia32_mulsd (v2df, v2df)
19262 v2df __builtin_ia32_divsd (v2df, v2df)
19263 v2df __builtin_ia32_minpd (v2df, v2df)
19264 v2df __builtin_ia32_maxpd (v2df, v2df)
19265 v2df __builtin_ia32_minsd (v2df, v2df)
19266 v2df __builtin_ia32_maxsd (v2df, v2df)
19267 v2df __builtin_ia32_andpd (v2df, v2df)
19268 v2df __builtin_ia32_andnpd (v2df, v2df)
19269 v2df __builtin_ia32_orpd (v2df, v2df)
19270 v2df __builtin_ia32_xorpd (v2df, v2df)
19271 v2df __builtin_ia32_movsd (v2df, v2df)
19272 v2df __builtin_ia32_unpckhpd (v2df, v2df)
19273 v2df __builtin_ia32_unpcklpd (v2df, v2df)
19274 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
19275 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
19276 v4si __builtin_ia32_paddd128 (v4si, v4si)
19277 v2di __builtin_ia32_paddq128 (v2di, v2di)
19278 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
19279 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
19280 v4si __builtin_ia32_psubd128 (v4si, v4si)
19281 v2di __builtin_ia32_psubq128 (v2di, v2di)
19282 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
19283 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
19284 v2di __builtin_ia32_pand128 (v2di, v2di)
19285 v2di __builtin_ia32_pandn128 (v2di, v2di)
19286 v2di __builtin_ia32_por128 (v2di, v2di)
19287 v2di __builtin_ia32_pxor128 (v2di, v2di)
19288 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
19289 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
19290 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
19291 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
19292 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
19293 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
19294 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
19295 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
19296 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
19297 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
19298 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
19299 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
19300 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
19301 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
19302 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
19303 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
19304 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
19305 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
19306 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
19307 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
19308 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
19309 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
19310 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
19311 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
19312 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
19313 v2df __builtin_ia32_loadupd (double *)
19314 void __builtin_ia32_storeupd (double *, v2df)
19315 v2df __builtin_ia32_loadhpd (v2df, double const *)
19316 v2df __builtin_ia32_loadlpd (v2df, double const *)
19317 int __builtin_ia32_movmskpd (v2df)
19318 int __builtin_ia32_pmovmskb128 (v16qi)
19319 void __builtin_ia32_movnti (int *, int)
19320 void __builtin_ia32_movnti64 (long long int *, long long int)
19321 void __builtin_ia32_movntpd (double *, v2df)
19322 void __builtin_ia32_movntdq (v2df *, v2df)
19323 v4si __builtin_ia32_pshufd (v4si, int)
19324 v8hi __builtin_ia32_pshuflw (v8hi, int)
19325 v8hi __builtin_ia32_pshufhw (v8hi, int)
19326 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
19327 v2df __builtin_ia32_sqrtpd (v2df)
19328 v2df __builtin_ia32_sqrtsd (v2df)
19329 v2df __builtin_ia32_shufpd (v2df, v2df, int)
19330 v2df __builtin_ia32_cvtdq2pd (v4si)
19331 v4sf __builtin_ia32_cvtdq2ps (v4si)
19332 v4si __builtin_ia32_cvtpd2dq (v2df)
19333 v2si __builtin_ia32_cvtpd2pi (v2df)
19334 v4sf __builtin_ia32_cvtpd2ps (v2df)
19335 v4si __builtin_ia32_cvttpd2dq (v2df)
19336 v2si __builtin_ia32_cvttpd2pi (v2df)
19337 v2df __builtin_ia32_cvtpi2pd (v2si)
19338 int __builtin_ia32_cvtsd2si (v2df)
19339 int __builtin_ia32_cvttsd2si (v2df)
19340 long long __builtin_ia32_cvtsd2si64 (v2df)
19341 long long __builtin_ia32_cvttsd2si64 (v2df)
19342 v4si __builtin_ia32_cvtps2dq (v4sf)
19343 v2df __builtin_ia32_cvtps2pd (v4sf)
19344 v4si __builtin_ia32_cvttps2dq (v4sf)
19345 v2df __builtin_ia32_cvtsi2sd (v2df, int)
19346 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
19347 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
19348 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
19349 void __builtin_ia32_clflush (const void *)
19350 void __builtin_ia32_lfence (void)
19351 void __builtin_ia32_mfence (void)
19352 v16qi __builtin_ia32_loaddqu (const char *)
19353 void __builtin_ia32_storedqu (char *, v16qi)
19354 v1di __builtin_ia32_pmuludq (v2si, v2si)
19355 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
19356 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
19357 v4si __builtin_ia32_pslld128 (v4si, v4si)
19358 v2di __builtin_ia32_psllq128 (v2di, v2di)
19359 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
19360 v4si __builtin_ia32_psrld128 (v4si, v4si)
19361 v2di __builtin_ia32_psrlq128 (v2di, v2di)
19362 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
19363 v4si __builtin_ia32_psrad128 (v4si, v4si)
19364 v2di __builtin_ia32_pslldqi128 (v2di, int)
19365 v8hi __builtin_ia32_psllwi128 (v8hi, int)
19366 v4si __builtin_ia32_pslldi128 (v4si, int)
19367 v2di __builtin_ia32_psllqi128 (v2di, int)
19368 v2di __builtin_ia32_psrldqi128 (v2di, int)
19369 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
19370 v4si __builtin_ia32_psrldi128 (v4si, int)
19371 v2di __builtin_ia32_psrlqi128 (v2di, int)
19372 v8hi __builtin_ia32_psrawi128 (v8hi, int)
19373 v4si __builtin_ia32_psradi128 (v4si, int)
19374 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
19375 v2di __builtin_ia32_movq128 (v2di)
19376 @end smallexample
19377
19378 The following built-in functions are available when @option{-msse3} is used.
19379 All of them generate the machine instruction that is part of the name.
19380
19381 @smallexample
19382 v2df __builtin_ia32_addsubpd (v2df, v2df)
19383 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
19384 v2df __builtin_ia32_haddpd (v2df, v2df)
19385 v4sf __builtin_ia32_haddps (v4sf, v4sf)
19386 v2df __builtin_ia32_hsubpd (v2df, v2df)
19387 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
19388 v16qi __builtin_ia32_lddqu (char const *)
19389 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
19390 v4sf __builtin_ia32_movshdup (v4sf)
19391 v4sf __builtin_ia32_movsldup (v4sf)
19392 void __builtin_ia32_mwait (unsigned int, unsigned int)
19393 @end smallexample
19394
19395 The following built-in functions are available when @option{-mssse3} is used.
19396 All of them generate the machine instruction that is part of the name.
19397
19398 @smallexample
19399 v2si __builtin_ia32_phaddd (v2si, v2si)
19400 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
19401 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
19402 v2si __builtin_ia32_phsubd (v2si, v2si)
19403 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
19404 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
19405 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
19406 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
19407 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
19408 v8qi __builtin_ia32_psignb (v8qi, v8qi)
19409 v2si __builtin_ia32_psignd (v2si, v2si)
19410 v4hi __builtin_ia32_psignw (v4hi, v4hi)
19411 v1di __builtin_ia32_palignr (v1di, v1di, int)
19412 v8qi __builtin_ia32_pabsb (v8qi)
19413 v2si __builtin_ia32_pabsd (v2si)
19414 v4hi __builtin_ia32_pabsw (v4hi)
19415 @end smallexample
19416
19417 The following built-in functions are available when @option{-mssse3} is used.
19418 All of them generate the machine instruction that is part of the name.
19419
19420 @smallexample
19421 v4si __builtin_ia32_phaddd128 (v4si, v4si)
19422 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
19423 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
19424 v4si __builtin_ia32_phsubd128 (v4si, v4si)
19425 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
19426 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
19427 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
19428 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
19429 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
19430 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
19431 v4si __builtin_ia32_psignd128 (v4si, v4si)
19432 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
19433 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
19434 v16qi __builtin_ia32_pabsb128 (v16qi)
19435 v4si __builtin_ia32_pabsd128 (v4si)
19436 v8hi __builtin_ia32_pabsw128 (v8hi)
19437 @end smallexample
19438
19439 The following built-in functions are available when @option{-msse4.1} is
19440 used. All of them generate the machine instruction that is part of the
19441 name.
19442
19443 @smallexample
19444 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
19445 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
19446 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
19447 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
19448 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19449 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19450 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19451 v2di __builtin_ia32_movntdqa (v2di *);
19452 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19453 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19454 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19455 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19456 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19457 v8hi __builtin_ia32_phminposuw128 (v8hi)
19458 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19459 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19460 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19461 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19462 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19463 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19464 v4si __builtin_ia32_pminud128 (v4si, v4si)
19465 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19466 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19467 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19468 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19469 v2di __builtin_ia32_pmovsxdq128 (v4si)
19470 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19471 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19472 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19473 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19474 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19475 v2di __builtin_ia32_pmovzxdq128 (v4si)
19476 v4si __builtin_ia32_pmovzxwd128 (v8hi)
19477 v2di __builtin_ia32_pmovzxwq128 (v8hi)
19478 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
19479 v4si __builtin_ia32_pmulld128 (v4si, v4si)
19480 int __builtin_ia32_ptestc128 (v2di, v2di)
19481 int __builtin_ia32_ptestnzc128 (v2di, v2di)
19482 int __builtin_ia32_ptestz128 (v2di, v2di)
19483 v2df __builtin_ia32_roundpd (v2df, const int)
19484 v4sf __builtin_ia32_roundps (v4sf, const int)
19485 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
19486 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
19487 @end smallexample
19488
19489 The following built-in functions are available when @option{-msse4.1} is
19490 used.
19491
19492 @table @code
19493 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
19494 Generates the @code{insertps} machine instruction.
19495 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
19496 Generates the @code{pextrb} machine instruction.
19497 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
19498 Generates the @code{pinsrb} machine instruction.
19499 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
19500 Generates the @code{pinsrd} machine instruction.
19501 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
19502 Generates the @code{pinsrq} machine instruction in 64bit mode.
19503 @end table
19504
19505 The following built-in functions are changed to generate new SSE4.1
19506 instructions when @option{-msse4.1} is used.
19507
19508 @table @code
19509 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
19510 Generates the @code{extractps} machine instruction.
19511 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
19512 Generates the @code{pextrd} machine instruction.
19513 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
19514 Generates the @code{pextrq} machine instruction in 64bit mode.
19515 @end table
19516
19517 The following built-in functions are available when @option{-msse4.2} is
19518 used. All of them generate the machine instruction that is part of the
19519 name.
19520
19521 @smallexample
19522 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
19523 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
19524 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
19525 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
19526 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
19527 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
19528 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
19529 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
19530 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
19531 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
19532 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
19533 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
19534 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
19535 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
19536 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
19537 @end smallexample
19538
19539 The following built-in functions are available when @option{-msse4.2} is
19540 used.
19541
19542 @table @code
19543 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
19544 Generates the @code{crc32b} machine instruction.
19545 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
19546 Generates the @code{crc32w} machine instruction.
19547 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
19548 Generates the @code{crc32l} machine instruction.
19549 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
19550 Generates the @code{crc32q} machine instruction.
19551 @end table
19552
19553 The following built-in functions are changed to generate new SSE4.2
19554 instructions when @option{-msse4.2} is used.
19555
19556 @table @code
19557 @item int __builtin_popcount (unsigned int)
19558 Generates the @code{popcntl} machine instruction.
19559 @item int __builtin_popcountl (unsigned long)
19560 Generates the @code{popcntl} or @code{popcntq} machine instruction,
19561 depending on the size of @code{unsigned long}.
19562 @item int __builtin_popcountll (unsigned long long)
19563 Generates the @code{popcntq} machine instruction.
19564 @end table
19565
19566 The following built-in functions are available when @option{-mavx} is
19567 used. All of them generate the machine instruction that is part of the
19568 name.
19569
19570 @smallexample
19571 v4df __builtin_ia32_addpd256 (v4df,v4df)
19572 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
19573 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
19574 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
19575 v4df __builtin_ia32_andnpd256 (v4df,v4df)
19576 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
19577 v4df __builtin_ia32_andpd256 (v4df,v4df)
19578 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
19579 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
19580 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
19581 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
19582 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
19583 v2df __builtin_ia32_cmppd (v2df,v2df,int)
19584 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
19585 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
19586 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
19587 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
19588 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
19589 v4df __builtin_ia32_cvtdq2pd256 (v4si)
19590 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
19591 v4si __builtin_ia32_cvtpd2dq256 (v4df)
19592 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
19593 v8si __builtin_ia32_cvtps2dq256 (v8sf)
19594 v4df __builtin_ia32_cvtps2pd256 (v4sf)
19595 v4si __builtin_ia32_cvttpd2dq256 (v4df)
19596 v8si __builtin_ia32_cvttps2dq256 (v8sf)
19597 v4df __builtin_ia32_divpd256 (v4df,v4df)
19598 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
19599 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
19600 v4df __builtin_ia32_haddpd256 (v4df,v4df)
19601 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
19602 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
19603 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
19604 v32qi __builtin_ia32_lddqu256 (pcchar)
19605 v32qi __builtin_ia32_loaddqu256 (pcchar)
19606 v4df __builtin_ia32_loadupd256 (pcdouble)
19607 v8sf __builtin_ia32_loadups256 (pcfloat)
19608 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
19609 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
19610 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
19611 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
19612 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
19613 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
19614 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
19615 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
19616 v4df __builtin_ia32_maxpd256 (v4df,v4df)
19617 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
19618 v4df __builtin_ia32_minpd256 (v4df,v4df)
19619 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
19620 v4df __builtin_ia32_movddup256 (v4df)
19621 int __builtin_ia32_movmskpd256 (v4df)
19622 int __builtin_ia32_movmskps256 (v8sf)
19623 v8sf __builtin_ia32_movshdup256 (v8sf)
19624 v8sf __builtin_ia32_movsldup256 (v8sf)
19625 v4df __builtin_ia32_mulpd256 (v4df,v4df)
19626 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
19627 v4df __builtin_ia32_orpd256 (v4df,v4df)
19628 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
19629 v2df __builtin_ia32_pd_pd256 (v4df)
19630 v4df __builtin_ia32_pd256_pd (v2df)
19631 v4sf __builtin_ia32_ps_ps256 (v8sf)
19632 v8sf __builtin_ia32_ps256_ps (v4sf)
19633 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
19634 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
19635 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
19636 v8sf __builtin_ia32_rcpps256 (v8sf)
19637 v4df __builtin_ia32_roundpd256 (v4df,int)
19638 v8sf __builtin_ia32_roundps256 (v8sf,int)
19639 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
19640 v8sf __builtin_ia32_rsqrtps256 (v8sf)
19641 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
19642 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
19643 v4si __builtin_ia32_si_si256 (v8si)
19644 v8si __builtin_ia32_si256_si (v4si)
19645 v4df __builtin_ia32_sqrtpd256 (v4df)
19646 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
19647 v8sf __builtin_ia32_sqrtps256 (v8sf)
19648 void __builtin_ia32_storedqu256 (pchar,v32qi)
19649 void __builtin_ia32_storeupd256 (pdouble,v4df)
19650 void __builtin_ia32_storeups256 (pfloat,v8sf)
19651 v4df __builtin_ia32_subpd256 (v4df,v4df)
19652 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
19653 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
19654 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
19655 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
19656 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
19657 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
19658 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
19659 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
19660 v4sf __builtin_ia32_vbroadcastss (pcfloat)
19661 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
19662 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
19663 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
19664 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
19665 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
19666 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
19667 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
19668 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
19669 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
19670 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
19671 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
19672 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
19673 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
19674 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
19675 v2df __builtin_ia32_vpermilpd (v2df,int)
19676 v4df __builtin_ia32_vpermilpd256 (v4df,int)
19677 v4sf __builtin_ia32_vpermilps (v4sf,int)
19678 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
19679 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
19680 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
19681 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
19682 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
19683 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
19684 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
19685 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
19686 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
19687 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
19688 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
19689 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
19690 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
19691 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
19692 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
19693 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
19694 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
19695 void __builtin_ia32_vzeroall (void)
19696 void __builtin_ia32_vzeroupper (void)
19697 v4df __builtin_ia32_xorpd256 (v4df,v4df)
19698 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
19699 @end smallexample
19700
19701 The following built-in functions are available when @option{-mavx2} is
19702 used. All of them generate the machine instruction that is part of the
19703 name.
19704
19705 @smallexample
19706 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
19707 v32qi __builtin_ia32_pabsb256 (v32qi)
19708 v16hi __builtin_ia32_pabsw256 (v16hi)
19709 v8si __builtin_ia32_pabsd256 (v8si)
19710 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
19711 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
19712 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
19713 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
19714 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
19715 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
19716 v8si __builtin_ia32_paddd256 (v8si,v8si)
19717 v4di __builtin_ia32_paddq256 (v4di,v4di)
19718 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
19719 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
19720 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
19721 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
19722 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
19723 v4di __builtin_ia32_andsi256 (v4di,v4di)
19724 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
19725 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
19726 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
19727 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
19728 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
19729 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
19730 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
19731 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
19732 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
19733 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
19734 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
19735 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
19736 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
19737 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
19738 v8si __builtin_ia32_phaddd256 (v8si,v8si)
19739 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
19740 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
19741 v8si __builtin_ia32_phsubd256 (v8si,v8si)
19742 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
19743 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
19744 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
19745 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
19746 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
19747 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
19748 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
19749 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
19750 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
19751 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
19752 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
19753 v8si __builtin_ia32_pminsd256 (v8si,v8si)
19754 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
19755 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
19756 v8si __builtin_ia32_pminud256 (v8si,v8si)
19757 int __builtin_ia32_pmovmskb256 (v32qi)
19758 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
19759 v8si __builtin_ia32_pmovsxbd256 (v16qi)
19760 v4di __builtin_ia32_pmovsxbq256 (v16qi)
19761 v8si __builtin_ia32_pmovsxwd256 (v8hi)
19762 v4di __builtin_ia32_pmovsxwq256 (v8hi)
19763 v4di __builtin_ia32_pmovsxdq256 (v4si)
19764 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
19765 v8si __builtin_ia32_pmovzxbd256 (v16qi)
19766 v4di __builtin_ia32_pmovzxbq256 (v16qi)
19767 v8si __builtin_ia32_pmovzxwd256 (v8hi)
19768 v4di __builtin_ia32_pmovzxwq256 (v8hi)
19769 v4di __builtin_ia32_pmovzxdq256 (v4si)
19770 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
19771 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
19772 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
19773 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
19774 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
19775 v8si __builtin_ia32_pmulld256 (v8si,v8si)
19776 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
19777 v4di __builtin_ia32_por256 (v4di,v4di)
19778 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
19779 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
19780 v8si __builtin_ia32_pshufd256 (v8si,int)
19781 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
19782 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
19783 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
19784 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
19785 v8si __builtin_ia32_psignd256 (v8si,v8si)
19786 v4di __builtin_ia32_pslldqi256 (v4di,int)
19787 v16hi __builtin_ia32_psllwi256 (16hi,int)
19788 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
19789 v8si __builtin_ia32_pslldi256 (v8si,int)
19790 v8si __builtin_ia32_pslld256(v8si,v4si)
19791 v4di __builtin_ia32_psllqi256 (v4di,int)
19792 v4di __builtin_ia32_psllq256(v4di,v2di)
19793 v16hi __builtin_ia32_psrawi256 (v16hi,int)
19794 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
19795 v8si __builtin_ia32_psradi256 (v8si,int)
19796 v8si __builtin_ia32_psrad256 (v8si,v4si)
19797 v4di __builtin_ia32_psrldqi256 (v4di, int)
19798 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
19799 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
19800 v8si __builtin_ia32_psrldi256 (v8si,int)
19801 v8si __builtin_ia32_psrld256 (v8si,v4si)
19802 v4di __builtin_ia32_psrlqi256 (v4di,int)
19803 v4di __builtin_ia32_psrlq256(v4di,v2di)
19804 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
19805 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
19806 v8si __builtin_ia32_psubd256 (v8si,v8si)
19807 v4di __builtin_ia32_psubq256 (v4di,v4di)
19808 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
19809 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
19810 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
19811 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
19812 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
19813 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
19814 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
19815 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
19816 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
19817 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
19818 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
19819 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
19820 v4di __builtin_ia32_pxor256 (v4di,v4di)
19821 v4di __builtin_ia32_movntdqa256 (pv4di)
19822 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
19823 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
19824 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
19825 v4di __builtin_ia32_vbroadcastsi256 (v2di)
19826 v4si __builtin_ia32_pblendd128 (v4si,v4si)
19827 v8si __builtin_ia32_pblendd256 (v8si,v8si)
19828 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
19829 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
19830 v8si __builtin_ia32_pbroadcastd256 (v4si)
19831 v4di __builtin_ia32_pbroadcastq256 (v2di)
19832 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
19833 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
19834 v4si __builtin_ia32_pbroadcastd128 (v4si)
19835 v2di __builtin_ia32_pbroadcastq128 (v2di)
19836 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
19837 v4df __builtin_ia32_permdf256 (v4df,int)
19838 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
19839 v4di __builtin_ia32_permdi256 (v4di,int)
19840 v4di __builtin_ia32_permti256 (v4di,v4di,int)
19841 v4di __builtin_ia32_extract128i256 (v4di,int)
19842 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
19843 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
19844 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
19845 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
19846 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
19847 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
19848 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
19849 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
19850 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
19851 v8si __builtin_ia32_psllv8si (v8si,v8si)
19852 v4si __builtin_ia32_psllv4si (v4si,v4si)
19853 v4di __builtin_ia32_psllv4di (v4di,v4di)
19854 v2di __builtin_ia32_psllv2di (v2di,v2di)
19855 v8si __builtin_ia32_psrav8si (v8si,v8si)
19856 v4si __builtin_ia32_psrav4si (v4si,v4si)
19857 v8si __builtin_ia32_psrlv8si (v8si,v8si)
19858 v4si __builtin_ia32_psrlv4si (v4si,v4si)
19859 v4di __builtin_ia32_psrlv4di (v4di,v4di)
19860 v2di __builtin_ia32_psrlv2di (v2di,v2di)
19861 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
19862 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
19863 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
19864 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
19865 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
19866 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
19867 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
19868 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
19869 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
19870 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
19871 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
19872 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
19873 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
19874 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
19875 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
19876 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
19877 @end smallexample
19878
19879 The following built-in functions are available when @option{-maes} is
19880 used. All of them generate the machine instruction that is part of the
19881 name.
19882
19883 @smallexample
19884 v2di __builtin_ia32_aesenc128 (v2di, v2di)
19885 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
19886 v2di __builtin_ia32_aesdec128 (v2di, v2di)
19887 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
19888 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
19889 v2di __builtin_ia32_aesimc128 (v2di)
19890 @end smallexample
19891
19892 The following built-in function is available when @option{-mpclmul} is
19893 used.
19894
19895 @table @code
19896 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
19897 Generates the @code{pclmulqdq} machine instruction.
19898 @end table
19899
19900 The following built-in function is available when @option{-mfsgsbase} is
19901 used. All of them generate the machine instruction that is part of the
19902 name.
19903
19904 @smallexample
19905 unsigned int __builtin_ia32_rdfsbase32 (void)
19906 unsigned long long __builtin_ia32_rdfsbase64 (void)
19907 unsigned int __builtin_ia32_rdgsbase32 (void)
19908 unsigned long long __builtin_ia32_rdgsbase64 (void)
19909 void _writefsbase_u32 (unsigned int)
19910 void _writefsbase_u64 (unsigned long long)
19911 void _writegsbase_u32 (unsigned int)
19912 void _writegsbase_u64 (unsigned long long)
19913 @end smallexample
19914
19915 The following built-in function is available when @option{-mrdrnd} is
19916 used. All of them generate the machine instruction that is part of the
19917 name.
19918
19919 @smallexample
19920 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
19921 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
19922 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
19923 @end smallexample
19924
19925 The following built-in functions are available when @option{-msse4a} is used.
19926 All of them generate the machine instruction that is part of the name.
19927
19928 @smallexample
19929 void __builtin_ia32_movntsd (double *, v2df)
19930 void __builtin_ia32_movntss (float *, v4sf)
19931 v2di __builtin_ia32_extrq (v2di, v16qi)
19932 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
19933 v2di __builtin_ia32_insertq (v2di, v2di)
19934 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
19935 @end smallexample
19936
19937 The following built-in functions are available when @option{-mxop} is used.
19938 @smallexample
19939 v2df __builtin_ia32_vfrczpd (v2df)
19940 v4sf __builtin_ia32_vfrczps (v4sf)
19941 v2df __builtin_ia32_vfrczsd (v2df)
19942 v4sf __builtin_ia32_vfrczss (v4sf)
19943 v4df __builtin_ia32_vfrczpd256 (v4df)
19944 v8sf __builtin_ia32_vfrczps256 (v8sf)
19945 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
19946 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
19947 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
19948 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
19949 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
19950 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
19951 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
19952 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
19953 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
19954 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
19955 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
19956 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
19957 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
19958 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
19959 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19960 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
19961 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
19962 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
19963 v4si __builtin_ia32_vpcomequd (v4si, v4si)
19964 v2di __builtin_ia32_vpcomequq (v2di, v2di)
19965 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
19966 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19967 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
19968 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
19969 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
19970 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
19971 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
19972 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
19973 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
19974 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
19975 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
19976 v4si __builtin_ia32_vpcomged (v4si, v4si)
19977 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
19978 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
19979 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
19980 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
19981 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
19982 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
19983 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
19984 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
19985 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
19986 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
19987 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
19988 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
19989 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
19990 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
19991 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
19992 v4si __builtin_ia32_vpcomled (v4si, v4si)
19993 v2di __builtin_ia32_vpcomleq (v2di, v2di)
19994 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
19995 v4si __builtin_ia32_vpcomleud (v4si, v4si)
19996 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
19997 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
19998 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
19999 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
20000 v4si __builtin_ia32_vpcomltd (v4si, v4si)
20001 v2di __builtin_ia32_vpcomltq (v2di, v2di)
20002 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
20003 v4si __builtin_ia32_vpcomltud (v4si, v4si)
20004 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
20005 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
20006 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
20007 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
20008 v4si __builtin_ia32_vpcomned (v4si, v4si)
20009 v2di __builtin_ia32_vpcomneq (v2di, v2di)
20010 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
20011 v4si __builtin_ia32_vpcomneud (v4si, v4si)
20012 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
20013 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
20014 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
20015 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
20016 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
20017 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
20018 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
20019 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
20020 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
20021 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
20022 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
20023 v4si __builtin_ia32_vphaddbd (v16qi)
20024 v2di __builtin_ia32_vphaddbq (v16qi)
20025 v8hi __builtin_ia32_vphaddbw (v16qi)
20026 v2di __builtin_ia32_vphadddq (v4si)
20027 v4si __builtin_ia32_vphaddubd (v16qi)
20028 v2di __builtin_ia32_vphaddubq (v16qi)
20029 v8hi __builtin_ia32_vphaddubw (v16qi)
20030 v2di __builtin_ia32_vphaddudq (v4si)
20031 v4si __builtin_ia32_vphadduwd (v8hi)
20032 v2di __builtin_ia32_vphadduwq (v8hi)
20033 v4si __builtin_ia32_vphaddwd (v8hi)
20034 v2di __builtin_ia32_vphaddwq (v8hi)
20035 v8hi __builtin_ia32_vphsubbw (v16qi)
20036 v2di __builtin_ia32_vphsubdq (v4si)
20037 v4si __builtin_ia32_vphsubwd (v8hi)
20038 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
20039 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
20040 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
20041 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
20042 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
20043 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
20044 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
20045 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
20046 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
20047 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
20048 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
20049 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
20050 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
20051 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
20052 v4si __builtin_ia32_vprotd (v4si, v4si)
20053 v2di __builtin_ia32_vprotq (v2di, v2di)
20054 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
20055 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
20056 v4si __builtin_ia32_vpshad (v4si, v4si)
20057 v2di __builtin_ia32_vpshaq (v2di, v2di)
20058 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
20059 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
20060 v4si __builtin_ia32_vpshld (v4si, v4si)
20061 v2di __builtin_ia32_vpshlq (v2di, v2di)
20062 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
20063 @end smallexample
20064
20065 The following built-in functions are available when @option{-mfma4} is used.
20066 All of them generate the machine instruction that is part of the name.
20067
20068 @smallexample
20069 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
20070 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
20071 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
20072 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
20073 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
20074 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
20075 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
20076 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
20077 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
20078 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
20079 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
20080 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
20081 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
20082 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
20083 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
20084 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
20085 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
20086 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
20087 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
20088 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
20089 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
20090 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
20091 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
20092 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
20093 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
20094 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
20095 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
20096 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
20097 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
20098 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
20099 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
20100 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
20101
20102 @end smallexample
20103
20104 The following built-in functions are available when @option{-mlwp} is used.
20105
20106 @smallexample
20107 void __builtin_ia32_llwpcb16 (void *);
20108 void __builtin_ia32_llwpcb32 (void *);
20109 void __builtin_ia32_llwpcb64 (void *);
20110 void * __builtin_ia32_llwpcb16 (void);
20111 void * __builtin_ia32_llwpcb32 (void);
20112 void * __builtin_ia32_llwpcb64 (void);
20113 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
20114 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
20115 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
20116 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
20117 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
20118 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
20119 @end smallexample
20120
20121 The following built-in functions are available when @option{-mbmi} is used.
20122 All of them generate the machine instruction that is part of the name.
20123 @smallexample
20124 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
20125 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
20126 @end smallexample
20127
20128 The following built-in functions are available when @option{-mbmi2} is used.
20129 All of them generate the machine instruction that is part of the name.
20130 @smallexample
20131 unsigned int _bzhi_u32 (unsigned int, unsigned int)
20132 unsigned int _pdep_u32 (unsigned int, unsigned int)
20133 unsigned int _pext_u32 (unsigned int, unsigned int)
20134 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
20135 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
20136 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
20137 @end smallexample
20138
20139 The following built-in functions are available when @option{-mlzcnt} is used.
20140 All of them generate the machine instruction that is part of the name.
20141 @smallexample
20142 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
20143 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
20144 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
20145 @end smallexample
20146
20147 The following built-in functions are available when @option{-mfxsr} is used.
20148 All of them generate the machine instruction that is part of the name.
20149 @smallexample
20150 void __builtin_ia32_fxsave (void *)
20151 void __builtin_ia32_fxrstor (void *)
20152 void __builtin_ia32_fxsave64 (void *)
20153 void __builtin_ia32_fxrstor64 (void *)
20154 @end smallexample
20155
20156 The following built-in functions are available when @option{-mxsave} is used.
20157 All of them generate the machine instruction that is part of the name.
20158 @smallexample
20159 void __builtin_ia32_xsave (void *, long long)
20160 void __builtin_ia32_xrstor (void *, long long)
20161 void __builtin_ia32_xsave64 (void *, long long)
20162 void __builtin_ia32_xrstor64 (void *, long long)
20163 @end smallexample
20164
20165 The following built-in functions are available when @option{-mxsaveopt} is used.
20166 All of them generate the machine instruction that is part of the name.
20167 @smallexample
20168 void __builtin_ia32_xsaveopt (void *, long long)
20169 void __builtin_ia32_xsaveopt64 (void *, long long)
20170 @end smallexample
20171
20172 The following built-in functions are available when @option{-mtbm} is used.
20173 Both of them generate the immediate form of the bextr machine instruction.
20174 @smallexample
20175 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
20176 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
20177 @end smallexample
20178
20179
20180 The following built-in functions are available when @option{-m3dnow} is used.
20181 All of them generate the machine instruction that is part of the name.
20182
20183 @smallexample
20184 void __builtin_ia32_femms (void)
20185 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
20186 v2si __builtin_ia32_pf2id (v2sf)
20187 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
20188 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
20189 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
20190 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
20191 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
20192 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
20193 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
20194 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
20195 v2sf __builtin_ia32_pfrcp (v2sf)
20196 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
20197 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
20198 v2sf __builtin_ia32_pfrsqrt (v2sf)
20199 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
20200 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
20201 v2sf __builtin_ia32_pi2fd (v2si)
20202 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
20203 @end smallexample
20204
20205 The following built-in functions are available when both @option{-m3dnow}
20206 and @option{-march=athlon} are used. All of them generate the machine
20207 instruction that is part of the name.
20208
20209 @smallexample
20210 v2si __builtin_ia32_pf2iw (v2sf)
20211 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
20212 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
20213 v2sf __builtin_ia32_pi2fw (v2si)
20214 v2sf __builtin_ia32_pswapdsf (v2sf)
20215 v2si __builtin_ia32_pswapdsi (v2si)
20216 @end smallexample
20217
20218 The following built-in functions are available when @option{-mrtm} is used
20219 They are used for restricted transactional memory. These are the internal
20220 low level functions. Normally the functions in
20221 @ref{x86 transactional memory intrinsics} should be used instead.
20222
20223 @smallexample
20224 int __builtin_ia32_xbegin ()
20225 void __builtin_ia32_xend ()
20226 void __builtin_ia32_xabort (status)
20227 int __builtin_ia32_xtest ()
20228 @end smallexample
20229
20230 The following built-in functions are available when @option{-mmwaitx} is used.
20231 All of them generate the machine instruction that is part of the name.
20232 @smallexample
20233 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
20234 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
20235 @end smallexample
20236
20237 The following built-in functions are available when @option{-mclzero} is used.
20238 All of them generate the machine instruction that is part of the name.
20239 @smallexample
20240 void __builtin_i32_clzero (void *)
20241 @end smallexample
20242
20243 The following built-in functions are available when @option{-mpku} is used.
20244 They generate reads and writes to PKRU.
20245 @smallexample
20246 void __builtin_ia32_wrpkru (unsigned int)
20247 unsigned int __builtin_ia32_rdpkru ()
20248 @end smallexample
20249
20250 @node x86 transactional memory intrinsics
20251 @subsection x86 Transactional Memory Intrinsics
20252
20253 These hardware transactional memory intrinsics for x86 allow you to use
20254 memory transactions with RTM (Restricted Transactional Memory).
20255 This support is enabled with the @option{-mrtm} option.
20256 For using HLE (Hardware Lock Elision) see
20257 @ref{x86 specific memory model extensions for transactional memory} instead.
20258
20259 A memory transaction commits all changes to memory in an atomic way,
20260 as visible to other threads. If the transaction fails it is rolled back
20261 and all side effects discarded.
20262
20263 Generally there is no guarantee that a memory transaction ever succeeds
20264 and suitable fallback code always needs to be supplied.
20265
20266 @deftypefn {RTM Function} {unsigned} _xbegin ()
20267 Start a RTM (Restricted Transactional Memory) transaction.
20268 Returns @code{_XBEGIN_STARTED} when the transaction
20269 started successfully (note this is not 0, so the constant has to be
20270 explicitly tested).
20271
20272 If the transaction aborts, all side-effects
20273 are undone and an abort code encoded as a bit mask is returned.
20274 The following macros are defined:
20275
20276 @table @code
20277 @item _XABORT_EXPLICIT
20278 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
20279 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
20280 @item _XABORT_RETRY
20281 Transaction retry is possible.
20282 @item _XABORT_CONFLICT
20283 Transaction abort due to a memory conflict with another thread.
20284 @item _XABORT_CAPACITY
20285 Transaction abort due to the transaction using too much memory.
20286 @item _XABORT_DEBUG
20287 Transaction abort due to a debug trap.
20288 @item _XABORT_NESTED
20289 Transaction abort in an inner nested transaction.
20290 @end table
20291
20292 There is no guarantee
20293 any transaction ever succeeds, so there always needs to be a valid
20294 fallback path.
20295 @end deftypefn
20296
20297 @deftypefn {RTM Function} {void} _xend ()
20298 Commit the current transaction. When no transaction is active this faults.
20299 All memory side-effects of the transaction become visible
20300 to other threads in an atomic manner.
20301 @end deftypefn
20302
20303 @deftypefn {RTM Function} {int} _xtest ()
20304 Return a nonzero value if a transaction is currently active, otherwise 0.
20305 @end deftypefn
20306
20307 @deftypefn {RTM Function} {void} _xabort (status)
20308 Abort the current transaction. When no transaction is active this is a no-op.
20309 The @var{status} is an 8-bit constant; its value is encoded in the return
20310 value from @code{_xbegin}.
20311 @end deftypefn
20312
20313 Here is an example showing handling for @code{_XABORT_RETRY}
20314 and a fallback path for other failures:
20315
20316 @smallexample
20317 #include <immintrin.h>
20318
20319 int n_tries, max_tries;
20320 unsigned status = _XABORT_EXPLICIT;
20321 ...
20322
20323 for (n_tries = 0; n_tries < max_tries; n_tries++)
20324 @{
20325 status = _xbegin ();
20326 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
20327 break;
20328 @}
20329 if (status == _XBEGIN_STARTED)
20330 @{
20331 ... transaction code...
20332 _xend ();
20333 @}
20334 else
20335 @{
20336 ... non-transactional fallback path...
20337 @}
20338 @end smallexample
20339
20340 @noindent
20341 Note that, in most cases, the transactional and non-transactional code
20342 must synchronize together to ensure consistency.
20343
20344 @node Target Format Checks
20345 @section Format Checks Specific to Particular Target Machines
20346
20347 For some target machines, GCC supports additional options to the
20348 format attribute
20349 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
20350
20351 @menu
20352 * Solaris Format Checks::
20353 * Darwin Format Checks::
20354 @end menu
20355
20356 @node Solaris Format Checks
20357 @subsection Solaris Format Checks
20358
20359 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
20360 check. @code{cmn_err} accepts a subset of the standard @code{printf}
20361 conversions, and the two-argument @code{%b} conversion for displaying
20362 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
20363
20364 @node Darwin Format Checks
20365 @subsection Darwin Format Checks
20366
20367 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
20368 attribute context. Declarations made with such attribution are parsed for correct syntax
20369 and format argument types. However, parsing of the format string itself is currently undefined
20370 and is not carried out by this version of the compiler.
20371
20372 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
20373 also be used as format arguments. Note that the relevant headers are only likely to be
20374 available on Darwin (OSX) installations. On such installations, the XCode and system
20375 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
20376 associated functions.
20377
20378 @node Pragmas
20379 @section Pragmas Accepted by GCC
20380 @cindex pragmas
20381 @cindex @code{#pragma}
20382
20383 GCC supports several types of pragmas, primarily in order to compile
20384 code originally written for other compilers. Note that in general
20385 we do not recommend the use of pragmas; @xref{Function Attributes},
20386 for further explanation.
20387
20388 @menu
20389 * AArch64 Pragmas::
20390 * ARM Pragmas::
20391 * M32C Pragmas::
20392 * MeP Pragmas::
20393 * RS/6000 and PowerPC Pragmas::
20394 * S/390 Pragmas::
20395 * Darwin Pragmas::
20396 * Solaris Pragmas::
20397 * Symbol-Renaming Pragmas::
20398 * Structure-Layout Pragmas::
20399 * Weak Pragmas::
20400 * Diagnostic Pragmas::
20401 * Visibility Pragmas::
20402 * Push/Pop Macro Pragmas::
20403 * Function Specific Option Pragmas::
20404 * Loop-Specific Pragmas::
20405 @end menu
20406
20407 @node AArch64 Pragmas
20408 @subsection AArch64 Pragmas
20409
20410 The pragmas defined by the AArch64 target correspond to the AArch64
20411 target function attributes. They can be specified as below:
20412 @smallexample
20413 #pragma GCC target("string")
20414 @end smallexample
20415
20416 where @code{@var{string}} can be any string accepted as an AArch64 target
20417 attribute. @xref{AArch64 Function Attributes}, for more details
20418 on the permissible values of @code{string}.
20419
20420 @node ARM Pragmas
20421 @subsection ARM Pragmas
20422
20423 The ARM target defines pragmas for controlling the default addition of
20424 @code{long_call} and @code{short_call} attributes to functions.
20425 @xref{Function Attributes}, for information about the effects of these
20426 attributes.
20427
20428 @table @code
20429 @item long_calls
20430 @cindex pragma, long_calls
20431 Set all subsequent functions to have the @code{long_call} attribute.
20432
20433 @item no_long_calls
20434 @cindex pragma, no_long_calls
20435 Set all subsequent functions to have the @code{short_call} attribute.
20436
20437 @item long_calls_off
20438 @cindex pragma, long_calls_off
20439 Do not affect the @code{long_call} or @code{short_call} attributes of
20440 subsequent functions.
20441 @end table
20442
20443 @node M32C Pragmas
20444 @subsection M32C Pragmas
20445
20446 @table @code
20447 @item GCC memregs @var{number}
20448 @cindex pragma, memregs
20449 Overrides the command-line option @code{-memregs=} for the current
20450 file. Use with care! This pragma must be before any function in the
20451 file, and mixing different memregs values in different objects may
20452 make them incompatible. This pragma is useful when a
20453 performance-critical function uses a memreg for temporary values,
20454 as it may allow you to reduce the number of memregs used.
20455
20456 @item ADDRESS @var{name} @var{address}
20457 @cindex pragma, address
20458 For any declared symbols matching @var{name}, this does three things
20459 to that symbol: it forces the symbol to be located at the given
20460 address (a number), it forces the symbol to be volatile, and it
20461 changes the symbol's scope to be static. This pragma exists for
20462 compatibility with other compilers, but note that the common
20463 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20464 instead). Example:
20465
20466 @smallexample
20467 #pragma ADDRESS port3 0x103
20468 char port3;
20469 @end smallexample
20470
20471 @end table
20472
20473 @node MeP Pragmas
20474 @subsection MeP Pragmas
20475
20476 @table @code
20477
20478 @item custom io_volatile (on|off)
20479 @cindex pragma, custom io_volatile
20480 Overrides the command-line option @code{-mio-volatile} for the current
20481 file. Note that for compatibility with future GCC releases, this
20482 option should only be used once before any @code{io} variables in each
20483 file.
20484
20485 @item GCC coprocessor available @var{registers}
20486 @cindex pragma, coprocessor available
20487 Specifies which coprocessor registers are available to the register
20488 allocator. @var{registers} may be a single register, register range
20489 separated by ellipses, or comma-separated list of those. Example:
20490
20491 @smallexample
20492 #pragma GCC coprocessor available $c0...$c10, $c28
20493 @end smallexample
20494
20495 @item GCC coprocessor call_saved @var{registers}
20496 @cindex pragma, coprocessor call_saved
20497 Specifies which coprocessor registers are to be saved and restored by
20498 any function using them. @var{registers} may be a single register,
20499 register range separated by ellipses, or comma-separated list of
20500 those. Example:
20501
20502 @smallexample
20503 #pragma GCC coprocessor call_saved $c4...$c6, $c31
20504 @end smallexample
20505
20506 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
20507 @cindex pragma, coprocessor subclass
20508 Creates and defines a register class. These register classes can be
20509 used by inline @code{asm} constructs. @var{registers} may be a single
20510 register, register range separated by ellipses, or comma-separated
20511 list of those. Example:
20512
20513 @smallexample
20514 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
20515
20516 asm ("cpfoo %0" : "=B" (x));
20517 @end smallexample
20518
20519 @item GCC disinterrupt @var{name} , @var{name} @dots{}
20520 @cindex pragma, disinterrupt
20521 For the named functions, the compiler adds code to disable interrupts
20522 for the duration of those functions. If any functions so named
20523 are not encountered in the source, a warning is emitted that the pragma is
20524 not used. Examples:
20525
20526 @smallexample
20527 #pragma disinterrupt foo
20528 #pragma disinterrupt bar, grill
20529 int foo () @{ @dots{} @}
20530 @end smallexample
20531
20532 @item GCC call @var{name} , @var{name} @dots{}
20533 @cindex pragma, call
20534 For the named functions, the compiler always uses a register-indirect
20535 call model when calling the named functions. Examples:
20536
20537 @smallexample
20538 extern int foo ();
20539 #pragma call foo
20540 @end smallexample
20541
20542 @end table
20543
20544 @node RS/6000 and PowerPC Pragmas
20545 @subsection RS/6000 and PowerPC Pragmas
20546
20547 The RS/6000 and PowerPC targets define one pragma for controlling
20548 whether or not the @code{longcall} attribute is added to function
20549 declarations by default. This pragma overrides the @option{-mlongcall}
20550 option, but not the @code{longcall} and @code{shortcall} attributes.
20551 @xref{RS/6000 and PowerPC Options}, for more information about when long
20552 calls are and are not necessary.
20553
20554 @table @code
20555 @item longcall (1)
20556 @cindex pragma, longcall
20557 Apply the @code{longcall} attribute to all subsequent function
20558 declarations.
20559
20560 @item longcall (0)
20561 Do not apply the @code{longcall} attribute to subsequent function
20562 declarations.
20563 @end table
20564
20565 @c Describe h8300 pragmas here.
20566 @c Describe sh pragmas here.
20567 @c Describe v850 pragmas here.
20568
20569 @node S/390 Pragmas
20570 @subsection S/390 Pragmas
20571
20572 The pragmas defined by the S/390 target correspond to the S/390
20573 target function attributes and some the additional options:
20574
20575 @table @samp
20576 @item zvector
20577 @itemx no-zvector
20578 @end table
20579
20580 Note that options of the pragma, unlike options of the target
20581 attribute, do change the value of preprocessor macros like
20582 @code{__VEC__}. They can be specified as below:
20583
20584 @smallexample
20585 #pragma GCC target("string[,string]...")
20586 #pragma GCC target("string"[,"string"]...)
20587 @end smallexample
20588
20589 @node Darwin Pragmas
20590 @subsection Darwin Pragmas
20591
20592 The following pragmas are available for all architectures running the
20593 Darwin operating system. These are useful for compatibility with other
20594 Mac OS compilers.
20595
20596 @table @code
20597 @item mark @var{tokens}@dots{}
20598 @cindex pragma, mark
20599 This pragma is accepted, but has no effect.
20600
20601 @item options align=@var{alignment}
20602 @cindex pragma, options align
20603 This pragma sets the alignment of fields in structures. The values of
20604 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
20605 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
20606 properly; to restore the previous setting, use @code{reset} for the
20607 @var{alignment}.
20608
20609 @item segment @var{tokens}@dots{}
20610 @cindex pragma, segment
20611 This pragma is accepted, but has no effect.
20612
20613 @item unused (@var{var} [, @var{var}]@dots{})
20614 @cindex pragma, unused
20615 This pragma declares variables to be possibly unused. GCC does not
20616 produce warnings for the listed variables. The effect is similar to
20617 that of the @code{unused} attribute, except that this pragma may appear
20618 anywhere within the variables' scopes.
20619 @end table
20620
20621 @node Solaris Pragmas
20622 @subsection Solaris Pragmas
20623
20624 The Solaris target supports @code{#pragma redefine_extname}
20625 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
20626 @code{#pragma} directives for compatibility with the system compiler.
20627
20628 @table @code
20629 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
20630 @cindex pragma, align
20631
20632 Increase the minimum alignment of each @var{variable} to @var{alignment}.
20633 This is the same as GCC's @code{aligned} attribute @pxref{Variable
20634 Attributes}). Macro expansion occurs on the arguments to this pragma
20635 when compiling C and Objective-C@. It does not currently occur when
20636 compiling C++, but this is a bug which may be fixed in a future
20637 release.
20638
20639 @item fini (@var{function} [, @var{function}]...)
20640 @cindex pragma, fini
20641
20642 This pragma causes each listed @var{function} to be called after
20643 main, or during shared module unloading, by adding a call to the
20644 @code{.fini} section.
20645
20646 @item init (@var{function} [, @var{function}]...)
20647 @cindex pragma, init
20648
20649 This pragma causes each listed @var{function} to be called during
20650 initialization (before @code{main}) or during shared module loading, by
20651 adding a call to the @code{.init} section.
20652
20653 @end table
20654
20655 @node Symbol-Renaming Pragmas
20656 @subsection Symbol-Renaming Pragmas
20657
20658 GCC supports a @code{#pragma} directive that changes the name used in
20659 assembly for a given declaration. While this pragma is supported on all
20660 platforms, it is intended primarily to provide compatibility with the
20661 Solaris system headers. This effect can also be achieved using the asm
20662 labels extension (@pxref{Asm Labels}).
20663
20664 @table @code
20665 @item redefine_extname @var{oldname} @var{newname}
20666 @cindex pragma, redefine_extname
20667
20668 This pragma gives the C function @var{oldname} the assembly symbol
20669 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
20670 is defined if this pragma is available (currently on all platforms).
20671 @end table
20672
20673 This pragma and the asm labels extension interact in a complicated
20674 manner. Here are some corner cases you may want to be aware of:
20675
20676 @enumerate
20677 @item This pragma silently applies only to declarations with external
20678 linkage. Asm labels do not have this restriction.
20679
20680 @item In C++, this pragma silently applies only to declarations with
20681 ``C'' linkage. Again, asm labels do not have this restriction.
20682
20683 @item If either of the ways of changing the assembly name of a
20684 declaration are applied to a declaration whose assembly name has
20685 already been determined (either by a previous use of one of these
20686 features, or because the compiler needed the assembly name in order to
20687 generate code), and the new name is different, a warning issues and
20688 the name does not change.
20689
20690 @item The @var{oldname} used by @code{#pragma redefine_extname} is
20691 always the C-language name.
20692 @end enumerate
20693
20694 @node Structure-Layout Pragmas
20695 @subsection Structure-Layout Pragmas
20696
20697 For compatibility with Microsoft Windows compilers, GCC supports a
20698 set of @code{#pragma} directives that change the maximum alignment of
20699 members of structures (other than zero-width bit-fields), unions, and
20700 classes subsequently defined. The @var{n} value below always is required
20701 to be a small power of two and specifies the new alignment in bytes.
20702
20703 @enumerate
20704 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
20705 @item @code{#pragma pack()} sets the alignment to the one that was in
20706 effect when compilation started (see also command-line option
20707 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
20708 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
20709 setting on an internal stack and then optionally sets the new alignment.
20710 @item @code{#pragma pack(pop)} restores the alignment setting to the one
20711 saved at the top of the internal stack (and removes that stack entry).
20712 Note that @code{#pragma pack([@var{n}])} does not influence this internal
20713 stack; thus it is possible to have @code{#pragma pack(push)} followed by
20714 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
20715 @code{#pragma pack(pop)}.
20716 @end enumerate
20717
20718 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
20719 directive which lays out structures and unions subsequently defined as the
20720 documented @code{__attribute__ ((ms_struct))}.
20721
20722 @enumerate
20723 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
20724 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
20725 @item @code{#pragma ms_struct reset} goes back to the default layout.
20726 @end enumerate
20727
20728 Most targets also support the @code{#pragma scalar_storage_order} directive
20729 which lays out structures and unions subsequently defined as the documented
20730 @code{__attribute__ ((scalar_storage_order))}.
20731
20732 @enumerate
20733 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
20734 of the scalar fields to big-endian.
20735 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
20736 of the scalar fields to little-endian.
20737 @item @code{#pragma scalar_storage_order default} goes back to the endianness
20738 that was in effect when compilation started (see also command-line option
20739 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
20740 @end enumerate
20741
20742 @node Weak Pragmas
20743 @subsection Weak Pragmas
20744
20745 For compatibility with SVR4, GCC supports a set of @code{#pragma}
20746 directives for declaring symbols to be weak, and defining weak
20747 aliases.
20748
20749 @table @code
20750 @item #pragma weak @var{symbol}
20751 @cindex pragma, weak
20752 This pragma declares @var{symbol} to be weak, as if the declaration
20753 had the attribute of the same name. The pragma may appear before
20754 or after the declaration of @var{symbol}. It is not an error for
20755 @var{symbol} to never be defined at all.
20756
20757 @item #pragma weak @var{symbol1} = @var{symbol2}
20758 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
20759 It is an error if @var{symbol2} is not defined in the current
20760 translation unit.
20761 @end table
20762
20763 @node Diagnostic Pragmas
20764 @subsection Diagnostic Pragmas
20765
20766 GCC allows the user to selectively enable or disable certain types of
20767 diagnostics, and change the kind of the diagnostic. For example, a
20768 project's policy might require that all sources compile with
20769 @option{-Werror} but certain files might have exceptions allowing
20770 specific types of warnings. Or, a project might selectively enable
20771 diagnostics and treat them as errors depending on which preprocessor
20772 macros are defined.
20773
20774 @table @code
20775 @item #pragma GCC diagnostic @var{kind} @var{option}
20776 @cindex pragma, diagnostic
20777
20778 Modifies the disposition of a diagnostic. Note that not all
20779 diagnostics are modifiable; at the moment only warnings (normally
20780 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
20781 Use @option{-fdiagnostics-show-option} to determine which diagnostics
20782 are controllable and which option controls them.
20783
20784 @var{kind} is @samp{error} to treat this diagnostic as an error,
20785 @samp{warning} to treat it like a warning (even if @option{-Werror} is
20786 in effect), or @samp{ignored} if the diagnostic is to be ignored.
20787 @var{option} is a double quoted string that matches the command-line
20788 option.
20789
20790 @smallexample
20791 #pragma GCC diagnostic warning "-Wformat"
20792 #pragma GCC diagnostic error "-Wformat"
20793 #pragma GCC diagnostic ignored "-Wformat"
20794 @end smallexample
20795
20796 Note that these pragmas override any command-line options. GCC keeps
20797 track of the location of each pragma, and issues diagnostics according
20798 to the state as of that point in the source file. Thus, pragmas occurring
20799 after a line do not affect diagnostics caused by that line.
20800
20801 @item #pragma GCC diagnostic push
20802 @itemx #pragma GCC diagnostic pop
20803
20804 Causes GCC to remember the state of the diagnostics as of each
20805 @code{push}, and restore to that point at each @code{pop}. If a
20806 @code{pop} has no matching @code{push}, the command-line options are
20807 restored.
20808
20809 @smallexample
20810 #pragma GCC diagnostic error "-Wuninitialized"
20811 foo(a); /* error is given for this one */
20812 #pragma GCC diagnostic push
20813 #pragma GCC diagnostic ignored "-Wuninitialized"
20814 foo(b); /* no diagnostic for this one */
20815 #pragma GCC diagnostic pop
20816 foo(c); /* error is given for this one */
20817 #pragma GCC diagnostic pop
20818 foo(d); /* depends on command-line options */
20819 @end smallexample
20820
20821 @end table
20822
20823 GCC also offers a simple mechanism for printing messages during
20824 compilation.
20825
20826 @table @code
20827 @item #pragma message @var{string}
20828 @cindex pragma, diagnostic
20829
20830 Prints @var{string} as a compiler message on compilation. The message
20831 is informational only, and is neither a compilation warning nor an error.
20832
20833 @smallexample
20834 #pragma message "Compiling " __FILE__ "..."
20835 @end smallexample
20836
20837 @var{string} may be parenthesized, and is printed with location
20838 information. For example,
20839
20840 @smallexample
20841 #define DO_PRAGMA(x) _Pragma (#x)
20842 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
20843
20844 TODO(Remember to fix this)
20845 @end smallexample
20846
20847 @noindent
20848 prints @samp{/tmp/file.c:4: note: #pragma message:
20849 TODO - Remember to fix this}.
20850
20851 @end table
20852
20853 @node Visibility Pragmas
20854 @subsection Visibility Pragmas
20855
20856 @table @code
20857 @item #pragma GCC visibility push(@var{visibility})
20858 @itemx #pragma GCC visibility pop
20859 @cindex pragma, visibility
20860
20861 This pragma allows the user to set the visibility for multiple
20862 declarations without having to give each a visibility attribute
20863 (@pxref{Function Attributes}).
20864
20865 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
20866 declarations. Class members and template specializations are not
20867 affected; if you want to override the visibility for a particular
20868 member or instantiation, you must use an attribute.
20869
20870 @end table
20871
20872
20873 @node Push/Pop Macro Pragmas
20874 @subsection Push/Pop Macro Pragmas
20875
20876 For compatibility with Microsoft Windows compilers, GCC supports
20877 @samp{#pragma push_macro(@var{"macro_name"})}
20878 and @samp{#pragma pop_macro(@var{"macro_name"})}.
20879
20880 @table @code
20881 @item #pragma push_macro(@var{"macro_name"})
20882 @cindex pragma, push_macro
20883 This pragma saves the value of the macro named as @var{macro_name} to
20884 the top of the stack for this macro.
20885
20886 @item #pragma pop_macro(@var{"macro_name"})
20887 @cindex pragma, pop_macro
20888 This pragma sets the value of the macro named as @var{macro_name} to
20889 the value on top of the stack for this macro. If the stack for
20890 @var{macro_name} is empty, the value of the macro remains unchanged.
20891 @end table
20892
20893 For example:
20894
20895 @smallexample
20896 #define X 1
20897 #pragma push_macro("X")
20898 #undef X
20899 #define X -1
20900 #pragma pop_macro("X")
20901 int x [X];
20902 @end smallexample
20903
20904 @noindent
20905 In this example, the definition of X as 1 is saved by @code{#pragma
20906 push_macro} and restored by @code{#pragma pop_macro}.
20907
20908 @node Function Specific Option Pragmas
20909 @subsection Function Specific Option Pragmas
20910
20911 @table @code
20912 @item #pragma GCC target (@var{"string"}...)
20913 @cindex pragma GCC target
20914
20915 This pragma allows you to set target specific options for functions
20916 defined later in the source file. One or more strings can be
20917 specified. Each function that is defined after this point is as
20918 if @code{attribute((target("STRING")))} was specified for that
20919 function. The parenthesis around the options is optional.
20920 @xref{Function Attributes}, for more information about the
20921 @code{target} attribute and the attribute syntax.
20922
20923 The @code{#pragma GCC target} pragma is presently implemented for
20924 x86, PowerPC, and Nios II targets only.
20925 @end table
20926
20927 @table @code
20928 @item #pragma GCC optimize (@var{"string"}...)
20929 @cindex pragma GCC optimize
20930
20931 This pragma allows you to set global optimization options for functions
20932 defined later in the source file. One or more strings can be
20933 specified. Each function that is defined after this point is as
20934 if @code{attribute((optimize("STRING")))} was specified for that
20935 function. The parenthesis around the options is optional.
20936 @xref{Function Attributes}, for more information about the
20937 @code{optimize} attribute and the attribute syntax.
20938 @end table
20939
20940 @table @code
20941 @item #pragma GCC push_options
20942 @itemx #pragma GCC pop_options
20943 @cindex pragma GCC push_options
20944 @cindex pragma GCC pop_options
20945
20946 These pragmas maintain a stack of the current target and optimization
20947 options. It is intended for include files where you temporarily want
20948 to switch to using a different @samp{#pragma GCC target} or
20949 @samp{#pragma GCC optimize} and then to pop back to the previous
20950 options.
20951 @end table
20952
20953 @table @code
20954 @item #pragma GCC reset_options
20955 @cindex pragma GCC reset_options
20956
20957 This pragma clears the current @code{#pragma GCC target} and
20958 @code{#pragma GCC optimize} to use the default switches as specified
20959 on the command line.
20960 @end table
20961
20962 @node Loop-Specific Pragmas
20963 @subsection Loop-Specific Pragmas
20964
20965 @table @code
20966 @item #pragma GCC ivdep
20967 @cindex pragma GCC ivdep
20968 @end table
20969
20970 With this pragma, the programmer asserts that there are no loop-carried
20971 dependencies which would prevent consecutive iterations of
20972 the following loop from executing concurrently with SIMD
20973 (single instruction multiple data) instructions.
20974
20975 For example, the compiler can only unconditionally vectorize the following
20976 loop with the pragma:
20977
20978 @smallexample
20979 void foo (int n, int *a, int *b, int *c)
20980 @{
20981 int i, j;
20982 #pragma GCC ivdep
20983 for (i = 0; i < n; ++i)
20984 a[i] = b[i] + c[i];
20985 @}
20986 @end smallexample
20987
20988 @noindent
20989 In this example, using the @code{restrict} qualifier had the same
20990 effect. In the following example, that would not be possible. Assume
20991 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
20992 that it can unconditionally vectorize the following loop:
20993
20994 @smallexample
20995 void ignore_vec_dep (int *a, int k, int c, int m)
20996 @{
20997 #pragma GCC ivdep
20998 for (int i = 0; i < m; i++)
20999 a[i] = a[i + k] * c;
21000 @}
21001 @end smallexample
21002
21003
21004 @node Unnamed Fields
21005 @section Unnamed Structure and Union Fields
21006 @cindex @code{struct}
21007 @cindex @code{union}
21008
21009 As permitted by ISO C11 and for compatibility with other compilers,
21010 GCC allows you to define
21011 a structure or union that contains, as fields, structures and unions
21012 without names. For example:
21013
21014 @smallexample
21015 struct @{
21016 int a;
21017 union @{
21018 int b;
21019 float c;
21020 @};
21021 int d;
21022 @} foo;
21023 @end smallexample
21024
21025 @noindent
21026 In this example, you are able to access members of the unnamed
21027 union with code like @samp{foo.b}. Note that only unnamed structs and
21028 unions are allowed, you may not have, for example, an unnamed
21029 @code{int}.
21030
21031 You must never create such structures that cause ambiguous field definitions.
21032 For example, in this structure:
21033
21034 @smallexample
21035 struct @{
21036 int a;
21037 struct @{
21038 int a;
21039 @};
21040 @} foo;
21041 @end smallexample
21042
21043 @noindent
21044 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
21045 The compiler gives errors for such constructs.
21046
21047 @opindex fms-extensions
21048 Unless @option{-fms-extensions} is used, the unnamed field must be a
21049 structure or union definition without a tag (for example, @samp{struct
21050 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
21051 also be a definition with a tag such as @samp{struct foo @{ int a;
21052 @};}, a reference to a previously defined structure or union such as
21053 @samp{struct foo;}, or a reference to a @code{typedef} name for a
21054 previously defined structure or union type.
21055
21056 @opindex fplan9-extensions
21057 The option @option{-fplan9-extensions} enables
21058 @option{-fms-extensions} as well as two other extensions. First, a
21059 pointer to a structure is automatically converted to a pointer to an
21060 anonymous field for assignments and function calls. For example:
21061
21062 @smallexample
21063 struct s1 @{ int a; @};
21064 struct s2 @{ struct s1; @};
21065 extern void f1 (struct s1 *);
21066 void f2 (struct s2 *p) @{ f1 (p); @}
21067 @end smallexample
21068
21069 @noindent
21070 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
21071 converted into a pointer to the anonymous field.
21072
21073 Second, when the type of an anonymous field is a @code{typedef} for a
21074 @code{struct} or @code{union}, code may refer to the field using the
21075 name of the @code{typedef}.
21076
21077 @smallexample
21078 typedef struct @{ int a; @} s1;
21079 struct s2 @{ s1; @};
21080 s1 f1 (struct s2 *p) @{ return p->s1; @}
21081 @end smallexample
21082
21083 These usages are only permitted when they are not ambiguous.
21084
21085 @node Thread-Local
21086 @section Thread-Local Storage
21087 @cindex Thread-Local Storage
21088 @cindex @acronym{TLS}
21089 @cindex @code{__thread}
21090
21091 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
21092 are allocated such that there is one instance of the variable per extant
21093 thread. The runtime model GCC uses to implement this originates
21094 in the IA-64 processor-specific ABI, but has since been migrated
21095 to other processors as well. It requires significant support from
21096 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
21097 system libraries (@file{libc.so} and @file{libpthread.so}), so it
21098 is not available everywhere.
21099
21100 At the user level, the extension is visible with a new storage
21101 class keyword: @code{__thread}. For example:
21102
21103 @smallexample
21104 __thread int i;
21105 extern __thread struct state s;
21106 static __thread char *p;
21107 @end smallexample
21108
21109 The @code{__thread} specifier may be used alone, with the @code{extern}
21110 or @code{static} specifiers, but with no other storage class specifier.
21111 When used with @code{extern} or @code{static}, @code{__thread} must appear
21112 immediately after the other storage class specifier.
21113
21114 The @code{__thread} specifier may be applied to any global, file-scoped
21115 static, function-scoped static, or static data member of a class. It may
21116 not be applied to block-scoped automatic or non-static data member.
21117
21118 When the address-of operator is applied to a thread-local variable, it is
21119 evaluated at run time and returns the address of the current thread's
21120 instance of that variable. An address so obtained may be used by any
21121 thread. When a thread terminates, any pointers to thread-local variables
21122 in that thread become invalid.
21123
21124 No static initialization may refer to the address of a thread-local variable.
21125
21126 In C++, if an initializer is present for a thread-local variable, it must
21127 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
21128 standard.
21129
21130 See @uref{http://www.akkadia.org/drepper/tls.pdf,
21131 ELF Handling For Thread-Local Storage} for a detailed explanation of
21132 the four thread-local storage addressing models, and how the runtime
21133 is expected to function.
21134
21135 @menu
21136 * C99 Thread-Local Edits::
21137 * C++98 Thread-Local Edits::
21138 @end menu
21139
21140 @node C99 Thread-Local Edits
21141 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
21142
21143 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
21144 that document the exact semantics of the language extension.
21145
21146 @itemize @bullet
21147 @item
21148 @cite{5.1.2 Execution environments}
21149
21150 Add new text after paragraph 1
21151
21152 @quotation
21153 Within either execution environment, a @dfn{thread} is a flow of
21154 control within a program. It is implementation defined whether
21155 or not there may be more than one thread associated with a program.
21156 It is implementation defined how threads beyond the first are
21157 created, the name and type of the function called at thread
21158 startup, and how threads may be terminated. However, objects
21159 with thread storage duration shall be initialized before thread
21160 startup.
21161 @end quotation
21162
21163 @item
21164 @cite{6.2.4 Storage durations of objects}
21165
21166 Add new text before paragraph 3
21167
21168 @quotation
21169 An object whose identifier is declared with the storage-class
21170 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
21171 Its lifetime is the entire execution of the thread, and its
21172 stored value is initialized only once, prior to thread startup.
21173 @end quotation
21174
21175 @item
21176 @cite{6.4.1 Keywords}
21177
21178 Add @code{__thread}.
21179
21180 @item
21181 @cite{6.7.1 Storage-class specifiers}
21182
21183 Add @code{__thread} to the list of storage class specifiers in
21184 paragraph 1.
21185
21186 Change paragraph 2 to
21187
21188 @quotation
21189 With the exception of @code{__thread}, at most one storage-class
21190 specifier may be given [@dots{}]. The @code{__thread} specifier may
21191 be used alone, or immediately following @code{extern} or
21192 @code{static}.
21193 @end quotation
21194
21195 Add new text after paragraph 6
21196
21197 @quotation
21198 The declaration of an identifier for a variable that has
21199 block scope that specifies @code{__thread} shall also
21200 specify either @code{extern} or @code{static}.
21201
21202 The @code{__thread} specifier shall be used only with
21203 variables.
21204 @end quotation
21205 @end itemize
21206
21207 @node C++98 Thread-Local Edits
21208 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
21209
21210 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
21211 that document the exact semantics of the language extension.
21212
21213 @itemize @bullet
21214 @item
21215 @b{[intro.execution]}
21216
21217 New text after paragraph 4
21218
21219 @quotation
21220 A @dfn{thread} is a flow of control within the abstract machine.
21221 It is implementation defined whether or not there may be more than
21222 one thread.
21223 @end quotation
21224
21225 New text after paragraph 7
21226
21227 @quotation
21228 It is unspecified whether additional action must be taken to
21229 ensure when and whether side effects are visible to other threads.
21230 @end quotation
21231
21232 @item
21233 @b{[lex.key]}
21234
21235 Add @code{__thread}.
21236
21237 @item
21238 @b{[basic.start.main]}
21239
21240 Add after paragraph 5
21241
21242 @quotation
21243 The thread that begins execution at the @code{main} function is called
21244 the @dfn{main thread}. It is implementation defined how functions
21245 beginning threads other than the main thread are designated or typed.
21246 A function so designated, as well as the @code{main} function, is called
21247 a @dfn{thread startup function}. It is implementation defined what
21248 happens if a thread startup function returns. It is implementation
21249 defined what happens to other threads when any thread calls @code{exit}.
21250 @end quotation
21251
21252 @item
21253 @b{[basic.start.init]}
21254
21255 Add after paragraph 4
21256
21257 @quotation
21258 The storage for an object of thread storage duration shall be
21259 statically initialized before the first statement of the thread startup
21260 function. An object of thread storage duration shall not require
21261 dynamic initialization.
21262 @end quotation
21263
21264 @item
21265 @b{[basic.start.term]}
21266
21267 Add after paragraph 3
21268
21269 @quotation
21270 The type of an object with thread storage duration shall not have a
21271 non-trivial destructor, nor shall it be an array type whose elements
21272 (directly or indirectly) have non-trivial destructors.
21273 @end quotation
21274
21275 @item
21276 @b{[basic.stc]}
21277
21278 Add ``thread storage duration'' to the list in paragraph 1.
21279
21280 Change paragraph 2
21281
21282 @quotation
21283 Thread, static, and automatic storage durations are associated with
21284 objects introduced by declarations [@dots{}].
21285 @end quotation
21286
21287 Add @code{__thread} to the list of specifiers in paragraph 3.
21288
21289 @item
21290 @b{[basic.stc.thread]}
21291
21292 New section before @b{[basic.stc.static]}
21293
21294 @quotation
21295 The keyword @code{__thread} applied to a non-local object gives the
21296 object thread storage duration.
21297
21298 A local variable or class data member declared both @code{static}
21299 and @code{__thread} gives the variable or member thread storage
21300 duration.
21301 @end quotation
21302
21303 @item
21304 @b{[basic.stc.static]}
21305
21306 Change paragraph 1
21307
21308 @quotation
21309 All objects that have neither thread storage duration, dynamic
21310 storage duration nor are local [@dots{}].
21311 @end quotation
21312
21313 @item
21314 @b{[dcl.stc]}
21315
21316 Add @code{__thread} to the list in paragraph 1.
21317
21318 Change paragraph 1
21319
21320 @quotation
21321 With the exception of @code{__thread}, at most one
21322 @var{storage-class-specifier} shall appear in a given
21323 @var{decl-specifier-seq}. The @code{__thread} specifier may
21324 be used alone, or immediately following the @code{extern} or
21325 @code{static} specifiers. [@dots{}]
21326 @end quotation
21327
21328 Add after paragraph 5
21329
21330 @quotation
21331 The @code{__thread} specifier can be applied only to the names of objects
21332 and to anonymous unions.
21333 @end quotation
21334
21335 @item
21336 @b{[class.mem]}
21337
21338 Add after paragraph 6
21339
21340 @quotation
21341 Non-@code{static} members shall not be @code{__thread}.
21342 @end quotation
21343 @end itemize
21344
21345 @node Binary constants
21346 @section Binary Constants using the @samp{0b} Prefix
21347 @cindex Binary constants using the @samp{0b} prefix
21348
21349 Integer constants can be written as binary constants, consisting of a
21350 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
21351 @samp{0B}. This is particularly useful in environments that operate a
21352 lot on the bit level (like microcontrollers).
21353
21354 The following statements are identical:
21355
21356 @smallexample
21357 i = 42;
21358 i = 0x2a;
21359 i = 052;
21360 i = 0b101010;
21361 @end smallexample
21362
21363 The type of these constants follows the same rules as for octal or
21364 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
21365 can be applied.
21366
21367 @node C++ Extensions
21368 @chapter Extensions to the C++ Language
21369 @cindex extensions, C++ language
21370 @cindex C++ language extensions
21371
21372 The GNU compiler provides these extensions to the C++ language (and you
21373 can also use most of the C language extensions in your C++ programs). If you
21374 want to write code that checks whether these features are available, you can
21375 test for the GNU compiler the same way as for C programs: check for a
21376 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
21377 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
21378 Predefined Macros,cpp,The GNU C Preprocessor}).
21379
21380 @menu
21381 * C++ Volatiles:: What constitutes an access to a volatile object.
21382 * Restricted Pointers:: C99 restricted pointers and references.
21383 * Vague Linkage:: Where G++ puts inlines, vtables and such.
21384 * C++ Interface:: You can use a single C++ header file for both
21385 declarations and definitions.
21386 * Template Instantiation:: Methods for ensuring that exactly one copy of
21387 each needed template instantiation is emitted.
21388 * Bound member functions:: You can extract a function pointer to the
21389 method denoted by a @samp{->*} or @samp{.*} expression.
21390 * C++ Attributes:: Variable, function, and type attributes for C++ only.
21391 * Function Multiversioning:: Declaring multiple function versions.
21392 * Namespace Association:: Strong using-directives for namespace association.
21393 * Type Traits:: Compiler support for type traits.
21394 * C++ Concepts:: Improved support for generic programming.
21395 * Java Exceptions:: Tweaking exception handling to work with Java.
21396 * Deprecated Features:: Things will disappear from G++.
21397 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
21398 @end menu
21399
21400 @node C++ Volatiles
21401 @section When is a Volatile C++ Object Accessed?
21402 @cindex accessing volatiles
21403 @cindex volatile read
21404 @cindex volatile write
21405 @cindex volatile access
21406
21407 The C++ standard differs from the C standard in its treatment of
21408 volatile objects. It fails to specify what constitutes a volatile
21409 access, except to say that C++ should behave in a similar manner to C
21410 with respect to volatiles, where possible. However, the different
21411 lvalueness of expressions between C and C++ complicate the behavior.
21412 G++ behaves the same as GCC for volatile access, @xref{C
21413 Extensions,,Volatiles}, for a description of GCC's behavior.
21414
21415 The C and C++ language specifications differ when an object is
21416 accessed in a void context:
21417
21418 @smallexample
21419 volatile int *src = @var{somevalue};
21420 *src;
21421 @end smallexample
21422
21423 The C++ standard specifies that such expressions do not undergo lvalue
21424 to rvalue conversion, and that the type of the dereferenced object may
21425 be incomplete. The C++ standard does not specify explicitly that it
21426 is lvalue to rvalue conversion that is responsible for causing an
21427 access. There is reason to believe that it is, because otherwise
21428 certain simple expressions become undefined. However, because it
21429 would surprise most programmers, G++ treats dereferencing a pointer to
21430 volatile object of complete type as GCC would do for an equivalent
21431 type in C@. When the object has incomplete type, G++ issues a
21432 warning; if you wish to force an error, you must force a conversion to
21433 rvalue with, for instance, a static cast.
21434
21435 When using a reference to volatile, G++ does not treat equivalent
21436 expressions as accesses to volatiles, but instead issues a warning that
21437 no volatile is accessed. The rationale for this is that otherwise it
21438 becomes difficult to determine where volatile access occur, and not
21439 possible to ignore the return value from functions returning volatile
21440 references. Again, if you wish to force a read, cast the reference to
21441 an rvalue.
21442
21443 G++ implements the same behavior as GCC does when assigning to a
21444 volatile object---there is no reread of the assigned-to object, the
21445 assigned rvalue is reused. Note that in C++ assignment expressions
21446 are lvalues, and if used as an lvalue, the volatile object is
21447 referred to. For instance, @var{vref} refers to @var{vobj}, as
21448 expected, in the following example:
21449
21450 @smallexample
21451 volatile int vobj;
21452 volatile int &vref = vobj = @var{something};
21453 @end smallexample
21454
21455 @node Restricted Pointers
21456 @section Restricting Pointer Aliasing
21457 @cindex restricted pointers
21458 @cindex restricted references
21459 @cindex restricted this pointer
21460
21461 As with the C front end, G++ understands the C99 feature of restricted pointers,
21462 specified with the @code{__restrict__}, or @code{__restrict} type
21463 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
21464 language flag, @code{restrict} is not a keyword in C++.
21465
21466 In addition to allowing restricted pointers, you can specify restricted
21467 references, which indicate that the reference is not aliased in the local
21468 context.
21469
21470 @smallexample
21471 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21472 @{
21473 /* @r{@dots{}} */
21474 @}
21475 @end smallexample
21476
21477 @noindent
21478 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
21479 @var{rref} refers to a (different) unaliased integer.
21480
21481 You may also specify whether a member function's @var{this} pointer is
21482 unaliased by using @code{__restrict__} as a member function qualifier.
21483
21484 @smallexample
21485 void T::fn () __restrict__
21486 @{
21487 /* @r{@dots{}} */
21488 @}
21489 @end smallexample
21490
21491 @noindent
21492 Within the body of @code{T::fn}, @var{this} has the effective
21493 definition @code{T *__restrict__ const this}. Notice that the
21494 interpretation of a @code{__restrict__} member function qualifier is
21495 different to that of @code{const} or @code{volatile} qualifier, in that it
21496 is applied to the pointer rather than the object. This is consistent with
21497 other compilers that implement restricted pointers.
21498
21499 As with all outermost parameter qualifiers, @code{__restrict__} is
21500 ignored in function definition matching. This means you only need to
21501 specify @code{__restrict__} in a function definition, rather than
21502 in a function prototype as well.
21503
21504 @node Vague Linkage
21505 @section Vague Linkage
21506 @cindex vague linkage
21507
21508 There are several constructs in C++ that require space in the object
21509 file but are not clearly tied to a single translation unit. We say that
21510 these constructs have ``vague linkage''. Typically such constructs are
21511 emitted wherever they are needed, though sometimes we can be more
21512 clever.
21513
21514 @table @asis
21515 @item Inline Functions
21516 Inline functions are typically defined in a header file which can be
21517 included in many different compilations. Hopefully they can usually be
21518 inlined, but sometimes an out-of-line copy is necessary, if the address
21519 of the function is taken or if inlining fails. In general, we emit an
21520 out-of-line copy in all translation units where one is needed. As an
21521 exception, we only emit inline virtual functions with the vtable, since
21522 it always requires a copy.
21523
21524 Local static variables and string constants used in an inline function
21525 are also considered to have vague linkage, since they must be shared
21526 between all inlined and out-of-line instances of the function.
21527
21528 @item VTables
21529 @cindex vtable
21530 C++ virtual functions are implemented in most compilers using a lookup
21531 table, known as a vtable. The vtable contains pointers to the virtual
21532 functions provided by a class, and each object of the class contains a
21533 pointer to its vtable (or vtables, in some multiple-inheritance
21534 situations). If the class declares any non-inline, non-pure virtual
21535 functions, the first one is chosen as the ``key method'' for the class,
21536 and the vtable is only emitted in the translation unit where the key
21537 method is defined.
21538
21539 @emph{Note:} If the chosen key method is later defined as inline, the
21540 vtable is still emitted in every translation unit that defines it.
21541 Make sure that any inline virtuals are declared inline in the class
21542 body, even if they are not defined there.
21543
21544 @item @code{type_info} objects
21545 @cindex @code{type_info}
21546 @cindex RTTI
21547 C++ requires information about types to be written out in order to
21548 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
21549 For polymorphic classes (classes with virtual functions), the @samp{type_info}
21550 object is written out along with the vtable so that @samp{dynamic_cast}
21551 can determine the dynamic type of a class object at run time. For all
21552 other types, we write out the @samp{type_info} object when it is used: when
21553 applying @samp{typeid} to an expression, throwing an object, or
21554 referring to a type in a catch clause or exception specification.
21555
21556 @item Template Instantiations
21557 Most everything in this section also applies to template instantiations,
21558 but there are other options as well.
21559 @xref{Template Instantiation,,Where's the Template?}.
21560
21561 @end table
21562
21563 When used with GNU ld version 2.8 or later on an ELF system such as
21564 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
21565 these constructs will be discarded at link time. This is known as
21566 COMDAT support.
21567
21568 On targets that don't support COMDAT, but do support weak symbols, GCC
21569 uses them. This way one copy overrides all the others, but
21570 the unused copies still take up space in the executable.
21571
21572 For targets that do not support either COMDAT or weak symbols,
21573 most entities with vague linkage are emitted as local symbols to
21574 avoid duplicate definition errors from the linker. This does not happen
21575 for local statics in inlines, however, as having multiple copies
21576 almost certainly breaks things.
21577
21578 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
21579 another way to control placement of these constructs.
21580
21581 @node C++ Interface
21582 @section C++ Interface and Implementation Pragmas
21583
21584 @cindex interface and implementation headers, C++
21585 @cindex C++ interface and implementation headers
21586 @cindex pragmas, interface and implementation
21587
21588 @code{#pragma interface} and @code{#pragma implementation} provide the
21589 user with a way of explicitly directing the compiler to emit entities
21590 with vague linkage (and debugging information) in a particular
21591 translation unit.
21592
21593 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
21594 by COMDAT support and the ``key method'' heuristic
21595 mentioned in @ref{Vague Linkage}. Using them can actually cause your
21596 program to grow due to unnecessary out-of-line copies of inline
21597 functions.
21598
21599 @table @code
21600 @item #pragma interface
21601 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
21602 @kindex #pragma interface
21603 Use this directive in @emph{header files} that define object classes, to save
21604 space in most of the object files that use those classes. Normally,
21605 local copies of certain information (backup copies of inline member
21606 functions, debugging information, and the internal tables that implement
21607 virtual functions) must be kept in each object file that includes class
21608 definitions. You can use this pragma to avoid such duplication. When a
21609 header file containing @samp{#pragma interface} is included in a
21610 compilation, this auxiliary information is not generated (unless
21611 the main input source file itself uses @samp{#pragma implementation}).
21612 Instead, the object files contain references to be resolved at link
21613 time.
21614
21615 The second form of this directive is useful for the case where you have
21616 multiple headers with the same name in different directories. If you
21617 use this form, you must specify the same string to @samp{#pragma
21618 implementation}.
21619
21620 @item #pragma implementation
21621 @itemx #pragma implementation "@var{objects}.h"
21622 @kindex #pragma implementation
21623 Use this pragma in a @emph{main input file}, when you want full output from
21624 included header files to be generated (and made globally visible). The
21625 included header file, in turn, should use @samp{#pragma interface}.
21626 Backup copies of inline member functions, debugging information, and the
21627 internal tables used to implement virtual functions are all generated in
21628 implementation files.
21629
21630 @cindex implied @code{#pragma implementation}
21631 @cindex @code{#pragma implementation}, implied
21632 @cindex naming convention, implementation headers
21633 If you use @samp{#pragma implementation} with no argument, it applies to
21634 an include file with the same basename@footnote{A file's @dfn{basename}
21635 is the name stripped of all leading path information and of trailing
21636 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
21637 file. For example, in @file{allclass.cc}, giving just
21638 @samp{#pragma implementation}
21639 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
21640
21641 Use the string argument if you want a single implementation file to
21642 include code from multiple header files. (You must also use
21643 @samp{#include} to include the header file; @samp{#pragma
21644 implementation} only specifies how to use the file---it doesn't actually
21645 include it.)
21646
21647 There is no way to split up the contents of a single header file into
21648 multiple implementation files.
21649 @end table
21650
21651 @cindex inlining and C++ pragmas
21652 @cindex C++ pragmas, effect on inlining
21653 @cindex pragmas in C++, effect on inlining
21654 @samp{#pragma implementation} and @samp{#pragma interface} also have an
21655 effect on function inlining.
21656
21657 If you define a class in a header file marked with @samp{#pragma
21658 interface}, the effect on an inline function defined in that class is
21659 similar to an explicit @code{extern} declaration---the compiler emits
21660 no code at all to define an independent version of the function. Its
21661 definition is used only for inlining with its callers.
21662
21663 @opindex fno-implement-inlines
21664 Conversely, when you include the same header file in a main source file
21665 that declares it as @samp{#pragma implementation}, the compiler emits
21666 code for the function itself; this defines a version of the function
21667 that can be found via pointers (or by callers compiled without
21668 inlining). If all calls to the function can be inlined, you can avoid
21669 emitting the function by compiling with @option{-fno-implement-inlines}.
21670 If any calls are not inlined, you will get linker errors.
21671
21672 @node Template Instantiation
21673 @section Where's the Template?
21674 @cindex template instantiation
21675
21676 C++ templates were the first language feature to require more
21677 intelligence from the environment than was traditionally found on a UNIX
21678 system. Somehow the compiler and linker have to make sure that each
21679 template instance occurs exactly once in the executable if it is needed,
21680 and not at all otherwise. There are two basic approaches to this
21681 problem, which are referred to as the Borland model and the Cfront model.
21682
21683 @table @asis
21684 @item Borland model
21685 Borland C++ solved the template instantiation problem by adding the code
21686 equivalent of common blocks to their linker; the compiler emits template
21687 instances in each translation unit that uses them, and the linker
21688 collapses them together. The advantage of this model is that the linker
21689 only has to consider the object files themselves; there is no external
21690 complexity to worry about. The disadvantage is that compilation time
21691 is increased because the template code is being compiled repeatedly.
21692 Code written for this model tends to include definitions of all
21693 templates in the header file, since they must be seen to be
21694 instantiated.
21695
21696 @item Cfront model
21697 The AT&T C++ translator, Cfront, solved the template instantiation
21698 problem by creating the notion of a template repository, an
21699 automatically maintained place where template instances are stored. A
21700 more modern version of the repository works as follows: As individual
21701 object files are built, the compiler places any template definitions and
21702 instantiations encountered in the repository. At link time, the link
21703 wrapper adds in the objects in the repository and compiles any needed
21704 instances that were not previously emitted. The advantages of this
21705 model are more optimal compilation speed and the ability to use the
21706 system linker; to implement the Borland model a compiler vendor also
21707 needs to replace the linker. The disadvantages are vastly increased
21708 complexity, and thus potential for error; for some code this can be
21709 just as transparent, but in practice it can been very difficult to build
21710 multiple programs in one directory and one program in multiple
21711 directories. Code written for this model tends to separate definitions
21712 of non-inline member templates into a separate file, which should be
21713 compiled separately.
21714 @end table
21715
21716 G++ implements the Borland model on targets where the linker supports it,
21717 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
21718 Otherwise G++ implements neither automatic model.
21719
21720 You have the following options for dealing with template instantiations:
21721
21722 @enumerate
21723 @item
21724 Do nothing. Code written for the Borland model works fine, but
21725 each translation unit contains instances of each of the templates it
21726 uses. The duplicate instances will be discarded by the linker, but in
21727 a large program, this can lead to an unacceptable amount of code
21728 duplication in object files or shared libraries.
21729
21730 Duplicate instances of a template can be avoided by defining an explicit
21731 instantiation in one object file, and preventing the compiler from doing
21732 implicit instantiations in any other object files by using an explicit
21733 instantiation declaration, using the @code{extern template} syntax:
21734
21735 @smallexample
21736 extern template int max (int, int);
21737 @end smallexample
21738
21739 This syntax is defined in the C++ 2011 standard, but has been supported by
21740 G++ and other compilers since well before 2011.
21741
21742 Explicit instantiations can be used for the largest or most frequently
21743 duplicated instances, without having to know exactly which other instances
21744 are used in the rest of the program. You can scatter the explicit
21745 instantiations throughout your program, perhaps putting them in the
21746 translation units where the instances are used or the translation units
21747 that define the templates themselves; you can put all of the explicit
21748 instantiations you need into one big file; or you can create small files
21749 like
21750
21751 @smallexample
21752 #include "Foo.h"
21753 #include "Foo.cc"
21754
21755 template class Foo<int>;
21756 template ostream& operator <<
21757 (ostream&, const Foo<int>&);
21758 @end smallexample
21759
21760 @noindent
21761 for each of the instances you need, and create a template instantiation
21762 library from those.
21763
21764 This is the simplest option, but also offers flexibility and
21765 fine-grained control when necessary. It is also the most portable
21766 alternative and programs using this approach will work with most modern
21767 compilers.
21768
21769 @item
21770 @opindex frepo
21771 Compile your template-using code with @option{-frepo}. The compiler
21772 generates files with the extension @samp{.rpo} listing all of the
21773 template instantiations used in the corresponding object files that
21774 could be instantiated there; the link wrapper, @samp{collect2},
21775 then updates the @samp{.rpo} files to tell the compiler where to place
21776 those instantiations and rebuild any affected object files. The
21777 link-time overhead is negligible after the first pass, as the compiler
21778 continues to place the instantiations in the same files.
21779
21780 This can be a suitable option for application code written for the Borland
21781 model, as it usually just works. Code written for the Cfront model
21782 needs to be modified so that the template definitions are available at
21783 one or more points of instantiation; usually this is as simple as adding
21784 @code{#include <tmethods.cc>} to the end of each template header.
21785
21786 For library code, if you want the library to provide all of the template
21787 instantiations it needs, just try to link all of its object files
21788 together; the link will fail, but cause the instantiations to be
21789 generated as a side effect. Be warned, however, that this may cause
21790 conflicts if multiple libraries try to provide the same instantiations.
21791 For greater control, use explicit instantiation as described in the next
21792 option.
21793
21794 @item
21795 @opindex fno-implicit-templates
21796 Compile your code with @option{-fno-implicit-templates} to disable the
21797 implicit generation of template instances, and explicitly instantiate
21798 all the ones you use. This approach requires more knowledge of exactly
21799 which instances you need than do the others, but it's less
21800 mysterious and allows greater control if you want to ensure that only
21801 the intended instances are used.
21802
21803 If you are using Cfront-model code, you can probably get away with not
21804 using @option{-fno-implicit-templates} when compiling files that don't
21805 @samp{#include} the member template definitions.
21806
21807 If you use one big file to do the instantiations, you may want to
21808 compile it without @option{-fno-implicit-templates} so you get all of the
21809 instances required by your explicit instantiations (but not by any
21810 other files) without having to specify them as well.
21811
21812 In addition to forward declaration of explicit instantiations
21813 (with @code{extern}), G++ has extended the template instantiation
21814 syntax to support instantiation of the compiler support data for a
21815 template class (i.e.@: the vtable) without instantiating any of its
21816 members (with @code{inline}), and instantiation of only the static data
21817 members of a template class, without the support data or member
21818 functions (with @code{static}):
21819
21820 @smallexample
21821 inline template class Foo<int>;
21822 static template class Foo<int>;
21823 @end smallexample
21824 @end enumerate
21825
21826 @node Bound member functions
21827 @section Extracting the Function Pointer from a Bound Pointer to Member Function
21828 @cindex pmf
21829 @cindex pointer to member function
21830 @cindex bound pointer to member function
21831
21832 In C++, pointer to member functions (PMFs) are implemented using a wide
21833 pointer of sorts to handle all the possible call mechanisms; the PMF
21834 needs to store information about how to adjust the @samp{this} pointer,
21835 and if the function pointed to is virtual, where to find the vtable, and
21836 where in the vtable to look for the member function. If you are using
21837 PMFs in an inner loop, you should really reconsider that decision. If
21838 that is not an option, you can extract the pointer to the function that
21839 would be called for a given object/PMF pair and call it directly inside
21840 the inner loop, to save a bit of time.
21841
21842 Note that you still pay the penalty for the call through a
21843 function pointer; on most modern architectures, such a call defeats the
21844 branch prediction features of the CPU@. This is also true of normal
21845 virtual function calls.
21846
21847 The syntax for this extension is
21848
21849 @smallexample
21850 extern A a;
21851 extern int (A::*fp)();
21852 typedef int (*fptr)(A *);
21853
21854 fptr p = (fptr)(a.*fp);
21855 @end smallexample
21856
21857 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
21858 no object is needed to obtain the address of the function. They can be
21859 converted to function pointers directly:
21860
21861 @smallexample
21862 fptr p1 = (fptr)(&A::foo);
21863 @end smallexample
21864
21865 @opindex Wno-pmf-conversions
21866 You must specify @option{-Wno-pmf-conversions} to use this extension.
21867
21868 @node C++ Attributes
21869 @section C++-Specific Variable, Function, and Type Attributes
21870
21871 Some attributes only make sense for C++ programs.
21872
21873 @table @code
21874 @item abi_tag ("@var{tag}", ...)
21875 @cindex @code{abi_tag} function attribute
21876 @cindex @code{abi_tag} variable attribute
21877 @cindex @code{abi_tag} type attribute
21878 The @code{abi_tag} attribute can be applied to a function, variable, or class
21879 declaration. It modifies the mangled name of the entity to
21880 incorporate the tag name, in order to distinguish the function or
21881 class from an earlier version with a different ABI; perhaps the class
21882 has changed size, or the function has a different return type that is
21883 not encoded in the mangled name.
21884
21885 The attribute can also be applied to an inline namespace, but does not
21886 affect the mangled name of the namespace; in this case it is only used
21887 for @option{-Wabi-tag} warnings and automatic tagging of functions and
21888 variables. Tagging inline namespaces is generally preferable to
21889 tagging individual declarations, but the latter is sometimes
21890 necessary, such as when only certain members of a class need to be
21891 tagged.
21892
21893 The argument can be a list of strings of arbitrary length. The
21894 strings are sorted on output, so the order of the list is
21895 unimportant.
21896
21897 A redeclaration of an entity must not add new ABI tags,
21898 since doing so would change the mangled name.
21899
21900 The ABI tags apply to a name, so all instantiations and
21901 specializations of a template have the same tags. The attribute will
21902 be ignored if applied to an explicit specialization or instantiation.
21903
21904 The @option{-Wabi-tag} flag enables a warning about a class which does
21905 not have all the ABI tags used by its subobjects and virtual functions; for users with code
21906 that needs to coexist with an earlier ABI, using this option can help
21907 to find all affected types that need to be tagged.
21908
21909 When a type involving an ABI tag is used as the type of a variable or
21910 return type of a function where that tag is not already present in the
21911 signature of the function, the tag is automatically applied to the
21912 variable or function. @option{-Wabi-tag} also warns about this
21913 situation; this warning can be avoided by explicitly tagging the
21914 variable or function or moving it into a tagged inline namespace.
21915
21916 @item init_priority (@var{priority})
21917 @cindex @code{init_priority} variable attribute
21918
21919 In Standard C++, objects defined at namespace scope are guaranteed to be
21920 initialized in an order in strict accordance with that of their definitions
21921 @emph{in a given translation unit}. No guarantee is made for initializations
21922 across translation units. However, GNU C++ allows users to control the
21923 order of initialization of objects defined at namespace scope with the
21924 @code{init_priority} attribute by specifying a relative @var{priority},
21925 a constant integral expression currently bounded between 101 and 65535
21926 inclusive. Lower numbers indicate a higher priority.
21927
21928 In the following example, @code{A} would normally be created before
21929 @code{B}, but the @code{init_priority} attribute reverses that order:
21930
21931 @smallexample
21932 Some_Class A __attribute__ ((init_priority (2000)));
21933 Some_Class B __attribute__ ((init_priority (543)));
21934 @end smallexample
21935
21936 @noindent
21937 Note that the particular values of @var{priority} do not matter; only their
21938 relative ordering.
21939
21940 @item java_interface
21941 @cindex @code{java_interface} type attribute
21942
21943 This type attribute informs C++ that the class is a Java interface. It may
21944 only be applied to classes declared within an @code{extern "Java"} block.
21945 Calls to methods declared in this interface are dispatched using GCJ's
21946 interface table mechanism, instead of regular virtual table dispatch.
21947
21948 @item warn_unused
21949 @cindex @code{warn_unused} type attribute
21950
21951 For C++ types with non-trivial constructors and/or destructors it is
21952 impossible for the compiler to determine whether a variable of this
21953 type is truly unused if it is not referenced. This type attribute
21954 informs the compiler that variables of this type should be warned
21955 about if they appear to be unused, just like variables of fundamental
21956 types.
21957
21958 This attribute is appropriate for types which just represent a value,
21959 such as @code{std::string}; it is not appropriate for types which
21960 control a resource, such as @code{std::lock_guard}.
21961
21962 This attribute is also accepted in C, but it is unnecessary because C
21963 does not have constructors or destructors.
21964
21965 @end table
21966
21967 See also @ref{Namespace Association}.
21968
21969 @node Function Multiversioning
21970 @section Function Multiversioning
21971 @cindex function versions
21972
21973 With the GNU C++ front end, for x86 targets, you may specify multiple
21974 versions of a function, where each function is specialized for a
21975 specific target feature. At runtime, the appropriate version of the
21976 function is automatically executed depending on the characteristics of
21977 the execution platform. Here is an example.
21978
21979 @smallexample
21980 __attribute__ ((target ("default")))
21981 int foo ()
21982 @{
21983 // The default version of foo.
21984 return 0;
21985 @}
21986
21987 __attribute__ ((target ("sse4.2")))
21988 int foo ()
21989 @{
21990 // foo version for SSE4.2
21991 return 1;
21992 @}
21993
21994 __attribute__ ((target ("arch=atom")))
21995 int foo ()
21996 @{
21997 // foo version for the Intel ATOM processor
21998 return 2;
21999 @}
22000
22001 __attribute__ ((target ("arch=amdfam10")))
22002 int foo ()
22003 @{
22004 // foo version for the AMD Family 0x10 processors.
22005 return 3;
22006 @}
22007
22008 int main ()
22009 @{
22010 int (*p)() = &foo;
22011 assert ((*p) () == foo ());
22012 return 0;
22013 @}
22014 @end smallexample
22015
22016 In the above example, four versions of function foo are created. The
22017 first version of foo with the target attribute "default" is the default
22018 version. This version gets executed when no other target specific
22019 version qualifies for execution on a particular platform. A new version
22020 of foo is created by using the same function signature but with a
22021 different target string. Function foo is called or a pointer to it is
22022 taken just like a regular function. GCC takes care of doing the
22023 dispatching to call the right version at runtime. Refer to the
22024 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
22025 Function Multiversioning} for more details.
22026
22027 @node Namespace Association
22028 @section Namespace Association
22029
22030 @strong{Caution:} The semantics of this extension are equivalent
22031 to C++ 2011 inline namespaces. Users should use inline namespaces
22032 instead as this extension will be removed in future versions of G++.
22033
22034 A using-directive with @code{__attribute ((strong))} is stronger
22035 than a normal using-directive in two ways:
22036
22037 @itemize @bullet
22038 @item
22039 Templates from the used namespace can be specialized and explicitly
22040 instantiated as though they were members of the using namespace.
22041
22042 @item
22043 The using namespace is considered an associated namespace of all
22044 templates in the used namespace for purposes of argument-dependent
22045 name lookup.
22046 @end itemize
22047
22048 The used namespace must be nested within the using namespace so that
22049 normal unqualified lookup works properly.
22050
22051 This is useful for composing a namespace transparently from
22052 implementation namespaces. For example:
22053
22054 @smallexample
22055 namespace std @{
22056 namespace debug @{
22057 template <class T> struct A @{ @};
22058 @}
22059 using namespace debug __attribute ((__strong__));
22060 template <> struct A<int> @{ @}; // @r{OK to specialize}
22061
22062 template <class T> void f (A<T>);
22063 @}
22064
22065 int main()
22066 @{
22067 f (std::A<float>()); // @r{lookup finds} std::f
22068 f (std::A<int>());
22069 @}
22070 @end smallexample
22071
22072 @node Type Traits
22073 @section Type Traits
22074
22075 The C++ front end implements syntactic extensions that allow
22076 compile-time determination of
22077 various characteristics of a type (or of a
22078 pair of types).
22079
22080 @table @code
22081 @item __has_nothrow_assign (type)
22082 If @code{type} is const qualified or is a reference type then the trait is
22083 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
22084 is true, else if @code{type} is a cv class or union type with copy assignment
22085 operators that are known not to throw an exception then the trait is true,
22086 else it is false. Requires: @code{type} shall be a complete type,
22087 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22088
22089 @item __has_nothrow_copy (type)
22090 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
22091 @code{type} is a cv class or union type with copy constructors that
22092 are known not to throw an exception then the trait is true, else it is false.
22093 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
22094 @code{void}, or an array of unknown bound.
22095
22096 @item __has_nothrow_constructor (type)
22097 If @code{__has_trivial_constructor (type)} is true then the trait is
22098 true, else if @code{type} is a cv class or union type (or array
22099 thereof) with a default constructor that is known not to throw an
22100 exception then the trait is true, else it is false. Requires:
22101 @code{type} shall be a complete type, (possibly cv-qualified)
22102 @code{void}, or an array of unknown bound.
22103
22104 @item __has_trivial_assign (type)
22105 If @code{type} is const qualified or is a reference type then the trait is
22106 false. Otherwise if @code{__is_pod (type)} is true then the trait is
22107 true, else if @code{type} is a cv class or union type with a trivial
22108 copy assignment ([class.copy]) then the trait is true, else it is
22109 false. Requires: @code{type} shall be a complete type, (possibly
22110 cv-qualified) @code{void}, or an array of unknown bound.
22111
22112 @item __has_trivial_copy (type)
22113 If @code{__is_pod (type)} is true or @code{type} is a reference type
22114 then the trait is true, else if @code{type} is a cv class or union type
22115 with a trivial copy constructor ([class.copy]) then the trait
22116 is true, else it is false. Requires: @code{type} shall be a complete
22117 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22118
22119 @item __has_trivial_constructor (type)
22120 If @code{__is_pod (type)} is true then the trait is true, else if
22121 @code{type} is a cv class or union type (or array thereof) with a
22122 trivial default constructor ([class.ctor]) then the trait is true,
22123 else it is false. Requires: @code{type} shall be a complete
22124 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22125
22126 @item __has_trivial_destructor (type)
22127 If @code{__is_pod (type)} is true or @code{type} is a reference type then
22128 the trait is true, else if @code{type} is a cv class or union type (or
22129 array thereof) with a trivial destructor ([class.dtor]) then the trait
22130 is true, else it is false. Requires: @code{type} shall be a complete
22131 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22132
22133 @item __has_virtual_destructor (type)
22134 If @code{type} is a class type with a virtual destructor
22135 ([class.dtor]) then the trait is true, else it is false. Requires:
22136 @code{type} shall be a complete type, (possibly cv-qualified)
22137 @code{void}, or an array of unknown bound.
22138
22139 @item __is_abstract (type)
22140 If @code{type} is an abstract class ([class.abstract]) then the trait
22141 is 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_base_of (base_type, derived_type)
22145 If @code{base_type} is a base class of @code{derived_type}
22146 ([class.derived]) then the trait is true, otherwise it is false.
22147 Top-level cv qualifications of @code{base_type} and
22148 @code{derived_type} are ignored. For the purposes of this trait, a
22149 class type is considered is own base. Requires: if @code{__is_class
22150 (base_type)} and @code{__is_class (derived_type)} are true and
22151 @code{base_type} and @code{derived_type} are not the same type
22152 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
22153 type. A diagnostic is produced if this requirement is not met.
22154
22155 @item __is_class (type)
22156 If @code{type} is a cv class type, and not a union type
22157 ([basic.compound]) the trait is true, else it is false.
22158
22159 @item __is_empty (type)
22160 If @code{__is_class (type)} is false then the trait is false.
22161 Otherwise @code{type} is considered empty if and only if: @code{type}
22162 has no non-static data members, or all non-static data members, if
22163 any, are bit-fields of length 0, and @code{type} has no virtual
22164 members, and @code{type} has no virtual base classes, and @code{type}
22165 has no base classes @code{base_type} for which
22166 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
22167 be a complete type, (possibly cv-qualified) @code{void}, or an array
22168 of unknown bound.
22169
22170 @item __is_enum (type)
22171 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
22172 true, else it is false.
22173
22174 @item __is_literal_type (type)
22175 If @code{type} is a literal type ([basic.types]) the trait is
22176 true, else it is false. Requires: @code{type} shall be a complete type,
22177 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22178
22179 @item __is_pod (type)
22180 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
22181 else it is false. Requires: @code{type} shall be a complete type,
22182 (possibly cv-qualified) @code{void}, or an array of unknown bound.
22183
22184 @item __is_polymorphic (type)
22185 If @code{type} is a polymorphic class ([class.virtual]) then the trait
22186 is true, else it is false. Requires: @code{type} shall be a complete
22187 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22188
22189 @item __is_standard_layout (type)
22190 If @code{type} is a standard-layout type ([basic.types]) the trait is
22191 true, else it is false. Requires: @code{type} shall be a complete
22192 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22193
22194 @item __is_trivial (type)
22195 If @code{type} is a trivial type ([basic.types]) the trait is
22196 true, else it is false. Requires: @code{type} shall be a complete
22197 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
22198
22199 @item __is_union (type)
22200 If @code{type} is a cv union type ([basic.compound]) the trait is
22201 true, else it is false.
22202
22203 @item __underlying_type (type)
22204 The underlying type of @code{type}. Requires: @code{type} shall be
22205 an enumeration type ([dcl.enum]).
22206
22207 @end table
22208
22209
22210 @node C++ Concepts
22211 @section C++ Concepts
22212
22213 C++ concepts provide much-improved support for generic programming. In
22214 particular, they allow the specification of constraints on template arguments.
22215 The constraints are used to extend the usual overloading and partial
22216 specialization capabilities of the language, allowing generic data structures
22217 and algorithms to be ``refined'' based on their properties rather than their
22218 type names.
22219
22220 The following keywords are reserved for concepts.
22221
22222 @table @code
22223 @item assumes
22224 States an expression as an assumption, and if possible, verifies that the
22225 assumption is valid. For example, @code{assume(n > 0)}.
22226
22227 @item axiom
22228 Introduces an axiom definition. Axioms introduce requirements on values.
22229
22230 @item forall
22231 Introduces a universally quantified object in an axiom. For example,
22232 @code{forall (int n) n + 0 == n}).
22233
22234 @item concept
22235 Introduces a concept definition. Concepts are sets of syntactic and semantic
22236 requirements on types and their values.
22237
22238 @item requires
22239 Introduces constraints on template arguments or requirements for a member
22240 function of a class template.
22241
22242 @end table
22243
22244 The front end also exposes a number of internal mechanism that can be used
22245 to simplify the writing of type traits. Note that some of these traits are
22246 likely to be removed in the future.
22247
22248 @table @code
22249 @item __is_same (type1, type2)
22250 A binary type trait: true whenever the type arguments are the same.
22251
22252 @end table
22253
22254
22255 @node Java Exceptions
22256 @section Java Exceptions
22257
22258 The Java language uses a slightly different exception handling model
22259 from C++. Normally, GNU C++ automatically detects when you are
22260 writing C++ code that uses Java exceptions, and handle them
22261 appropriately. However, if C++ code only needs to execute destructors
22262 when Java exceptions are thrown through it, GCC guesses incorrectly.
22263 Sample problematic code is:
22264
22265 @smallexample
22266 struct S @{ ~S(); @};
22267 extern void bar(); // @r{is written in Java, and may throw exceptions}
22268 void foo()
22269 @{
22270 S s;
22271 bar();
22272 @}
22273 @end smallexample
22274
22275 @noindent
22276 The usual effect of an incorrect guess is a link failure, complaining of
22277 a missing routine called @samp{__gxx_personality_v0}.
22278
22279 You can inform the compiler that Java exceptions are to be used in a
22280 translation unit, irrespective of what it might think, by writing
22281 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
22282 @samp{#pragma} must appear before any functions that throw or catch
22283 exceptions, or run destructors when exceptions are thrown through them.
22284
22285 You cannot mix Java and C++ exceptions in the same translation unit. It
22286 is believed to be safe to throw a C++ exception from one file through
22287 another file compiled for the Java exception model, or vice versa, but
22288 there may be bugs in this area.
22289
22290 @node Deprecated Features
22291 @section Deprecated Features
22292
22293 In the past, the GNU C++ compiler was extended to experiment with new
22294 features, at a time when the C++ language was still evolving. Now that
22295 the C++ standard is complete, some of those features are superseded by
22296 superior alternatives. Using the old features might cause a warning in
22297 some cases that the feature will be dropped in the future. In other
22298 cases, the feature might be gone already.
22299
22300 While the list below is not exhaustive, it documents some of the options
22301 that are now deprecated:
22302
22303 @table @code
22304 @item -fexternal-templates
22305 @itemx -falt-external-templates
22306 These are two of the many ways for G++ to implement template
22307 instantiation. @xref{Template Instantiation}. The C++ standard clearly
22308 defines how template definitions have to be organized across
22309 implementation units. G++ has an implicit instantiation mechanism that
22310 should work just fine for standard-conforming code.
22311
22312 @item -fstrict-prototype
22313 @itemx -fno-strict-prototype
22314 Previously it was possible to use an empty prototype parameter list to
22315 indicate an unspecified number of parameters (like C), rather than no
22316 parameters, as C++ demands. This feature has been removed, except where
22317 it is required for backwards compatibility. @xref{Backwards Compatibility}.
22318 @end table
22319
22320 G++ allows a virtual function returning @samp{void *} to be overridden
22321 by one returning a different pointer type. This extension to the
22322 covariant return type rules is now deprecated and will be removed from a
22323 future version.
22324
22325 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
22326 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
22327 and are now removed from G++. Code using these operators should be
22328 modified to use @code{std::min} and @code{std::max} instead.
22329
22330 The named return value extension has been deprecated, and is now
22331 removed from G++.
22332
22333 The use of initializer lists with new expressions has been deprecated,
22334 and is now removed from G++.
22335
22336 Floating and complex non-type template parameters have been deprecated,
22337 and are now removed from G++.
22338
22339 The implicit typename extension has been deprecated and is now
22340 removed from G++.
22341
22342 The use of default arguments in function pointers, function typedefs
22343 and other places where they are not permitted by the standard is
22344 deprecated and will be removed from a future version of G++.
22345
22346 G++ allows floating-point literals to appear in integral constant expressions,
22347 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
22348 This extension is deprecated and will be removed from a future version.
22349
22350 G++ allows static data members of const floating-point type to be declared
22351 with an initializer in a class definition. The standard only allows
22352 initializers for static members of const integral types and const
22353 enumeration types so this extension has been deprecated and will be removed
22354 from a future version.
22355
22356 @node Backwards Compatibility
22357 @section Backwards Compatibility
22358 @cindex Backwards Compatibility
22359 @cindex ARM [Annotated C++ Reference Manual]
22360
22361 Now that there is a definitive ISO standard C++, G++ has a specification
22362 to adhere to. The C++ language evolved over time, and features that
22363 used to be acceptable in previous drafts of the standard, such as the ARM
22364 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
22365 compilation of C++ written to such drafts, G++ contains some backwards
22366 compatibilities. @emph{All such backwards compatibility features are
22367 liable to disappear in future versions of G++.} They should be considered
22368 deprecated. @xref{Deprecated Features}.
22369
22370 @table @code
22371 @item For scope
22372 If a variable is declared at for scope, it used to remain in scope until
22373 the end of the scope that contained the for statement (rather than just
22374 within the for scope). G++ retains this, but issues a warning, if such a
22375 variable is accessed outside the for scope.
22376
22377 @item Implicit C language
22378 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
22379 scope to set the language. On such systems, all header files are
22380 implicitly scoped inside a C language scope. Also, an empty prototype
22381 @code{()} is treated as an unspecified number of arguments, rather
22382 than no arguments, as C++ demands.
22383 @end table
22384
22385 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
22386 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr