sparc: support for the SPARC M7 and VIS 4.0
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2016 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
17
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
21
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
52 or arrays as values.
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
75 function.
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
219
220 @smallexample
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
223
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
228
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
233
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
238
239 A local label declaration looks like this:
240
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
244
245 @noindent
246 or
247
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
251
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
254
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
258
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
265
266 @smallexample
267 #define SEARCH(value, array, target) \
268 do @{ \
269 __label__ found; \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
272 int i, j; \
273 int value; \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
278 (value) = -1; \
279 found:; \
280 @} while (0)
281 @end smallexample
282
283 This could also be written using a statement expression:
284
285 @smallexample
286 #define SEARCH(array, target) \
287 (@{ \
288 __label__ found; \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
291 int i, j; \
292 int value; \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
297 value = -1; \
298 found: \
299 value; \
300 @})
301 @end smallexample
302
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
305
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
312
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
317
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
323
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
329
330 @smallexample
331 goto *ptr;
332 @end smallexample
333
334 @noindent
335 Any expression of type @code{void *} is allowed.
336
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
339
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
343
344 @noindent
345 Then you can select a label with indexing, like this:
346
347 @smallexample
348 goto *array[i];
349 @end smallexample
350
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
354
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
359
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
363
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
368
369 An alternate way to write the above example is
370
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
376
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
383
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
390
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
396
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
400
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
404
405 @smallexample
406 @group
407 foo (double a, double b)
408 @{
409 double square (double z) @{ return z * z; @}
410
411 return square (a) + square (b);
412 @}
413 @end group
414 @end smallexample
415
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
420
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
424 @{
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
427 int i;
428 /* @r{@dots{}} */
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @}
432 @end group
433 @end smallexample
434
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
438
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
441
442 @smallexample
443 hack (int *array, int size)
444 @{
445 void store (int index, int value)
446 @{ array[index] = value; @}
447
448 intermediate (store, size);
449 @}
450 @end smallexample
451
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
457
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
465
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
470
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
476
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
480 @{
481 __label__ failure;
482 int access (int *array, int index)
483 @{
484 if (index > size)
485 goto failure;
486 return array[index + offset];
487 @}
488 int i;
489 /* @r{@dots{}} */
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492 /* @r{@dots{}} */
493 return 0;
494
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
497 failure:
498 return -1;
499 @}
500 @end group
501 @end smallexample
502
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
507
508 @smallexample
509 bar (int *array, int offset, int size)
510 @{
511 __label__ failure;
512 auto int access (int *, int);
513 /* @r{@dots{}} */
514 int access (int *array, int index)
515 @{
516 if (index > size)
517 goto failure;
518 return array[index + offset];
519 @}
520 /* @r{@dots{}} */
521 @}
522 @end smallexample
523
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
528
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
533
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
538
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
543
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
548
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
553 @end deftypefn
554
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
559
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
563
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
567
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
573
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
579
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
594 @{
595 int r = fprintf (f, "myprintf: ");
596 if (r < 0)
597 return r;
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
599 if (s < 0)
600 return s;
601 return r + s;
602 @}
603 @end smallexample
604 @end deftypefn
605
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
618 @{
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
621
622 if (__builtin_constant_p (oflag))
623 @{
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 @{
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
628 @}
629 return open (path, oflag, __builtin_va_arg_pack ());
630 @}
631
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
634
635 return open (path, oflag, __builtin_va_arg_pack ());
636 @}
637 #endif
638 @end smallexample
639 @end deftypefn
640
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
646
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
650
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
653
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
657
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
661
662 Here is an example with a typename as the argument:
663
664 @smallexample
665 typeof (int *)
666 @end smallexample
667
668 @noindent
669 Here the type described is that of pointers to @code{int}.
670
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
674
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
678
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
682
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
688
689 @smallexample
690 #define max(a,b) \
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
694 @end smallexample
695
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
701
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
708
709 @noindent
710 Some more examples of the use of @code{typeof}:
711
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
715
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of such values.
722
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
726
727 @item
728 This declares @code{y} as an array of pointers to characters:
729
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
733
734 @noindent
735 It is equivalent to the following traditional C declaration:
736
737 @smallexample
738 char *y[4];
739 @end smallexample
740
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
743
744 @smallexample
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
748
749 @noindent
750 Now the declaration can be rewritten this way:
751
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
755
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
760
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
769
770 @smallexample
771 #define max(a,b) \
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
775 @end smallexample
776
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
784
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
789
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
797
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
801
802 Therefore, the expression
803
804 @smallexample
805 x ? : y
806 @end smallexample
807
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
811
812 This example is perfectly equivalent to
813
814 @smallexample
815 x ? x : y
816 @end smallexample
817
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
827
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
831
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
838
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
846
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
854
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
862
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
870
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
876
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
882
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
889
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
899
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
909
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
916
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF
920 debug info format can represent this, so use of DWARF is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}. You can
925 examine and set these two fictitious variables with your debugger.
926
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{__ibm128} data type
933 @cindex @code{w} floating point suffix
934 @cindex @code{q} floating point suffix
935 @cindex @code{W} floating point suffix
936 @cindex @code{Q} floating point suffix
937
938 As an extension, GNU C supports additional floating
939 types, @code{__float80} and @code{__float128} to support 80-bit
940 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
941 Support for additional types includes the arithmetic operators:
942 add, subtract, multiply, divide; unary arithmetic operators;
943 relational operators; equality operators; and conversions to and from
944 integer and other floating types. Use a suffix @samp{w} or @samp{W}
945 in a literal constant of type @code{__float80} or type
946 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
947
948 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
949 types using the corresponding internal complex type, @code{XCmode} for
950 @code{__float80} type and @code{TCmode} for @code{__float128} type:
951
952 @smallexample
953 typedef _Complex float __attribute__((mode(TC))) _Complex128;
954 typedef _Complex float __attribute__((mode(XC))) _Complex80;
955 @end smallexample
956
957 In order to use @code{__float128} and @code{__ibm128} on PowerPC Linux
958 systems, you must use the @option{-mfloat128}. It is expected in
959 future versions of GCC that @code{__float128} will be enabled
960 automatically. In addition, there are currently problems in using the
961 complex @code{__float128} type. When these problems are fixed, you
962 would use the following syntax to declare @code{_Complex128} to be a
963 complex @code{__float128} type:
964
965 On the PowerPC Linux VSX targets, you can declare complex types using
966 the corresponding internal complex type, @code{KCmode} for
967 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
968
969 @smallexample
970 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
971 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
972 @end smallexample
973
974 Not all targets support additional floating-point types.
975 @code{__float80} and @code{__float128} types are supported on x86 and
976 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
977 The @code{__float128} type is supported on PowerPC 64-bit Linux
978 systems by default if the vector scalar instruction set (VSX) is
979 enabled.
980
981 On the PowerPC, @code{__ibm128} provides access to the IBM extended
982 double format, and it is intended to be used by the library functions
983 that handle conversions if/when long double is changed to be IEEE
984 128-bit floating point.
985
986 @node Half-Precision
987 @section Half-Precision Floating Point
988 @cindex half-precision floating point
989 @cindex @code{__fp16} data type
990
991 On ARM targets, GCC supports half-precision (16-bit) floating point via
992 the @code{__fp16} type. You must enable this type explicitly
993 with the @option{-mfp16-format} command-line option in order to use it.
994
995 ARM supports two incompatible representations for half-precision
996 floating-point values. You must choose one of the representations and
997 use it consistently in your program.
998
999 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1000 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1001 There are 11 bits of significand precision, approximately 3
1002 decimal digits.
1003
1004 Specifying @option{-mfp16-format=alternative} selects the ARM
1005 alternative format. This representation is similar to the IEEE
1006 format, but does not support infinities or NaNs. Instead, the range
1007 of exponents is extended, so that this format can represent normalized
1008 values in the range of @math{2^{-14}} to 131008.
1009
1010 The @code{__fp16} type is a storage format only. For purposes
1011 of arithmetic and other operations, @code{__fp16} values in C or C++
1012 expressions are automatically promoted to @code{float}. In addition,
1013 you cannot declare a function with a return value or parameters
1014 of type @code{__fp16}.
1015
1016 Note that conversions from @code{double} to @code{__fp16}
1017 involve an intermediate conversion to @code{float}. Because
1018 of rounding, this can sometimes produce a different result than a
1019 direct conversion.
1020
1021 ARM provides hardware support for conversions between
1022 @code{__fp16} and @code{float} values
1023 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1024 code using these hardware instructions if you compile with
1025 options to select an FPU that provides them;
1026 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1027 in addition to the @option{-mfp16-format} option to select
1028 a half-precision format.
1029
1030 Language-level support for the @code{__fp16} data type is
1031 independent of whether GCC generates code using hardware floating-point
1032 instructions. In cases where hardware support is not specified, GCC
1033 implements conversions between @code{__fp16} and @code{float} values
1034 as library calls.
1035
1036 @node Decimal Float
1037 @section Decimal Floating Types
1038 @cindex decimal floating types
1039 @cindex @code{_Decimal32} data type
1040 @cindex @code{_Decimal64} data type
1041 @cindex @code{_Decimal128} data type
1042 @cindex @code{df} integer suffix
1043 @cindex @code{dd} integer suffix
1044 @cindex @code{dl} integer suffix
1045 @cindex @code{DF} integer suffix
1046 @cindex @code{DD} integer suffix
1047 @cindex @code{DL} integer suffix
1048
1049 As an extension, GNU C supports decimal floating types as
1050 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1051 floating types in GCC will evolve as the draft technical report changes.
1052 Calling conventions for any target might also change. Not all targets
1053 support decimal floating types.
1054
1055 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1056 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1057 @code{float}, @code{double}, and @code{long double} whose radix is not
1058 specified by the C standard but is usually two.
1059
1060 Support for decimal floating types includes the arithmetic operators
1061 add, subtract, multiply, divide; unary arithmetic operators;
1062 relational operators; equality operators; and conversions to and from
1063 integer and other floating types. Use a suffix @samp{df} or
1064 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1065 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1066 @code{_Decimal128}.
1067
1068 GCC support of decimal float as specified by the draft technical report
1069 is incomplete:
1070
1071 @itemize @bullet
1072 @item
1073 When the value of a decimal floating type cannot be represented in the
1074 integer type to which it is being converted, the result is undefined
1075 rather than the result value specified by the draft technical report.
1076
1077 @item
1078 GCC does not provide the C library functionality associated with
1079 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1080 @file{wchar.h}, which must come from a separate C library implementation.
1081 Because of this the GNU C compiler does not define macro
1082 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1083 the technical report.
1084 @end itemize
1085
1086 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1087 are supported by the DWARF debug information format.
1088
1089 @node Hex Floats
1090 @section Hex Floats
1091 @cindex hex floats
1092
1093 ISO C99 supports floating-point numbers written not only in the usual
1094 decimal notation, such as @code{1.55e1}, but also numbers such as
1095 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1096 supports this in C90 mode (except in some cases when strictly
1097 conforming) and in C++. In that format the
1098 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1099 mandatory. The exponent is a decimal number that indicates the power of
1100 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1101 @tex
1102 $1 {15\over16}$,
1103 @end tex
1104 @ifnottex
1105 1 15/16,
1106 @end ifnottex
1107 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1108 is the same as @code{1.55e1}.
1109
1110 Unlike for floating-point numbers in the decimal notation the exponent
1111 is always required in the hexadecimal notation. Otherwise the compiler
1112 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1113 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1114 extension for floating-point constants of type @code{float}.
1115
1116 @node Fixed-Point
1117 @section Fixed-Point Types
1118 @cindex fixed-point types
1119 @cindex @code{_Fract} data type
1120 @cindex @code{_Accum} data type
1121 @cindex @code{_Sat} data type
1122 @cindex @code{hr} fixed-suffix
1123 @cindex @code{r} fixed-suffix
1124 @cindex @code{lr} fixed-suffix
1125 @cindex @code{llr} fixed-suffix
1126 @cindex @code{uhr} fixed-suffix
1127 @cindex @code{ur} fixed-suffix
1128 @cindex @code{ulr} fixed-suffix
1129 @cindex @code{ullr} fixed-suffix
1130 @cindex @code{hk} fixed-suffix
1131 @cindex @code{k} fixed-suffix
1132 @cindex @code{lk} fixed-suffix
1133 @cindex @code{llk} fixed-suffix
1134 @cindex @code{uhk} fixed-suffix
1135 @cindex @code{uk} fixed-suffix
1136 @cindex @code{ulk} fixed-suffix
1137 @cindex @code{ullk} fixed-suffix
1138 @cindex @code{HR} fixed-suffix
1139 @cindex @code{R} fixed-suffix
1140 @cindex @code{LR} fixed-suffix
1141 @cindex @code{LLR} fixed-suffix
1142 @cindex @code{UHR} fixed-suffix
1143 @cindex @code{UR} fixed-suffix
1144 @cindex @code{ULR} fixed-suffix
1145 @cindex @code{ULLR} fixed-suffix
1146 @cindex @code{HK} fixed-suffix
1147 @cindex @code{K} fixed-suffix
1148 @cindex @code{LK} fixed-suffix
1149 @cindex @code{LLK} fixed-suffix
1150 @cindex @code{UHK} fixed-suffix
1151 @cindex @code{UK} fixed-suffix
1152 @cindex @code{ULK} fixed-suffix
1153 @cindex @code{ULLK} fixed-suffix
1154
1155 As an extension, GNU C supports fixed-point types as
1156 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1157 types in GCC will evolve as the draft technical report changes.
1158 Calling conventions for any target might also change. Not all targets
1159 support fixed-point types.
1160
1161 The fixed-point types are
1162 @code{short _Fract},
1163 @code{_Fract},
1164 @code{long _Fract},
1165 @code{long long _Fract},
1166 @code{unsigned short _Fract},
1167 @code{unsigned _Fract},
1168 @code{unsigned long _Fract},
1169 @code{unsigned long long _Fract},
1170 @code{_Sat short _Fract},
1171 @code{_Sat _Fract},
1172 @code{_Sat long _Fract},
1173 @code{_Sat long long _Fract},
1174 @code{_Sat unsigned short _Fract},
1175 @code{_Sat unsigned _Fract},
1176 @code{_Sat unsigned long _Fract},
1177 @code{_Sat unsigned long long _Fract},
1178 @code{short _Accum},
1179 @code{_Accum},
1180 @code{long _Accum},
1181 @code{long long _Accum},
1182 @code{unsigned short _Accum},
1183 @code{unsigned _Accum},
1184 @code{unsigned long _Accum},
1185 @code{unsigned long long _Accum},
1186 @code{_Sat short _Accum},
1187 @code{_Sat _Accum},
1188 @code{_Sat long _Accum},
1189 @code{_Sat long long _Accum},
1190 @code{_Sat unsigned short _Accum},
1191 @code{_Sat unsigned _Accum},
1192 @code{_Sat unsigned long _Accum},
1193 @code{_Sat unsigned long long _Accum}.
1194
1195 Fixed-point data values contain fractional and optional integral parts.
1196 The format of fixed-point data varies and depends on the target machine.
1197
1198 Support for fixed-point types includes:
1199 @itemize @bullet
1200 @item
1201 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1202 @item
1203 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1204 @item
1205 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1206 @item
1207 binary shift operators (@code{<<}, @code{>>})
1208 @item
1209 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1210 @item
1211 equality operators (@code{==}, @code{!=})
1212 @item
1213 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1214 @code{<<=}, @code{>>=})
1215 @item
1216 conversions to and from integer, floating-point, or fixed-point types
1217 @end itemize
1218
1219 Use a suffix in a fixed-point literal constant:
1220 @itemize
1221 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1222 @code{_Sat short _Fract}
1223 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1224 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1225 @code{_Sat long _Fract}
1226 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1227 @code{_Sat long long _Fract}
1228 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1229 @code{_Sat unsigned short _Fract}
1230 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1231 @code{_Sat unsigned _Fract}
1232 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1233 @code{_Sat unsigned long _Fract}
1234 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1235 and @code{_Sat unsigned long long _Fract}
1236 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1237 @code{_Sat short _Accum}
1238 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1239 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1240 @code{_Sat long _Accum}
1241 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1242 @code{_Sat long long _Accum}
1243 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1244 @code{_Sat unsigned short _Accum}
1245 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1246 @code{_Sat unsigned _Accum}
1247 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1248 @code{_Sat unsigned long _Accum}
1249 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1250 and @code{_Sat unsigned long long _Accum}
1251 @end itemize
1252
1253 GCC support of fixed-point types as specified by the draft technical report
1254 is incomplete:
1255
1256 @itemize @bullet
1257 @item
1258 Pragmas to control overflow and rounding behaviors are not implemented.
1259 @end itemize
1260
1261 Fixed-point types are supported by the DWARF debug information format.
1262
1263 @node Named Address Spaces
1264 @section Named Address Spaces
1265 @cindex Named Address Spaces
1266
1267 As an extension, GNU C supports named address spaces as
1268 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1269 address spaces in GCC will evolve as the draft technical report
1270 changes. Calling conventions for any target might also change. At
1271 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1272 address spaces other than the generic address space.
1273
1274 Address space identifiers may be used exactly like any other C type
1275 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1276 document for more details.
1277
1278 @anchor{AVR Named Address Spaces}
1279 @subsection AVR Named Address Spaces
1280
1281 On the AVR target, there are several address spaces that can be used
1282 in order to put read-only data into the flash memory and access that
1283 data by means of the special instructions @code{LPM} or @code{ELPM}
1284 needed to read from flash.
1285
1286 Per default, any data including read-only data is located in RAM
1287 (the generic address space) so that non-generic address spaces are
1288 needed to locate read-only data in flash memory
1289 @emph{and} to generate the right instructions to access this data
1290 without using (inline) assembler code.
1291
1292 @table @code
1293 @item __flash
1294 @cindex @code{__flash} AVR Named Address Spaces
1295 The @code{__flash} qualifier locates data in the
1296 @code{.progmem.data} section. Data is read using the @code{LPM}
1297 instruction. Pointers to this address space are 16 bits wide.
1298
1299 @item __flash1
1300 @itemx __flash2
1301 @itemx __flash3
1302 @itemx __flash4
1303 @itemx __flash5
1304 @cindex @code{__flash1} AVR Named Address Spaces
1305 @cindex @code{__flash2} AVR Named Address Spaces
1306 @cindex @code{__flash3} AVR Named Address Spaces
1307 @cindex @code{__flash4} AVR Named Address Spaces
1308 @cindex @code{__flash5} AVR Named Address Spaces
1309 These are 16-bit address spaces locating data in section
1310 @code{.progmem@var{N}.data} where @var{N} refers to
1311 address space @code{__flash@var{N}}.
1312 The compiler sets the @code{RAMPZ} segment register appropriately
1313 before reading data by means of the @code{ELPM} instruction.
1314
1315 @item __memx
1316 @cindex @code{__memx} AVR Named Address Spaces
1317 This is a 24-bit address space that linearizes flash and RAM:
1318 If the high bit of the address is set, data is read from
1319 RAM using the lower two bytes as RAM address.
1320 If the high bit of the address is clear, data is read from flash
1321 with @code{RAMPZ} set according to the high byte of the address.
1322 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1323
1324 Objects in this address space are located in @code{.progmemx.data}.
1325 @end table
1326
1327 @b{Example}
1328
1329 @smallexample
1330 char my_read (const __flash char ** p)
1331 @{
1332 /* p is a pointer to RAM that points to a pointer to flash.
1333 The first indirection of p reads that flash pointer
1334 from RAM and the second indirection reads a char from this
1335 flash address. */
1336
1337 return **p;
1338 @}
1339
1340 /* Locate array[] in flash memory */
1341 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1342
1343 int i = 1;
1344
1345 int main (void)
1346 @{
1347 /* Return 17 by reading from flash memory */
1348 return array[array[i]];
1349 @}
1350 @end smallexample
1351
1352 @noindent
1353 For each named address space supported by avr-gcc there is an equally
1354 named but uppercase built-in macro defined.
1355 The purpose is to facilitate testing if respective address space
1356 support is available or not:
1357
1358 @smallexample
1359 #ifdef __FLASH
1360 const __flash int var = 1;
1361
1362 int read_var (void)
1363 @{
1364 return var;
1365 @}
1366 #else
1367 #include <avr/pgmspace.h> /* From AVR-LibC */
1368
1369 const int var PROGMEM = 1;
1370
1371 int read_var (void)
1372 @{
1373 return (int) pgm_read_word (&var);
1374 @}
1375 #endif /* __FLASH */
1376 @end smallexample
1377
1378 @noindent
1379 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1380 locates data in flash but
1381 accesses to these data read from generic address space, i.e.@:
1382 from RAM,
1383 so that you need special accessors like @code{pgm_read_byte}
1384 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1385 together with attribute @code{progmem}.
1386
1387 @noindent
1388 @b{Limitations and caveats}
1389
1390 @itemize
1391 @item
1392 Reading across the 64@tie{}KiB section boundary of
1393 the @code{__flash} or @code{__flash@var{N}} address spaces
1394 shows undefined behavior. The only address space that
1395 supports reading across the 64@tie{}KiB flash segment boundaries is
1396 @code{__memx}.
1397
1398 @item
1399 If you use one of the @code{__flash@var{N}} address spaces
1400 you must arrange your linker script to locate the
1401 @code{.progmem@var{N}.data} sections according to your needs.
1402
1403 @item
1404 Any data or pointers to the non-generic address spaces must
1405 be qualified as @code{const}, i.e.@: as read-only data.
1406 This still applies if the data in one of these address
1407 spaces like software version number or calibration lookup table are intended to
1408 be changed after load time by, say, a boot loader. In this case
1409 the right qualification is @code{const} @code{volatile} so that the compiler
1410 must not optimize away known values or insert them
1411 as immediates into operands of instructions.
1412
1413 @item
1414 The following code initializes a variable @code{pfoo}
1415 located in static storage with a 24-bit address:
1416 @smallexample
1417 extern const __memx char foo;
1418 const __memx void *pfoo = &foo;
1419 @end smallexample
1420
1421 @noindent
1422 Such code requires at least binutils 2.23, see
1423 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1424
1425 @end itemize
1426
1427 @subsection M32C Named Address Spaces
1428 @cindex @code{__far} M32C Named Address Spaces
1429
1430 On the M32C target, with the R8C and M16C CPU variants, variables
1431 qualified with @code{__far} are accessed using 32-bit addresses in
1432 order to access memory beyond the first 64@tie{}Ki bytes. If
1433 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1434 effect.
1435
1436 @subsection RL78 Named Address Spaces
1437 @cindex @code{__far} RL78 Named Address Spaces
1438
1439 On the RL78 target, variables qualified with @code{__far} are accessed
1440 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1441 addresses. Non-far variables are assumed to appear in the topmost
1442 64@tie{}KiB of the address space.
1443
1444 @subsection SPU Named Address Spaces
1445 @cindex @code{__ea} SPU Named Address Spaces
1446
1447 On the SPU target variables may be declared as
1448 belonging to another address space by qualifying the type with the
1449 @code{__ea} address space identifier:
1450
1451 @smallexample
1452 extern int __ea i;
1453 @end smallexample
1454
1455 @noindent
1456 The compiler generates special code to access the variable @code{i}.
1457 It may use runtime library
1458 support, or generate special machine instructions to access that address
1459 space.
1460
1461 @subsection x86 Named Address Spaces
1462 @cindex x86 named address spaces
1463
1464 On the x86 target, variables may be declared as being relative
1465 to the @code{%fs} or @code{%gs} segments.
1466
1467 @table @code
1468 @item __seg_fs
1469 @itemx __seg_gs
1470 @cindex @code{__seg_fs} x86 named address space
1471 @cindex @code{__seg_gs} x86 named address space
1472 The object is accessed with the respective segment override prefix.
1473
1474 The respective segment base must be set via some method specific to
1475 the operating system. Rather than require an expensive system call
1476 to retrieve the segment base, these address spaces are not considered
1477 to be subspaces of the generic (flat) address space. This means that
1478 explicit casts are required to convert pointers between these address
1479 spaces and the generic address space. In practice the application
1480 should cast to @code{uintptr_t} and apply the segment base offset
1481 that it installed previously.
1482
1483 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1484 defined when these address spaces are supported.
1485 @end table
1486
1487 @node Zero Length
1488 @section Arrays of Length Zero
1489 @cindex arrays of length zero
1490 @cindex zero-length arrays
1491 @cindex length-zero arrays
1492 @cindex flexible array members
1493
1494 Zero-length arrays are allowed in GNU C@. They are very useful as the
1495 last element of a structure that is really a header for a variable-length
1496 object:
1497
1498 @smallexample
1499 struct line @{
1500 int length;
1501 char contents[0];
1502 @};
1503
1504 struct line *thisline = (struct line *)
1505 malloc (sizeof (struct line) + this_length);
1506 thisline->length = this_length;
1507 @end smallexample
1508
1509 In ISO C90, you would have to give @code{contents} a length of 1, which
1510 means either you waste space or complicate the argument to @code{malloc}.
1511
1512 In ISO C99, you would use a @dfn{flexible array member}, which is
1513 slightly different in syntax and semantics:
1514
1515 @itemize @bullet
1516 @item
1517 Flexible array members are written as @code{contents[]} without
1518 the @code{0}.
1519
1520 @item
1521 Flexible array members have incomplete type, and so the @code{sizeof}
1522 operator may not be applied. As a quirk of the original implementation
1523 of zero-length arrays, @code{sizeof} evaluates to zero.
1524
1525 @item
1526 Flexible array members may only appear as the last member of a
1527 @code{struct} that is otherwise non-empty.
1528
1529 @item
1530 A structure containing a flexible array member, or a union containing
1531 such a structure (possibly recursively), may not be a member of a
1532 structure or an element of an array. (However, these uses are
1533 permitted by GCC as extensions.)
1534 @end itemize
1535
1536 Non-empty initialization of zero-length
1537 arrays is treated like any case where there are more initializer
1538 elements than the array holds, in that a suitable warning about ``excess
1539 elements in array'' is given, and the excess elements (all of them, in
1540 this case) are ignored.
1541
1542 GCC allows static initialization of flexible array members.
1543 This is equivalent to defining a new structure containing the original
1544 structure followed by an array of sufficient size to contain the data.
1545 E.g.@: in the following, @code{f1} is constructed as if it were declared
1546 like @code{f2}.
1547
1548 @smallexample
1549 struct f1 @{
1550 int x; int y[];
1551 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1552
1553 struct f2 @{
1554 struct f1 f1; int data[3];
1555 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1556 @end smallexample
1557
1558 @noindent
1559 The convenience of this extension is that @code{f1} has the desired
1560 type, eliminating the need to consistently refer to @code{f2.f1}.
1561
1562 This has symmetry with normal static arrays, in that an array of
1563 unknown size is also written with @code{[]}.
1564
1565 Of course, this extension only makes sense if the extra data comes at
1566 the end of a top-level object, as otherwise we would be overwriting
1567 data at subsequent offsets. To avoid undue complication and confusion
1568 with initialization of deeply nested arrays, we simply disallow any
1569 non-empty initialization except when the structure is the top-level
1570 object. For example:
1571
1572 @smallexample
1573 struct foo @{ int x; int y[]; @};
1574 struct bar @{ struct foo z; @};
1575
1576 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1577 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1578 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1579 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1580 @end smallexample
1581
1582 @node Empty Structures
1583 @section Structures with No Members
1584 @cindex empty structures
1585 @cindex zero-size structures
1586
1587 GCC permits a C structure to have no members:
1588
1589 @smallexample
1590 struct empty @{
1591 @};
1592 @end smallexample
1593
1594 The structure has size zero. In C++, empty structures are part
1595 of the language. G++ treats empty structures as if they had a single
1596 member of type @code{char}.
1597
1598 @node Variable Length
1599 @section Arrays of Variable Length
1600 @cindex variable-length arrays
1601 @cindex arrays of variable length
1602 @cindex VLAs
1603
1604 Variable-length automatic arrays are allowed in ISO C99, and as an
1605 extension GCC accepts them in C90 mode and in C++. These arrays are
1606 declared like any other automatic arrays, but with a length that is not
1607 a constant expression. The storage is allocated at the point of
1608 declaration and deallocated when the block scope containing the declaration
1609 exits. For
1610 example:
1611
1612 @smallexample
1613 FILE *
1614 concat_fopen (char *s1, char *s2, char *mode)
1615 @{
1616 char str[strlen (s1) + strlen (s2) + 1];
1617 strcpy (str, s1);
1618 strcat (str, s2);
1619 return fopen (str, mode);
1620 @}
1621 @end smallexample
1622
1623 @cindex scope of a variable length array
1624 @cindex variable-length array scope
1625 @cindex deallocating variable length arrays
1626 Jumping or breaking out of the scope of the array name deallocates the
1627 storage. Jumping into the scope is not allowed; you get an error
1628 message for it.
1629
1630 @cindex variable-length array in a structure
1631 As an extension, GCC accepts variable-length arrays as a member of
1632 a structure or a union. For example:
1633
1634 @smallexample
1635 void
1636 foo (int n)
1637 @{
1638 struct S @{ int x[n]; @};
1639 @}
1640 @end smallexample
1641
1642 @cindex @code{alloca} vs variable-length arrays
1643 You can use the function @code{alloca} to get an effect much like
1644 variable-length arrays. The function @code{alloca} is available in
1645 many other C implementations (but not in all). On the other hand,
1646 variable-length arrays are more elegant.
1647
1648 There are other differences between these two methods. Space allocated
1649 with @code{alloca} exists until the containing @emph{function} returns.
1650 The space for a variable-length array is deallocated as soon as the array
1651 name's scope ends, unless you also use @code{alloca} in this scope.
1652
1653 You can also use variable-length arrays as arguments to functions:
1654
1655 @smallexample
1656 struct entry
1657 tester (int len, char data[len][len])
1658 @{
1659 /* @r{@dots{}} */
1660 @}
1661 @end smallexample
1662
1663 The length of an array is computed once when the storage is allocated
1664 and is remembered for the scope of the array in case you access it with
1665 @code{sizeof}.
1666
1667 If you want to pass the array first and the length afterward, you can
1668 use a forward declaration in the parameter list---another GNU extension.
1669
1670 @smallexample
1671 struct entry
1672 tester (int len; char data[len][len], int len)
1673 @{
1674 /* @r{@dots{}} */
1675 @}
1676 @end smallexample
1677
1678 @cindex parameter forward declaration
1679 The @samp{int len} before the semicolon is a @dfn{parameter forward
1680 declaration}, and it serves the purpose of making the name @code{len}
1681 known when the declaration of @code{data} is parsed.
1682
1683 You can write any number of such parameter forward declarations in the
1684 parameter list. They can be separated by commas or semicolons, but the
1685 last one must end with a semicolon, which is followed by the ``real''
1686 parameter declarations. Each forward declaration must match a ``real''
1687 declaration in parameter name and data type. ISO C99 does not support
1688 parameter forward declarations.
1689
1690 @node Variadic Macros
1691 @section Macros with a Variable Number of Arguments.
1692 @cindex variable number of arguments
1693 @cindex macro with variable arguments
1694 @cindex rest argument (in macro)
1695 @cindex variadic macros
1696
1697 In the ISO C standard of 1999, a macro can be declared to accept a
1698 variable number of arguments much as a function can. The syntax for
1699 defining the macro is similar to that of a function. Here is an
1700 example:
1701
1702 @smallexample
1703 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1704 @end smallexample
1705
1706 @noindent
1707 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1708 such a macro, it represents the zero or more tokens until the closing
1709 parenthesis that ends the invocation, including any commas. This set of
1710 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1711 wherever it appears. See the CPP manual for more information.
1712
1713 GCC has long supported variadic macros, and used a different syntax that
1714 allowed you to give a name to the variable arguments just like any other
1715 argument. Here is an example:
1716
1717 @smallexample
1718 #define debug(format, args...) fprintf (stderr, format, args)
1719 @end smallexample
1720
1721 @noindent
1722 This is in all ways equivalent to the ISO C example above, but arguably
1723 more readable and descriptive.
1724
1725 GNU CPP has two further variadic macro extensions, and permits them to
1726 be used with either of the above forms of macro definition.
1727
1728 In standard C, you are not allowed to leave the variable argument out
1729 entirely; but you are allowed to pass an empty argument. For example,
1730 this invocation is invalid in ISO C, because there is no comma after
1731 the string:
1732
1733 @smallexample
1734 debug ("A message")
1735 @end smallexample
1736
1737 GNU CPP permits you to completely omit the variable arguments in this
1738 way. In the above examples, the compiler would complain, though since
1739 the expansion of the macro still has the extra comma after the format
1740 string.
1741
1742 To help solve this problem, CPP behaves specially for variable arguments
1743 used with the token paste operator, @samp{##}. If instead you write
1744
1745 @smallexample
1746 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1747 @end smallexample
1748
1749 @noindent
1750 and if the variable arguments are omitted or empty, the @samp{##}
1751 operator causes the preprocessor to remove the comma before it. If you
1752 do provide some variable arguments in your macro invocation, GNU CPP
1753 does not complain about the paste operation and instead places the
1754 variable arguments after the comma. Just like any other pasted macro
1755 argument, these arguments are not macro expanded.
1756
1757 @node Escaped Newlines
1758 @section Slightly Looser Rules for Escaped Newlines
1759 @cindex escaped newlines
1760 @cindex newlines (escaped)
1761
1762 The preprocessor treatment of escaped newlines is more relaxed
1763 than that specified by the C90 standard, which requires the newline
1764 to immediately follow a backslash.
1765 GCC's implementation allows whitespace in the form
1766 of spaces, horizontal and vertical tabs, and form feeds between the
1767 backslash and the subsequent newline. The preprocessor issues a
1768 warning, but treats it as a valid escaped newline and combines the two
1769 lines to form a single logical line. This works within comments and
1770 tokens, as well as between tokens. Comments are @emph{not} treated as
1771 whitespace for the purposes of this relaxation, since they have not
1772 yet been replaced with spaces.
1773
1774 @node Subscripting
1775 @section Non-Lvalue Arrays May Have Subscripts
1776 @cindex subscripting
1777 @cindex arrays, non-lvalue
1778
1779 @cindex subscripting and function values
1780 In ISO C99, arrays that are not lvalues still decay to pointers, and
1781 may be subscripted, although they may not be modified or used after
1782 the next sequence point and the unary @samp{&} operator may not be
1783 applied to them. As an extension, GNU C allows such arrays to be
1784 subscripted in C90 mode, though otherwise they do not decay to
1785 pointers outside C99 mode. For example,
1786 this is valid in GNU C though not valid in C90:
1787
1788 @smallexample
1789 @group
1790 struct foo @{int a[4];@};
1791
1792 struct foo f();
1793
1794 bar (int index)
1795 @{
1796 return f().a[index];
1797 @}
1798 @end group
1799 @end smallexample
1800
1801 @node Pointer Arith
1802 @section Arithmetic on @code{void}- and Function-Pointers
1803 @cindex void pointers, arithmetic
1804 @cindex void, size of pointer to
1805 @cindex function pointers, arithmetic
1806 @cindex function, size of pointer to
1807
1808 In GNU C, addition and subtraction operations are supported on pointers to
1809 @code{void} and on pointers to functions. This is done by treating the
1810 size of a @code{void} or of a function as 1.
1811
1812 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1813 and on function types, and returns 1.
1814
1815 @opindex Wpointer-arith
1816 The option @option{-Wpointer-arith} requests a warning if these extensions
1817 are used.
1818
1819 @node Pointers to Arrays
1820 @section Pointers to Arrays with Qualifiers Work as Expected
1821 @cindex pointers to arrays
1822 @cindex const qualifier
1823
1824 In GNU C, pointers to arrays with qualifiers work similar to pointers
1825 to other qualified types. For example, a value of type @code{int (*)[5]}
1826 can be used to initialize a variable of type @code{const int (*)[5]}.
1827 These types are incompatible in ISO C because the @code{const} qualifier
1828 is formally attached to the element type of the array and not the
1829 array itself.
1830
1831 @smallexample
1832 extern void
1833 transpose (int N, int M, double out[M][N], const double in[N][M]);
1834 double x[3][2];
1835 double y[2][3];
1836 @r{@dots{}}
1837 transpose(3, 2, y, x);
1838 @end smallexample
1839
1840 @node Initializers
1841 @section Non-Constant Initializers
1842 @cindex initializers, non-constant
1843 @cindex non-constant initializers
1844
1845 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1846 automatic variable are not required to be constant expressions in GNU C@.
1847 Here is an example of an initializer with run-time varying elements:
1848
1849 @smallexample
1850 foo (float f, float g)
1851 @{
1852 float beat_freqs[2] = @{ f-g, f+g @};
1853 /* @r{@dots{}} */
1854 @}
1855 @end smallexample
1856
1857 @node Compound Literals
1858 @section Compound Literals
1859 @cindex constructor expressions
1860 @cindex initializations in expressions
1861 @cindex structures, constructor expression
1862 @cindex expressions, constructor
1863 @cindex compound literals
1864 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1865
1866 ISO C99 supports compound literals. A compound literal looks like
1867 a cast containing an initializer. Its value is an object of the
1868 type specified in the cast, containing the elements specified in
1869 the initializer; it is an lvalue. As an extension, GCC supports
1870 compound literals in C90 mode and in C++, though the semantics are
1871 somewhat different in C++.
1872
1873 Usually, the specified type is a structure. Assume that
1874 @code{struct foo} and @code{structure} are declared as shown:
1875
1876 @smallexample
1877 struct foo @{int a; char b[2];@} structure;
1878 @end smallexample
1879
1880 @noindent
1881 Here is an example of constructing a @code{struct foo} with a compound literal:
1882
1883 @smallexample
1884 structure = ((struct foo) @{x + y, 'a', 0@});
1885 @end smallexample
1886
1887 @noindent
1888 This is equivalent to writing the following:
1889
1890 @smallexample
1891 @{
1892 struct foo temp = @{x + y, 'a', 0@};
1893 structure = temp;
1894 @}
1895 @end smallexample
1896
1897 You can also construct an array, though this is dangerous in C++, as
1898 explained below. If all the elements of the compound literal are
1899 (made up of) simple constant expressions, suitable for use in
1900 initializers of objects of static storage duration, then the compound
1901 literal can be coerced to a pointer to its first element and used in
1902 such an initializer, as shown here:
1903
1904 @smallexample
1905 char **foo = (char *[]) @{ "x", "y", "z" @};
1906 @end smallexample
1907
1908 Compound literals for scalar types and union types are
1909 also allowed, but then the compound literal is equivalent
1910 to a cast.
1911
1912 As a GNU extension, GCC allows initialization of objects with static storage
1913 duration by compound literals (which is not possible in ISO C99, because
1914 the initializer is not a constant).
1915 It is handled as if the object is initialized only with the bracket
1916 enclosed list if the types of the compound literal and the object match.
1917 The initializer list of the compound literal must be constant.
1918 If the object being initialized has array type of unknown size, the size is
1919 determined by compound literal size.
1920
1921 @smallexample
1922 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1923 static int y[] = (int []) @{1, 2, 3@};
1924 static int z[] = (int [3]) @{1@};
1925 @end smallexample
1926
1927 @noindent
1928 The above lines are equivalent to the following:
1929 @smallexample
1930 static struct foo x = @{1, 'a', 'b'@};
1931 static int y[] = @{1, 2, 3@};
1932 static int z[] = @{1, 0, 0@};
1933 @end smallexample
1934
1935 In C, a compound literal designates an unnamed object with static or
1936 automatic storage duration. In C++, a compound literal designates a
1937 temporary object, which only lives until the end of its
1938 full-expression. As a result, well-defined C code that takes the
1939 address of a subobject of a compound literal can be undefined in C++,
1940 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1941 For instance, if the array compound literal example above appeared
1942 inside a function, any subsequent use of @samp{foo} in C++ has
1943 undefined behavior because the lifetime of the array ends after the
1944 declaration of @samp{foo}.
1945
1946 As an optimization, the C++ compiler sometimes gives array compound
1947 literals longer lifetimes: when the array either appears outside a
1948 function or has const-qualified type. If @samp{foo} and its
1949 initializer had elements of @samp{char *const} type rather than
1950 @samp{char *}, or if @samp{foo} were a global variable, the array
1951 would have static storage duration. But it is probably safest just to
1952 avoid the use of array compound literals in code compiled as C++.
1953
1954 @node Designated Inits
1955 @section Designated Initializers
1956 @cindex initializers with labeled elements
1957 @cindex labeled elements in initializers
1958 @cindex case labels in initializers
1959 @cindex designated initializers
1960
1961 Standard C90 requires the elements of an initializer to appear in a fixed
1962 order, the same as the order of the elements in the array or structure
1963 being initialized.
1964
1965 In ISO C99 you can give the elements in any order, specifying the array
1966 indices or structure field names they apply to, and GNU C allows this as
1967 an extension in C90 mode as well. This extension is not
1968 implemented in GNU C++.
1969
1970 To specify an array index, write
1971 @samp{[@var{index}] =} before the element value. For example,
1972
1973 @smallexample
1974 int a[6] = @{ [4] = 29, [2] = 15 @};
1975 @end smallexample
1976
1977 @noindent
1978 is equivalent to
1979
1980 @smallexample
1981 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1982 @end smallexample
1983
1984 @noindent
1985 The index values must be constant expressions, even if the array being
1986 initialized is automatic.
1987
1988 An alternative syntax for this that has been obsolete since GCC 2.5 but
1989 GCC still accepts is to write @samp{[@var{index}]} before the element
1990 value, with no @samp{=}.
1991
1992 To initialize a range of elements to the same value, write
1993 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1994 extension. For example,
1995
1996 @smallexample
1997 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1998 @end smallexample
1999
2000 @noindent
2001 If the value in it has side-effects, the side-effects happen only once,
2002 not for each initialized field by the range initializer.
2003
2004 @noindent
2005 Note that the length of the array is the highest value specified
2006 plus one.
2007
2008 In a structure initializer, specify the name of a field to initialize
2009 with @samp{.@var{fieldname} =} before the element value. For example,
2010 given the following structure,
2011
2012 @smallexample
2013 struct point @{ int x, y; @};
2014 @end smallexample
2015
2016 @noindent
2017 the following initialization
2018
2019 @smallexample
2020 struct point p = @{ .y = yvalue, .x = xvalue @};
2021 @end smallexample
2022
2023 @noindent
2024 is equivalent to
2025
2026 @smallexample
2027 struct point p = @{ xvalue, yvalue @};
2028 @end smallexample
2029
2030 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2031 @samp{@var{fieldname}:}, as shown here:
2032
2033 @smallexample
2034 struct point p = @{ y: yvalue, x: xvalue @};
2035 @end smallexample
2036
2037 Omitted field members are implicitly initialized the same as objects
2038 that have static storage duration.
2039
2040 @cindex designators
2041 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2042 @dfn{designator}. You can also use a designator (or the obsolete colon
2043 syntax) when initializing a union, to specify which element of the union
2044 should be used. For example,
2045
2046 @smallexample
2047 union foo @{ int i; double d; @};
2048
2049 union foo f = @{ .d = 4 @};
2050 @end smallexample
2051
2052 @noindent
2053 converts 4 to a @code{double} to store it in the union using
2054 the second element. By contrast, casting 4 to type @code{union foo}
2055 stores it into the union as the integer @code{i}, since it is
2056 an integer. (@xref{Cast to Union}.)
2057
2058 You can combine this technique of naming elements with ordinary C
2059 initialization of successive elements. Each initializer element that
2060 does not have a designator applies to the next consecutive element of the
2061 array or structure. For example,
2062
2063 @smallexample
2064 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2065 @end smallexample
2066
2067 @noindent
2068 is equivalent to
2069
2070 @smallexample
2071 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2072 @end smallexample
2073
2074 Labeling the elements of an array initializer is especially useful
2075 when the indices are characters or belong to an @code{enum} type.
2076 For example:
2077
2078 @smallexample
2079 int whitespace[256]
2080 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2081 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2082 @end smallexample
2083
2084 @cindex designator lists
2085 You can also write a series of @samp{.@var{fieldname}} and
2086 @samp{[@var{index}]} designators before an @samp{=} to specify a
2087 nested subobject to initialize; the list is taken relative to the
2088 subobject corresponding to the closest surrounding brace pair. For
2089 example, with the @samp{struct point} declaration above:
2090
2091 @smallexample
2092 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2093 @end smallexample
2094
2095 @noindent
2096 If the same field is initialized multiple times, it has the value from
2097 the last initialization. If any such overridden initialization has
2098 side-effect, it is unspecified whether the side-effect happens or not.
2099 Currently, GCC discards them and issues a warning.
2100
2101 @node Case Ranges
2102 @section Case Ranges
2103 @cindex case ranges
2104 @cindex ranges in case statements
2105
2106 You can specify a range of consecutive values in a single @code{case} label,
2107 like this:
2108
2109 @smallexample
2110 case @var{low} ... @var{high}:
2111 @end smallexample
2112
2113 @noindent
2114 This has the same effect as the proper number of individual @code{case}
2115 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2116
2117 This feature is especially useful for ranges of ASCII character codes:
2118
2119 @smallexample
2120 case 'A' ... 'Z':
2121 @end smallexample
2122
2123 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2124 it may be parsed wrong when you use it with integer values. For example,
2125 write this:
2126
2127 @smallexample
2128 case 1 ... 5:
2129 @end smallexample
2130
2131 @noindent
2132 rather than this:
2133
2134 @smallexample
2135 case 1...5:
2136 @end smallexample
2137
2138 @node Cast to Union
2139 @section Cast to a Union Type
2140 @cindex cast to a union
2141 @cindex union, casting to a
2142
2143 A cast to union type is similar to other casts, except that the type
2144 specified is a union type. You can specify the type either with
2145 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2146 a constructor, not a cast, and hence does not yield an lvalue like
2147 normal casts. (@xref{Compound Literals}.)
2148
2149 The types that may be cast to the union type are those of the members
2150 of the union. Thus, given the following union and variables:
2151
2152 @smallexample
2153 union foo @{ int i; double d; @};
2154 int x;
2155 double y;
2156 @end smallexample
2157
2158 @noindent
2159 both @code{x} and @code{y} can be cast to type @code{union foo}.
2160
2161 Using the cast as the right-hand side of an assignment to a variable of
2162 union type is equivalent to storing in a member of the union:
2163
2164 @smallexample
2165 union foo u;
2166 /* @r{@dots{}} */
2167 u = (union foo) x @equiv{} u.i = x
2168 u = (union foo) y @equiv{} u.d = y
2169 @end smallexample
2170
2171 You can also use the union cast as a function argument:
2172
2173 @smallexample
2174 void hack (union foo);
2175 /* @r{@dots{}} */
2176 hack ((union foo) x);
2177 @end smallexample
2178
2179 @node Mixed Declarations
2180 @section Mixed Declarations and Code
2181 @cindex mixed declarations and code
2182 @cindex declarations, mixed with code
2183 @cindex code, mixed with declarations
2184
2185 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2186 within compound statements. As an extension, GNU C also allows this in
2187 C90 mode. For example, you could do:
2188
2189 @smallexample
2190 int i;
2191 /* @r{@dots{}} */
2192 i++;
2193 int j = i + 2;
2194 @end smallexample
2195
2196 Each identifier is visible from where it is declared until the end of
2197 the enclosing block.
2198
2199 @node Function Attributes
2200 @section Declaring Attributes of Functions
2201 @cindex function attributes
2202 @cindex declaring attributes of functions
2203 @cindex @code{volatile} applied to function
2204 @cindex @code{const} applied to function
2205
2206 In GNU C, you can use function attributes to declare certain things
2207 about functions called in your program which help the compiler
2208 optimize calls and check your code more carefully. For example, you
2209 can use attributes to declare that a function never returns
2210 (@code{noreturn}), returns a value depending only on its arguments
2211 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2212
2213 You can also use attributes to control memory placement, code
2214 generation options or call/return conventions within the function
2215 being annotated. Many of these attributes are target-specific. For
2216 example, many targets support attributes for defining interrupt
2217 handler functions, which typically must follow special register usage
2218 and return conventions.
2219
2220 Function attributes are introduced by the @code{__attribute__} keyword
2221 on a declaration, followed by an attribute specification inside double
2222 parentheses. You can specify multiple attributes in a declaration by
2223 separating them by commas within the double parentheses or by
2224 immediately following an attribute declaration with another attribute
2225 declaration. @xref{Attribute Syntax}, for the exact rules on
2226 attribute syntax and placement.
2227
2228 GCC also supports attributes on
2229 variable declarations (@pxref{Variable Attributes}),
2230 labels (@pxref{Label Attributes}),
2231 enumerators (@pxref{Enumerator Attributes}),
2232 and types (@pxref{Type Attributes}).
2233
2234 There is some overlap between the purposes of attributes and pragmas
2235 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2236 found convenient to use @code{__attribute__} to achieve a natural
2237 attachment of attributes to their corresponding declarations, whereas
2238 @code{#pragma} is of use for compatibility with other compilers
2239 or constructs that do not naturally form part of the grammar.
2240
2241 In addition to the attributes documented here,
2242 GCC plugins may provide their own attributes.
2243
2244 @menu
2245 * Common Function Attributes::
2246 * AArch64 Function Attributes::
2247 * ARC Function Attributes::
2248 * ARM Function Attributes::
2249 * AVR Function Attributes::
2250 * Blackfin Function Attributes::
2251 * CR16 Function Attributes::
2252 * Epiphany Function Attributes::
2253 * H8/300 Function Attributes::
2254 * IA-64 Function Attributes::
2255 * M32C Function Attributes::
2256 * M32R/D Function Attributes::
2257 * m68k Function Attributes::
2258 * MCORE Function Attributes::
2259 * MeP Function Attributes::
2260 * MicroBlaze Function Attributes::
2261 * Microsoft Windows Function Attributes::
2262 * MIPS Function Attributes::
2263 * MSP430 Function Attributes::
2264 * NDS32 Function Attributes::
2265 * Nios II Function Attributes::
2266 * Nvidia PTX Function Attributes::
2267 * PowerPC Function Attributes::
2268 * RL78 Function Attributes::
2269 * RX Function Attributes::
2270 * S/390 Function Attributes::
2271 * SH Function Attributes::
2272 * SPU Function Attributes::
2273 * Symbian OS Function Attributes::
2274 * V850 Function Attributes::
2275 * Visium Function Attributes::
2276 * x86 Function Attributes::
2277 * Xstormy16 Function Attributes::
2278 @end menu
2279
2280 @node Common Function Attributes
2281 @subsection Common Function Attributes
2282
2283 The following attributes are supported on most targets.
2284
2285 @table @code
2286 @c Keep this table alphabetized by attribute name. Treat _ as space.
2287
2288 @item alias ("@var{target}")
2289 @cindex @code{alias} function attribute
2290 The @code{alias} attribute causes the declaration to be emitted as an
2291 alias for another symbol, which must be specified. For instance,
2292
2293 @smallexample
2294 void __f () @{ /* @r{Do something.} */; @}
2295 void f () __attribute__ ((weak, alias ("__f")));
2296 @end smallexample
2297
2298 @noindent
2299 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2300 mangled name for the target must be used. It is an error if @samp{__f}
2301 is not defined in the same translation unit.
2302
2303 This attribute requires assembler and object file support,
2304 and may not be available on all targets.
2305
2306 @item aligned (@var{alignment})
2307 @cindex @code{aligned} function attribute
2308 This attribute specifies a minimum alignment for the function,
2309 measured in bytes.
2310
2311 You cannot use this attribute to decrease the alignment of a function,
2312 only to increase it. However, when you explicitly specify a function
2313 alignment this overrides the effect of the
2314 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2315 function.
2316
2317 Note that the effectiveness of @code{aligned} attributes may be
2318 limited by inherent limitations in your linker. On many systems, the
2319 linker is only able to arrange for functions to be aligned up to a
2320 certain maximum alignment. (For some linkers, the maximum supported
2321 alignment may be very very small.) See your linker documentation for
2322 further information.
2323
2324 The @code{aligned} attribute can also be used for variables and fields
2325 (@pxref{Variable Attributes}.)
2326
2327 @item alloc_align
2328 @cindex @code{alloc_align} function attribute
2329 The @code{alloc_align} attribute is used to tell the compiler that the
2330 function return value points to memory, where the returned pointer minimum
2331 alignment is given by one of the functions parameters. GCC uses this
2332 information to improve pointer alignment analysis.
2333
2334 The function parameter denoting the allocated alignment is specified by
2335 one integer argument, whose number is the argument of the attribute.
2336 Argument numbering starts at one.
2337
2338 For instance,
2339
2340 @smallexample
2341 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2342 @end smallexample
2343
2344 @noindent
2345 declares that @code{my_memalign} returns memory with minimum alignment
2346 given by parameter 1.
2347
2348 @item alloc_size
2349 @cindex @code{alloc_size} function attribute
2350 The @code{alloc_size} attribute is used to tell the compiler that the
2351 function return value points to memory, where the size is given by
2352 one or two of the functions parameters. GCC uses this
2353 information to improve the correctness of @code{__builtin_object_size}.
2354
2355 The function parameter(s) denoting the allocated size are specified by
2356 one or two integer arguments supplied to the attribute. The allocated size
2357 is either the value of the single function argument specified or the product
2358 of the two function arguments specified. Argument numbering starts at
2359 one.
2360
2361 For instance,
2362
2363 @smallexample
2364 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2365 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2366 @end smallexample
2367
2368 @noindent
2369 declares that @code{my_calloc} returns memory of the size given by
2370 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2371 of the size given by parameter 2.
2372
2373 @item always_inline
2374 @cindex @code{always_inline} function attribute
2375 Generally, functions are not inlined unless optimization is specified.
2376 For functions declared inline, this attribute inlines the function
2377 independent of any restrictions that otherwise apply to inlining.
2378 Failure to inline such a function is diagnosed as an error.
2379 Note that if such a function is called indirectly the compiler may
2380 or may not inline it depending on optimization level and a failure
2381 to inline an indirect call may or may not be diagnosed.
2382
2383 @item artificial
2384 @cindex @code{artificial} function attribute
2385 This attribute is useful for small inline wrappers that if possible
2386 should appear during debugging as a unit. Depending on the debug
2387 info format it either means marking the function as artificial
2388 or using the caller location for all instructions within the inlined
2389 body.
2390
2391 @item assume_aligned
2392 @cindex @code{assume_aligned} function attribute
2393 The @code{assume_aligned} attribute is used to tell the compiler that the
2394 function return value points to memory, where the returned pointer minimum
2395 alignment is given by the first argument.
2396 If the attribute has two arguments, the second argument is misalignment offset.
2397
2398 For instance
2399
2400 @smallexample
2401 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2402 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2403 @end smallexample
2404
2405 @noindent
2406 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2407 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2408 to 8.
2409
2410 @item bnd_instrument
2411 @cindex @code{bnd_instrument} function attribute
2412 The @code{bnd_instrument} attribute on functions is used to inform the
2413 compiler that the function should be instrumented when compiled
2414 with the @option{-fchkp-instrument-marked-only} option.
2415
2416 @item bnd_legacy
2417 @cindex @code{bnd_legacy} function attribute
2418 @cindex Pointer Bounds Checker attributes
2419 The @code{bnd_legacy} attribute on functions is used to inform the
2420 compiler that the function should not be instrumented when compiled
2421 with the @option{-fcheck-pointer-bounds} option.
2422
2423 @item cold
2424 @cindex @code{cold} function attribute
2425 The @code{cold} attribute on functions is used to inform the compiler that
2426 the function is unlikely to be executed. The function is optimized for
2427 size rather than speed and on many targets it is placed into a special
2428 subsection of the text section so all cold functions appear close together,
2429 improving code locality of non-cold parts of program. The paths leading
2430 to calls of cold functions within code are marked as unlikely by the branch
2431 prediction mechanism. It is thus useful to mark functions used to handle
2432 unlikely conditions, such as @code{perror}, as cold to improve optimization
2433 of hot functions that do call marked functions in rare occasions.
2434
2435 When profile feedback is available, via @option{-fprofile-use}, cold functions
2436 are automatically detected and this attribute is ignored.
2437
2438 @item const
2439 @cindex @code{const} function attribute
2440 @cindex functions that have no side effects
2441 Many functions do not examine any values except their arguments, and
2442 have no effects except the return value. Basically this is just slightly
2443 more strict class than the @code{pure} attribute below, since function is not
2444 allowed to read global memory.
2445
2446 @cindex pointer arguments
2447 Note that a function that has pointer arguments and examines the data
2448 pointed to must @emph{not} be declared @code{const}. Likewise, a
2449 function that calls a non-@code{const} function usually must not be
2450 @code{const}. It does not make sense for a @code{const} function to
2451 return @code{void}.
2452
2453 @item constructor
2454 @itemx destructor
2455 @itemx constructor (@var{priority})
2456 @itemx destructor (@var{priority})
2457 @cindex @code{constructor} function attribute
2458 @cindex @code{destructor} function attribute
2459 The @code{constructor} attribute causes the function to be called
2460 automatically before execution enters @code{main ()}. Similarly, the
2461 @code{destructor} attribute causes the function to be called
2462 automatically after @code{main ()} completes or @code{exit ()} is
2463 called. Functions with these attributes are useful for
2464 initializing data that is used implicitly during the execution of
2465 the program.
2466
2467 You may provide an optional integer priority to control the order in
2468 which constructor and destructor functions are run. A constructor
2469 with a smaller priority number runs before a constructor with a larger
2470 priority number; the opposite relationship holds for destructors. So,
2471 if you have a constructor that allocates a resource and a destructor
2472 that deallocates the same resource, both functions typically have the
2473 same priority. The priorities for constructor and destructor
2474 functions are the same as those specified for namespace-scope C++
2475 objects (@pxref{C++ Attributes}).
2476
2477 These attributes are not currently implemented for Objective-C@.
2478
2479 @item deprecated
2480 @itemx deprecated (@var{msg})
2481 @cindex @code{deprecated} function attribute
2482 The @code{deprecated} attribute results in a warning if the function
2483 is used anywhere in the source file. This is useful when identifying
2484 functions that are expected to be removed in a future version of a
2485 program. The warning also includes the location of the declaration
2486 of the deprecated function, to enable users to easily find further
2487 information about why the function is deprecated, or what they should
2488 do instead. Note that the warnings only occurs for uses:
2489
2490 @smallexample
2491 int old_fn () __attribute__ ((deprecated));
2492 int old_fn ();
2493 int (*fn_ptr)() = old_fn;
2494 @end smallexample
2495
2496 @noindent
2497 results in a warning on line 3 but not line 2. The optional @var{msg}
2498 argument, which must be a string, is printed in the warning if
2499 present.
2500
2501 The @code{deprecated} attribute can also be used for variables and
2502 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2503
2504 @item error ("@var{message}")
2505 @itemx warning ("@var{message}")
2506 @cindex @code{error} function attribute
2507 @cindex @code{warning} function attribute
2508 If the @code{error} or @code{warning} attribute
2509 is used on a function declaration and a call to such a function
2510 is not eliminated through dead code elimination or other optimizations,
2511 an error or warning (respectively) that includes @var{message} is diagnosed.
2512 This is useful
2513 for compile-time checking, especially together with @code{__builtin_constant_p}
2514 and inline functions where checking the inline function arguments is not
2515 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2516
2517 While it is possible to leave the function undefined and thus invoke
2518 a link failure (to define the function with
2519 a message in @code{.gnu.warning*} section),
2520 when using these attributes the problem is diagnosed
2521 earlier and with exact location of the call even in presence of inline
2522 functions or when not emitting debugging information.
2523
2524 @item externally_visible
2525 @cindex @code{externally_visible} function attribute
2526 This attribute, attached to a global variable or function, nullifies
2527 the effect of the @option{-fwhole-program} command-line option, so the
2528 object remains visible outside the current compilation unit.
2529
2530 If @option{-fwhole-program} is used together with @option{-flto} and
2531 @command{gold} is used as the linker plugin,
2532 @code{externally_visible} attributes are automatically added to functions
2533 (not variable yet due to a current @command{gold} issue)
2534 that are accessed outside of LTO objects according to resolution file
2535 produced by @command{gold}.
2536 For other linkers that cannot generate resolution file,
2537 explicit @code{externally_visible} attributes are still necessary.
2538
2539 @item flatten
2540 @cindex @code{flatten} function attribute
2541 Generally, inlining into a function is limited. For a function marked with
2542 this attribute, every call inside this function is inlined, if possible.
2543 Whether the function itself is considered for inlining depends on its size and
2544 the current inlining parameters.
2545
2546 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2547 @cindex @code{format} function attribute
2548 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2549 @opindex Wformat
2550 The @code{format} attribute specifies that a function takes @code{printf},
2551 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2552 should be type-checked against a format string. For example, the
2553 declaration:
2554
2555 @smallexample
2556 extern int
2557 my_printf (void *my_object, const char *my_format, ...)
2558 __attribute__ ((format (printf, 2, 3)));
2559 @end smallexample
2560
2561 @noindent
2562 causes the compiler to check the arguments in calls to @code{my_printf}
2563 for consistency with the @code{printf} style format string argument
2564 @code{my_format}.
2565
2566 The parameter @var{archetype} determines how the format string is
2567 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2568 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2569 @code{strfmon}. (You can also use @code{__printf__},
2570 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2571 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2572 @code{ms_strftime} are also present.
2573 @var{archetype} values such as @code{printf} refer to the formats accepted
2574 by the system's C runtime library,
2575 while values prefixed with @samp{gnu_} always refer
2576 to the formats accepted by the GNU C Library. On Microsoft Windows
2577 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2578 @file{msvcrt.dll} library.
2579 The parameter @var{string-index}
2580 specifies which argument is the format string argument (starting
2581 from 1), while @var{first-to-check} is the number of the first
2582 argument to check against the format string. For functions
2583 where the arguments are not available to be checked (such as
2584 @code{vprintf}), specify the third parameter as zero. In this case the
2585 compiler only checks the format string for consistency. For
2586 @code{strftime} formats, the third parameter is required to be zero.
2587 Since non-static C++ methods have an implicit @code{this} argument, the
2588 arguments of such methods should be counted from two, not one, when
2589 giving values for @var{string-index} and @var{first-to-check}.
2590
2591 In the example above, the format string (@code{my_format}) is the second
2592 argument of the function @code{my_print}, and the arguments to check
2593 start with the third argument, so the correct parameters for the format
2594 attribute are 2 and 3.
2595
2596 @opindex ffreestanding
2597 @opindex fno-builtin
2598 The @code{format} attribute allows you to identify your own functions
2599 that take format strings as arguments, so that GCC can check the
2600 calls to these functions for errors. The compiler always (unless
2601 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2602 for the standard library functions @code{printf}, @code{fprintf},
2603 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2604 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2605 warnings are requested (using @option{-Wformat}), so there is no need to
2606 modify the header file @file{stdio.h}. In C99 mode, the functions
2607 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2608 @code{vsscanf} are also checked. Except in strictly conforming C
2609 standard modes, the X/Open function @code{strfmon} is also checked as
2610 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2611 @xref{C Dialect Options,,Options Controlling C Dialect}.
2612
2613 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2614 recognized in the same context. Declarations including these format attributes
2615 are parsed for correct syntax, however the result of checking of such format
2616 strings is not yet defined, and is not carried out by this version of the
2617 compiler.
2618
2619 The target may also provide additional types of format checks.
2620 @xref{Target Format Checks,,Format Checks Specific to Particular
2621 Target Machines}.
2622
2623 @item format_arg (@var{string-index})
2624 @cindex @code{format_arg} function attribute
2625 @opindex Wformat-nonliteral
2626 The @code{format_arg} attribute specifies that a function takes a format
2627 string for a @code{printf}, @code{scanf}, @code{strftime} or
2628 @code{strfmon} style function and modifies it (for example, to translate
2629 it into another language), so the result can be passed to a
2630 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2631 function (with the remaining arguments to the format function the same
2632 as they would have been for the unmodified string). For example, the
2633 declaration:
2634
2635 @smallexample
2636 extern char *
2637 my_dgettext (char *my_domain, const char *my_format)
2638 __attribute__ ((format_arg (2)));
2639 @end smallexample
2640
2641 @noindent
2642 causes the compiler to check the arguments in calls to a @code{printf},
2643 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2644 format string argument is a call to the @code{my_dgettext} function, for
2645 consistency with the format string argument @code{my_format}. If the
2646 @code{format_arg} attribute had not been specified, all the compiler
2647 could tell in such calls to format functions would be that the format
2648 string argument is not constant; this would generate a warning when
2649 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2650 without the attribute.
2651
2652 The parameter @var{string-index} specifies which argument is the format
2653 string argument (starting from one). Since non-static C++ methods have
2654 an implicit @code{this} argument, the arguments of such methods should
2655 be counted from two.
2656
2657 The @code{format_arg} attribute allows you to identify your own
2658 functions that modify format strings, so that GCC can check the
2659 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2660 type function whose operands are a call to one of your own function.
2661 The compiler always treats @code{gettext}, @code{dgettext}, and
2662 @code{dcgettext} in this manner except when strict ISO C support is
2663 requested by @option{-ansi} or an appropriate @option{-std} option, or
2664 @option{-ffreestanding} or @option{-fno-builtin}
2665 is used. @xref{C Dialect Options,,Options
2666 Controlling C Dialect}.
2667
2668 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2669 @code{NSString} reference for compatibility with the @code{format} attribute
2670 above.
2671
2672 The target may also allow additional types in @code{format-arg} attributes.
2673 @xref{Target Format Checks,,Format Checks Specific to Particular
2674 Target Machines}.
2675
2676 @item gnu_inline
2677 @cindex @code{gnu_inline} function attribute
2678 This attribute should be used with a function that is also declared
2679 with the @code{inline} keyword. It directs GCC to treat the function
2680 as if it were defined in gnu90 mode even when compiling in C99 or
2681 gnu99 mode.
2682
2683 If the function is declared @code{extern}, then this definition of the
2684 function is used only for inlining. In no case is the function
2685 compiled as a standalone function, not even if you take its address
2686 explicitly. Such an address becomes an external reference, as if you
2687 had only declared the function, and had not defined it. This has
2688 almost the effect of a macro. The way to use this is to put a
2689 function definition in a header file with this attribute, and put
2690 another copy of the function, without @code{extern}, in a library
2691 file. The definition in the header file causes most calls to the
2692 function to be inlined. If any uses of the function remain, they
2693 refer to the single copy in the library. Note that the two
2694 definitions of the functions need not be precisely the same, although
2695 if they do not have the same effect your program may behave oddly.
2696
2697 In C, if the function is neither @code{extern} nor @code{static}, then
2698 the function is compiled as a standalone function, as well as being
2699 inlined where possible.
2700
2701 This is how GCC traditionally handled functions declared
2702 @code{inline}. Since ISO C99 specifies a different semantics for
2703 @code{inline}, this function attribute is provided as a transition
2704 measure and as a useful feature in its own right. This attribute is
2705 available in GCC 4.1.3 and later. It is available if either of the
2706 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2707 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2708 Function is As Fast As a Macro}.
2709
2710 In C++, this attribute does not depend on @code{extern} in any way,
2711 but it still requires the @code{inline} keyword to enable its special
2712 behavior.
2713
2714 @item hot
2715 @cindex @code{hot} function attribute
2716 The @code{hot} attribute on a function is used to inform the compiler that
2717 the function is a hot spot of the compiled program. The function is
2718 optimized more aggressively and on many targets it is placed into a special
2719 subsection of the text section so all hot functions appear close together,
2720 improving locality.
2721
2722 When profile feedback is available, via @option{-fprofile-use}, hot functions
2723 are automatically detected and this attribute is ignored.
2724
2725 @item ifunc ("@var{resolver}")
2726 @cindex @code{ifunc} function attribute
2727 @cindex indirect functions
2728 @cindex functions that are dynamically resolved
2729 The @code{ifunc} attribute is used to mark a function as an indirect
2730 function using the STT_GNU_IFUNC symbol type extension to the ELF
2731 standard. This allows the resolution of the symbol value to be
2732 determined dynamically at load time, and an optimized version of the
2733 routine can be selected for the particular processor or other system
2734 characteristics determined then. To use this attribute, first define
2735 the implementation functions available, and a resolver function that
2736 returns a pointer to the selected implementation function. The
2737 implementation functions' declarations must match the API of the
2738 function being implemented, the resolver's declaration is be a
2739 function returning pointer to void function returning void:
2740
2741 @smallexample
2742 void *my_memcpy (void *dst, const void *src, size_t len)
2743 @{
2744 @dots{}
2745 @}
2746
2747 static void (*resolve_memcpy (void)) (void)
2748 @{
2749 return my_memcpy; // we'll just always select this routine
2750 @}
2751 @end smallexample
2752
2753 @noindent
2754 The exported header file declaring the function the user calls would
2755 contain:
2756
2757 @smallexample
2758 extern void *memcpy (void *, const void *, size_t);
2759 @end smallexample
2760
2761 @noindent
2762 allowing the user to call this as a regular function, unaware of the
2763 implementation. Finally, the indirect function needs to be defined in
2764 the same translation unit as the resolver function:
2765
2766 @smallexample
2767 void *memcpy (void *, const void *, size_t)
2768 __attribute__ ((ifunc ("resolve_memcpy")));
2769 @end smallexample
2770
2771 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2772 and GNU C Library version 2.11.1 are required to use this feature.
2773
2774 @item interrupt
2775 @itemx interrupt_handler
2776 Many GCC back ends support attributes to indicate that a function is
2777 an interrupt handler, which tells the compiler to generate function
2778 entry and exit sequences that differ from those from regular
2779 functions. The exact syntax and behavior are target-specific;
2780 refer to the following subsections for details.
2781
2782 @item leaf
2783 @cindex @code{leaf} function attribute
2784 Calls to external functions with this attribute must return to the
2785 current compilation unit only by return or by exception handling. In
2786 particular, a leaf function is not allowed to invoke callback functions
2787 passed to it from the current compilation unit, directly call functions
2788 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2789 might still call functions from other compilation units and thus they
2790 are not necessarily leaf in the sense that they contain no function
2791 calls at all.
2792
2793 The attribute is intended for library functions to improve dataflow
2794 analysis. The compiler takes the hint that any data not escaping the
2795 current compilation unit cannot be used or modified by the leaf
2796 function. For example, the @code{sin} function is a leaf function, but
2797 @code{qsort} is not.
2798
2799 Note that leaf functions might indirectly run a signal handler defined
2800 in the current compilation unit that uses static variables. Similarly,
2801 when lazy symbol resolution is in effect, leaf functions might invoke
2802 indirect functions whose resolver function or implementation function is
2803 defined in the current compilation unit and uses static variables. There
2804 is no standard-compliant way to write such a signal handler, resolver
2805 function, or implementation function, and the best that you can do is to
2806 remove the @code{leaf} attribute or mark all such static variables
2807 @code{volatile}. Lastly, for ELF-based systems that support symbol
2808 interposition, care should be taken that functions defined in the
2809 current compilation unit do not unexpectedly interpose other symbols
2810 based on the defined standards mode and defined feature test macros;
2811 otherwise an inadvertent callback would be added.
2812
2813 The attribute has no effect on functions defined within the current
2814 compilation unit. This is to allow easy merging of multiple compilation
2815 units into one, for example, by using the link-time optimization. For
2816 this reason the attribute is not allowed on types to annotate indirect
2817 calls.
2818
2819 @item malloc
2820 @cindex @code{malloc} function attribute
2821 @cindex functions that behave like malloc
2822 This tells the compiler that a function is @code{malloc}-like, i.e.,
2823 that the pointer @var{P} returned by the function cannot alias any
2824 other pointer valid when the function returns, and moreover no
2825 pointers to valid objects occur in any storage addressed by @var{P}.
2826
2827 Using this attribute can improve optimization. Functions like
2828 @code{malloc} and @code{calloc} have this property because they return
2829 a pointer to uninitialized or zeroed-out storage. However, functions
2830 like @code{realloc} do not have this property, as they can return a
2831 pointer to storage containing pointers.
2832
2833 @item no_icf
2834 @cindex @code{no_icf} function attribute
2835 This function attribute prevents a functions from being merged with another
2836 semantically equivalent function.
2837
2838 @item no_instrument_function
2839 @cindex @code{no_instrument_function} function attribute
2840 @opindex finstrument-functions
2841 If @option{-finstrument-functions} is given, profiling function calls are
2842 generated at entry and exit of most user-compiled functions.
2843 Functions with this attribute are not so instrumented.
2844
2845 @item no_reorder
2846 @cindex @code{no_reorder} function attribute
2847 Do not reorder functions or variables marked @code{no_reorder}
2848 against each other or top level assembler statements the executable.
2849 The actual order in the program will depend on the linker command
2850 line. Static variables marked like this are also not removed.
2851 This has a similar effect
2852 as the @option{-fno-toplevel-reorder} option, but only applies to the
2853 marked symbols.
2854
2855 @item no_sanitize_address
2856 @itemx no_address_safety_analysis
2857 @cindex @code{no_sanitize_address} function attribute
2858 The @code{no_sanitize_address} attribute on functions is used
2859 to inform the compiler that it should not instrument memory accesses
2860 in the function when compiling with the @option{-fsanitize=address} option.
2861 The @code{no_address_safety_analysis} is a deprecated alias of the
2862 @code{no_sanitize_address} attribute, new code should use
2863 @code{no_sanitize_address}.
2864
2865 @item no_sanitize_thread
2866 @cindex @code{no_sanitize_thread} function attribute
2867 The @code{no_sanitize_thread} attribute on functions is used
2868 to inform the compiler that it should not instrument memory accesses
2869 in the function when compiling with the @option{-fsanitize=thread} option.
2870
2871 @item no_sanitize_undefined
2872 @cindex @code{no_sanitize_undefined} function attribute
2873 The @code{no_sanitize_undefined} attribute on functions is used
2874 to inform the compiler that it should not check for undefined behavior
2875 in the function when compiling with the @option{-fsanitize=undefined} option.
2876
2877 @item no_split_stack
2878 @cindex @code{no_split_stack} function attribute
2879 @opindex fsplit-stack
2880 If @option{-fsplit-stack} is given, functions have a small
2881 prologue which decides whether to split the stack. Functions with the
2882 @code{no_split_stack} attribute do not have that prologue, and thus
2883 may run with only a small amount of stack space available.
2884
2885 @item no_stack_limit
2886 @cindex @code{no_stack_limit} function attribute
2887 This attribute locally overrides the @option{-fstack-limit-register}
2888 and @option{-fstack-limit-symbol} command-line options; it has the effect
2889 of disabling stack limit checking in the function it applies to.
2890
2891 @item noclone
2892 @cindex @code{noclone} function attribute
2893 This function attribute prevents a function from being considered for
2894 cloning---a mechanism that produces specialized copies of functions
2895 and which is (currently) performed by interprocedural constant
2896 propagation.
2897
2898 @item noinline
2899 @cindex @code{noinline} function attribute
2900 This function attribute prevents a function from being considered for
2901 inlining.
2902 @c Don't enumerate the optimizations by name here; we try to be
2903 @c future-compatible with this mechanism.
2904 If the function does not have side-effects, there are optimizations
2905 other than inlining that cause function calls to be optimized away,
2906 although the function call is live. To keep such calls from being
2907 optimized away, put
2908 @smallexample
2909 asm ("");
2910 @end smallexample
2911
2912 @noindent
2913 (@pxref{Extended Asm}) in the called function, to serve as a special
2914 side-effect.
2915
2916 @item nonnull (@var{arg-index}, @dots{})
2917 @cindex @code{nonnull} function attribute
2918 @cindex functions with non-null pointer arguments
2919 The @code{nonnull} attribute specifies that some function parameters should
2920 be non-null pointers. For instance, the declaration:
2921
2922 @smallexample
2923 extern void *
2924 my_memcpy (void *dest, const void *src, size_t len)
2925 __attribute__((nonnull (1, 2)));
2926 @end smallexample
2927
2928 @noindent
2929 causes the compiler to check that, in calls to @code{my_memcpy},
2930 arguments @var{dest} and @var{src} are non-null. If the compiler
2931 determines that a null pointer is passed in an argument slot marked
2932 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2933 is issued. The compiler may also choose to make optimizations based
2934 on the knowledge that certain function arguments will never be null.
2935
2936 If no argument index list is given to the @code{nonnull} attribute,
2937 all pointer arguments are marked as non-null. To illustrate, the
2938 following declaration is equivalent to the previous example:
2939
2940 @smallexample
2941 extern void *
2942 my_memcpy (void *dest, const void *src, size_t len)
2943 __attribute__((nonnull));
2944 @end smallexample
2945
2946 @item noplt
2947 @cindex @code{noplt} function attribute
2948 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2949 Calls to functions marked with this attribute in position-independent code
2950 do not use the PLT.
2951
2952 @smallexample
2953 @group
2954 /* Externally defined function foo. */
2955 int foo () __attribute__ ((noplt));
2956
2957 int
2958 main (/* @r{@dots{}} */)
2959 @{
2960 /* @r{@dots{}} */
2961 foo ();
2962 /* @r{@dots{}} */
2963 @}
2964 @end group
2965 @end smallexample
2966
2967 The @code{noplt} attribute on function @code{foo}
2968 tells the compiler to assume that
2969 the function @code{foo} is externally defined and that the call to
2970 @code{foo} must avoid the PLT
2971 in position-independent code.
2972
2973 In position-dependent code, a few targets also convert calls to
2974 functions that are marked to not use the PLT to use the GOT instead.
2975
2976 @item noreturn
2977 @cindex @code{noreturn} function attribute
2978 @cindex functions that never return
2979 A few standard library functions, such as @code{abort} and @code{exit},
2980 cannot return. GCC knows this automatically. Some programs define
2981 their own functions that never return. You can declare them
2982 @code{noreturn} to tell the compiler this fact. For example,
2983
2984 @smallexample
2985 @group
2986 void fatal () __attribute__ ((noreturn));
2987
2988 void
2989 fatal (/* @r{@dots{}} */)
2990 @{
2991 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2992 exit (1);
2993 @}
2994 @end group
2995 @end smallexample
2996
2997 The @code{noreturn} keyword tells the compiler to assume that
2998 @code{fatal} cannot return. It can then optimize without regard to what
2999 would happen if @code{fatal} ever did return. This makes slightly
3000 better code. More importantly, it helps avoid spurious warnings of
3001 uninitialized variables.
3002
3003 The @code{noreturn} keyword does not affect the exceptional path when that
3004 applies: a @code{noreturn}-marked function may still return to the caller
3005 by throwing an exception or calling @code{longjmp}.
3006
3007 Do not assume that registers saved by the calling function are
3008 restored before calling the @code{noreturn} function.
3009
3010 It does not make sense for a @code{noreturn} function to have a return
3011 type other than @code{void}.
3012
3013 @item nothrow
3014 @cindex @code{nothrow} function attribute
3015 The @code{nothrow} attribute is used to inform the compiler that a
3016 function cannot throw an exception. For example, most functions in
3017 the standard C library can be guaranteed not to throw an exception
3018 with the notable exceptions of @code{qsort} and @code{bsearch} that
3019 take function pointer arguments.
3020
3021 @item optimize
3022 @cindex @code{optimize} function attribute
3023 The @code{optimize} attribute is used to specify that a function is to
3024 be compiled with different optimization options than specified on the
3025 command line. Arguments can either be numbers or strings. Numbers
3026 are assumed to be an optimization level. Strings that begin with
3027 @code{O} are assumed to be an optimization option, while other options
3028 are assumed to be used with a @code{-f} prefix. You can also use the
3029 @samp{#pragma GCC optimize} pragma to set the optimization options
3030 that affect more than one function.
3031 @xref{Function Specific Option Pragmas}, for details about the
3032 @samp{#pragma GCC optimize} pragma.
3033
3034 This attribute should be used for debugging purposes only. It is not
3035 suitable in production code.
3036
3037 @item pure
3038 @cindex @code{pure} function attribute
3039 @cindex functions that have no side effects
3040 Many functions have no effects except the return value and their
3041 return value depends only on the parameters and/or global variables.
3042 Such a function can be subject
3043 to common subexpression elimination and loop optimization just as an
3044 arithmetic operator would be. These functions should be declared
3045 with the attribute @code{pure}. For example,
3046
3047 @smallexample
3048 int square (int) __attribute__ ((pure));
3049 @end smallexample
3050
3051 @noindent
3052 says that the hypothetical function @code{square} is safe to call
3053 fewer times than the program says.
3054
3055 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3056 Interesting non-pure functions are functions with infinite loops or those
3057 depending on volatile memory or other system resource, that may change between
3058 two consecutive calls (such as @code{feof} in a multithreading environment).
3059
3060 @item returns_nonnull
3061 @cindex @code{returns_nonnull} function attribute
3062 The @code{returns_nonnull} attribute specifies that the function
3063 return value should be a non-null pointer. For instance, the declaration:
3064
3065 @smallexample
3066 extern void *
3067 mymalloc (size_t len) __attribute__((returns_nonnull));
3068 @end smallexample
3069
3070 @noindent
3071 lets the compiler optimize callers based on the knowledge
3072 that the return value will never be null.
3073
3074 @item returns_twice
3075 @cindex @code{returns_twice} function attribute
3076 @cindex functions that return more than once
3077 The @code{returns_twice} attribute tells the compiler that a function may
3078 return more than one time. The compiler ensures that all registers
3079 are dead before calling such a function and emits a warning about
3080 the variables that may be clobbered after the second return from the
3081 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3082 The @code{longjmp}-like counterpart of such function, if any, might need
3083 to be marked with the @code{noreturn} attribute.
3084
3085 @item section ("@var{section-name}")
3086 @cindex @code{section} function attribute
3087 @cindex functions in arbitrary sections
3088 Normally, the compiler places the code it generates in the @code{text} section.
3089 Sometimes, however, you need additional sections, or you need certain
3090 particular functions to appear in special sections. The @code{section}
3091 attribute specifies that a function lives in a particular section.
3092 For example, the declaration:
3093
3094 @smallexample
3095 extern void foobar (void) __attribute__ ((section ("bar")));
3096 @end smallexample
3097
3098 @noindent
3099 puts the function @code{foobar} in the @code{bar} section.
3100
3101 Some file formats do not support arbitrary sections so the @code{section}
3102 attribute is not available on all platforms.
3103 If you need to map the entire contents of a module to a particular
3104 section, consider using the facilities of the linker instead.
3105
3106 @item sentinel
3107 @cindex @code{sentinel} function attribute
3108 This function attribute ensures that a parameter in a function call is
3109 an explicit @code{NULL}. The attribute is only valid on variadic
3110 functions. By default, the sentinel is located at position zero, the
3111 last parameter of the function call. If an optional integer position
3112 argument P is supplied to the attribute, the sentinel must be located at
3113 position P counting backwards from the end of the argument list.
3114
3115 @smallexample
3116 __attribute__ ((sentinel))
3117 is equivalent to
3118 __attribute__ ((sentinel(0)))
3119 @end smallexample
3120
3121 The attribute is automatically set with a position of 0 for the built-in
3122 functions @code{execl} and @code{execlp}. The built-in function
3123 @code{execle} has the attribute set with a position of 1.
3124
3125 A valid @code{NULL} in this context is defined as zero with any pointer
3126 type. If your system defines the @code{NULL} macro with an integer type
3127 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3128 with a copy that redefines NULL appropriately.
3129
3130 The warnings for missing or incorrect sentinels are enabled with
3131 @option{-Wformat}.
3132
3133 @item simd
3134 @itemx simd("@var{mask}")
3135 @cindex @code{simd} function attribute
3136 This attribute enables creation of one or more function versions that
3137 can process multiple arguments using SIMD instructions from a
3138 single invocation. Specifying this attribute allows compiler to
3139 assume that such versions are available at link time (provided
3140 in the same or another translation unit). Generated versions are
3141 target-dependent and described in the corresponding Vector ABI document. For
3142 x86_64 target this document can be found
3143 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3144
3145 The optional argument @var{mask} may have the value
3146 @code{notinbranch} or @code{inbranch},
3147 and instructs the compiler to generate non-masked or masked
3148 clones correspondingly. By default, all clones are generated.
3149
3150 The attribute should not be used together with Cilk Plus @code{vector}
3151 attribute on the same function.
3152
3153 If the attribute is specified and @code{#pragma omp declare simd} is
3154 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3155 switch is specified, then the attribute is ignored.
3156
3157 @item stack_protect
3158 @cindex @code{stack_protect} function attribute
3159 This attribute adds stack protection code to the function if
3160 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3161 or @option{-fstack-protector-explicit} are set.
3162
3163 @item target (@var{options})
3164 @cindex @code{target} function attribute
3165 Multiple target back ends implement the @code{target} attribute
3166 to specify that a function is to
3167 be compiled with different target options than specified on the
3168 command line. This can be used for instance to have functions
3169 compiled with a different ISA (instruction set architecture) than the
3170 default. You can also use the @samp{#pragma GCC target} pragma to set
3171 more than one function to be compiled with specific target options.
3172 @xref{Function Specific Option Pragmas}, for details about the
3173 @samp{#pragma GCC target} pragma.
3174
3175 For instance, on an x86, you could declare one function with the
3176 @code{target("sse4.1,arch=core2")} attribute and another with
3177 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3178 compiling the first function with @option{-msse4.1} and
3179 @option{-march=core2} options, and the second function with
3180 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3181 to make sure that a function is only invoked on a machine that
3182 supports the particular ISA it is compiled for (for example by using
3183 @code{cpuid} on x86 to determine what feature bits and architecture
3184 family are used).
3185
3186 @smallexample
3187 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3188 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3189 @end smallexample
3190
3191 You can either use multiple
3192 strings separated by commas to specify multiple options,
3193 or separate the options with a comma (@samp{,}) within a single string.
3194
3195 The options supported are specific to each target; refer to @ref{x86
3196 Function Attributes}, @ref{PowerPC Function Attributes},
3197 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3198 for details.
3199
3200 @item target_clones (@var{options})
3201 @cindex @code{target_clones} function attribute
3202 The @code{target_clones} attribute is used to specify that a function
3203 be cloned into multiple versions compiled with different target options
3204 than specified on the command line. The supported options and restrictions
3205 are the same as for @code{target} attribute.
3206
3207 For instance, on an x86, you could compile a function with
3208 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3209 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3210 It also creates a resolver function (see the @code{ifunc} attribute
3211 above) that dynamically selects a clone suitable for current architecture.
3212
3213 @item unused
3214 @cindex @code{unused} function attribute
3215 This attribute, attached to a function, means that the function is meant
3216 to be possibly unused. GCC does not produce a warning for this
3217 function.
3218
3219 @item used
3220 @cindex @code{used} function attribute
3221 This attribute, attached to a function, means that code must be emitted
3222 for the function even if it appears that the function is not referenced.
3223 This is useful, for example, when the function is referenced only in
3224 inline assembly.
3225
3226 When applied to a member function of a C++ class template, the
3227 attribute also means that the function is instantiated if the
3228 class itself is instantiated.
3229
3230 @item visibility ("@var{visibility_type}")
3231 @cindex @code{visibility} function attribute
3232 This attribute affects the linkage of the declaration to which it is attached.
3233 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3234 (@pxref{Common Type Attributes}) as well as functions.
3235
3236 There are four supported @var{visibility_type} values: default,
3237 hidden, protected or internal visibility.
3238
3239 @smallexample
3240 void __attribute__ ((visibility ("protected")))
3241 f () @{ /* @r{Do something.} */; @}
3242 int i __attribute__ ((visibility ("hidden")));
3243 @end smallexample
3244
3245 The possible values of @var{visibility_type} correspond to the
3246 visibility settings in the ELF gABI.
3247
3248 @table @code
3249 @c keep this list of visibilities in alphabetical order.
3250
3251 @item default
3252 Default visibility is the normal case for the object file format.
3253 This value is available for the visibility attribute to override other
3254 options that may change the assumed visibility of entities.
3255
3256 On ELF, default visibility means that the declaration is visible to other
3257 modules and, in shared libraries, means that the declared entity may be
3258 overridden.
3259
3260 On Darwin, default visibility means that the declaration is visible to
3261 other modules.
3262
3263 Default visibility corresponds to ``external linkage'' in the language.
3264
3265 @item hidden
3266 Hidden visibility indicates that the entity declared has a new
3267 form of linkage, which we call ``hidden linkage''. Two
3268 declarations of an object with hidden linkage refer to the same object
3269 if they are in the same shared object.
3270
3271 @item internal
3272 Internal visibility is like hidden visibility, but with additional
3273 processor specific semantics. Unless otherwise specified by the
3274 psABI, GCC defines internal visibility to mean that a function is
3275 @emph{never} called from another module. Compare this with hidden
3276 functions which, while they cannot be referenced directly by other
3277 modules, can be referenced indirectly via function pointers. By
3278 indicating that a function cannot be called from outside the module,
3279 GCC may for instance omit the load of a PIC register since it is known
3280 that the calling function loaded the correct value.
3281
3282 @item protected
3283 Protected visibility is like default visibility except that it
3284 indicates that references within the defining module bind to the
3285 definition in that module. That is, the declared entity cannot be
3286 overridden by another module.
3287
3288 @end table
3289
3290 All visibilities are supported on many, but not all, ELF targets
3291 (supported when the assembler supports the @samp{.visibility}
3292 pseudo-op). Default visibility is supported everywhere. Hidden
3293 visibility is supported on Darwin targets.
3294
3295 The visibility attribute should be applied only to declarations that
3296 would otherwise have external linkage. The attribute should be applied
3297 consistently, so that the same entity should not be declared with
3298 different settings of the attribute.
3299
3300 In C++, the visibility attribute applies to types as well as functions
3301 and objects, because in C++ types have linkage. A class must not have
3302 greater visibility than its non-static data member types and bases,
3303 and class members default to the visibility of their class. Also, a
3304 declaration without explicit visibility is limited to the visibility
3305 of its type.
3306
3307 In C++, you can mark member functions and static member variables of a
3308 class with the visibility attribute. This is useful if you know a
3309 particular method or static member variable should only be used from
3310 one shared object; then you can mark it hidden while the rest of the
3311 class has default visibility. Care must be taken to avoid breaking
3312 the One Definition Rule; for example, it is usually not useful to mark
3313 an inline method as hidden without marking the whole class as hidden.
3314
3315 A C++ namespace declaration can also have the visibility attribute.
3316
3317 @smallexample
3318 namespace nspace1 __attribute__ ((visibility ("protected")))
3319 @{ /* @r{Do something.} */; @}
3320 @end smallexample
3321
3322 This attribute applies only to the particular namespace body, not to
3323 other definitions of the same namespace; it is equivalent to using
3324 @samp{#pragma GCC visibility} before and after the namespace
3325 definition (@pxref{Visibility Pragmas}).
3326
3327 In C++, if a template argument has limited visibility, this
3328 restriction is implicitly propagated to the template instantiation.
3329 Otherwise, template instantiations and specializations default to the
3330 visibility of their template.
3331
3332 If both the template and enclosing class have explicit visibility, the
3333 visibility from the template is used.
3334
3335 @item warn_unused_result
3336 @cindex @code{warn_unused_result} function attribute
3337 The @code{warn_unused_result} attribute causes a warning to be emitted
3338 if a caller of the function with this attribute does not use its
3339 return value. This is useful for functions where not checking
3340 the result is either a security problem or always a bug, such as
3341 @code{realloc}.
3342
3343 @smallexample
3344 int fn () __attribute__ ((warn_unused_result));
3345 int foo ()
3346 @{
3347 if (fn () < 0) return -1;
3348 fn ();
3349 return 0;
3350 @}
3351 @end smallexample
3352
3353 @noindent
3354 results in warning on line 5.
3355
3356 @item weak
3357 @cindex @code{weak} function attribute
3358 The @code{weak} attribute causes the declaration to be emitted as a weak
3359 symbol rather than a global. This is primarily useful in defining
3360 library functions that can be overridden in user code, though it can
3361 also be used with non-function declarations. Weak symbols are supported
3362 for ELF targets, and also for a.out targets when using the GNU assembler
3363 and linker.
3364
3365 @item weakref
3366 @itemx weakref ("@var{target}")
3367 @cindex @code{weakref} function attribute
3368 The @code{weakref} attribute marks a declaration as a weak reference.
3369 Without arguments, it should be accompanied by an @code{alias} attribute
3370 naming the target symbol. Optionally, the @var{target} may be given as
3371 an argument to @code{weakref} itself. In either case, @code{weakref}
3372 implicitly marks the declaration as @code{weak}. Without a
3373 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3374 @code{weakref} is equivalent to @code{weak}.
3375
3376 @smallexample
3377 static int x() __attribute__ ((weakref ("y")));
3378 /* is equivalent to... */
3379 static int x() __attribute__ ((weak, weakref, alias ("y")));
3380 /* and to... */
3381 static int x() __attribute__ ((weakref));
3382 static int x() __attribute__ ((alias ("y")));
3383 @end smallexample
3384
3385 A weak reference is an alias that does not by itself require a
3386 definition to be given for the target symbol. If the target symbol is
3387 only referenced through weak references, then it becomes a @code{weak}
3388 undefined symbol. If it is directly referenced, however, then such
3389 strong references prevail, and a definition is required for the
3390 symbol, not necessarily in the same translation unit.
3391
3392 The effect is equivalent to moving all references to the alias to a
3393 separate translation unit, renaming the alias to the aliased symbol,
3394 declaring it as weak, compiling the two separate translation units and
3395 performing a reloadable link on them.
3396
3397 At present, a declaration to which @code{weakref} is attached can
3398 only be @code{static}.
3399
3400
3401 @end table
3402
3403 @c This is the end of the target-independent attribute table
3404
3405 @node AArch64 Function Attributes
3406 @subsection AArch64 Function Attributes
3407
3408 The following target-specific function attributes are available for the
3409 AArch64 target. For the most part, these options mirror the behavior of
3410 similar command-line options (@pxref{AArch64 Options}), but on a
3411 per-function basis.
3412
3413 @table @code
3414 @item general-regs-only
3415 @cindex @code{general-regs-only} function attribute, AArch64
3416 Indicates that no floating-point or Advanced SIMD registers should be
3417 used when generating code for this function. If the function explicitly
3418 uses floating-point code, then the compiler gives an error. This is
3419 the same behavior as that of the command-line option
3420 @option{-mgeneral-regs-only}.
3421
3422 @item fix-cortex-a53-835769
3423 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3424 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3425 applied to this function. To explicitly disable the workaround for this
3426 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3427 This corresponds to the behavior of the command line options
3428 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3429
3430 @item cmodel=
3431 @cindex @code{cmodel=} function attribute, AArch64
3432 Indicates that code should be generated for a particular code model for
3433 this function. The behavior and permissible arguments are the same as
3434 for the command line option @option{-mcmodel=}.
3435
3436 @item strict-align
3437 @cindex @code{strict-align} function attribute, AArch64
3438 Indicates that the compiler should not assume that unaligned memory references
3439 are handled by the system. The behavior is the same as for the command-line
3440 option @option{-mstrict-align}.
3441
3442 @item omit-leaf-frame-pointer
3443 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3444 Indicates that the frame pointer should be omitted for a leaf function call.
3445 To keep the frame pointer, the inverse attribute
3446 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3447 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3448 and @option{-mno-omit-leaf-frame-pointer}.
3449
3450 @item tls-dialect=
3451 @cindex @code{tls-dialect=} function attribute, AArch64
3452 Specifies the TLS dialect to use for this function. The behavior and
3453 permissible arguments are the same as for the command-line option
3454 @option{-mtls-dialect=}.
3455
3456 @item arch=
3457 @cindex @code{arch=} function attribute, AArch64
3458 Specifies the architecture version and architectural extensions to use
3459 for this function. The behavior and permissible arguments are the same as
3460 for the @option{-march=} command-line option.
3461
3462 @item tune=
3463 @cindex @code{tune=} function attribute, AArch64
3464 Specifies the core for which to tune the performance of this function.
3465 The behavior and permissible arguments are the same as for the @option{-mtune=}
3466 command-line option.
3467
3468 @item cpu=
3469 @cindex @code{cpu=} function attribute, AArch64
3470 Specifies the core for which to tune the performance of this function and also
3471 whose architectural features to use. The behavior and valid arguments are the
3472 same as for the @option{-mcpu=} command-line option.
3473
3474 @end table
3475
3476 The above target attributes can be specified as follows:
3477
3478 @smallexample
3479 __attribute__((target("@var{attr-string}")))
3480 int
3481 f (int a)
3482 @{
3483 return a + 5;
3484 @}
3485 @end smallexample
3486
3487 where @code{@var{attr-string}} is one of the attribute strings specified above.
3488
3489 Additionally, the architectural extension string may be specified on its
3490 own. This can be used to turn on and off particular architectural extensions
3491 without having to specify a particular architecture version or core. Example:
3492
3493 @smallexample
3494 __attribute__((target("+crc+nocrypto")))
3495 int
3496 foo (int a)
3497 @{
3498 return a + 5;
3499 @}
3500 @end smallexample
3501
3502 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3503 extension and disables the @code{crypto} extension for the function @code{foo}
3504 without modifying an existing @option{-march=} or @option{-mcpu} option.
3505
3506 Multiple target function attributes can be specified by separating them with
3507 a comma. For example:
3508 @smallexample
3509 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3510 int
3511 foo (int a)
3512 @{
3513 return a + 5;
3514 @}
3515 @end smallexample
3516
3517 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3518 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3519
3520 @subsubsection Inlining rules
3521 Specifying target attributes on individual functions or performing link-time
3522 optimization across translation units compiled with different target options
3523 can affect function inlining rules:
3524
3525 In particular, a caller function can inline a callee function only if the
3526 architectural features available to the callee are a subset of the features
3527 available to the caller.
3528 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3529 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3530 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3531 because the all the architectural features that function @code{bar} requires
3532 are available to function @code{foo}. Conversely, function @code{bar} cannot
3533 inline function @code{foo}.
3534
3535 Additionally inlining a function compiled with @option{-mstrict-align} into a
3536 function compiled without @code{-mstrict-align} is not allowed.
3537 However, inlining a function compiled without @option{-mstrict-align} into a
3538 function compiled with @option{-mstrict-align} is allowed.
3539
3540 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3541 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3542 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3543 architectural feature rules specified above.
3544
3545 @node ARC Function Attributes
3546 @subsection ARC Function Attributes
3547
3548 These function attributes are supported by the ARC back end:
3549
3550 @table @code
3551 @item interrupt
3552 @cindex @code{interrupt} function attribute, ARC
3553 Use this attribute to indicate
3554 that the specified function is an interrupt handler. The compiler generates
3555 function entry and exit sequences suitable for use in an interrupt handler
3556 when this attribute is present.
3557
3558 On the ARC, you must specify the kind of interrupt to be handled
3559 in a parameter to the interrupt attribute like this:
3560
3561 @smallexample
3562 void f () __attribute__ ((interrupt ("ilink1")));
3563 @end smallexample
3564
3565 Permissible values for this parameter are: @w{@code{ilink1}} and
3566 @w{@code{ilink2}}.
3567
3568 @item long_call
3569 @itemx medium_call
3570 @itemx short_call
3571 @cindex @code{long_call} function attribute, ARC
3572 @cindex @code{medium_call} function attribute, ARC
3573 @cindex @code{short_call} function attribute, ARC
3574 @cindex indirect calls, ARC
3575 These attributes specify how a particular function is called.
3576 These attributes override the
3577 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3578 command-line switches and @code{#pragma long_calls} settings.
3579
3580 For ARC, a function marked with the @code{long_call} attribute is
3581 always called using register-indirect jump-and-link instructions,
3582 thereby enabling the called function to be placed anywhere within the
3583 32-bit address space. A function marked with the @code{medium_call}
3584 attribute will always be close enough to be called with an unconditional
3585 branch-and-link instruction, which has a 25-bit offset from
3586 the call site. A function marked with the @code{short_call}
3587 attribute will always be close enough to be called with a conditional
3588 branch-and-link instruction, which has a 21-bit offset from
3589 the call site.
3590 @end table
3591
3592 @node ARM Function Attributes
3593 @subsection ARM Function Attributes
3594
3595 These function attributes are supported for ARM targets:
3596
3597 @table @code
3598 @item interrupt
3599 @cindex @code{interrupt} function attribute, ARM
3600 Use this attribute to indicate
3601 that the specified function is an interrupt handler. The compiler generates
3602 function entry and exit sequences suitable for use in an interrupt handler
3603 when this attribute is present.
3604
3605 You can specify the kind of interrupt to be handled by
3606 adding an optional parameter to the interrupt attribute like this:
3607
3608 @smallexample
3609 void f () __attribute__ ((interrupt ("IRQ")));
3610 @end smallexample
3611
3612 @noindent
3613 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3614 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3615
3616 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3617 may be called with a word-aligned stack pointer.
3618
3619 @item isr
3620 @cindex @code{isr} function attribute, ARM
3621 Use this attribute on ARM to write Interrupt Service Routines. This is an
3622 alias to the @code{interrupt} attribute above.
3623
3624 @item long_call
3625 @itemx short_call
3626 @cindex @code{long_call} function attribute, ARM
3627 @cindex @code{short_call} function attribute, ARM
3628 @cindex indirect calls, ARM
3629 These attributes specify how a particular function is called.
3630 These attributes override the
3631 @option{-mlong-calls} (@pxref{ARM Options})
3632 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3633 @code{long_call} attribute indicates that the function might be far
3634 away from the call site and require a different (more expensive)
3635 calling sequence. The @code{short_call} attribute always places
3636 the offset to the function from the call site into the @samp{BL}
3637 instruction directly.
3638
3639 @item naked
3640 @cindex @code{naked} function attribute, ARM
3641 This attribute allows the compiler to construct the
3642 requisite function declaration, while allowing the body of the
3643 function to be assembly code. The specified function will not have
3644 prologue/epilogue sequences generated by the compiler. Only basic
3645 @code{asm} statements can safely be included in naked functions
3646 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3647 basic @code{asm} and C code may appear to work, they cannot be
3648 depended upon to work reliably and are not supported.
3649
3650 @item pcs
3651 @cindex @code{pcs} function attribute, ARM
3652
3653 The @code{pcs} attribute can be used to control the calling convention
3654 used for a function on ARM. The attribute takes an argument that specifies
3655 the calling convention to use.
3656
3657 When compiling using the AAPCS ABI (or a variant of it) then valid
3658 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3659 order to use a variant other than @code{"aapcs"} then the compiler must
3660 be permitted to use the appropriate co-processor registers (i.e., the
3661 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3662 For example,
3663
3664 @smallexample
3665 /* Argument passed in r0, and result returned in r0+r1. */
3666 double f2d (float) __attribute__((pcs("aapcs")));
3667 @end smallexample
3668
3669 Variadic functions always use the @code{"aapcs"} calling convention and
3670 the compiler rejects attempts to specify an alternative.
3671
3672 @item target (@var{options})
3673 @cindex @code{target} function attribute
3674 As discussed in @ref{Common Function Attributes}, this attribute
3675 allows specification of target-specific compilation options.
3676
3677 On ARM, the following options are allowed:
3678
3679 @table @samp
3680 @item thumb
3681 @cindex @code{target("thumb")} function attribute, ARM
3682 Force code generation in the Thumb (T16/T32) ISA, depending on the
3683 architecture level.
3684
3685 @item arm
3686 @cindex @code{target("arm")} function attribute, ARM
3687 Force code generation in the ARM (A32) ISA.
3688
3689 Functions from different modes can be inlined in the caller's mode.
3690
3691 @item fpu=
3692 @cindex @code{target("fpu=")} function attribute, ARM
3693 Specifies the fpu for which to tune the performance of this function.
3694 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3695 command-line option.
3696
3697 @end table
3698
3699 @end table
3700
3701 @node AVR Function Attributes
3702 @subsection AVR Function Attributes
3703
3704 These function attributes are supported by the AVR back end:
3705
3706 @table @code
3707 @item interrupt
3708 @cindex @code{interrupt} function attribute, AVR
3709 Use this attribute to indicate
3710 that the specified function is an interrupt handler. The compiler generates
3711 function entry and exit sequences suitable for use in an interrupt handler
3712 when this attribute is present.
3713
3714 On the AVR, the hardware globally disables interrupts when an
3715 interrupt is executed. The first instruction of an interrupt handler
3716 declared with this attribute is a @code{SEI} instruction to
3717 re-enable interrupts. See also the @code{signal} function attribute
3718 that does not insert a @code{SEI} instruction. If both @code{signal} and
3719 @code{interrupt} are specified for the same function, @code{signal}
3720 is silently ignored.
3721
3722 @item naked
3723 @cindex @code{naked} function attribute, AVR
3724 This attribute allows the compiler to construct the
3725 requisite function declaration, while allowing the body of the
3726 function to be assembly code. The specified function will not have
3727 prologue/epilogue sequences generated by the compiler. Only basic
3728 @code{asm} statements can safely be included in naked functions
3729 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3730 basic @code{asm} and C code may appear to work, they cannot be
3731 depended upon to work reliably and are not supported.
3732
3733 @item OS_main
3734 @itemx OS_task
3735 @cindex @code{OS_main} function attribute, AVR
3736 @cindex @code{OS_task} function attribute, AVR
3737 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3738 do not save/restore any call-saved register in their prologue/epilogue.
3739
3740 The @code{OS_main} attribute can be used when there @emph{is
3741 guarantee} that interrupts are disabled at the time when the function
3742 is entered. This saves resources when the stack pointer has to be
3743 changed to set up a frame for local variables.
3744
3745 The @code{OS_task} attribute can be used when there is @emph{no
3746 guarantee} that interrupts are disabled at that time when the function
3747 is entered like for, e@.g@. task functions in a multi-threading operating
3748 system. In that case, changing the stack pointer register is
3749 guarded by save/clear/restore of the global interrupt enable flag.
3750
3751 The differences to the @code{naked} function attribute are:
3752 @itemize @bullet
3753 @item @code{naked} functions do not have a return instruction whereas
3754 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3755 @code{RETI} return instruction.
3756 @item @code{naked} functions do not set up a frame for local variables
3757 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3758 as needed.
3759 @end itemize
3760
3761 @item signal
3762 @cindex @code{signal} function attribute, AVR
3763 Use this attribute on the AVR to indicate that the specified
3764 function is an interrupt handler. The compiler generates function
3765 entry and exit sequences suitable for use in an interrupt handler when this
3766 attribute is present.
3767
3768 See also the @code{interrupt} function attribute.
3769
3770 The AVR hardware globally disables interrupts when an interrupt is executed.
3771 Interrupt handler functions defined with the @code{signal} attribute
3772 do not re-enable interrupts. It is save to enable interrupts in a
3773 @code{signal} handler. This ``save'' only applies to the code
3774 generated by the compiler and not to the IRQ layout of the
3775 application which is responsibility of the application.
3776
3777 If both @code{signal} and @code{interrupt} are specified for the same
3778 function, @code{signal} is silently ignored.
3779 @end table
3780
3781 @node Blackfin Function Attributes
3782 @subsection Blackfin Function Attributes
3783
3784 These function attributes are supported by the Blackfin back end:
3785
3786 @table @code
3787
3788 @item exception_handler
3789 @cindex @code{exception_handler} function attribute
3790 @cindex exception handler functions, Blackfin
3791 Use this attribute on the Blackfin to indicate that the specified function
3792 is an exception handler. The compiler generates function entry and
3793 exit sequences suitable for use in an exception handler when this
3794 attribute is present.
3795
3796 @item interrupt_handler
3797 @cindex @code{interrupt_handler} function attribute, Blackfin
3798 Use this attribute to
3799 indicate that the specified function is an interrupt handler. The compiler
3800 generates function entry and exit sequences suitable for use in an
3801 interrupt handler when this attribute is present.
3802
3803 @item kspisusp
3804 @cindex @code{kspisusp} function attribute, Blackfin
3805 @cindex User stack pointer in interrupts on the Blackfin
3806 When used together with @code{interrupt_handler}, @code{exception_handler}
3807 or @code{nmi_handler}, code is generated to load the stack pointer
3808 from the USP register in the function prologue.
3809
3810 @item l1_text
3811 @cindex @code{l1_text} function attribute, Blackfin
3812 This attribute specifies a function to be placed into L1 Instruction
3813 SRAM@. The function is put into a specific section named @code{.l1.text}.
3814 With @option{-mfdpic}, function calls with a such function as the callee
3815 or caller uses inlined PLT.
3816
3817 @item l2
3818 @cindex @code{l2} function attribute, Blackfin
3819 This attribute specifies a function to be placed into L2
3820 SRAM. The function is put into a specific section named
3821 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3822 an inlined PLT.
3823
3824 @item longcall
3825 @itemx shortcall
3826 @cindex indirect calls, Blackfin
3827 @cindex @code{longcall} function attribute, Blackfin
3828 @cindex @code{shortcall} function attribute, Blackfin
3829 The @code{longcall} attribute
3830 indicates that the function might be far away from the call site and
3831 require a different (more expensive) calling sequence. The
3832 @code{shortcall} attribute indicates that the function is always close
3833 enough for the shorter calling sequence to be used. These attributes
3834 override the @option{-mlongcall} switch.
3835
3836 @item nesting
3837 @cindex @code{nesting} function attribute, Blackfin
3838 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3839 Use this attribute together with @code{interrupt_handler},
3840 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3841 entry code should enable nested interrupts or exceptions.
3842
3843 @item nmi_handler
3844 @cindex @code{nmi_handler} function attribute, Blackfin
3845 @cindex NMI handler functions on the Blackfin processor
3846 Use this attribute on the Blackfin to indicate that the specified function
3847 is an NMI handler. The compiler generates function entry and
3848 exit sequences suitable for use in an NMI handler when this
3849 attribute is present.
3850
3851 @item saveall
3852 @cindex @code{saveall} function attribute, Blackfin
3853 @cindex save all registers on the Blackfin
3854 Use this attribute to indicate that
3855 all registers except the stack pointer should be saved in the prologue
3856 regardless of whether they are used or not.
3857 @end table
3858
3859 @node CR16 Function Attributes
3860 @subsection CR16 Function Attributes
3861
3862 These function attributes are supported by the CR16 back end:
3863
3864 @table @code
3865 @item interrupt
3866 @cindex @code{interrupt} function attribute, CR16
3867 Use this attribute to indicate
3868 that the specified function is an interrupt handler. The compiler generates
3869 function entry and exit sequences suitable for use in an interrupt handler
3870 when this attribute is present.
3871 @end table
3872
3873 @node Epiphany Function Attributes
3874 @subsection Epiphany Function Attributes
3875
3876 These function attributes are supported by the Epiphany back end:
3877
3878 @table @code
3879 @item disinterrupt
3880 @cindex @code{disinterrupt} function attribute, Epiphany
3881 This attribute causes the compiler to emit
3882 instructions to disable interrupts for the duration of the given
3883 function.
3884
3885 @item forwarder_section
3886 @cindex @code{forwarder_section} function attribute, Epiphany
3887 This attribute modifies the behavior of an interrupt handler.
3888 The interrupt handler may be in external memory which cannot be
3889 reached by a branch instruction, so generate a local memory trampoline
3890 to transfer control. The single parameter identifies the section where
3891 the trampoline is placed.
3892
3893 @item interrupt
3894 @cindex @code{interrupt} function attribute, Epiphany
3895 Use this attribute to indicate
3896 that the specified function is an interrupt handler. The compiler generates
3897 function entry and exit sequences suitable for use in an interrupt handler
3898 when this attribute is present. It may also generate
3899 a special section with code to initialize the interrupt vector table.
3900
3901 On Epiphany targets one or more optional parameters can be added like this:
3902
3903 @smallexample
3904 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3905 @end smallexample
3906
3907 Permissible values for these parameters are: @w{@code{reset}},
3908 @w{@code{software_exception}}, @w{@code{page_miss}},
3909 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3910 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3911 Multiple parameters indicate that multiple entries in the interrupt
3912 vector table should be initialized for this function, i.e.@: for each
3913 parameter @w{@var{name}}, a jump to the function is emitted in
3914 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3915 entirely, in which case no interrupt vector table entry is provided.
3916
3917 Note that interrupts are enabled inside the function
3918 unless the @code{disinterrupt} attribute is also specified.
3919
3920 The following examples are all valid uses of these attributes on
3921 Epiphany targets:
3922 @smallexample
3923 void __attribute__ ((interrupt)) universal_handler ();
3924 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3925 void __attribute__ ((interrupt ("dma0, dma1")))
3926 universal_dma_handler ();
3927 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3928 fast_timer_handler ();
3929 void __attribute__ ((interrupt ("dma0, dma1"),
3930 forwarder_section ("tramp")))
3931 external_dma_handler ();
3932 @end smallexample
3933
3934 @item long_call
3935 @itemx short_call
3936 @cindex @code{long_call} function attribute, Epiphany
3937 @cindex @code{short_call} function attribute, Epiphany
3938 @cindex indirect calls, Epiphany
3939 These attributes specify how a particular function is called.
3940 These attributes override the
3941 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3942 command-line switch and @code{#pragma long_calls} settings.
3943 @end table
3944
3945
3946 @node H8/300 Function Attributes
3947 @subsection H8/300 Function Attributes
3948
3949 These function attributes are available for H8/300 targets:
3950
3951 @table @code
3952 @item function_vector
3953 @cindex @code{function_vector} function attribute, H8/300
3954 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3955 that the specified function should be called through the function vector.
3956 Calling a function through the function vector reduces code size; however,
3957 the function vector has a limited size (maximum 128 entries on the H8/300
3958 and 64 entries on the H8/300H and H8S)
3959 and shares space with the interrupt vector.
3960
3961 @item interrupt_handler
3962 @cindex @code{interrupt_handler} function attribute, H8/300
3963 Use this attribute on the H8/300, H8/300H, and H8S to
3964 indicate that the specified function is an interrupt handler. The compiler
3965 generates function entry and exit sequences suitable for use in an
3966 interrupt handler when this attribute is present.
3967
3968 @item saveall
3969 @cindex @code{saveall} function attribute, H8/300
3970 @cindex save all registers on the H8/300, H8/300H, and H8S
3971 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3972 all registers except the stack pointer should be saved in the prologue
3973 regardless of whether they are used or not.
3974 @end table
3975
3976 @node IA-64 Function Attributes
3977 @subsection IA-64 Function Attributes
3978
3979 These function attributes are supported on IA-64 targets:
3980
3981 @table @code
3982 @item syscall_linkage
3983 @cindex @code{syscall_linkage} function attribute, IA-64
3984 This attribute is used to modify the IA-64 calling convention by marking
3985 all input registers as live at all function exits. This makes it possible
3986 to restart a system call after an interrupt without having to save/restore
3987 the input registers. This also prevents kernel data from leaking into
3988 application code.
3989
3990 @item version_id
3991 @cindex @code{version_id} function attribute, IA-64
3992 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3993 symbol to contain a version string, thus allowing for function level
3994 versioning. HP-UX system header files may use function level versioning
3995 for some system calls.
3996
3997 @smallexample
3998 extern int foo () __attribute__((version_id ("20040821")));
3999 @end smallexample
4000
4001 @noindent
4002 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4003 @end table
4004
4005 @node M32C Function Attributes
4006 @subsection M32C Function Attributes
4007
4008 These function attributes are supported by the M32C back end:
4009
4010 @table @code
4011 @item bank_switch
4012 @cindex @code{bank_switch} function attribute, M32C
4013 When added to an interrupt handler with the M32C port, causes the
4014 prologue and epilogue to use bank switching to preserve the registers
4015 rather than saving them on the stack.
4016
4017 @item fast_interrupt
4018 @cindex @code{fast_interrupt} function attribute, M32C
4019 Use this attribute on the M32C port to indicate that the specified
4020 function is a fast interrupt handler. This is just like the
4021 @code{interrupt} attribute, except that @code{freit} is used to return
4022 instead of @code{reit}.
4023
4024 @item function_vector
4025 @cindex @code{function_vector} function attribute, M16C/M32C
4026 On M16C/M32C targets, the @code{function_vector} attribute declares a
4027 special page subroutine call function. Use of this attribute reduces
4028 the code size by 2 bytes for each call generated to the
4029 subroutine. The argument to the attribute is the vector number entry
4030 from the special page vector table which contains the 16 low-order
4031 bits of the subroutine's entry address. Each vector table has special
4032 page number (18 to 255) that is used in @code{jsrs} instructions.
4033 Jump addresses of the routines are generated by adding 0x0F0000 (in
4034 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4035 2-byte addresses set in the vector table. Therefore you need to ensure
4036 that all the special page vector routines should get mapped within the
4037 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4038 (for M32C).
4039
4040 In the following example 2 bytes are saved for each call to
4041 function @code{foo}.
4042
4043 @smallexample
4044 void foo (void) __attribute__((function_vector(0x18)));
4045 void foo (void)
4046 @{
4047 @}
4048
4049 void bar (void)
4050 @{
4051 foo();
4052 @}
4053 @end smallexample
4054
4055 If functions are defined in one file and are called in another file,
4056 then be sure to write this declaration in both files.
4057
4058 This attribute is ignored for R8C target.
4059
4060 @item interrupt
4061 @cindex @code{interrupt} function attribute, M32C
4062 Use this attribute to indicate
4063 that the specified function is an interrupt handler. The compiler generates
4064 function entry and exit sequences suitable for use in an interrupt handler
4065 when this attribute is present.
4066 @end table
4067
4068 @node M32R/D Function Attributes
4069 @subsection M32R/D Function Attributes
4070
4071 These function attributes are supported by the M32R/D back end:
4072
4073 @table @code
4074 @item interrupt
4075 @cindex @code{interrupt} function attribute, M32R/D
4076 Use this attribute to indicate
4077 that the specified function is an interrupt handler. The compiler generates
4078 function entry and exit sequences suitable for use in an interrupt handler
4079 when this attribute is present.
4080
4081 @item model (@var{model-name})
4082 @cindex @code{model} function attribute, M32R/D
4083 @cindex function addressability on the M32R/D
4084
4085 On the M32R/D, use this attribute to set the addressability of an
4086 object, and of the code generated for a function. The identifier
4087 @var{model-name} is one of @code{small}, @code{medium}, or
4088 @code{large}, representing each of the code models.
4089
4090 Small model objects live in the lower 16MB of memory (so that their
4091 addresses can be loaded with the @code{ld24} instruction), and are
4092 callable with the @code{bl} instruction.
4093
4094 Medium model objects may live anywhere in the 32-bit address space (the
4095 compiler generates @code{seth/add3} instructions to load their addresses),
4096 and are callable with the @code{bl} instruction.
4097
4098 Large model objects may live anywhere in the 32-bit address space (the
4099 compiler generates @code{seth/add3} instructions to load their addresses),
4100 and may not be reachable with the @code{bl} instruction (the compiler
4101 generates the much slower @code{seth/add3/jl} instruction sequence).
4102 @end table
4103
4104 @node m68k Function Attributes
4105 @subsection m68k Function Attributes
4106
4107 These function attributes are supported by the m68k back end:
4108
4109 @table @code
4110 @item interrupt
4111 @itemx interrupt_handler
4112 @cindex @code{interrupt} function attribute, m68k
4113 @cindex @code{interrupt_handler} function attribute, m68k
4114 Use this attribute to
4115 indicate that the specified function is an interrupt handler. The compiler
4116 generates function entry and exit sequences suitable for use in an
4117 interrupt handler when this attribute is present. Either name may be used.
4118
4119 @item interrupt_thread
4120 @cindex @code{interrupt_thread} function attribute, fido
4121 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4122 that the specified function is an interrupt handler that is designed
4123 to run as a thread. The compiler omits generate prologue/epilogue
4124 sequences and replaces the return instruction with a @code{sleep}
4125 instruction. This attribute is available only on fido.
4126 @end table
4127
4128 @node MCORE Function Attributes
4129 @subsection MCORE Function Attributes
4130
4131 These function attributes are supported by the MCORE back end:
4132
4133 @table @code
4134 @item naked
4135 @cindex @code{naked} function attribute, MCORE
4136 This attribute allows the compiler to construct the
4137 requisite function declaration, while allowing the body of the
4138 function to be assembly code. The specified function will not have
4139 prologue/epilogue sequences generated by the compiler. Only basic
4140 @code{asm} statements can safely be included in naked functions
4141 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4142 basic @code{asm} and C code may appear to work, they cannot be
4143 depended upon to work reliably and are not supported.
4144 @end table
4145
4146 @node MeP Function Attributes
4147 @subsection MeP Function Attributes
4148
4149 These function attributes are supported by the MeP back end:
4150
4151 @table @code
4152 @item disinterrupt
4153 @cindex @code{disinterrupt} function attribute, MeP
4154 On MeP targets, this attribute causes the compiler to emit
4155 instructions to disable interrupts for the duration of the given
4156 function.
4157
4158 @item interrupt
4159 @cindex @code{interrupt} function attribute, MeP
4160 Use this attribute to indicate
4161 that the specified function is an interrupt handler. The compiler generates
4162 function entry and exit sequences suitable for use in an interrupt handler
4163 when this attribute is present.
4164
4165 @item near
4166 @cindex @code{near} function attribute, MeP
4167 This attribute causes the compiler to assume the called
4168 function is close enough to use the normal calling convention,
4169 overriding the @option{-mtf} command-line option.
4170
4171 @item far
4172 @cindex @code{far} function attribute, MeP
4173 On MeP targets this causes the compiler to use a calling convention
4174 that assumes the called function is too far away for the built-in
4175 addressing modes.
4176
4177 @item vliw
4178 @cindex @code{vliw} function attribute, MeP
4179 The @code{vliw} attribute tells the compiler to emit
4180 instructions in VLIW mode instead of core mode. Note that this
4181 attribute is not allowed unless a VLIW coprocessor has been configured
4182 and enabled through command-line options.
4183 @end table
4184
4185 @node MicroBlaze Function Attributes
4186 @subsection MicroBlaze Function Attributes
4187
4188 These function attributes are supported on MicroBlaze targets:
4189
4190 @table @code
4191 @item save_volatiles
4192 @cindex @code{save_volatiles} function attribute, MicroBlaze
4193 Use this attribute to indicate that the function is
4194 an interrupt handler. All volatile registers (in addition to non-volatile
4195 registers) are saved in the function prologue. If the function is a leaf
4196 function, only volatiles used by the function are saved. A normal function
4197 return is generated instead of a return from interrupt.
4198
4199 @item break_handler
4200 @cindex @code{break_handler} function attribute, MicroBlaze
4201 @cindex break handler functions
4202 Use this attribute to indicate that
4203 the specified function is a break handler. The compiler generates function
4204 entry and exit sequences suitable for use in an break handler when this
4205 attribute is present. The return from @code{break_handler} is done through
4206 the @code{rtbd} instead of @code{rtsd}.
4207
4208 @smallexample
4209 void f () __attribute__ ((break_handler));
4210 @end smallexample
4211
4212 @item interrupt_handler
4213 @itemx fast_interrupt
4214 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4215 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4216 These attributes indicate that the specified function is an interrupt
4217 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4218 used in low-latency interrupt mode, and @code{interrupt_handler} for
4219 interrupts that do not use low-latency handlers. In both cases, GCC
4220 emits appropriate prologue code and generates a return from the handler
4221 using @code{rtid} instead of @code{rtsd}.
4222 @end table
4223
4224 @node Microsoft Windows Function Attributes
4225 @subsection Microsoft Windows Function Attributes
4226
4227 The following attributes are available on Microsoft Windows and Symbian OS
4228 targets.
4229
4230 @table @code
4231 @item dllexport
4232 @cindex @code{dllexport} function attribute
4233 @cindex @code{__declspec(dllexport)}
4234 On Microsoft Windows targets and Symbian OS targets the
4235 @code{dllexport} attribute causes the compiler to provide a global
4236 pointer to a pointer in a DLL, so that it can be referenced with the
4237 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4238 name is formed by combining @code{_imp__} and the function or variable
4239 name.
4240
4241 You can use @code{__declspec(dllexport)} as a synonym for
4242 @code{__attribute__ ((dllexport))} for compatibility with other
4243 compilers.
4244
4245 On systems that support the @code{visibility} attribute, this
4246 attribute also implies ``default'' visibility. It is an error to
4247 explicitly specify any other visibility.
4248
4249 GCC's default behavior is to emit all inline functions with the
4250 @code{dllexport} attribute. Since this can cause object file-size bloat,
4251 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4252 ignore the attribute for inlined functions unless the
4253 @option{-fkeep-inline-functions} flag is used instead.
4254
4255 The attribute is ignored for undefined symbols.
4256
4257 When applied to C++ classes, the attribute marks defined non-inlined
4258 member functions and static data members as exports. Static consts
4259 initialized in-class are not marked unless they are also defined
4260 out-of-class.
4261
4262 For Microsoft Windows targets there are alternative methods for
4263 including the symbol in the DLL's export table such as using a
4264 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4265 the @option{--export-all} linker flag.
4266
4267 @item dllimport
4268 @cindex @code{dllimport} function attribute
4269 @cindex @code{__declspec(dllimport)}
4270 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4271 attribute causes the compiler to reference a function or variable via
4272 a global pointer to a pointer that is set up by the DLL exporting the
4273 symbol. The attribute implies @code{extern}. On Microsoft Windows
4274 targets, the pointer name is formed by combining @code{_imp__} and the
4275 function or variable name.
4276
4277 You can use @code{__declspec(dllimport)} as a synonym for
4278 @code{__attribute__ ((dllimport))} for compatibility with other
4279 compilers.
4280
4281 On systems that support the @code{visibility} attribute, this
4282 attribute also implies ``default'' visibility. It is an error to
4283 explicitly specify any other visibility.
4284
4285 Currently, the attribute is ignored for inlined functions. If the
4286 attribute is applied to a symbol @emph{definition}, an error is reported.
4287 If a symbol previously declared @code{dllimport} is later defined, the
4288 attribute is ignored in subsequent references, and a warning is emitted.
4289 The attribute is also overridden by a subsequent declaration as
4290 @code{dllexport}.
4291
4292 When applied to C++ classes, the attribute marks non-inlined
4293 member functions and static data members as imports. However, the
4294 attribute is ignored for virtual methods to allow creation of vtables
4295 using thunks.
4296
4297 On the SH Symbian OS target the @code{dllimport} attribute also has
4298 another affect---it can cause the vtable and run-time type information
4299 for a class to be exported. This happens when the class has a
4300 dllimported constructor or a non-inline, non-pure virtual function
4301 and, for either of those two conditions, the class also has an inline
4302 constructor or destructor and has a key function that is defined in
4303 the current translation unit.
4304
4305 For Microsoft Windows targets the use of the @code{dllimport}
4306 attribute on functions is not necessary, but provides a small
4307 performance benefit by eliminating a thunk in the DLL@. The use of the
4308 @code{dllimport} attribute on imported variables can be avoided by passing the
4309 @option{--enable-auto-import} switch to the GNU linker. As with
4310 functions, using the attribute for a variable eliminates a thunk in
4311 the DLL@.
4312
4313 One drawback to using this attribute is that a pointer to a
4314 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4315 address. However, a pointer to a @emph{function} with the
4316 @code{dllimport} attribute can be used as a constant initializer; in
4317 this case, the address of a stub function in the import lib is
4318 referenced. On Microsoft Windows targets, the attribute can be disabled
4319 for functions by setting the @option{-mnop-fun-dllimport} flag.
4320 @end table
4321
4322 @node MIPS Function Attributes
4323 @subsection MIPS Function Attributes
4324
4325 These function attributes are supported by the MIPS back end:
4326
4327 @table @code
4328 @item interrupt
4329 @cindex @code{interrupt} function attribute, MIPS
4330 Use this attribute to indicate that the specified function is an interrupt
4331 handler. The compiler generates function entry and exit sequences suitable
4332 for use in an interrupt handler when this attribute is present.
4333 An optional argument is supported for the interrupt attribute which allows
4334 the interrupt mode to be described. By default GCC assumes the external
4335 interrupt controller (EIC) mode is in use, this can be explicitly set using
4336 @code{eic}. When interrupts are non-masked then the requested Interrupt
4337 Priority Level (IPL) is copied to the current IPL which has the effect of only
4338 enabling higher priority interrupts. To use vectored interrupt mode use
4339 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4340 the behavior of the non-masked interrupt support and GCC will arrange to mask
4341 all interrupts from sw0 up to and including the specified interrupt vector.
4342
4343 You can use the following attributes to modify the behavior
4344 of an interrupt handler:
4345 @table @code
4346 @item use_shadow_register_set
4347 @cindex @code{use_shadow_register_set} function attribute, MIPS
4348 Assume that the handler uses a shadow register set, instead of
4349 the main general-purpose registers. An optional argument @code{intstack} is
4350 supported to indicate that the shadow register set contains a valid stack
4351 pointer.
4352
4353 @item keep_interrupts_masked
4354 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4355 Keep interrupts masked for the whole function. Without this attribute,
4356 GCC tries to reenable interrupts for as much of the function as it can.
4357
4358 @item use_debug_exception_return
4359 @cindex @code{use_debug_exception_return} function attribute, MIPS
4360 Return using the @code{deret} instruction. Interrupt handlers that don't
4361 have this attribute return using @code{eret} instead.
4362 @end table
4363
4364 You can use any combination of these attributes, as shown below:
4365 @smallexample
4366 void __attribute__ ((interrupt)) v0 ();
4367 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4368 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4369 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4370 void __attribute__ ((interrupt, use_shadow_register_set,
4371 keep_interrupts_masked)) v4 ();
4372 void __attribute__ ((interrupt, use_shadow_register_set,
4373 use_debug_exception_return)) v5 ();
4374 void __attribute__ ((interrupt, keep_interrupts_masked,
4375 use_debug_exception_return)) v6 ();
4376 void __attribute__ ((interrupt, use_shadow_register_set,
4377 keep_interrupts_masked,
4378 use_debug_exception_return)) v7 ();
4379 void __attribute__ ((interrupt("eic"))) v8 ();
4380 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4381 @end smallexample
4382
4383 @item long_call
4384 @itemx near
4385 @itemx far
4386 @cindex indirect calls, MIPS
4387 @cindex @code{long_call} function attribute, MIPS
4388 @cindex @code{near} function attribute, MIPS
4389 @cindex @code{far} function attribute, MIPS
4390 These attributes specify how a particular function is called on MIPS@.
4391 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4392 command-line switch. The @code{long_call} and @code{far} attributes are
4393 synonyms, and cause the compiler to always call
4394 the function by first loading its address into a register, and then using
4395 the contents of that register. The @code{near} attribute has the opposite
4396 effect; it specifies that non-PIC calls should be made using the more
4397 efficient @code{jal} instruction.
4398
4399 @item mips16
4400 @itemx nomips16
4401 @cindex @code{mips16} function attribute, MIPS
4402 @cindex @code{nomips16} function attribute, MIPS
4403
4404 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4405 function attributes to locally select or turn off MIPS16 code generation.
4406 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4407 while MIPS16 code generation is disabled for functions with the
4408 @code{nomips16} attribute. These attributes override the
4409 @option{-mips16} and @option{-mno-mips16} options on the command line
4410 (@pxref{MIPS Options}).
4411
4412 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4413 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4414 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4415 may interact badly with some GCC extensions such as @code{__builtin_apply}
4416 (@pxref{Constructing Calls}).
4417
4418 @item micromips, MIPS
4419 @itemx nomicromips, MIPS
4420 @cindex @code{micromips} function attribute
4421 @cindex @code{nomicromips} function attribute
4422
4423 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4424 function attributes to locally select or turn off microMIPS code generation.
4425 A function with the @code{micromips} attribute is emitted as microMIPS code,
4426 while microMIPS code generation is disabled for functions with the
4427 @code{nomicromips} attribute. These attributes override the
4428 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4429 (@pxref{MIPS Options}).
4430
4431 When compiling files containing mixed microMIPS and non-microMIPS code, the
4432 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4433 command line,
4434 not that within individual functions. Mixed microMIPS and non-microMIPS code
4435 may interact badly with some GCC extensions such as @code{__builtin_apply}
4436 (@pxref{Constructing Calls}).
4437
4438 @item nocompression
4439 @cindex @code{nocompression} function attribute, MIPS
4440 On MIPS targets, you can use the @code{nocompression} function attribute
4441 to locally turn off MIPS16 and microMIPS code generation. This attribute
4442 overrides the @option{-mips16} and @option{-mmicromips} options on the
4443 command line (@pxref{MIPS Options}).
4444 @end table
4445
4446 @node MSP430 Function Attributes
4447 @subsection MSP430 Function Attributes
4448
4449 These function attributes are supported by the MSP430 back end:
4450
4451 @table @code
4452 @item critical
4453 @cindex @code{critical} function attribute, MSP430
4454 Critical functions disable interrupts upon entry and restore the
4455 previous interrupt state upon exit. Critical functions cannot also
4456 have the @code{naked} or @code{reentrant} attributes. They can have
4457 the @code{interrupt} attribute.
4458
4459 @item interrupt
4460 @cindex @code{interrupt} function attribute, MSP430
4461 Use this attribute to indicate
4462 that the specified function is an interrupt handler. The compiler generates
4463 function entry and exit sequences suitable for use in an interrupt handler
4464 when this attribute is present.
4465
4466 You can provide an argument to the interrupt
4467 attribute which specifies a name or number. If the argument is a
4468 number it indicates the slot in the interrupt vector table (0 - 31) to
4469 which this handler should be assigned. If the argument is a name it
4470 is treated as a symbolic name for the vector slot. These names should
4471 match up with appropriate entries in the linker script. By default
4472 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4473 @code{reset} for vector 31 are recognized.
4474
4475 @item naked
4476 @cindex @code{naked} function attribute, MSP430
4477 This attribute allows the compiler to construct the
4478 requisite function declaration, while allowing the body of the
4479 function to be assembly code. The specified function will not have
4480 prologue/epilogue sequences generated by the compiler. Only basic
4481 @code{asm} statements can safely be included in naked functions
4482 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4483 basic @code{asm} and C code may appear to work, they cannot be
4484 depended upon to work reliably and are not supported.
4485
4486 @item reentrant
4487 @cindex @code{reentrant} function attribute, MSP430
4488 Reentrant functions disable interrupts upon entry and enable them
4489 upon exit. Reentrant functions cannot also have the @code{naked}
4490 or @code{critical} attributes. They can have the @code{interrupt}
4491 attribute.
4492
4493 @item wakeup
4494 @cindex @code{wakeup} function attribute, MSP430
4495 This attribute only applies to interrupt functions. It is silently
4496 ignored if applied to a non-interrupt function. A wakeup interrupt
4497 function will rouse the processor from any low-power state that it
4498 might be in when the function exits.
4499
4500 @item lower
4501 @itemx upper
4502 @itemx either
4503 @cindex @code{lower} function attribute, MSP430
4504 @cindex @code{upper} function attribute, MSP430
4505 @cindex @code{either} function attribute, MSP430
4506 On the MSP430 target these attributes can be used to specify whether
4507 the function or variable should be placed into low memory, high
4508 memory, or the placement should be left to the linker to decide. The
4509 attributes are only significant if compiling for the MSP430X
4510 architecture.
4511
4512 The attributes work in conjunction with a linker script that has been
4513 augmented to specify where to place sections with a @code{.lower} and
4514 a @code{.upper} prefix. So, for example, as well as placing the
4515 @code{.data} section, the script also specifies the placement of a
4516 @code{.lower.data} and a @code{.upper.data} section. The intention
4517 is that @code{lower} sections are placed into a small but easier to
4518 access memory region and the upper sections are placed into a larger, but
4519 slower to access, region.
4520
4521 The @code{either} attribute is special. It tells the linker to place
4522 the object into the corresponding @code{lower} section if there is
4523 room for it. If there is insufficient room then the object is placed
4524 into the corresponding @code{upper} section instead. Note that the
4525 placement algorithm is not very sophisticated. It does not attempt to
4526 find an optimal packing of the @code{lower} sections. It just makes
4527 one pass over the objects and does the best that it can. Using the
4528 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4529 options can help the packing, however, since they produce smaller,
4530 easier to pack regions.
4531 @end table
4532
4533 @node NDS32 Function Attributes
4534 @subsection NDS32 Function Attributes
4535
4536 These function attributes are supported by the NDS32 back end:
4537
4538 @table @code
4539 @item exception
4540 @cindex @code{exception} function attribute
4541 @cindex exception handler functions, NDS32
4542 Use this attribute on the NDS32 target to indicate that the specified function
4543 is an exception handler. The compiler will generate corresponding sections
4544 for use in an exception handler.
4545
4546 @item interrupt
4547 @cindex @code{interrupt} function attribute, NDS32
4548 On NDS32 target, this attribute indicates that the specified function
4549 is an interrupt handler. The compiler generates corresponding sections
4550 for use in an interrupt handler. You can use the following attributes
4551 to modify the behavior:
4552 @table @code
4553 @item nested
4554 @cindex @code{nested} function attribute, NDS32
4555 This interrupt service routine is interruptible.
4556 @item not_nested
4557 @cindex @code{not_nested} function attribute, NDS32
4558 This interrupt service routine is not interruptible.
4559 @item nested_ready
4560 @cindex @code{nested_ready} function attribute, NDS32
4561 This interrupt service routine is interruptible after @code{PSW.GIE}
4562 (global interrupt enable) is set. This allows interrupt service routine to
4563 finish some short critical code before enabling interrupts.
4564 @item save_all
4565 @cindex @code{save_all} function attribute, NDS32
4566 The system will help save all registers into stack before entering
4567 interrupt handler.
4568 @item partial_save
4569 @cindex @code{partial_save} function attribute, NDS32
4570 The system will help save caller registers into stack before entering
4571 interrupt handler.
4572 @end table
4573
4574 @item naked
4575 @cindex @code{naked} function attribute, NDS32
4576 This attribute allows the compiler to construct the
4577 requisite function declaration, while allowing the body of the
4578 function to be assembly code. The specified function will not have
4579 prologue/epilogue sequences generated by the compiler. Only basic
4580 @code{asm} statements can safely be included in naked functions
4581 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4582 basic @code{asm} and C code may appear to work, they cannot be
4583 depended upon to work reliably and are not supported.
4584
4585 @item reset
4586 @cindex @code{reset} function attribute, NDS32
4587 @cindex reset handler functions
4588 Use this attribute on the NDS32 target to indicate that the specified function
4589 is a reset handler. The compiler will generate corresponding sections
4590 for use in a reset handler. You can use the following attributes
4591 to provide extra exception handling:
4592 @table @code
4593 @item nmi
4594 @cindex @code{nmi} function attribute, NDS32
4595 Provide a user-defined function to handle NMI exception.
4596 @item warm
4597 @cindex @code{warm} function attribute, NDS32
4598 Provide a user-defined function to handle warm reset exception.
4599 @end table
4600 @end table
4601
4602 @node Nios II Function Attributes
4603 @subsection Nios II Function Attributes
4604
4605 These function attributes are supported by the Nios II back end:
4606
4607 @table @code
4608 @item target (@var{options})
4609 @cindex @code{target} function attribute
4610 As discussed in @ref{Common Function Attributes}, this attribute
4611 allows specification of target-specific compilation options.
4612
4613 When compiling for Nios II, the following options are allowed:
4614
4615 @table @samp
4616 @item custom-@var{insn}=@var{N}
4617 @itemx no-custom-@var{insn}
4618 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4619 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4620 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4621 custom instruction with encoding @var{N} when generating code that uses
4622 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4623 the custom instruction @var{insn}.
4624 These target attributes correspond to the
4625 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4626 command-line options, and support the same set of @var{insn} keywords.
4627 @xref{Nios II Options}, for more information.
4628
4629 @item custom-fpu-cfg=@var{name}
4630 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4631 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4632 command-line option, to select a predefined set of custom instructions
4633 named @var{name}.
4634 @xref{Nios II Options}, for more information.
4635 @end table
4636 @end table
4637
4638 @node Nvidia PTX Function Attributes
4639 @subsection Nvidia PTX Function Attributes
4640
4641 These function attributes are supported by the Nvidia PTX back end:
4642
4643 @table @code
4644 @item kernel
4645 @cindex @code{kernel} attribute, Nvidia PTX
4646 This attribute indicates that the corresponding function should be compiled
4647 as a kernel function, which can be invoked from the host via the CUDA RT
4648 library.
4649 By default functions are only callable only from other PTX functions.
4650
4651 Kernel functions must have @code{void} return type.
4652 @end table
4653
4654 @node PowerPC Function Attributes
4655 @subsection PowerPC Function Attributes
4656
4657 These function attributes are supported by the PowerPC back end:
4658
4659 @table @code
4660 @item longcall
4661 @itemx shortcall
4662 @cindex indirect calls, PowerPC
4663 @cindex @code{longcall} function attribute, PowerPC
4664 @cindex @code{shortcall} function attribute, PowerPC
4665 The @code{longcall} attribute
4666 indicates that the function might be far away from the call site and
4667 require a different (more expensive) calling sequence. The
4668 @code{shortcall} attribute indicates that the function is always close
4669 enough for the shorter calling sequence to be used. These attributes
4670 override both the @option{-mlongcall} switch and
4671 the @code{#pragma longcall} setting.
4672
4673 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4674 calls are necessary.
4675
4676 @item target (@var{options})
4677 @cindex @code{target} function attribute
4678 As discussed in @ref{Common Function Attributes}, this attribute
4679 allows specification of target-specific compilation options.
4680
4681 On the PowerPC, the following options are allowed:
4682
4683 @table @samp
4684 @item altivec
4685 @itemx no-altivec
4686 @cindex @code{target("altivec")} function attribute, PowerPC
4687 Generate code that uses (does not use) AltiVec instructions. In
4688 32-bit code, you cannot enable AltiVec instructions unless
4689 @option{-mabi=altivec} is used on the command line.
4690
4691 @item cmpb
4692 @itemx no-cmpb
4693 @cindex @code{target("cmpb")} function attribute, PowerPC
4694 Generate code that uses (does not use) the compare bytes instruction
4695 implemented on the POWER6 processor and other processors that support
4696 the PowerPC V2.05 architecture.
4697
4698 @item dlmzb
4699 @itemx no-dlmzb
4700 @cindex @code{target("dlmzb")} function attribute, PowerPC
4701 Generate code that uses (does not use) the string-search @samp{dlmzb}
4702 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4703 generated by default when targeting those processors.
4704
4705 @item fprnd
4706 @itemx no-fprnd
4707 @cindex @code{target("fprnd")} function attribute, PowerPC
4708 Generate code that uses (does not use) the FP round to integer
4709 instructions implemented on the POWER5+ processor and other processors
4710 that support the PowerPC V2.03 architecture.
4711
4712 @item hard-dfp
4713 @itemx no-hard-dfp
4714 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4715 Generate code that uses (does not use) the decimal floating-point
4716 instructions implemented on some POWER processors.
4717
4718 @item isel
4719 @itemx no-isel
4720 @cindex @code{target("isel")} function attribute, PowerPC
4721 Generate code that uses (does not use) ISEL instruction.
4722
4723 @item mfcrf
4724 @itemx no-mfcrf
4725 @cindex @code{target("mfcrf")} function attribute, PowerPC
4726 Generate code that uses (does not use) the move from condition
4727 register field instruction implemented on the POWER4 processor and
4728 other processors that support the PowerPC V2.01 architecture.
4729
4730 @item mfpgpr
4731 @itemx no-mfpgpr
4732 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4733 Generate code that uses (does not use) the FP move to/from general
4734 purpose register instructions implemented on the POWER6X processor and
4735 other processors that support the extended PowerPC V2.05 architecture.
4736
4737 @item mulhw
4738 @itemx no-mulhw
4739 @cindex @code{target("mulhw")} function attribute, PowerPC
4740 Generate code that uses (does not use) the half-word multiply and
4741 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4742 These instructions are generated by default when targeting those
4743 processors.
4744
4745 @item multiple
4746 @itemx no-multiple
4747 @cindex @code{target("multiple")} function attribute, PowerPC
4748 Generate code that uses (does not use) the load multiple word
4749 instructions and the store multiple word instructions.
4750
4751 @item update
4752 @itemx no-update
4753 @cindex @code{target("update")} function attribute, PowerPC
4754 Generate code that uses (does not use) the load or store instructions
4755 that update the base register to the address of the calculated memory
4756 location.
4757
4758 @item popcntb
4759 @itemx no-popcntb
4760 @cindex @code{target("popcntb")} function attribute, PowerPC
4761 Generate code that uses (does not use) the popcount and double-precision
4762 FP reciprocal estimate instruction implemented on the POWER5
4763 processor and other processors that support the PowerPC V2.02
4764 architecture.
4765
4766 @item popcntd
4767 @itemx no-popcntd
4768 @cindex @code{target("popcntd")} function attribute, PowerPC
4769 Generate code that uses (does not use) the popcount instruction
4770 implemented on the POWER7 processor and other processors that support
4771 the PowerPC V2.06 architecture.
4772
4773 @item powerpc-gfxopt
4774 @itemx no-powerpc-gfxopt
4775 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4776 Generate code that uses (does not use) the optional PowerPC
4777 architecture instructions in the Graphics group, including
4778 floating-point select.
4779
4780 @item powerpc-gpopt
4781 @itemx no-powerpc-gpopt
4782 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4783 Generate code that uses (does not use) the optional PowerPC
4784 architecture instructions in the General Purpose group, including
4785 floating-point square root.
4786
4787 @item recip-precision
4788 @itemx no-recip-precision
4789 @cindex @code{target("recip-precision")} function attribute, PowerPC
4790 Assume (do not assume) that the reciprocal estimate instructions
4791 provide higher-precision estimates than is mandated by the PowerPC
4792 ABI.
4793
4794 @item string
4795 @itemx no-string
4796 @cindex @code{target("string")} function attribute, PowerPC
4797 Generate code that uses (does not use) the load string instructions
4798 and the store string word instructions to save multiple registers and
4799 do small block moves.
4800
4801 @item vsx
4802 @itemx no-vsx
4803 @cindex @code{target("vsx")} function attribute, PowerPC
4804 Generate code that uses (does not use) vector/scalar (VSX)
4805 instructions, and also enable the use of built-in functions that allow
4806 more direct access to the VSX instruction set. In 32-bit code, you
4807 cannot enable VSX or AltiVec instructions unless
4808 @option{-mabi=altivec} is used on the command line.
4809
4810 @item friz
4811 @itemx no-friz
4812 @cindex @code{target("friz")} function attribute, PowerPC
4813 Generate (do not generate) the @code{friz} instruction when the
4814 @option{-funsafe-math-optimizations} option is used to optimize
4815 rounding a floating-point value to 64-bit integer and back to floating
4816 point. The @code{friz} instruction does not return the same value if
4817 the floating-point number is too large to fit in an integer.
4818
4819 @item avoid-indexed-addresses
4820 @itemx no-avoid-indexed-addresses
4821 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4822 Generate code that tries to avoid (not avoid) the use of indexed load
4823 or store instructions.
4824
4825 @item paired
4826 @itemx no-paired
4827 @cindex @code{target("paired")} function attribute, PowerPC
4828 Generate code that uses (does not use) the generation of PAIRED simd
4829 instructions.
4830
4831 @item longcall
4832 @itemx no-longcall
4833 @cindex @code{target("longcall")} function attribute, PowerPC
4834 Generate code that assumes (does not assume) that all calls are far
4835 away so that a longer more expensive calling sequence is required.
4836
4837 @item cpu=@var{CPU}
4838 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4839 Specify the architecture to generate code for when compiling the
4840 function. If you select the @code{target("cpu=power7")} attribute when
4841 generating 32-bit code, VSX and AltiVec instructions are not generated
4842 unless you use the @option{-mabi=altivec} option on the command line.
4843
4844 @item tune=@var{TUNE}
4845 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4846 Specify the architecture to tune for when compiling the function. If
4847 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4848 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4849 compilation tunes for the @var{CPU} architecture, and not the
4850 default tuning specified on the command line.
4851 @end table
4852
4853 On the PowerPC, the inliner does not inline a
4854 function that has different target options than the caller, unless the
4855 callee has a subset of the target options of the caller.
4856 @end table
4857
4858 @node RL78 Function Attributes
4859 @subsection RL78 Function Attributes
4860
4861 These function attributes are supported by the RL78 back end:
4862
4863 @table @code
4864 @item interrupt
4865 @itemx brk_interrupt
4866 @cindex @code{interrupt} function attribute, RL78
4867 @cindex @code{brk_interrupt} function attribute, RL78
4868 These attributes indicate
4869 that the specified function is an interrupt handler. The compiler generates
4870 function entry and exit sequences suitable for use in an interrupt handler
4871 when this attribute is present.
4872
4873 Use @code{brk_interrupt} instead of @code{interrupt} for
4874 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4875 that must end with @code{RETB} instead of @code{RETI}).
4876
4877 @item naked
4878 @cindex @code{naked} function attribute, RL78
4879 This attribute allows the compiler to construct the
4880 requisite function declaration, while allowing the body of the
4881 function to be assembly code. The specified function will not have
4882 prologue/epilogue sequences generated by the compiler. Only basic
4883 @code{asm} statements can safely be included in naked functions
4884 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4885 basic @code{asm} and C code may appear to work, they cannot be
4886 depended upon to work reliably and are not supported.
4887 @end table
4888
4889 @node RX Function Attributes
4890 @subsection RX Function Attributes
4891
4892 These function attributes are supported by the RX back end:
4893
4894 @table @code
4895 @item fast_interrupt
4896 @cindex @code{fast_interrupt} function attribute, RX
4897 Use this attribute on the RX port to indicate that the specified
4898 function is a fast interrupt handler. This is just like the
4899 @code{interrupt} attribute, except that @code{freit} is used to return
4900 instead of @code{reit}.
4901
4902 @item interrupt
4903 @cindex @code{interrupt} function attribute, RX
4904 Use this attribute to indicate
4905 that the specified function is an interrupt handler. The compiler generates
4906 function entry and exit sequences suitable for use in an interrupt handler
4907 when this attribute is present.
4908
4909 On RX targets, you may specify one or more vector numbers as arguments
4910 to the attribute, as well as naming an alternate table name.
4911 Parameters are handled sequentially, so one handler can be assigned to
4912 multiple entries in multiple tables. One may also pass the magic
4913 string @code{"$default"} which causes the function to be used for any
4914 unfilled slots in the current table.
4915
4916 This example shows a simple assignment of a function to one vector in
4917 the default table (note that preprocessor macros may be used for
4918 chip-specific symbolic vector names):
4919 @smallexample
4920 void __attribute__ ((interrupt (5))) txd1_handler ();
4921 @end smallexample
4922
4923 This example assigns a function to two slots in the default table
4924 (using preprocessor macros defined elsewhere) and makes it the default
4925 for the @code{dct} table:
4926 @smallexample
4927 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4928 txd1_handler ();
4929 @end smallexample
4930
4931 @item naked
4932 @cindex @code{naked} function attribute, RX
4933 This attribute allows the compiler to construct the
4934 requisite function declaration, while allowing the body of the
4935 function to be assembly code. The specified function will not have
4936 prologue/epilogue sequences generated by the compiler. Only basic
4937 @code{asm} statements can safely be included in naked functions
4938 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4939 basic @code{asm} and C code may appear to work, they cannot be
4940 depended upon to work reliably and are not supported.
4941
4942 @item vector
4943 @cindex @code{vector} function attribute, RX
4944 This RX attribute is similar to the @code{interrupt} attribute, including its
4945 parameters, but does not make the function an interrupt-handler type
4946 function (i.e. it retains the normal C function calling ABI). See the
4947 @code{interrupt} attribute for a description of its arguments.
4948 @end table
4949
4950 @node S/390 Function Attributes
4951 @subsection S/390 Function Attributes
4952
4953 These function attributes are supported on the S/390:
4954
4955 @table @code
4956 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4957 @cindex @code{hotpatch} function attribute, S/390
4958
4959 On S/390 System z targets, you can use this function attribute to
4960 make GCC generate a ``hot-patching'' function prologue. If the
4961 @option{-mhotpatch=} command-line option is used at the same time,
4962 the @code{hotpatch} attribute takes precedence. The first of the
4963 two arguments specifies the number of halfwords to be added before
4964 the function label. A second argument can be used to specify the
4965 number of halfwords to be added after the function label. For
4966 both arguments the maximum allowed value is 1000000.
4967
4968 If both arguments are zero, hotpatching is disabled.
4969
4970 @item target (@var{options})
4971 @cindex @code{target} function attribute
4972 As discussed in @ref{Common Function Attributes}, this attribute
4973 allows specification of target-specific compilation options.
4974
4975 On S/390, the following options are supported:
4976
4977 @table @samp
4978 @item arch=
4979 @item tune=
4980 @item stack-guard=
4981 @item stack-size=
4982 @item branch-cost=
4983 @item warn-framesize=
4984 @item backchain
4985 @itemx no-backchain
4986 @item hard-dfp
4987 @itemx no-hard-dfp
4988 @item hard-float
4989 @itemx soft-float
4990 @item htm
4991 @itemx no-htm
4992 @item vx
4993 @itemx no-vx
4994 @item packed-stack
4995 @itemx no-packed-stack
4996 @item small-exec
4997 @itemx no-small-exec
4998 @item mvcle
4999 @itemx no-mvcle
5000 @item warn-dynamicstack
5001 @itemx no-warn-dynamicstack
5002 @end table
5003
5004 The options work exactly like the S/390 specific command line
5005 options (without the prefix @option{-m}) except that they do not
5006 change any feature macros. For example,
5007
5008 @smallexample
5009 @code{target("no-vx")}
5010 @end smallexample
5011
5012 does not undefine the @code{__VEC__} macro.
5013 @end table
5014
5015 @node SH Function Attributes
5016 @subsection SH Function Attributes
5017
5018 These function attributes are supported on the SH family of processors:
5019
5020 @table @code
5021 @item function_vector
5022 @cindex @code{function_vector} function attribute, SH
5023 @cindex calling functions through the function vector on SH2A
5024 On SH2A targets, this attribute declares a function to be called using the
5025 TBR relative addressing mode. The argument to this attribute is the entry
5026 number of the same function in a vector table containing all the TBR
5027 relative addressable functions. For correct operation the TBR must be setup
5028 accordingly to point to the start of the vector table before any functions with
5029 this attribute are invoked. Usually a good place to do the initialization is
5030 the startup routine. The TBR relative vector table can have at max 256 function
5031 entries. The jumps to these functions are generated using a SH2A specific,
5032 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5033 from GNU binutils version 2.7 or later for this attribute to work correctly.
5034
5035 In an application, for a function being called once, this attribute
5036 saves at least 8 bytes of code; and if other successive calls are being
5037 made to the same function, it saves 2 bytes of code per each of these
5038 calls.
5039
5040 @item interrupt_handler
5041 @cindex @code{interrupt_handler} function attribute, SH
5042 Use this attribute to
5043 indicate that the specified function is an interrupt handler. The compiler
5044 generates function entry and exit sequences suitable for use in an
5045 interrupt handler when this attribute is present.
5046
5047 @item nosave_low_regs
5048 @cindex @code{nosave_low_regs} function attribute, SH
5049 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5050 function should not save and restore registers R0..R7. This can be used on SH3*
5051 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5052 interrupt handlers.
5053
5054 @item renesas
5055 @cindex @code{renesas} function attribute, SH
5056 On SH targets this attribute specifies that the function or struct follows the
5057 Renesas ABI.
5058
5059 @item resbank
5060 @cindex @code{resbank} function attribute, SH
5061 On the SH2A target, this attribute enables the high-speed register
5062 saving and restoration using a register bank for @code{interrupt_handler}
5063 routines. Saving to the bank is performed automatically after the CPU
5064 accepts an interrupt that uses a register bank.
5065
5066 The nineteen 32-bit registers comprising general register R0 to R14,
5067 control register GBR, and system registers MACH, MACL, and PR and the
5068 vector table address offset are saved into a register bank. Register
5069 banks are stacked in first-in last-out (FILO) sequence. Restoration
5070 from the bank is executed by issuing a RESBANK instruction.
5071
5072 @item sp_switch
5073 @cindex @code{sp_switch} function attribute, SH
5074 Use this attribute on the SH to indicate an @code{interrupt_handler}
5075 function should switch to an alternate stack. It expects a string
5076 argument that names a global variable holding the address of the
5077 alternate stack.
5078
5079 @smallexample
5080 void *alt_stack;
5081 void f () __attribute__ ((interrupt_handler,
5082 sp_switch ("alt_stack")));
5083 @end smallexample
5084
5085 @item trap_exit
5086 @cindex @code{trap_exit} function attribute, SH
5087 Use this attribute on the SH for an @code{interrupt_handler} to return using
5088 @code{trapa} instead of @code{rte}. This attribute expects an integer
5089 argument specifying the trap number to be used.
5090
5091 @item trapa_handler
5092 @cindex @code{trapa_handler} function attribute, SH
5093 On SH targets this function attribute is similar to @code{interrupt_handler}
5094 but it does not save and restore all registers.
5095 @end table
5096
5097 @node SPU Function Attributes
5098 @subsection SPU Function Attributes
5099
5100 These function attributes are supported by the SPU back end:
5101
5102 @table @code
5103 @item naked
5104 @cindex @code{naked} function attribute, SPU
5105 This attribute allows the compiler to construct the
5106 requisite function declaration, while allowing the body of the
5107 function to be assembly code. The specified function will not have
5108 prologue/epilogue sequences generated by the compiler. Only basic
5109 @code{asm} statements can safely be included in naked functions
5110 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5111 basic @code{asm} and C code may appear to work, they cannot be
5112 depended upon to work reliably and are not supported.
5113 @end table
5114
5115 @node Symbian OS Function Attributes
5116 @subsection Symbian OS Function Attributes
5117
5118 @xref{Microsoft Windows Function Attributes}, for discussion of the
5119 @code{dllexport} and @code{dllimport} attributes.
5120
5121 @node V850 Function Attributes
5122 @subsection V850 Function Attributes
5123
5124 The V850 back end supports these function attributes:
5125
5126 @table @code
5127 @item interrupt
5128 @itemx interrupt_handler
5129 @cindex @code{interrupt} function attribute, V850
5130 @cindex @code{interrupt_handler} function attribute, V850
5131 Use these attributes to indicate
5132 that the specified function is an interrupt handler. The compiler generates
5133 function entry and exit sequences suitable for use in an interrupt handler
5134 when either attribute is present.
5135 @end table
5136
5137 @node Visium Function Attributes
5138 @subsection Visium Function Attributes
5139
5140 These function attributes are supported by the Visium back end:
5141
5142 @table @code
5143 @item interrupt
5144 @cindex @code{interrupt} function attribute, Visium
5145 Use this attribute to indicate
5146 that the specified function is an interrupt handler. The compiler generates
5147 function entry and exit sequences suitable for use in an interrupt handler
5148 when this attribute is present.
5149 @end table
5150
5151 @node x86 Function Attributes
5152 @subsection x86 Function Attributes
5153
5154 These function attributes are supported by the x86 back end:
5155
5156 @table @code
5157 @item cdecl
5158 @cindex @code{cdecl} function attribute, x86-32
5159 @cindex functions that pop the argument stack on x86-32
5160 @opindex mrtd
5161 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5162 assume that the calling function pops off the stack space used to
5163 pass arguments. This is
5164 useful to override the effects of the @option{-mrtd} switch.
5165
5166 @item fastcall
5167 @cindex @code{fastcall} function attribute, x86-32
5168 @cindex functions that pop the argument stack on x86-32
5169 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5170 pass the first argument (if of integral type) in the register ECX and
5171 the second argument (if of integral type) in the register EDX@. Subsequent
5172 and other typed arguments are passed on the stack. The called function
5173 pops the arguments off the stack. If the number of arguments is variable all
5174 arguments are pushed on the stack.
5175
5176 @item thiscall
5177 @cindex @code{thiscall} function attribute, x86-32
5178 @cindex functions that pop the argument stack on x86-32
5179 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5180 pass the first argument (if of integral type) in the register ECX.
5181 Subsequent and other typed arguments are passed on the stack. The called
5182 function pops the arguments off the stack.
5183 If the number of arguments is variable all arguments are pushed on the
5184 stack.
5185 The @code{thiscall} attribute is intended for C++ non-static member functions.
5186 As a GCC extension, this calling convention can be used for C functions
5187 and for static member methods.
5188
5189 @item ms_abi
5190 @itemx sysv_abi
5191 @cindex @code{ms_abi} function attribute, x86
5192 @cindex @code{sysv_abi} function attribute, x86
5193
5194 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5195 to indicate which calling convention should be used for a function. The
5196 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5197 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5198 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5199 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5200
5201 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5202 requires the @option{-maccumulate-outgoing-args} option.
5203
5204 @item callee_pop_aggregate_return (@var{number})
5205 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5206
5207 On x86-32 targets, you can use this attribute to control how
5208 aggregates are returned in memory. If the caller is responsible for
5209 popping the hidden pointer together with the rest of the arguments, specify
5210 @var{number} equal to zero. If callee is responsible for popping the
5211 hidden pointer, specify @var{number} equal to one.
5212
5213 The default x86-32 ABI assumes that the callee pops the
5214 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5215 the compiler assumes that the
5216 caller pops the stack for hidden pointer.
5217
5218 @item ms_hook_prologue
5219 @cindex @code{ms_hook_prologue} function attribute, x86
5220
5221 On 32-bit and 64-bit x86 targets, you can use
5222 this function attribute to make GCC generate the ``hot-patching'' function
5223 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5224 and newer.
5225
5226 @item regparm (@var{number})
5227 @cindex @code{regparm} function attribute, x86
5228 @cindex functions that are passed arguments in registers on x86-32
5229 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5230 pass arguments number one to @var{number} if they are of integral type
5231 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5232 take a variable number of arguments continue to be passed all of their
5233 arguments on the stack.
5234
5235 Beware that on some ELF systems this attribute is unsuitable for
5236 global functions in shared libraries with lazy binding (which is the
5237 default). Lazy binding sends the first call via resolving code in
5238 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5239 per the standard calling conventions. Solaris 8 is affected by this.
5240 Systems with the GNU C Library version 2.1 or higher
5241 and FreeBSD are believed to be
5242 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5243 disabled with the linker or the loader if desired, to avoid the
5244 problem.)
5245
5246 @item sseregparm
5247 @cindex @code{sseregparm} function attribute, x86
5248 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5249 causes the compiler to pass up to 3 floating-point arguments in
5250 SSE registers instead of on the stack. Functions that take a
5251 variable number of arguments continue to pass all of their
5252 floating-point arguments on the stack.
5253
5254 @item force_align_arg_pointer
5255 @cindex @code{force_align_arg_pointer} function attribute, x86
5256 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5257 applied to individual function definitions, generating an alternate
5258 prologue and epilogue that realigns the run-time stack if necessary.
5259 This supports mixing legacy codes that run with a 4-byte aligned stack
5260 with modern codes that keep a 16-byte stack for SSE compatibility.
5261
5262 @item stdcall
5263 @cindex @code{stdcall} function attribute, x86-32
5264 @cindex functions that pop the argument stack on x86-32
5265 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5266 assume that the called function pops off the stack space used to
5267 pass arguments, unless it takes a variable number of arguments.
5268
5269 @item no_caller_saved_registers
5270 @cindex @code{no_caller_saved_registers} function attribute, x86
5271 Use this attribute to indicate that the specified function has no
5272 caller-saved registers. That is, all registers are callee-saved. For
5273 example, this attribute can be used for a function called from an
5274 interrupt handler. The compiler generates proper function entry and
5275 exit sequences to save and restore any modified registers, except for
5276 the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87
5277 states, the GCC option @option{-mgeneral-regs-only} should be used to
5278 compile functions with @code{no_caller_saved_registers} attribute.
5279
5280 @item interrupt
5281 @cindex @code{interrupt} function attribute, x86
5282 Use this attribute to indicate that the specified function is an
5283 interrupt handler or an exception handler (depending on parameters passed
5284 to the function, explained further). The compiler generates function
5285 entry and exit sequences suitable for use in an interrupt handler when
5286 this attribute is present. The @code{IRET} instruction, instead of the
5287 @code{RET} instruction, is used to return from interrupt handlers. All
5288 registers, except for the EFLAGS register which is restored by the
5289 @code{IRET} instruction, are preserved by the compiler. Since GCC
5290 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5291 @option{-mgeneral-regs-only} should be used to compile interrupt and
5292 exception handlers.
5293
5294 Any interruptible-without-stack-switch code must be compiled with
5295 @option{-mno-red-zone} since interrupt handlers can and will, because
5296 of the hardware design, touch the red zone.
5297
5298 An interrupt handler must be declared with a mandatory pointer
5299 argument:
5300
5301 @smallexample
5302 struct interrupt_frame;
5303
5304 __attribute__ ((interrupt))
5305 void
5306 f (struct interrupt_frame *frame)
5307 @{
5308 @}
5309 @end smallexample
5310
5311 @noindent
5312 and you must define @code{struct interrupt_frame} as described in the
5313 processor's manual.
5314
5315 Exception handlers differ from interrupt handlers because the system
5316 pushes an error code on the stack. An exception handler declaration is
5317 similar to that for an interrupt handler, but with a different mandatory
5318 function signature. The compiler arranges to pop the error code off the
5319 stack before the @code{IRET} instruction.
5320
5321 @smallexample
5322 #ifdef __x86_64__
5323 typedef unsigned long long int uword_t;
5324 #else
5325 typedef unsigned int uword_t;
5326 #endif
5327
5328 struct interrupt_frame;
5329
5330 __attribute__ ((interrupt))
5331 void
5332 f (struct interrupt_frame *frame, uword_t error_code)
5333 @{
5334 ...
5335 @}
5336 @end smallexample
5337
5338 Exception handlers should only be used for exceptions that push an error
5339 code; you should use an interrupt handler in other cases. The system
5340 will crash if the wrong kind of handler is used.
5341
5342 @item target (@var{options})
5343 @cindex @code{target} function attribute
5344 As discussed in @ref{Common Function Attributes}, this attribute
5345 allows specification of target-specific compilation options.
5346
5347 On the x86, the following options are allowed:
5348 @table @samp
5349 @item abm
5350 @itemx no-abm
5351 @cindex @code{target("abm")} function attribute, x86
5352 Enable/disable the generation of the advanced bit instructions.
5353
5354 @item aes
5355 @itemx no-aes
5356 @cindex @code{target("aes")} function attribute, x86
5357 Enable/disable the generation of the AES instructions.
5358
5359 @item default
5360 @cindex @code{target("default")} function attribute, x86
5361 @xref{Function Multiversioning}, where it is used to specify the
5362 default function version.
5363
5364 @item mmx
5365 @itemx no-mmx
5366 @cindex @code{target("mmx")} function attribute, x86
5367 Enable/disable the generation of the MMX instructions.
5368
5369 @item pclmul
5370 @itemx no-pclmul
5371 @cindex @code{target("pclmul")} function attribute, x86
5372 Enable/disable the generation of the PCLMUL instructions.
5373
5374 @item popcnt
5375 @itemx no-popcnt
5376 @cindex @code{target("popcnt")} function attribute, x86
5377 Enable/disable the generation of the POPCNT instruction.
5378
5379 @item sse
5380 @itemx no-sse
5381 @cindex @code{target("sse")} function attribute, x86
5382 Enable/disable the generation of the SSE instructions.
5383
5384 @item sse2
5385 @itemx no-sse2
5386 @cindex @code{target("sse2")} function attribute, x86
5387 Enable/disable the generation of the SSE2 instructions.
5388
5389 @item sse3
5390 @itemx no-sse3
5391 @cindex @code{target("sse3")} function attribute, x86
5392 Enable/disable the generation of the SSE3 instructions.
5393
5394 @item sse4
5395 @itemx no-sse4
5396 @cindex @code{target("sse4")} function attribute, x86
5397 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5398 and SSE4.2).
5399
5400 @item sse4.1
5401 @itemx no-sse4.1
5402 @cindex @code{target("sse4.1")} function attribute, x86
5403 Enable/disable the generation of the sse4.1 instructions.
5404
5405 @item sse4.2
5406 @itemx no-sse4.2
5407 @cindex @code{target("sse4.2")} function attribute, x86
5408 Enable/disable the generation of the sse4.2 instructions.
5409
5410 @item sse4a
5411 @itemx no-sse4a
5412 @cindex @code{target("sse4a")} function attribute, x86
5413 Enable/disable the generation of the SSE4A instructions.
5414
5415 @item fma4
5416 @itemx no-fma4
5417 @cindex @code{target("fma4")} function attribute, x86
5418 Enable/disable the generation of the FMA4 instructions.
5419
5420 @item xop
5421 @itemx no-xop
5422 @cindex @code{target("xop")} function attribute, x86
5423 Enable/disable the generation of the XOP instructions.
5424
5425 @item lwp
5426 @itemx no-lwp
5427 @cindex @code{target("lwp")} function attribute, x86
5428 Enable/disable the generation of the LWP instructions.
5429
5430 @item ssse3
5431 @itemx no-ssse3
5432 @cindex @code{target("ssse3")} function attribute, x86
5433 Enable/disable the generation of the SSSE3 instructions.
5434
5435 @item cld
5436 @itemx no-cld
5437 @cindex @code{target("cld")} function attribute, x86
5438 Enable/disable the generation of the CLD before string moves.
5439
5440 @item fancy-math-387
5441 @itemx no-fancy-math-387
5442 @cindex @code{target("fancy-math-387")} function attribute, x86
5443 Enable/disable the generation of the @code{sin}, @code{cos}, and
5444 @code{sqrt} instructions on the 387 floating-point unit.
5445
5446 @item fused-madd
5447 @itemx no-fused-madd
5448 @cindex @code{target("fused-madd")} function attribute, x86
5449 Enable/disable the generation of the fused multiply/add instructions.
5450
5451 @item ieee-fp
5452 @itemx no-ieee-fp
5453 @cindex @code{target("ieee-fp")} function attribute, x86
5454 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5455
5456 @item inline-all-stringops
5457 @itemx no-inline-all-stringops
5458 @cindex @code{target("inline-all-stringops")} function attribute, x86
5459 Enable/disable inlining of string operations.
5460
5461 @item inline-stringops-dynamically
5462 @itemx no-inline-stringops-dynamically
5463 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5464 Enable/disable the generation of the inline code to do small string
5465 operations and calling the library routines for large operations.
5466
5467 @item align-stringops
5468 @itemx no-align-stringops
5469 @cindex @code{target("align-stringops")} function attribute, x86
5470 Do/do not align destination of inlined string operations.
5471
5472 @item recip
5473 @itemx no-recip
5474 @cindex @code{target("recip")} function attribute, x86
5475 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5476 instructions followed an additional Newton-Raphson step instead of
5477 doing a floating-point division.
5478
5479 @item arch=@var{ARCH}
5480 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5481 Specify the architecture to generate code for in compiling the function.
5482
5483 @item tune=@var{TUNE}
5484 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5485 Specify the architecture to tune for in compiling the function.
5486
5487 @item fpmath=@var{FPMATH}
5488 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5489 Specify which floating-point unit to use. You must specify the
5490 @code{target("fpmath=sse,387")} option as
5491 @code{target("fpmath=sse+387")} because the comma would separate
5492 different options.
5493 @end table
5494
5495 On the x86, the inliner does not inline a
5496 function that has different target options than the caller, unless the
5497 callee has a subset of the target options of the caller. For example
5498 a function declared with @code{target("sse3")} can inline a function
5499 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5500 @end table
5501
5502 @node Xstormy16 Function Attributes
5503 @subsection Xstormy16 Function Attributes
5504
5505 These function attributes are supported by the Xstormy16 back end:
5506
5507 @table @code
5508 @item interrupt
5509 @cindex @code{interrupt} function attribute, Xstormy16
5510 Use this attribute to indicate
5511 that the specified function is an interrupt handler. The compiler generates
5512 function entry and exit sequences suitable for use in an interrupt handler
5513 when this attribute is present.
5514 @end table
5515
5516 @node Variable Attributes
5517 @section Specifying Attributes of Variables
5518 @cindex attribute of variables
5519 @cindex variable attributes
5520
5521 The keyword @code{__attribute__} allows you to specify special
5522 attributes of variables or structure fields. This keyword is followed
5523 by an attribute specification inside double parentheses. Some
5524 attributes are currently defined generically for variables.
5525 Other attributes are defined for variables on particular target
5526 systems. Other attributes are available for functions
5527 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5528 enumerators (@pxref{Enumerator Attributes}), and for types
5529 (@pxref{Type Attributes}).
5530 Other front ends might define more attributes
5531 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5532
5533 @xref{Attribute Syntax}, for details of the exact syntax for using
5534 attributes.
5535
5536 @menu
5537 * Common Variable Attributes::
5538 * AVR Variable Attributes::
5539 * Blackfin Variable Attributes::
5540 * H8/300 Variable Attributes::
5541 * IA-64 Variable Attributes::
5542 * M32R/D Variable Attributes::
5543 * MeP Variable Attributes::
5544 * Microsoft Windows Variable Attributes::
5545 * MSP430 Variable Attributes::
5546 * PowerPC Variable Attributes::
5547 * RL78 Variable Attributes::
5548 * SPU Variable Attributes::
5549 * V850 Variable Attributes::
5550 * x86 Variable Attributes::
5551 * Xstormy16 Variable Attributes::
5552 @end menu
5553
5554 @node Common Variable Attributes
5555 @subsection Common Variable Attributes
5556
5557 The following attributes are supported on most targets.
5558
5559 @table @code
5560 @cindex @code{aligned} variable attribute
5561 @item aligned (@var{alignment})
5562 This attribute specifies a minimum alignment for the variable or
5563 structure field, measured in bytes. For example, the declaration:
5564
5565 @smallexample
5566 int x __attribute__ ((aligned (16))) = 0;
5567 @end smallexample
5568
5569 @noindent
5570 causes the compiler to allocate the global variable @code{x} on a
5571 16-byte boundary. On a 68040, this could be used in conjunction with
5572 an @code{asm} expression to access the @code{move16} instruction which
5573 requires 16-byte aligned operands.
5574
5575 You can also specify the alignment of structure fields. For example, to
5576 create a double-word aligned @code{int} pair, you could write:
5577
5578 @smallexample
5579 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5580 @end smallexample
5581
5582 @noindent
5583 This is an alternative to creating a union with a @code{double} member,
5584 which forces the union to be double-word aligned.
5585
5586 As in the preceding examples, you can explicitly specify the alignment
5587 (in bytes) that you wish the compiler to use for a given variable or
5588 structure field. Alternatively, you can leave out the alignment factor
5589 and just ask the compiler to align a variable or field to the
5590 default alignment for the target architecture you are compiling for.
5591 The default alignment is sufficient for all scalar types, but may not be
5592 enough for all vector types on a target that supports vector operations.
5593 The default alignment is fixed for a particular target ABI.
5594
5595 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5596 which is the largest alignment ever used for any data type on the
5597 target machine you are compiling for. For example, you could write:
5598
5599 @smallexample
5600 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5601 @end smallexample
5602
5603 The compiler automatically sets the alignment for the declared
5604 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5605 often make copy operations more efficient, because the compiler can
5606 use whatever instructions copy the biggest chunks of memory when
5607 performing copies to or from the variables or fields that you have
5608 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5609 may change depending on command-line options.
5610
5611 When used on a struct, or struct member, the @code{aligned} attribute can
5612 only increase the alignment; in order to decrease it, the @code{packed}
5613 attribute must be specified as well. When used as part of a typedef, the
5614 @code{aligned} attribute can both increase and decrease alignment, and
5615 specifying the @code{packed} attribute generates a warning.
5616
5617 Note that the effectiveness of @code{aligned} attributes may be limited
5618 by inherent limitations in your linker. On many systems, the linker is
5619 only able to arrange for variables to be aligned up to a certain maximum
5620 alignment. (For some linkers, the maximum supported alignment may
5621 be very very small.) If your linker is only able to align variables
5622 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5623 in an @code{__attribute__} still only provides you with 8-byte
5624 alignment. See your linker documentation for further information.
5625
5626 The @code{aligned} attribute can also be used for functions
5627 (@pxref{Common Function Attributes}.)
5628
5629 @item cleanup (@var{cleanup_function})
5630 @cindex @code{cleanup} variable attribute
5631 The @code{cleanup} attribute runs a function when the variable goes
5632 out of scope. This attribute can only be applied to auto function
5633 scope variables; it may not be applied to parameters or variables
5634 with static storage duration. The function must take one parameter,
5635 a pointer to a type compatible with the variable. The return value
5636 of the function (if any) is ignored.
5637
5638 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5639 is run during the stack unwinding that happens during the
5640 processing of the exception. Note that the @code{cleanup} attribute
5641 does not allow the exception to be caught, only to perform an action.
5642 It is undefined what happens if @var{cleanup_function} does not
5643 return normally.
5644
5645 @item common
5646 @itemx nocommon
5647 @cindex @code{common} variable attribute
5648 @cindex @code{nocommon} variable attribute
5649 @opindex fcommon
5650 @opindex fno-common
5651 The @code{common} attribute requests GCC to place a variable in
5652 ``common'' storage. The @code{nocommon} attribute requests the
5653 opposite---to allocate space for it directly.
5654
5655 These attributes override the default chosen by the
5656 @option{-fno-common} and @option{-fcommon} flags respectively.
5657
5658 @item deprecated
5659 @itemx deprecated (@var{msg})
5660 @cindex @code{deprecated} variable attribute
5661 The @code{deprecated} attribute results in a warning if the variable
5662 is used anywhere in the source file. This is useful when identifying
5663 variables that are expected to be removed in a future version of a
5664 program. The warning also includes the location of the declaration
5665 of the deprecated variable, to enable users to easily find further
5666 information about why the variable is deprecated, or what they should
5667 do instead. Note that the warning only occurs for uses:
5668
5669 @smallexample
5670 extern int old_var __attribute__ ((deprecated));
5671 extern int old_var;
5672 int new_fn () @{ return old_var; @}
5673 @end smallexample
5674
5675 @noindent
5676 results in a warning on line 3 but not line 2. The optional @var{msg}
5677 argument, which must be a string, is printed in the warning if
5678 present.
5679
5680 The @code{deprecated} attribute can also be used for functions and
5681 types (@pxref{Common Function Attributes},
5682 @pxref{Common Type Attributes}).
5683
5684 @item mode (@var{mode})
5685 @cindex @code{mode} variable attribute
5686 This attribute specifies the data type for the declaration---whichever
5687 type corresponds to the mode @var{mode}. This in effect lets you
5688 request an integer or floating-point type according to its width.
5689
5690 You may also specify a mode of @code{byte} or @code{__byte__} to
5691 indicate the mode corresponding to a one-byte integer, @code{word} or
5692 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5693 or @code{__pointer__} for the mode used to represent pointers.
5694
5695 @item packed
5696 @cindex @code{packed} variable attribute
5697 The @code{packed} attribute specifies that a variable or structure field
5698 should have the smallest possible alignment---one byte for a variable,
5699 and one bit for a field, unless you specify a larger value with the
5700 @code{aligned} attribute.
5701
5702 Here is a structure in which the field @code{x} is packed, so that it
5703 immediately follows @code{a}:
5704
5705 @smallexample
5706 struct foo
5707 @{
5708 char a;
5709 int x[2] __attribute__ ((packed));
5710 @};
5711 @end smallexample
5712
5713 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5714 @code{packed} attribute on bit-fields of type @code{char}. This has
5715 been fixed in GCC 4.4 but the change can lead to differences in the
5716 structure layout. See the documentation of
5717 @option{-Wpacked-bitfield-compat} for more information.
5718
5719 @item section ("@var{section-name}")
5720 @cindex @code{section} variable attribute
5721 Normally, the compiler places the objects it generates in sections like
5722 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5723 or you need certain particular variables to appear in special sections,
5724 for example to map to special hardware. The @code{section}
5725 attribute specifies that a variable (or function) lives in a particular
5726 section. For example, this small program uses several specific section names:
5727
5728 @smallexample
5729 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5730 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5731 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5732 int init_data __attribute__ ((section ("INITDATA")));
5733
5734 main()
5735 @{
5736 /* @r{Initialize stack pointer} */
5737 init_sp (stack + sizeof (stack));
5738
5739 /* @r{Initialize initialized data} */
5740 memcpy (&init_data, &data, &edata - &data);
5741
5742 /* @r{Turn on the serial ports} */
5743 init_duart (&a);
5744 init_duart (&b);
5745 @}
5746 @end smallexample
5747
5748 @noindent
5749 Use the @code{section} attribute with
5750 @emph{global} variables and not @emph{local} variables,
5751 as shown in the example.
5752
5753 You may use the @code{section} attribute with initialized or
5754 uninitialized global variables but the linker requires
5755 each object be defined once, with the exception that uninitialized
5756 variables tentatively go in the @code{common} (or @code{bss}) section
5757 and can be multiply ``defined''. Using the @code{section} attribute
5758 changes what section the variable goes into and may cause the
5759 linker to issue an error if an uninitialized variable has multiple
5760 definitions. You can force a variable to be initialized with the
5761 @option{-fno-common} flag or the @code{nocommon} attribute.
5762
5763 Some file formats do not support arbitrary sections so the @code{section}
5764 attribute is not available on all platforms.
5765 If you need to map the entire contents of a module to a particular
5766 section, consider using the facilities of the linker instead.
5767
5768 @item tls_model ("@var{tls_model}")
5769 @cindex @code{tls_model} variable attribute
5770 The @code{tls_model} attribute sets thread-local storage model
5771 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5772 overriding @option{-ftls-model=} command-line switch on a per-variable
5773 basis.
5774 The @var{tls_model} argument should be one of @code{global-dynamic},
5775 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5776
5777 Not all targets support this attribute.
5778
5779 @item unused
5780 @cindex @code{unused} variable attribute
5781 This attribute, attached to a variable, means that the variable is meant
5782 to be possibly unused. GCC does not produce a warning for this
5783 variable.
5784
5785 @item used
5786 @cindex @code{used} variable attribute
5787 This attribute, attached to a variable with static storage, means that
5788 the variable must be emitted even if it appears that the variable is not
5789 referenced.
5790
5791 When applied to a static data member of a C++ class template, the
5792 attribute also means that the member is instantiated if the
5793 class itself is instantiated.
5794
5795 @item vector_size (@var{bytes})
5796 @cindex @code{vector_size} variable attribute
5797 This attribute specifies the vector size for the variable, measured in
5798 bytes. For example, the declaration:
5799
5800 @smallexample
5801 int foo __attribute__ ((vector_size (16)));
5802 @end smallexample
5803
5804 @noindent
5805 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5806 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5807 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5808
5809 This attribute is only applicable to integral and float scalars,
5810 although arrays, pointers, and function return values are allowed in
5811 conjunction with this construct.
5812
5813 Aggregates with this attribute are invalid, even if they are of the same
5814 size as a corresponding scalar. For example, the declaration:
5815
5816 @smallexample
5817 struct S @{ int a; @};
5818 struct S __attribute__ ((vector_size (16))) foo;
5819 @end smallexample
5820
5821 @noindent
5822 is invalid even if the size of the structure is the same as the size of
5823 the @code{int}.
5824
5825 @item visibility ("@var{visibility_type}")
5826 @cindex @code{visibility} variable attribute
5827 This attribute affects the linkage of the declaration to which it is attached.
5828 The @code{visibility} attribute is described in
5829 @ref{Common Function Attributes}.
5830
5831 @item weak
5832 @cindex @code{weak} variable attribute
5833 The @code{weak} attribute is described in
5834 @ref{Common Function Attributes}.
5835
5836 @end table
5837
5838 @node AVR Variable Attributes
5839 @subsection AVR Variable Attributes
5840
5841 @table @code
5842 @item progmem
5843 @cindex @code{progmem} variable attribute, AVR
5844 The @code{progmem} attribute is used on the AVR to place read-only
5845 data in the non-volatile program memory (flash). The @code{progmem}
5846 attribute accomplishes this by putting respective variables into a
5847 section whose name starts with @code{.progmem}.
5848
5849 This attribute works similar to the @code{section} attribute
5850 but adds additional checking. Notice that just like the
5851 @code{section} attribute, @code{progmem} affects the location
5852 of the data but not how this data is accessed.
5853
5854 In order to read data located with the @code{progmem} attribute
5855 (inline) assembler must be used.
5856 @smallexample
5857 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5858 #include <avr/pgmspace.h>
5859
5860 /* Locate var in flash memory */
5861 const int var[2] PROGMEM = @{ 1, 2 @};
5862
5863 int read_var (int i)
5864 @{
5865 /* Access var[] by accessor macro from avr/pgmspace.h */
5866 return (int) pgm_read_word (& var[i]);
5867 @}
5868 @end smallexample
5869
5870 AVR is a Harvard architecture processor and data and read-only data
5871 normally resides in the data memory (RAM).
5872
5873 See also the @ref{AVR Named Address Spaces} section for
5874 an alternate way to locate and access data in flash memory.
5875
5876 @item io
5877 @itemx io (@var{addr})
5878 @cindex @code{io} variable attribute, AVR
5879 Variables with the @code{io} attribute are used to address
5880 memory-mapped peripherals in the io address range.
5881 If an address is specified, the variable
5882 is assigned that address, and the value is interpreted as an
5883 address in the data address space.
5884 Example:
5885
5886 @smallexample
5887 volatile int porta __attribute__((io (0x22)));
5888 @end smallexample
5889
5890 The address specified in the address in the data address range.
5891
5892 Otherwise, the variable it is not assigned an address, but the
5893 compiler will still use in/out instructions where applicable,
5894 assuming some other module assigns an address in the io address range.
5895 Example:
5896
5897 @smallexample
5898 extern volatile int porta __attribute__((io));
5899 @end smallexample
5900
5901 @item io_low
5902 @itemx io_low (@var{addr})
5903 @cindex @code{io_low} variable attribute, AVR
5904 This is like the @code{io} attribute, but additionally it informs the
5905 compiler that the object lies in the lower half of the I/O area,
5906 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5907 instructions.
5908
5909 @item address
5910 @itemx address (@var{addr})
5911 @cindex @code{address} variable attribute, AVR
5912 Variables with the @code{address} attribute are used to address
5913 memory-mapped peripherals that may lie outside the io address range.
5914
5915 @smallexample
5916 volatile int porta __attribute__((address (0x600)));
5917 @end smallexample
5918
5919 @end table
5920
5921 @node Blackfin Variable Attributes
5922 @subsection Blackfin Variable Attributes
5923
5924 Three attributes are currently defined for the Blackfin.
5925
5926 @table @code
5927 @item l1_data
5928 @itemx l1_data_A
5929 @itemx l1_data_B
5930 @cindex @code{l1_data} variable attribute, Blackfin
5931 @cindex @code{l1_data_A} variable attribute, Blackfin
5932 @cindex @code{l1_data_B} variable attribute, Blackfin
5933 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5934 Variables with @code{l1_data} attribute are put into the specific section
5935 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5936 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5937 attribute are put into the specific section named @code{.l1.data.B}.
5938
5939 @item l2
5940 @cindex @code{l2} variable attribute, Blackfin
5941 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5942 Variables with @code{l2} attribute are put into the specific section
5943 named @code{.l2.data}.
5944 @end table
5945
5946 @node H8/300 Variable Attributes
5947 @subsection H8/300 Variable Attributes
5948
5949 These variable attributes are available for H8/300 targets:
5950
5951 @table @code
5952 @item eightbit_data
5953 @cindex @code{eightbit_data} variable attribute, H8/300
5954 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5955 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5956 variable should be placed into the eight-bit data section.
5957 The compiler generates more efficient code for certain operations
5958 on data in the eight-bit data area. Note the eight-bit data area is limited to
5959 256 bytes of data.
5960
5961 You must use GAS and GLD from GNU binutils version 2.7 or later for
5962 this attribute to work correctly.
5963
5964 @item tiny_data
5965 @cindex @code{tiny_data} variable attribute, H8/300
5966 @cindex tiny data section on the H8/300H and H8S
5967 Use this attribute on the H8/300H and H8S to indicate that the specified
5968 variable should be placed into the tiny data section.
5969 The compiler generates more efficient code for loads and stores
5970 on data in the tiny data section. Note the tiny data area is limited to
5971 slightly under 32KB of data.
5972
5973 @end table
5974
5975 @node IA-64 Variable Attributes
5976 @subsection IA-64 Variable Attributes
5977
5978 The IA-64 back end supports the following variable attribute:
5979
5980 @table @code
5981 @item model (@var{model-name})
5982 @cindex @code{model} variable attribute, IA-64
5983
5984 On IA-64, use this attribute to set the addressability of an object.
5985 At present, the only supported identifier for @var{model-name} is
5986 @code{small}, indicating addressability via ``small'' (22-bit)
5987 addresses (so that their addresses can be loaded with the @code{addl}
5988 instruction). Caveat: such addressing is by definition not position
5989 independent and hence this attribute must not be used for objects
5990 defined by shared libraries.
5991
5992 @end table
5993
5994 @node M32R/D Variable Attributes
5995 @subsection M32R/D Variable Attributes
5996
5997 One attribute is currently defined for the M32R/D@.
5998
5999 @table @code
6000 @item model (@var{model-name})
6001 @cindex @code{model-name} variable attribute, M32R/D
6002 @cindex variable addressability on the M32R/D
6003 Use this attribute on the M32R/D to set the addressability of an object.
6004 The identifier @var{model-name} is one of @code{small}, @code{medium},
6005 or @code{large}, representing each of the code models.
6006
6007 Small model objects live in the lower 16MB of memory (so that their
6008 addresses can be loaded with the @code{ld24} instruction).
6009
6010 Medium and large model objects may live anywhere in the 32-bit address space
6011 (the compiler generates @code{seth/add3} instructions to load their
6012 addresses).
6013 @end table
6014
6015 @node MeP Variable Attributes
6016 @subsection MeP Variable Attributes
6017
6018 The MeP target has a number of addressing modes and busses. The
6019 @code{near} space spans the standard memory space's first 16 megabytes
6020 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6021 The @code{based} space is a 128-byte region in the memory space that
6022 is addressed relative to the @code{$tp} register. The @code{tiny}
6023 space is a 65536-byte region relative to the @code{$gp} register. In
6024 addition to these memory regions, the MeP target has a separate 16-bit
6025 control bus which is specified with @code{cb} attributes.
6026
6027 @table @code
6028
6029 @item based
6030 @cindex @code{based} variable attribute, MeP
6031 Any variable with the @code{based} attribute is assigned to the
6032 @code{.based} section, and is accessed with relative to the
6033 @code{$tp} register.
6034
6035 @item tiny
6036 @cindex @code{tiny} variable attribute, MeP
6037 Likewise, the @code{tiny} attribute assigned variables to the
6038 @code{.tiny} section, relative to the @code{$gp} register.
6039
6040 @item near
6041 @cindex @code{near} variable attribute, MeP
6042 Variables with the @code{near} attribute are assumed to have addresses
6043 that fit in a 24-bit addressing mode. This is the default for large
6044 variables (@code{-mtiny=4} is the default) but this attribute can
6045 override @code{-mtiny=} for small variables, or override @code{-ml}.
6046
6047 @item far
6048 @cindex @code{far} variable attribute, MeP
6049 Variables with the @code{far} attribute are addressed using a full
6050 32-bit address. Since this covers the entire memory space, this
6051 allows modules to make no assumptions about where variables might be
6052 stored.
6053
6054 @item io
6055 @cindex @code{io} variable attribute, MeP
6056 @itemx io (@var{addr})
6057 Variables with the @code{io} attribute are used to address
6058 memory-mapped peripherals. If an address is specified, the variable
6059 is assigned that address, else it is not assigned an address (it is
6060 assumed some other module assigns an address). Example:
6061
6062 @smallexample
6063 int timer_count __attribute__((io(0x123)));
6064 @end smallexample
6065
6066 @item cb
6067 @itemx cb (@var{addr})
6068 @cindex @code{cb} variable attribute, MeP
6069 Variables with the @code{cb} attribute are used to access the control
6070 bus, using special instructions. @code{addr} indicates the control bus
6071 address. Example:
6072
6073 @smallexample
6074 int cpu_clock __attribute__((cb(0x123)));
6075 @end smallexample
6076
6077 @end table
6078
6079 @node Microsoft Windows Variable Attributes
6080 @subsection Microsoft Windows Variable Attributes
6081
6082 You can use these attributes on Microsoft Windows targets.
6083 @ref{x86 Variable Attributes} for additional Windows compatibility
6084 attributes available on all x86 targets.
6085
6086 @table @code
6087 @item dllimport
6088 @itemx dllexport
6089 @cindex @code{dllimport} variable attribute
6090 @cindex @code{dllexport} variable attribute
6091 The @code{dllimport} and @code{dllexport} attributes are described in
6092 @ref{Microsoft Windows Function Attributes}.
6093
6094 @item selectany
6095 @cindex @code{selectany} variable attribute
6096 The @code{selectany} attribute causes an initialized global variable to
6097 have link-once semantics. When multiple definitions of the variable are
6098 encountered by the linker, the first is selected and the remainder are
6099 discarded. Following usage by the Microsoft compiler, the linker is told
6100 @emph{not} to warn about size or content differences of the multiple
6101 definitions.
6102
6103 Although the primary usage of this attribute is for POD types, the
6104 attribute can also be applied to global C++ objects that are initialized
6105 by a constructor. In this case, the static initialization and destruction
6106 code for the object is emitted in each translation defining the object,
6107 but the calls to the constructor and destructor are protected by a
6108 link-once guard variable.
6109
6110 The @code{selectany} attribute is only available on Microsoft Windows
6111 targets. You can use @code{__declspec (selectany)} as a synonym for
6112 @code{__attribute__ ((selectany))} for compatibility with other
6113 compilers.
6114
6115 @item shared
6116 @cindex @code{shared} variable attribute
6117 On Microsoft Windows, in addition to putting variable definitions in a named
6118 section, the section can also be shared among all running copies of an
6119 executable or DLL@. For example, this small program defines shared data
6120 by putting it in a named section @code{shared} and marking the section
6121 shareable:
6122
6123 @smallexample
6124 int foo __attribute__((section ("shared"), shared)) = 0;
6125
6126 int
6127 main()
6128 @{
6129 /* @r{Read and write foo. All running
6130 copies see the same value.} */
6131 return 0;
6132 @}
6133 @end smallexample
6134
6135 @noindent
6136 You may only use the @code{shared} attribute along with @code{section}
6137 attribute with a fully-initialized global definition because of the way
6138 linkers work. See @code{section} attribute for more information.
6139
6140 The @code{shared} attribute is only available on Microsoft Windows@.
6141
6142 @end table
6143
6144 @node MSP430 Variable Attributes
6145 @subsection MSP430 Variable Attributes
6146
6147 @table @code
6148 @item noinit
6149 @cindex @code{noinit} variable attribute, MSP430
6150 Any data with the @code{noinit} attribute will not be initialised by
6151 the C runtime startup code, or the program loader. Not initialising
6152 data in this way can reduce program startup times.
6153
6154 @item persistent
6155 @cindex @code{persistent} variable attribute, MSP430
6156 Any variable with the @code{persistent} attribute will not be
6157 initialised by the C runtime startup code. Instead its value will be
6158 set once, when the application is loaded, and then never initialised
6159 again, even if the processor is reset or the program restarts.
6160 Persistent data is intended to be placed into FLASH RAM, where its
6161 value will be retained across resets. The linker script being used to
6162 create the application should ensure that persistent data is correctly
6163 placed.
6164
6165 @item lower
6166 @itemx upper
6167 @itemx either
6168 @cindex @code{lower} variable attribute, MSP430
6169 @cindex @code{upper} variable attribute, MSP430
6170 @cindex @code{either} variable attribute, MSP430
6171 These attributes are the same as the MSP430 function attributes of the
6172 same name (@pxref{MSP430 Function Attributes}).
6173 These attributes can be applied to both functions and variables.
6174 @end table
6175
6176 @node PowerPC Variable Attributes
6177 @subsection PowerPC Variable Attributes
6178
6179 Three attributes currently are defined for PowerPC configurations:
6180 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6181
6182 @cindex @code{ms_struct} variable attribute, PowerPC
6183 @cindex @code{gcc_struct} variable attribute, PowerPC
6184 For full documentation of the struct attributes please see the
6185 documentation in @ref{x86 Variable Attributes}.
6186
6187 @cindex @code{altivec} variable attribute, PowerPC
6188 For documentation of @code{altivec} attribute please see the
6189 documentation in @ref{PowerPC Type Attributes}.
6190
6191 @node RL78 Variable Attributes
6192 @subsection RL78 Variable Attributes
6193
6194 @cindex @code{saddr} variable attribute, RL78
6195 The RL78 back end supports the @code{saddr} variable attribute. This
6196 specifies placement of the corresponding variable in the SADDR area,
6197 which can be accessed more efficiently than the default memory region.
6198
6199 @node SPU Variable Attributes
6200 @subsection SPU Variable Attributes
6201
6202 @cindex @code{spu_vector} variable attribute, SPU
6203 The SPU supports the @code{spu_vector} attribute for variables. For
6204 documentation of this attribute please see the documentation in
6205 @ref{SPU Type Attributes}.
6206
6207 @node V850 Variable Attributes
6208 @subsection V850 Variable Attributes
6209
6210 These variable attributes are supported by the V850 back end:
6211
6212 @table @code
6213
6214 @item sda
6215 @cindex @code{sda} variable attribute, V850
6216 Use this attribute to explicitly place a variable in the small data area,
6217 which can hold up to 64 kilobytes.
6218
6219 @item tda
6220 @cindex @code{tda} variable attribute, V850
6221 Use this attribute to explicitly place a variable in the tiny data area,
6222 which can hold up to 256 bytes in total.
6223
6224 @item zda
6225 @cindex @code{zda} variable attribute, V850
6226 Use this attribute to explicitly place a variable in the first 32 kilobytes
6227 of memory.
6228 @end table
6229
6230 @node x86 Variable Attributes
6231 @subsection x86 Variable Attributes
6232
6233 Two attributes are currently defined for x86 configurations:
6234 @code{ms_struct} and @code{gcc_struct}.
6235
6236 @table @code
6237 @item ms_struct
6238 @itemx gcc_struct
6239 @cindex @code{ms_struct} variable attribute, x86
6240 @cindex @code{gcc_struct} variable attribute, x86
6241
6242 If @code{packed} is used on a structure, or if bit-fields are used,
6243 it may be that the Microsoft ABI lays out the structure differently
6244 than the way GCC normally does. Particularly when moving packed
6245 data between functions compiled with GCC and the native Microsoft compiler
6246 (either via function call or as data in a file), it may be necessary to access
6247 either format.
6248
6249 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6250 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6251 command-line options, respectively;
6252 see @ref{x86 Options}, for details of how structure layout is affected.
6253 @xref{x86 Type Attributes}, for information about the corresponding
6254 attributes on types.
6255
6256 @end table
6257
6258 @node Xstormy16 Variable Attributes
6259 @subsection Xstormy16 Variable Attributes
6260
6261 One attribute is currently defined for xstormy16 configurations:
6262 @code{below100}.
6263
6264 @table @code
6265 @item below100
6266 @cindex @code{below100} variable attribute, Xstormy16
6267
6268 If a variable has the @code{below100} attribute (@code{BELOW100} is
6269 allowed also), GCC places the variable in the first 0x100 bytes of
6270 memory and use special opcodes to access it. Such variables are
6271 placed in either the @code{.bss_below100} section or the
6272 @code{.data_below100} section.
6273
6274 @end table
6275
6276 @node Type Attributes
6277 @section Specifying Attributes of Types
6278 @cindex attribute of types
6279 @cindex type attributes
6280
6281 The keyword @code{__attribute__} allows you to specify special
6282 attributes of types. Some type attributes apply only to @code{struct}
6283 and @code{union} types, while others can apply to any type defined
6284 via a @code{typedef} declaration. Other attributes are defined for
6285 functions (@pxref{Function Attributes}), labels (@pxref{Label
6286 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6287 variables (@pxref{Variable Attributes}).
6288
6289 The @code{__attribute__} keyword is followed by an attribute specification
6290 inside double parentheses.
6291
6292 You may specify type attributes in an enum, struct or union type
6293 declaration or definition by placing them immediately after the
6294 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6295 syntax is to place them just past the closing curly brace of the
6296 definition.
6297
6298 You can also include type attributes in a @code{typedef} declaration.
6299 @xref{Attribute Syntax}, for details of the exact syntax for using
6300 attributes.
6301
6302 @menu
6303 * Common Type Attributes::
6304 * ARM Type Attributes::
6305 * MeP Type Attributes::
6306 * PowerPC Type Attributes::
6307 * SPU Type Attributes::
6308 * x86 Type Attributes::
6309 @end menu
6310
6311 @node Common Type Attributes
6312 @subsection Common Type Attributes
6313
6314 The following type attributes are supported on most targets.
6315
6316 @table @code
6317 @cindex @code{aligned} type attribute
6318 @item aligned (@var{alignment})
6319 This attribute specifies a minimum alignment (in bytes) for variables
6320 of the specified type. For example, the declarations:
6321
6322 @smallexample
6323 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6324 typedef int more_aligned_int __attribute__ ((aligned (8)));
6325 @end smallexample
6326
6327 @noindent
6328 force the compiler to ensure (as far as it can) that each variable whose
6329 type is @code{struct S} or @code{more_aligned_int} is allocated and
6330 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6331 variables of type @code{struct S} aligned to 8-byte boundaries allows
6332 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6333 store) instructions when copying one variable of type @code{struct S} to
6334 another, thus improving run-time efficiency.
6335
6336 Note that the alignment of any given @code{struct} or @code{union} type
6337 is required by the ISO C standard to be at least a perfect multiple of
6338 the lowest common multiple of the alignments of all of the members of
6339 the @code{struct} or @code{union} in question. This means that you @emph{can}
6340 effectively adjust the alignment of a @code{struct} or @code{union}
6341 type by attaching an @code{aligned} attribute to any one of the members
6342 of such a type, but the notation illustrated in the example above is a
6343 more obvious, intuitive, and readable way to request the compiler to
6344 adjust the alignment of an entire @code{struct} or @code{union} type.
6345
6346 As in the preceding example, you can explicitly specify the alignment
6347 (in bytes) that you wish the compiler to use for a given @code{struct}
6348 or @code{union} type. Alternatively, you can leave out the alignment factor
6349 and just ask the compiler to align a type to the maximum
6350 useful alignment for the target machine you are compiling for. For
6351 example, you could write:
6352
6353 @smallexample
6354 struct S @{ short f[3]; @} __attribute__ ((aligned));
6355 @end smallexample
6356
6357 Whenever you leave out the alignment factor in an @code{aligned}
6358 attribute specification, the compiler automatically sets the alignment
6359 for the type to the largest alignment that is ever used for any data
6360 type on the target machine you are compiling for. Doing this can often
6361 make copy operations more efficient, because the compiler can use
6362 whatever instructions copy the biggest chunks of memory when performing
6363 copies to or from the variables that have types that you have aligned
6364 this way.
6365
6366 In the example above, if the size of each @code{short} is 2 bytes, then
6367 the size of the entire @code{struct S} type is 6 bytes. The smallest
6368 power of two that is greater than or equal to that is 8, so the
6369 compiler sets the alignment for the entire @code{struct S} type to 8
6370 bytes.
6371
6372 Note that although you can ask the compiler to select a time-efficient
6373 alignment for a given type and then declare only individual stand-alone
6374 objects of that type, the compiler's ability to select a time-efficient
6375 alignment is primarily useful only when you plan to create arrays of
6376 variables having the relevant (efficiently aligned) type. If you
6377 declare or use arrays of variables of an efficiently-aligned type, then
6378 it is likely that your program also does pointer arithmetic (or
6379 subscripting, which amounts to the same thing) on pointers to the
6380 relevant type, and the code that the compiler generates for these
6381 pointer arithmetic operations is often more efficient for
6382 efficiently-aligned types than for other types.
6383
6384 Note that the effectiveness of @code{aligned} attributes may be limited
6385 by inherent limitations in your linker. On many systems, the linker is
6386 only able to arrange for variables to be aligned up to a certain maximum
6387 alignment. (For some linkers, the maximum supported alignment may
6388 be very very small.) If your linker is only able to align variables
6389 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6390 in an @code{__attribute__} still only provides you with 8-byte
6391 alignment. See your linker documentation for further information.
6392
6393 The @code{aligned} attribute can only increase alignment. Alignment
6394 can be decreased by specifying the @code{packed} attribute. See below.
6395
6396 @item bnd_variable_size
6397 @cindex @code{bnd_variable_size} type attribute
6398 @cindex Pointer Bounds Checker attributes
6399 When applied to a structure field, this attribute tells Pointer
6400 Bounds Checker that the size of this field should not be computed
6401 using static type information. It may be used to mark variably-sized
6402 static array fields placed at the end of a structure.
6403
6404 @smallexample
6405 struct S
6406 @{
6407 int size;
6408 char data[1];
6409 @}
6410 S *p = (S *)malloc (sizeof(S) + 100);
6411 p->data[10] = 0; //Bounds violation
6412 @end smallexample
6413
6414 @noindent
6415 By using an attribute for the field we may avoid unwanted bound
6416 violation checks:
6417
6418 @smallexample
6419 struct S
6420 @{
6421 int size;
6422 char data[1] __attribute__((bnd_variable_size));
6423 @}
6424 S *p = (S *)malloc (sizeof(S) + 100);
6425 p->data[10] = 0; //OK
6426 @end smallexample
6427
6428 @item deprecated
6429 @itemx deprecated (@var{msg})
6430 @cindex @code{deprecated} type attribute
6431 The @code{deprecated} attribute results in a warning if the type
6432 is used anywhere in the source file. This is useful when identifying
6433 types that are expected to be removed in a future version of a program.
6434 If possible, the warning also includes the location of the declaration
6435 of the deprecated type, to enable users to easily find further
6436 information about why the type is deprecated, or what they should do
6437 instead. Note that the warnings only occur for uses and then only
6438 if the type is being applied to an identifier that itself is not being
6439 declared as deprecated.
6440
6441 @smallexample
6442 typedef int T1 __attribute__ ((deprecated));
6443 T1 x;
6444 typedef T1 T2;
6445 T2 y;
6446 typedef T1 T3 __attribute__ ((deprecated));
6447 T3 z __attribute__ ((deprecated));
6448 @end smallexample
6449
6450 @noindent
6451 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6452 warning is issued for line 4 because T2 is not explicitly
6453 deprecated. Line 5 has no warning because T3 is explicitly
6454 deprecated. Similarly for line 6. The optional @var{msg}
6455 argument, which must be a string, is printed in the warning if
6456 present.
6457
6458 The @code{deprecated} attribute can also be used for functions and
6459 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6460
6461 @item designated_init
6462 @cindex @code{designated_init} type attribute
6463 This attribute may only be applied to structure types. It indicates
6464 that any initialization of an object of this type must use designated
6465 initializers rather than positional initializers. The intent of this
6466 attribute is to allow the programmer to indicate that a structure's
6467 layout may change, and that therefore relying on positional
6468 initialization will result in future breakage.
6469
6470 GCC emits warnings based on this attribute by default; use
6471 @option{-Wno-designated-init} to suppress them.
6472
6473 @item may_alias
6474 @cindex @code{may_alias} type attribute
6475 Accesses through pointers to types with this attribute are not subject
6476 to type-based alias analysis, but are instead assumed to be able to alias
6477 any other type of objects.
6478 In the context of section 6.5 paragraph 7 of the C99 standard,
6479 an lvalue expression
6480 dereferencing such a pointer is treated like having a character type.
6481 See @option{-fstrict-aliasing} for more information on aliasing issues.
6482 This extension exists to support some vector APIs, in which pointers to
6483 one vector type are permitted to alias pointers to a different vector type.
6484
6485 Note that an object of a type with this attribute does not have any
6486 special semantics.
6487
6488 Example of use:
6489
6490 @smallexample
6491 typedef short __attribute__((__may_alias__)) short_a;
6492
6493 int
6494 main (void)
6495 @{
6496 int a = 0x12345678;
6497 short_a *b = (short_a *) &a;
6498
6499 b[1] = 0;
6500
6501 if (a == 0x12345678)
6502 abort();
6503
6504 exit(0);
6505 @}
6506 @end smallexample
6507
6508 @noindent
6509 If you replaced @code{short_a} with @code{short} in the variable
6510 declaration, the above program would abort when compiled with
6511 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6512 above.
6513
6514 @item packed
6515 @cindex @code{packed} type attribute
6516 This attribute, attached to @code{struct} or @code{union} type
6517 definition, specifies that each member (other than zero-width bit-fields)
6518 of the structure or union is placed to minimize the memory required. When
6519 attached to an @code{enum} definition, it indicates that the smallest
6520 integral type should be used.
6521
6522 @opindex fshort-enums
6523 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6524 types is equivalent to specifying the @code{packed} attribute on each
6525 of the structure or union members. Specifying the @option{-fshort-enums}
6526 flag on the command line is equivalent to specifying the @code{packed}
6527 attribute on all @code{enum} definitions.
6528
6529 In the following example @code{struct my_packed_struct}'s members are
6530 packed closely together, but the internal layout of its @code{s} member
6531 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6532 be packed too.
6533
6534 @smallexample
6535 struct my_unpacked_struct
6536 @{
6537 char c;
6538 int i;
6539 @};
6540
6541 struct __attribute__ ((__packed__)) my_packed_struct
6542 @{
6543 char c;
6544 int i;
6545 struct my_unpacked_struct s;
6546 @};
6547 @end smallexample
6548
6549 You may only specify the @code{packed} attribute attribute on the definition
6550 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6551 that does not also define the enumerated type, structure or union.
6552
6553 @item scalar_storage_order ("@var{endianness}")
6554 @cindex @code{scalar_storage_order} type attribute
6555 When attached to a @code{union} or a @code{struct}, this attribute sets
6556 the storage order, aka endianness, of the scalar fields of the type, as
6557 well as the array fields whose component is scalar. The supported
6558 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6559 has no effects on fields which are themselves a @code{union}, a @code{struct}
6560 or an array whose component is a @code{union} or a @code{struct}, and it is
6561 possible for these fields to have a different scalar storage order than the
6562 enclosing type.
6563
6564 This attribute is supported only for targets that use a uniform default
6565 scalar storage order (fortunately, most of them), i.e. targets that store
6566 the scalars either all in big-endian or all in little-endian.
6567
6568 Additional restrictions are enforced for types with the reverse scalar
6569 storage order with regard to the scalar storage order of the target:
6570
6571 @itemize
6572 @item Taking the address of a scalar field of a @code{union} or a
6573 @code{struct} with reverse scalar storage order is not permitted and yields
6574 an error.
6575 @item Taking the address of an array field, whose component is scalar, of
6576 a @code{union} or a @code{struct} with reverse scalar storage order is
6577 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6578 is specified.
6579 @item Taking the address of a @code{union} or a @code{struct} with reverse
6580 scalar storage order is permitted.
6581 @end itemize
6582
6583 These restrictions exist because the storage order attribute is lost when
6584 the address of a scalar or the address of an array with scalar component is
6585 taken, so storing indirectly through this address generally does not work.
6586 The second case is nevertheless allowed to be able to perform a block copy
6587 from or to the array.
6588
6589 Moreover, the use of type punning or aliasing to toggle the storage order
6590 is not supported; that is to say, a given scalar object cannot be accessed
6591 through distinct types that assign a different storage order to it.
6592
6593 @item transparent_union
6594 @cindex @code{transparent_union} type attribute
6595
6596 This attribute, attached to a @code{union} type definition, indicates
6597 that any function parameter having that union type causes calls to that
6598 function to be treated in a special way.
6599
6600 First, the argument corresponding to a transparent union type can be of
6601 any type in the union; no cast is required. Also, if the union contains
6602 a pointer type, the corresponding argument can be a null pointer
6603 constant or a void pointer expression; and if the union contains a void
6604 pointer type, the corresponding argument can be any pointer expression.
6605 If the union member type is a pointer, qualifiers like @code{const} on
6606 the referenced type must be respected, just as with normal pointer
6607 conversions.
6608
6609 Second, the argument is passed to the function using the calling
6610 conventions of the first member of the transparent union, not the calling
6611 conventions of the union itself. All members of the union must have the
6612 same machine representation; this is necessary for this argument passing
6613 to work properly.
6614
6615 Transparent unions are designed for library functions that have multiple
6616 interfaces for compatibility reasons. For example, suppose the
6617 @code{wait} function must accept either a value of type @code{int *} to
6618 comply with POSIX, or a value of type @code{union wait *} to comply with
6619 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6620 @code{wait} would accept both kinds of arguments, but it would also
6621 accept any other pointer type and this would make argument type checking
6622 less useful. Instead, @code{<sys/wait.h>} might define the interface
6623 as follows:
6624
6625 @smallexample
6626 typedef union __attribute__ ((__transparent_union__))
6627 @{
6628 int *__ip;
6629 union wait *__up;
6630 @} wait_status_ptr_t;
6631
6632 pid_t wait (wait_status_ptr_t);
6633 @end smallexample
6634
6635 @noindent
6636 This interface allows either @code{int *} or @code{union wait *}
6637 arguments to be passed, using the @code{int *} calling convention.
6638 The program can call @code{wait} with arguments of either type:
6639
6640 @smallexample
6641 int w1 () @{ int w; return wait (&w); @}
6642 int w2 () @{ union wait w; return wait (&w); @}
6643 @end smallexample
6644
6645 @noindent
6646 With this interface, @code{wait}'s implementation might look like this:
6647
6648 @smallexample
6649 pid_t wait (wait_status_ptr_t p)
6650 @{
6651 return waitpid (-1, p.__ip, 0);
6652 @}
6653 @end smallexample
6654
6655 @item unused
6656 @cindex @code{unused} type attribute
6657 When attached to a type (including a @code{union} or a @code{struct}),
6658 this attribute means that variables of that type are meant to appear
6659 possibly unused. GCC does not produce a warning for any variables of
6660 that type, even if the variable appears to do nothing. This is often
6661 the case with lock or thread classes, which are usually defined and then
6662 not referenced, but contain constructors and destructors that have
6663 nontrivial bookkeeping functions.
6664
6665 @item visibility
6666 @cindex @code{visibility} type attribute
6667 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6668 applied to class, struct, union and enum types. Unlike other type
6669 attributes, the attribute must appear between the initial keyword and
6670 the name of the type; it cannot appear after the body of the type.
6671
6672 Note that the type visibility is applied to vague linkage entities
6673 associated with the class (vtable, typeinfo node, etc.). In
6674 particular, if a class is thrown as an exception in one shared object
6675 and caught in another, the class must have default visibility.
6676 Otherwise the two shared objects are unable to use the same
6677 typeinfo node and exception handling will break.
6678
6679 @end table
6680
6681 To specify multiple attributes, separate them by commas within the
6682 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6683 packed))}.
6684
6685 @node ARM Type Attributes
6686 @subsection ARM Type Attributes
6687
6688 @cindex @code{notshared} type attribute, ARM
6689 On those ARM targets that support @code{dllimport} (such as Symbian
6690 OS), you can use the @code{notshared} attribute to indicate that the
6691 virtual table and other similar data for a class should not be
6692 exported from a DLL@. For example:
6693
6694 @smallexample
6695 class __declspec(notshared) C @{
6696 public:
6697 __declspec(dllimport) C();
6698 virtual void f();
6699 @}
6700
6701 __declspec(dllexport)
6702 C::C() @{@}
6703 @end smallexample
6704
6705 @noindent
6706 In this code, @code{C::C} is exported from the current DLL, but the
6707 virtual table for @code{C} is not exported. (You can use
6708 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6709 most Symbian OS code uses @code{__declspec}.)
6710
6711 @node MeP Type Attributes
6712 @subsection MeP Type Attributes
6713
6714 @cindex @code{based} type attribute, MeP
6715 @cindex @code{tiny} type attribute, MeP
6716 @cindex @code{near} type attribute, MeP
6717 @cindex @code{far} type attribute, MeP
6718 Many of the MeP variable attributes may be applied to types as well.
6719 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6720 @code{far} attributes may be applied to either. The @code{io} and
6721 @code{cb} attributes may not be applied to types.
6722
6723 @node PowerPC Type Attributes
6724 @subsection PowerPC Type Attributes
6725
6726 Three attributes currently are defined for PowerPC configurations:
6727 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6728
6729 @cindex @code{ms_struct} type attribute, PowerPC
6730 @cindex @code{gcc_struct} type attribute, PowerPC
6731 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6732 attributes please see the documentation in @ref{x86 Type Attributes}.
6733
6734 @cindex @code{altivec} type attribute, PowerPC
6735 The @code{altivec} attribute allows one to declare AltiVec vector data
6736 types supported by the AltiVec Programming Interface Manual. The
6737 attribute requires an argument to specify one of three vector types:
6738 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6739 and @code{bool__} (always followed by unsigned).
6740
6741 @smallexample
6742 __attribute__((altivec(vector__)))
6743 __attribute__((altivec(pixel__))) unsigned short
6744 __attribute__((altivec(bool__))) unsigned
6745 @end smallexample
6746
6747 These attributes mainly are intended to support the @code{__vector},
6748 @code{__pixel}, and @code{__bool} AltiVec keywords.
6749
6750 @node SPU Type Attributes
6751 @subsection SPU Type Attributes
6752
6753 @cindex @code{spu_vector} type attribute, SPU
6754 The SPU supports the @code{spu_vector} attribute for types. This attribute
6755 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6756 Language Extensions Specification. It is intended to support the
6757 @code{__vector} keyword.
6758
6759 @node x86 Type Attributes
6760 @subsection x86 Type Attributes
6761
6762 Two attributes are currently defined for x86 configurations:
6763 @code{ms_struct} and @code{gcc_struct}.
6764
6765 @table @code
6766
6767 @item ms_struct
6768 @itemx gcc_struct
6769 @cindex @code{ms_struct} type attribute, x86
6770 @cindex @code{gcc_struct} type attribute, x86
6771
6772 If @code{packed} is used on a structure, or if bit-fields are used
6773 it may be that the Microsoft ABI packs them differently
6774 than GCC normally packs them. Particularly when moving packed
6775 data between functions compiled with GCC and the native Microsoft compiler
6776 (either via function call or as data in a file), it may be necessary to access
6777 either format.
6778
6779 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6780 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6781 command-line options, respectively;
6782 see @ref{x86 Options}, for details of how structure layout is affected.
6783 @xref{x86 Variable Attributes}, for information about the corresponding
6784 attributes on variables.
6785
6786 @end table
6787
6788 @node Label Attributes
6789 @section Label Attributes
6790 @cindex Label Attributes
6791
6792 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6793 details of the exact syntax for using attributes. Other attributes are
6794 available for functions (@pxref{Function Attributes}), variables
6795 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6796 and for types (@pxref{Type Attributes}).
6797
6798 This example uses the @code{cold} label attribute to indicate the
6799 @code{ErrorHandling} branch is unlikely to be taken and that the
6800 @code{ErrorHandling} label is unused:
6801
6802 @smallexample
6803
6804 asm goto ("some asm" : : : : NoError);
6805
6806 /* This branch (the fall-through from the asm) is less commonly used */
6807 ErrorHandling:
6808 __attribute__((cold, unused)); /* Semi-colon is required here */
6809 printf("error\n");
6810 return 0;
6811
6812 NoError:
6813 printf("no error\n");
6814 return 1;
6815 @end smallexample
6816
6817 @table @code
6818 @item unused
6819 @cindex @code{unused} label attribute
6820 This feature is intended for program-generated code that may contain
6821 unused labels, but which is compiled with @option{-Wall}. It is
6822 not normally appropriate to use in it human-written code, though it
6823 could be useful in cases where the code that jumps to the label is
6824 contained within an @code{#ifdef} conditional.
6825
6826 @item hot
6827 @cindex @code{hot} label attribute
6828 The @code{hot} attribute on a label is used to inform the compiler that
6829 the path following the label is more likely than paths that are not so
6830 annotated. This attribute is used in cases where @code{__builtin_expect}
6831 cannot be used, for instance with computed goto or @code{asm goto}.
6832
6833 @item cold
6834 @cindex @code{cold} label attribute
6835 The @code{cold} attribute on labels is used to inform the compiler that
6836 the path following the label is unlikely to be executed. This attribute
6837 is used in cases where @code{__builtin_expect} cannot be used, for instance
6838 with computed goto or @code{asm goto}.
6839
6840 @end table
6841
6842 @node Enumerator Attributes
6843 @section Enumerator Attributes
6844 @cindex Enumerator Attributes
6845
6846 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6847 details of the exact syntax for using attributes. Other attributes are
6848 available for functions (@pxref{Function Attributes}), variables
6849 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6850 and for types (@pxref{Type Attributes}).
6851
6852 This example uses the @code{deprecated} enumerator attribute to indicate the
6853 @code{oldval} enumerator is deprecated:
6854
6855 @smallexample
6856 enum E @{
6857 oldval __attribute__((deprecated)),
6858 newval
6859 @};
6860
6861 int
6862 fn (void)
6863 @{
6864 return oldval;
6865 @}
6866 @end smallexample
6867
6868 @table @code
6869 @item deprecated
6870 @cindex @code{deprecated} enumerator attribute
6871 The @code{deprecated} attribute results in a warning if the enumerator
6872 is used anywhere in the source file. This is useful when identifying
6873 enumerators that are expected to be removed in a future version of a
6874 program. The warning also includes the location of the declaration
6875 of the deprecated enumerator, to enable users to easily find further
6876 information about why the enumerator is deprecated, or what they should
6877 do instead. Note that the warnings only occurs for uses.
6878
6879 @end table
6880
6881 @node Attribute Syntax
6882 @section Attribute Syntax
6883 @cindex attribute syntax
6884
6885 This section describes the syntax with which @code{__attribute__} may be
6886 used, and the constructs to which attribute specifiers bind, for the C
6887 language. Some details may vary for C++ and Objective-C@. Because of
6888 infelicities in the grammar for attributes, some forms described here
6889 may not be successfully parsed in all cases.
6890
6891 There are some problems with the semantics of attributes in C++. For
6892 example, there are no manglings for attributes, although they may affect
6893 code generation, so problems may arise when attributed types are used in
6894 conjunction with templates or overloading. Similarly, @code{typeid}
6895 does not distinguish between types with different attributes. Support
6896 for attributes in C++ may be restricted in future to attributes on
6897 declarations only, but not on nested declarators.
6898
6899 @xref{Function Attributes}, for details of the semantics of attributes
6900 applying to functions. @xref{Variable Attributes}, for details of the
6901 semantics of attributes applying to variables. @xref{Type Attributes},
6902 for details of the semantics of attributes applying to structure, union
6903 and enumerated types.
6904 @xref{Label Attributes}, for details of the semantics of attributes
6905 applying to labels.
6906 @xref{Enumerator Attributes}, for details of the semantics of attributes
6907 applying to enumerators.
6908
6909 An @dfn{attribute specifier} is of the form
6910 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6911 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6912 each attribute is one of the following:
6913
6914 @itemize @bullet
6915 @item
6916 Empty. Empty attributes are ignored.
6917
6918 @item
6919 An attribute name
6920 (which may be an identifier such as @code{unused}, or a reserved
6921 word such as @code{const}).
6922
6923 @item
6924 An attribute name followed by a parenthesized list of
6925 parameters for the attribute.
6926 These parameters take one of the following forms:
6927
6928 @itemize @bullet
6929 @item
6930 An identifier. For example, @code{mode} attributes use this form.
6931
6932 @item
6933 An identifier followed by a comma and a non-empty comma-separated list
6934 of expressions. For example, @code{format} attributes use this form.
6935
6936 @item
6937 A possibly empty comma-separated list of expressions. For example,
6938 @code{format_arg} attributes use this form with the list being a single
6939 integer constant expression, and @code{alias} attributes use this form
6940 with the list being a single string constant.
6941 @end itemize
6942 @end itemize
6943
6944 An @dfn{attribute specifier list} is a sequence of one or more attribute
6945 specifiers, not separated by any other tokens.
6946
6947 You may optionally specify attribute names with @samp{__}
6948 preceding and following the name.
6949 This allows you to use them in header files without
6950 being concerned about a possible macro of the same name. For example,
6951 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6952
6953
6954 @subsubheading Label Attributes
6955
6956 In GNU C, an attribute specifier list may appear after the colon following a
6957 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6958 attributes on labels if the attribute specifier is immediately
6959 followed by a semicolon (i.e., the label applies to an empty
6960 statement). If the semicolon is missing, C++ label attributes are
6961 ambiguous, as it is permissible for a declaration, which could begin
6962 with an attribute list, to be labelled in C++. Declarations cannot be
6963 labelled in C90 or C99, so the ambiguity does not arise there.
6964
6965 @subsubheading Enumerator Attributes
6966
6967 In GNU C, an attribute specifier list may appear as part of an enumerator.
6968 The attribute goes after the enumeration constant, before @code{=}, if
6969 present. The optional attribute in the enumerator appertains to the
6970 enumeration constant. It is not possible to place the attribute after
6971 the constant expression, if present.
6972
6973 @subsubheading Type Attributes
6974
6975 An attribute specifier list may appear as part of a @code{struct},
6976 @code{union} or @code{enum} specifier. It may go either immediately
6977 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6978 the closing brace. The former syntax is preferred.
6979 Where attribute specifiers follow the closing brace, they are considered
6980 to relate to the structure, union or enumerated type defined, not to any
6981 enclosing declaration the type specifier appears in, and the type
6982 defined is not complete until after the attribute specifiers.
6983 @c Otherwise, there would be the following problems: a shift/reduce
6984 @c conflict between attributes binding the struct/union/enum and
6985 @c binding to the list of specifiers/qualifiers; and "aligned"
6986 @c attributes could use sizeof for the structure, but the size could be
6987 @c changed later by "packed" attributes.
6988
6989
6990 @subsubheading All other attributes
6991
6992 Otherwise, an attribute specifier appears as part of a declaration,
6993 counting declarations of unnamed parameters and type names, and relates
6994 to that declaration (which may be nested in another declaration, for
6995 example in the case of a parameter declaration), or to a particular declarator
6996 within a declaration. Where an
6997 attribute specifier is applied to a parameter declared as a function or
6998 an array, it should apply to the function or array rather than the
6999 pointer to which the parameter is implicitly converted, but this is not
7000 yet correctly implemented.
7001
7002 Any list of specifiers and qualifiers at the start of a declaration may
7003 contain attribute specifiers, whether or not such a list may in that
7004 context contain storage class specifiers. (Some attributes, however,
7005 are essentially in the nature of storage class specifiers, and only make
7006 sense where storage class specifiers may be used; for example,
7007 @code{section}.) There is one necessary limitation to this syntax: the
7008 first old-style parameter declaration in a function definition cannot
7009 begin with an attribute specifier, because such an attribute applies to
7010 the function instead by syntax described below (which, however, is not
7011 yet implemented in this case). In some other cases, attribute
7012 specifiers are permitted by this grammar but not yet supported by the
7013 compiler. All attribute specifiers in this place relate to the
7014 declaration as a whole. In the obsolescent usage where a type of
7015 @code{int} is implied by the absence of type specifiers, such a list of
7016 specifiers and qualifiers may be an attribute specifier list with no
7017 other specifiers or qualifiers.
7018
7019 At present, the first parameter in a function prototype must have some
7020 type specifier that is not an attribute specifier; this resolves an
7021 ambiguity in the interpretation of @code{void f(int
7022 (__attribute__((foo)) x))}, but is subject to change. At present, if
7023 the parentheses of a function declarator contain only attributes then
7024 those attributes are ignored, rather than yielding an error or warning
7025 or implying a single parameter of type int, but this is subject to
7026 change.
7027
7028 An attribute specifier list may appear immediately before a declarator
7029 (other than the first) in a comma-separated list of declarators in a
7030 declaration of more than one identifier using a single list of
7031 specifiers and qualifiers. Such attribute specifiers apply
7032 only to the identifier before whose declarator they appear. For
7033 example, in
7034
7035 @smallexample
7036 __attribute__((noreturn)) void d0 (void),
7037 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7038 d2 (void);
7039 @end smallexample
7040
7041 @noindent
7042 the @code{noreturn} attribute applies to all the functions
7043 declared; the @code{format} attribute only applies to @code{d1}.
7044
7045 An attribute specifier list may appear immediately before the comma,
7046 @code{=} or semicolon terminating the declaration of an identifier other
7047 than a function definition. Such attribute specifiers apply
7048 to the declared object or function. Where an
7049 assembler name for an object or function is specified (@pxref{Asm
7050 Labels}), the attribute must follow the @code{asm}
7051 specification.
7052
7053 An attribute specifier list may, in future, be permitted to appear after
7054 the declarator in a function definition (before any old-style parameter
7055 declarations or the function body).
7056
7057 Attribute specifiers may be mixed with type qualifiers appearing inside
7058 the @code{[]} of a parameter array declarator, in the C99 construct by
7059 which such qualifiers are applied to the pointer to which the array is
7060 implicitly converted. Such attribute specifiers apply to the pointer,
7061 not to the array, but at present this is not implemented and they are
7062 ignored.
7063
7064 An attribute specifier list may appear at the start of a nested
7065 declarator. At present, there are some limitations in this usage: the
7066 attributes correctly apply to the declarator, but for most individual
7067 attributes the semantics this implies are not implemented.
7068 When attribute specifiers follow the @code{*} of a pointer
7069 declarator, they may be mixed with any type qualifiers present.
7070 The following describes the formal semantics of this syntax. It makes the
7071 most sense if you are familiar with the formal specification of
7072 declarators in the ISO C standard.
7073
7074 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7075 D1}, where @code{T} contains declaration specifiers that specify a type
7076 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7077 contains an identifier @var{ident}. The type specified for @var{ident}
7078 for derived declarators whose type does not include an attribute
7079 specifier is as in the ISO C standard.
7080
7081 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7082 and the declaration @code{T D} specifies the type
7083 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7084 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7085 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7086
7087 If @code{D1} has the form @code{*
7088 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7089 declaration @code{T D} specifies the type
7090 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7091 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7092 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7093 @var{ident}.
7094
7095 For example,
7096
7097 @smallexample
7098 void (__attribute__((noreturn)) ****f) (void);
7099 @end smallexample
7100
7101 @noindent
7102 specifies the type ``pointer to pointer to pointer to pointer to
7103 non-returning function returning @code{void}''. As another example,
7104
7105 @smallexample
7106 char *__attribute__((aligned(8))) *f;
7107 @end smallexample
7108
7109 @noindent
7110 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7111 Note again that this does not work with most attributes; for example,
7112 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7113 is not yet supported.
7114
7115 For compatibility with existing code written for compiler versions that
7116 did not implement attributes on nested declarators, some laxity is
7117 allowed in the placing of attributes. If an attribute that only applies
7118 to types is applied to a declaration, it is treated as applying to
7119 the type of that declaration. If an attribute that only applies to
7120 declarations is applied to the type of a declaration, it is treated
7121 as applying to that declaration; and, for compatibility with code
7122 placing the attributes immediately before the identifier declared, such
7123 an attribute applied to a function return type is treated as
7124 applying to the function type, and such an attribute applied to an array
7125 element type is treated as applying to the array type. If an
7126 attribute that only applies to function types is applied to a
7127 pointer-to-function type, it is treated as applying to the pointer
7128 target type; if such an attribute is applied to a function return type
7129 that is not a pointer-to-function type, it is treated as applying
7130 to the function type.
7131
7132 @node Function Prototypes
7133 @section Prototypes and Old-Style Function Definitions
7134 @cindex function prototype declarations
7135 @cindex old-style function definitions
7136 @cindex promotion of formal parameters
7137
7138 GNU C extends ISO C to allow a function prototype to override a later
7139 old-style non-prototype definition. Consider the following example:
7140
7141 @smallexample
7142 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7143 #ifdef __STDC__
7144 #define P(x) x
7145 #else
7146 #define P(x) ()
7147 #endif
7148
7149 /* @r{Prototype function declaration.} */
7150 int isroot P((uid_t));
7151
7152 /* @r{Old-style function definition.} */
7153 int
7154 isroot (x) /* @r{??? lossage here ???} */
7155 uid_t x;
7156 @{
7157 return x == 0;
7158 @}
7159 @end smallexample
7160
7161 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7162 not allow this example, because subword arguments in old-style
7163 non-prototype definitions are promoted. Therefore in this example the
7164 function definition's argument is really an @code{int}, which does not
7165 match the prototype argument type of @code{short}.
7166
7167 This restriction of ISO C makes it hard to write code that is portable
7168 to traditional C compilers, because the programmer does not know
7169 whether the @code{uid_t} type is @code{short}, @code{int}, or
7170 @code{long}. Therefore, in cases like these GNU C allows a prototype
7171 to override a later old-style definition. More precisely, in GNU C, a
7172 function prototype argument type overrides the argument type specified
7173 by a later old-style definition if the former type is the same as the
7174 latter type before promotion. Thus in GNU C the above example is
7175 equivalent to the following:
7176
7177 @smallexample
7178 int isroot (uid_t);
7179
7180 int
7181 isroot (uid_t x)
7182 @{
7183 return x == 0;
7184 @}
7185 @end smallexample
7186
7187 @noindent
7188 GNU C++ does not support old-style function definitions, so this
7189 extension is irrelevant.
7190
7191 @node C++ Comments
7192 @section C++ Style Comments
7193 @cindex @code{//}
7194 @cindex C++ comments
7195 @cindex comments, C++ style
7196
7197 In GNU C, you may use C++ style comments, which start with @samp{//} and
7198 continue until the end of the line. Many other C implementations allow
7199 such comments, and they are included in the 1999 C standard. However,
7200 C++ style comments are not recognized if you specify an @option{-std}
7201 option specifying a version of ISO C before C99, or @option{-ansi}
7202 (equivalent to @option{-std=c90}).
7203
7204 @node Dollar Signs
7205 @section Dollar Signs in Identifier Names
7206 @cindex $
7207 @cindex dollar signs in identifier names
7208 @cindex identifier names, dollar signs in
7209
7210 In GNU C, you may normally use dollar signs in identifier names.
7211 This is because many traditional C implementations allow such identifiers.
7212 However, dollar signs in identifiers are not supported on a few target
7213 machines, typically because the target assembler does not allow them.
7214
7215 @node Character Escapes
7216 @section The Character @key{ESC} in Constants
7217
7218 You can use the sequence @samp{\e} in a string or character constant to
7219 stand for the ASCII character @key{ESC}.
7220
7221 @node Alignment
7222 @section Inquiring on Alignment of Types or Variables
7223 @cindex alignment
7224 @cindex type alignment
7225 @cindex variable alignment
7226
7227 The keyword @code{__alignof__} allows you to inquire about how an object
7228 is aligned, or the minimum alignment usually required by a type. Its
7229 syntax is just like @code{sizeof}.
7230
7231 For example, if the target machine requires a @code{double} value to be
7232 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7233 This is true on many RISC machines. On more traditional machine
7234 designs, @code{__alignof__ (double)} is 4 or even 2.
7235
7236 Some machines never actually require alignment; they allow reference to any
7237 data type even at an odd address. For these machines, @code{__alignof__}
7238 reports the smallest alignment that GCC gives the data type, usually as
7239 mandated by the target ABI.
7240
7241 If the operand of @code{__alignof__} is an lvalue rather than a type,
7242 its value is the required alignment for its type, taking into account
7243 any minimum alignment specified with GCC's @code{__attribute__}
7244 extension (@pxref{Variable Attributes}). For example, after this
7245 declaration:
7246
7247 @smallexample
7248 struct foo @{ int x; char y; @} foo1;
7249 @end smallexample
7250
7251 @noindent
7252 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7253 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7254
7255 It is an error to ask for the alignment of an incomplete type.
7256
7257
7258 @node Inline
7259 @section An Inline Function is As Fast As a Macro
7260 @cindex inline functions
7261 @cindex integrating function code
7262 @cindex open coding
7263 @cindex macros, inline alternative
7264
7265 By declaring a function inline, you can direct GCC to make
7266 calls to that function faster. One way GCC can achieve this is to
7267 integrate that function's code into the code for its callers. This
7268 makes execution faster by eliminating the function-call overhead; in
7269 addition, if any of the actual argument values are constant, their
7270 known values may permit simplifications at compile time so that not
7271 all of the inline function's code needs to be included. The effect on
7272 code size is less predictable; object code may be larger or smaller
7273 with function inlining, depending on the particular case. You can
7274 also direct GCC to try to integrate all ``simple enough'' functions
7275 into their callers with the option @option{-finline-functions}.
7276
7277 GCC implements three different semantics of declaring a function
7278 inline. One is available with @option{-std=gnu89} or
7279 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7280 on all inline declarations, another when
7281 @option{-std=c99}, @option{-std=c11},
7282 @option{-std=gnu99} or @option{-std=gnu11}
7283 (without @option{-fgnu89-inline}), and the third
7284 is used when compiling C++.
7285
7286 To declare a function inline, use the @code{inline} keyword in its
7287 declaration, like this:
7288
7289 @smallexample
7290 static inline int
7291 inc (int *a)
7292 @{
7293 return (*a)++;
7294 @}
7295 @end smallexample
7296
7297 If you are writing a header file to be included in ISO C90 programs, write
7298 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7299
7300 The three types of inlining behave similarly in two important cases:
7301 when the @code{inline} keyword is used on a @code{static} function,
7302 like the example above, and when a function is first declared without
7303 using the @code{inline} keyword and then is defined with
7304 @code{inline}, like this:
7305
7306 @smallexample
7307 extern int inc (int *a);
7308 inline int
7309 inc (int *a)
7310 @{
7311 return (*a)++;
7312 @}
7313 @end smallexample
7314
7315 In both of these common cases, the program behaves the same as if you
7316 had not used the @code{inline} keyword, except for its speed.
7317
7318 @cindex inline functions, omission of
7319 @opindex fkeep-inline-functions
7320 When a function is both inline and @code{static}, if all calls to the
7321 function are integrated into the caller, and the function's address is
7322 never used, then the function's own assembler code is never referenced.
7323 In this case, GCC does not actually output assembler code for the
7324 function, unless you specify the option @option{-fkeep-inline-functions}.
7325 If there is a nonintegrated call, then the function is compiled to
7326 assembler code as usual. The function must also be compiled as usual if
7327 the program refers to its address, because that can't be inlined.
7328
7329 @opindex Winline
7330 Note that certain usages in a function definition can make it unsuitable
7331 for inline substitution. Among these usages are: variadic functions,
7332 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7333 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7334 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7335 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7336 function marked @code{inline} could not be substituted, and gives the
7337 reason for the failure.
7338
7339 @cindex automatic @code{inline} for C++ member fns
7340 @cindex @code{inline} automatic for C++ member fns
7341 @cindex member fns, automatically @code{inline}
7342 @cindex C++ member fns, automatically @code{inline}
7343 @opindex fno-default-inline
7344 As required by ISO C++, GCC considers member functions defined within
7345 the body of a class to be marked inline even if they are
7346 not explicitly declared with the @code{inline} keyword. You can
7347 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7348 Options,,Options Controlling C++ Dialect}.
7349
7350 GCC does not inline any functions when not optimizing unless you specify
7351 the @samp{always_inline} attribute for the function, like this:
7352
7353 @smallexample
7354 /* @r{Prototype.} */
7355 inline void foo (const char) __attribute__((always_inline));
7356 @end smallexample
7357
7358 The remainder of this section is specific to GNU C90 inlining.
7359
7360 @cindex non-static inline function
7361 When an inline function is not @code{static}, then the compiler must assume
7362 that there may be calls from other source files; since a global symbol can
7363 be defined only once in any program, the function must not be defined in
7364 the other source files, so the calls therein cannot be integrated.
7365 Therefore, a non-@code{static} inline function is always compiled on its
7366 own in the usual fashion.
7367
7368 If you specify both @code{inline} and @code{extern} in the function
7369 definition, then the definition is used only for inlining. In no case
7370 is the function compiled on its own, not even if you refer to its
7371 address explicitly. Such an address becomes an external reference, as
7372 if you had only declared the function, and had not defined it.
7373
7374 This combination of @code{inline} and @code{extern} has almost the
7375 effect of a macro. The way to use it is to put a function definition in
7376 a header file with these keywords, and put another copy of the
7377 definition (lacking @code{inline} and @code{extern}) in a library file.
7378 The definition in the header file causes most calls to the function
7379 to be inlined. If any uses of the function remain, they refer to
7380 the single copy in the library.
7381
7382 @node Volatiles
7383 @section When is a Volatile Object Accessed?
7384 @cindex accessing volatiles
7385 @cindex volatile read
7386 @cindex volatile write
7387 @cindex volatile access
7388
7389 C has the concept of volatile objects. These are normally accessed by
7390 pointers and used for accessing hardware or inter-thread
7391 communication. The standard encourages compilers to refrain from
7392 optimizations concerning accesses to volatile objects, but leaves it
7393 implementation defined as to what constitutes a volatile access. The
7394 minimum requirement is that at a sequence point all previous accesses
7395 to volatile objects have stabilized and no subsequent accesses have
7396 occurred. Thus an implementation is free to reorder and combine
7397 volatile accesses that occur between sequence points, but cannot do
7398 so for accesses across a sequence point. The use of volatile does
7399 not allow you to violate the restriction on updating objects multiple
7400 times between two sequence points.
7401
7402 Accesses to non-volatile objects are not ordered with respect to
7403 volatile accesses. You cannot use a volatile object as a memory
7404 barrier to order a sequence of writes to non-volatile memory. For
7405 instance:
7406
7407 @smallexample
7408 int *ptr = @var{something};
7409 volatile int vobj;
7410 *ptr = @var{something};
7411 vobj = 1;
7412 @end smallexample
7413
7414 @noindent
7415 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7416 that the write to @var{*ptr} occurs by the time the update
7417 of @var{vobj} happens. If you need this guarantee, you must use
7418 a stronger memory barrier such as:
7419
7420 @smallexample
7421 int *ptr = @var{something};
7422 volatile int vobj;
7423 *ptr = @var{something};
7424 asm volatile ("" : : : "memory");
7425 vobj = 1;
7426 @end smallexample
7427
7428 A scalar volatile object is read when it is accessed in a void context:
7429
7430 @smallexample
7431 volatile int *src = @var{somevalue};
7432 *src;
7433 @end smallexample
7434
7435 Such expressions are rvalues, and GCC implements this as a
7436 read of the volatile object being pointed to.
7437
7438 Assignments are also expressions and have an rvalue. However when
7439 assigning to a scalar volatile, the volatile object is not reread,
7440 regardless of whether the assignment expression's rvalue is used or
7441 not. If the assignment's rvalue is used, the value is that assigned
7442 to the volatile object. For instance, there is no read of @var{vobj}
7443 in all the following cases:
7444
7445 @smallexample
7446 int obj;
7447 volatile int vobj;
7448 vobj = @var{something};
7449 obj = vobj = @var{something};
7450 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7451 obj = (@var{something}, vobj = @var{anotherthing});
7452 @end smallexample
7453
7454 If you need to read the volatile object after an assignment has
7455 occurred, you must use a separate expression with an intervening
7456 sequence point.
7457
7458 As bit-fields are not individually addressable, volatile bit-fields may
7459 be implicitly read when written to, or when adjacent bit-fields are
7460 accessed. Bit-field operations may be optimized such that adjacent
7461 bit-fields are only partially accessed, if they straddle a storage unit
7462 boundary. For these reasons it is unwise to use volatile bit-fields to
7463 access hardware.
7464
7465 @node Using Assembly Language with C
7466 @section How to Use Inline Assembly Language in C Code
7467 @cindex @code{asm} keyword
7468 @cindex assembly language in C
7469 @cindex inline assembly language
7470 @cindex mixing assembly language and C
7471
7472 The @code{asm} keyword allows you to embed assembler instructions
7473 within C code. GCC provides two forms of inline @code{asm}
7474 statements. A @dfn{basic @code{asm}} statement is one with no
7475 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7476 statement (@pxref{Extended Asm}) includes one or more operands.
7477 The extended form is preferred for mixing C and assembly language
7478 within a function, but to include assembly language at
7479 top level you must use basic @code{asm}.
7480
7481 You can also use the @code{asm} keyword to override the assembler name
7482 for a C symbol, or to place a C variable in a specific register.
7483
7484 @menu
7485 * Basic Asm:: Inline assembler without operands.
7486 * Extended Asm:: Inline assembler with operands.
7487 * Constraints:: Constraints for @code{asm} operands
7488 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7489 * Explicit Register Variables:: Defining variables residing in specified
7490 registers.
7491 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7492 @end menu
7493
7494 @node Basic Asm
7495 @subsection Basic Asm --- Assembler Instructions Without Operands
7496 @cindex basic @code{asm}
7497 @cindex assembly language in C, basic
7498
7499 A basic @code{asm} statement has the following syntax:
7500
7501 @example
7502 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7503 @end example
7504
7505 The @code{asm} keyword is a GNU extension.
7506 When writing code that can be compiled with @option{-ansi} and the
7507 various @option{-std} options, use @code{__asm__} instead of
7508 @code{asm} (@pxref{Alternate Keywords}).
7509
7510 @subsubheading Qualifiers
7511 @table @code
7512 @item volatile
7513 The optional @code{volatile} qualifier has no effect.
7514 All basic @code{asm} blocks are implicitly volatile.
7515 @end table
7516
7517 @subsubheading Parameters
7518 @table @var
7519
7520 @item AssemblerInstructions
7521 This is a literal string that specifies the assembler code. The string can
7522 contain any instructions recognized by the assembler, including directives.
7523 GCC does not parse the assembler instructions themselves and
7524 does not know what they mean or even whether they are valid assembler input.
7525
7526 You may place multiple assembler instructions together in a single @code{asm}
7527 string, separated by the characters normally used in assembly code for the
7528 system. A combination that works in most places is a newline to break the
7529 line, plus a tab character (written as @samp{\n\t}).
7530 Some assemblers allow semicolons as a line separator. However,
7531 note that some assembler dialects use semicolons to start a comment.
7532 @end table
7533
7534 @subsubheading Remarks
7535 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7536 smaller, safer, and more efficient code, and in most cases it is a
7537 better solution than basic @code{asm}. However, there are two
7538 situations where only basic @code{asm} can be used:
7539
7540 @itemize @bullet
7541 @item
7542 Extended @code{asm} statements have to be inside a C
7543 function, so to write inline assembly language at file scope (``top-level''),
7544 outside of C functions, you must use basic @code{asm}.
7545 You can use this technique to emit assembler directives,
7546 define assembly language macros that can be invoked elsewhere in the file,
7547 or write entire functions in assembly language.
7548
7549 @item
7550 Functions declared
7551 with the @code{naked} attribute also require basic @code{asm}
7552 (@pxref{Function Attributes}).
7553 @end itemize
7554
7555 Safely accessing C data and calling functions from basic @code{asm} is more
7556 complex than it may appear. To access C data, it is better to use extended
7557 @code{asm}.
7558
7559 Do not expect a sequence of @code{asm} statements to remain perfectly
7560 consecutive after compilation. If certain instructions need to remain
7561 consecutive in the output, put them in a single multi-instruction @code{asm}
7562 statement. Note that GCC's optimizers can move @code{asm} statements
7563 relative to other code, including across jumps.
7564
7565 @code{asm} statements may not perform jumps into other @code{asm} statements.
7566 GCC does not know about these jumps, and therefore cannot take
7567 account of them when deciding how to optimize. Jumps from @code{asm} to C
7568 labels are only supported in extended @code{asm}.
7569
7570 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7571 assembly code when optimizing. This can lead to unexpected duplicate
7572 symbol errors during compilation if your assembly code defines symbols or
7573 labels.
7574
7575 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7576 making it a potential source of incompatibilities between compilers. These
7577 incompatibilities may not produce compiler warnings/errors.
7578
7579 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7580 means there is no way to communicate to the compiler what is happening
7581 inside them. GCC has no visibility of symbols in the @code{asm} and may
7582 discard them as unreferenced. It also does not know about side effects of
7583 the assembler code, such as modifications to memory or registers. Unlike
7584 some compilers, GCC assumes that no changes to either memory or registers
7585 occur. This assumption may change in a future release.
7586
7587 To avoid complications from future changes to the semantics and the
7588 compatibility issues between compilers, consider replacing basic @code{asm}
7589 with extended @code{asm}. See
7590 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7591 from basic asm to extended asm} for information about how to perform this
7592 conversion.
7593
7594 The compiler copies the assembler instructions in a basic @code{asm}
7595 verbatim to the assembly language output file, without
7596 processing dialects or any of the @samp{%} operators that are available with
7597 extended @code{asm}. This results in minor differences between basic
7598 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7599 registers you might use @samp{%eax} in basic @code{asm} and
7600 @samp{%%eax} in extended @code{asm}.
7601
7602 On targets such as x86 that support multiple assembler dialects,
7603 all basic @code{asm} blocks use the assembler dialect specified by the
7604 @option{-masm} command-line option (@pxref{x86 Options}).
7605 Basic @code{asm} provides no
7606 mechanism to provide different assembler strings for different dialects.
7607
7608 Here is an example of basic @code{asm} for i386:
7609
7610 @example
7611 /* Note that this code will not compile with -masm=intel */
7612 #define DebugBreak() asm("int $3")
7613 @end example
7614
7615 @node Extended Asm
7616 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7617 @cindex extended @code{asm}
7618 @cindex assembly language in C, extended
7619
7620 With extended @code{asm} you can read and write C variables from
7621 assembler and perform jumps from assembler code to C labels.
7622 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7623 the operand parameters after the assembler template:
7624
7625 @example
7626 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7627 : @var{OutputOperands}
7628 @r{[} : @var{InputOperands}
7629 @r{[} : @var{Clobbers} @r{]} @r{]})
7630
7631 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7632 :
7633 : @var{InputOperands}
7634 : @var{Clobbers}
7635 : @var{GotoLabels})
7636 @end example
7637
7638 The @code{asm} keyword is a GNU extension.
7639 When writing code that can be compiled with @option{-ansi} and the
7640 various @option{-std} options, use @code{__asm__} instead of
7641 @code{asm} (@pxref{Alternate Keywords}).
7642
7643 @subsubheading Qualifiers
7644 @table @code
7645
7646 @item volatile
7647 The typical use of extended @code{asm} statements is to manipulate input
7648 values to produce output values. However, your @code{asm} statements may
7649 also produce side effects. If so, you may need to use the @code{volatile}
7650 qualifier to disable certain optimizations. @xref{Volatile}.
7651
7652 @item goto
7653 This qualifier informs the compiler that the @code{asm} statement may
7654 perform a jump to one of the labels listed in the @var{GotoLabels}.
7655 @xref{GotoLabels}.
7656 @end table
7657
7658 @subsubheading Parameters
7659 @table @var
7660 @item AssemblerTemplate
7661 This is a literal string that is the template for the assembler code. It is a
7662 combination of fixed text and tokens that refer to the input, output,
7663 and goto parameters. @xref{AssemblerTemplate}.
7664
7665 @item OutputOperands
7666 A comma-separated list of the C variables modified by the instructions in the
7667 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7668
7669 @item InputOperands
7670 A comma-separated list of C expressions read by the instructions in the
7671 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7672
7673 @item Clobbers
7674 A comma-separated list of registers or other values changed by the
7675 @var{AssemblerTemplate}, beyond those listed as outputs.
7676 An empty list is permitted. @xref{Clobbers}.
7677
7678 @item GotoLabels
7679 When you are using the @code{goto} form of @code{asm}, this section contains
7680 the list of all C labels to which the code in the
7681 @var{AssemblerTemplate} may jump.
7682 @xref{GotoLabels}.
7683
7684 @code{asm} statements may not perform jumps into other @code{asm} statements,
7685 only to the listed @var{GotoLabels}.
7686 GCC's optimizers do not know about other jumps; therefore they cannot take
7687 account of them when deciding how to optimize.
7688 @end table
7689
7690 The total number of input + output + goto operands is limited to 30.
7691
7692 @subsubheading Remarks
7693 The @code{asm} statement allows you to include assembly instructions directly
7694 within C code. This may help you to maximize performance in time-sensitive
7695 code or to access assembly instructions that are not readily available to C
7696 programs.
7697
7698 Note that extended @code{asm} statements must be inside a function. Only
7699 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7700 Functions declared with the @code{naked} attribute also require basic
7701 @code{asm} (@pxref{Function Attributes}).
7702
7703 While the uses of @code{asm} are many and varied, it may help to think of an
7704 @code{asm} statement as a series of low-level instructions that convert input
7705 parameters to output parameters. So a simple (if not particularly useful)
7706 example for i386 using @code{asm} might look like this:
7707
7708 @example
7709 int src = 1;
7710 int dst;
7711
7712 asm ("mov %1, %0\n\t"
7713 "add $1, %0"
7714 : "=r" (dst)
7715 : "r" (src));
7716
7717 printf("%d\n", dst);
7718 @end example
7719
7720 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7721
7722 @anchor{Volatile}
7723 @subsubsection Volatile
7724 @cindex volatile @code{asm}
7725 @cindex @code{asm} volatile
7726
7727 GCC's optimizers sometimes discard @code{asm} statements if they determine
7728 there is no need for the output variables. Also, the optimizers may move
7729 code out of loops if they believe that the code will always return the same
7730 result (i.e. none of its input values change between calls). Using the
7731 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7732 that have no output operands, including @code{asm goto} statements,
7733 are implicitly volatile.
7734
7735 This i386 code demonstrates a case that does not use (or require) the
7736 @code{volatile} qualifier. If it is performing assertion checking, this code
7737 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7738 unreferenced by any code. As a result, the optimizers can discard the
7739 @code{asm} statement, which in turn removes the need for the entire
7740 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7741 isn't needed you allow the optimizers to produce the most efficient code
7742 possible.
7743
7744 @example
7745 void DoCheck(uint32_t dwSomeValue)
7746 @{
7747 uint32_t dwRes;
7748
7749 // Assumes dwSomeValue is not zero.
7750 asm ("bsfl %1,%0"
7751 : "=r" (dwRes)
7752 : "r" (dwSomeValue)
7753 : "cc");
7754
7755 assert(dwRes > 3);
7756 @}
7757 @end example
7758
7759 The next example shows a case where the optimizers can recognize that the input
7760 (@code{dwSomeValue}) never changes during the execution of the function and can
7761 therefore move the @code{asm} outside the loop to produce more efficient code.
7762 Again, using @code{volatile} disables this type of optimization.
7763
7764 @example
7765 void do_print(uint32_t dwSomeValue)
7766 @{
7767 uint32_t dwRes;
7768
7769 for (uint32_t x=0; x < 5; x++)
7770 @{
7771 // Assumes dwSomeValue is not zero.
7772 asm ("bsfl %1,%0"
7773 : "=r" (dwRes)
7774 : "r" (dwSomeValue)
7775 : "cc");
7776
7777 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7778 @}
7779 @}
7780 @end example
7781
7782 The following example demonstrates a case where you need to use the
7783 @code{volatile} qualifier.
7784 It uses the x86 @code{rdtsc} instruction, which reads
7785 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7786 the optimizers might assume that the @code{asm} block will always return the
7787 same value and therefore optimize away the second call.
7788
7789 @example
7790 uint64_t msr;
7791
7792 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7793 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7794 "or %%rdx, %0" // 'Or' in the lower bits.
7795 : "=a" (msr)
7796 :
7797 : "rdx");
7798
7799 printf("msr: %llx\n", msr);
7800
7801 // Do other work...
7802
7803 // Reprint the timestamp
7804 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7805 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7806 "or %%rdx, %0" // 'Or' in the lower bits.
7807 : "=a" (msr)
7808 :
7809 : "rdx");
7810
7811 printf("msr: %llx\n", msr);
7812 @end example
7813
7814 GCC's optimizers do not treat this code like the non-volatile code in the
7815 earlier examples. They do not move it out of loops or omit it on the
7816 assumption that the result from a previous call is still valid.
7817
7818 Note that the compiler can move even volatile @code{asm} instructions relative
7819 to other code, including across jump instructions. For example, on many
7820 targets there is a system register that controls the rounding mode of
7821 floating-point operations. Setting it with a volatile @code{asm}, as in the
7822 following PowerPC example, does not work reliably.
7823
7824 @example
7825 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7826 sum = x + y;
7827 @end example
7828
7829 The compiler may move the addition back before the volatile @code{asm}. To
7830 make it work as expected, add an artificial dependency to the @code{asm} by
7831 referencing a variable in the subsequent code, for example:
7832
7833 @example
7834 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7835 sum = x + y;
7836 @end example
7837
7838 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7839 assembly code when optimizing. This can lead to unexpected duplicate symbol
7840 errors during compilation if your asm code defines symbols or labels.
7841 Using @samp{%=}
7842 (@pxref{AssemblerTemplate}) may help resolve this problem.
7843
7844 @anchor{AssemblerTemplate}
7845 @subsubsection Assembler Template
7846 @cindex @code{asm} assembler template
7847
7848 An assembler template is a literal string containing assembler instructions.
7849 The compiler replaces tokens in the template that refer
7850 to inputs, outputs, and goto labels,
7851 and then outputs the resulting string to the assembler. The
7852 string can contain any instructions recognized by the assembler, including
7853 directives. GCC does not parse the assembler instructions
7854 themselves and does not know what they mean or even whether they are valid
7855 assembler input. However, it does count the statements
7856 (@pxref{Size of an asm}).
7857
7858 You may place multiple assembler instructions together in a single @code{asm}
7859 string, separated by the characters normally used in assembly code for the
7860 system. A combination that works in most places is a newline to break the
7861 line, plus a tab character to move to the instruction field (written as
7862 @samp{\n\t}).
7863 Some assemblers allow semicolons as a line separator. However, note
7864 that some assembler dialects use semicolons to start a comment.
7865
7866 Do not expect a sequence of @code{asm} statements to remain perfectly
7867 consecutive after compilation, even when you are using the @code{volatile}
7868 qualifier. If certain instructions need to remain consecutive in the output,
7869 put them in a single multi-instruction asm statement.
7870
7871 Accessing data from C programs without using input/output operands (such as
7872 by using global symbols directly from the assembler template) may not work as
7873 expected. Similarly, calling functions directly from an assembler template
7874 requires a detailed understanding of the target assembler and ABI.
7875
7876 Since GCC does not parse the assembler template,
7877 it has no visibility of any
7878 symbols it references. This may result in GCC discarding those symbols as
7879 unreferenced unless they are also listed as input, output, or goto operands.
7880
7881 @subsubheading Special format strings
7882
7883 In addition to the tokens described by the input, output, and goto operands,
7884 these tokens have special meanings in the assembler template:
7885
7886 @table @samp
7887 @item %%
7888 Outputs a single @samp{%} into the assembler code.
7889
7890 @item %=
7891 Outputs a number that is unique to each instance of the @code{asm}
7892 statement in the entire compilation. This option is useful when creating local
7893 labels and referring to them multiple times in a single template that
7894 generates multiple assembler instructions.
7895
7896 @item %@{
7897 @itemx %|
7898 @itemx %@}
7899 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7900 into the assembler code. When unescaped, these characters have special
7901 meaning to indicate multiple assembler dialects, as described below.
7902 @end table
7903
7904 @subsubheading Multiple assembler dialects in @code{asm} templates
7905
7906 On targets such as x86, GCC supports multiple assembler dialects.
7907 The @option{-masm} option controls which dialect GCC uses as its
7908 default for inline assembler. The target-specific documentation for the
7909 @option{-masm} option contains the list of supported dialects, as well as the
7910 default dialect if the option is not specified. This information may be
7911 important to understand, since assembler code that works correctly when
7912 compiled using one dialect will likely fail if compiled using another.
7913 @xref{x86 Options}.
7914
7915 If your code needs to support multiple assembler dialects (for example, if
7916 you are writing public headers that need to support a variety of compilation
7917 options), use constructs of this form:
7918
7919 @example
7920 @{ dialect0 | dialect1 | dialect2... @}
7921 @end example
7922
7923 This construct outputs @code{dialect0}
7924 when using dialect #0 to compile the code,
7925 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7926 braces than the number of dialects the compiler supports, the construct
7927 outputs nothing.
7928
7929 For example, if an x86 compiler supports two dialects
7930 (@samp{att}, @samp{intel}), an
7931 assembler template such as this:
7932
7933 @example
7934 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7935 @end example
7936
7937 @noindent
7938 is equivalent to one of
7939
7940 @example
7941 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7942 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7943 @end example
7944
7945 Using that same compiler, this code:
7946
7947 @example
7948 "xchg@{l@}\t@{%%@}ebx, %1"
7949 @end example
7950
7951 @noindent
7952 corresponds to either
7953
7954 @example
7955 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7956 "xchg\tebx, %1" @r{/* intel dialect */}
7957 @end example
7958
7959 There is no support for nesting dialect alternatives.
7960
7961 @anchor{OutputOperands}
7962 @subsubsection Output Operands
7963 @cindex @code{asm} output operands
7964
7965 An @code{asm} statement has zero or more output operands indicating the names
7966 of C variables modified by the assembler code.
7967
7968 In this i386 example, @code{old} (referred to in the template string as
7969 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7970 (@code{%2}) is an input:
7971
7972 @example
7973 bool old;
7974
7975 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7976 "sbb %0,%0" // Use the CF to calculate old.
7977 : "=r" (old), "+rm" (*Base)
7978 : "Ir" (Offset)
7979 : "cc");
7980
7981 return old;
7982 @end example
7983
7984 Operands are separated by commas. Each operand has this format:
7985
7986 @example
7987 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7988 @end example
7989
7990 @table @var
7991 @item asmSymbolicName
7992 Specifies a symbolic name for the operand.
7993 Reference the name in the assembler template
7994 by enclosing it in square brackets
7995 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7996 that contains the definition. Any valid C variable name is acceptable,
7997 including names already defined in the surrounding code. No two operands
7998 within the same @code{asm} statement can use the same symbolic name.
7999
8000 When not using an @var{asmSymbolicName}, use the (zero-based) position
8001 of the operand
8002 in the list of operands in the assembler template. For example if there are
8003 three output operands, use @samp{%0} in the template to refer to the first,
8004 @samp{%1} for the second, and @samp{%2} for the third.
8005
8006 @item constraint
8007 A string constant specifying constraints on the placement of the operand;
8008 @xref{Constraints}, for details.
8009
8010 Output constraints must begin with either @samp{=} (a variable overwriting an
8011 existing value) or @samp{+} (when reading and writing). When using
8012 @samp{=}, do not assume the location contains the existing value
8013 on entry to the @code{asm}, except
8014 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8015
8016 After the prefix, there must be one or more additional constraints
8017 (@pxref{Constraints}) that describe where the value resides. Common
8018 constraints include @samp{r} for register and @samp{m} for memory.
8019 When you list more than one possible location (for example, @code{"=rm"}),
8020 the compiler chooses the most efficient one based on the current context.
8021 If you list as many alternates as the @code{asm} statement allows, you permit
8022 the optimizers to produce the best possible code.
8023 If you must use a specific register, but your Machine Constraints do not
8024 provide sufficient control to select the specific register you want,
8025 local register variables may provide a solution (@pxref{Local Register
8026 Variables}).
8027
8028 @item cvariablename
8029 Specifies a C lvalue expression to hold the output, typically a variable name.
8030 The enclosing parentheses are a required part of the syntax.
8031
8032 @end table
8033
8034 When the compiler selects the registers to use to
8035 represent the output operands, it does not use any of the clobbered registers
8036 (@pxref{Clobbers}).
8037
8038 Output operand expressions must be lvalues. The compiler cannot check whether
8039 the operands have data types that are reasonable for the instruction being
8040 executed. For output expressions that are not directly addressable (for
8041 example a bit-field), the constraint must allow a register. In that case, GCC
8042 uses the register as the output of the @code{asm}, and then stores that
8043 register into the output.
8044
8045 Operands using the @samp{+} constraint modifier count as two operands
8046 (that is, both as input and output) towards the total maximum of 30 operands
8047 per @code{asm} statement.
8048
8049 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8050 operands that must not overlap an input. Otherwise,
8051 GCC may allocate the output operand in the same register as an unrelated
8052 input operand, on the assumption that the assembler code consumes its
8053 inputs before producing outputs. This assumption may be false if the assembler
8054 code actually consists of more than one instruction.
8055
8056 The same problem can occur if one output parameter (@var{a}) allows a register
8057 constraint and another output parameter (@var{b}) allows a memory constraint.
8058 The code generated by GCC to access the memory address in @var{b} can contain
8059 registers which @emph{might} be shared by @var{a}, and GCC considers those
8060 registers to be inputs to the asm. As above, GCC assumes that such input
8061 registers are consumed before any outputs are written. This assumption may
8062 result in incorrect behavior if the asm writes to @var{a} before using
8063 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8064 ensures that modifying @var{a} does not affect the address referenced by
8065 @var{b}. Otherwise, the location of @var{b}
8066 is undefined if @var{a} is modified before using @var{b}.
8067
8068 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8069 instead of simply @samp{%2}). Typically these qualifiers are hardware
8070 dependent. The list of supported modifiers for x86 is found at
8071 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8072
8073 If the C code that follows the @code{asm} makes no use of any of the output
8074 operands, use @code{volatile} for the @code{asm} statement to prevent the
8075 optimizers from discarding the @code{asm} statement as unneeded
8076 (see @ref{Volatile}).
8077
8078 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8079 references the first output operand as @code{%0} (were there a second, it
8080 would be @code{%1}, etc). The number of the first input operand is one greater
8081 than that of the last output operand. In this i386 example, that makes
8082 @code{Mask} referenced as @code{%1}:
8083
8084 @example
8085 uint32_t Mask = 1234;
8086 uint32_t Index;
8087
8088 asm ("bsfl %1, %0"
8089 : "=r" (Index)
8090 : "r" (Mask)
8091 : "cc");
8092 @end example
8093
8094 That code overwrites the variable @code{Index} (@samp{=}),
8095 placing the value in a register (@samp{r}).
8096 Using the generic @samp{r} constraint instead of a constraint for a specific
8097 register allows the compiler to pick the register to use, which can result
8098 in more efficient code. This may not be possible if an assembler instruction
8099 requires a specific register.
8100
8101 The following i386 example uses the @var{asmSymbolicName} syntax.
8102 It produces the
8103 same result as the code above, but some may consider it more readable or more
8104 maintainable since reordering index numbers is not necessary when adding or
8105 removing operands. The names @code{aIndex} and @code{aMask}
8106 are only used in this example to emphasize which
8107 names get used where.
8108 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8109
8110 @example
8111 uint32_t Mask = 1234;
8112 uint32_t Index;
8113
8114 asm ("bsfl %[aMask], %[aIndex]"
8115 : [aIndex] "=r" (Index)
8116 : [aMask] "r" (Mask)
8117 : "cc");
8118 @end example
8119
8120 Here are some more examples of output operands.
8121
8122 @example
8123 uint32_t c = 1;
8124 uint32_t d;
8125 uint32_t *e = &c;
8126
8127 asm ("mov %[e], %[d]"
8128 : [d] "=rm" (d)
8129 : [e] "rm" (*e));
8130 @end example
8131
8132 Here, @code{d} may either be in a register or in memory. Since the compiler
8133 might already have the current value of the @code{uint32_t} location
8134 pointed to by @code{e}
8135 in a register, you can enable it to choose the best location
8136 for @code{d} by specifying both constraints.
8137
8138 @anchor{FlagOutputOperands}
8139 @subsubsection Flag Output Operands
8140 @cindex @code{asm} flag output operands
8141
8142 Some targets have a special register that holds the ``flags'' for the
8143 result of an operation or comparison. Normally, the contents of that
8144 register are either unmodifed by the asm, or the asm is considered to
8145 clobber the contents.
8146
8147 On some targets, a special form of output operand exists by which
8148 conditions in the flags register may be outputs of the asm. The set of
8149 conditions supported are target specific, but the general rule is that
8150 the output variable must be a scalar integer, and the value is boolean.
8151 When supported, the target defines the preprocessor symbol
8152 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8153
8154 Because of the special nature of the flag output operands, the constraint
8155 may not include alternatives.
8156
8157 Most often, the target has only one flags register, and thus is an implied
8158 operand of many instructions. In this case, the operand should not be
8159 referenced within the assembler template via @code{%0} etc, as there's
8160 no corresponding text in the assembly language.
8161
8162 @table @asis
8163 @item x86 family
8164 The flag output constraints for the x86 family are of the form
8165 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8166 conditions defined in the ISA manual for @code{j@var{cc}} or
8167 @code{set@var{cc}}.
8168
8169 @table @code
8170 @item a
8171 ``above'' or unsigned greater than
8172 @item ae
8173 ``above or equal'' or unsigned greater than or equal
8174 @item b
8175 ``below'' or unsigned less than
8176 @item be
8177 ``below or equal'' or unsigned less than or equal
8178 @item c
8179 carry flag set
8180 @item e
8181 @itemx z
8182 ``equal'' or zero flag set
8183 @item g
8184 signed greater than
8185 @item ge
8186 signed greater than or equal
8187 @item l
8188 signed less than
8189 @item le
8190 signed less than or equal
8191 @item o
8192 overflow flag set
8193 @item p
8194 parity flag set
8195 @item s
8196 sign flag set
8197 @item na
8198 @itemx nae
8199 @itemx nb
8200 @itemx nbe
8201 @itemx nc
8202 @itemx ne
8203 @itemx ng
8204 @itemx nge
8205 @itemx nl
8206 @itemx nle
8207 @itemx no
8208 @itemx np
8209 @itemx ns
8210 @itemx nz
8211 ``not'' @var{flag}, or inverted versions of those above
8212 @end table
8213
8214 @end table
8215
8216 @anchor{InputOperands}
8217 @subsubsection Input Operands
8218 @cindex @code{asm} input operands
8219 @cindex @code{asm} expressions
8220
8221 Input operands make values from C variables and expressions available to the
8222 assembly code.
8223
8224 Operands are separated by commas. Each operand has this format:
8225
8226 @example
8227 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8228 @end example
8229
8230 @table @var
8231 @item asmSymbolicName
8232 Specifies a symbolic name for the operand.
8233 Reference the name in the assembler template
8234 by enclosing it in square brackets
8235 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8236 that contains the definition. Any valid C variable name is acceptable,
8237 including names already defined in the surrounding code. No two operands
8238 within the same @code{asm} statement can use the same symbolic name.
8239
8240 When not using an @var{asmSymbolicName}, use the (zero-based) position
8241 of the operand
8242 in the list of operands in the assembler template. For example if there are
8243 two output operands and three inputs,
8244 use @samp{%2} in the template to refer to the first input operand,
8245 @samp{%3} for the second, and @samp{%4} for the third.
8246
8247 @item constraint
8248 A string constant specifying constraints on the placement of the operand;
8249 @xref{Constraints}, for details.
8250
8251 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8252 When you list more than one possible location (for example, @samp{"irm"}),
8253 the compiler chooses the most efficient one based on the current context.
8254 If you must use a specific register, but your Machine Constraints do not
8255 provide sufficient control to select the specific register you want,
8256 local register variables may provide a solution (@pxref{Local Register
8257 Variables}).
8258
8259 Input constraints can also be digits (for example, @code{"0"}). This indicates
8260 that the specified input must be in the same place as the output constraint
8261 at the (zero-based) index in the output constraint list.
8262 When using @var{asmSymbolicName} syntax for the output operands,
8263 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8264
8265 @item cexpression
8266 This is the C variable or expression being passed to the @code{asm} statement
8267 as input. The enclosing parentheses are a required part of the syntax.
8268
8269 @end table
8270
8271 When the compiler selects the registers to use to represent the input
8272 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8273
8274 If there are no output operands but there are input operands, place two
8275 consecutive colons where the output operands would go:
8276
8277 @example
8278 __asm__ ("some instructions"
8279 : /* No outputs. */
8280 : "r" (Offset / 8));
8281 @end example
8282
8283 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8284 (except for inputs tied to outputs). The compiler assumes that on exit from
8285 the @code{asm} statement these operands contain the same values as they
8286 had before executing the statement.
8287 It is @emph{not} possible to use clobbers
8288 to inform the compiler that the values in these inputs are changing. One
8289 common work-around is to tie the changing input variable to an output variable
8290 that never gets used. Note, however, that if the code that follows the
8291 @code{asm} statement makes no use of any of the output operands, the GCC
8292 optimizers may discard the @code{asm} statement as unneeded
8293 (see @ref{Volatile}).
8294
8295 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8296 instead of simply @samp{%2}). Typically these qualifiers are hardware
8297 dependent. The list of supported modifiers for x86 is found at
8298 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8299
8300 In this example using the fictitious @code{combine} instruction, the
8301 constraint @code{"0"} for input operand 1 says that it must occupy the same
8302 location as output operand 0. Only input operands may use numbers in
8303 constraints, and they must each refer to an output operand. Only a number (or
8304 the symbolic assembler name) in the constraint can guarantee that one operand
8305 is in the same place as another. The mere fact that @code{foo} is the value of
8306 both operands is not enough to guarantee that they are in the same place in
8307 the generated assembler code.
8308
8309 @example
8310 asm ("combine %2, %0"
8311 : "=r" (foo)
8312 : "0" (foo), "g" (bar));
8313 @end example
8314
8315 Here is an example using symbolic names.
8316
8317 @example
8318 asm ("cmoveq %1, %2, %[result]"
8319 : [result] "=r"(result)
8320 : "r" (test), "r" (new), "[result]" (old));
8321 @end example
8322
8323 @anchor{Clobbers}
8324 @subsubsection Clobbers
8325 @cindex @code{asm} clobbers
8326
8327 While the compiler is aware of changes to entries listed in the output
8328 operands, the inline @code{asm} code may modify more than just the outputs. For
8329 example, calculations may require additional registers, or the processor may
8330 overwrite a register as a side effect of a particular assembler instruction.
8331 In order to inform the compiler of these changes, list them in the clobber
8332 list. Clobber list items are either register names or the special clobbers
8333 (listed below). Each clobber list item is a string constant
8334 enclosed in double quotes and separated by commas.
8335
8336 Clobber descriptions may not in any way overlap with an input or output
8337 operand. For example, you may not have an operand describing a register class
8338 with one member when listing that register in the clobber list. Variables
8339 declared to live in specific registers (@pxref{Explicit Register
8340 Variables}) and used
8341 as @code{asm} input or output operands must have no part mentioned in the
8342 clobber description. In particular, there is no way to specify that input
8343 operands get modified without also specifying them as output operands.
8344
8345 When the compiler selects which registers to use to represent input and output
8346 operands, it does not use any of the clobbered registers. As a result,
8347 clobbered registers are available for any use in the assembler code.
8348
8349 Here is a realistic example for the VAX showing the use of clobbered
8350 registers:
8351
8352 @example
8353 asm volatile ("movc3 %0, %1, %2"
8354 : /* No outputs. */
8355 : "g" (from), "g" (to), "g" (count)
8356 : "r0", "r1", "r2", "r3", "r4", "r5");
8357 @end example
8358
8359 Also, there are two special clobber arguments:
8360
8361 @table @code
8362 @item "cc"
8363 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8364 register. On some machines, GCC represents the condition codes as a specific
8365 hardware register; @code{"cc"} serves to name this register.
8366 On other machines, condition code handling is different,
8367 and specifying @code{"cc"} has no effect. But
8368 it is valid no matter what the target.
8369
8370 @item "memory"
8371 The @code{"memory"} clobber tells the compiler that the assembly code
8372 performs memory
8373 reads or writes to items other than those listed in the input and output
8374 operands (for example, accessing the memory pointed to by one of the input
8375 parameters). To ensure memory contains correct values, GCC may need to flush
8376 specific register values to memory before executing the @code{asm}. Further,
8377 the compiler does not assume that any values read from memory before an
8378 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8379 needed.
8380 Using the @code{"memory"} clobber effectively forms a read/write
8381 memory barrier for the compiler.
8382
8383 Note that this clobber does not prevent the @emph{processor} from doing
8384 speculative reads past the @code{asm} statement. To prevent that, you need
8385 processor-specific fence instructions.
8386
8387 Flushing registers to memory has performance implications and may be an issue
8388 for time-sensitive code. You can use a trick to avoid this if the size of
8389 the memory being accessed is known at compile time. For example, if accessing
8390 ten bytes of a string, use a memory input like:
8391
8392 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8393
8394 @end table
8395
8396 @anchor{GotoLabels}
8397 @subsubsection Goto Labels
8398 @cindex @code{asm} goto labels
8399
8400 @code{asm goto} allows assembly code to jump to one or more C labels. The
8401 @var{GotoLabels} section in an @code{asm goto} statement contains
8402 a comma-separated
8403 list of all C labels to which the assembler code may jump. GCC assumes that
8404 @code{asm} execution falls through to the next statement (if this is not the
8405 case, consider using the @code{__builtin_unreachable} intrinsic after the
8406 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8407 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8408 Attributes}).
8409
8410 An @code{asm goto} statement cannot have outputs.
8411 This is due to an internal restriction of
8412 the compiler: control transfer instructions cannot have outputs.
8413 If the assembler code does modify anything, use the @code{"memory"} clobber
8414 to force the
8415 optimizers to flush all register values to memory and reload them if
8416 necessary after the @code{asm} statement.
8417
8418 Also note that an @code{asm goto} statement is always implicitly
8419 considered volatile.
8420
8421 To reference a label in the assembler template,
8422 prefix it with @samp{%l} (lowercase @samp{L}) followed
8423 by its (zero-based) position in @var{GotoLabels} plus the number of input
8424 operands. For example, if the @code{asm} has three inputs and references two
8425 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8426
8427 Alternately, you can reference labels using the actual C label name enclosed
8428 in brackets. For example, to reference a label named @code{carry}, you can
8429 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8430 section when using this approach.
8431
8432 Here is an example of @code{asm goto} for i386:
8433
8434 @example
8435 asm goto (
8436 "btl %1, %0\n\t"
8437 "jc %l2"
8438 : /* No outputs. */
8439 : "r" (p1), "r" (p2)
8440 : "cc"
8441 : carry);
8442
8443 return 0;
8444
8445 carry:
8446 return 1;
8447 @end example
8448
8449 The following example shows an @code{asm goto} that uses a memory clobber.
8450
8451 @example
8452 int frob(int x)
8453 @{
8454 int y;
8455 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8456 : /* No outputs. */
8457 : "r"(x), "r"(&y)
8458 : "r5", "memory"
8459 : error);
8460 return y;
8461 error:
8462 return -1;
8463 @}
8464 @end example
8465
8466 @anchor{x86Operandmodifiers}
8467 @subsubsection x86 Operand Modifiers
8468
8469 References to input, output, and goto operands in the assembler template
8470 of extended @code{asm} statements can use
8471 modifiers to affect the way the operands are formatted in
8472 the code output to the assembler. For example, the
8473 following code uses the @samp{h} and @samp{b} modifiers for x86:
8474
8475 @example
8476 uint16_t num;
8477 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8478 @end example
8479
8480 @noindent
8481 These modifiers generate this assembler code:
8482
8483 @example
8484 xchg %ah, %al
8485 @end example
8486
8487 The rest of this discussion uses the following code for illustrative purposes.
8488
8489 @example
8490 int main()
8491 @{
8492 int iInt = 1;
8493
8494 top:
8495
8496 asm volatile goto ("some assembler instructions here"
8497 : /* No outputs. */
8498 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8499 : /* No clobbers. */
8500 : top);
8501 @}
8502 @end example
8503
8504 With no modifiers, this is what the output from the operands would be for the
8505 @samp{att} and @samp{intel} dialects of assembler:
8506
8507 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8508 @headitem Operand @tab masm=att @tab masm=intel
8509 @item @code{%0}
8510 @tab @code{%eax}
8511 @tab @code{eax}
8512 @item @code{%1}
8513 @tab @code{$2}
8514 @tab @code{2}
8515 @item @code{%2}
8516 @tab @code{$.L2}
8517 @tab @code{OFFSET FLAT:.L2}
8518 @end multitable
8519
8520 The table below shows the list of supported modifiers and their effects.
8521
8522 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8523 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8524 @item @code{z}
8525 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8526 @tab @code{%z0}
8527 @tab @code{l}
8528 @tab
8529 @item @code{b}
8530 @tab Print the QImode name of the register.
8531 @tab @code{%b0}
8532 @tab @code{%al}
8533 @tab @code{al}
8534 @item @code{h}
8535 @tab Print the QImode name for a ``high'' register.
8536 @tab @code{%h0}
8537 @tab @code{%ah}
8538 @tab @code{ah}
8539 @item @code{w}
8540 @tab Print the HImode name of the register.
8541 @tab @code{%w0}
8542 @tab @code{%ax}
8543 @tab @code{ax}
8544 @item @code{k}
8545 @tab Print the SImode name of the register.
8546 @tab @code{%k0}
8547 @tab @code{%eax}
8548 @tab @code{eax}
8549 @item @code{q}
8550 @tab Print the DImode name of the register.
8551 @tab @code{%q0}
8552 @tab @code{%rax}
8553 @tab @code{rax}
8554 @item @code{l}
8555 @tab Print the label name with no punctuation.
8556 @tab @code{%l2}
8557 @tab @code{.L2}
8558 @tab @code{.L2}
8559 @item @code{c}
8560 @tab Require a constant operand and print the constant expression with no punctuation.
8561 @tab @code{%c1}
8562 @tab @code{2}
8563 @tab @code{2}
8564 @end multitable
8565
8566 @anchor{x86floatingpointasmoperands}
8567 @subsubsection x86 Floating-Point @code{asm} Operands
8568
8569 On x86 targets, there are several rules on the usage of stack-like registers
8570 in the operands of an @code{asm}. These rules apply only to the operands
8571 that are stack-like registers:
8572
8573 @enumerate
8574 @item
8575 Given a set of input registers that die in an @code{asm}, it is
8576 necessary to know which are implicitly popped by the @code{asm}, and
8577 which must be explicitly popped by GCC@.
8578
8579 An input register that is implicitly popped by the @code{asm} must be
8580 explicitly clobbered, unless it is constrained to match an
8581 output operand.
8582
8583 @item
8584 For any input register that is implicitly popped by an @code{asm}, it is
8585 necessary to know how to adjust the stack to compensate for the pop.
8586 If any non-popped input is closer to the top of the reg-stack than
8587 the implicitly popped register, it would not be possible to know what the
8588 stack looked like---it's not clear how the rest of the stack ``slides
8589 up''.
8590
8591 All implicitly popped input registers must be closer to the top of
8592 the reg-stack than any input that is not implicitly popped.
8593
8594 It is possible that if an input dies in an @code{asm}, the compiler might
8595 use the input register for an output reload. Consider this example:
8596
8597 @smallexample
8598 asm ("foo" : "=t" (a) : "f" (b));
8599 @end smallexample
8600
8601 @noindent
8602 This code says that input @code{b} is not popped by the @code{asm}, and that
8603 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8604 deeper after the @code{asm} than it was before. But, it is possible that
8605 reload may think that it can use the same register for both the input and
8606 the output.
8607
8608 To prevent this from happening,
8609 if any input operand uses the @samp{f} constraint, all output register
8610 constraints must use the @samp{&} early-clobber modifier.
8611
8612 The example above is correctly written as:
8613
8614 @smallexample
8615 asm ("foo" : "=&t" (a) : "f" (b));
8616 @end smallexample
8617
8618 @item
8619 Some operands need to be in particular places on the stack. All
8620 output operands fall in this category---GCC has no other way to
8621 know which registers the outputs appear in unless you indicate
8622 this in the constraints.
8623
8624 Output operands must specifically indicate which register an output
8625 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8626 constraints must select a class with a single register.
8627
8628 @item
8629 Output operands may not be ``inserted'' between existing stack registers.
8630 Since no 387 opcode uses a read/write operand, all output operands
8631 are dead before the @code{asm}, and are pushed by the @code{asm}.
8632 It makes no sense to push anywhere but the top of the reg-stack.
8633
8634 Output operands must start at the top of the reg-stack: output
8635 operands may not ``skip'' a register.
8636
8637 @item
8638 Some @code{asm} statements may need extra stack space for internal
8639 calculations. This can be guaranteed by clobbering stack registers
8640 unrelated to the inputs and outputs.
8641
8642 @end enumerate
8643
8644 This @code{asm}
8645 takes one input, which is internally popped, and produces two outputs.
8646
8647 @smallexample
8648 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8649 @end smallexample
8650
8651 @noindent
8652 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8653 and replaces them with one output. The @code{st(1)} clobber is necessary
8654 for the compiler to know that @code{fyl2xp1} pops both inputs.
8655
8656 @smallexample
8657 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8658 @end smallexample
8659
8660 @lowersections
8661 @include md.texi
8662 @raisesections
8663
8664 @node Asm Labels
8665 @subsection Controlling Names Used in Assembler Code
8666 @cindex assembler names for identifiers
8667 @cindex names used in assembler code
8668 @cindex identifiers, names in assembler code
8669
8670 You can specify the name to be used in the assembler code for a C
8671 function or variable by writing the @code{asm} (or @code{__asm__})
8672 keyword after the declarator.
8673 It is up to you to make sure that the assembler names you choose do not
8674 conflict with any other assembler symbols, or reference registers.
8675
8676 @subsubheading Assembler names for data:
8677
8678 This sample shows how to specify the assembler name for data:
8679
8680 @smallexample
8681 int foo asm ("myfoo") = 2;
8682 @end smallexample
8683
8684 @noindent
8685 This specifies that the name to be used for the variable @code{foo} in
8686 the assembler code should be @samp{myfoo} rather than the usual
8687 @samp{_foo}.
8688
8689 On systems where an underscore is normally prepended to the name of a C
8690 variable, this feature allows you to define names for the
8691 linker that do not start with an underscore.
8692
8693 GCC does not support using this feature with a non-static local variable
8694 since such variables do not have assembler names. If you are
8695 trying to put the variable in a particular register, see
8696 @ref{Explicit Register Variables}.
8697
8698 @subsubheading Assembler names for functions:
8699
8700 To specify the assembler name for functions, write a declaration for the
8701 function before its definition and put @code{asm} there, like this:
8702
8703 @smallexample
8704 int func (int x, int y) asm ("MYFUNC");
8705
8706 int func (int x, int y)
8707 @{
8708 /* @r{@dots{}} */
8709 @end smallexample
8710
8711 @noindent
8712 This specifies that the name to be used for the function @code{func} in
8713 the assembler code should be @code{MYFUNC}.
8714
8715 @node Explicit Register Variables
8716 @subsection Variables in Specified Registers
8717 @anchor{Explicit Reg Vars}
8718 @cindex explicit register variables
8719 @cindex variables in specified registers
8720 @cindex specified registers
8721
8722 GNU C allows you to associate specific hardware registers with C
8723 variables. In almost all cases, allowing the compiler to assign
8724 registers produces the best code. However under certain unusual
8725 circumstances, more precise control over the variable storage is
8726 required.
8727
8728 Both global and local variables can be associated with a register. The
8729 consequences of performing this association are very different between
8730 the two, as explained in the sections below.
8731
8732 @menu
8733 * Global Register Variables:: Variables declared at global scope.
8734 * Local Register Variables:: Variables declared within a function.
8735 @end menu
8736
8737 @node Global Register Variables
8738 @subsubsection Defining Global Register Variables
8739 @anchor{Global Reg Vars}
8740 @cindex global register variables
8741 @cindex registers, global variables in
8742 @cindex registers, global allocation
8743
8744 You can define a global register variable and associate it with a specified
8745 register like this:
8746
8747 @smallexample
8748 register int *foo asm ("r12");
8749 @end smallexample
8750
8751 @noindent
8752 Here @code{r12} is the name of the register that should be used. Note that
8753 this is the same syntax used for defining local register variables, but for
8754 a global variable the declaration appears outside a function. The
8755 @code{register} keyword is required, and cannot be combined with
8756 @code{static}. The register name must be a valid register name for the
8757 target platform.
8758
8759 Registers are a scarce resource on most systems and allowing the
8760 compiler to manage their usage usually results in the best code. However,
8761 under special circumstances it can make sense to reserve some globally.
8762 For example this may be useful in programs such as programming language
8763 interpreters that have a couple of global variables that are accessed
8764 very often.
8765
8766 After defining a global register variable, for the current compilation
8767 unit:
8768
8769 @itemize @bullet
8770 @item The register is reserved entirely for this use, and will not be
8771 allocated for any other purpose.
8772 @item The register is not saved and restored by any functions.
8773 @item Stores into this register are never deleted even if they appear to be
8774 dead, but references may be deleted, moved or simplified.
8775 @end itemize
8776
8777 Note that these points @emph{only} apply to code that is compiled with the
8778 definition. The behavior of code that is merely linked in (for example
8779 code from libraries) is not affected.
8780
8781 If you want to recompile source files that do not actually use your global
8782 register variable so they do not use the specified register for any other
8783 purpose, you need not actually add the global register declaration to
8784 their source code. It suffices to specify the compiler option
8785 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8786 register.
8787
8788 @subsubheading Declaring the variable
8789
8790 Global register variables can not have initial values, because an
8791 executable file has no means to supply initial contents for a register.
8792
8793 When selecting a register, choose one that is normally saved and
8794 restored by function calls on your machine. This ensures that code
8795 which is unaware of this reservation (such as library routines) will
8796 restore it before returning.
8797
8798 On machines with register windows, be sure to choose a global
8799 register that is not affected magically by the function call mechanism.
8800
8801 @subsubheading Using the variable
8802
8803 @cindex @code{qsort}, and global register variables
8804 When calling routines that are not aware of the reservation, be
8805 cautious if those routines call back into code which uses them. As an
8806 example, if you call the system library version of @code{qsort}, it may
8807 clobber your registers during execution, but (if you have selected
8808 appropriate registers) it will restore them before returning. However
8809 it will @emph{not} restore them before calling @code{qsort}'s comparison
8810 function. As a result, global values will not reliably be available to
8811 the comparison function unless the @code{qsort} function itself is rebuilt.
8812
8813 Similarly, it is not safe to access the global register variables from signal
8814 handlers or from more than one thread of control. Unless you recompile
8815 them specially for the task at hand, the system library routines may
8816 temporarily use the register for other things.
8817
8818 @cindex register variable after @code{longjmp}
8819 @cindex global register after @code{longjmp}
8820 @cindex value after @code{longjmp}
8821 @findex longjmp
8822 @findex setjmp
8823 On most machines, @code{longjmp} restores to each global register
8824 variable the value it had at the time of the @code{setjmp}. On some
8825 machines, however, @code{longjmp} does not change the value of global
8826 register variables. To be portable, the function that called @code{setjmp}
8827 should make other arrangements to save the values of the global register
8828 variables, and to restore them in a @code{longjmp}. This way, the same
8829 thing happens regardless of what @code{longjmp} does.
8830
8831 Eventually there may be a way of asking the compiler to choose a register
8832 automatically, but first we need to figure out how it should choose and
8833 how to enable you to guide the choice. No solution is evident.
8834
8835 @node Local Register Variables
8836 @subsubsection Specifying Registers for Local Variables
8837 @anchor{Local Reg Vars}
8838 @cindex local variables, specifying registers
8839 @cindex specifying registers for local variables
8840 @cindex registers for local variables
8841
8842 You can define a local register variable and associate it with a specified
8843 register like this:
8844
8845 @smallexample
8846 register int *foo asm ("r12");
8847 @end smallexample
8848
8849 @noindent
8850 Here @code{r12} is the name of the register that should be used. Note
8851 that this is the same syntax used for defining global register variables,
8852 but for a local variable the declaration appears within a function. The
8853 @code{register} keyword is required, and cannot be combined with
8854 @code{static}. The register name must be a valid register name for the
8855 target platform.
8856
8857 As with global register variables, it is recommended that you choose
8858 a register that is normally saved and restored by function calls on your
8859 machine, so that calls to library routines will not clobber it.
8860
8861 The only supported use for this feature is to specify registers
8862 for input and output operands when calling Extended @code{asm}
8863 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8864 particular machine don't provide sufficient control to select the desired
8865 register. To force an operand into a register, create a local variable
8866 and specify the register name after the variable's declaration. Then use
8867 the local variable for the @code{asm} operand and specify any constraint
8868 letter that matches the register:
8869
8870 @smallexample
8871 register int *p1 asm ("r0") = @dots{};
8872 register int *p2 asm ("r1") = @dots{};
8873 register int *result asm ("r0");
8874 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8875 @end smallexample
8876
8877 @emph{Warning:} In the above example, be aware that a register (for example
8878 @code{r0}) can be call-clobbered by subsequent code, including function
8879 calls and library calls for arithmetic operators on other variables (for
8880 example the initialization of @code{p2}). In this case, use temporary
8881 variables for expressions between the register assignments:
8882
8883 @smallexample
8884 int t1 = @dots{};
8885 register int *p1 asm ("r0") = @dots{};
8886 register int *p2 asm ("r1") = t1;
8887 register int *result asm ("r0");
8888 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8889 @end smallexample
8890
8891 Defining a register variable does not reserve the register. Other than
8892 when invoking the Extended @code{asm}, the contents of the specified
8893 register are not guaranteed. For this reason, the following uses
8894 are explicitly @emph{not} supported. If they appear to work, it is only
8895 happenstance, and may stop working as intended due to (seemingly)
8896 unrelated changes in surrounding code, or even minor changes in the
8897 optimization of a future version of gcc:
8898
8899 @itemize @bullet
8900 @item Passing parameters to or from Basic @code{asm}
8901 @item Passing parameters to or from Extended @code{asm} without using input
8902 or output operands.
8903 @item Passing parameters to or from routines written in assembler (or
8904 other languages) using non-standard calling conventions.
8905 @end itemize
8906
8907 Some developers use Local Register Variables in an attempt to improve
8908 gcc's allocation of registers, especially in large functions. In this
8909 case the register name is essentially a hint to the register allocator.
8910 While in some instances this can generate better code, improvements are
8911 subject to the whims of the allocator/optimizers. Since there are no
8912 guarantees that your improvements won't be lost, this usage of Local
8913 Register Variables is discouraged.
8914
8915 On the MIPS platform, there is related use for local register variables
8916 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8917 Defining coprocessor specifics for MIPS targets, gccint,
8918 GNU Compiler Collection (GCC) Internals}).
8919
8920 @node Size of an asm
8921 @subsection Size of an @code{asm}
8922
8923 Some targets require that GCC track the size of each instruction used
8924 in order to generate correct code. Because the final length of the
8925 code produced by an @code{asm} statement is only known by the
8926 assembler, GCC must make an estimate as to how big it will be. It
8927 does this by counting the number of instructions in the pattern of the
8928 @code{asm} and multiplying that by the length of the longest
8929 instruction supported by that processor. (When working out the number
8930 of instructions, it assumes that any occurrence of a newline or of
8931 whatever statement separator character is supported by the assembler --
8932 typically @samp{;} --- indicates the end of an instruction.)
8933
8934 Normally, GCC's estimate is adequate to ensure that correct
8935 code is generated, but it is possible to confuse the compiler if you use
8936 pseudo instructions or assembler macros that expand into multiple real
8937 instructions, or if you use assembler directives that expand to more
8938 space in the object file than is needed for a single instruction.
8939 If this happens then the assembler may produce a diagnostic saying that
8940 a label is unreachable.
8941
8942 @node Alternate Keywords
8943 @section Alternate Keywords
8944 @cindex alternate keywords
8945 @cindex keywords, alternate
8946
8947 @option{-ansi} and the various @option{-std} options disable certain
8948 keywords. This causes trouble when you want to use GNU C extensions, or
8949 a general-purpose header file that should be usable by all programs,
8950 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8951 @code{inline} are not available in programs compiled with
8952 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8953 program compiled with @option{-std=c99} or @option{-std=c11}). The
8954 ISO C99 keyword
8955 @code{restrict} is only available when @option{-std=gnu99} (which will
8956 eventually be the default) or @option{-std=c99} (or the equivalent
8957 @option{-std=iso9899:1999}), or an option for a later standard
8958 version, is used.
8959
8960 The way to solve these problems is to put @samp{__} at the beginning and
8961 end of each problematical keyword. For example, use @code{__asm__}
8962 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8963
8964 Other C compilers won't accept these alternative keywords; if you want to
8965 compile with another compiler, you can define the alternate keywords as
8966 macros to replace them with the customary keywords. It looks like this:
8967
8968 @smallexample
8969 #ifndef __GNUC__
8970 #define __asm__ asm
8971 #endif
8972 @end smallexample
8973
8974 @findex __extension__
8975 @opindex pedantic
8976 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8977 You can
8978 prevent such warnings within one expression by writing
8979 @code{__extension__} before the expression. @code{__extension__} has no
8980 effect aside from this.
8981
8982 @node Incomplete Enums
8983 @section Incomplete @code{enum} Types
8984
8985 You can define an @code{enum} tag without specifying its possible values.
8986 This results in an incomplete type, much like what you get if you write
8987 @code{struct foo} without describing the elements. A later declaration
8988 that does specify the possible values completes the type.
8989
8990 You can't allocate variables or storage using the type while it is
8991 incomplete. However, you can work with pointers to that type.
8992
8993 This extension may not be very useful, but it makes the handling of
8994 @code{enum} more consistent with the way @code{struct} and @code{union}
8995 are handled.
8996
8997 This extension is not supported by GNU C++.
8998
8999 @node Function Names
9000 @section Function Names as Strings
9001 @cindex @code{__func__} identifier
9002 @cindex @code{__FUNCTION__} identifier
9003 @cindex @code{__PRETTY_FUNCTION__} identifier
9004
9005 GCC provides three magic constants that hold the name of the current
9006 function as a string. In C++11 and later modes, all three are treated
9007 as constant expressions and can be used in @code{constexpr} constexts.
9008 The first of these constants is @code{__func__}, which is part of
9009 the C99 standard:
9010
9011 The identifier @code{__func__} is implicitly declared by the translator
9012 as if, immediately following the opening brace of each function
9013 definition, the declaration
9014
9015 @smallexample
9016 static const char __func__[] = "function-name";
9017 @end smallexample
9018
9019 @noindent
9020 appeared, where function-name is the name of the lexically-enclosing
9021 function. This name is the unadorned name of the function. As an
9022 extension, at file (or, in C++, namespace scope), @code{__func__}
9023 evaluates to the empty string.
9024
9025 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9026 backward compatibility with old versions of GCC.
9027
9028 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9029 @code{__func__}, except that at file (or, in C++, namespace scope),
9030 it evaluates to the string @code{"top level"}. In addition, in C++,
9031 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9032 well as its bare name. For example, this program:
9033
9034 @smallexample
9035 extern "C" int printf (const char *, ...);
9036
9037 class a @{
9038 public:
9039 void sub (int i)
9040 @{
9041 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9042 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9043 @}
9044 @};
9045
9046 int
9047 main (void)
9048 @{
9049 a ax;
9050 ax.sub (0);
9051 return 0;
9052 @}
9053 @end smallexample
9054
9055 @noindent
9056 gives this output:
9057
9058 @smallexample
9059 __FUNCTION__ = sub
9060 __PRETTY_FUNCTION__ = void a::sub(int)
9061 @end smallexample
9062
9063 These identifiers are variables, not preprocessor macros, and may not
9064 be used to initialize @code{char} arrays or be concatenated with string
9065 literals.
9066
9067 @node Return Address
9068 @section Getting the Return or Frame Address of a Function
9069
9070 These functions may be used to get information about the callers of a
9071 function.
9072
9073 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9074 This function returns the return address of the current function, or of
9075 one of its callers. The @var{level} argument is number of frames to
9076 scan up the call stack. A value of @code{0} yields the return address
9077 of the current function, a value of @code{1} yields the return address
9078 of the caller of the current function, and so forth. When inlining
9079 the expected behavior is that the function returns the address of
9080 the function that is returned to. To work around this behavior use
9081 the @code{noinline} function attribute.
9082
9083 The @var{level} argument must be a constant integer.
9084
9085 On some machines it may be impossible to determine the return address of
9086 any function other than the current one; in such cases, or when the top
9087 of the stack has been reached, this function returns @code{0} or a
9088 random value. In addition, @code{__builtin_frame_address} may be used
9089 to determine if the top of the stack has been reached.
9090
9091 Additional post-processing of the returned value may be needed, see
9092 @code{__builtin_extract_return_addr}.
9093
9094 Calling this function with a nonzero argument can have unpredictable
9095 effects, including crashing the calling program. As a result, calls
9096 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9097 option is in effect. Such calls should only be made in debugging
9098 situations.
9099 @end deftypefn
9100
9101 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9102 The address as returned by @code{__builtin_return_address} may have to be fed
9103 through this function to get the actual encoded address. For example, on the
9104 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9105 platforms an offset has to be added for the true next instruction to be
9106 executed.
9107
9108 If no fixup is needed, this function simply passes through @var{addr}.
9109 @end deftypefn
9110
9111 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9112 This function does the reverse of @code{__builtin_extract_return_addr}.
9113 @end deftypefn
9114
9115 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9116 This function is similar to @code{__builtin_return_address}, but it
9117 returns the address of the function frame rather than the return address
9118 of the function. Calling @code{__builtin_frame_address} with a value of
9119 @code{0} yields the frame address of the current function, a value of
9120 @code{1} yields the frame address of the caller of the current function,
9121 and so forth.
9122
9123 The frame is the area on the stack that holds local variables and saved
9124 registers. The frame address is normally the address of the first word
9125 pushed on to the stack by the function. However, the exact definition
9126 depends upon the processor and the calling convention. If the processor
9127 has a dedicated frame pointer register, and the function has a frame,
9128 then @code{__builtin_frame_address} returns the value of the frame
9129 pointer register.
9130
9131 On some machines it may be impossible to determine the frame address of
9132 any function other than the current one; in such cases, or when the top
9133 of the stack has been reached, this function returns @code{0} if
9134 the first frame pointer is properly initialized by the startup code.
9135
9136 Calling this function with a nonzero argument can have unpredictable
9137 effects, including crashing the calling program. As a result, calls
9138 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9139 option is in effect. Such calls should only be made in debugging
9140 situations.
9141 @end deftypefn
9142
9143 @node Vector Extensions
9144 @section Using Vector Instructions through Built-in Functions
9145
9146 On some targets, the instruction set contains SIMD vector instructions which
9147 operate on multiple values contained in one large register at the same time.
9148 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9149 this way.
9150
9151 The first step in using these extensions is to provide the necessary data
9152 types. This should be done using an appropriate @code{typedef}:
9153
9154 @smallexample
9155 typedef int v4si __attribute__ ((vector_size (16)));
9156 @end smallexample
9157
9158 @noindent
9159 The @code{int} type specifies the base type, while the attribute specifies
9160 the vector size for the variable, measured in bytes. For example, the
9161 declaration above causes the compiler to set the mode for the @code{v4si}
9162 type to be 16 bytes wide and divided into @code{int} sized units. For
9163 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9164 corresponding mode of @code{foo} is @acronym{V4SI}.
9165
9166 The @code{vector_size} attribute is only applicable to integral and
9167 float scalars, although arrays, pointers, and function return values
9168 are allowed in conjunction with this construct. Only sizes that are
9169 a power of two are currently allowed.
9170
9171 All the basic integer types can be used as base types, both as signed
9172 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9173 @code{long long}. In addition, @code{float} and @code{double} can be
9174 used to build floating-point vector types.
9175
9176 Specifying a combination that is not valid for the current architecture
9177 causes GCC to synthesize the instructions using a narrower mode.
9178 For example, if you specify a variable of type @code{V4SI} and your
9179 architecture does not allow for this specific SIMD type, GCC
9180 produces code that uses 4 @code{SIs}.
9181
9182 The types defined in this manner can be used with a subset of normal C
9183 operations. Currently, GCC allows using the following operators
9184 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9185
9186 The operations behave like C++ @code{valarrays}. Addition is defined as
9187 the addition of the corresponding elements of the operands. For
9188 example, in the code below, each of the 4 elements in @var{a} is
9189 added to the corresponding 4 elements in @var{b} and the resulting
9190 vector is stored in @var{c}.
9191
9192 @smallexample
9193 typedef int v4si __attribute__ ((vector_size (16)));
9194
9195 v4si a, b, c;
9196
9197 c = a + b;
9198 @end smallexample
9199
9200 Subtraction, multiplication, division, and the logical operations
9201 operate in a similar manner. Likewise, the result of using the unary
9202 minus or complement operators on a vector type is a vector whose
9203 elements are the negative or complemented values of the corresponding
9204 elements in the operand.
9205
9206 It is possible to use shifting operators @code{<<}, @code{>>} on
9207 integer-type vectors. The operation is defined as following: @code{@{a0,
9208 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9209 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9210 elements.
9211
9212 For convenience, it is allowed to use a binary vector operation
9213 where one operand is a scalar. In that case the compiler transforms
9214 the scalar operand into a vector where each element is the scalar from
9215 the operation. The transformation happens only if the scalar could be
9216 safely converted to the vector-element type.
9217 Consider the following code.
9218
9219 @smallexample
9220 typedef int v4si __attribute__ ((vector_size (16)));
9221
9222 v4si a, b, c;
9223 long l;
9224
9225 a = b + 1; /* a = b + @{1,1,1,1@}; */
9226 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9227
9228 a = l + a; /* Error, cannot convert long to int. */
9229 @end smallexample
9230
9231 Vectors can be subscripted as if the vector were an array with
9232 the same number of elements and base type. Out of bound accesses
9233 invoke undefined behavior at run time. Warnings for out of bound
9234 accesses for vector subscription can be enabled with
9235 @option{-Warray-bounds}.
9236
9237 Vector comparison is supported with standard comparison
9238 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9239 vector expressions of integer-type or real-type. Comparison between
9240 integer-type vectors and real-type vectors are not supported. The
9241 result of the comparison is a vector of the same width and number of
9242 elements as the comparison operands with a signed integral element
9243 type.
9244
9245 Vectors are compared element-wise producing 0 when comparison is false
9246 and -1 (constant of the appropriate type where all bits are set)
9247 otherwise. Consider the following example.
9248
9249 @smallexample
9250 typedef int v4si __attribute__ ((vector_size (16)));
9251
9252 v4si a = @{1,2,3,4@};
9253 v4si b = @{3,2,1,4@};
9254 v4si c;
9255
9256 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9257 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9258 @end smallexample
9259
9260 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9261 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9262 integer vector with the same number of elements of the same size as @code{b}
9263 and @code{c}, computes all three arguments and creates a vector
9264 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9265 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9266 As in the case of binary operations, this syntax is also accepted when
9267 one of @code{b} or @code{c} is a scalar that is then transformed into a
9268 vector. If both @code{b} and @code{c} are scalars and the type of
9269 @code{true?b:c} has the same size as the element type of @code{a}, then
9270 @code{b} and @code{c} are converted to a vector type whose elements have
9271 this type and with the same number of elements as @code{a}.
9272
9273 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9274 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9275 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9276 For mixed operations between a scalar @code{s} and a vector @code{v},
9277 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9278 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9279
9280 Vector shuffling is available using functions
9281 @code{__builtin_shuffle (vec, mask)} and
9282 @code{__builtin_shuffle (vec0, vec1, mask)}.
9283 Both functions construct a permutation of elements from one or two
9284 vectors and return a vector of the same type as the input vector(s).
9285 The @var{mask} is an integral vector with the same width (@var{W})
9286 and element count (@var{N}) as the output vector.
9287
9288 The elements of the input vectors are numbered in memory ordering of
9289 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9290 elements of @var{mask} are considered modulo @var{N} in the single-operand
9291 case and modulo @math{2*@var{N}} in the two-operand case.
9292
9293 Consider the following example,
9294
9295 @smallexample
9296 typedef int v4si __attribute__ ((vector_size (16)));
9297
9298 v4si a = @{1,2,3,4@};
9299 v4si b = @{5,6,7,8@};
9300 v4si mask1 = @{0,1,1,3@};
9301 v4si mask2 = @{0,4,2,5@};
9302 v4si res;
9303
9304 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9305 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9306 @end smallexample
9307
9308 Note that @code{__builtin_shuffle} is intentionally semantically
9309 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9310
9311 You can declare variables and use them in function calls and returns, as
9312 well as in assignments and some casts. You can specify a vector type as
9313 a return type for a function. Vector types can also be used as function
9314 arguments. It is possible to cast from one vector type to another,
9315 provided they are of the same size (in fact, you can also cast vectors
9316 to and from other datatypes of the same size).
9317
9318 You cannot operate between vectors of different lengths or different
9319 signedness without a cast.
9320
9321 @node Offsetof
9322 @section Support for @code{offsetof}
9323 @findex __builtin_offsetof
9324
9325 GCC implements for both C and C++ a syntactic extension to implement
9326 the @code{offsetof} macro.
9327
9328 @smallexample
9329 primary:
9330 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9331
9332 offsetof_member_designator:
9333 @code{identifier}
9334 | offsetof_member_designator "." @code{identifier}
9335 | offsetof_member_designator "[" @code{expr} "]"
9336 @end smallexample
9337
9338 This extension is sufficient such that
9339
9340 @smallexample
9341 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9342 @end smallexample
9343
9344 @noindent
9345 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9346 may be dependent. In either case, @var{member} may consist of a single
9347 identifier, or a sequence of member accesses and array references.
9348
9349 @node __sync Builtins
9350 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9351
9352 The following built-in functions
9353 are intended to be compatible with those described
9354 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9355 section 7.4. As such, they depart from normal GCC practice by not using
9356 the @samp{__builtin_} prefix and also by being overloaded so that they
9357 work on multiple types.
9358
9359 The definition given in the Intel documentation allows only for the use of
9360 the types @code{int}, @code{long}, @code{long long} or their unsigned
9361 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9362 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9363 Operations on pointer arguments are performed as if the operands were
9364 of the @code{uintptr_t} type. That is, they are not scaled by the size
9365 of the type to which the pointer points.
9366
9367 These functions are implemented in terms of the @samp{__atomic}
9368 builtins (@pxref{__atomic Builtins}). They should not be used for new
9369 code which should use the @samp{__atomic} builtins instead.
9370
9371 Not all operations are supported by all target processors. If a particular
9372 operation cannot be implemented on the target processor, a warning is
9373 generated and a call to an external function is generated. The external
9374 function carries the same name as the built-in version,
9375 with an additional suffix
9376 @samp{_@var{n}} where @var{n} is the size of the data type.
9377
9378 @c ??? Should we have a mechanism to suppress this warning? This is almost
9379 @c useful for implementing the operation under the control of an external
9380 @c mutex.
9381
9382 In most cases, these built-in functions are considered a @dfn{full barrier}.
9383 That is,
9384 no memory operand is moved across the operation, either forward or
9385 backward. Further, instructions are issued as necessary to prevent the
9386 processor from speculating loads across the operation and from queuing stores
9387 after the operation.
9388
9389 All of the routines are described in the Intel documentation to take
9390 ``an optional list of variables protected by the memory barrier''. It's
9391 not clear what is meant by that; it could mean that @emph{only} the
9392 listed variables are protected, or it could mean a list of additional
9393 variables to be protected. The list is ignored by GCC which treats it as
9394 empty. GCC interprets an empty list as meaning that all globally
9395 accessible variables should be protected.
9396
9397 @table @code
9398 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9399 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9400 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9401 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9402 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9403 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9404 @findex __sync_fetch_and_add
9405 @findex __sync_fetch_and_sub
9406 @findex __sync_fetch_and_or
9407 @findex __sync_fetch_and_and
9408 @findex __sync_fetch_and_xor
9409 @findex __sync_fetch_and_nand
9410 These built-in functions perform the operation suggested by the name, and
9411 returns the value that had previously been in memory. That is, operations
9412 on integer operands have the following semantics. Operations on pointer
9413 arguments are performed as if the operands were of the @code{uintptr_t}
9414 type. That is, they are not scaled by the size of the type to which
9415 the pointer points.
9416
9417 @smallexample
9418 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9419 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9420 @end smallexample
9421
9422 The object pointed to by the first argument must be of integer or pointer
9423 type. It must not be a Boolean type.
9424
9425 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9426 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9427
9428 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9429 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9430 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9431 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9432 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9433 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9434 @findex __sync_add_and_fetch
9435 @findex __sync_sub_and_fetch
9436 @findex __sync_or_and_fetch
9437 @findex __sync_and_and_fetch
9438 @findex __sync_xor_and_fetch
9439 @findex __sync_nand_and_fetch
9440 These built-in functions perform the operation suggested by the name, and
9441 return the new value. That is, operations on integer operands have
9442 the following semantics. Operations on pointer operands are performed as
9443 if the operand's type were @code{uintptr_t}.
9444
9445 @smallexample
9446 @{ *ptr @var{op}= value; return *ptr; @}
9447 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9448 @end smallexample
9449
9450 The same constraints on arguments apply as for the corresponding
9451 @code{__sync_op_and_fetch} built-in functions.
9452
9453 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9454 as @code{*ptr = ~(*ptr & value)} instead of
9455 @code{*ptr = ~*ptr & value}.
9456
9457 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9458 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9459 @findex __sync_bool_compare_and_swap
9460 @findex __sync_val_compare_and_swap
9461 These built-in functions perform an atomic compare and swap.
9462 That is, if the current
9463 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9464 @code{*@var{ptr}}.
9465
9466 The ``bool'' version returns true if the comparison is successful and
9467 @var{newval} is written. The ``val'' version returns the contents
9468 of @code{*@var{ptr}} before the operation.
9469
9470 @item __sync_synchronize (...)
9471 @findex __sync_synchronize
9472 This built-in function issues a full memory barrier.
9473
9474 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9475 @findex __sync_lock_test_and_set
9476 This built-in function, as described by Intel, is not a traditional test-and-set
9477 operation, but rather an atomic exchange operation. It writes @var{value}
9478 into @code{*@var{ptr}}, and returns the previous contents of
9479 @code{*@var{ptr}}.
9480
9481 Many targets have only minimal support for such locks, and do not support
9482 a full exchange operation. In this case, a target may support reduced
9483 functionality here by which the @emph{only} valid value to store is the
9484 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9485 is implementation defined.
9486
9487 This built-in function is not a full barrier,
9488 but rather an @dfn{acquire barrier}.
9489 This means that references after the operation cannot move to (or be
9490 speculated to) before the operation, but previous memory stores may not
9491 be globally visible yet, and previous memory loads may not yet be
9492 satisfied.
9493
9494 @item void __sync_lock_release (@var{type} *ptr, ...)
9495 @findex __sync_lock_release
9496 This built-in function releases the lock acquired by
9497 @code{__sync_lock_test_and_set}.
9498 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9499
9500 This built-in function is not a full barrier,
9501 but rather a @dfn{release barrier}.
9502 This means that all previous memory stores are globally visible, and all
9503 previous memory loads have been satisfied, but following memory reads
9504 are not prevented from being speculated to before the barrier.
9505 @end table
9506
9507 @node __atomic Builtins
9508 @section Built-in Functions for Memory Model Aware Atomic Operations
9509
9510 The following built-in functions approximately match the requirements
9511 for the C++11 memory model. They are all
9512 identified by being prefixed with @samp{__atomic} and most are
9513 overloaded so that they work with multiple types.
9514
9515 These functions are intended to replace the legacy @samp{__sync}
9516 builtins. The main difference is that the memory order that is requested
9517 is a parameter to the functions. New code should always use the
9518 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9519
9520 Note that the @samp{__atomic} builtins assume that programs will
9521 conform to the C++11 memory model. In particular, they assume
9522 that programs are free of data races. See the C++11 standard for
9523 detailed requirements.
9524
9525 The @samp{__atomic} builtins can be used with any integral scalar or
9526 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9527 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9528 supported by the architecture.
9529
9530 The four non-arithmetic functions (load, store, exchange, and
9531 compare_exchange) all have a generic version as well. This generic
9532 version works on any data type. It uses the lock-free built-in function
9533 if the specific data type size makes that possible; otherwise, an
9534 external call is left to be resolved at run time. This external call is
9535 the same format with the addition of a @samp{size_t} parameter inserted
9536 as the first parameter indicating the size of the object being pointed to.
9537 All objects must be the same size.
9538
9539 There are 6 different memory orders that can be specified. These map
9540 to the C++11 memory orders with the same names, see the C++11 standard
9541 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9542 on atomic synchronization} for detailed definitions. Individual
9543 targets may also support additional memory orders for use on specific
9544 architectures. Refer to the target documentation for details of
9545 these.
9546
9547 An atomic operation can both constrain code motion and
9548 be mapped to hardware instructions for synchronization between threads
9549 (e.g., a fence). To which extent this happens is controlled by the
9550 memory orders, which are listed here in approximately ascending order of
9551 strength. The description of each memory order is only meant to roughly
9552 illustrate the effects and is not a specification; see the C++11
9553 memory model for precise semantics.
9554
9555 @table @code
9556 @item __ATOMIC_RELAXED
9557 Implies no inter-thread ordering constraints.
9558 @item __ATOMIC_CONSUME
9559 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9560 memory order because of a deficiency in C++11's semantics for
9561 @code{memory_order_consume}.
9562 @item __ATOMIC_ACQUIRE
9563 Creates an inter-thread happens-before constraint from the release (or
9564 stronger) semantic store to this acquire load. Can prevent hoisting
9565 of code to before the operation.
9566 @item __ATOMIC_RELEASE
9567 Creates an inter-thread happens-before constraint to acquire (or stronger)
9568 semantic loads that read from this release store. Can prevent sinking
9569 of code to after the operation.
9570 @item __ATOMIC_ACQ_REL
9571 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9572 @code{__ATOMIC_RELEASE}.
9573 @item __ATOMIC_SEQ_CST
9574 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9575 @end table
9576
9577 Note that in the C++11 memory model, @emph{fences} (e.g.,
9578 @samp{__atomic_thread_fence}) take effect in combination with other
9579 atomic operations on specific memory locations (e.g., atomic loads);
9580 operations on specific memory locations do not necessarily affect other
9581 operations in the same way.
9582
9583 Target architectures are encouraged to provide their own patterns for
9584 each of the atomic built-in functions. If no target is provided, the original
9585 non-memory model set of @samp{__sync} atomic built-in functions are
9586 used, along with any required synchronization fences surrounding it in
9587 order to achieve the proper behavior. Execution in this case is subject
9588 to the same restrictions as those built-in functions.
9589
9590 If there is no pattern or mechanism to provide a lock-free instruction
9591 sequence, a call is made to an external routine with the same parameters
9592 to be resolved at run time.
9593
9594 When implementing patterns for these built-in functions, the memory order
9595 parameter can be ignored as long as the pattern implements the most
9596 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9597 orders execute correctly with this memory order but they may not execute as
9598 efficiently as they could with a more appropriate implementation of the
9599 relaxed requirements.
9600
9601 Note that the C++11 standard allows for the memory order parameter to be
9602 determined at run time rather than at compile time. These built-in
9603 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9604 than invoke a runtime library call or inline a switch statement. This is
9605 standard compliant, safe, and the simplest approach for now.
9606
9607 The memory order parameter is a signed int, but only the lower 16 bits are
9608 reserved for the memory order. The remainder of the signed int is reserved
9609 for target use and should be 0. Use of the predefined atomic values
9610 ensures proper usage.
9611
9612 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9613 This built-in function implements an atomic load operation. It returns the
9614 contents of @code{*@var{ptr}}.
9615
9616 The valid memory order variants are
9617 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9618 and @code{__ATOMIC_CONSUME}.
9619
9620 @end deftypefn
9621
9622 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9623 This is the generic version of an atomic load. It returns the
9624 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9625
9626 @end deftypefn
9627
9628 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9629 This built-in function implements an atomic store operation. It writes
9630 @code{@var{val}} into @code{*@var{ptr}}.
9631
9632 The valid memory order variants are
9633 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9634
9635 @end deftypefn
9636
9637 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9638 This is the generic version of an atomic store. It stores the value
9639 of @code{*@var{val}} into @code{*@var{ptr}}.
9640
9641 @end deftypefn
9642
9643 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9644 This built-in function implements an atomic exchange operation. It writes
9645 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9646 @code{*@var{ptr}}.
9647
9648 The valid memory order variants are
9649 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9650 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9651
9652 @end deftypefn
9653
9654 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9655 This is the generic version of an atomic exchange. It stores the
9656 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9657 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9658
9659 @end deftypefn
9660
9661 @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)
9662 This built-in function implements an atomic compare and exchange operation.
9663 This compares the contents of @code{*@var{ptr}} with the contents of
9664 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9665 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9666 equal, the operation is a @emph{read} and the current contents of
9667 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9668 for weak compare_exchange, which may fail spuriously, and false for
9669 the strong variation, which never fails spuriously. Many targets
9670 only offer the strong variation and ignore the parameter. When in doubt, use
9671 the strong variation.
9672
9673 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9674 and memory is affected according to the
9675 memory order specified by @var{success_memorder}. There are no
9676 restrictions on what memory order can be used here.
9677
9678 Otherwise, false is returned and memory is affected according
9679 to @var{failure_memorder}. This memory order cannot be
9680 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9681 stronger order than that specified by @var{success_memorder}.
9682
9683 @end deftypefn
9684
9685 @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)
9686 This built-in function implements the generic version of
9687 @code{__atomic_compare_exchange}. The function is virtually identical to
9688 @code{__atomic_compare_exchange_n}, except the desired value is also a
9689 pointer.
9690
9691 @end deftypefn
9692
9693 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9694 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9695 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9696 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9697 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9698 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9699 These built-in functions perform the operation suggested by the name, and
9700 return the result of the operation. Operations on pointer arguments are
9701 performed as if the operands were of the @code{uintptr_t} type. That is,
9702 they are not scaled by the size of the type to which the pointer points.
9703
9704 @smallexample
9705 @{ *ptr @var{op}= val; return *ptr; @}
9706 @end smallexample
9707
9708 The object pointed to by the first argument must be of integer or pointer
9709 type. It must not be a Boolean type. All memory orders are valid.
9710
9711 @end deftypefn
9712
9713 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9714 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9715 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9716 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9717 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9718 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9719 These built-in functions perform the operation suggested by the name, and
9720 return the value that had previously been in @code{*@var{ptr}}. Operations
9721 on pointer arguments are performed as if the operands were of
9722 the @code{uintptr_t} type. That is, they are not scaled by the size of
9723 the type to which the pointer points.
9724
9725 @smallexample
9726 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9727 @end smallexample
9728
9729 The same constraints on arguments apply as for the corresponding
9730 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9731
9732 @end deftypefn
9733
9734 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9735
9736 This built-in function performs an atomic test-and-set operation on
9737 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9738 defined nonzero ``set'' value and the return value is @code{true} if and only
9739 if the previous contents were ``set''.
9740 It should be only used for operands of type @code{bool} or @code{char}. For
9741 other types only part of the value may be set.
9742
9743 All memory orders are valid.
9744
9745 @end deftypefn
9746
9747 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9748
9749 This built-in function performs an atomic clear operation on
9750 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9751 It should be only used for operands of type @code{bool} or @code{char} and
9752 in conjunction with @code{__atomic_test_and_set}.
9753 For other types it may only clear partially. If the type is not @code{bool}
9754 prefer using @code{__atomic_store}.
9755
9756 The valid memory order variants are
9757 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9758 @code{__ATOMIC_RELEASE}.
9759
9760 @end deftypefn
9761
9762 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9763
9764 This built-in function acts as a synchronization fence between threads
9765 based on the specified memory order.
9766
9767 All memory orders are valid.
9768
9769 @end deftypefn
9770
9771 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9772
9773 This built-in function acts as a synchronization fence between a thread
9774 and signal handlers based in the same thread.
9775
9776 All memory orders are valid.
9777
9778 @end deftypefn
9779
9780 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9781
9782 This built-in function returns true if objects of @var{size} bytes always
9783 generate lock-free atomic instructions for the target architecture.
9784 @var{size} must resolve to a compile-time constant and the result also
9785 resolves to a compile-time constant.
9786
9787 @var{ptr} is an optional pointer to the object that may be used to determine
9788 alignment. A value of 0 indicates typical alignment should be used. The
9789 compiler may also ignore this parameter.
9790
9791 @smallexample
9792 if (__atomic_always_lock_free (sizeof (long long), 0))
9793 @end smallexample
9794
9795 @end deftypefn
9796
9797 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9798
9799 This built-in function returns true if objects of @var{size} bytes always
9800 generate lock-free atomic instructions for the target architecture. If
9801 the built-in function is not known to be lock-free, a call is made to a
9802 runtime routine named @code{__atomic_is_lock_free}.
9803
9804 @var{ptr} is an optional pointer to the object that may be used to determine
9805 alignment. A value of 0 indicates typical alignment should be used. The
9806 compiler may also ignore this parameter.
9807 @end deftypefn
9808
9809 @node Integer Overflow Builtins
9810 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9811
9812 The following built-in functions allow performing simple arithmetic operations
9813 together with checking whether the operations overflowed.
9814
9815 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9816 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9817 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9818 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9819 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9820 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9821 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9822
9823 These built-in functions promote the first two operands into infinite precision signed
9824 type and perform addition on those promoted operands. The result is then
9825 cast to the type the third pointer argument points to and stored there.
9826 If the stored result is equal to the infinite precision result, the built-in
9827 functions return false, otherwise they return true. As the addition is
9828 performed in infinite signed precision, these built-in functions have fully defined
9829 behavior for all argument values.
9830
9831 The first built-in function allows arbitrary integral types for operands and
9832 the result type must be pointer to some integer type, the rest of the built-in
9833 functions have explicit integer types.
9834
9835 The compiler will attempt to use hardware instructions to implement
9836 these built-in functions where possible, like conditional jump on overflow
9837 after addition, conditional jump on carry etc.
9838
9839 @end deftypefn
9840
9841 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9842 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9843 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9844 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9845 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9846 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9847 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9848
9849 These built-in functions are similar to the add overflow checking built-in
9850 functions above, except they perform subtraction, subtract the second argument
9851 from the first one, instead of addition.
9852
9853 @end deftypefn
9854
9855 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9856 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9857 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9858 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9859 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9860 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9861 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9862
9863 These built-in functions are similar to the add overflow checking built-in
9864 functions above, except they perform multiplication, instead of addition.
9865
9866 @end deftypefn
9867
9868 @node x86 specific memory model extensions for transactional memory
9869 @section x86-Specific Memory Model Extensions for Transactional Memory
9870
9871 The x86 architecture supports additional memory ordering flags
9872 to mark lock critical sections for hardware lock elision.
9873 These must be specified in addition to an existing memory order to
9874 atomic intrinsics.
9875
9876 @table @code
9877 @item __ATOMIC_HLE_ACQUIRE
9878 Start lock elision on a lock variable.
9879 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9880 @item __ATOMIC_HLE_RELEASE
9881 End lock elision on a lock variable.
9882 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9883 @end table
9884
9885 When a lock acquire fails, it is required for good performance to abort
9886 the transaction quickly. This can be done with a @code{_mm_pause}.
9887
9888 @smallexample
9889 #include <immintrin.h> // For _mm_pause
9890
9891 int lockvar;
9892
9893 /* Acquire lock with lock elision */
9894 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9895 _mm_pause(); /* Abort failed transaction */
9896 ...
9897 /* Free lock with lock elision */
9898 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9899 @end smallexample
9900
9901 @node Object Size Checking
9902 @section Object Size Checking Built-in Functions
9903 @findex __builtin_object_size
9904 @findex __builtin___memcpy_chk
9905 @findex __builtin___mempcpy_chk
9906 @findex __builtin___memmove_chk
9907 @findex __builtin___memset_chk
9908 @findex __builtin___strcpy_chk
9909 @findex __builtin___stpcpy_chk
9910 @findex __builtin___strncpy_chk
9911 @findex __builtin___strcat_chk
9912 @findex __builtin___strncat_chk
9913 @findex __builtin___sprintf_chk
9914 @findex __builtin___snprintf_chk
9915 @findex __builtin___vsprintf_chk
9916 @findex __builtin___vsnprintf_chk
9917 @findex __builtin___printf_chk
9918 @findex __builtin___vprintf_chk
9919 @findex __builtin___fprintf_chk
9920 @findex __builtin___vfprintf_chk
9921
9922 GCC implements a limited buffer overflow protection mechanism
9923 that can prevent some buffer overflow attacks.
9924
9925 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9926 is a built-in construct that returns a constant number of bytes from
9927 @var{ptr} to the end of the object @var{ptr} pointer points to
9928 (if known at compile time). @code{__builtin_object_size} never evaluates
9929 its arguments for side-effects. If there are any side-effects in them, it
9930 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9931 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9932 point to and all of them are known at compile time, the returned number
9933 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9934 0 and minimum if nonzero. If it is not possible to determine which objects
9935 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9936 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9937 for @var{type} 2 or 3.
9938
9939 @var{type} is an integer constant from 0 to 3. If the least significant
9940 bit is clear, objects are whole variables, if it is set, a closest
9941 surrounding subobject is considered the object a pointer points to.
9942 The second bit determines if maximum or minimum of remaining bytes
9943 is computed.
9944
9945 @smallexample
9946 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9947 char *p = &var.buf1[1], *q = &var.b;
9948
9949 /* Here the object p points to is var. */
9950 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9951 /* The subobject p points to is var.buf1. */
9952 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9953 /* The object q points to is var. */
9954 assert (__builtin_object_size (q, 0)
9955 == (char *) (&var + 1) - (char *) &var.b);
9956 /* The subobject q points to is var.b. */
9957 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9958 @end smallexample
9959 @end deftypefn
9960
9961 There are built-in functions added for many common string operation
9962 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9963 built-in is provided. This built-in has an additional last argument,
9964 which is the number of bytes remaining in object the @var{dest}
9965 argument points to or @code{(size_t) -1} if the size is not known.
9966
9967 The built-in functions are optimized into the normal string functions
9968 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9969 it is known at compile time that the destination object will not
9970 be overflown. If the compiler can determine at compile time the
9971 object will be always overflown, it issues a warning.
9972
9973 The intended use can be e.g.@:
9974
9975 @smallexample
9976 #undef memcpy
9977 #define bos0(dest) __builtin_object_size (dest, 0)
9978 #define memcpy(dest, src, n) \
9979 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9980
9981 char *volatile p;
9982 char buf[10];
9983 /* It is unknown what object p points to, so this is optimized
9984 into plain memcpy - no checking is possible. */
9985 memcpy (p, "abcde", n);
9986 /* Destination is known and length too. It is known at compile
9987 time there will be no overflow. */
9988 memcpy (&buf[5], "abcde", 5);
9989 /* Destination is known, but the length is not known at compile time.
9990 This will result in __memcpy_chk call that can check for overflow
9991 at run time. */
9992 memcpy (&buf[5], "abcde", n);
9993 /* Destination is known and it is known at compile time there will
9994 be overflow. There will be a warning and __memcpy_chk call that
9995 will abort the program at run time. */
9996 memcpy (&buf[6], "abcde", 5);
9997 @end smallexample
9998
9999 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10000 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10001 @code{strcat} and @code{strncat}.
10002
10003 There are also checking built-in functions for formatted output functions.
10004 @smallexample
10005 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10006 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10007 const char *fmt, ...);
10008 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10009 va_list ap);
10010 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10011 const char *fmt, va_list ap);
10012 @end smallexample
10013
10014 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10015 etc.@: functions and can contain implementation specific flags on what
10016 additional security measures the checking function might take, such as
10017 handling @code{%n} differently.
10018
10019 The @var{os} argument is the object size @var{s} points to, like in the
10020 other built-in functions. There is a small difference in the behavior
10021 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10022 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10023 the checking function is called with @var{os} argument set to
10024 @code{(size_t) -1}.
10025
10026 In addition to this, there are checking built-in functions
10027 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10028 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10029 These have just one additional argument, @var{flag}, right before
10030 format string @var{fmt}. If the compiler is able to optimize them to
10031 @code{fputc} etc.@: functions, it does, otherwise the checking function
10032 is called and the @var{flag} argument passed to it.
10033
10034 @node Pointer Bounds Checker builtins
10035 @section Pointer Bounds Checker Built-in Functions
10036 @cindex Pointer Bounds Checker builtins
10037 @findex __builtin___bnd_set_ptr_bounds
10038 @findex __builtin___bnd_narrow_ptr_bounds
10039 @findex __builtin___bnd_copy_ptr_bounds
10040 @findex __builtin___bnd_init_ptr_bounds
10041 @findex __builtin___bnd_null_ptr_bounds
10042 @findex __builtin___bnd_store_ptr_bounds
10043 @findex __builtin___bnd_chk_ptr_lbounds
10044 @findex __builtin___bnd_chk_ptr_ubounds
10045 @findex __builtin___bnd_chk_ptr_bounds
10046 @findex __builtin___bnd_get_ptr_lbound
10047 @findex __builtin___bnd_get_ptr_ubound
10048
10049 GCC provides a set of built-in functions to control Pointer Bounds Checker
10050 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10051 even if you compile with Pointer Bounds Checker off
10052 (@option{-fno-check-pointer-bounds}).
10053 The behavior may differ in such case as documented below.
10054
10055 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10056
10057 This built-in function returns a new pointer with the value of @var{q}, and
10058 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10059 Bounds Checker off, the built-in function just returns the first argument.
10060
10061 @smallexample
10062 extern void *__wrap_malloc (size_t n)
10063 @{
10064 void *p = (void *)__real_malloc (n);
10065 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10066 return __builtin___bnd_set_ptr_bounds (p, n);
10067 @}
10068 @end smallexample
10069
10070 @end deftypefn
10071
10072 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10073
10074 This built-in function returns a new pointer with the value of @var{p}
10075 and associates it with the narrowed bounds formed by the intersection
10076 of bounds associated with @var{q} and the bounds
10077 [@var{p}, @var{p} + @var{size} - 1].
10078 With Pointer Bounds Checker off, the built-in function just returns the first
10079 argument.
10080
10081 @smallexample
10082 void init_objects (object *objs, size_t size)
10083 @{
10084 size_t i;
10085 /* Initialize objects one-by-one passing pointers with bounds of
10086 an object, not the full array of objects. */
10087 for (i = 0; i < size; i++)
10088 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10089 sizeof(object)));
10090 @}
10091 @end smallexample
10092
10093 @end deftypefn
10094
10095 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10096
10097 This built-in function returns a new pointer with the value of @var{q},
10098 and associates it with the bounds already associated with pointer @var{r}.
10099 With Pointer Bounds Checker off, the built-in function just returns the first
10100 argument.
10101
10102 @smallexample
10103 /* Here is a way to get pointer to object's field but
10104 still with the full object's bounds. */
10105 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10106 objptr);
10107 @end smallexample
10108
10109 @end deftypefn
10110
10111 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10112
10113 This built-in function returns a new pointer with the value of @var{q}, and
10114 associates it with INIT (allowing full memory access) bounds. With Pointer
10115 Bounds Checker off, the built-in function just returns the first argument.
10116
10117 @end deftypefn
10118
10119 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10120
10121 This built-in function returns a new pointer with the value of @var{q}, and
10122 associates it with NULL (allowing no memory access) bounds. With Pointer
10123 Bounds Checker off, the built-in function just returns the first argument.
10124
10125 @end deftypefn
10126
10127 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10128
10129 This built-in function stores the bounds associated with pointer @var{ptr_val}
10130 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10131 bounds from legacy code without touching the associated pointer's memory when
10132 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10133 function call is ignored.
10134
10135 @end deftypefn
10136
10137 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10138
10139 This built-in function checks if the pointer @var{q} is within the lower
10140 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10141 function call is ignored.
10142
10143 @smallexample
10144 extern void *__wrap_memset (void *dst, int c, size_t len)
10145 @{
10146 if (len > 0)
10147 @{
10148 __builtin___bnd_chk_ptr_lbounds (dst);
10149 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10150 __real_memset (dst, c, len);
10151 @}
10152 return dst;
10153 @}
10154 @end smallexample
10155
10156 @end deftypefn
10157
10158 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10159
10160 This built-in function checks if the pointer @var{q} is within the upper
10161 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10162 function call is ignored.
10163
10164 @end deftypefn
10165
10166 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10167
10168 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10169 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10170 off, the built-in function call is ignored.
10171
10172 @smallexample
10173 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10174 @{
10175 if (n > 0)
10176 @{
10177 __bnd_chk_ptr_bounds (dst, n);
10178 __bnd_chk_ptr_bounds (src, n);
10179 __real_memcpy (dst, src, n);
10180 @}
10181 return dst;
10182 @}
10183 @end smallexample
10184
10185 @end deftypefn
10186
10187 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10188
10189 This built-in function returns the lower bound associated
10190 with the pointer @var{q}, as a pointer value.
10191 This is useful for debugging using @code{printf}.
10192 With Pointer Bounds Checker off, the built-in function returns 0.
10193
10194 @smallexample
10195 void *lb = __builtin___bnd_get_ptr_lbound (q);
10196 void *ub = __builtin___bnd_get_ptr_ubound (q);
10197 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10198 @end smallexample
10199
10200 @end deftypefn
10201
10202 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10203
10204 This built-in function returns the upper bound (which is a pointer) associated
10205 with the pointer @var{q}. With Pointer Bounds Checker off,
10206 the built-in function returns -1.
10207
10208 @end deftypefn
10209
10210 @node Cilk Plus Builtins
10211 @section Cilk Plus C/C++ Language Extension Built-in Functions
10212
10213 GCC provides support for the following built-in reduction functions if Cilk Plus
10214 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10215
10216 @itemize @bullet
10217 @item @code{__sec_implicit_index}
10218 @item @code{__sec_reduce}
10219 @item @code{__sec_reduce_add}
10220 @item @code{__sec_reduce_all_nonzero}
10221 @item @code{__sec_reduce_all_zero}
10222 @item @code{__sec_reduce_any_nonzero}
10223 @item @code{__sec_reduce_any_zero}
10224 @item @code{__sec_reduce_max}
10225 @item @code{__sec_reduce_min}
10226 @item @code{__sec_reduce_max_ind}
10227 @item @code{__sec_reduce_min_ind}
10228 @item @code{__sec_reduce_mul}
10229 @item @code{__sec_reduce_mutating}
10230 @end itemize
10231
10232 Further details and examples about these built-in functions are described
10233 in the Cilk Plus language manual which can be found at
10234 @uref{http://www.cilkplus.org}.
10235
10236 @node Other Builtins
10237 @section Other Built-in Functions Provided by GCC
10238 @cindex built-in functions
10239 @findex __builtin_alloca
10240 @findex __builtin_alloca_with_align
10241 @findex __builtin_call_with_static_chain
10242 @findex __builtin_fpclassify
10243 @findex __builtin_isfinite
10244 @findex __builtin_isnormal
10245 @findex __builtin_isgreater
10246 @findex __builtin_isgreaterequal
10247 @findex __builtin_isinf_sign
10248 @findex __builtin_isless
10249 @findex __builtin_islessequal
10250 @findex __builtin_islessgreater
10251 @findex __builtin_isunordered
10252 @findex __builtin_powi
10253 @findex __builtin_powif
10254 @findex __builtin_powil
10255 @findex _Exit
10256 @findex _exit
10257 @findex abort
10258 @findex abs
10259 @findex acos
10260 @findex acosf
10261 @findex acosh
10262 @findex acoshf
10263 @findex acoshl
10264 @findex acosl
10265 @findex alloca
10266 @findex asin
10267 @findex asinf
10268 @findex asinh
10269 @findex asinhf
10270 @findex asinhl
10271 @findex asinl
10272 @findex atan
10273 @findex atan2
10274 @findex atan2f
10275 @findex atan2l
10276 @findex atanf
10277 @findex atanh
10278 @findex atanhf
10279 @findex atanhl
10280 @findex atanl
10281 @findex bcmp
10282 @findex bzero
10283 @findex cabs
10284 @findex cabsf
10285 @findex cabsl
10286 @findex cacos
10287 @findex cacosf
10288 @findex cacosh
10289 @findex cacoshf
10290 @findex cacoshl
10291 @findex cacosl
10292 @findex calloc
10293 @findex carg
10294 @findex cargf
10295 @findex cargl
10296 @findex casin
10297 @findex casinf
10298 @findex casinh
10299 @findex casinhf
10300 @findex casinhl
10301 @findex casinl
10302 @findex catan
10303 @findex catanf
10304 @findex catanh
10305 @findex catanhf
10306 @findex catanhl
10307 @findex catanl
10308 @findex cbrt
10309 @findex cbrtf
10310 @findex cbrtl
10311 @findex ccos
10312 @findex ccosf
10313 @findex ccosh
10314 @findex ccoshf
10315 @findex ccoshl
10316 @findex ccosl
10317 @findex ceil
10318 @findex ceilf
10319 @findex ceill
10320 @findex cexp
10321 @findex cexpf
10322 @findex cexpl
10323 @findex cimag
10324 @findex cimagf
10325 @findex cimagl
10326 @findex clog
10327 @findex clogf
10328 @findex clogl
10329 @findex clog10
10330 @findex clog10f
10331 @findex clog10l
10332 @findex conj
10333 @findex conjf
10334 @findex conjl
10335 @findex copysign
10336 @findex copysignf
10337 @findex copysignl
10338 @findex cos
10339 @findex cosf
10340 @findex cosh
10341 @findex coshf
10342 @findex coshl
10343 @findex cosl
10344 @findex cpow
10345 @findex cpowf
10346 @findex cpowl
10347 @findex cproj
10348 @findex cprojf
10349 @findex cprojl
10350 @findex creal
10351 @findex crealf
10352 @findex creall
10353 @findex csin
10354 @findex csinf
10355 @findex csinh
10356 @findex csinhf
10357 @findex csinhl
10358 @findex csinl
10359 @findex csqrt
10360 @findex csqrtf
10361 @findex csqrtl
10362 @findex ctan
10363 @findex ctanf
10364 @findex ctanh
10365 @findex ctanhf
10366 @findex ctanhl
10367 @findex ctanl
10368 @findex dcgettext
10369 @findex dgettext
10370 @findex drem
10371 @findex dremf
10372 @findex dreml
10373 @findex erf
10374 @findex erfc
10375 @findex erfcf
10376 @findex erfcl
10377 @findex erff
10378 @findex erfl
10379 @findex exit
10380 @findex exp
10381 @findex exp10
10382 @findex exp10f
10383 @findex exp10l
10384 @findex exp2
10385 @findex exp2f
10386 @findex exp2l
10387 @findex expf
10388 @findex expl
10389 @findex expm1
10390 @findex expm1f
10391 @findex expm1l
10392 @findex fabs
10393 @findex fabsf
10394 @findex fabsl
10395 @findex fdim
10396 @findex fdimf
10397 @findex fdiml
10398 @findex ffs
10399 @findex floor
10400 @findex floorf
10401 @findex floorl
10402 @findex fma
10403 @findex fmaf
10404 @findex fmal
10405 @findex fmax
10406 @findex fmaxf
10407 @findex fmaxl
10408 @findex fmin
10409 @findex fminf
10410 @findex fminl
10411 @findex fmod
10412 @findex fmodf
10413 @findex fmodl
10414 @findex fprintf
10415 @findex fprintf_unlocked
10416 @findex fputs
10417 @findex fputs_unlocked
10418 @findex frexp
10419 @findex frexpf
10420 @findex frexpl
10421 @findex fscanf
10422 @findex gamma
10423 @findex gammaf
10424 @findex gammal
10425 @findex gamma_r
10426 @findex gammaf_r
10427 @findex gammal_r
10428 @findex gettext
10429 @findex hypot
10430 @findex hypotf
10431 @findex hypotl
10432 @findex ilogb
10433 @findex ilogbf
10434 @findex ilogbl
10435 @findex imaxabs
10436 @findex index
10437 @findex isalnum
10438 @findex isalpha
10439 @findex isascii
10440 @findex isblank
10441 @findex iscntrl
10442 @findex isdigit
10443 @findex isgraph
10444 @findex islower
10445 @findex isprint
10446 @findex ispunct
10447 @findex isspace
10448 @findex isupper
10449 @findex iswalnum
10450 @findex iswalpha
10451 @findex iswblank
10452 @findex iswcntrl
10453 @findex iswdigit
10454 @findex iswgraph
10455 @findex iswlower
10456 @findex iswprint
10457 @findex iswpunct
10458 @findex iswspace
10459 @findex iswupper
10460 @findex iswxdigit
10461 @findex isxdigit
10462 @findex j0
10463 @findex j0f
10464 @findex j0l
10465 @findex j1
10466 @findex j1f
10467 @findex j1l
10468 @findex jn
10469 @findex jnf
10470 @findex jnl
10471 @findex labs
10472 @findex ldexp
10473 @findex ldexpf
10474 @findex ldexpl
10475 @findex lgamma
10476 @findex lgammaf
10477 @findex lgammal
10478 @findex lgamma_r
10479 @findex lgammaf_r
10480 @findex lgammal_r
10481 @findex llabs
10482 @findex llrint
10483 @findex llrintf
10484 @findex llrintl
10485 @findex llround
10486 @findex llroundf
10487 @findex llroundl
10488 @findex log
10489 @findex log10
10490 @findex log10f
10491 @findex log10l
10492 @findex log1p
10493 @findex log1pf
10494 @findex log1pl
10495 @findex log2
10496 @findex log2f
10497 @findex log2l
10498 @findex logb
10499 @findex logbf
10500 @findex logbl
10501 @findex logf
10502 @findex logl
10503 @findex lrint
10504 @findex lrintf
10505 @findex lrintl
10506 @findex lround
10507 @findex lroundf
10508 @findex lroundl
10509 @findex malloc
10510 @findex memchr
10511 @findex memcmp
10512 @findex memcpy
10513 @findex mempcpy
10514 @findex memset
10515 @findex modf
10516 @findex modff
10517 @findex modfl
10518 @findex nearbyint
10519 @findex nearbyintf
10520 @findex nearbyintl
10521 @findex nextafter
10522 @findex nextafterf
10523 @findex nextafterl
10524 @findex nexttoward
10525 @findex nexttowardf
10526 @findex nexttowardl
10527 @findex pow
10528 @findex pow10
10529 @findex pow10f
10530 @findex pow10l
10531 @findex powf
10532 @findex powl
10533 @findex printf
10534 @findex printf_unlocked
10535 @findex putchar
10536 @findex puts
10537 @findex remainder
10538 @findex remainderf
10539 @findex remainderl
10540 @findex remquo
10541 @findex remquof
10542 @findex remquol
10543 @findex rindex
10544 @findex rint
10545 @findex rintf
10546 @findex rintl
10547 @findex round
10548 @findex roundf
10549 @findex roundl
10550 @findex scalb
10551 @findex scalbf
10552 @findex scalbl
10553 @findex scalbln
10554 @findex scalblnf
10555 @findex scalblnf
10556 @findex scalbn
10557 @findex scalbnf
10558 @findex scanfnl
10559 @findex signbit
10560 @findex signbitf
10561 @findex signbitl
10562 @findex signbitd32
10563 @findex signbitd64
10564 @findex signbitd128
10565 @findex significand
10566 @findex significandf
10567 @findex significandl
10568 @findex sin
10569 @findex sincos
10570 @findex sincosf
10571 @findex sincosl
10572 @findex sinf
10573 @findex sinh
10574 @findex sinhf
10575 @findex sinhl
10576 @findex sinl
10577 @findex snprintf
10578 @findex sprintf
10579 @findex sqrt
10580 @findex sqrtf
10581 @findex sqrtl
10582 @findex sscanf
10583 @findex stpcpy
10584 @findex stpncpy
10585 @findex strcasecmp
10586 @findex strcat
10587 @findex strchr
10588 @findex strcmp
10589 @findex strcpy
10590 @findex strcspn
10591 @findex strdup
10592 @findex strfmon
10593 @findex strftime
10594 @findex strlen
10595 @findex strncasecmp
10596 @findex strncat
10597 @findex strncmp
10598 @findex strncpy
10599 @findex strndup
10600 @findex strpbrk
10601 @findex strrchr
10602 @findex strspn
10603 @findex strstr
10604 @findex tan
10605 @findex tanf
10606 @findex tanh
10607 @findex tanhf
10608 @findex tanhl
10609 @findex tanl
10610 @findex tgamma
10611 @findex tgammaf
10612 @findex tgammal
10613 @findex toascii
10614 @findex tolower
10615 @findex toupper
10616 @findex towlower
10617 @findex towupper
10618 @findex trunc
10619 @findex truncf
10620 @findex truncl
10621 @findex vfprintf
10622 @findex vfscanf
10623 @findex vprintf
10624 @findex vscanf
10625 @findex vsnprintf
10626 @findex vsprintf
10627 @findex vsscanf
10628 @findex y0
10629 @findex y0f
10630 @findex y0l
10631 @findex y1
10632 @findex y1f
10633 @findex y1l
10634 @findex yn
10635 @findex ynf
10636 @findex ynl
10637
10638 GCC provides a large number of built-in functions other than the ones
10639 mentioned above. Some of these are for internal use in the processing
10640 of exceptions or variable-length argument lists and are not
10641 documented here because they may change from time to time; we do not
10642 recommend general use of these functions.
10643
10644 The remaining functions are provided for optimization purposes.
10645
10646 With the exception of built-ins that have library equivalents such as
10647 the standard C library functions discussed below, or that expand to
10648 library calls, GCC built-in functions are always expanded inline and
10649 thus do not have corresponding entry points and their address cannot
10650 be obtained. Attempting to use them in an expression other than
10651 a function call results in a compile-time error.
10652
10653 @opindex fno-builtin
10654 GCC includes built-in versions of many of the functions in the standard
10655 C library. These functions come in two forms: one whose names start with
10656 the @code{__builtin_} prefix, and the other without. Both forms have the
10657 same type (including prototype), the same address (when their address is
10658 taken), and the same meaning as the C library functions even if you specify
10659 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10660 functions are only optimized in certain cases; if they are not optimized in
10661 a particular case, a call to the library function is emitted.
10662
10663 @opindex ansi
10664 @opindex std
10665 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10666 @option{-std=c99} or @option{-std=c11}), the functions
10667 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10668 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10669 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10670 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10671 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10672 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10673 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10674 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10675 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10676 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10677 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10678 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10679 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10680 @code{significandl}, @code{significand}, @code{sincosf},
10681 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10682 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10683 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10684 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10685 @code{yn}
10686 may be handled as built-in functions.
10687 All these functions have corresponding versions
10688 prefixed with @code{__builtin_}, which may be used even in strict C90
10689 mode.
10690
10691 The ISO C99 functions
10692 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10693 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10694 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10695 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10696 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10697 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10698 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10699 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10700 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10701 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10702 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10703 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10704 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10705 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10706 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10707 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10708 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10709 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10710 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10711 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10712 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10713 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10714 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10715 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10716 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10717 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10718 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10719 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10720 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10721 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10722 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10723 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10724 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10725 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10726 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10727 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10728 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10729 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10730 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10731 are handled as built-in functions
10732 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10733
10734 There are also built-in versions of the ISO C99 functions
10735 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10736 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10737 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10738 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10739 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10740 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10741 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10742 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10743 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10744 that are recognized in any mode since ISO C90 reserves these names for
10745 the purpose to which ISO C99 puts them. All these functions have
10746 corresponding versions prefixed with @code{__builtin_}.
10747
10748 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10749 @code{clog10l} which names are reserved by ISO C99 for future use.
10750 All these functions have versions prefixed with @code{__builtin_}.
10751
10752 The ISO C94 functions
10753 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10754 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10755 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10756 @code{towupper}
10757 are handled as built-in functions
10758 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10759
10760 The ISO C90 functions
10761 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10762 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10763 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10764 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10765 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10766 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10767 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10768 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10769 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10770 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10771 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10772 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10773 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10774 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10775 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10776 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10777 are all recognized as built-in functions unless
10778 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10779 is specified for an individual function). All of these functions have
10780 corresponding versions prefixed with @code{__builtin_}.
10781
10782 GCC provides built-in versions of the ISO C99 floating-point comparison
10783 macros that avoid raising exceptions for unordered operands. They have
10784 the same names as the standard macros ( @code{isgreater},
10785 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10786 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10787 prefixed. We intend for a library implementor to be able to simply
10788 @code{#define} each standard macro to its built-in equivalent.
10789 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10790 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10791 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10792 built-in functions appear both with and without the @code{__builtin_} prefix.
10793
10794 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10795 The @code{__builtin_alloca} function must be called at block scope.
10796 The function allocates an object @var{size} bytes large on the stack
10797 of the calling function. The object is aligned on the default stack
10798 alignment boundary for the target determined by the
10799 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10800 function returns a pointer to the first byte of the allocated object.
10801 The lifetime of the allocated object ends just before the calling
10802 function returns to its caller. This is so even when
10803 @code{__builtin_alloca} is called within a nested block.
10804
10805 For example, the following function allocates eight objects of @code{n}
10806 bytes each on the stack, storing a pointer to each in consecutive elements
10807 of the array @code{a}. It then passes the array to function @code{g}
10808 which can safely use the storage pointed to by each of the array elements.
10809
10810 @smallexample
10811 void f (unsigned n)
10812 @{
10813 void *a [8];
10814 for (int i = 0; i != 8; ++i)
10815 a [i] = __builtin_alloca (n);
10816
10817 g (a, n); // @r{safe}
10818 @}
10819 @end smallexample
10820
10821 Since the @code{__builtin_alloca} function doesn't validate its argument
10822 it is the responsibility of its caller to make sure the argument doesn't
10823 cause it to exceed the stack size limit.
10824 The @code{__builtin_alloca} function is provided to make it possible to
10825 allocate on the stack arrays of bytes with an upper bound that may be
10826 computed at run time. Since C99 Variable Length Arrays offer
10827 similar functionality under a portable, more convenient, and safer
10828 interface they are recommended instead, in both C99 and C++ programs
10829 where GCC provides them as an extension.
10830 @xref{Variable Length}, for details.
10831
10832 @end deftypefn
10833
10834 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10835 The @code{__builtin_alloca_with_align} function must be called at block
10836 scope. The function allocates an object @var{size} bytes large on
10837 the stack of the calling function. The allocated object is aligned on
10838 the boundary specified by the argument @var{alignment} whose unit is given
10839 in bits (not bytes). The @var{size} argument must be positive and not
10840 exceed the stack size limit. The @var{alignment} argument must be a constant
10841 integer expression that evaluates to a power of 2 greater than or equal to
10842 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10843 with other values are rejected with an error indicating the valid bounds.
10844 The function returns a pointer to the first byte of the allocated object.
10845 The lifetime of the allocated object ends at the end of the block in which
10846 the function was called. The allocated storage is released no later than
10847 just before the calling function returns to its caller, but may be released
10848 at the end of the block in which the function was called.
10849
10850 For example, in the following function the call to @code{g} is unsafe
10851 because when @code{overalign} is non-zero, the space allocated by
10852 @code{__builtin_alloca_with_align} may have been released at the end
10853 of the @code{if} statement in which it was called.
10854
10855 @smallexample
10856 void f (unsigned n, bool overalign)
10857 @{
10858 void *p;
10859 if (overalign)
10860 p = __builtin_alloca_with_align (n, 64 /* bits */);
10861 else
10862 p = __builtin_alloc (n);
10863
10864 g (p, n); // @r{unsafe}
10865 @}
10866 @end smallexample
10867
10868 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10869 @var{size} argument it is the responsibility of its caller to make sure
10870 the argument doesn't cause it to exceed the stack size limit.
10871 The @code{__builtin_alloca_with_align} function is provided to make
10872 it possible to allocate on the stack overaligned arrays of bytes with
10873 an upper bound that may be computed at run time. Since C99
10874 Variable Length Arrays offer the same functionality under
10875 a portable, more convenient, and safer interface they are recommended
10876 instead, in both C99 and C++ programs where GCC provides them as
10877 an extension. @xref{Variable Length}, for details.
10878
10879 @end deftypefn
10880
10881 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10882
10883 You can use the built-in function @code{__builtin_types_compatible_p} to
10884 determine whether two types are the same.
10885
10886 This built-in function returns 1 if the unqualified versions of the
10887 types @var{type1} and @var{type2} (which are types, not expressions) are
10888 compatible, 0 otherwise. The result of this built-in function can be
10889 used in integer constant expressions.
10890
10891 This built-in function ignores top level qualifiers (e.g., @code{const},
10892 @code{volatile}). For example, @code{int} is equivalent to @code{const
10893 int}.
10894
10895 The type @code{int[]} and @code{int[5]} are compatible. On the other
10896 hand, @code{int} and @code{char *} are not compatible, even if the size
10897 of their types, on the particular architecture are the same. Also, the
10898 amount of pointer indirection is taken into account when determining
10899 similarity. Consequently, @code{short *} is not similar to
10900 @code{short **}. Furthermore, two types that are typedefed are
10901 considered compatible if their underlying types are compatible.
10902
10903 An @code{enum} type is not considered to be compatible with another
10904 @code{enum} type even if both are compatible with the same integer
10905 type; this is what the C standard specifies.
10906 For example, @code{enum @{foo, bar@}} is not similar to
10907 @code{enum @{hot, dog@}}.
10908
10909 You typically use this function in code whose execution varies
10910 depending on the arguments' types. For example:
10911
10912 @smallexample
10913 #define foo(x) \
10914 (@{ \
10915 typeof (x) tmp = (x); \
10916 if (__builtin_types_compatible_p (typeof (x), long double)) \
10917 tmp = foo_long_double (tmp); \
10918 else if (__builtin_types_compatible_p (typeof (x), double)) \
10919 tmp = foo_double (tmp); \
10920 else if (__builtin_types_compatible_p (typeof (x), float)) \
10921 tmp = foo_float (tmp); \
10922 else \
10923 abort (); \
10924 tmp; \
10925 @})
10926 @end smallexample
10927
10928 @emph{Note:} This construct is only available for C@.
10929
10930 @end deftypefn
10931
10932 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10933
10934 The @var{call_exp} expression must be a function call, and the
10935 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10936 is passed to the function call in the target's static chain location.
10937 The result of builtin is the result of the function call.
10938
10939 @emph{Note:} This builtin is only available for C@.
10940 This builtin can be used to call Go closures from C.
10941
10942 @end deftypefn
10943
10944 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10945
10946 You can use the built-in function @code{__builtin_choose_expr} to
10947 evaluate code depending on the value of a constant expression. This
10948 built-in function returns @var{exp1} if @var{const_exp}, which is an
10949 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10950
10951 This built-in function is analogous to the @samp{? :} operator in C,
10952 except that the expression returned has its type unaltered by promotion
10953 rules. Also, the built-in function does not evaluate the expression
10954 that is not chosen. For example, if @var{const_exp} evaluates to true,
10955 @var{exp2} is not evaluated even if it has side-effects.
10956
10957 This built-in function can return an lvalue if the chosen argument is an
10958 lvalue.
10959
10960 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10961 type. Similarly, if @var{exp2} is returned, its return type is the same
10962 as @var{exp2}.
10963
10964 Example:
10965
10966 @smallexample
10967 #define foo(x) \
10968 __builtin_choose_expr ( \
10969 __builtin_types_compatible_p (typeof (x), double), \
10970 foo_double (x), \
10971 __builtin_choose_expr ( \
10972 __builtin_types_compatible_p (typeof (x), float), \
10973 foo_float (x), \
10974 /* @r{The void expression results in a compile-time error} \
10975 @r{when assigning the result to something.} */ \
10976 (void)0))
10977 @end smallexample
10978
10979 @emph{Note:} This construct is only available for C@. Furthermore, the
10980 unused expression (@var{exp1} or @var{exp2} depending on the value of
10981 @var{const_exp}) may still generate syntax errors. This may change in
10982 future revisions.
10983
10984 @end deftypefn
10985
10986 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10987
10988 The built-in function @code{__builtin_complex} is provided for use in
10989 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10990 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10991 real binary floating-point type, and the result has the corresponding
10992 complex type with real and imaginary parts @var{real} and @var{imag}.
10993 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10994 infinities, NaNs and negative zeros are involved.
10995
10996 @end deftypefn
10997
10998 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10999 You can use the built-in function @code{__builtin_constant_p} to
11000 determine if a value is known to be constant at compile time and hence
11001 that GCC can perform constant-folding on expressions involving that
11002 value. The argument of the function is the value to test. The function
11003 returns the integer 1 if the argument is known to be a compile-time
11004 constant and 0 if it is not known to be a compile-time constant. A
11005 return of 0 does not indicate that the value is @emph{not} a constant,
11006 but merely that GCC cannot prove it is a constant with the specified
11007 value of the @option{-O} option.
11008
11009 You typically use this function in an embedded application where
11010 memory is a critical resource. If you have some complex calculation,
11011 you may want it to be folded if it involves constants, but need to call
11012 a function if it does not. For example:
11013
11014 @smallexample
11015 #define Scale_Value(X) \
11016 (__builtin_constant_p (X) \
11017 ? ((X) * SCALE + OFFSET) : Scale (X))
11018 @end smallexample
11019
11020 You may use this built-in function in either a macro or an inline
11021 function. However, if you use it in an inlined function and pass an
11022 argument of the function as the argument to the built-in, GCC
11023 never returns 1 when you call the inline function with a string constant
11024 or compound literal (@pxref{Compound Literals}) and does not return 1
11025 when you pass a constant numeric value to the inline function unless you
11026 specify the @option{-O} option.
11027
11028 You may also use @code{__builtin_constant_p} in initializers for static
11029 data. For instance, you can write
11030
11031 @smallexample
11032 static const int table[] = @{
11033 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11034 /* @r{@dots{}} */
11035 @};
11036 @end smallexample
11037
11038 @noindent
11039 This is an acceptable initializer even if @var{EXPRESSION} is not a
11040 constant expression, including the case where
11041 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11042 folded to a constant but @var{EXPRESSION} contains operands that are
11043 not otherwise permitted in a static initializer (for example,
11044 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11045 built-in in this case, because it has no opportunity to perform
11046 optimization.
11047 @end deftypefn
11048
11049 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11050 @opindex fprofile-arcs
11051 You may use @code{__builtin_expect} to provide the compiler with
11052 branch prediction information. In general, you should prefer to
11053 use actual profile feedback for this (@option{-fprofile-arcs}), as
11054 programmers are notoriously bad at predicting how their programs
11055 actually perform. However, there are applications in which this
11056 data is hard to collect.
11057
11058 The return value is the value of @var{exp}, which should be an integral
11059 expression. The semantics of the built-in are that it is expected that
11060 @var{exp} == @var{c}. For example:
11061
11062 @smallexample
11063 if (__builtin_expect (x, 0))
11064 foo ();
11065 @end smallexample
11066
11067 @noindent
11068 indicates that we do not expect to call @code{foo}, since
11069 we expect @code{x} to be zero. Since you are limited to integral
11070 expressions for @var{exp}, you should use constructions such as
11071
11072 @smallexample
11073 if (__builtin_expect (ptr != NULL, 1))
11074 foo (*ptr);
11075 @end smallexample
11076
11077 @noindent
11078 when testing pointer or floating-point values.
11079 @end deftypefn
11080
11081 @deftypefn {Built-in Function} void __builtin_trap (void)
11082 This function causes the program to exit abnormally. GCC implements
11083 this function by using a target-dependent mechanism (such as
11084 intentionally executing an illegal instruction) or by calling
11085 @code{abort}. The mechanism used may vary from release to release so
11086 you should not rely on any particular implementation.
11087 @end deftypefn
11088
11089 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11090 If control flow reaches the point of the @code{__builtin_unreachable},
11091 the program is undefined. It is useful in situations where the
11092 compiler cannot deduce the unreachability of the code.
11093
11094 One such case is immediately following an @code{asm} statement that
11095 either never terminates, or one that transfers control elsewhere
11096 and never returns. In this example, without the
11097 @code{__builtin_unreachable}, GCC issues a warning that control
11098 reaches the end of a non-void function. It also generates code
11099 to return after the @code{asm}.
11100
11101 @smallexample
11102 int f (int c, int v)
11103 @{
11104 if (c)
11105 @{
11106 return v;
11107 @}
11108 else
11109 @{
11110 asm("jmp error_handler");
11111 __builtin_unreachable ();
11112 @}
11113 @}
11114 @end smallexample
11115
11116 @noindent
11117 Because the @code{asm} statement unconditionally transfers control out
11118 of the function, control never reaches the end of the function
11119 body. The @code{__builtin_unreachable} is in fact unreachable and
11120 communicates this fact to the compiler.
11121
11122 Another use for @code{__builtin_unreachable} is following a call a
11123 function that never returns but that is not declared
11124 @code{__attribute__((noreturn))}, as in this example:
11125
11126 @smallexample
11127 void function_that_never_returns (void);
11128
11129 int g (int c)
11130 @{
11131 if (c)
11132 @{
11133 return 1;
11134 @}
11135 else
11136 @{
11137 function_that_never_returns ();
11138 __builtin_unreachable ();
11139 @}
11140 @}
11141 @end smallexample
11142
11143 @end deftypefn
11144
11145 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11146 This function returns its first argument, and allows the compiler
11147 to assume that the returned pointer is at least @var{align} bytes
11148 aligned. This built-in can have either two or three arguments,
11149 if it has three, the third argument should have integer type, and
11150 if it is nonzero means misalignment offset. For example:
11151
11152 @smallexample
11153 void *x = __builtin_assume_aligned (arg, 16);
11154 @end smallexample
11155
11156 @noindent
11157 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11158 16-byte aligned, while:
11159
11160 @smallexample
11161 void *x = __builtin_assume_aligned (arg, 32, 8);
11162 @end smallexample
11163
11164 @noindent
11165 means that the compiler can assume for @code{x}, set to @code{arg}, that
11166 @code{(char *) x - 8} is 32-byte aligned.
11167 @end deftypefn
11168
11169 @deftypefn {Built-in Function} int __builtin_LINE ()
11170 This function is the equivalent of the preprocessor @code{__LINE__}
11171 macro and returns a constant integer expression that evaluates to
11172 the line number of the invocation of the built-in. When used as a C++
11173 default argument for a function @var{F}, it returns the line number
11174 of the call to @var{F}.
11175 @end deftypefn
11176
11177 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11178 This function is the equivalent of the @code{__FUNCTION__} symbol
11179 and returns an address constant pointing to the name of the function
11180 from which the built-in was invoked, or the empty string if
11181 the invocation is not at function scope. When used as a C++ default
11182 argument for a function @var{F}, it returns the name of @var{F}'s
11183 caller or the empty string if the call was not made at function
11184 scope.
11185 @end deftypefn
11186
11187 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11188 This function is the equivalent of the preprocessor @code{__FILE__}
11189 macro and returns an address constant pointing to the file name
11190 containing the invocation of the built-in, or the empty string if
11191 the invocation is not at function scope. When used as a C++ default
11192 argument for a function @var{F}, it returns the file name of the call
11193 to @var{F} or the empty string if the call was not made at function
11194 scope.
11195
11196 For example, in the following, each call to function @code{foo} will
11197 print a line similar to @code{"file.c:123: foo: message"} with the name
11198 of the file and the line number of the @code{printf} call, the name of
11199 the function @code{foo}, followed by the word @code{message}.
11200
11201 @smallexample
11202 const char*
11203 function (const char *func = __builtin_FUNCTION ())
11204 @{
11205 return func;
11206 @}
11207
11208 void foo (void)
11209 @{
11210 printf ("%s:%i: %s: message\n", file (), line (), function ());
11211 @}
11212 @end smallexample
11213
11214 @end deftypefn
11215
11216 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11217 This function is used to flush the processor's instruction cache for
11218 the region of memory between @var{begin} inclusive and @var{end}
11219 exclusive. Some targets require that the instruction cache be
11220 flushed, after modifying memory containing code, in order to obtain
11221 deterministic behavior.
11222
11223 If the target does not require instruction cache flushes,
11224 @code{__builtin___clear_cache} has no effect. Otherwise either
11225 instructions are emitted in-line to clear the instruction cache or a
11226 call to the @code{__clear_cache} function in libgcc is made.
11227 @end deftypefn
11228
11229 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11230 This function is used to minimize cache-miss latency by moving data into
11231 a cache before it is accessed.
11232 You can insert calls to @code{__builtin_prefetch} into code for which
11233 you know addresses of data in memory that is likely to be accessed soon.
11234 If the target supports them, data prefetch instructions are generated.
11235 If the prefetch is done early enough before the access then the data will
11236 be in the cache by the time it is accessed.
11237
11238 The value of @var{addr} is the address of the memory to prefetch.
11239 There are two optional arguments, @var{rw} and @var{locality}.
11240 The value of @var{rw} is a compile-time constant one or zero; one
11241 means that the prefetch is preparing for a write to the memory address
11242 and zero, the default, means that the prefetch is preparing for a read.
11243 The value @var{locality} must be a compile-time constant integer between
11244 zero and three. A value of zero means that the data has no temporal
11245 locality, so it need not be left in the cache after the access. A value
11246 of three means that the data has a high degree of temporal locality and
11247 should be left in all levels of cache possible. Values of one and two
11248 mean, respectively, a low or moderate degree of temporal locality. The
11249 default is three.
11250
11251 @smallexample
11252 for (i = 0; i < n; i++)
11253 @{
11254 a[i] = a[i] + b[i];
11255 __builtin_prefetch (&a[i+j], 1, 1);
11256 __builtin_prefetch (&b[i+j], 0, 1);
11257 /* @r{@dots{}} */
11258 @}
11259 @end smallexample
11260
11261 Data prefetch does not generate faults if @var{addr} is invalid, but
11262 the address expression itself must be valid. For example, a prefetch
11263 of @code{p->next} does not fault if @code{p->next} is not a valid
11264 address, but evaluation faults if @code{p} is not a valid address.
11265
11266 If the target does not support data prefetch, the address expression
11267 is evaluated if it includes side effects but no other code is generated
11268 and GCC does not issue a warning.
11269 @end deftypefn
11270
11271 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11272 Returns a positive infinity, if supported by the floating-point format,
11273 else @code{DBL_MAX}. This function is suitable for implementing the
11274 ISO C macro @code{HUGE_VAL}.
11275 @end deftypefn
11276
11277 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11278 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11279 @end deftypefn
11280
11281 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11282 Similar to @code{__builtin_huge_val}, except the return
11283 type is @code{long double}.
11284 @end deftypefn
11285
11286 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11287 This built-in implements the C99 fpclassify functionality. The first
11288 five int arguments should be the target library's notion of the
11289 possible FP classes and are used for return values. They must be
11290 constant values and they must appear in this order: @code{FP_NAN},
11291 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11292 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11293 to classify. GCC treats the last argument as type-generic, which
11294 means it does not do default promotion from float to double.
11295 @end deftypefn
11296
11297 @deftypefn {Built-in Function} double __builtin_inf (void)
11298 Similar to @code{__builtin_huge_val}, except a warning is generated
11299 if the target floating-point format does not support infinities.
11300 @end deftypefn
11301
11302 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11303 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11304 @end deftypefn
11305
11306 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11307 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11308 @end deftypefn
11309
11310 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11311 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11312 @end deftypefn
11313
11314 @deftypefn {Built-in Function} float __builtin_inff (void)
11315 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11316 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11317 @end deftypefn
11318
11319 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11320 Similar to @code{__builtin_inf}, except the return
11321 type is @code{long double}.
11322 @end deftypefn
11323
11324 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11325 Similar to @code{isinf}, except the return value is -1 for
11326 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11327 Note while the parameter list is an
11328 ellipsis, this function only accepts exactly one floating-point
11329 argument. GCC treats this parameter as type-generic, which means it
11330 does not do default promotion from float to double.
11331 @end deftypefn
11332
11333 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11334 This is an implementation of the ISO C99 function @code{nan}.
11335
11336 Since ISO C99 defines this function in terms of @code{strtod}, which we
11337 do not implement, a description of the parsing is in order. The string
11338 is parsed as by @code{strtol}; that is, the base is recognized by
11339 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11340 in the significand such that the least significant bit of the number
11341 is at the least significant bit of the significand. The number is
11342 truncated to fit the significand field provided. The significand is
11343 forced to be a quiet NaN@.
11344
11345 This function, if given a string literal all of which would have been
11346 consumed by @code{strtol}, is evaluated early enough that it is considered a
11347 compile-time constant.
11348 @end deftypefn
11349
11350 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11351 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11352 @end deftypefn
11353
11354 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11355 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11356 @end deftypefn
11357
11358 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11359 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11360 @end deftypefn
11361
11362 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11363 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11364 @end deftypefn
11365
11366 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11367 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11368 @end deftypefn
11369
11370 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11371 Similar to @code{__builtin_nan}, except the significand is forced
11372 to be a signaling NaN@. The @code{nans} function is proposed by
11373 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11374 @end deftypefn
11375
11376 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11377 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11378 @end deftypefn
11379
11380 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11381 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11382 @end deftypefn
11383
11384 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11385 Returns one plus the index of the least significant 1-bit of @var{x}, or
11386 if @var{x} is zero, returns zero.
11387 @end deftypefn
11388
11389 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11390 Returns the number of leading 0-bits in @var{x}, starting at the most
11391 significant bit position. If @var{x} is 0, the result is undefined.
11392 @end deftypefn
11393
11394 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11395 Returns the number of trailing 0-bits in @var{x}, starting at the least
11396 significant bit position. If @var{x} is 0, the result is undefined.
11397 @end deftypefn
11398
11399 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11400 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11401 number of bits following the most significant bit that are identical
11402 to it. There are no special cases for 0 or other values.
11403 @end deftypefn
11404
11405 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11406 Returns the number of 1-bits in @var{x}.
11407 @end deftypefn
11408
11409 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11410 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11411 modulo 2.
11412 @end deftypefn
11413
11414 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11415 Similar to @code{__builtin_ffs}, except the argument type is
11416 @code{long}.
11417 @end deftypefn
11418
11419 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11420 Similar to @code{__builtin_clz}, except the argument type is
11421 @code{unsigned long}.
11422 @end deftypefn
11423
11424 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11425 Similar to @code{__builtin_ctz}, except the argument type is
11426 @code{unsigned long}.
11427 @end deftypefn
11428
11429 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11430 Similar to @code{__builtin_clrsb}, except the argument type is
11431 @code{long}.
11432 @end deftypefn
11433
11434 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11435 Similar to @code{__builtin_popcount}, except the argument type is
11436 @code{unsigned long}.
11437 @end deftypefn
11438
11439 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11440 Similar to @code{__builtin_parity}, except the argument type is
11441 @code{unsigned long}.
11442 @end deftypefn
11443
11444 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11445 Similar to @code{__builtin_ffs}, except the argument type is
11446 @code{long long}.
11447 @end deftypefn
11448
11449 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11450 Similar to @code{__builtin_clz}, except the argument type is
11451 @code{unsigned long long}.
11452 @end deftypefn
11453
11454 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11455 Similar to @code{__builtin_ctz}, except the argument type is
11456 @code{unsigned long long}.
11457 @end deftypefn
11458
11459 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11460 Similar to @code{__builtin_clrsb}, except the argument type is
11461 @code{long long}.
11462 @end deftypefn
11463
11464 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11465 Similar to @code{__builtin_popcount}, except the argument type is
11466 @code{unsigned long long}.
11467 @end deftypefn
11468
11469 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11470 Similar to @code{__builtin_parity}, except the argument type is
11471 @code{unsigned long long}.
11472 @end deftypefn
11473
11474 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11475 Returns the first argument raised to the power of the second. Unlike the
11476 @code{pow} function no guarantees about precision and rounding are made.
11477 @end deftypefn
11478
11479 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11480 Similar to @code{__builtin_powi}, except the argument and return types
11481 are @code{float}.
11482 @end deftypefn
11483
11484 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11485 Similar to @code{__builtin_powi}, except the argument and return types
11486 are @code{long double}.
11487 @end deftypefn
11488
11489 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11490 Returns @var{x} with the order of the bytes reversed; for example,
11491 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11492 exactly 8 bits.
11493 @end deftypefn
11494
11495 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11496 Similar to @code{__builtin_bswap16}, except the argument and return types
11497 are 32 bit.
11498 @end deftypefn
11499
11500 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11501 Similar to @code{__builtin_bswap32}, except the argument and return types
11502 are 64 bit.
11503 @end deftypefn
11504
11505 @node Target Builtins
11506 @section Built-in Functions Specific to Particular Target Machines
11507
11508 On some target machines, GCC supports many built-in functions specific
11509 to those machines. Generally these generate calls to specific machine
11510 instructions, but allow the compiler to schedule those calls.
11511
11512 @menu
11513 * AArch64 Built-in Functions::
11514 * Alpha Built-in Functions::
11515 * Altera Nios II Built-in Functions::
11516 * ARC Built-in Functions::
11517 * ARC SIMD Built-in Functions::
11518 * ARM iWMMXt Built-in Functions::
11519 * ARM C Language Extensions (ACLE)::
11520 * ARM Floating Point Status and Control Intrinsics::
11521 * AVR Built-in Functions::
11522 * Blackfin Built-in Functions::
11523 * FR-V Built-in Functions::
11524 * MIPS DSP Built-in Functions::
11525 * MIPS Paired-Single Support::
11526 * MIPS Loongson Built-in Functions::
11527 * MIPS SIMD Architecture (MSA) Support::
11528 * Other MIPS Built-in Functions::
11529 * MSP430 Built-in Functions::
11530 * NDS32 Built-in Functions::
11531 * picoChip Built-in Functions::
11532 * PowerPC Built-in Functions::
11533 * PowerPC AltiVec/VSX Built-in Functions::
11534 * PowerPC Hardware Transactional Memory Built-in Functions::
11535 * RX Built-in Functions::
11536 * S/390 System z Built-in Functions::
11537 * SH Built-in Functions::
11538 * SPARC VIS Built-in Functions::
11539 * SPU Built-in Functions::
11540 * TI C6X Built-in Functions::
11541 * TILE-Gx Built-in Functions::
11542 * TILEPro Built-in Functions::
11543 * x86 Built-in Functions::
11544 * x86 transactional memory intrinsics::
11545 @end menu
11546
11547 @node AArch64 Built-in Functions
11548 @subsection AArch64 Built-in Functions
11549
11550 These built-in functions are available for the AArch64 family of
11551 processors.
11552 @smallexample
11553 unsigned int __builtin_aarch64_get_fpcr ()
11554 void __builtin_aarch64_set_fpcr (unsigned int)
11555 unsigned int __builtin_aarch64_get_fpsr ()
11556 void __builtin_aarch64_set_fpsr (unsigned int)
11557 @end smallexample
11558
11559 @node Alpha Built-in Functions
11560 @subsection Alpha Built-in Functions
11561
11562 These built-in functions are available for the Alpha family of
11563 processors, depending on the command-line switches used.
11564
11565 The following built-in functions are always available. They
11566 all generate the machine instruction that is part of the name.
11567
11568 @smallexample
11569 long __builtin_alpha_implver (void)
11570 long __builtin_alpha_rpcc (void)
11571 long __builtin_alpha_amask (long)
11572 long __builtin_alpha_cmpbge (long, long)
11573 long __builtin_alpha_extbl (long, long)
11574 long __builtin_alpha_extwl (long, long)
11575 long __builtin_alpha_extll (long, long)
11576 long __builtin_alpha_extql (long, long)
11577 long __builtin_alpha_extwh (long, long)
11578 long __builtin_alpha_extlh (long, long)
11579 long __builtin_alpha_extqh (long, long)
11580 long __builtin_alpha_insbl (long, long)
11581 long __builtin_alpha_inswl (long, long)
11582 long __builtin_alpha_insll (long, long)
11583 long __builtin_alpha_insql (long, long)
11584 long __builtin_alpha_inswh (long, long)
11585 long __builtin_alpha_inslh (long, long)
11586 long __builtin_alpha_insqh (long, long)
11587 long __builtin_alpha_mskbl (long, long)
11588 long __builtin_alpha_mskwl (long, long)
11589 long __builtin_alpha_mskll (long, long)
11590 long __builtin_alpha_mskql (long, long)
11591 long __builtin_alpha_mskwh (long, long)
11592 long __builtin_alpha_msklh (long, long)
11593 long __builtin_alpha_mskqh (long, long)
11594 long __builtin_alpha_umulh (long, long)
11595 long __builtin_alpha_zap (long, long)
11596 long __builtin_alpha_zapnot (long, long)
11597 @end smallexample
11598
11599 The following built-in functions are always with @option{-mmax}
11600 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11601 later. They all generate the machine instruction that is part
11602 of the name.
11603
11604 @smallexample
11605 long __builtin_alpha_pklb (long)
11606 long __builtin_alpha_pkwb (long)
11607 long __builtin_alpha_unpkbl (long)
11608 long __builtin_alpha_unpkbw (long)
11609 long __builtin_alpha_minub8 (long, long)
11610 long __builtin_alpha_minsb8 (long, long)
11611 long __builtin_alpha_minuw4 (long, long)
11612 long __builtin_alpha_minsw4 (long, long)
11613 long __builtin_alpha_maxub8 (long, long)
11614 long __builtin_alpha_maxsb8 (long, long)
11615 long __builtin_alpha_maxuw4 (long, long)
11616 long __builtin_alpha_maxsw4 (long, long)
11617 long __builtin_alpha_perr (long, long)
11618 @end smallexample
11619
11620 The following built-in functions are always with @option{-mcix}
11621 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11622 later. They all generate the machine instruction that is part
11623 of the name.
11624
11625 @smallexample
11626 long __builtin_alpha_cttz (long)
11627 long __builtin_alpha_ctlz (long)
11628 long __builtin_alpha_ctpop (long)
11629 @end smallexample
11630
11631 The following built-in functions are available on systems that use the OSF/1
11632 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11633 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11634 @code{rdval} and @code{wrval}.
11635
11636 @smallexample
11637 void *__builtin_thread_pointer (void)
11638 void __builtin_set_thread_pointer (void *)
11639 @end smallexample
11640
11641 @node Altera Nios II Built-in Functions
11642 @subsection Altera Nios II Built-in Functions
11643
11644 These built-in functions are available for the Altera Nios II
11645 family of processors.
11646
11647 The following built-in functions are always available. They
11648 all generate the machine instruction that is part of the name.
11649
11650 @example
11651 int __builtin_ldbio (volatile const void *)
11652 int __builtin_ldbuio (volatile const void *)
11653 int __builtin_ldhio (volatile const void *)
11654 int __builtin_ldhuio (volatile const void *)
11655 int __builtin_ldwio (volatile const void *)
11656 void __builtin_stbio (volatile void *, int)
11657 void __builtin_sthio (volatile void *, int)
11658 void __builtin_stwio (volatile void *, int)
11659 void __builtin_sync (void)
11660 int __builtin_rdctl (int)
11661 int __builtin_rdprs (int, int)
11662 void __builtin_wrctl (int, int)
11663 void __builtin_flushd (volatile void *)
11664 void __builtin_flushda (volatile void *)
11665 int __builtin_wrpie (int);
11666 void __builtin_eni (int);
11667 int __builtin_ldex (volatile const void *)
11668 int __builtin_stex (volatile void *, int)
11669 int __builtin_ldsex (volatile const void *)
11670 int __builtin_stsex (volatile void *, int)
11671 @end example
11672
11673 The following built-in functions are always available. They
11674 all generate a Nios II Custom Instruction. The name of the
11675 function represents the types that the function takes and
11676 returns. The letter before the @code{n} is the return type
11677 or void if absent. The @code{n} represents the first parameter
11678 to all the custom instructions, the custom instruction number.
11679 The two letters after the @code{n} represent the up to two
11680 parameters to the function.
11681
11682 The letters represent the following data types:
11683 @table @code
11684 @item <no letter>
11685 @code{void} for return type and no parameter for parameter types.
11686
11687 @item i
11688 @code{int} for return type and parameter type
11689
11690 @item f
11691 @code{float} for return type and parameter type
11692
11693 @item p
11694 @code{void *} for return type and parameter type
11695
11696 @end table
11697
11698 And the function names are:
11699 @example
11700 void __builtin_custom_n (void)
11701 void __builtin_custom_ni (int)
11702 void __builtin_custom_nf (float)
11703 void __builtin_custom_np (void *)
11704 void __builtin_custom_nii (int, int)
11705 void __builtin_custom_nif (int, float)
11706 void __builtin_custom_nip (int, void *)
11707 void __builtin_custom_nfi (float, int)
11708 void __builtin_custom_nff (float, float)
11709 void __builtin_custom_nfp (float, void *)
11710 void __builtin_custom_npi (void *, int)
11711 void __builtin_custom_npf (void *, float)
11712 void __builtin_custom_npp (void *, void *)
11713 int __builtin_custom_in (void)
11714 int __builtin_custom_ini (int)
11715 int __builtin_custom_inf (float)
11716 int __builtin_custom_inp (void *)
11717 int __builtin_custom_inii (int, int)
11718 int __builtin_custom_inif (int, float)
11719 int __builtin_custom_inip (int, void *)
11720 int __builtin_custom_infi (float, int)
11721 int __builtin_custom_inff (float, float)
11722 int __builtin_custom_infp (float, void *)
11723 int __builtin_custom_inpi (void *, int)
11724 int __builtin_custom_inpf (void *, float)
11725 int __builtin_custom_inpp (void *, void *)
11726 float __builtin_custom_fn (void)
11727 float __builtin_custom_fni (int)
11728 float __builtin_custom_fnf (float)
11729 float __builtin_custom_fnp (void *)
11730 float __builtin_custom_fnii (int, int)
11731 float __builtin_custom_fnif (int, float)
11732 float __builtin_custom_fnip (int, void *)
11733 float __builtin_custom_fnfi (float, int)
11734 float __builtin_custom_fnff (float, float)
11735 float __builtin_custom_fnfp (float, void *)
11736 float __builtin_custom_fnpi (void *, int)
11737 float __builtin_custom_fnpf (void *, float)
11738 float __builtin_custom_fnpp (void *, void *)
11739 void * __builtin_custom_pn (void)
11740 void * __builtin_custom_pni (int)
11741 void * __builtin_custom_pnf (float)
11742 void * __builtin_custom_pnp (void *)
11743 void * __builtin_custom_pnii (int, int)
11744 void * __builtin_custom_pnif (int, float)
11745 void * __builtin_custom_pnip (int, void *)
11746 void * __builtin_custom_pnfi (float, int)
11747 void * __builtin_custom_pnff (float, float)
11748 void * __builtin_custom_pnfp (float, void *)
11749 void * __builtin_custom_pnpi (void *, int)
11750 void * __builtin_custom_pnpf (void *, float)
11751 void * __builtin_custom_pnpp (void *, void *)
11752 @end example
11753
11754 @node ARC Built-in Functions
11755 @subsection ARC Built-in Functions
11756
11757 The following built-in functions are provided for ARC targets. The
11758 built-ins generate the corresponding assembly instructions. In the
11759 examples given below, the generated code often requires an operand or
11760 result to be in a register. Where necessary further code will be
11761 generated to ensure this is true, but for brevity this is not
11762 described in each case.
11763
11764 @emph{Note:} Using a built-in to generate an instruction not supported
11765 by a target may cause problems. At present the compiler is not
11766 guaranteed to detect such misuse, and as a result an internal compiler
11767 error may be generated.
11768
11769 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11770 Return 1 if @var{val} is known to have the byte alignment given
11771 by @var{alignval}, otherwise return 0.
11772 Note that this is different from
11773 @smallexample
11774 __alignof__(*(char *)@var{val}) >= alignval
11775 @end smallexample
11776 because __alignof__ sees only the type of the dereference, whereas
11777 __builtin_arc_align uses alignment information from the pointer
11778 as well as from the pointed-to type.
11779 The information available will depend on optimization level.
11780 @end deftypefn
11781
11782 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11783 Generates
11784 @example
11785 brk
11786 @end example
11787 @end deftypefn
11788
11789 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11790 The operand is the number of a register to be read. Generates:
11791 @example
11792 mov @var{dest}, r@var{regno}
11793 @end example
11794 where the value in @var{dest} will be the result returned from the
11795 built-in.
11796 @end deftypefn
11797
11798 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11799 The first operand is the number of a register to be written, the
11800 second operand is a compile time constant to write into that
11801 register. Generates:
11802 @example
11803 mov r@var{regno}, @var{val}
11804 @end example
11805 @end deftypefn
11806
11807 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11808 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11809 Generates:
11810 @example
11811 divaw @var{dest}, @var{a}, @var{b}
11812 @end example
11813 where the value in @var{dest} will be the result returned from the
11814 built-in.
11815 @end deftypefn
11816
11817 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11818 Generates
11819 @example
11820 flag @var{a}
11821 @end example
11822 @end deftypefn
11823
11824 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11825 The operand, @var{auxv}, is the address of an auxiliary register and
11826 must be a compile time constant. Generates:
11827 @example
11828 lr @var{dest}, [@var{auxr}]
11829 @end example
11830 Where the value in @var{dest} will be the result returned from the
11831 built-in.
11832 @end deftypefn
11833
11834 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11835 Only available with @option{-mmul64}. Generates:
11836 @example
11837 mul64 @var{a}, @var{b}
11838 @end example
11839 @end deftypefn
11840
11841 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11842 Only available with @option{-mmul64}. Generates:
11843 @example
11844 mulu64 @var{a}, @var{b}
11845 @end example
11846 @end deftypefn
11847
11848 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11849 Generates:
11850 @example
11851 nop
11852 @end example
11853 @end deftypefn
11854
11855 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11856 Only valid if the @samp{norm} instruction is available through the
11857 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11858 Generates:
11859 @example
11860 norm @var{dest}, @var{src}
11861 @end example
11862 Where the value in @var{dest} will be the result returned from the
11863 built-in.
11864 @end deftypefn
11865
11866 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11867 Only valid if the @samp{normw} instruction is available through the
11868 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11869 Generates:
11870 @example
11871 normw @var{dest}, @var{src}
11872 @end example
11873 Where the value in @var{dest} will be the result returned from the
11874 built-in.
11875 @end deftypefn
11876
11877 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11878 Generates:
11879 @example
11880 rtie
11881 @end example
11882 @end deftypefn
11883
11884 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11885 Generates:
11886 @example
11887 sleep @var{a}
11888 @end example
11889 @end deftypefn
11890
11891 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11892 The first argument, @var{auxv}, is the address of an auxiliary
11893 register, the second argument, @var{val}, is a compile time constant
11894 to be written to the register. Generates:
11895 @example
11896 sr @var{auxr}, [@var{val}]
11897 @end example
11898 @end deftypefn
11899
11900 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11901 Only valid with @option{-mswap}. Generates:
11902 @example
11903 swap @var{dest}, @var{src}
11904 @end example
11905 Where the value in @var{dest} will be the result returned from the
11906 built-in.
11907 @end deftypefn
11908
11909 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11910 Generates:
11911 @example
11912 swi
11913 @end example
11914 @end deftypefn
11915
11916 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11917 Only available with @option{-mcpu=ARC700}. Generates:
11918 @example
11919 sync
11920 @end example
11921 @end deftypefn
11922
11923 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11924 Only available with @option{-mcpu=ARC700}. Generates:
11925 @example
11926 trap_s @var{c}
11927 @end example
11928 @end deftypefn
11929
11930 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11931 Only available with @option{-mcpu=ARC700}. Generates:
11932 @example
11933 unimp_s
11934 @end example
11935 @end deftypefn
11936
11937 The instructions generated by the following builtins are not
11938 considered as candidates for scheduling. They are not moved around by
11939 the compiler during scheduling, and thus can be expected to appear
11940 where they are put in the C code:
11941 @example
11942 __builtin_arc_brk()
11943 __builtin_arc_core_read()
11944 __builtin_arc_core_write()
11945 __builtin_arc_flag()
11946 __builtin_arc_lr()
11947 __builtin_arc_sleep()
11948 __builtin_arc_sr()
11949 __builtin_arc_swi()
11950 @end example
11951
11952 @node ARC SIMD Built-in Functions
11953 @subsection ARC SIMD Built-in Functions
11954
11955 SIMD builtins provided by the compiler can be used to generate the
11956 vector instructions. This section describes the available builtins
11957 and their usage in programs. With the @option{-msimd} option, the
11958 compiler provides 128-bit vector types, which can be specified using
11959 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11960 can be included to use the following predefined types:
11961 @example
11962 typedef int __v4si __attribute__((vector_size(16)));
11963 typedef short __v8hi __attribute__((vector_size(16)));
11964 @end example
11965
11966 These types can be used to define 128-bit variables. The built-in
11967 functions listed in the following section can be used on these
11968 variables to generate the vector operations.
11969
11970 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11971 @file{arc-simd.h} also provides equivalent macros called
11972 @code{_@var{someinsn}} that can be used for programming ease and
11973 improved readability. The following macros for DMA control are also
11974 provided:
11975 @example
11976 #define _setup_dma_in_channel_reg _vdiwr
11977 #define _setup_dma_out_channel_reg _vdowr
11978 @end example
11979
11980 The following is a complete list of all the SIMD built-ins provided
11981 for ARC, grouped by calling signature.
11982
11983 The following take two @code{__v8hi} arguments and return a
11984 @code{__v8hi} result:
11985 @example
11986 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11987 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11988 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11989 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11990 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11991 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11992 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11993 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11994 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11995 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11996 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11997 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11998 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11999 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12000 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12001 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12002 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12003 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12004 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12005 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12006 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12007 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12008 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12009 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12010 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12011 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12012 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12013 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12014 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12015 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12016 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12017 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12018 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12019 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12020 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12021 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12022 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12023 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12024 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12025 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12026 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12027 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12028 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12029 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12030 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12031 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12032 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12033 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12034 @end example
12035
12036 The following take one @code{__v8hi} and one @code{int} argument and return a
12037 @code{__v8hi} result:
12038
12039 @example
12040 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12041 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12042 __v8hi __builtin_arc_vbminw (__v8hi, int)
12043 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12044 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12045 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12046 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12047 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12048 @end example
12049
12050 The following take one @code{__v8hi} argument and one @code{int} argument which
12051 must be a 3-bit compile time constant indicating a register number
12052 I0-I7. They return a @code{__v8hi} result.
12053 @example
12054 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12055 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12056 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12057 @end example
12058
12059 The following take one @code{__v8hi} argument and one @code{int}
12060 argument which must be a 6-bit compile time constant. They return a
12061 @code{__v8hi} result.
12062 @example
12063 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12064 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12065 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12066 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12067 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12068 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12069 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12070 @end example
12071
12072 The following take one @code{__v8hi} argument and one @code{int} argument which
12073 must be a 8-bit compile time constant. They return a @code{__v8hi}
12074 result.
12075 @example
12076 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12077 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12078 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12079 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12080 @end example
12081
12082 The following take two @code{int} arguments, the second of which which
12083 must be a 8-bit compile time constant. They return a @code{__v8hi}
12084 result:
12085 @example
12086 __v8hi __builtin_arc_vmovaw (int, const int)
12087 __v8hi __builtin_arc_vmovw (int, const int)
12088 __v8hi __builtin_arc_vmovzw (int, const int)
12089 @end example
12090
12091 The following take a single @code{__v8hi} argument and return a
12092 @code{__v8hi} result:
12093 @example
12094 __v8hi __builtin_arc_vabsaw (__v8hi)
12095 __v8hi __builtin_arc_vabsw (__v8hi)
12096 __v8hi __builtin_arc_vaddsuw (__v8hi)
12097 __v8hi __builtin_arc_vexch1 (__v8hi)
12098 __v8hi __builtin_arc_vexch2 (__v8hi)
12099 __v8hi __builtin_arc_vexch4 (__v8hi)
12100 __v8hi __builtin_arc_vsignw (__v8hi)
12101 __v8hi __builtin_arc_vupbaw (__v8hi)
12102 __v8hi __builtin_arc_vupbw (__v8hi)
12103 __v8hi __builtin_arc_vupsbaw (__v8hi)
12104 __v8hi __builtin_arc_vupsbw (__v8hi)
12105 @end example
12106
12107 The following take two @code{int} arguments and return no result:
12108 @example
12109 void __builtin_arc_vdirun (int, int)
12110 void __builtin_arc_vdorun (int, int)
12111 @end example
12112
12113 The following take two @code{int} arguments and return no result. The
12114 first argument must a 3-bit compile time constant indicating one of
12115 the DR0-DR7 DMA setup channels:
12116 @example
12117 void __builtin_arc_vdiwr (const int, int)
12118 void __builtin_arc_vdowr (const int, int)
12119 @end example
12120
12121 The following take an @code{int} argument and return no result:
12122 @example
12123 void __builtin_arc_vendrec (int)
12124 void __builtin_arc_vrec (int)
12125 void __builtin_arc_vrecrun (int)
12126 void __builtin_arc_vrun (int)
12127 @end example
12128
12129 The following take a @code{__v8hi} argument and two @code{int}
12130 arguments and return a @code{__v8hi} result. The second argument must
12131 be a 3-bit compile time constants, indicating one the registers I0-I7,
12132 and the third argument must be an 8-bit compile time constant.
12133
12134 @emph{Note:} Although the equivalent hardware instructions do not take
12135 an SIMD register as an operand, these builtins overwrite the relevant
12136 bits of the @code{__v8hi} register provided as the first argument with
12137 the value loaded from the @code{[Ib, u8]} location in the SDM.
12138
12139 @example
12140 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12141 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12142 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12143 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12144 @end example
12145
12146 The following take two @code{int} arguments and return a @code{__v8hi}
12147 result. The first argument must be a 3-bit compile time constants,
12148 indicating one the registers I0-I7, and the second argument must be an
12149 8-bit compile time constant.
12150
12151 @example
12152 __v8hi __builtin_arc_vld128 (const int, const int)
12153 __v8hi __builtin_arc_vld64w (const int, const int)
12154 @end example
12155
12156 The following take a @code{__v8hi} argument and two @code{int}
12157 arguments and return no result. The second argument must be a 3-bit
12158 compile time constants, indicating one the registers I0-I7, and the
12159 third argument must be an 8-bit compile time constant.
12160
12161 @example
12162 void __builtin_arc_vst128 (__v8hi, const int, const int)
12163 void __builtin_arc_vst64 (__v8hi, const int, const int)
12164 @end example
12165
12166 The following take a @code{__v8hi} argument and three @code{int}
12167 arguments and return no result. The second argument must be a 3-bit
12168 compile-time constant, identifying the 16-bit sub-register to be
12169 stored, the third argument must be a 3-bit compile time constants,
12170 indicating one the registers I0-I7, and the fourth argument must be an
12171 8-bit compile time constant.
12172
12173 @example
12174 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12175 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12176 @end example
12177
12178 @node ARM iWMMXt Built-in Functions
12179 @subsection ARM iWMMXt Built-in Functions
12180
12181 These built-in functions are available for the ARM family of
12182 processors when the @option{-mcpu=iwmmxt} switch is used:
12183
12184 @smallexample
12185 typedef int v2si __attribute__ ((vector_size (8)));
12186 typedef short v4hi __attribute__ ((vector_size (8)));
12187 typedef char v8qi __attribute__ ((vector_size (8)));
12188
12189 int __builtin_arm_getwcgr0 (void)
12190 void __builtin_arm_setwcgr0 (int)
12191 int __builtin_arm_getwcgr1 (void)
12192 void __builtin_arm_setwcgr1 (int)
12193 int __builtin_arm_getwcgr2 (void)
12194 void __builtin_arm_setwcgr2 (int)
12195 int __builtin_arm_getwcgr3 (void)
12196 void __builtin_arm_setwcgr3 (int)
12197 int __builtin_arm_textrmsb (v8qi, int)
12198 int __builtin_arm_textrmsh (v4hi, int)
12199 int __builtin_arm_textrmsw (v2si, int)
12200 int __builtin_arm_textrmub (v8qi, int)
12201 int __builtin_arm_textrmuh (v4hi, int)
12202 int __builtin_arm_textrmuw (v2si, int)
12203 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12204 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12205 v2si __builtin_arm_tinsrw (v2si, int, int)
12206 long long __builtin_arm_tmia (long long, int, int)
12207 long long __builtin_arm_tmiabb (long long, int, int)
12208 long long __builtin_arm_tmiabt (long long, int, int)
12209 long long __builtin_arm_tmiaph (long long, int, int)
12210 long long __builtin_arm_tmiatb (long long, int, int)
12211 long long __builtin_arm_tmiatt (long long, int, int)
12212 int __builtin_arm_tmovmskb (v8qi)
12213 int __builtin_arm_tmovmskh (v4hi)
12214 int __builtin_arm_tmovmskw (v2si)
12215 long long __builtin_arm_waccb (v8qi)
12216 long long __builtin_arm_wacch (v4hi)
12217 long long __builtin_arm_waccw (v2si)
12218 v8qi __builtin_arm_waddb (v8qi, v8qi)
12219 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12220 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12221 v4hi __builtin_arm_waddh (v4hi, v4hi)
12222 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12223 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12224 v2si __builtin_arm_waddw (v2si, v2si)
12225 v2si __builtin_arm_waddwss (v2si, v2si)
12226 v2si __builtin_arm_waddwus (v2si, v2si)
12227 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12228 long long __builtin_arm_wand(long long, long long)
12229 long long __builtin_arm_wandn (long long, long long)
12230 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12231 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12232 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12233 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12234 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12235 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12236 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12237 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12238 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12239 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12240 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12241 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12242 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12243 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12244 long long __builtin_arm_wmacsz (v4hi, v4hi)
12245 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12246 long long __builtin_arm_wmacuz (v4hi, v4hi)
12247 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12248 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12249 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12250 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12251 v2si __builtin_arm_wmaxsw (v2si, v2si)
12252 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12253 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12254 v2si __builtin_arm_wmaxuw (v2si, v2si)
12255 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12256 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12257 v2si __builtin_arm_wminsw (v2si, v2si)
12258 v8qi __builtin_arm_wminub (v8qi, v8qi)
12259 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12260 v2si __builtin_arm_wminuw (v2si, v2si)
12261 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12262 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12263 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12264 long long __builtin_arm_wor (long long, long long)
12265 v2si __builtin_arm_wpackdss (long long, long long)
12266 v2si __builtin_arm_wpackdus (long long, long long)
12267 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12268 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12269 v4hi __builtin_arm_wpackwss (v2si, v2si)
12270 v4hi __builtin_arm_wpackwus (v2si, v2si)
12271 long long __builtin_arm_wrord (long long, long long)
12272 long long __builtin_arm_wrordi (long long, int)
12273 v4hi __builtin_arm_wrorh (v4hi, long long)
12274 v4hi __builtin_arm_wrorhi (v4hi, int)
12275 v2si __builtin_arm_wrorw (v2si, long long)
12276 v2si __builtin_arm_wrorwi (v2si, int)
12277 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12278 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12279 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12280 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12281 v4hi __builtin_arm_wshufh (v4hi, int)
12282 long long __builtin_arm_wslld (long long, long long)
12283 long long __builtin_arm_wslldi (long long, int)
12284 v4hi __builtin_arm_wsllh (v4hi, long long)
12285 v4hi __builtin_arm_wsllhi (v4hi, int)
12286 v2si __builtin_arm_wsllw (v2si, long long)
12287 v2si __builtin_arm_wsllwi (v2si, int)
12288 long long __builtin_arm_wsrad (long long, long long)
12289 long long __builtin_arm_wsradi (long long, int)
12290 v4hi __builtin_arm_wsrah (v4hi, long long)
12291 v4hi __builtin_arm_wsrahi (v4hi, int)
12292 v2si __builtin_arm_wsraw (v2si, long long)
12293 v2si __builtin_arm_wsrawi (v2si, int)
12294 long long __builtin_arm_wsrld (long long, long long)
12295 long long __builtin_arm_wsrldi (long long, int)
12296 v4hi __builtin_arm_wsrlh (v4hi, long long)
12297 v4hi __builtin_arm_wsrlhi (v4hi, int)
12298 v2si __builtin_arm_wsrlw (v2si, long long)
12299 v2si __builtin_arm_wsrlwi (v2si, int)
12300 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12301 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12302 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12303 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12304 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12305 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12306 v2si __builtin_arm_wsubw (v2si, v2si)
12307 v2si __builtin_arm_wsubwss (v2si, v2si)
12308 v2si __builtin_arm_wsubwus (v2si, v2si)
12309 v4hi __builtin_arm_wunpckehsb (v8qi)
12310 v2si __builtin_arm_wunpckehsh (v4hi)
12311 long long __builtin_arm_wunpckehsw (v2si)
12312 v4hi __builtin_arm_wunpckehub (v8qi)
12313 v2si __builtin_arm_wunpckehuh (v4hi)
12314 long long __builtin_arm_wunpckehuw (v2si)
12315 v4hi __builtin_arm_wunpckelsb (v8qi)
12316 v2si __builtin_arm_wunpckelsh (v4hi)
12317 long long __builtin_arm_wunpckelsw (v2si)
12318 v4hi __builtin_arm_wunpckelub (v8qi)
12319 v2si __builtin_arm_wunpckeluh (v4hi)
12320 long long __builtin_arm_wunpckeluw (v2si)
12321 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12322 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12323 v2si __builtin_arm_wunpckihw (v2si, v2si)
12324 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12325 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12326 v2si __builtin_arm_wunpckilw (v2si, v2si)
12327 long long __builtin_arm_wxor (long long, long long)
12328 long long __builtin_arm_wzero ()
12329 @end smallexample
12330
12331
12332 @node ARM C Language Extensions (ACLE)
12333 @subsection ARM C Language Extensions (ACLE)
12334
12335 GCC implements extensions for C as described in the ARM C Language
12336 Extensions (ACLE) specification, which can be found at
12337 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12338
12339 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12340 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12341 intrinsics can be found at
12342 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12343 The built-in intrinsics for the Advanced SIMD extension are available when
12344 NEON is enabled.
12345
12346 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12347 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12348 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12349 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12350 intrinsics yet.
12351
12352 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12353 availability of extensions.
12354
12355 @node ARM Floating Point Status and Control Intrinsics
12356 @subsection ARM Floating Point Status and Control Intrinsics
12357
12358 These built-in functions are available for the ARM family of
12359 processors with floating-point unit.
12360
12361 @smallexample
12362 unsigned int __builtin_arm_get_fpscr ()
12363 void __builtin_arm_set_fpscr (unsigned int)
12364 @end smallexample
12365
12366 @node AVR Built-in Functions
12367 @subsection AVR Built-in Functions
12368
12369 For each built-in function for AVR, there is an equally named,
12370 uppercase built-in macro defined. That way users can easily query if
12371 or if not a specific built-in is implemented or not. For example, if
12372 @code{__builtin_avr_nop} is available the macro
12373 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12374
12375 The following built-in functions map to the respective machine
12376 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12377 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12378 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12379 as library call if no hardware multiplier is available.
12380
12381 @smallexample
12382 void __builtin_avr_nop (void)
12383 void __builtin_avr_sei (void)
12384 void __builtin_avr_cli (void)
12385 void __builtin_avr_sleep (void)
12386 void __builtin_avr_wdr (void)
12387 unsigned char __builtin_avr_swap (unsigned char)
12388 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12389 int __builtin_avr_fmuls (char, char)
12390 int __builtin_avr_fmulsu (char, unsigned char)
12391 @end smallexample
12392
12393 In order to delay execution for a specific number of cycles, GCC
12394 implements
12395 @smallexample
12396 void __builtin_avr_delay_cycles (unsigned long ticks)
12397 @end smallexample
12398
12399 @noindent
12400 @code{ticks} is the number of ticks to delay execution. Note that this
12401 built-in does not take into account the effect of interrupts that
12402 might increase delay time. @code{ticks} must be a compile-time
12403 integer constant; delays with a variable number of cycles are not supported.
12404
12405 @smallexample
12406 char __builtin_avr_flash_segment (const __memx void*)
12407 @end smallexample
12408
12409 @noindent
12410 This built-in takes a byte address to the 24-bit
12411 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12412 the number of the flash segment (the 64 KiB chunk) where the address
12413 points to. Counting starts at @code{0}.
12414 If the address does not point to flash memory, return @code{-1}.
12415
12416 @smallexample
12417 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12418 @end smallexample
12419
12420 @noindent
12421 Insert bits from @var{bits} into @var{val} and return the resulting
12422 value. The nibbles of @var{map} determine how the insertion is
12423 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12424 @enumerate
12425 @item If @var{X} is @code{0xf},
12426 then the @var{n}-th bit of @var{val} is returned unaltered.
12427
12428 @item If X is in the range 0@dots{}7,
12429 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12430
12431 @item If X is in the range 8@dots{}@code{0xe},
12432 then the @var{n}-th result bit is undefined.
12433 @end enumerate
12434
12435 @noindent
12436 One typical use case for this built-in is adjusting input and
12437 output values to non-contiguous port layouts. Some examples:
12438
12439 @smallexample
12440 // same as val, bits is unused
12441 __builtin_avr_insert_bits (0xffffffff, bits, val)
12442 @end smallexample
12443
12444 @smallexample
12445 // same as bits, val is unused
12446 __builtin_avr_insert_bits (0x76543210, bits, val)
12447 @end smallexample
12448
12449 @smallexample
12450 // same as rotating bits by 4
12451 __builtin_avr_insert_bits (0x32107654, bits, 0)
12452 @end smallexample
12453
12454 @smallexample
12455 // high nibble of result is the high nibble of val
12456 // low nibble of result is the low nibble of bits
12457 __builtin_avr_insert_bits (0xffff3210, bits, val)
12458 @end smallexample
12459
12460 @smallexample
12461 // reverse the bit order of bits
12462 __builtin_avr_insert_bits (0x01234567, bits, 0)
12463 @end smallexample
12464
12465 @node Blackfin Built-in Functions
12466 @subsection Blackfin Built-in Functions
12467
12468 Currently, there are two Blackfin-specific built-in functions. These are
12469 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12470 using inline assembly; by using these built-in functions the compiler can
12471 automatically add workarounds for hardware errata involving these
12472 instructions. These functions are named as follows:
12473
12474 @smallexample
12475 void __builtin_bfin_csync (void)
12476 void __builtin_bfin_ssync (void)
12477 @end smallexample
12478
12479 @node FR-V Built-in Functions
12480 @subsection FR-V Built-in Functions
12481
12482 GCC provides many FR-V-specific built-in functions. In general,
12483 these functions are intended to be compatible with those described
12484 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12485 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12486 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12487 pointer rather than by value.
12488
12489 Most of the functions are named after specific FR-V instructions.
12490 Such functions are said to be ``directly mapped'' and are summarized
12491 here in tabular form.
12492
12493 @menu
12494 * Argument Types::
12495 * Directly-mapped Integer Functions::
12496 * Directly-mapped Media Functions::
12497 * Raw read/write Functions::
12498 * Other Built-in Functions::
12499 @end menu
12500
12501 @node Argument Types
12502 @subsubsection Argument Types
12503
12504 The arguments to the built-in functions can be divided into three groups:
12505 register numbers, compile-time constants and run-time values. In order
12506 to make this classification clear at a glance, the arguments and return
12507 values are given the following pseudo types:
12508
12509 @multitable @columnfractions .20 .30 .15 .35
12510 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12511 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12512 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12513 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12514 @item @code{uw2} @tab @code{unsigned long long} @tab No
12515 @tab an unsigned doubleword
12516 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12517 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12518 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12519 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12520 @end multitable
12521
12522 These pseudo types are not defined by GCC, they are simply a notational
12523 convenience used in this manual.
12524
12525 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12526 and @code{sw2} are evaluated at run time. They correspond to
12527 register operands in the underlying FR-V instructions.
12528
12529 @code{const} arguments represent immediate operands in the underlying
12530 FR-V instructions. They must be compile-time constants.
12531
12532 @code{acc} arguments are evaluated at compile time and specify the number
12533 of an accumulator register. For example, an @code{acc} argument of 2
12534 selects the ACC2 register.
12535
12536 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12537 number of an IACC register. See @pxref{Other Built-in Functions}
12538 for more details.
12539
12540 @node Directly-mapped Integer Functions
12541 @subsubsection Directly-Mapped Integer Functions
12542
12543 The functions listed below map directly to FR-V I-type instructions.
12544
12545 @multitable @columnfractions .45 .32 .23
12546 @item Function prototype @tab Example usage @tab Assembly output
12547 @item @code{sw1 __ADDSS (sw1, sw1)}
12548 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12549 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12550 @item @code{sw1 __SCAN (sw1, sw1)}
12551 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12552 @tab @code{SCAN @var{a},@var{b},@var{c}}
12553 @item @code{sw1 __SCUTSS (sw1)}
12554 @tab @code{@var{b} = __SCUTSS (@var{a})}
12555 @tab @code{SCUTSS @var{a},@var{b}}
12556 @item @code{sw1 __SLASS (sw1, sw1)}
12557 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12558 @tab @code{SLASS @var{a},@var{b},@var{c}}
12559 @item @code{void __SMASS (sw1, sw1)}
12560 @tab @code{__SMASS (@var{a}, @var{b})}
12561 @tab @code{SMASS @var{a},@var{b}}
12562 @item @code{void __SMSSS (sw1, sw1)}
12563 @tab @code{__SMSSS (@var{a}, @var{b})}
12564 @tab @code{SMSSS @var{a},@var{b}}
12565 @item @code{void __SMU (sw1, sw1)}
12566 @tab @code{__SMU (@var{a}, @var{b})}
12567 @tab @code{SMU @var{a},@var{b}}
12568 @item @code{sw2 __SMUL (sw1, sw1)}
12569 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12570 @tab @code{SMUL @var{a},@var{b},@var{c}}
12571 @item @code{sw1 __SUBSS (sw1, sw1)}
12572 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12573 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12574 @item @code{uw2 __UMUL (uw1, uw1)}
12575 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12576 @tab @code{UMUL @var{a},@var{b},@var{c}}
12577 @end multitable
12578
12579 @node Directly-mapped Media Functions
12580 @subsubsection Directly-Mapped Media Functions
12581
12582 The functions listed below map directly to FR-V M-type instructions.
12583
12584 @multitable @columnfractions .45 .32 .23
12585 @item Function prototype @tab Example usage @tab Assembly output
12586 @item @code{uw1 __MABSHS (sw1)}
12587 @tab @code{@var{b} = __MABSHS (@var{a})}
12588 @tab @code{MABSHS @var{a},@var{b}}
12589 @item @code{void __MADDACCS (acc, acc)}
12590 @tab @code{__MADDACCS (@var{b}, @var{a})}
12591 @tab @code{MADDACCS @var{a},@var{b}}
12592 @item @code{sw1 __MADDHSS (sw1, sw1)}
12593 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12594 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12595 @item @code{uw1 __MADDHUS (uw1, uw1)}
12596 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12597 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12598 @item @code{uw1 __MAND (uw1, uw1)}
12599 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12600 @tab @code{MAND @var{a},@var{b},@var{c}}
12601 @item @code{void __MASACCS (acc, acc)}
12602 @tab @code{__MASACCS (@var{b}, @var{a})}
12603 @tab @code{MASACCS @var{a},@var{b}}
12604 @item @code{uw1 __MAVEH (uw1, uw1)}
12605 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12606 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12607 @item @code{uw2 __MBTOH (uw1)}
12608 @tab @code{@var{b} = __MBTOH (@var{a})}
12609 @tab @code{MBTOH @var{a},@var{b}}
12610 @item @code{void __MBTOHE (uw1 *, uw1)}
12611 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12612 @tab @code{MBTOHE @var{a},@var{b}}
12613 @item @code{void __MCLRACC (acc)}
12614 @tab @code{__MCLRACC (@var{a})}
12615 @tab @code{MCLRACC @var{a}}
12616 @item @code{void __MCLRACCA (void)}
12617 @tab @code{__MCLRACCA ()}
12618 @tab @code{MCLRACCA}
12619 @item @code{uw1 __Mcop1 (uw1, uw1)}
12620 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12621 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12622 @item @code{uw1 __Mcop2 (uw1, uw1)}
12623 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12624 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12625 @item @code{uw1 __MCPLHI (uw2, const)}
12626 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12627 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12628 @item @code{uw1 __MCPLI (uw2, const)}
12629 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12630 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12631 @item @code{void __MCPXIS (acc, sw1, sw1)}
12632 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12633 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12634 @item @code{void __MCPXIU (acc, uw1, uw1)}
12635 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12636 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12637 @item @code{void __MCPXRS (acc, sw1, sw1)}
12638 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12639 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12640 @item @code{void __MCPXRU (acc, uw1, uw1)}
12641 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12642 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12643 @item @code{uw1 __MCUT (acc, uw1)}
12644 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12645 @tab @code{MCUT @var{a},@var{b},@var{c}}
12646 @item @code{uw1 __MCUTSS (acc, sw1)}
12647 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12648 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12649 @item @code{void __MDADDACCS (acc, acc)}
12650 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12651 @tab @code{MDADDACCS @var{a},@var{b}}
12652 @item @code{void __MDASACCS (acc, acc)}
12653 @tab @code{__MDASACCS (@var{b}, @var{a})}
12654 @tab @code{MDASACCS @var{a},@var{b}}
12655 @item @code{uw2 __MDCUTSSI (acc, const)}
12656 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12657 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12658 @item @code{uw2 __MDPACKH (uw2, uw2)}
12659 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12660 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12661 @item @code{uw2 __MDROTLI (uw2, const)}
12662 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12663 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12664 @item @code{void __MDSUBACCS (acc, acc)}
12665 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12666 @tab @code{MDSUBACCS @var{a},@var{b}}
12667 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12668 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12669 @tab @code{MDUNPACKH @var{a},@var{b}}
12670 @item @code{uw2 __MEXPDHD (uw1, const)}
12671 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12672 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12673 @item @code{uw1 __MEXPDHW (uw1, const)}
12674 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12675 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12676 @item @code{uw1 __MHDSETH (uw1, const)}
12677 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12678 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12679 @item @code{sw1 __MHDSETS (const)}
12680 @tab @code{@var{b} = __MHDSETS (@var{a})}
12681 @tab @code{MHDSETS #@var{a},@var{b}}
12682 @item @code{uw1 __MHSETHIH (uw1, const)}
12683 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12684 @tab @code{MHSETHIH #@var{a},@var{b}}
12685 @item @code{sw1 __MHSETHIS (sw1, const)}
12686 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12687 @tab @code{MHSETHIS #@var{a},@var{b}}
12688 @item @code{uw1 __MHSETLOH (uw1, const)}
12689 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12690 @tab @code{MHSETLOH #@var{a},@var{b}}
12691 @item @code{sw1 __MHSETLOS (sw1, const)}
12692 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12693 @tab @code{MHSETLOS #@var{a},@var{b}}
12694 @item @code{uw1 __MHTOB (uw2)}
12695 @tab @code{@var{b} = __MHTOB (@var{a})}
12696 @tab @code{MHTOB @var{a},@var{b}}
12697 @item @code{void __MMACHS (acc, sw1, sw1)}
12698 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12699 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12700 @item @code{void __MMACHU (acc, uw1, uw1)}
12701 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12702 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12703 @item @code{void __MMRDHS (acc, sw1, sw1)}
12704 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12705 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12706 @item @code{void __MMRDHU (acc, uw1, uw1)}
12707 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12708 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12709 @item @code{void __MMULHS (acc, sw1, sw1)}
12710 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12711 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12712 @item @code{void __MMULHU (acc, uw1, uw1)}
12713 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12714 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12715 @item @code{void __MMULXHS (acc, sw1, sw1)}
12716 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12717 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12718 @item @code{void __MMULXHU (acc, uw1, uw1)}
12719 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12720 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12721 @item @code{uw1 __MNOT (uw1)}
12722 @tab @code{@var{b} = __MNOT (@var{a})}
12723 @tab @code{MNOT @var{a},@var{b}}
12724 @item @code{uw1 __MOR (uw1, uw1)}
12725 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12726 @tab @code{MOR @var{a},@var{b},@var{c}}
12727 @item @code{uw1 __MPACKH (uh, uh)}
12728 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12729 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12730 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12731 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12732 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12733 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12734 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12735 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12736 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12737 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12738 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12739 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12740 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12741 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12742 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12743 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12744 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12745 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12746 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12747 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12748 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12749 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12750 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12751 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12752 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12753 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12754 @item @code{void __MQMACHS (acc, sw2, sw2)}
12755 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12756 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12757 @item @code{void __MQMACHU (acc, uw2, uw2)}
12758 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12759 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12760 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12761 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12762 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12763 @item @code{void __MQMULHS (acc, sw2, sw2)}
12764 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12765 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12766 @item @code{void __MQMULHU (acc, uw2, uw2)}
12767 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12768 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12769 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12770 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12771 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12772 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12773 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12774 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12775 @item @code{sw2 __MQSATHS (sw2, sw2)}
12776 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12777 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12778 @item @code{uw2 __MQSLLHI (uw2, int)}
12779 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12780 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12781 @item @code{sw2 __MQSRAHI (sw2, int)}
12782 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12783 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12784 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12785 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12786 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12787 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12788 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12789 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12790 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12791 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12792 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12793 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12794 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12795 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12796 @item @code{uw1 __MRDACC (acc)}
12797 @tab @code{@var{b} = __MRDACC (@var{a})}
12798 @tab @code{MRDACC @var{a},@var{b}}
12799 @item @code{uw1 __MRDACCG (acc)}
12800 @tab @code{@var{b} = __MRDACCG (@var{a})}
12801 @tab @code{MRDACCG @var{a},@var{b}}
12802 @item @code{uw1 __MROTLI (uw1, const)}
12803 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12804 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12805 @item @code{uw1 __MROTRI (uw1, const)}
12806 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12807 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12808 @item @code{sw1 __MSATHS (sw1, sw1)}
12809 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12810 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12811 @item @code{uw1 __MSATHU (uw1, uw1)}
12812 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12813 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12814 @item @code{uw1 __MSLLHI (uw1, const)}
12815 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12816 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12817 @item @code{sw1 __MSRAHI (sw1, const)}
12818 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12819 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12820 @item @code{uw1 __MSRLHI (uw1, const)}
12821 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12822 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12823 @item @code{void __MSUBACCS (acc, acc)}
12824 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12825 @tab @code{MSUBACCS @var{a},@var{b}}
12826 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12827 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12828 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12829 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12830 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12831 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12832 @item @code{void __MTRAP (void)}
12833 @tab @code{__MTRAP ()}
12834 @tab @code{MTRAP}
12835 @item @code{uw2 __MUNPACKH (uw1)}
12836 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12837 @tab @code{MUNPACKH @var{a},@var{b}}
12838 @item @code{uw1 __MWCUT (uw2, uw1)}
12839 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12840 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12841 @item @code{void __MWTACC (acc, uw1)}
12842 @tab @code{__MWTACC (@var{b}, @var{a})}
12843 @tab @code{MWTACC @var{a},@var{b}}
12844 @item @code{void __MWTACCG (acc, uw1)}
12845 @tab @code{__MWTACCG (@var{b}, @var{a})}
12846 @tab @code{MWTACCG @var{a},@var{b}}
12847 @item @code{uw1 __MXOR (uw1, uw1)}
12848 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12849 @tab @code{MXOR @var{a},@var{b},@var{c}}
12850 @end multitable
12851
12852 @node Raw read/write Functions
12853 @subsubsection Raw Read/Write Functions
12854
12855 This sections describes built-in functions related to read and write
12856 instructions to access memory. These functions generate
12857 @code{membar} instructions to flush the I/O load and stores where
12858 appropriate, as described in Fujitsu's manual described above.
12859
12860 @table @code
12861
12862 @item unsigned char __builtin_read8 (void *@var{data})
12863 @item unsigned short __builtin_read16 (void *@var{data})
12864 @item unsigned long __builtin_read32 (void *@var{data})
12865 @item unsigned long long __builtin_read64 (void *@var{data})
12866
12867 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12868 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12869 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12870 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12871 @end table
12872
12873 @node Other Built-in Functions
12874 @subsubsection Other Built-in Functions
12875
12876 This section describes built-in functions that are not named after
12877 a specific FR-V instruction.
12878
12879 @table @code
12880 @item sw2 __IACCreadll (iacc @var{reg})
12881 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12882 for future expansion and must be 0.
12883
12884 @item sw1 __IACCreadl (iacc @var{reg})
12885 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12886 Other values of @var{reg} are rejected as invalid.
12887
12888 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12889 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12890 is reserved for future expansion and must be 0.
12891
12892 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12893 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12894 is 1. Other values of @var{reg} are rejected as invalid.
12895
12896 @item void __data_prefetch0 (const void *@var{x})
12897 Use the @code{dcpl} instruction to load the contents of address @var{x}
12898 into the data cache.
12899
12900 @item void __data_prefetch (const void *@var{x})
12901 Use the @code{nldub} instruction to load the contents of address @var{x}
12902 into the data cache. The instruction is issued in slot I1@.
12903 @end table
12904
12905 @node MIPS DSP Built-in Functions
12906 @subsection MIPS DSP Built-in Functions
12907
12908 The MIPS DSP Application-Specific Extension (ASE) includes new
12909 instructions that are designed to improve the performance of DSP and
12910 media applications. It provides instructions that operate on packed
12911 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12912
12913 GCC supports MIPS DSP operations using both the generic
12914 vector extensions (@pxref{Vector Extensions}) and a collection of
12915 MIPS-specific built-in functions. Both kinds of support are
12916 enabled by the @option{-mdsp} command-line option.
12917
12918 Revision 2 of the ASE was introduced in the second half of 2006.
12919 This revision adds extra instructions to the original ASE, but is
12920 otherwise backwards-compatible with it. You can select revision 2
12921 using the command-line option @option{-mdspr2}; this option implies
12922 @option{-mdsp}.
12923
12924 The SCOUNT and POS bits of the DSP control register are global. The
12925 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12926 POS bits. During optimization, the compiler does not delete these
12927 instructions and it does not delete calls to functions containing
12928 these instructions.
12929
12930 At present, GCC only provides support for operations on 32-bit
12931 vectors. The vector type associated with 8-bit integer data is
12932 usually called @code{v4i8}, the vector type associated with Q7
12933 is usually called @code{v4q7}, the vector type associated with 16-bit
12934 integer data is usually called @code{v2i16}, and the vector type
12935 associated with Q15 is usually called @code{v2q15}. They can be
12936 defined in C as follows:
12937
12938 @smallexample
12939 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12940 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12941 typedef short v2i16 __attribute__ ((vector_size(4)));
12942 typedef short v2q15 __attribute__ ((vector_size(4)));
12943 @end smallexample
12944
12945 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12946 initialized in the same way as aggregates. For example:
12947
12948 @smallexample
12949 v4i8 a = @{1, 2, 3, 4@};
12950 v4i8 b;
12951 b = (v4i8) @{5, 6, 7, 8@};
12952
12953 v2q15 c = @{0x0fcb, 0x3a75@};
12954 v2q15 d;
12955 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12956 @end smallexample
12957
12958 @emph{Note:} The CPU's endianness determines the order in which values
12959 are packed. On little-endian targets, the first value is the least
12960 significant and the last value is the most significant. The opposite
12961 order applies to big-endian targets. For example, the code above
12962 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12963 and @code{4} on big-endian targets.
12964
12965 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12966 representation. As shown in this example, the integer representation
12967 of a Q7 value can be obtained by multiplying the fractional value by
12968 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12969 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12970 @code{0x1.0p31}.
12971
12972 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12973 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12974 and @code{c} and @code{d} are @code{v2q15} values.
12975
12976 @multitable @columnfractions .50 .50
12977 @item C code @tab MIPS instruction
12978 @item @code{a + b} @tab @code{addu.qb}
12979 @item @code{c + d} @tab @code{addq.ph}
12980 @item @code{a - b} @tab @code{subu.qb}
12981 @item @code{c - d} @tab @code{subq.ph}
12982 @end multitable
12983
12984 The table below lists the @code{v2i16} operation for which
12985 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12986 @code{v2i16} values.
12987
12988 @multitable @columnfractions .50 .50
12989 @item C code @tab MIPS instruction
12990 @item @code{e * f} @tab @code{mul.ph}
12991 @end multitable
12992
12993 It is easier to describe the DSP built-in functions if we first define
12994 the following types:
12995
12996 @smallexample
12997 typedef int q31;
12998 typedef int i32;
12999 typedef unsigned int ui32;
13000 typedef long long a64;
13001 @end smallexample
13002
13003 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13004 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13005 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
13006 @code{long long}, but we use @code{a64} to indicate values that are
13007 placed in one of the four DSP accumulators (@code{$ac0},
13008 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13009
13010 Also, some built-in functions prefer or require immediate numbers as
13011 parameters, because the corresponding DSP instructions accept both immediate
13012 numbers and register operands, or accept immediate numbers only. The
13013 immediate parameters are listed as follows.
13014
13015 @smallexample
13016 imm0_3: 0 to 3.
13017 imm0_7: 0 to 7.
13018 imm0_15: 0 to 15.
13019 imm0_31: 0 to 31.
13020 imm0_63: 0 to 63.
13021 imm0_255: 0 to 255.
13022 imm_n32_31: -32 to 31.
13023 imm_n512_511: -512 to 511.
13024 @end smallexample
13025
13026 The following built-in functions map directly to a particular MIPS DSP
13027 instruction. Please refer to the architecture specification
13028 for details on what each instruction does.
13029
13030 @smallexample
13031 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13032 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13033 q31 __builtin_mips_addq_s_w (q31, q31)
13034 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13035 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13036 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13037 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13038 q31 __builtin_mips_subq_s_w (q31, q31)
13039 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13040 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13041 i32 __builtin_mips_addsc (i32, i32)
13042 i32 __builtin_mips_addwc (i32, i32)
13043 i32 __builtin_mips_modsub (i32, i32)
13044 i32 __builtin_mips_raddu_w_qb (v4i8)
13045 v2q15 __builtin_mips_absq_s_ph (v2q15)
13046 q31 __builtin_mips_absq_s_w (q31)
13047 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13048 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13049 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13050 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13051 q31 __builtin_mips_preceq_w_phl (v2q15)
13052 q31 __builtin_mips_preceq_w_phr (v2q15)
13053 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13054 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13055 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13056 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13057 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13058 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13059 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13060 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13061 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13062 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13063 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13064 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13065 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13066 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13067 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13068 q31 __builtin_mips_shll_s_w (q31, i32)
13069 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13070 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13071 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13072 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13073 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13074 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13075 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13076 q31 __builtin_mips_shra_r_w (q31, i32)
13077 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13078 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13079 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13080 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13081 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13082 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13083 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13084 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13085 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13086 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13087 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13088 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13089 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13090 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13091 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13092 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13093 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13094 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13095 i32 __builtin_mips_bitrev (i32)
13096 i32 __builtin_mips_insv (i32, i32)
13097 v4i8 __builtin_mips_repl_qb (imm0_255)
13098 v4i8 __builtin_mips_repl_qb (i32)
13099 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13100 v2q15 __builtin_mips_repl_ph (i32)
13101 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13102 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13103 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13104 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13105 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13106 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13107 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13108 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13109 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13110 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13111 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13112 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13113 i32 __builtin_mips_extr_w (a64, imm0_31)
13114 i32 __builtin_mips_extr_w (a64, i32)
13115 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13116 i32 __builtin_mips_extr_s_h (a64, i32)
13117 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13118 i32 __builtin_mips_extr_rs_w (a64, i32)
13119 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13120 i32 __builtin_mips_extr_r_w (a64, i32)
13121 i32 __builtin_mips_extp (a64, imm0_31)
13122 i32 __builtin_mips_extp (a64, i32)
13123 i32 __builtin_mips_extpdp (a64, imm0_31)
13124 i32 __builtin_mips_extpdp (a64, i32)
13125 a64 __builtin_mips_shilo (a64, imm_n32_31)
13126 a64 __builtin_mips_shilo (a64, i32)
13127 a64 __builtin_mips_mthlip (a64, i32)
13128 void __builtin_mips_wrdsp (i32, imm0_63)
13129 i32 __builtin_mips_rddsp (imm0_63)
13130 i32 __builtin_mips_lbux (void *, i32)
13131 i32 __builtin_mips_lhx (void *, i32)
13132 i32 __builtin_mips_lwx (void *, i32)
13133 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13134 i32 __builtin_mips_bposge32 (void)
13135 a64 __builtin_mips_madd (a64, i32, i32);
13136 a64 __builtin_mips_maddu (a64, ui32, ui32);
13137 a64 __builtin_mips_msub (a64, i32, i32);
13138 a64 __builtin_mips_msubu (a64, ui32, ui32);
13139 a64 __builtin_mips_mult (i32, i32);
13140 a64 __builtin_mips_multu (ui32, ui32);
13141 @end smallexample
13142
13143 The following built-in functions map directly to a particular MIPS DSP REV 2
13144 instruction. Please refer to the architecture specification
13145 for details on what each instruction does.
13146
13147 @smallexample
13148 v4q7 __builtin_mips_absq_s_qb (v4q7);
13149 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13150 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13151 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13152 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13153 i32 __builtin_mips_append (i32, i32, imm0_31);
13154 i32 __builtin_mips_balign (i32, i32, imm0_3);
13155 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13156 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13157 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13158 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13159 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13160 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13161 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13162 q31 __builtin_mips_mulq_rs_w (q31, q31);
13163 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13164 q31 __builtin_mips_mulq_s_w (q31, q31);
13165 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13166 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13167 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13168 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13169 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13170 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13171 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13172 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13173 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13174 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13175 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13176 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13177 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13178 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13179 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13180 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13181 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13182 q31 __builtin_mips_addqh_w (q31, q31);
13183 q31 __builtin_mips_addqh_r_w (q31, q31);
13184 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13185 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13186 q31 __builtin_mips_subqh_w (q31, q31);
13187 q31 __builtin_mips_subqh_r_w (q31, q31);
13188 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13189 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13190 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13191 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13192 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13193 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13194 @end smallexample
13195
13196
13197 @node MIPS Paired-Single Support
13198 @subsection MIPS Paired-Single Support
13199
13200 The MIPS64 architecture includes a number of instructions that
13201 operate on pairs of single-precision floating-point values.
13202 Each pair is packed into a 64-bit floating-point register,
13203 with one element being designated the ``upper half'' and
13204 the other being designated the ``lower half''.
13205
13206 GCC supports paired-single operations using both the generic
13207 vector extensions (@pxref{Vector Extensions}) and a collection of
13208 MIPS-specific built-in functions. Both kinds of support are
13209 enabled by the @option{-mpaired-single} command-line option.
13210
13211 The vector type associated with paired-single values is usually
13212 called @code{v2sf}. It can be defined in C as follows:
13213
13214 @smallexample
13215 typedef float v2sf __attribute__ ((vector_size (8)));
13216 @end smallexample
13217
13218 @code{v2sf} values are initialized in the same way as aggregates.
13219 For example:
13220
13221 @smallexample
13222 v2sf a = @{1.5, 9.1@};
13223 v2sf b;
13224 float e, f;
13225 b = (v2sf) @{e, f@};
13226 @end smallexample
13227
13228 @emph{Note:} The CPU's endianness determines which value is stored in
13229 the upper half of a register and which value is stored in the lower half.
13230 On little-endian targets, the first value is the lower one and the second
13231 value is the upper one. The opposite order applies to big-endian targets.
13232 For example, the code above sets the lower half of @code{a} to
13233 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13234
13235 @node MIPS Loongson Built-in Functions
13236 @subsection MIPS Loongson Built-in Functions
13237
13238 GCC provides intrinsics to access the SIMD instructions provided by the
13239 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13240 available after inclusion of the @code{loongson.h} header file,
13241 operate on the following 64-bit vector types:
13242
13243 @itemize
13244 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13245 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13246 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13247 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13248 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13249 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13250 @end itemize
13251
13252 The intrinsics provided are listed below; each is named after the
13253 machine instruction to which it corresponds, with suffixes added as
13254 appropriate to distinguish intrinsics that expand to the same machine
13255 instruction yet have different argument types. Refer to the architecture
13256 documentation for a description of the functionality of each
13257 instruction.
13258
13259 @smallexample
13260 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13261 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13262 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13263 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13264 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13265 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13266 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13267 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13268 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13269 uint64_t paddd_u (uint64_t s, uint64_t t);
13270 int64_t paddd_s (int64_t s, int64_t t);
13271 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13272 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13273 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13274 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13275 uint64_t pandn_ud (uint64_t s, uint64_t t);
13276 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13277 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13278 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13279 int64_t pandn_sd (int64_t s, int64_t t);
13280 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13281 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13282 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13283 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13284 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13285 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13286 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13287 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13288 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13289 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13290 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13291 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13292 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13293 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13294 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13295 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13296 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13297 uint16x4_t pextrh_u (uint16x4_t s, int field);
13298 int16x4_t pextrh_s (int16x4_t s, int field);
13299 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13300 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13301 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13302 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13303 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13304 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13305 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13306 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13307 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13308 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13309 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13310 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13311 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13312 uint8x8_t pmovmskb_u (uint8x8_t s);
13313 int8x8_t pmovmskb_s (int8x8_t s);
13314 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13315 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13316 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13317 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13318 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13319 uint16x4_t biadd (uint8x8_t s);
13320 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13321 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13322 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13323 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13324 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13325 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13326 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13327 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13328 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13329 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13330 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13331 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13332 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13333 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13334 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13335 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13336 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13337 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13338 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13339 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13340 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13341 uint64_t psubd_u (uint64_t s, uint64_t t);
13342 int64_t psubd_s (int64_t s, int64_t t);
13343 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13344 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13345 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13346 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13347 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13348 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13349 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13350 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13351 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13352 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13353 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13354 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13355 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13356 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13357 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13358 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13359 @end smallexample
13360
13361 @menu
13362 * Paired-Single Arithmetic::
13363 * Paired-Single Built-in Functions::
13364 * MIPS-3D Built-in Functions::
13365 @end menu
13366
13367 @node Paired-Single Arithmetic
13368 @subsubsection Paired-Single Arithmetic
13369
13370 The table below lists the @code{v2sf} operations for which hardware
13371 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13372 values and @code{x} is an integral value.
13373
13374 @multitable @columnfractions .50 .50
13375 @item C code @tab MIPS instruction
13376 @item @code{a + b} @tab @code{add.ps}
13377 @item @code{a - b} @tab @code{sub.ps}
13378 @item @code{-a} @tab @code{neg.ps}
13379 @item @code{a * b} @tab @code{mul.ps}
13380 @item @code{a * b + c} @tab @code{madd.ps}
13381 @item @code{a * b - c} @tab @code{msub.ps}
13382 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13383 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13384 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13385 @end multitable
13386
13387 Note that the multiply-accumulate instructions can be disabled
13388 using the command-line option @code{-mno-fused-madd}.
13389
13390 @node Paired-Single Built-in Functions
13391 @subsubsection Paired-Single Built-in Functions
13392
13393 The following paired-single functions map directly to a particular
13394 MIPS instruction. Please refer to the architecture specification
13395 for details on what each instruction does.
13396
13397 @table @code
13398 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13399 Pair lower lower (@code{pll.ps}).
13400
13401 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13402 Pair upper lower (@code{pul.ps}).
13403
13404 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13405 Pair lower upper (@code{plu.ps}).
13406
13407 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13408 Pair upper upper (@code{puu.ps}).
13409
13410 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13411 Convert pair to paired single (@code{cvt.ps.s}).
13412
13413 @item float __builtin_mips_cvt_s_pl (v2sf)
13414 Convert pair lower to single (@code{cvt.s.pl}).
13415
13416 @item float __builtin_mips_cvt_s_pu (v2sf)
13417 Convert pair upper to single (@code{cvt.s.pu}).
13418
13419 @item v2sf __builtin_mips_abs_ps (v2sf)
13420 Absolute value (@code{abs.ps}).
13421
13422 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13423 Align variable (@code{alnv.ps}).
13424
13425 @emph{Note:} The value of the third parameter must be 0 or 4
13426 modulo 8, otherwise the result is unpredictable. Please read the
13427 instruction description for details.
13428 @end table
13429
13430 The following multi-instruction functions are also available.
13431 In each case, @var{cond} can be any of the 16 floating-point conditions:
13432 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13433 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13434 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13435
13436 @table @code
13437 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13438 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13439 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13440 @code{movt.ps}/@code{movf.ps}).
13441
13442 The @code{movt} functions return the value @var{x} computed by:
13443
13444 @smallexample
13445 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13446 mov.ps @var{x},@var{c}
13447 movt.ps @var{x},@var{d},@var{cc}
13448 @end smallexample
13449
13450 The @code{movf} functions are similar but use @code{movf.ps} instead
13451 of @code{movt.ps}.
13452
13453 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13454 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13455 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13456 @code{bc1t}/@code{bc1f}).
13457
13458 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13459 and return either the upper or lower half of the result. For example:
13460
13461 @smallexample
13462 v2sf a, b;
13463 if (__builtin_mips_upper_c_eq_ps (a, b))
13464 upper_halves_are_equal ();
13465 else
13466 upper_halves_are_unequal ();
13467
13468 if (__builtin_mips_lower_c_eq_ps (a, b))
13469 lower_halves_are_equal ();
13470 else
13471 lower_halves_are_unequal ();
13472 @end smallexample
13473 @end table
13474
13475 @node MIPS-3D Built-in Functions
13476 @subsubsection MIPS-3D Built-in Functions
13477
13478 The MIPS-3D Application-Specific Extension (ASE) includes additional
13479 paired-single instructions that are designed to improve the performance
13480 of 3D graphics operations. Support for these instructions is controlled
13481 by the @option{-mips3d} command-line option.
13482
13483 The functions listed below map directly to a particular MIPS-3D
13484 instruction. Please refer to the architecture specification for
13485 more details on what each instruction does.
13486
13487 @table @code
13488 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13489 Reduction add (@code{addr.ps}).
13490
13491 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13492 Reduction multiply (@code{mulr.ps}).
13493
13494 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13495 Convert paired single to paired word (@code{cvt.pw.ps}).
13496
13497 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13498 Convert paired word to paired single (@code{cvt.ps.pw}).
13499
13500 @item float __builtin_mips_recip1_s (float)
13501 @itemx double __builtin_mips_recip1_d (double)
13502 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13503 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13504
13505 @item float __builtin_mips_recip2_s (float, float)
13506 @itemx double __builtin_mips_recip2_d (double, double)
13507 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13508 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13509
13510 @item float __builtin_mips_rsqrt1_s (float)
13511 @itemx double __builtin_mips_rsqrt1_d (double)
13512 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13513 Reduced-precision reciprocal square root (sequence step 1)
13514 (@code{rsqrt1.@var{fmt}}).
13515
13516 @item float __builtin_mips_rsqrt2_s (float, float)
13517 @itemx double __builtin_mips_rsqrt2_d (double, double)
13518 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13519 Reduced-precision reciprocal square root (sequence step 2)
13520 (@code{rsqrt2.@var{fmt}}).
13521 @end table
13522
13523 The following multi-instruction functions are also available.
13524 In each case, @var{cond} can be any of the 16 floating-point conditions:
13525 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13526 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13527 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13528
13529 @table @code
13530 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13531 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13532 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13533 @code{bc1t}/@code{bc1f}).
13534
13535 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13536 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13537 For example:
13538
13539 @smallexample
13540 float a, b;
13541 if (__builtin_mips_cabs_eq_s (a, b))
13542 true ();
13543 else
13544 false ();
13545 @end smallexample
13546
13547 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13548 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13549 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13550 @code{bc1t}/@code{bc1f}).
13551
13552 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13553 and return either the upper or lower half of the result. For example:
13554
13555 @smallexample
13556 v2sf a, b;
13557 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13558 upper_halves_are_equal ();
13559 else
13560 upper_halves_are_unequal ();
13561
13562 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13563 lower_halves_are_equal ();
13564 else
13565 lower_halves_are_unequal ();
13566 @end smallexample
13567
13568 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13569 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13570 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13571 @code{movt.ps}/@code{movf.ps}).
13572
13573 The @code{movt} functions return the value @var{x} computed by:
13574
13575 @smallexample
13576 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13577 mov.ps @var{x},@var{c}
13578 movt.ps @var{x},@var{d},@var{cc}
13579 @end smallexample
13580
13581 The @code{movf} functions are similar but use @code{movf.ps} instead
13582 of @code{movt.ps}.
13583
13584 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13585 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13586 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13587 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13588 Comparison of two paired-single values
13589 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13590 @code{bc1any2t}/@code{bc1any2f}).
13591
13592 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13593 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13594 result is true and the @code{all} forms return true if both results are true.
13595 For example:
13596
13597 @smallexample
13598 v2sf a, b;
13599 if (__builtin_mips_any_c_eq_ps (a, b))
13600 one_is_true ();
13601 else
13602 both_are_false ();
13603
13604 if (__builtin_mips_all_c_eq_ps (a, b))
13605 both_are_true ();
13606 else
13607 one_is_false ();
13608 @end smallexample
13609
13610 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13611 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13612 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13613 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13614 Comparison of four paired-single values
13615 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13616 @code{bc1any4t}/@code{bc1any4f}).
13617
13618 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13619 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13620 The @code{any} forms return true if any of the four results are true
13621 and the @code{all} forms return true if all four results are true.
13622 For example:
13623
13624 @smallexample
13625 v2sf a, b, c, d;
13626 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13627 some_are_true ();
13628 else
13629 all_are_false ();
13630
13631 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13632 all_are_true ();
13633 else
13634 some_are_false ();
13635 @end smallexample
13636 @end table
13637
13638 @node MIPS SIMD Architecture (MSA) Support
13639 @subsection MIPS SIMD Architecture (MSA) Support
13640
13641 @menu
13642 * MIPS SIMD Architecture Built-in Functions::
13643 @end menu
13644
13645 GCC provides intrinsics to access the SIMD instructions provided by the
13646 MSA MIPS SIMD Architecture. The interface is made available by including
13647 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
13648 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
13649 @code{__msa_*}.
13650
13651 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
13652 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
13653 data elements. The following vectors typedefs are included in @code{msa.h}:
13654 @itemize
13655 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
13656 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
13657 @item @code{v8i16}, a vector of eight signed 16-bit integers;
13658 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
13659 @item @code{v4i32}, a vector of four signed 32-bit integers;
13660 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
13661 @item @code{v2i64}, a vector of two signed 64-bit integers;
13662 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
13663 @item @code{v4f32}, a vector of four 32-bit floats;
13664 @item @code{v2f64}, a vector of two 64-bit doubles.
13665 @end itemize
13666
13667 Intructions and corresponding built-ins may have additional restrictions and/or
13668 input/output values manipulated:
13669 @itemize
13670 @item @code{imm0_1}, an integer literal in range 0 to 1;
13671 @item @code{imm0_3}, an integer literal in range 0 to 3;
13672 @item @code{imm0_7}, an integer literal in range 0 to 7;
13673 @item @code{imm0_15}, an integer literal in range 0 to 15;
13674 @item @code{imm0_31}, an integer literal in range 0 to 31;
13675 @item @code{imm0_63}, an integer literal in range 0 to 63;
13676 @item @code{imm0_255}, an integer literal in range 0 to 255;
13677 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
13678 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
13679 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
13680 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
13681 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
13682 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
13683 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
13684 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
13685 @item @code{imm1_4}, an integer literal in range 1 to 4;
13686 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
13687 @end itemize
13688
13689 @smallexample
13690 @{
13691 typedef int i32;
13692 #if __LONG_MAX__ == __LONG_LONG_MAX__
13693 typedef long i64;
13694 #else
13695 typedef long long i64;
13696 #endif
13697
13698 typedef unsigned int u32;
13699 #if __LONG_MAX__ == __LONG_LONG_MAX__
13700 typedef unsigned long u64;
13701 #else
13702 typedef unsigned long long u64;
13703 #endif
13704
13705 typedef double f64;
13706 typedef float f32;
13707 @}
13708 @end smallexample
13709
13710 @node MIPS SIMD Architecture Built-in Functions
13711 @subsubsection MIPS SIMD Architecture Built-in Functions
13712
13713 The intrinsics provided are listed below; each is named after the
13714 machine instruction.
13715
13716 @smallexample
13717 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
13718 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
13719 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
13720 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
13721
13722 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
13723 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
13724 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
13725 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
13726
13727 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
13728 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
13729 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
13730 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
13731
13732 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
13733 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
13734 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
13735 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
13736
13737 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
13738 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
13739 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
13740 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
13741
13742 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
13743 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
13744 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
13745 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
13746
13747 v16u8 __builtin_msa_and_v (v16u8, v16u8);
13748
13749 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
13750
13751 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
13752 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
13753 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
13754 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
13755
13756 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
13757 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
13758 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
13759 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
13760
13761 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
13762 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
13763 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
13764 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
13765
13766 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
13767 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
13768 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
13769 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
13770
13771 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
13772 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
13773 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
13774 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
13775
13776 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
13777 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
13778 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
13779 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
13780
13781 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
13782 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
13783 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
13784 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
13785
13786 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
13787 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
13788 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
13789 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
13790
13791 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
13792 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
13793 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
13794 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
13795
13796 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
13797 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
13798 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
13799 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
13800
13801 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
13802 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
13803 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
13804 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
13805
13806 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
13807 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
13808 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
13809 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
13810
13811 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
13812
13813 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
13814
13815 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
13816
13817 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
13818
13819 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
13820 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
13821 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
13822 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
13823
13824 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
13825 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
13826 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
13827 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
13828
13829 i32 __builtin_msa_bnz_b (v16u8);
13830 i32 __builtin_msa_bnz_h (v8u16);
13831 i32 __builtin_msa_bnz_w (v4u32);
13832 i32 __builtin_msa_bnz_d (v2u64);
13833
13834 i32 __builtin_msa_bnz_v (v16u8);
13835
13836 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
13837
13838 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
13839
13840 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
13841 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
13842 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
13843 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
13844
13845 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
13846 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
13847 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
13848 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
13849
13850 i32 __builtin_msa_bz_b (v16u8);
13851 i32 __builtin_msa_bz_h (v8u16);
13852 i32 __builtin_msa_bz_w (v4u32);
13853 i32 __builtin_msa_bz_d (v2u64);
13854
13855 i32 __builtin_msa_bz_v (v16u8);
13856
13857 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
13858 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
13859 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
13860 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
13861
13862 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
13863 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
13864 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
13865 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
13866
13867 i32 __builtin_msa_cfcmsa (imm0_31);
13868
13869 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
13870 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
13871 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
13872 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
13873
13874 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
13875 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
13876 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
13877 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
13878
13879 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
13880 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
13881 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
13882 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
13883
13884 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
13885 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
13886 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
13887 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
13888
13889 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
13890 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
13891 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
13892 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
13893
13894 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
13895 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
13896 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
13897 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
13898
13899 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
13900 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
13901 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
13902 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
13903
13904 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
13905 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
13906 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
13907 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
13908
13909 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
13910 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
13911 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
13912 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
13913
13914 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
13915 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
13916 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
13917 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
13918
13919 void __builtin_msa_ctcmsa (imm0_31, i32);
13920
13921 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
13922 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
13923 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
13924 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
13925
13926 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
13927 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
13928 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
13929 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
13930
13931 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
13932 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
13933 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
13934
13935 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
13936 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
13937 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
13938
13939 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
13940 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
13941 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
13942
13943 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
13944 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
13945 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
13946
13947 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
13948 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
13949 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
13950
13951 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
13952 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
13953 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
13954
13955 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
13956 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
13957
13958 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
13959 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
13960
13961 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
13962 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
13963
13964 v4i32 __builtin_msa_fclass_w (v4f32);
13965 v2i64 __builtin_msa_fclass_d (v2f64);
13966
13967 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
13968 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
13969
13970 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
13971 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
13972
13973 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
13974 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
13975
13976 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
13977 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
13978
13979 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
13980 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
13981
13982 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
13983 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
13984
13985 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
13986 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
13987
13988 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
13989 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
13990
13991 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
13992 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
13993
13994 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
13995 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
13996
13997 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
13998 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
13999
14000 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14001 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14002
14003 v4f32 __builtin_msa_fexupl_w (v8i16);
14004 v2f64 __builtin_msa_fexupl_d (v4f32);
14005
14006 v4f32 __builtin_msa_fexupr_w (v8i16);
14007 v2f64 __builtin_msa_fexupr_d (v4f32);
14008
14009 v4f32 __builtin_msa_ffint_s_w (v4i32);
14010 v2f64 __builtin_msa_ffint_s_d (v2i64);
14011
14012 v4f32 __builtin_msa_ffint_u_w (v4u32);
14013 v2f64 __builtin_msa_ffint_u_d (v2u64);
14014
14015 v4f32 __builtin_msa_ffql_w (v8i16);
14016 v2f64 __builtin_msa_ffql_d (v4i32);
14017
14018 v4f32 __builtin_msa_ffqr_w (v8i16);
14019 v2f64 __builtin_msa_ffqr_d (v4i32);
14020
14021 v16i8 __builtin_msa_fill_b (i32);
14022 v8i16 __builtin_msa_fill_h (i32);
14023 v4i32 __builtin_msa_fill_w (i32);
14024 v2i64 __builtin_msa_fill_d (i64);
14025
14026 v4f32 __builtin_msa_flog2_w (v4f32);
14027 v2f64 __builtin_msa_flog2_d (v2f64);
14028
14029 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14030 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14031
14032 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14033 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14034
14035 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14036 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14037
14038 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14039 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14040
14041 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14042 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14043
14044 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14045 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14046
14047 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14048 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14049
14050 v4f32 __builtin_msa_frint_w (v4f32);
14051 v2f64 __builtin_msa_frint_d (v2f64);
14052
14053 v4f32 __builtin_msa_frcp_w (v4f32);
14054 v2f64 __builtin_msa_frcp_d (v2f64);
14055
14056 v4f32 __builtin_msa_frsqrt_w (v4f32);
14057 v2f64 __builtin_msa_frsqrt_d (v2f64);
14058
14059 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14060 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14061
14062 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14063 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14064
14065 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14066 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14067
14068 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14069 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14070
14071 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14072 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14073
14074 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14075 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14076
14077 v4f32 __builtin_msa_fsqrt_w (v4f32);
14078 v2f64 __builtin_msa_fsqrt_d (v2f64);
14079
14080 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14081 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14082
14083 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14084 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
14085
14086 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
14087 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
14088
14089 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
14090 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
14091
14092 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
14093 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
14094
14095 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
14096 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
14097
14098 v4i32 __builtin_msa_ftint_s_w (v4f32);
14099 v2i64 __builtin_msa_ftint_s_d (v2f64);
14100
14101 v4u32 __builtin_msa_ftint_u_w (v4f32);
14102 v2u64 __builtin_msa_ftint_u_d (v2f64);
14103
14104 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
14105 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
14106
14107 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
14108 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
14109
14110 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
14111 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
14112
14113 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
14114 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
14115 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
14116
14117 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
14118 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
14119 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
14120
14121 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
14122 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
14123 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
14124
14125 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
14126 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
14127 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
14128
14129 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
14130 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
14131 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
14132 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
14133
14134 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
14135 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
14136 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
14137 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
14138
14139 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
14140 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
14141 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
14142 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
14143
14144 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
14145 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
14146 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
14147 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
14148
14149 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
14150 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
14151 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
14152 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
14153
14154 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
14155 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
14156 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
14157 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
14158
14159 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
14160 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
14161 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
14162 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
14163
14164 v16i8 __builtin_msa_ldi_b (imm_n512_511);
14165 v8i16 __builtin_msa_ldi_h (imm_n512_511);
14166 v4i32 __builtin_msa_ldi_w (imm_n512_511);
14167 v2i64 __builtin_msa_ldi_d (imm_n512_511);
14168
14169 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
14170 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
14171
14172 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
14173 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
14174
14175 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
14176 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
14177 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
14178 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
14179
14180 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
14181 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
14182 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
14183 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
14184
14185 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
14186 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
14187 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
14188 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
14189
14190 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
14191 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
14192 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
14193 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
14194
14195 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
14196 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
14197 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
14198 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
14199
14200 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
14201 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
14202 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
14203 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
14204
14205 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
14206 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
14207 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
14208 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
14209
14210 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
14211 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
14212 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
14213 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
14214
14215 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
14216 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
14217 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
14218 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
14219
14220 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
14221 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
14222 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
14223 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
14224
14225 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
14226 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
14227 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
14228 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
14229
14230 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
14231 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
14232 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
14233 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
14234
14235 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
14236 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
14237 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
14238 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
14239
14240 v16i8 __builtin_msa_move_v (v16i8);
14241
14242 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
14243 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
14244
14245 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
14246 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
14247
14248 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
14249 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
14250 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
14251 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
14252
14253 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
14254 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
14255
14256 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
14257 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
14258
14259 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
14260 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
14261 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
14262 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
14263
14264 v16i8 __builtin_msa_nloc_b (v16i8);
14265 v8i16 __builtin_msa_nloc_h (v8i16);
14266 v4i32 __builtin_msa_nloc_w (v4i32);
14267 v2i64 __builtin_msa_nloc_d (v2i64);
14268
14269 v16i8 __builtin_msa_nlzc_b (v16i8);
14270 v8i16 __builtin_msa_nlzc_h (v8i16);
14271 v4i32 __builtin_msa_nlzc_w (v4i32);
14272 v2i64 __builtin_msa_nlzc_d (v2i64);
14273
14274 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
14275
14276 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
14277
14278 v16u8 __builtin_msa_or_v (v16u8, v16u8);
14279
14280 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
14281
14282 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
14283 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
14284 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
14285 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
14286
14287 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
14288 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
14289 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
14290 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
14291
14292 v16i8 __builtin_msa_pcnt_b (v16i8);
14293 v8i16 __builtin_msa_pcnt_h (v8i16);
14294 v4i32 __builtin_msa_pcnt_w (v4i32);
14295 v2i64 __builtin_msa_pcnt_d (v2i64);
14296
14297 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
14298 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
14299 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
14300 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
14301
14302 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
14303 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
14304 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
14305 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
14306
14307 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
14308 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
14309 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
14310
14311 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
14312 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
14313 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
14314 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
14315
14316 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
14317 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
14318 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
14319 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
14320
14321 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
14322 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
14323 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
14324 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
14325
14326 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
14327 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
14328 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
14329 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
14330
14331 v16i8 __builtin_msa_splat_b (v16i8, i32);
14332 v8i16 __builtin_msa_splat_h (v8i16, i32);
14333 v4i32 __builtin_msa_splat_w (v4i32, i32);
14334 v2i64 __builtin_msa_splat_d (v2i64, i32);
14335
14336 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
14337 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
14338 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
14339 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
14340
14341 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
14342 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
14343 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
14344 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
14345
14346 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
14347 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
14348 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
14349 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
14350
14351 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
14352 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
14353 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
14354 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
14355
14356 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
14357 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
14358 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
14359 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
14360
14361 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
14362 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
14363 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
14364 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
14365
14366 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
14367 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
14368 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
14369 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
14370
14371 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
14372 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
14373 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
14374 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
14375
14376 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
14377 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
14378 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
14379 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
14380
14381 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
14382 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
14383 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
14384 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
14385
14386 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
14387 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
14388 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
14389 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
14390
14391 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
14392 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
14393 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
14394 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
14395
14396 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
14397 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
14398 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
14399 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
14400
14401 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
14402 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
14403 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
14404 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
14405
14406 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
14407 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
14408 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
14409 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
14410
14411 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
14412 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
14413 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
14414 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
14415
14416 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
14417 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
14418 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
14419 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
14420
14421 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
14422
14423 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
14424 @end smallexample
14425
14426 @node Other MIPS Built-in Functions
14427 @subsection Other MIPS Built-in Functions
14428
14429 GCC provides other MIPS-specific built-in functions:
14430
14431 @table @code
14432 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
14433 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
14434 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
14435 when this function is available.
14436
14437 @item unsigned int __builtin_mips_get_fcsr (void)
14438 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
14439 Get and set the contents of the floating-point control and status register
14440 (FPU control register 31). These functions are only available in hard-float
14441 code but can be called in both MIPS16 and non-MIPS16 contexts.
14442
14443 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
14444 register except the condition codes, which GCC assumes are preserved.
14445 @end table
14446
14447 @node MSP430 Built-in Functions
14448 @subsection MSP430 Built-in Functions
14449
14450 GCC provides a couple of special builtin functions to aid in the
14451 writing of interrupt handlers in C.
14452
14453 @table @code
14454 @item __bic_SR_register_on_exit (int @var{mask})
14455 This clears the indicated bits in the saved copy of the status register
14456 currently residing on the stack. This only works inside interrupt
14457 handlers and the changes to the status register will only take affect
14458 once the handler returns.
14459
14460 @item __bis_SR_register_on_exit (int @var{mask})
14461 This sets the indicated bits in the saved copy of the status register
14462 currently residing on the stack. This only works inside interrupt
14463 handlers and the changes to the status register will only take affect
14464 once the handler returns.
14465
14466 @item __delay_cycles (long long @var{cycles})
14467 This inserts an instruction sequence that takes exactly @var{cycles}
14468 cycles (between 0 and about 17E9) to complete. The inserted sequence
14469 may use jumps, loops, or no-ops, and does not interfere with any other
14470 instructions. Note that @var{cycles} must be a compile-time constant
14471 integer - that is, you must pass a number, not a variable that may be
14472 optimized to a constant later. The number of cycles delayed by this
14473 builtin is exact.
14474 @end table
14475
14476 @node NDS32 Built-in Functions
14477 @subsection NDS32 Built-in Functions
14478
14479 These built-in functions are available for the NDS32 target:
14480
14481 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
14482 Insert an ISYNC instruction into the instruction stream where
14483 @var{addr} is an instruction address for serialization.
14484 @end deftypefn
14485
14486 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
14487 Insert an ISB instruction into the instruction stream.
14488 @end deftypefn
14489
14490 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
14491 Return the content of a system register which is mapped by @var{sr}.
14492 @end deftypefn
14493
14494 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
14495 Return the content of a user space register which is mapped by @var{usr}.
14496 @end deftypefn
14497
14498 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
14499 Move the @var{value} to a system register which is mapped by @var{sr}.
14500 @end deftypefn
14501
14502 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
14503 Move the @var{value} to a user space register which is mapped by @var{usr}.
14504 @end deftypefn
14505
14506 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
14507 Enable global interrupt.
14508 @end deftypefn
14509
14510 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
14511 Disable global interrupt.
14512 @end deftypefn
14513
14514 @node picoChip Built-in Functions
14515 @subsection picoChip Built-in Functions
14516
14517 GCC provides an interface to selected machine instructions from the
14518 picoChip instruction set.
14519
14520 @table @code
14521 @item int __builtin_sbc (int @var{value})
14522 Sign bit count. Return the number of consecutive bits in @var{value}
14523 that have the same value as the sign bit. The result is the number of
14524 leading sign bits minus one, giving the number of redundant sign bits in
14525 @var{value}.
14526
14527 @item int __builtin_byteswap (int @var{value})
14528 Byte swap. Return the result of swapping the upper and lower bytes of
14529 @var{value}.
14530
14531 @item int __builtin_brev (int @var{value})
14532 Bit reversal. Return the result of reversing the bits in
14533 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
14534 and so on.
14535
14536 @item int __builtin_adds (int @var{x}, int @var{y})
14537 Saturating addition. Return the result of adding @var{x} and @var{y},
14538 storing the value 32767 if the result overflows.
14539
14540 @item int __builtin_subs (int @var{x}, int @var{y})
14541 Saturating subtraction. Return the result of subtracting @var{y} from
14542 @var{x}, storing the value @minus{}32768 if the result overflows.
14543
14544 @item void __builtin_halt (void)
14545 Halt. The processor stops execution. This built-in is useful for
14546 implementing assertions.
14547
14548 @end table
14549
14550 @node PowerPC Built-in Functions
14551 @subsection PowerPC Built-in Functions
14552
14553 The following built-in functions are always available and can be used to
14554 check the PowerPC target platform type:
14555
14556 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
14557 This function is a @code{nop} on the PowerPC platform and is included solely
14558 to maintain API compatibility with the x86 builtins.
14559 @end deftypefn
14560
14561 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
14562 This function returns a value of @code{1} if the run-time CPU is of type
14563 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
14564 detected:
14565
14566 @table @samp
14567 @item power9
14568 IBM POWER9 Server CPU.
14569 @item power8
14570 IBM POWER8 Server CPU.
14571 @item power7
14572 IBM POWER7 Server CPU.
14573 @item power6x
14574 IBM POWER6 Server CPU (RAW mode).
14575 @item power6
14576 IBM POWER6 Server CPU (Architected mode).
14577 @item power5+
14578 IBM POWER5+ Server CPU.
14579 @item power5
14580 IBM POWER5 Server CPU.
14581 @item ppc970
14582 IBM 970 Server CPU (ie, Apple G5).
14583 @item power4
14584 IBM POWER4 Server CPU.
14585 @item ppca2
14586 IBM A2 64-bit Embedded CPU
14587 @item ppc476
14588 IBM PowerPC 476FP 32-bit Embedded CPU.
14589 @item ppc464
14590 IBM PowerPC 464 32-bit Embedded CPU.
14591 @item ppc440
14592 PowerPC 440 32-bit Embedded CPU.
14593 @item ppc405
14594 PowerPC 405 32-bit Embedded CPU.
14595 @item ppc-cell-be
14596 IBM PowerPC Cell Broadband Engine Architecture CPU.
14597 @end table
14598
14599 Here is an example:
14600 @smallexample
14601 if (__builtin_cpu_is ("power8"))
14602 @{
14603 do_power8 (); // POWER8 specific implementation.
14604 @}
14605 else
14606 @{
14607 do_generic (); // Generic implementation.
14608 @}
14609 @end smallexample
14610 @end deftypefn
14611
14612 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
14613 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
14614 feature @var{feature} and returns @code{0} otherwise. The following features can be
14615 detected:
14616
14617 @table @samp
14618 @item 4xxmac
14619 4xx CPU has a Multiply Accumulator.
14620 @item altivec
14621 CPU has a SIMD/Vector Unit.
14622 @item arch_2_05
14623 CPU supports ISA 2.05 (eg, POWER6)
14624 @item arch_2_06
14625 CPU supports ISA 2.06 (eg, POWER7)
14626 @item arch_2_07
14627 CPU supports ISA 2.07 (eg, POWER8)
14628 @item arch_3_00
14629 CPU supports ISA 3.0 (eg, POWER9)
14630 @item archpmu
14631 CPU supports the set of compatible performance monitoring events.
14632 @item booke
14633 CPU supports the Embedded ISA category.
14634 @item cellbe
14635 CPU has a CELL broadband engine.
14636 @item dfp
14637 CPU has a decimal floating point unit.
14638 @item dscr
14639 CPU supports the data stream control register.
14640 @item ebb
14641 CPU supports event base branching.
14642 @item efpdouble
14643 CPU has a SPE double precision floating point unit.
14644 @item efpsingle
14645 CPU has a SPE single precision floating point unit.
14646 @item fpu
14647 CPU has a floating point unit.
14648 @item htm
14649 CPU has hardware transaction memory instructions.
14650 @item htm-nosc
14651 Kernel aborts hardware transactions when a syscall is made.
14652 @item ic_snoop
14653 CPU supports icache snooping capabilities.
14654 @item ieee128
14655 CPU supports 128-bit IEEE binary floating point instructions.
14656 @item isel
14657 CPU supports the integer select instruction.
14658 @item mmu
14659 CPU has a memory management unit.
14660 @item notb
14661 CPU does not have a timebase (eg, 601 and 403gx).
14662 @item pa6t
14663 CPU supports the PA Semi 6T CORE ISA.
14664 @item power4
14665 CPU supports ISA 2.00 (eg, POWER4)
14666 @item power5
14667 CPU supports ISA 2.02 (eg, POWER5)
14668 @item power5+
14669 CPU supports ISA 2.03 (eg, POWER5+)
14670 @item power6x
14671 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
14672 @item ppc32
14673 CPU supports 32-bit mode execution.
14674 @item ppc601
14675 CPU supports the old POWER ISA (eg, 601)
14676 @item ppc64
14677 CPU supports 64-bit mode execution.
14678 @item ppcle
14679 CPU supports a little-endian mode that uses address swizzling.
14680 @item smt
14681 CPU support simultaneous multi-threading.
14682 @item spe
14683 CPU has a signal processing extension unit.
14684 @item tar
14685 CPU supports the target address register.
14686 @item true_le
14687 CPU supports true little-endian mode.
14688 @item ucache
14689 CPU has unified I/D cache.
14690 @item vcrypto
14691 CPU supports the vector cryptography instructions.
14692 @item vsx
14693 CPU supports the vector-scalar extension.
14694 @end table
14695
14696 Here is an example:
14697 @smallexample
14698 if (__builtin_cpu_supports ("fpu"))
14699 @{
14700 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
14701 @}
14702 else
14703 @{
14704 dst = __fadd (src1, src2); // Software FP addition function.
14705 @}
14706 @end smallexample
14707 @end deftypefn
14708
14709 These built-in functions are available for the PowerPC family of
14710 processors:
14711 @smallexample
14712 float __builtin_recipdivf (float, float);
14713 float __builtin_rsqrtf (float);
14714 double __builtin_recipdiv (double, double);
14715 double __builtin_rsqrt (double);
14716 uint64_t __builtin_ppc_get_timebase ();
14717 unsigned long __builtin_ppc_mftb ();
14718 double __builtin_unpack_longdouble (long double, int);
14719 long double __builtin_pack_longdouble (double, double);
14720 @end smallexample
14721
14722 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
14723 @code{__builtin_rsqrtf} functions generate multiple instructions to
14724 implement the reciprocal sqrt functionality using reciprocal sqrt
14725 estimate instructions.
14726
14727 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
14728 functions generate multiple instructions to implement division using
14729 the reciprocal estimate instructions.
14730
14731 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
14732 functions generate instructions to read the Time Base Register. The
14733 @code{__builtin_ppc_get_timebase} function may generate multiple
14734 instructions and always returns the 64 bits of the Time Base Register.
14735 The @code{__builtin_ppc_mftb} function always generates one instruction and
14736 returns the Time Base Register value as an unsigned long, throwing away
14737 the most significant word on 32-bit environments.
14738
14739 The following built-in functions are available for the PowerPC family
14740 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
14741 or @option{-mpopcntd}):
14742 @smallexample
14743 long __builtin_bpermd (long, long);
14744 int __builtin_divwe (int, int);
14745 int __builtin_divweo (int, int);
14746 unsigned int __builtin_divweu (unsigned int, unsigned int);
14747 unsigned int __builtin_divweuo (unsigned int, unsigned int);
14748 long __builtin_divde (long, long);
14749 long __builtin_divdeo (long, long);
14750 unsigned long __builtin_divdeu (unsigned long, unsigned long);
14751 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
14752 unsigned int cdtbcd (unsigned int);
14753 unsigned int cbcdtd (unsigned int);
14754 unsigned int addg6s (unsigned int, unsigned int);
14755 @end smallexample
14756
14757 The @code{__builtin_divde}, @code{__builtin_divdeo},
14758 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
14759 64-bit environment support ISA 2.06 or later.
14760
14761 The following built-in functions are available for the PowerPC family
14762 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9})
14763 or with @option{-mmodulo}:
14764 @smallexample
14765 long long __builtin_darn (void);
14766 long long __builtin_darn_raw (void);
14767 int __builtin_darn_32 (void);
14768 @end smallexample
14769
14770 The @code{__builtin_darn} and @code{__builtin_darn_raw}
14771 functions require a
14772 64-bit environment supporting ISA 3.0 or later.
14773 The @code{__builtin_darn} function provides a 64-bit conditioned
14774 random number. The @code{__builtin_darn_raw} function provides a
14775 64-bit raw random number. The @code{__builtin_darn_32} function
14776 provides a 32-bit random number.
14777
14778 The following built-in functions are available for the PowerPC family
14779 of processors when hardware decimal floating point
14780 (@option{-mhard-dfp}) is available:
14781 @smallexample
14782 _Decimal64 __builtin_dxex (_Decimal64);
14783 _Decimal128 __builtin_dxexq (_Decimal128);
14784 _Decimal64 __builtin_ddedpd (int, _Decimal64);
14785 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
14786 _Decimal64 __builtin_denbcd (int, _Decimal64);
14787 _Decimal128 __builtin_denbcdq (int, _Decimal128);
14788 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
14789 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
14790 _Decimal64 __builtin_dscli (_Decimal64, int);
14791 _Decimal128 __builtin_dscliq (_Decimal128, int);
14792 _Decimal64 __builtin_dscri (_Decimal64, int);
14793 _Decimal128 __builtin_dscriq (_Decimal128, int);
14794 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
14795 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
14796 @end smallexample
14797
14798 The following built-in functions are available for the PowerPC family
14799 of processors when the Vector Scalar (vsx) instruction set is
14800 available:
14801 @smallexample
14802 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
14803 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
14804 unsigned long long);
14805 @end smallexample
14806
14807 @node PowerPC AltiVec/VSX Built-in Functions
14808 @subsection PowerPC AltiVec Built-in Functions
14809
14810 GCC provides an interface for the PowerPC family of processors to access
14811 the AltiVec operations described in Motorola's AltiVec Programming
14812 Interface Manual. The interface is made available by including
14813 @code{<altivec.h>} and using @option{-maltivec} and
14814 @option{-mabi=altivec}. The interface supports the following vector
14815 types.
14816
14817 @smallexample
14818 vector unsigned char
14819 vector signed char
14820 vector bool char
14821
14822 vector unsigned short
14823 vector signed short
14824 vector bool short
14825 vector pixel
14826
14827 vector unsigned int
14828 vector signed int
14829 vector bool int
14830 vector float
14831 @end smallexample
14832
14833 If @option{-mvsx} is used the following additional vector types are
14834 implemented.
14835
14836 @smallexample
14837 vector unsigned long
14838 vector signed long
14839 vector double
14840 @end smallexample
14841
14842 The long types are only implemented for 64-bit code generation, and
14843 the long type is only used in the floating point/integer conversion
14844 instructions.
14845
14846 GCC's implementation of the high-level language interface available from
14847 C and C++ code differs from Motorola's documentation in several ways.
14848
14849 @itemize @bullet
14850
14851 @item
14852 A vector constant is a list of constant expressions within curly braces.
14853
14854 @item
14855 A vector initializer requires no cast if the vector constant is of the
14856 same type as the variable it is initializing.
14857
14858 @item
14859 If @code{signed} or @code{unsigned} is omitted, the signedness of the
14860 vector type is the default signedness of the base type. The default
14861 varies depending on the operating system, so a portable program should
14862 always specify the signedness.
14863
14864 @item
14865 Compiling with @option{-maltivec} adds keywords @code{__vector},
14866 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
14867 @code{bool}. When compiling ISO C, the context-sensitive substitution
14868 of the keywords @code{vector}, @code{pixel} and @code{bool} is
14869 disabled. To use them, you must include @code{<altivec.h>} instead.
14870
14871 @item
14872 GCC allows using a @code{typedef} name as the type specifier for a
14873 vector type.
14874
14875 @item
14876 For C, overloaded functions are implemented with macros so the following
14877 does not work:
14878
14879 @smallexample
14880 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
14881 @end smallexample
14882
14883 @noindent
14884 Since @code{vec_add} is a macro, the vector constant in the example
14885 is treated as four separate arguments. Wrap the entire argument in
14886 parentheses for this to work.
14887 @end itemize
14888
14889 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
14890 Internally, GCC uses built-in functions to achieve the functionality in
14891 the aforementioned header file, but they are not supported and are
14892 subject to change without notice.
14893
14894 The following interfaces are supported for the generic and specific
14895 AltiVec operations and the AltiVec predicates. In cases where there
14896 is a direct mapping between generic and specific operations, only the
14897 generic names are shown here, although the specific operations can also
14898 be used.
14899
14900 Arguments that are documented as @code{const int} require literal
14901 integral values within the range required for that operation.
14902
14903 @smallexample
14904 vector signed char vec_abs (vector signed char);
14905 vector signed short vec_abs (vector signed short);
14906 vector signed int vec_abs (vector signed int);
14907 vector float vec_abs (vector float);
14908
14909 vector signed char vec_abss (vector signed char);
14910 vector signed short vec_abss (vector signed short);
14911 vector signed int vec_abss (vector signed int);
14912
14913 vector signed char vec_add (vector bool char, vector signed char);
14914 vector signed char vec_add (vector signed char, vector bool char);
14915 vector signed char vec_add (vector signed char, vector signed char);
14916 vector unsigned char vec_add (vector bool char, vector unsigned char);
14917 vector unsigned char vec_add (vector unsigned char, vector bool char);
14918 vector unsigned char vec_add (vector unsigned char,
14919 vector unsigned char);
14920 vector signed short vec_add (vector bool short, vector signed short);
14921 vector signed short vec_add (vector signed short, vector bool short);
14922 vector signed short vec_add (vector signed short, vector signed short);
14923 vector unsigned short vec_add (vector bool short,
14924 vector unsigned short);
14925 vector unsigned short vec_add (vector unsigned short,
14926 vector bool short);
14927 vector unsigned short vec_add (vector unsigned short,
14928 vector unsigned short);
14929 vector signed int vec_add (vector bool int, vector signed int);
14930 vector signed int vec_add (vector signed int, vector bool int);
14931 vector signed int vec_add (vector signed int, vector signed int);
14932 vector unsigned int vec_add (vector bool int, vector unsigned int);
14933 vector unsigned int vec_add (vector unsigned int, vector bool int);
14934 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14935 vector float vec_add (vector float, vector float);
14936
14937 vector float vec_vaddfp (vector float, vector float);
14938
14939 vector signed int vec_vadduwm (vector bool int, vector signed int);
14940 vector signed int vec_vadduwm (vector signed int, vector bool int);
14941 vector signed int vec_vadduwm (vector signed int, vector signed int);
14942 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14943 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14944 vector unsigned int vec_vadduwm (vector unsigned int,
14945 vector unsigned int);
14946
14947 vector signed short vec_vadduhm (vector bool short,
14948 vector signed short);
14949 vector signed short vec_vadduhm (vector signed short,
14950 vector bool short);
14951 vector signed short vec_vadduhm (vector signed short,
14952 vector signed short);
14953 vector unsigned short vec_vadduhm (vector bool short,
14954 vector unsigned short);
14955 vector unsigned short vec_vadduhm (vector unsigned short,
14956 vector bool short);
14957 vector unsigned short vec_vadduhm (vector unsigned short,
14958 vector unsigned short);
14959
14960 vector signed char vec_vaddubm (vector bool char, vector signed char);
14961 vector signed char vec_vaddubm (vector signed char, vector bool char);
14962 vector signed char vec_vaddubm (vector signed char, vector signed char);
14963 vector unsigned char vec_vaddubm (vector bool char,
14964 vector unsigned char);
14965 vector unsigned char vec_vaddubm (vector unsigned char,
14966 vector bool char);
14967 vector unsigned char vec_vaddubm (vector unsigned char,
14968 vector unsigned char);
14969
14970 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14971
14972 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14973 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14974 vector unsigned char vec_adds (vector unsigned char,
14975 vector unsigned char);
14976 vector signed char vec_adds (vector bool char, vector signed char);
14977 vector signed char vec_adds (vector signed char, vector bool char);
14978 vector signed char vec_adds (vector signed char, vector signed char);
14979 vector unsigned short vec_adds (vector bool short,
14980 vector unsigned short);
14981 vector unsigned short vec_adds (vector unsigned short,
14982 vector bool short);
14983 vector unsigned short vec_adds (vector unsigned short,
14984 vector unsigned short);
14985 vector signed short vec_adds (vector bool short, vector signed short);
14986 vector signed short vec_adds (vector signed short, vector bool short);
14987 vector signed short vec_adds (vector signed short, vector signed short);
14988 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14989 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14990 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14991 vector signed int vec_adds (vector bool int, vector signed int);
14992 vector signed int vec_adds (vector signed int, vector bool int);
14993 vector signed int vec_adds (vector signed int, vector signed int);
14994
14995 vector signed int vec_vaddsws (vector bool int, vector signed int);
14996 vector signed int vec_vaddsws (vector signed int, vector bool int);
14997 vector signed int vec_vaddsws (vector signed int, vector signed int);
14998
14999 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
15000 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
15001 vector unsigned int vec_vadduws (vector unsigned int,
15002 vector unsigned int);
15003
15004 vector signed short vec_vaddshs (vector bool short,
15005 vector signed short);
15006 vector signed short vec_vaddshs (vector signed short,
15007 vector bool short);
15008 vector signed short vec_vaddshs (vector signed short,
15009 vector signed short);
15010
15011 vector unsigned short vec_vadduhs (vector bool short,
15012 vector unsigned short);
15013 vector unsigned short vec_vadduhs (vector unsigned short,
15014 vector bool short);
15015 vector unsigned short vec_vadduhs (vector unsigned short,
15016 vector unsigned short);
15017
15018 vector signed char vec_vaddsbs (vector bool char, vector signed char);
15019 vector signed char vec_vaddsbs (vector signed char, vector bool char);
15020 vector signed char vec_vaddsbs (vector signed char, vector signed char);
15021
15022 vector unsigned char vec_vaddubs (vector bool char,
15023 vector unsigned char);
15024 vector unsigned char vec_vaddubs (vector unsigned char,
15025 vector bool char);
15026 vector unsigned char vec_vaddubs (vector unsigned char,
15027 vector unsigned char);
15028
15029 vector float vec_and (vector float, vector float);
15030 vector float vec_and (vector float, vector bool int);
15031 vector float vec_and (vector bool int, vector float);
15032 vector bool int vec_and (vector bool int, vector bool int);
15033 vector signed int vec_and (vector bool int, vector signed int);
15034 vector signed int vec_and (vector signed int, vector bool int);
15035 vector signed int vec_and (vector signed int, vector signed int);
15036 vector unsigned int vec_and (vector bool int, vector unsigned int);
15037 vector unsigned int vec_and (vector unsigned int, vector bool int);
15038 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
15039 vector bool short vec_and (vector bool short, vector bool short);
15040 vector signed short vec_and (vector bool short, vector signed short);
15041 vector signed short vec_and (vector signed short, vector bool short);
15042 vector signed short vec_and (vector signed short, vector signed short);
15043 vector unsigned short vec_and (vector bool short,
15044 vector unsigned short);
15045 vector unsigned short vec_and (vector unsigned short,
15046 vector bool short);
15047 vector unsigned short vec_and (vector unsigned short,
15048 vector unsigned short);
15049 vector signed char vec_and (vector bool char, vector signed char);
15050 vector bool char vec_and (vector bool char, vector bool char);
15051 vector signed char vec_and (vector signed char, vector bool char);
15052 vector signed char vec_and (vector signed char, vector signed char);
15053 vector unsigned char vec_and (vector bool char, vector unsigned char);
15054 vector unsigned char vec_and (vector unsigned char, vector bool char);
15055 vector unsigned char vec_and (vector unsigned char,
15056 vector unsigned char);
15057
15058 vector float vec_andc (vector float, vector float);
15059 vector float vec_andc (vector float, vector bool int);
15060 vector float vec_andc (vector bool int, vector float);
15061 vector bool int vec_andc (vector bool int, vector bool int);
15062 vector signed int vec_andc (vector bool int, vector signed int);
15063 vector signed int vec_andc (vector signed int, vector bool int);
15064 vector signed int vec_andc (vector signed int, vector signed int);
15065 vector unsigned int vec_andc (vector bool int, vector unsigned int);
15066 vector unsigned int vec_andc (vector unsigned int, vector bool int);
15067 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
15068 vector bool short vec_andc (vector bool short, vector bool short);
15069 vector signed short vec_andc (vector bool short, vector signed short);
15070 vector signed short vec_andc (vector signed short, vector bool short);
15071 vector signed short vec_andc (vector signed short, vector signed short);
15072 vector unsigned short vec_andc (vector bool short,
15073 vector unsigned short);
15074 vector unsigned short vec_andc (vector unsigned short,
15075 vector bool short);
15076 vector unsigned short vec_andc (vector unsigned short,
15077 vector unsigned short);
15078 vector signed char vec_andc (vector bool char, vector signed char);
15079 vector bool char vec_andc (vector bool char, vector bool char);
15080 vector signed char vec_andc (vector signed char, vector bool char);
15081 vector signed char vec_andc (vector signed char, vector signed char);
15082 vector unsigned char vec_andc (vector bool char, vector unsigned char);
15083 vector unsigned char vec_andc (vector unsigned char, vector bool char);
15084 vector unsigned char vec_andc (vector unsigned char,
15085 vector unsigned char);
15086
15087 vector unsigned char vec_avg (vector unsigned char,
15088 vector unsigned char);
15089 vector signed char vec_avg (vector signed char, vector signed char);
15090 vector unsigned short vec_avg (vector unsigned short,
15091 vector unsigned short);
15092 vector signed short vec_avg (vector signed short, vector signed short);
15093 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
15094 vector signed int vec_avg (vector signed int, vector signed int);
15095
15096 vector signed int vec_vavgsw (vector signed int, vector signed int);
15097
15098 vector unsigned int vec_vavguw (vector unsigned int,
15099 vector unsigned int);
15100
15101 vector signed short vec_vavgsh (vector signed short,
15102 vector signed short);
15103
15104 vector unsigned short vec_vavguh (vector unsigned short,
15105 vector unsigned short);
15106
15107 vector signed char vec_vavgsb (vector signed char, vector signed char);
15108
15109 vector unsigned char vec_vavgub (vector unsigned char,
15110 vector unsigned char);
15111
15112 vector float vec_copysign (vector float);
15113
15114 vector float vec_ceil (vector float);
15115
15116 vector signed int vec_cmpb (vector float, vector float);
15117
15118 vector bool char vec_cmpeq (vector signed char, vector signed char);
15119 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
15120 vector bool short vec_cmpeq (vector signed short, vector signed short);
15121 vector bool short vec_cmpeq (vector unsigned short,
15122 vector unsigned short);
15123 vector bool int vec_cmpeq (vector signed int, vector signed int);
15124 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
15125 vector bool int vec_cmpeq (vector float, vector float);
15126
15127 vector bool int vec_vcmpeqfp (vector float, vector float);
15128
15129 vector bool int vec_vcmpequw (vector signed int, vector signed int);
15130 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
15131
15132 vector bool short vec_vcmpequh (vector signed short,
15133 vector signed short);
15134 vector bool short vec_vcmpequh (vector unsigned short,
15135 vector unsigned short);
15136
15137 vector bool char vec_vcmpequb (vector signed char, vector signed char);
15138 vector bool char vec_vcmpequb (vector unsigned char,
15139 vector unsigned char);
15140
15141 vector bool int vec_cmpge (vector float, vector float);
15142
15143 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
15144 vector bool char vec_cmpgt (vector signed char, vector signed char);
15145 vector bool short vec_cmpgt (vector unsigned short,
15146 vector unsigned short);
15147 vector bool short vec_cmpgt (vector signed short, vector signed short);
15148 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
15149 vector bool int vec_cmpgt (vector signed int, vector signed int);
15150 vector bool int vec_cmpgt (vector float, vector float);
15151
15152 vector bool int vec_vcmpgtfp (vector float, vector float);
15153
15154 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
15155
15156 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
15157
15158 vector bool short vec_vcmpgtsh (vector signed short,
15159 vector signed short);
15160
15161 vector bool short vec_vcmpgtuh (vector unsigned short,
15162 vector unsigned short);
15163
15164 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
15165
15166 vector bool char vec_vcmpgtub (vector unsigned char,
15167 vector unsigned char);
15168
15169 vector bool int vec_cmple (vector float, vector float);
15170
15171 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
15172 vector bool char vec_cmplt (vector signed char, vector signed char);
15173 vector bool short vec_cmplt (vector unsigned short,
15174 vector unsigned short);
15175 vector bool short vec_cmplt (vector signed short, vector signed short);
15176 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
15177 vector bool int vec_cmplt (vector signed int, vector signed int);
15178 vector bool int vec_cmplt (vector float, vector float);
15179
15180 vector float vec_cpsgn (vector float, vector float);
15181
15182 vector float vec_ctf (vector unsigned int, const int);
15183 vector float vec_ctf (vector signed int, const int);
15184 vector double vec_ctf (vector unsigned long, const int);
15185 vector double vec_ctf (vector signed long, const int);
15186
15187 vector float vec_vcfsx (vector signed int, const int);
15188
15189 vector float vec_vcfux (vector unsigned int, const int);
15190
15191 vector signed int vec_cts (vector float, const int);
15192 vector signed long vec_cts (vector double, const int);
15193
15194 vector unsigned int vec_ctu (vector float, const int);
15195 vector unsigned long vec_ctu (vector double, const int);
15196
15197 void vec_dss (const int);
15198
15199 void vec_dssall (void);
15200
15201 void vec_dst (const vector unsigned char *, int, const int);
15202 void vec_dst (const vector signed char *, int, const int);
15203 void vec_dst (const vector bool char *, int, const int);
15204 void vec_dst (const vector unsigned short *, int, const int);
15205 void vec_dst (const vector signed short *, int, const int);
15206 void vec_dst (const vector bool short *, int, const int);
15207 void vec_dst (const vector pixel *, int, const int);
15208 void vec_dst (const vector unsigned int *, int, const int);
15209 void vec_dst (const vector signed int *, int, const int);
15210 void vec_dst (const vector bool int *, int, const int);
15211 void vec_dst (const vector float *, int, const int);
15212 void vec_dst (const unsigned char *, int, const int);
15213 void vec_dst (const signed char *, int, const int);
15214 void vec_dst (const unsigned short *, int, const int);
15215 void vec_dst (const short *, int, const int);
15216 void vec_dst (const unsigned int *, int, const int);
15217 void vec_dst (const int *, int, const int);
15218 void vec_dst (const unsigned long *, int, const int);
15219 void vec_dst (const long *, int, const int);
15220 void vec_dst (const float *, int, const int);
15221
15222 void vec_dstst (const vector unsigned char *, int, const int);
15223 void vec_dstst (const vector signed char *, int, const int);
15224 void vec_dstst (const vector bool char *, int, const int);
15225 void vec_dstst (const vector unsigned short *, int, const int);
15226 void vec_dstst (const vector signed short *, int, const int);
15227 void vec_dstst (const vector bool short *, int, const int);
15228 void vec_dstst (const vector pixel *, int, const int);
15229 void vec_dstst (const vector unsigned int *, int, const int);
15230 void vec_dstst (const vector signed int *, int, const int);
15231 void vec_dstst (const vector bool int *, int, const int);
15232 void vec_dstst (const vector float *, int, const int);
15233 void vec_dstst (const unsigned char *, int, const int);
15234 void vec_dstst (const signed char *, int, const int);
15235 void vec_dstst (const unsigned short *, int, const int);
15236 void vec_dstst (const short *, int, const int);
15237 void vec_dstst (const unsigned int *, int, const int);
15238 void vec_dstst (const int *, int, const int);
15239 void vec_dstst (const unsigned long *, int, const int);
15240 void vec_dstst (const long *, int, const int);
15241 void vec_dstst (const float *, int, const int);
15242
15243 void vec_dststt (const vector unsigned char *, int, const int);
15244 void vec_dststt (const vector signed char *, int, const int);
15245 void vec_dststt (const vector bool char *, int, const int);
15246 void vec_dststt (const vector unsigned short *, int, const int);
15247 void vec_dststt (const vector signed short *, int, const int);
15248 void vec_dststt (const vector bool short *, int, const int);
15249 void vec_dststt (const vector pixel *, int, const int);
15250 void vec_dststt (const vector unsigned int *, int, const int);
15251 void vec_dststt (const vector signed int *, int, const int);
15252 void vec_dststt (const vector bool int *, int, const int);
15253 void vec_dststt (const vector float *, int, const int);
15254 void vec_dststt (const unsigned char *, int, const int);
15255 void vec_dststt (const signed char *, int, const int);
15256 void vec_dststt (const unsigned short *, int, const int);
15257 void vec_dststt (const short *, int, const int);
15258 void vec_dststt (const unsigned int *, int, const int);
15259 void vec_dststt (const int *, int, const int);
15260 void vec_dststt (const unsigned long *, int, const int);
15261 void vec_dststt (const long *, int, const int);
15262 void vec_dststt (const float *, int, const int);
15263
15264 void vec_dstt (const vector unsigned char *, int, const int);
15265 void vec_dstt (const vector signed char *, int, const int);
15266 void vec_dstt (const vector bool char *, int, const int);
15267 void vec_dstt (const vector unsigned short *, int, const int);
15268 void vec_dstt (const vector signed short *, int, const int);
15269 void vec_dstt (const vector bool short *, int, const int);
15270 void vec_dstt (const vector pixel *, int, const int);
15271 void vec_dstt (const vector unsigned int *, int, const int);
15272 void vec_dstt (const vector signed int *, int, const int);
15273 void vec_dstt (const vector bool int *, int, const int);
15274 void vec_dstt (const vector float *, int, const int);
15275 void vec_dstt (const unsigned char *, int, const int);
15276 void vec_dstt (const signed char *, int, const int);
15277 void vec_dstt (const unsigned short *, int, const int);
15278 void vec_dstt (const short *, int, const int);
15279 void vec_dstt (const unsigned int *, int, const int);
15280 void vec_dstt (const int *, int, const int);
15281 void vec_dstt (const unsigned long *, int, const int);
15282 void vec_dstt (const long *, int, const int);
15283 void vec_dstt (const float *, int, const int);
15284
15285 vector float vec_expte (vector float);
15286
15287 vector float vec_floor (vector float);
15288
15289 vector float vec_ld (int, const vector float *);
15290 vector float vec_ld (int, const float *);
15291 vector bool int vec_ld (int, const vector bool int *);
15292 vector signed int vec_ld (int, const vector signed int *);
15293 vector signed int vec_ld (int, const int *);
15294 vector signed int vec_ld (int, const long *);
15295 vector unsigned int vec_ld (int, const vector unsigned int *);
15296 vector unsigned int vec_ld (int, const unsigned int *);
15297 vector unsigned int vec_ld (int, const unsigned long *);
15298 vector bool short vec_ld (int, const vector bool short *);
15299 vector pixel vec_ld (int, const vector pixel *);
15300 vector signed short vec_ld (int, const vector signed short *);
15301 vector signed short vec_ld (int, const short *);
15302 vector unsigned short vec_ld (int, const vector unsigned short *);
15303 vector unsigned short vec_ld (int, const unsigned short *);
15304 vector bool char vec_ld (int, const vector bool char *);
15305 vector signed char vec_ld (int, const vector signed char *);
15306 vector signed char vec_ld (int, const signed char *);
15307 vector unsigned char vec_ld (int, const vector unsigned char *);
15308 vector unsigned char vec_ld (int, const unsigned char *);
15309
15310 vector signed char vec_lde (int, const signed char *);
15311 vector unsigned char vec_lde (int, const unsigned char *);
15312 vector signed short vec_lde (int, const short *);
15313 vector unsigned short vec_lde (int, const unsigned short *);
15314 vector float vec_lde (int, const float *);
15315 vector signed int vec_lde (int, const int *);
15316 vector unsigned int vec_lde (int, const unsigned int *);
15317 vector signed int vec_lde (int, const long *);
15318 vector unsigned int vec_lde (int, const unsigned long *);
15319
15320 vector float vec_lvewx (int, float *);
15321 vector signed int vec_lvewx (int, int *);
15322 vector unsigned int vec_lvewx (int, unsigned int *);
15323 vector signed int vec_lvewx (int, long *);
15324 vector unsigned int vec_lvewx (int, unsigned long *);
15325
15326 vector signed short vec_lvehx (int, short *);
15327 vector unsigned short vec_lvehx (int, unsigned short *);
15328
15329 vector signed char vec_lvebx (int, char *);
15330 vector unsigned char vec_lvebx (int, unsigned char *);
15331
15332 vector float vec_ldl (int, const vector float *);
15333 vector float vec_ldl (int, const float *);
15334 vector bool int vec_ldl (int, const vector bool int *);
15335 vector signed int vec_ldl (int, const vector signed int *);
15336 vector signed int vec_ldl (int, const int *);
15337 vector signed int vec_ldl (int, const long *);
15338 vector unsigned int vec_ldl (int, const vector unsigned int *);
15339 vector unsigned int vec_ldl (int, const unsigned int *);
15340 vector unsigned int vec_ldl (int, const unsigned long *);
15341 vector bool short vec_ldl (int, const vector bool short *);
15342 vector pixel vec_ldl (int, const vector pixel *);
15343 vector signed short vec_ldl (int, const vector signed short *);
15344 vector signed short vec_ldl (int, const short *);
15345 vector unsigned short vec_ldl (int, const vector unsigned short *);
15346 vector unsigned short vec_ldl (int, const unsigned short *);
15347 vector bool char vec_ldl (int, const vector bool char *);
15348 vector signed char vec_ldl (int, const vector signed char *);
15349 vector signed char vec_ldl (int, const signed char *);
15350 vector unsigned char vec_ldl (int, const vector unsigned char *);
15351 vector unsigned char vec_ldl (int, const unsigned char *);
15352
15353 vector float vec_loge (vector float);
15354
15355 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
15356 vector unsigned char vec_lvsl (int, const volatile signed char *);
15357 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
15358 vector unsigned char vec_lvsl (int, const volatile short *);
15359 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
15360 vector unsigned char vec_lvsl (int, const volatile int *);
15361 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
15362 vector unsigned char vec_lvsl (int, const volatile long *);
15363 vector unsigned char vec_lvsl (int, const volatile float *);
15364
15365 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
15366 vector unsigned char vec_lvsr (int, const volatile signed char *);
15367 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
15368 vector unsigned char vec_lvsr (int, const volatile short *);
15369 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
15370 vector unsigned char vec_lvsr (int, const volatile int *);
15371 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
15372 vector unsigned char vec_lvsr (int, const volatile long *);
15373 vector unsigned char vec_lvsr (int, const volatile float *);
15374
15375 vector float vec_madd (vector float, vector float, vector float);
15376
15377 vector signed short vec_madds (vector signed short,
15378 vector signed short,
15379 vector signed short);
15380
15381 vector unsigned char vec_max (vector bool char, vector unsigned char);
15382 vector unsigned char vec_max (vector unsigned char, vector bool char);
15383 vector unsigned char vec_max (vector unsigned char,
15384 vector unsigned char);
15385 vector signed char vec_max (vector bool char, vector signed char);
15386 vector signed char vec_max (vector signed char, vector bool char);
15387 vector signed char vec_max (vector signed char, vector signed char);
15388 vector unsigned short vec_max (vector bool short,
15389 vector unsigned short);
15390 vector unsigned short vec_max (vector unsigned short,
15391 vector bool short);
15392 vector unsigned short vec_max (vector unsigned short,
15393 vector unsigned short);
15394 vector signed short vec_max (vector bool short, vector signed short);
15395 vector signed short vec_max (vector signed short, vector bool short);
15396 vector signed short vec_max (vector signed short, vector signed short);
15397 vector unsigned int vec_max (vector bool int, vector unsigned int);
15398 vector unsigned int vec_max (vector unsigned int, vector bool int);
15399 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
15400 vector signed int vec_max (vector bool int, vector signed int);
15401 vector signed int vec_max (vector signed int, vector bool int);
15402 vector signed int vec_max (vector signed int, vector signed int);
15403 vector float vec_max (vector float, vector float);
15404
15405 vector float vec_vmaxfp (vector float, vector float);
15406
15407 vector signed int vec_vmaxsw (vector bool int, vector signed int);
15408 vector signed int vec_vmaxsw (vector signed int, vector bool int);
15409 vector signed int vec_vmaxsw (vector signed int, vector signed int);
15410
15411 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
15412 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
15413 vector unsigned int vec_vmaxuw (vector unsigned int,
15414 vector unsigned int);
15415
15416 vector signed short vec_vmaxsh (vector bool short, vector signed short);
15417 vector signed short vec_vmaxsh (vector signed short, vector bool short);
15418 vector signed short vec_vmaxsh (vector signed short,
15419 vector signed short);
15420
15421 vector unsigned short vec_vmaxuh (vector bool short,
15422 vector unsigned short);
15423 vector unsigned short vec_vmaxuh (vector unsigned short,
15424 vector bool short);
15425 vector unsigned short vec_vmaxuh (vector unsigned short,
15426 vector unsigned short);
15427
15428 vector signed char vec_vmaxsb (vector bool char, vector signed char);
15429 vector signed char vec_vmaxsb (vector signed char, vector bool char);
15430 vector signed char vec_vmaxsb (vector signed char, vector signed char);
15431
15432 vector unsigned char vec_vmaxub (vector bool char,
15433 vector unsigned char);
15434 vector unsigned char vec_vmaxub (vector unsigned char,
15435 vector bool char);
15436 vector unsigned char vec_vmaxub (vector unsigned char,
15437 vector unsigned char);
15438
15439 vector bool char vec_mergeh (vector bool char, vector bool char);
15440 vector signed char vec_mergeh (vector signed char, vector signed char);
15441 vector unsigned char vec_mergeh (vector unsigned char,
15442 vector unsigned char);
15443 vector bool short vec_mergeh (vector bool short, vector bool short);
15444 vector pixel vec_mergeh (vector pixel, vector pixel);
15445 vector signed short vec_mergeh (vector signed short,
15446 vector signed short);
15447 vector unsigned short vec_mergeh (vector unsigned short,
15448 vector unsigned short);
15449 vector float vec_mergeh (vector float, vector float);
15450 vector bool int vec_mergeh (vector bool int, vector bool int);
15451 vector signed int vec_mergeh (vector signed int, vector signed int);
15452 vector unsigned int vec_mergeh (vector unsigned int,
15453 vector unsigned int);
15454
15455 vector float vec_vmrghw (vector float, vector float);
15456 vector bool int vec_vmrghw (vector bool int, vector bool int);
15457 vector signed int vec_vmrghw (vector signed int, vector signed int);
15458 vector unsigned int vec_vmrghw (vector unsigned int,
15459 vector unsigned int);
15460
15461 vector bool short vec_vmrghh (vector bool short, vector bool short);
15462 vector signed short vec_vmrghh (vector signed short,
15463 vector signed short);
15464 vector unsigned short vec_vmrghh (vector unsigned short,
15465 vector unsigned short);
15466 vector pixel vec_vmrghh (vector pixel, vector pixel);
15467
15468 vector bool char vec_vmrghb (vector bool char, vector bool char);
15469 vector signed char vec_vmrghb (vector signed char, vector signed char);
15470 vector unsigned char vec_vmrghb (vector unsigned char,
15471 vector unsigned char);
15472
15473 vector bool char vec_mergel (vector bool char, vector bool char);
15474 vector signed char vec_mergel (vector signed char, vector signed char);
15475 vector unsigned char vec_mergel (vector unsigned char,
15476 vector unsigned char);
15477 vector bool short vec_mergel (vector bool short, vector bool short);
15478 vector pixel vec_mergel (vector pixel, vector pixel);
15479 vector signed short vec_mergel (vector signed short,
15480 vector signed short);
15481 vector unsigned short vec_mergel (vector unsigned short,
15482 vector unsigned short);
15483 vector float vec_mergel (vector float, vector float);
15484 vector bool int vec_mergel (vector bool int, vector bool int);
15485 vector signed int vec_mergel (vector signed int, vector signed int);
15486 vector unsigned int vec_mergel (vector unsigned int,
15487 vector unsigned int);
15488
15489 vector float vec_vmrglw (vector float, vector float);
15490 vector signed int vec_vmrglw (vector signed int, vector signed int);
15491 vector unsigned int vec_vmrglw (vector unsigned int,
15492 vector unsigned int);
15493 vector bool int vec_vmrglw (vector bool int, vector bool int);
15494
15495 vector bool short vec_vmrglh (vector bool short, vector bool short);
15496 vector signed short vec_vmrglh (vector signed short,
15497 vector signed short);
15498 vector unsigned short vec_vmrglh (vector unsigned short,
15499 vector unsigned short);
15500 vector pixel vec_vmrglh (vector pixel, vector pixel);
15501
15502 vector bool char vec_vmrglb (vector bool char, vector bool char);
15503 vector signed char vec_vmrglb (vector signed char, vector signed char);
15504 vector unsigned char vec_vmrglb (vector unsigned char,
15505 vector unsigned char);
15506
15507 vector unsigned short vec_mfvscr (void);
15508
15509 vector unsigned char vec_min (vector bool char, vector unsigned char);
15510 vector unsigned char vec_min (vector unsigned char, vector bool char);
15511 vector unsigned char vec_min (vector unsigned char,
15512 vector unsigned char);
15513 vector signed char vec_min (vector bool char, vector signed char);
15514 vector signed char vec_min (vector signed char, vector bool char);
15515 vector signed char vec_min (vector signed char, vector signed char);
15516 vector unsigned short vec_min (vector bool short,
15517 vector unsigned short);
15518 vector unsigned short vec_min (vector unsigned short,
15519 vector bool short);
15520 vector unsigned short vec_min (vector unsigned short,
15521 vector unsigned short);
15522 vector signed short vec_min (vector bool short, vector signed short);
15523 vector signed short vec_min (vector signed short, vector bool short);
15524 vector signed short vec_min (vector signed short, vector signed short);
15525 vector unsigned int vec_min (vector bool int, vector unsigned int);
15526 vector unsigned int vec_min (vector unsigned int, vector bool int);
15527 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
15528 vector signed int vec_min (vector bool int, vector signed int);
15529 vector signed int vec_min (vector signed int, vector bool int);
15530 vector signed int vec_min (vector signed int, vector signed int);
15531 vector float vec_min (vector float, vector float);
15532
15533 vector float vec_vminfp (vector float, vector float);
15534
15535 vector signed int vec_vminsw (vector bool int, vector signed int);
15536 vector signed int vec_vminsw (vector signed int, vector bool int);
15537 vector signed int vec_vminsw (vector signed int, vector signed int);
15538
15539 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
15540 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
15541 vector unsigned int vec_vminuw (vector unsigned int,
15542 vector unsigned int);
15543
15544 vector signed short vec_vminsh (vector bool short, vector signed short);
15545 vector signed short vec_vminsh (vector signed short, vector bool short);
15546 vector signed short vec_vminsh (vector signed short,
15547 vector signed short);
15548
15549 vector unsigned short vec_vminuh (vector bool short,
15550 vector unsigned short);
15551 vector unsigned short vec_vminuh (vector unsigned short,
15552 vector bool short);
15553 vector unsigned short vec_vminuh (vector unsigned short,
15554 vector unsigned short);
15555
15556 vector signed char vec_vminsb (vector bool char, vector signed char);
15557 vector signed char vec_vminsb (vector signed char, vector bool char);
15558 vector signed char vec_vminsb (vector signed char, vector signed char);
15559
15560 vector unsigned char vec_vminub (vector bool char,
15561 vector unsigned char);
15562 vector unsigned char vec_vminub (vector unsigned char,
15563 vector bool char);
15564 vector unsigned char vec_vminub (vector unsigned char,
15565 vector unsigned char);
15566
15567 vector signed short vec_mladd (vector signed short,
15568 vector signed short,
15569 vector signed short);
15570 vector signed short vec_mladd (vector signed short,
15571 vector unsigned short,
15572 vector unsigned short);
15573 vector signed short vec_mladd (vector unsigned short,
15574 vector signed short,
15575 vector signed short);
15576 vector unsigned short vec_mladd (vector unsigned short,
15577 vector unsigned short,
15578 vector unsigned short);
15579
15580 vector signed short vec_mradds (vector signed short,
15581 vector signed short,
15582 vector signed short);
15583
15584 vector unsigned int vec_msum (vector unsigned char,
15585 vector unsigned char,
15586 vector unsigned int);
15587 vector signed int vec_msum (vector signed char,
15588 vector unsigned char,
15589 vector signed int);
15590 vector unsigned int vec_msum (vector unsigned short,
15591 vector unsigned short,
15592 vector unsigned int);
15593 vector signed int vec_msum (vector signed short,
15594 vector signed short,
15595 vector signed int);
15596
15597 vector signed int vec_vmsumshm (vector signed short,
15598 vector signed short,
15599 vector signed int);
15600
15601 vector unsigned int vec_vmsumuhm (vector unsigned short,
15602 vector unsigned short,
15603 vector unsigned int);
15604
15605 vector signed int vec_vmsummbm (vector signed char,
15606 vector unsigned char,
15607 vector signed int);
15608
15609 vector unsigned int vec_vmsumubm (vector unsigned char,
15610 vector unsigned char,
15611 vector unsigned int);
15612
15613 vector unsigned int vec_msums (vector unsigned short,
15614 vector unsigned short,
15615 vector unsigned int);
15616 vector signed int vec_msums (vector signed short,
15617 vector signed short,
15618 vector signed int);
15619
15620 vector signed int vec_vmsumshs (vector signed short,
15621 vector signed short,
15622 vector signed int);
15623
15624 vector unsigned int vec_vmsumuhs (vector unsigned short,
15625 vector unsigned short,
15626 vector unsigned int);
15627
15628 void vec_mtvscr (vector signed int);
15629 void vec_mtvscr (vector unsigned int);
15630 void vec_mtvscr (vector bool int);
15631 void vec_mtvscr (vector signed short);
15632 void vec_mtvscr (vector unsigned short);
15633 void vec_mtvscr (vector bool short);
15634 void vec_mtvscr (vector pixel);
15635 void vec_mtvscr (vector signed char);
15636 void vec_mtvscr (vector unsigned char);
15637 void vec_mtvscr (vector bool char);
15638
15639 vector unsigned short vec_mule (vector unsigned char,
15640 vector unsigned char);
15641 vector signed short vec_mule (vector signed char,
15642 vector signed char);
15643 vector unsigned int vec_mule (vector unsigned short,
15644 vector unsigned short);
15645 vector signed int vec_mule (vector signed short, vector signed short);
15646
15647 vector signed int vec_vmulesh (vector signed short,
15648 vector signed short);
15649
15650 vector unsigned int vec_vmuleuh (vector unsigned short,
15651 vector unsigned short);
15652
15653 vector signed short vec_vmulesb (vector signed char,
15654 vector signed char);
15655
15656 vector unsigned short vec_vmuleub (vector unsigned char,
15657 vector unsigned char);
15658
15659 vector unsigned short vec_mulo (vector unsigned char,
15660 vector unsigned char);
15661 vector signed short vec_mulo (vector signed char, vector signed char);
15662 vector unsigned int vec_mulo (vector unsigned short,
15663 vector unsigned short);
15664 vector signed int vec_mulo (vector signed short, vector signed short);
15665
15666 vector signed int vec_vmulosh (vector signed short,
15667 vector signed short);
15668
15669 vector unsigned int vec_vmulouh (vector unsigned short,
15670 vector unsigned short);
15671
15672 vector signed short vec_vmulosb (vector signed char,
15673 vector signed char);
15674
15675 vector unsigned short vec_vmuloub (vector unsigned char,
15676 vector unsigned char);
15677
15678 vector float vec_nmsub (vector float, vector float, vector float);
15679
15680 vector float vec_nor (vector float, vector float);
15681 vector signed int vec_nor (vector signed int, vector signed int);
15682 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
15683 vector bool int vec_nor (vector bool int, vector bool int);
15684 vector signed short vec_nor (vector signed short, vector signed short);
15685 vector unsigned short vec_nor (vector unsigned short,
15686 vector unsigned short);
15687 vector bool short vec_nor (vector bool short, vector bool short);
15688 vector signed char vec_nor (vector signed char, vector signed char);
15689 vector unsigned char vec_nor (vector unsigned char,
15690 vector unsigned char);
15691 vector bool char vec_nor (vector bool char, vector bool char);
15692
15693 vector float vec_or (vector float, vector float);
15694 vector float vec_or (vector float, vector bool int);
15695 vector float vec_or (vector bool int, vector float);
15696 vector bool int vec_or (vector bool int, vector bool int);
15697 vector signed int vec_or (vector bool int, vector signed int);
15698 vector signed int vec_or (vector signed int, vector bool int);
15699 vector signed int vec_or (vector signed int, vector signed int);
15700 vector unsigned int vec_or (vector bool int, vector unsigned int);
15701 vector unsigned int vec_or (vector unsigned int, vector bool int);
15702 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
15703 vector bool short vec_or (vector bool short, vector bool short);
15704 vector signed short vec_or (vector bool short, vector signed short);
15705 vector signed short vec_or (vector signed short, vector bool short);
15706 vector signed short vec_or (vector signed short, vector signed short);
15707 vector unsigned short vec_or (vector bool short, vector unsigned short);
15708 vector unsigned short vec_or (vector unsigned short, vector bool short);
15709 vector unsigned short vec_or (vector unsigned short,
15710 vector unsigned short);
15711 vector signed char vec_or (vector bool char, vector signed char);
15712 vector bool char vec_or (vector bool char, vector bool char);
15713 vector signed char vec_or (vector signed char, vector bool char);
15714 vector signed char vec_or (vector signed char, vector signed char);
15715 vector unsigned char vec_or (vector bool char, vector unsigned char);
15716 vector unsigned char vec_or (vector unsigned char, vector bool char);
15717 vector unsigned char vec_or (vector unsigned char,
15718 vector unsigned char);
15719
15720 vector signed char vec_pack (vector signed short, vector signed short);
15721 vector unsigned char vec_pack (vector unsigned short,
15722 vector unsigned short);
15723 vector bool char vec_pack (vector bool short, vector bool short);
15724 vector signed short vec_pack (vector signed int, vector signed int);
15725 vector unsigned short vec_pack (vector unsigned int,
15726 vector unsigned int);
15727 vector bool short vec_pack (vector bool int, vector bool int);
15728
15729 vector bool short vec_vpkuwum (vector bool int, vector bool int);
15730 vector signed short vec_vpkuwum (vector signed int, vector signed int);
15731 vector unsigned short vec_vpkuwum (vector unsigned int,
15732 vector unsigned int);
15733
15734 vector bool char vec_vpkuhum (vector bool short, vector bool short);
15735 vector signed char vec_vpkuhum (vector signed short,
15736 vector signed short);
15737 vector unsigned char vec_vpkuhum (vector unsigned short,
15738 vector unsigned short);
15739
15740 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
15741
15742 vector unsigned char vec_packs (vector unsigned short,
15743 vector unsigned short);
15744 vector signed char vec_packs (vector signed short, vector signed short);
15745 vector unsigned short vec_packs (vector unsigned int,
15746 vector unsigned int);
15747 vector signed short vec_packs (vector signed int, vector signed int);
15748
15749 vector signed short vec_vpkswss (vector signed int, vector signed int);
15750
15751 vector unsigned short vec_vpkuwus (vector unsigned int,
15752 vector unsigned int);
15753
15754 vector signed char vec_vpkshss (vector signed short,
15755 vector signed short);
15756
15757 vector unsigned char vec_vpkuhus (vector unsigned short,
15758 vector unsigned short);
15759
15760 vector unsigned char vec_packsu (vector unsigned short,
15761 vector unsigned short);
15762 vector unsigned char vec_packsu (vector signed short,
15763 vector signed short);
15764 vector unsigned short vec_packsu (vector unsigned int,
15765 vector unsigned int);
15766 vector unsigned short vec_packsu (vector signed int, vector signed int);
15767
15768 vector unsigned short vec_vpkswus (vector signed int,
15769 vector signed int);
15770
15771 vector unsigned char vec_vpkshus (vector signed short,
15772 vector signed short);
15773
15774 vector float vec_perm (vector float,
15775 vector float,
15776 vector unsigned char);
15777 vector signed int vec_perm (vector signed int,
15778 vector signed int,
15779 vector unsigned char);
15780 vector unsigned int vec_perm (vector unsigned int,
15781 vector unsigned int,
15782 vector unsigned char);
15783 vector bool int vec_perm (vector bool int,
15784 vector bool int,
15785 vector unsigned char);
15786 vector signed short vec_perm (vector signed short,
15787 vector signed short,
15788 vector unsigned char);
15789 vector unsigned short vec_perm (vector unsigned short,
15790 vector unsigned short,
15791 vector unsigned char);
15792 vector bool short vec_perm (vector bool short,
15793 vector bool short,
15794 vector unsigned char);
15795 vector pixel vec_perm (vector pixel,
15796 vector pixel,
15797 vector unsigned char);
15798 vector signed char vec_perm (vector signed char,
15799 vector signed char,
15800 vector unsigned char);
15801 vector unsigned char vec_perm (vector unsigned char,
15802 vector unsigned char,
15803 vector unsigned char);
15804 vector bool char vec_perm (vector bool char,
15805 vector bool char,
15806 vector unsigned char);
15807
15808 vector float vec_re (vector float);
15809
15810 vector signed char vec_rl (vector signed char,
15811 vector unsigned char);
15812 vector unsigned char vec_rl (vector unsigned char,
15813 vector unsigned char);
15814 vector signed short vec_rl (vector signed short, vector unsigned short);
15815 vector unsigned short vec_rl (vector unsigned short,
15816 vector unsigned short);
15817 vector signed int vec_rl (vector signed int, vector unsigned int);
15818 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
15819
15820 vector signed int vec_vrlw (vector signed int, vector unsigned int);
15821 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
15822
15823 vector signed short vec_vrlh (vector signed short,
15824 vector unsigned short);
15825 vector unsigned short vec_vrlh (vector unsigned short,
15826 vector unsigned short);
15827
15828 vector signed char vec_vrlb (vector signed char, vector unsigned char);
15829 vector unsigned char vec_vrlb (vector unsigned char,
15830 vector unsigned char);
15831
15832 vector float vec_round (vector float);
15833
15834 vector float vec_recip (vector float, vector float);
15835
15836 vector float vec_rsqrt (vector float);
15837
15838 vector float vec_rsqrte (vector float);
15839
15840 vector float vec_sel (vector float, vector float, vector bool int);
15841 vector float vec_sel (vector float, vector float, vector unsigned int);
15842 vector signed int vec_sel (vector signed int,
15843 vector signed int,
15844 vector bool int);
15845 vector signed int vec_sel (vector signed int,
15846 vector signed int,
15847 vector unsigned int);
15848 vector unsigned int vec_sel (vector unsigned int,
15849 vector unsigned int,
15850 vector bool int);
15851 vector unsigned int vec_sel (vector unsigned int,
15852 vector unsigned int,
15853 vector unsigned int);
15854 vector bool int vec_sel (vector bool int,
15855 vector bool int,
15856 vector bool int);
15857 vector bool int vec_sel (vector bool int,
15858 vector bool int,
15859 vector unsigned int);
15860 vector signed short vec_sel (vector signed short,
15861 vector signed short,
15862 vector bool short);
15863 vector signed short vec_sel (vector signed short,
15864 vector signed short,
15865 vector unsigned short);
15866 vector unsigned short vec_sel (vector unsigned short,
15867 vector unsigned short,
15868 vector bool short);
15869 vector unsigned short vec_sel (vector unsigned short,
15870 vector unsigned short,
15871 vector unsigned short);
15872 vector bool short vec_sel (vector bool short,
15873 vector bool short,
15874 vector bool short);
15875 vector bool short vec_sel (vector bool short,
15876 vector bool short,
15877 vector unsigned short);
15878 vector signed char vec_sel (vector signed char,
15879 vector signed char,
15880 vector bool char);
15881 vector signed char vec_sel (vector signed char,
15882 vector signed char,
15883 vector unsigned char);
15884 vector unsigned char vec_sel (vector unsigned char,
15885 vector unsigned char,
15886 vector bool char);
15887 vector unsigned char vec_sel (vector unsigned char,
15888 vector unsigned char,
15889 vector unsigned char);
15890 vector bool char vec_sel (vector bool char,
15891 vector bool char,
15892 vector bool char);
15893 vector bool char vec_sel (vector bool char,
15894 vector bool char,
15895 vector unsigned char);
15896
15897 vector signed char vec_sl (vector signed char,
15898 vector unsigned char);
15899 vector unsigned char vec_sl (vector unsigned char,
15900 vector unsigned char);
15901 vector signed short vec_sl (vector signed short, vector unsigned short);
15902 vector unsigned short vec_sl (vector unsigned short,
15903 vector unsigned short);
15904 vector signed int vec_sl (vector signed int, vector unsigned int);
15905 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
15906
15907 vector signed int vec_vslw (vector signed int, vector unsigned int);
15908 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
15909
15910 vector signed short vec_vslh (vector signed short,
15911 vector unsigned short);
15912 vector unsigned short vec_vslh (vector unsigned short,
15913 vector unsigned short);
15914
15915 vector signed char vec_vslb (vector signed char, vector unsigned char);
15916 vector unsigned char vec_vslb (vector unsigned char,
15917 vector unsigned char);
15918
15919 vector float vec_sld (vector float, vector float, const int);
15920 vector signed int vec_sld (vector signed int,
15921 vector signed int,
15922 const int);
15923 vector unsigned int vec_sld (vector unsigned int,
15924 vector unsigned int,
15925 const int);
15926 vector bool int vec_sld (vector bool int,
15927 vector bool int,
15928 const int);
15929 vector signed short vec_sld (vector signed short,
15930 vector signed short,
15931 const int);
15932 vector unsigned short vec_sld (vector unsigned short,
15933 vector unsigned short,
15934 const int);
15935 vector bool short vec_sld (vector bool short,
15936 vector bool short,
15937 const int);
15938 vector pixel vec_sld (vector pixel,
15939 vector pixel,
15940 const int);
15941 vector signed char vec_sld (vector signed char,
15942 vector signed char,
15943 const int);
15944 vector unsigned char vec_sld (vector unsigned char,
15945 vector unsigned char,
15946 const int);
15947 vector bool char vec_sld (vector bool char,
15948 vector bool char,
15949 const int);
15950
15951 vector signed int vec_sll (vector signed int,
15952 vector unsigned int);
15953 vector signed int vec_sll (vector signed int,
15954 vector unsigned short);
15955 vector signed int vec_sll (vector signed int,
15956 vector unsigned char);
15957 vector unsigned int vec_sll (vector unsigned int,
15958 vector unsigned int);
15959 vector unsigned int vec_sll (vector unsigned int,
15960 vector unsigned short);
15961 vector unsigned int vec_sll (vector unsigned int,
15962 vector unsigned char);
15963 vector bool int vec_sll (vector bool int,
15964 vector unsigned int);
15965 vector bool int vec_sll (vector bool int,
15966 vector unsigned short);
15967 vector bool int vec_sll (vector bool int,
15968 vector unsigned char);
15969 vector signed short vec_sll (vector signed short,
15970 vector unsigned int);
15971 vector signed short vec_sll (vector signed short,
15972 vector unsigned short);
15973 vector signed short vec_sll (vector signed short,
15974 vector unsigned char);
15975 vector unsigned short vec_sll (vector unsigned short,
15976 vector unsigned int);
15977 vector unsigned short vec_sll (vector unsigned short,
15978 vector unsigned short);
15979 vector unsigned short vec_sll (vector unsigned short,
15980 vector unsigned char);
15981 vector bool short vec_sll (vector bool short, vector unsigned int);
15982 vector bool short vec_sll (vector bool short, vector unsigned short);
15983 vector bool short vec_sll (vector bool short, vector unsigned char);
15984 vector pixel vec_sll (vector pixel, vector unsigned int);
15985 vector pixel vec_sll (vector pixel, vector unsigned short);
15986 vector pixel vec_sll (vector pixel, vector unsigned char);
15987 vector signed char vec_sll (vector signed char, vector unsigned int);
15988 vector signed char vec_sll (vector signed char, vector unsigned short);
15989 vector signed char vec_sll (vector signed char, vector unsigned char);
15990 vector unsigned char vec_sll (vector unsigned char,
15991 vector unsigned int);
15992 vector unsigned char vec_sll (vector unsigned char,
15993 vector unsigned short);
15994 vector unsigned char vec_sll (vector unsigned char,
15995 vector unsigned char);
15996 vector bool char vec_sll (vector bool char, vector unsigned int);
15997 vector bool char vec_sll (vector bool char, vector unsigned short);
15998 vector bool char vec_sll (vector bool char, vector unsigned char);
15999
16000 vector float vec_slo (vector float, vector signed char);
16001 vector float vec_slo (vector float, vector unsigned char);
16002 vector signed int vec_slo (vector signed int, vector signed char);
16003 vector signed int vec_slo (vector signed int, vector unsigned char);
16004 vector unsigned int vec_slo (vector unsigned int, vector signed char);
16005 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
16006 vector signed short vec_slo (vector signed short, vector signed char);
16007 vector signed short vec_slo (vector signed short, vector unsigned char);
16008 vector unsigned short vec_slo (vector unsigned short,
16009 vector signed char);
16010 vector unsigned short vec_slo (vector unsigned short,
16011 vector unsigned char);
16012 vector pixel vec_slo (vector pixel, vector signed char);
16013 vector pixel vec_slo (vector pixel, vector unsigned char);
16014 vector signed char vec_slo (vector signed char, vector signed char);
16015 vector signed char vec_slo (vector signed char, vector unsigned char);
16016 vector unsigned char vec_slo (vector unsigned char, vector signed char);
16017 vector unsigned char vec_slo (vector unsigned char,
16018 vector unsigned char);
16019
16020 vector signed char vec_splat (vector signed char, const int);
16021 vector unsigned char vec_splat (vector unsigned char, const int);
16022 vector bool char vec_splat (vector bool char, const int);
16023 vector signed short vec_splat (vector signed short, const int);
16024 vector unsigned short vec_splat (vector unsigned short, const int);
16025 vector bool short vec_splat (vector bool short, const int);
16026 vector pixel vec_splat (vector pixel, const int);
16027 vector float vec_splat (vector float, const int);
16028 vector signed int vec_splat (vector signed int, const int);
16029 vector unsigned int vec_splat (vector unsigned int, const int);
16030 vector bool int vec_splat (vector bool int, const int);
16031 vector signed long vec_splat (vector signed long, const int);
16032 vector unsigned long vec_splat (vector unsigned long, const int);
16033
16034 vector signed char vec_splats (signed char);
16035 vector unsigned char vec_splats (unsigned char);
16036 vector signed short vec_splats (signed short);
16037 vector unsigned short vec_splats (unsigned short);
16038 vector signed int vec_splats (signed int);
16039 vector unsigned int vec_splats (unsigned int);
16040 vector float vec_splats (float);
16041
16042 vector float vec_vspltw (vector float, const int);
16043 vector signed int vec_vspltw (vector signed int, const int);
16044 vector unsigned int vec_vspltw (vector unsigned int, const int);
16045 vector bool int vec_vspltw (vector bool int, const int);
16046
16047 vector bool short vec_vsplth (vector bool short, const int);
16048 vector signed short vec_vsplth (vector signed short, const int);
16049 vector unsigned short vec_vsplth (vector unsigned short, const int);
16050 vector pixel vec_vsplth (vector pixel, const int);
16051
16052 vector signed char vec_vspltb (vector signed char, const int);
16053 vector unsigned char vec_vspltb (vector unsigned char, const int);
16054 vector bool char vec_vspltb (vector bool char, const int);
16055
16056 vector signed char vec_splat_s8 (const int);
16057
16058 vector signed short vec_splat_s16 (const int);
16059
16060 vector signed int vec_splat_s32 (const int);
16061
16062 vector unsigned char vec_splat_u8 (const int);
16063
16064 vector unsigned short vec_splat_u16 (const int);
16065
16066 vector unsigned int vec_splat_u32 (const int);
16067
16068 vector signed char vec_sr (vector signed char, vector unsigned char);
16069 vector unsigned char vec_sr (vector unsigned char,
16070 vector unsigned char);
16071 vector signed short vec_sr (vector signed short,
16072 vector unsigned short);
16073 vector unsigned short vec_sr (vector unsigned short,
16074 vector unsigned short);
16075 vector signed int vec_sr (vector signed int, vector unsigned int);
16076 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
16077
16078 vector signed int vec_vsrw (vector signed int, vector unsigned int);
16079 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
16080
16081 vector signed short vec_vsrh (vector signed short,
16082 vector unsigned short);
16083 vector unsigned short vec_vsrh (vector unsigned short,
16084 vector unsigned short);
16085
16086 vector signed char vec_vsrb (vector signed char, vector unsigned char);
16087 vector unsigned char vec_vsrb (vector unsigned char,
16088 vector unsigned char);
16089
16090 vector signed char vec_sra (vector signed char, vector unsigned char);
16091 vector unsigned char vec_sra (vector unsigned char,
16092 vector unsigned char);
16093 vector signed short vec_sra (vector signed short,
16094 vector unsigned short);
16095 vector unsigned short vec_sra (vector unsigned short,
16096 vector unsigned short);
16097 vector signed int vec_sra (vector signed int, vector unsigned int);
16098 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
16099
16100 vector signed int vec_vsraw (vector signed int, vector unsigned int);
16101 vector unsigned int vec_vsraw (vector unsigned int,
16102 vector unsigned int);
16103
16104 vector signed short vec_vsrah (vector signed short,
16105 vector unsigned short);
16106 vector unsigned short vec_vsrah (vector unsigned short,
16107 vector unsigned short);
16108
16109 vector signed char vec_vsrab (vector signed char, vector unsigned char);
16110 vector unsigned char vec_vsrab (vector unsigned char,
16111 vector unsigned char);
16112
16113 vector signed int vec_srl (vector signed int, vector unsigned int);
16114 vector signed int vec_srl (vector signed int, vector unsigned short);
16115 vector signed int vec_srl (vector signed int, vector unsigned char);
16116 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
16117 vector unsigned int vec_srl (vector unsigned int,
16118 vector unsigned short);
16119 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
16120 vector bool int vec_srl (vector bool int, vector unsigned int);
16121 vector bool int vec_srl (vector bool int, vector unsigned short);
16122 vector bool int vec_srl (vector bool int, vector unsigned char);
16123 vector signed short vec_srl (vector signed short, vector unsigned int);
16124 vector signed short vec_srl (vector signed short,
16125 vector unsigned short);
16126 vector signed short vec_srl (vector signed short, vector unsigned char);
16127 vector unsigned short vec_srl (vector unsigned short,
16128 vector unsigned int);
16129 vector unsigned short vec_srl (vector unsigned short,
16130 vector unsigned short);
16131 vector unsigned short vec_srl (vector unsigned short,
16132 vector unsigned char);
16133 vector bool short vec_srl (vector bool short, vector unsigned int);
16134 vector bool short vec_srl (vector bool short, vector unsigned short);
16135 vector bool short vec_srl (vector bool short, vector unsigned char);
16136 vector pixel vec_srl (vector pixel, vector unsigned int);
16137 vector pixel vec_srl (vector pixel, vector unsigned short);
16138 vector pixel vec_srl (vector pixel, vector unsigned char);
16139 vector signed char vec_srl (vector signed char, vector unsigned int);
16140 vector signed char vec_srl (vector signed char, vector unsigned short);
16141 vector signed char vec_srl (vector signed char, vector unsigned char);
16142 vector unsigned char vec_srl (vector unsigned char,
16143 vector unsigned int);
16144 vector unsigned char vec_srl (vector unsigned char,
16145 vector unsigned short);
16146 vector unsigned char vec_srl (vector unsigned char,
16147 vector unsigned char);
16148 vector bool char vec_srl (vector bool char, vector unsigned int);
16149 vector bool char vec_srl (vector bool char, vector unsigned short);
16150 vector bool char vec_srl (vector bool char, vector unsigned char);
16151
16152 vector float vec_sro (vector float, vector signed char);
16153 vector float vec_sro (vector float, vector unsigned char);
16154 vector signed int vec_sro (vector signed int, vector signed char);
16155 vector signed int vec_sro (vector signed int, vector unsigned char);
16156 vector unsigned int vec_sro (vector unsigned int, vector signed char);
16157 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
16158 vector signed short vec_sro (vector signed short, vector signed char);
16159 vector signed short vec_sro (vector signed short, vector unsigned char);
16160 vector unsigned short vec_sro (vector unsigned short,
16161 vector signed char);
16162 vector unsigned short vec_sro (vector unsigned short,
16163 vector unsigned char);
16164 vector pixel vec_sro (vector pixel, vector signed char);
16165 vector pixel vec_sro (vector pixel, vector unsigned char);
16166 vector signed char vec_sro (vector signed char, vector signed char);
16167 vector signed char vec_sro (vector signed char, vector unsigned char);
16168 vector unsigned char vec_sro (vector unsigned char, vector signed char);
16169 vector unsigned char vec_sro (vector unsigned char,
16170 vector unsigned char);
16171
16172 void vec_st (vector float, int, vector float *);
16173 void vec_st (vector float, int, float *);
16174 void vec_st (vector signed int, int, vector signed int *);
16175 void vec_st (vector signed int, int, int *);
16176 void vec_st (vector unsigned int, int, vector unsigned int *);
16177 void vec_st (vector unsigned int, int, unsigned int *);
16178 void vec_st (vector bool int, int, vector bool int *);
16179 void vec_st (vector bool int, int, unsigned int *);
16180 void vec_st (vector bool int, int, int *);
16181 void vec_st (vector signed short, int, vector signed short *);
16182 void vec_st (vector signed short, int, short *);
16183 void vec_st (vector unsigned short, int, vector unsigned short *);
16184 void vec_st (vector unsigned short, int, unsigned short *);
16185 void vec_st (vector bool short, int, vector bool short *);
16186 void vec_st (vector bool short, int, unsigned short *);
16187 void vec_st (vector pixel, int, vector pixel *);
16188 void vec_st (vector pixel, int, unsigned short *);
16189 void vec_st (vector pixel, int, short *);
16190 void vec_st (vector bool short, int, short *);
16191 void vec_st (vector signed char, int, vector signed char *);
16192 void vec_st (vector signed char, int, signed char *);
16193 void vec_st (vector unsigned char, int, vector unsigned char *);
16194 void vec_st (vector unsigned char, int, unsigned char *);
16195 void vec_st (vector bool char, int, vector bool char *);
16196 void vec_st (vector bool char, int, unsigned char *);
16197 void vec_st (vector bool char, int, signed char *);
16198
16199 void vec_ste (vector signed char, int, signed char *);
16200 void vec_ste (vector unsigned char, int, unsigned char *);
16201 void vec_ste (vector bool char, int, signed char *);
16202 void vec_ste (vector bool char, int, unsigned char *);
16203 void vec_ste (vector signed short, int, short *);
16204 void vec_ste (vector unsigned short, int, unsigned short *);
16205 void vec_ste (vector bool short, int, short *);
16206 void vec_ste (vector bool short, int, unsigned short *);
16207 void vec_ste (vector pixel, int, short *);
16208 void vec_ste (vector pixel, int, unsigned short *);
16209 void vec_ste (vector float, int, float *);
16210 void vec_ste (vector signed int, int, int *);
16211 void vec_ste (vector unsigned int, int, unsigned int *);
16212 void vec_ste (vector bool int, int, int *);
16213 void vec_ste (vector bool int, int, unsigned int *);
16214
16215 void vec_stvewx (vector float, int, float *);
16216 void vec_stvewx (vector signed int, int, int *);
16217 void vec_stvewx (vector unsigned int, int, unsigned int *);
16218 void vec_stvewx (vector bool int, int, int *);
16219 void vec_stvewx (vector bool int, int, unsigned int *);
16220
16221 void vec_stvehx (vector signed short, int, short *);
16222 void vec_stvehx (vector unsigned short, int, unsigned short *);
16223 void vec_stvehx (vector bool short, int, short *);
16224 void vec_stvehx (vector bool short, int, unsigned short *);
16225 void vec_stvehx (vector pixel, int, short *);
16226 void vec_stvehx (vector pixel, int, unsigned short *);
16227
16228 void vec_stvebx (vector signed char, int, signed char *);
16229 void vec_stvebx (vector unsigned char, int, unsigned char *);
16230 void vec_stvebx (vector bool char, int, signed char *);
16231 void vec_stvebx (vector bool char, int, unsigned char *);
16232
16233 void vec_stl (vector float, int, vector float *);
16234 void vec_stl (vector float, int, float *);
16235 void vec_stl (vector signed int, int, vector signed int *);
16236 void vec_stl (vector signed int, int, int *);
16237 void vec_stl (vector unsigned int, int, vector unsigned int *);
16238 void vec_stl (vector unsigned int, int, unsigned int *);
16239 void vec_stl (vector bool int, int, vector bool int *);
16240 void vec_stl (vector bool int, int, unsigned int *);
16241 void vec_stl (vector bool int, int, int *);
16242 void vec_stl (vector signed short, int, vector signed short *);
16243 void vec_stl (vector signed short, int, short *);
16244 void vec_stl (vector unsigned short, int, vector unsigned short *);
16245 void vec_stl (vector unsigned short, int, unsigned short *);
16246 void vec_stl (vector bool short, int, vector bool short *);
16247 void vec_stl (vector bool short, int, unsigned short *);
16248 void vec_stl (vector bool short, int, short *);
16249 void vec_stl (vector pixel, int, vector pixel *);
16250 void vec_stl (vector pixel, int, unsigned short *);
16251 void vec_stl (vector pixel, int, short *);
16252 void vec_stl (vector signed char, int, vector signed char *);
16253 void vec_stl (vector signed char, int, signed char *);
16254 void vec_stl (vector unsigned char, int, vector unsigned char *);
16255 void vec_stl (vector unsigned char, int, unsigned char *);
16256 void vec_stl (vector bool char, int, vector bool char *);
16257 void vec_stl (vector bool char, int, unsigned char *);
16258 void vec_stl (vector bool char, int, signed char *);
16259
16260 vector signed char vec_sub (vector bool char, vector signed char);
16261 vector signed char vec_sub (vector signed char, vector bool char);
16262 vector signed char vec_sub (vector signed char, vector signed char);
16263 vector unsigned char vec_sub (vector bool char, vector unsigned char);
16264 vector unsigned char vec_sub (vector unsigned char, vector bool char);
16265 vector unsigned char vec_sub (vector unsigned char,
16266 vector unsigned char);
16267 vector signed short vec_sub (vector bool short, vector signed short);
16268 vector signed short vec_sub (vector signed short, vector bool short);
16269 vector signed short vec_sub (vector signed short, vector signed short);
16270 vector unsigned short vec_sub (vector bool short,
16271 vector unsigned short);
16272 vector unsigned short vec_sub (vector unsigned short,
16273 vector bool short);
16274 vector unsigned short vec_sub (vector unsigned short,
16275 vector unsigned short);
16276 vector signed int vec_sub (vector bool int, vector signed int);
16277 vector signed int vec_sub (vector signed int, vector bool int);
16278 vector signed int vec_sub (vector signed int, vector signed int);
16279 vector unsigned int vec_sub (vector bool int, vector unsigned int);
16280 vector unsigned int vec_sub (vector unsigned int, vector bool int);
16281 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
16282 vector float vec_sub (vector float, vector float);
16283
16284 vector float vec_vsubfp (vector float, vector float);
16285
16286 vector signed int vec_vsubuwm (vector bool int, vector signed int);
16287 vector signed int vec_vsubuwm (vector signed int, vector bool int);
16288 vector signed int vec_vsubuwm (vector signed int, vector signed int);
16289 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
16290 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
16291 vector unsigned int vec_vsubuwm (vector unsigned int,
16292 vector unsigned int);
16293
16294 vector signed short vec_vsubuhm (vector bool short,
16295 vector signed short);
16296 vector signed short vec_vsubuhm (vector signed short,
16297 vector bool short);
16298 vector signed short vec_vsubuhm (vector signed short,
16299 vector signed short);
16300 vector unsigned short vec_vsubuhm (vector bool short,
16301 vector unsigned short);
16302 vector unsigned short vec_vsubuhm (vector unsigned short,
16303 vector bool short);
16304 vector unsigned short vec_vsubuhm (vector unsigned short,
16305 vector unsigned short);
16306
16307 vector signed char vec_vsububm (vector bool char, vector signed char);
16308 vector signed char vec_vsububm (vector signed char, vector bool char);
16309 vector signed char vec_vsububm (vector signed char, vector signed char);
16310 vector unsigned char vec_vsububm (vector bool char,
16311 vector unsigned char);
16312 vector unsigned char vec_vsububm (vector unsigned char,
16313 vector bool char);
16314 vector unsigned char vec_vsububm (vector unsigned char,
16315 vector unsigned char);
16316
16317 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
16318
16319 vector unsigned char vec_subs (vector bool char, vector unsigned char);
16320 vector unsigned char vec_subs (vector unsigned char, vector bool char);
16321 vector unsigned char vec_subs (vector unsigned char,
16322 vector unsigned char);
16323 vector signed char vec_subs (vector bool char, vector signed char);
16324 vector signed char vec_subs (vector signed char, vector bool char);
16325 vector signed char vec_subs (vector signed char, vector signed char);
16326 vector unsigned short vec_subs (vector bool short,
16327 vector unsigned short);
16328 vector unsigned short vec_subs (vector unsigned short,
16329 vector bool short);
16330 vector unsigned short vec_subs (vector unsigned short,
16331 vector unsigned short);
16332 vector signed short vec_subs (vector bool short, vector signed short);
16333 vector signed short vec_subs (vector signed short, vector bool short);
16334 vector signed short vec_subs (vector signed short, vector signed short);
16335 vector unsigned int vec_subs (vector bool int, vector unsigned int);
16336 vector unsigned int vec_subs (vector unsigned int, vector bool int);
16337 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
16338 vector signed int vec_subs (vector bool int, vector signed int);
16339 vector signed int vec_subs (vector signed int, vector bool int);
16340 vector signed int vec_subs (vector signed int, vector signed int);
16341
16342 vector signed int vec_vsubsws (vector bool int, vector signed int);
16343 vector signed int vec_vsubsws (vector signed int, vector bool int);
16344 vector signed int vec_vsubsws (vector signed int, vector signed int);
16345
16346 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
16347 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
16348 vector unsigned int vec_vsubuws (vector unsigned int,
16349 vector unsigned int);
16350
16351 vector signed short vec_vsubshs (vector bool short,
16352 vector signed short);
16353 vector signed short vec_vsubshs (vector signed short,
16354 vector bool short);
16355 vector signed short vec_vsubshs (vector signed short,
16356 vector signed short);
16357
16358 vector unsigned short vec_vsubuhs (vector bool short,
16359 vector unsigned short);
16360 vector unsigned short vec_vsubuhs (vector unsigned short,
16361 vector bool short);
16362 vector unsigned short vec_vsubuhs (vector unsigned short,
16363 vector unsigned short);
16364
16365 vector signed char vec_vsubsbs (vector bool char, vector signed char);
16366 vector signed char vec_vsubsbs (vector signed char, vector bool char);
16367 vector signed char vec_vsubsbs (vector signed char, vector signed char);
16368
16369 vector unsigned char vec_vsububs (vector bool char,
16370 vector unsigned char);
16371 vector unsigned char vec_vsububs (vector unsigned char,
16372 vector bool char);
16373 vector unsigned char vec_vsububs (vector unsigned char,
16374 vector unsigned char);
16375
16376 vector unsigned int vec_sum4s (vector unsigned char,
16377 vector unsigned int);
16378 vector signed int vec_sum4s (vector signed char, vector signed int);
16379 vector signed int vec_sum4s (vector signed short, vector signed int);
16380
16381 vector signed int vec_vsum4shs (vector signed short, vector signed int);
16382
16383 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
16384
16385 vector unsigned int vec_vsum4ubs (vector unsigned char,
16386 vector unsigned int);
16387
16388 vector signed int vec_sum2s (vector signed int, vector signed int);
16389
16390 vector signed int vec_sums (vector signed int, vector signed int);
16391
16392 vector float vec_trunc (vector float);
16393
16394 vector signed short vec_unpackh (vector signed char);
16395 vector bool short vec_unpackh (vector bool char);
16396 vector signed int vec_unpackh (vector signed short);
16397 vector bool int vec_unpackh (vector bool short);
16398 vector unsigned int vec_unpackh (vector pixel);
16399
16400 vector bool int vec_vupkhsh (vector bool short);
16401 vector signed int vec_vupkhsh (vector signed short);
16402
16403 vector unsigned int vec_vupkhpx (vector pixel);
16404
16405 vector bool short vec_vupkhsb (vector bool char);
16406 vector signed short vec_vupkhsb (vector signed char);
16407
16408 vector signed short vec_unpackl (vector signed char);
16409 vector bool short vec_unpackl (vector bool char);
16410 vector unsigned int vec_unpackl (vector pixel);
16411 vector signed int vec_unpackl (vector signed short);
16412 vector bool int vec_unpackl (vector bool short);
16413
16414 vector unsigned int vec_vupklpx (vector pixel);
16415
16416 vector bool int vec_vupklsh (vector bool short);
16417 vector signed int vec_vupklsh (vector signed short);
16418
16419 vector bool short vec_vupklsb (vector bool char);
16420 vector signed short vec_vupklsb (vector signed char);
16421
16422 vector float vec_xor (vector float, vector float);
16423 vector float vec_xor (vector float, vector bool int);
16424 vector float vec_xor (vector bool int, vector float);
16425 vector bool int vec_xor (vector bool int, vector bool int);
16426 vector signed int vec_xor (vector bool int, vector signed int);
16427 vector signed int vec_xor (vector signed int, vector bool int);
16428 vector signed int vec_xor (vector signed int, vector signed int);
16429 vector unsigned int vec_xor (vector bool int, vector unsigned int);
16430 vector unsigned int vec_xor (vector unsigned int, vector bool int);
16431 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
16432 vector bool short vec_xor (vector bool short, vector bool short);
16433 vector signed short vec_xor (vector bool short, vector signed short);
16434 vector signed short vec_xor (vector signed short, vector bool short);
16435 vector signed short vec_xor (vector signed short, vector signed short);
16436 vector unsigned short vec_xor (vector bool short,
16437 vector unsigned short);
16438 vector unsigned short vec_xor (vector unsigned short,
16439 vector bool short);
16440 vector unsigned short vec_xor (vector unsigned short,
16441 vector unsigned short);
16442 vector signed char vec_xor (vector bool char, vector signed char);
16443 vector bool char vec_xor (vector bool char, vector bool char);
16444 vector signed char vec_xor (vector signed char, vector bool char);
16445 vector signed char vec_xor (vector signed char, vector signed char);
16446 vector unsigned char vec_xor (vector bool char, vector unsigned char);
16447 vector unsigned char vec_xor (vector unsigned char, vector bool char);
16448 vector unsigned char vec_xor (vector unsigned char,
16449 vector unsigned char);
16450
16451 int vec_all_eq (vector signed char, vector bool char);
16452 int vec_all_eq (vector signed char, vector signed char);
16453 int vec_all_eq (vector unsigned char, vector bool char);
16454 int vec_all_eq (vector unsigned char, vector unsigned char);
16455 int vec_all_eq (vector bool char, vector bool char);
16456 int vec_all_eq (vector bool char, vector unsigned char);
16457 int vec_all_eq (vector bool char, vector signed char);
16458 int vec_all_eq (vector signed short, vector bool short);
16459 int vec_all_eq (vector signed short, vector signed short);
16460 int vec_all_eq (vector unsigned short, vector bool short);
16461 int vec_all_eq (vector unsigned short, vector unsigned short);
16462 int vec_all_eq (vector bool short, vector bool short);
16463 int vec_all_eq (vector bool short, vector unsigned short);
16464 int vec_all_eq (vector bool short, vector signed short);
16465 int vec_all_eq (vector pixel, vector pixel);
16466 int vec_all_eq (vector signed int, vector bool int);
16467 int vec_all_eq (vector signed int, vector signed int);
16468 int vec_all_eq (vector unsigned int, vector bool int);
16469 int vec_all_eq (vector unsigned int, vector unsigned int);
16470 int vec_all_eq (vector bool int, vector bool int);
16471 int vec_all_eq (vector bool int, vector unsigned int);
16472 int vec_all_eq (vector bool int, vector signed int);
16473 int vec_all_eq (vector float, vector float);
16474
16475 int vec_all_ge (vector bool char, vector unsigned char);
16476 int vec_all_ge (vector unsigned char, vector bool char);
16477 int vec_all_ge (vector unsigned char, vector unsigned char);
16478 int vec_all_ge (vector bool char, vector signed char);
16479 int vec_all_ge (vector signed char, vector bool char);
16480 int vec_all_ge (vector signed char, vector signed char);
16481 int vec_all_ge (vector bool short, vector unsigned short);
16482 int vec_all_ge (vector unsigned short, vector bool short);
16483 int vec_all_ge (vector unsigned short, vector unsigned short);
16484 int vec_all_ge (vector signed short, vector signed short);
16485 int vec_all_ge (vector bool short, vector signed short);
16486 int vec_all_ge (vector signed short, vector bool short);
16487 int vec_all_ge (vector bool int, vector unsigned int);
16488 int vec_all_ge (vector unsigned int, vector bool int);
16489 int vec_all_ge (vector unsigned int, vector unsigned int);
16490 int vec_all_ge (vector bool int, vector signed int);
16491 int vec_all_ge (vector signed int, vector bool int);
16492 int vec_all_ge (vector signed int, vector signed int);
16493 int vec_all_ge (vector float, vector float);
16494
16495 int vec_all_gt (vector bool char, vector unsigned char);
16496 int vec_all_gt (vector unsigned char, vector bool char);
16497 int vec_all_gt (vector unsigned char, vector unsigned char);
16498 int vec_all_gt (vector bool char, vector signed char);
16499 int vec_all_gt (vector signed char, vector bool char);
16500 int vec_all_gt (vector signed char, vector signed char);
16501 int vec_all_gt (vector bool short, vector unsigned short);
16502 int vec_all_gt (vector unsigned short, vector bool short);
16503 int vec_all_gt (vector unsigned short, vector unsigned short);
16504 int vec_all_gt (vector bool short, vector signed short);
16505 int vec_all_gt (vector signed short, vector bool short);
16506 int vec_all_gt (vector signed short, vector signed short);
16507 int vec_all_gt (vector bool int, vector unsigned int);
16508 int vec_all_gt (vector unsigned int, vector bool int);
16509 int vec_all_gt (vector unsigned int, vector unsigned int);
16510 int vec_all_gt (vector bool int, vector signed int);
16511 int vec_all_gt (vector signed int, vector bool int);
16512 int vec_all_gt (vector signed int, vector signed int);
16513 int vec_all_gt (vector float, vector float);
16514
16515 int vec_all_in (vector float, vector float);
16516
16517 int vec_all_le (vector bool char, vector unsigned char);
16518 int vec_all_le (vector unsigned char, vector bool char);
16519 int vec_all_le (vector unsigned char, vector unsigned char);
16520 int vec_all_le (vector bool char, vector signed char);
16521 int vec_all_le (vector signed char, vector bool char);
16522 int vec_all_le (vector signed char, vector signed char);
16523 int vec_all_le (vector bool short, vector unsigned short);
16524 int vec_all_le (vector unsigned short, vector bool short);
16525 int vec_all_le (vector unsigned short, vector unsigned short);
16526 int vec_all_le (vector bool short, vector signed short);
16527 int vec_all_le (vector signed short, vector bool short);
16528 int vec_all_le (vector signed short, vector signed short);
16529 int vec_all_le (vector bool int, vector unsigned int);
16530 int vec_all_le (vector unsigned int, vector bool int);
16531 int vec_all_le (vector unsigned int, vector unsigned int);
16532 int vec_all_le (vector bool int, vector signed int);
16533 int vec_all_le (vector signed int, vector bool int);
16534 int vec_all_le (vector signed int, vector signed int);
16535 int vec_all_le (vector float, vector float);
16536
16537 int vec_all_lt (vector bool char, vector unsigned char);
16538 int vec_all_lt (vector unsigned char, vector bool char);
16539 int vec_all_lt (vector unsigned char, vector unsigned char);
16540 int vec_all_lt (vector bool char, vector signed char);
16541 int vec_all_lt (vector signed char, vector bool char);
16542 int vec_all_lt (vector signed char, vector signed char);
16543 int vec_all_lt (vector bool short, vector unsigned short);
16544 int vec_all_lt (vector unsigned short, vector bool short);
16545 int vec_all_lt (vector unsigned short, vector unsigned short);
16546 int vec_all_lt (vector bool short, vector signed short);
16547 int vec_all_lt (vector signed short, vector bool short);
16548 int vec_all_lt (vector signed short, vector signed short);
16549 int vec_all_lt (vector bool int, vector unsigned int);
16550 int vec_all_lt (vector unsigned int, vector bool int);
16551 int vec_all_lt (vector unsigned int, vector unsigned int);
16552 int vec_all_lt (vector bool int, vector signed int);
16553 int vec_all_lt (vector signed int, vector bool int);
16554 int vec_all_lt (vector signed int, vector signed int);
16555 int vec_all_lt (vector float, vector float);
16556
16557 int vec_all_nan (vector float);
16558
16559 int vec_all_ne (vector signed char, vector bool char);
16560 int vec_all_ne (vector signed char, vector signed char);
16561 int vec_all_ne (vector unsigned char, vector bool char);
16562 int vec_all_ne (vector unsigned char, vector unsigned char);
16563 int vec_all_ne (vector bool char, vector bool char);
16564 int vec_all_ne (vector bool char, vector unsigned char);
16565 int vec_all_ne (vector bool char, vector signed char);
16566 int vec_all_ne (vector signed short, vector bool short);
16567 int vec_all_ne (vector signed short, vector signed short);
16568 int vec_all_ne (vector unsigned short, vector bool short);
16569 int vec_all_ne (vector unsigned short, vector unsigned short);
16570 int vec_all_ne (vector bool short, vector bool short);
16571 int vec_all_ne (vector bool short, vector unsigned short);
16572 int vec_all_ne (vector bool short, vector signed short);
16573 int vec_all_ne (vector pixel, vector pixel);
16574 int vec_all_ne (vector signed int, vector bool int);
16575 int vec_all_ne (vector signed int, vector signed int);
16576 int vec_all_ne (vector unsigned int, vector bool int);
16577 int vec_all_ne (vector unsigned int, vector unsigned int);
16578 int vec_all_ne (vector bool int, vector bool int);
16579 int vec_all_ne (vector bool int, vector unsigned int);
16580 int vec_all_ne (vector bool int, vector signed int);
16581 int vec_all_ne (vector float, vector float);
16582
16583 int vec_all_nge (vector float, vector float);
16584
16585 int vec_all_ngt (vector float, vector float);
16586
16587 int vec_all_nle (vector float, vector float);
16588
16589 int vec_all_nlt (vector float, vector float);
16590
16591 int vec_all_numeric (vector float);
16592
16593 int vec_any_eq (vector signed char, vector bool char);
16594 int vec_any_eq (vector signed char, vector signed char);
16595 int vec_any_eq (vector unsigned char, vector bool char);
16596 int vec_any_eq (vector unsigned char, vector unsigned char);
16597 int vec_any_eq (vector bool char, vector bool char);
16598 int vec_any_eq (vector bool char, vector unsigned char);
16599 int vec_any_eq (vector bool char, vector signed char);
16600 int vec_any_eq (vector signed short, vector bool short);
16601 int vec_any_eq (vector signed short, vector signed short);
16602 int vec_any_eq (vector unsigned short, vector bool short);
16603 int vec_any_eq (vector unsigned short, vector unsigned short);
16604 int vec_any_eq (vector bool short, vector bool short);
16605 int vec_any_eq (vector bool short, vector unsigned short);
16606 int vec_any_eq (vector bool short, vector signed short);
16607 int vec_any_eq (vector pixel, vector pixel);
16608 int vec_any_eq (vector signed int, vector bool int);
16609 int vec_any_eq (vector signed int, vector signed int);
16610 int vec_any_eq (vector unsigned int, vector bool int);
16611 int vec_any_eq (vector unsigned int, vector unsigned int);
16612 int vec_any_eq (vector bool int, vector bool int);
16613 int vec_any_eq (vector bool int, vector unsigned int);
16614 int vec_any_eq (vector bool int, vector signed int);
16615 int vec_any_eq (vector float, vector float);
16616
16617 int vec_any_ge (vector signed char, vector bool char);
16618 int vec_any_ge (vector unsigned char, vector bool char);
16619 int vec_any_ge (vector unsigned char, vector unsigned char);
16620 int vec_any_ge (vector signed char, vector signed char);
16621 int vec_any_ge (vector bool char, vector unsigned char);
16622 int vec_any_ge (vector bool char, vector signed char);
16623 int vec_any_ge (vector unsigned short, vector bool short);
16624 int vec_any_ge (vector unsigned short, vector unsigned short);
16625 int vec_any_ge (vector signed short, vector signed short);
16626 int vec_any_ge (vector signed short, vector bool short);
16627 int vec_any_ge (vector bool short, vector unsigned short);
16628 int vec_any_ge (vector bool short, vector signed short);
16629 int vec_any_ge (vector signed int, vector bool int);
16630 int vec_any_ge (vector unsigned int, vector bool int);
16631 int vec_any_ge (vector unsigned int, vector unsigned int);
16632 int vec_any_ge (vector signed int, vector signed int);
16633 int vec_any_ge (vector bool int, vector unsigned int);
16634 int vec_any_ge (vector bool int, vector signed int);
16635 int vec_any_ge (vector float, vector float);
16636
16637 int vec_any_gt (vector bool char, vector unsigned char);
16638 int vec_any_gt (vector unsigned char, vector bool char);
16639 int vec_any_gt (vector unsigned char, vector unsigned char);
16640 int vec_any_gt (vector bool char, vector signed char);
16641 int vec_any_gt (vector signed char, vector bool char);
16642 int vec_any_gt (vector signed char, vector signed char);
16643 int vec_any_gt (vector bool short, vector unsigned short);
16644 int vec_any_gt (vector unsigned short, vector bool short);
16645 int vec_any_gt (vector unsigned short, vector unsigned short);
16646 int vec_any_gt (vector bool short, vector signed short);
16647 int vec_any_gt (vector signed short, vector bool short);
16648 int vec_any_gt (vector signed short, vector signed short);
16649 int vec_any_gt (vector bool int, vector unsigned int);
16650 int vec_any_gt (vector unsigned int, vector bool int);
16651 int vec_any_gt (vector unsigned int, vector unsigned int);
16652 int vec_any_gt (vector bool int, vector signed int);
16653 int vec_any_gt (vector signed int, vector bool int);
16654 int vec_any_gt (vector signed int, vector signed int);
16655 int vec_any_gt (vector float, vector float);
16656
16657 int vec_any_le (vector bool char, vector unsigned char);
16658 int vec_any_le (vector unsigned char, vector bool char);
16659 int vec_any_le (vector unsigned char, vector unsigned char);
16660 int vec_any_le (vector bool char, vector signed char);
16661 int vec_any_le (vector signed char, vector bool char);
16662 int vec_any_le (vector signed char, vector signed char);
16663 int vec_any_le (vector bool short, vector unsigned short);
16664 int vec_any_le (vector unsigned short, vector bool short);
16665 int vec_any_le (vector unsigned short, vector unsigned short);
16666 int vec_any_le (vector bool short, vector signed short);
16667 int vec_any_le (vector signed short, vector bool short);
16668 int vec_any_le (vector signed short, vector signed short);
16669 int vec_any_le (vector bool int, vector unsigned int);
16670 int vec_any_le (vector unsigned int, vector bool int);
16671 int vec_any_le (vector unsigned int, vector unsigned int);
16672 int vec_any_le (vector bool int, vector signed int);
16673 int vec_any_le (vector signed int, vector bool int);
16674 int vec_any_le (vector signed int, vector signed int);
16675 int vec_any_le (vector float, vector float);
16676
16677 int vec_any_lt (vector bool char, vector unsigned char);
16678 int vec_any_lt (vector unsigned char, vector bool char);
16679 int vec_any_lt (vector unsigned char, vector unsigned char);
16680 int vec_any_lt (vector bool char, vector signed char);
16681 int vec_any_lt (vector signed char, vector bool char);
16682 int vec_any_lt (vector signed char, vector signed char);
16683 int vec_any_lt (vector bool short, vector unsigned short);
16684 int vec_any_lt (vector unsigned short, vector bool short);
16685 int vec_any_lt (vector unsigned short, vector unsigned short);
16686 int vec_any_lt (vector bool short, vector signed short);
16687 int vec_any_lt (vector signed short, vector bool short);
16688 int vec_any_lt (vector signed short, vector signed short);
16689 int vec_any_lt (vector bool int, vector unsigned int);
16690 int vec_any_lt (vector unsigned int, vector bool int);
16691 int vec_any_lt (vector unsigned int, vector unsigned int);
16692 int vec_any_lt (vector bool int, vector signed int);
16693 int vec_any_lt (vector signed int, vector bool int);
16694 int vec_any_lt (vector signed int, vector signed int);
16695 int vec_any_lt (vector float, vector float);
16696
16697 int vec_any_nan (vector float);
16698
16699 int vec_any_ne (vector signed char, vector bool char);
16700 int vec_any_ne (vector signed char, vector signed char);
16701 int vec_any_ne (vector unsigned char, vector bool char);
16702 int vec_any_ne (vector unsigned char, vector unsigned char);
16703 int vec_any_ne (vector bool char, vector bool char);
16704 int vec_any_ne (vector bool char, vector unsigned char);
16705 int vec_any_ne (vector bool char, vector signed char);
16706 int vec_any_ne (vector signed short, vector bool short);
16707 int vec_any_ne (vector signed short, vector signed short);
16708 int vec_any_ne (vector unsigned short, vector bool short);
16709 int vec_any_ne (vector unsigned short, vector unsigned short);
16710 int vec_any_ne (vector bool short, vector bool short);
16711 int vec_any_ne (vector bool short, vector unsigned short);
16712 int vec_any_ne (vector bool short, vector signed short);
16713 int vec_any_ne (vector pixel, vector pixel);
16714 int vec_any_ne (vector signed int, vector bool int);
16715 int vec_any_ne (vector signed int, vector signed int);
16716 int vec_any_ne (vector unsigned int, vector bool int);
16717 int vec_any_ne (vector unsigned int, vector unsigned int);
16718 int vec_any_ne (vector bool int, vector bool int);
16719 int vec_any_ne (vector bool int, vector unsigned int);
16720 int vec_any_ne (vector bool int, vector signed int);
16721 int vec_any_ne (vector float, vector float);
16722
16723 int vec_any_nge (vector float, vector float);
16724
16725 int vec_any_ngt (vector float, vector float);
16726
16727 int vec_any_nle (vector float, vector float);
16728
16729 int vec_any_nlt (vector float, vector float);
16730
16731 int vec_any_numeric (vector float);
16732
16733 int vec_any_out (vector float, vector float);
16734 @end smallexample
16735
16736 If the vector/scalar (VSX) instruction set is available, the following
16737 additional functions are available:
16738
16739 @smallexample
16740 vector double vec_abs (vector double);
16741 vector double vec_add (vector double, vector double);
16742 vector double vec_and (vector double, vector double);
16743 vector double vec_and (vector double, vector bool long);
16744 vector double vec_and (vector bool long, vector double);
16745 vector long vec_and (vector long, vector long);
16746 vector long vec_and (vector long, vector bool long);
16747 vector long vec_and (vector bool long, vector long);
16748 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
16749 vector unsigned long vec_and (vector unsigned long, vector bool long);
16750 vector unsigned long vec_and (vector bool long, vector unsigned long);
16751 vector double vec_andc (vector double, vector double);
16752 vector double vec_andc (vector double, vector bool long);
16753 vector double vec_andc (vector bool long, vector double);
16754 vector long vec_andc (vector long, vector long);
16755 vector long vec_andc (vector long, vector bool long);
16756 vector long vec_andc (vector bool long, vector long);
16757 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
16758 vector unsigned long vec_andc (vector unsigned long, vector bool long);
16759 vector unsigned long vec_andc (vector bool long, vector unsigned long);
16760 vector double vec_ceil (vector double);
16761 vector bool long vec_cmpeq (vector double, vector double);
16762 vector bool long vec_cmpge (vector double, vector double);
16763 vector bool long vec_cmpgt (vector double, vector double);
16764 vector bool long vec_cmple (vector double, vector double);
16765 vector bool long vec_cmplt (vector double, vector double);
16766 vector double vec_cpsgn (vector double, vector double);
16767 vector float vec_div (vector float, vector float);
16768 vector double vec_div (vector double, vector double);
16769 vector long vec_div (vector long, vector long);
16770 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
16771 vector double vec_floor (vector double);
16772 vector double vec_ld (int, const vector double *);
16773 vector double vec_ld (int, const double *);
16774 vector double vec_ldl (int, const vector double *);
16775 vector double vec_ldl (int, const double *);
16776 vector unsigned char vec_lvsl (int, const volatile double *);
16777 vector unsigned char vec_lvsr (int, const volatile double *);
16778 vector double vec_madd (vector double, vector double, vector double);
16779 vector double vec_max (vector double, vector double);
16780 vector signed long vec_mergeh (vector signed long, vector signed long);
16781 vector signed long vec_mergeh (vector signed long, vector bool long);
16782 vector signed long vec_mergeh (vector bool long, vector signed long);
16783 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
16784 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
16785 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
16786 vector signed long vec_mergel (vector signed long, vector signed long);
16787 vector signed long vec_mergel (vector signed long, vector bool long);
16788 vector signed long vec_mergel (vector bool long, vector signed long);
16789 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
16790 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
16791 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
16792 vector double vec_min (vector double, vector double);
16793 vector float vec_msub (vector float, vector float, vector float);
16794 vector double vec_msub (vector double, vector double, vector double);
16795 vector float vec_mul (vector float, vector float);
16796 vector double vec_mul (vector double, vector double);
16797 vector long vec_mul (vector long, vector long);
16798 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
16799 vector float vec_nearbyint (vector float);
16800 vector double vec_nearbyint (vector double);
16801 vector float vec_nmadd (vector float, vector float, vector float);
16802 vector double vec_nmadd (vector double, vector double, vector double);
16803 vector double vec_nmsub (vector double, vector double, vector double);
16804 vector double vec_nor (vector double, vector double);
16805 vector long vec_nor (vector long, vector long);
16806 vector long vec_nor (vector long, vector bool long);
16807 vector long vec_nor (vector bool long, vector long);
16808 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
16809 vector unsigned long vec_nor (vector unsigned long, vector bool long);
16810 vector unsigned long vec_nor (vector bool long, vector unsigned long);
16811 vector double vec_or (vector double, vector double);
16812 vector double vec_or (vector double, vector bool long);
16813 vector double vec_or (vector bool long, vector double);
16814 vector long vec_or (vector long, vector long);
16815 vector long vec_or (vector long, vector bool long);
16816 vector long vec_or (vector bool long, vector long);
16817 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
16818 vector unsigned long vec_or (vector unsigned long, vector bool long);
16819 vector unsigned long vec_or (vector bool long, vector unsigned long);
16820 vector double vec_perm (vector double, vector double, vector unsigned char);
16821 vector long vec_perm (vector long, vector long, vector unsigned char);
16822 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
16823 vector unsigned char);
16824 vector double vec_rint (vector double);
16825 vector double vec_recip (vector double, vector double);
16826 vector double vec_rsqrt (vector double);
16827 vector double vec_rsqrte (vector double);
16828 vector double vec_sel (vector double, vector double, vector bool long);
16829 vector double vec_sel (vector double, vector double, vector unsigned long);
16830 vector long vec_sel (vector long, vector long, vector long);
16831 vector long vec_sel (vector long, vector long, vector unsigned long);
16832 vector long vec_sel (vector long, vector long, vector bool long);
16833 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
16834 vector long);
16835 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
16836 vector unsigned long);
16837 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
16838 vector bool long);
16839 vector double vec_splats (double);
16840 vector signed long vec_splats (signed long);
16841 vector unsigned long vec_splats (unsigned long);
16842 vector float vec_sqrt (vector float);
16843 vector double vec_sqrt (vector double);
16844 void vec_st (vector double, int, vector double *);
16845 void vec_st (vector double, int, double *);
16846 vector double vec_sub (vector double, vector double);
16847 vector double vec_trunc (vector double);
16848 vector double vec_xl (int, vector double *);
16849 vector double vec_xl (int, double *);
16850 vector long long vec_xl (int, vector long long *);
16851 vector long long vec_xl (int, long long *);
16852 vector unsigned long long vec_xl (int, vector unsigned long long *);
16853 vector unsigned long long vec_xl (int, unsigned long long *);
16854 vector float vec_xl (int, vector float *);
16855 vector float vec_xl (int, float *);
16856 vector int vec_xl (int, vector int *);
16857 vector int vec_xl (int, int *);
16858 vector unsigned int vec_xl (int, vector unsigned int *);
16859 vector unsigned int vec_xl (int, unsigned int *);
16860 vector double vec_xor (vector double, vector double);
16861 vector double vec_xor (vector double, vector bool long);
16862 vector double vec_xor (vector bool long, vector double);
16863 vector long vec_xor (vector long, vector long);
16864 vector long vec_xor (vector long, vector bool long);
16865 vector long vec_xor (vector bool long, vector long);
16866 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
16867 vector unsigned long vec_xor (vector unsigned long, vector bool long);
16868 vector unsigned long vec_xor (vector bool long, vector unsigned long);
16869 void vec_xst (vector double, int, vector double *);
16870 void vec_xst (vector double, int, double *);
16871 void vec_xst (vector long long, int, vector long long *);
16872 void vec_xst (vector long long, int, long long *);
16873 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
16874 void vec_xst (vector unsigned long long, int, unsigned long long *);
16875 void vec_xst (vector float, int, vector float *);
16876 void vec_xst (vector float, int, float *);
16877 void vec_xst (vector int, int, vector int *);
16878 void vec_xst (vector int, int, int *);
16879 void vec_xst (vector unsigned int, int, vector unsigned int *);
16880 void vec_xst (vector unsigned int, int, unsigned int *);
16881 int vec_all_eq (vector double, vector double);
16882 int vec_all_ge (vector double, vector double);
16883 int vec_all_gt (vector double, vector double);
16884 int vec_all_le (vector double, vector double);
16885 int vec_all_lt (vector double, vector double);
16886 int vec_all_nan (vector double);
16887 int vec_all_ne (vector double, vector double);
16888 int vec_all_nge (vector double, vector double);
16889 int vec_all_ngt (vector double, vector double);
16890 int vec_all_nle (vector double, vector double);
16891 int vec_all_nlt (vector double, vector double);
16892 int vec_all_numeric (vector double);
16893 int vec_any_eq (vector double, vector double);
16894 int vec_any_ge (vector double, vector double);
16895 int vec_any_gt (vector double, vector double);
16896 int vec_any_le (vector double, vector double);
16897 int vec_any_lt (vector double, vector double);
16898 int vec_any_nan (vector double);
16899 int vec_any_ne (vector double, vector double);
16900 int vec_any_nge (vector double, vector double);
16901 int vec_any_ngt (vector double, vector double);
16902 int vec_any_nle (vector double, vector double);
16903 int vec_any_nlt (vector double, vector double);
16904 int vec_any_numeric (vector double);
16905
16906 vector double vec_vsx_ld (int, const vector double *);
16907 vector double vec_vsx_ld (int, const double *);
16908 vector float vec_vsx_ld (int, const vector float *);
16909 vector float vec_vsx_ld (int, const float *);
16910 vector bool int vec_vsx_ld (int, const vector bool int *);
16911 vector signed int vec_vsx_ld (int, const vector signed int *);
16912 vector signed int vec_vsx_ld (int, const int *);
16913 vector signed int vec_vsx_ld (int, const long *);
16914 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
16915 vector unsigned int vec_vsx_ld (int, const unsigned int *);
16916 vector unsigned int vec_vsx_ld (int, const unsigned long *);
16917 vector bool short vec_vsx_ld (int, const vector bool short *);
16918 vector pixel vec_vsx_ld (int, const vector pixel *);
16919 vector signed short vec_vsx_ld (int, const vector signed short *);
16920 vector signed short vec_vsx_ld (int, const short *);
16921 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
16922 vector unsigned short vec_vsx_ld (int, const unsigned short *);
16923 vector bool char vec_vsx_ld (int, const vector bool char *);
16924 vector signed char vec_vsx_ld (int, const vector signed char *);
16925 vector signed char vec_vsx_ld (int, const signed char *);
16926 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
16927 vector unsigned char vec_vsx_ld (int, const unsigned char *);
16928
16929 void vec_vsx_st (vector double, int, vector double *);
16930 void vec_vsx_st (vector double, int, double *);
16931 void vec_vsx_st (vector float, int, vector float *);
16932 void vec_vsx_st (vector float, int, float *);
16933 void vec_vsx_st (vector signed int, int, vector signed int *);
16934 void vec_vsx_st (vector signed int, int, int *);
16935 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
16936 void vec_vsx_st (vector unsigned int, int, unsigned int *);
16937 void vec_vsx_st (vector bool int, int, vector bool int *);
16938 void vec_vsx_st (vector bool int, int, unsigned int *);
16939 void vec_vsx_st (vector bool int, int, int *);
16940 void vec_vsx_st (vector signed short, int, vector signed short *);
16941 void vec_vsx_st (vector signed short, int, short *);
16942 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
16943 void vec_vsx_st (vector unsigned short, int, unsigned short *);
16944 void vec_vsx_st (vector bool short, int, vector bool short *);
16945 void vec_vsx_st (vector bool short, int, unsigned short *);
16946 void vec_vsx_st (vector pixel, int, vector pixel *);
16947 void vec_vsx_st (vector pixel, int, unsigned short *);
16948 void vec_vsx_st (vector pixel, int, short *);
16949 void vec_vsx_st (vector bool short, int, short *);
16950 void vec_vsx_st (vector signed char, int, vector signed char *);
16951 void vec_vsx_st (vector signed char, int, signed char *);
16952 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16953 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16954 void vec_vsx_st (vector bool char, int, vector bool char *);
16955 void vec_vsx_st (vector bool char, int, unsigned char *);
16956 void vec_vsx_st (vector bool char, int, signed char *);
16957
16958 vector double vec_xxpermdi (vector double, vector double, int);
16959 vector float vec_xxpermdi (vector float, vector float, int);
16960 vector long long vec_xxpermdi (vector long long, vector long long, int);
16961 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16962 vector unsigned long long, int);
16963 vector int vec_xxpermdi (vector int, vector int, int);
16964 vector unsigned int vec_xxpermdi (vector unsigned int,
16965 vector unsigned int, int);
16966 vector short vec_xxpermdi (vector short, vector short, int);
16967 vector unsigned short vec_xxpermdi (vector unsigned short,
16968 vector unsigned short, int);
16969 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16970 vector unsigned char vec_xxpermdi (vector unsigned char,
16971 vector unsigned char, int);
16972
16973 vector double vec_xxsldi (vector double, vector double, int);
16974 vector float vec_xxsldi (vector float, vector float, int);
16975 vector long long vec_xxsldi (vector long long, vector long long, int);
16976 vector unsigned long long vec_xxsldi (vector unsigned long long,
16977 vector unsigned long long, int);
16978 vector int vec_xxsldi (vector int, vector int, int);
16979 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16980 vector short vec_xxsldi (vector short, vector short, int);
16981 vector unsigned short vec_xxsldi (vector unsigned short,
16982 vector unsigned short, int);
16983 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16984 vector unsigned char vec_xxsldi (vector unsigned char,
16985 vector unsigned char, int);
16986 @end smallexample
16987
16988 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16989 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16990 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16991 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16992 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16993
16994 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16995 instruction set are available, the following additional functions are
16996 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16997 can use @var{vector long} instead of @var{vector long long},
16998 @var{vector bool long} instead of @var{vector bool long long}, and
16999 @var{vector unsigned long} instead of @var{vector unsigned long long}.
17000
17001 @smallexample
17002 vector long long vec_abs (vector long long);
17003
17004 vector long long vec_add (vector long long, vector long long);
17005 vector unsigned long long vec_add (vector unsigned long long,
17006 vector unsigned long long);
17007
17008 int vec_all_eq (vector long long, vector long long);
17009 int vec_all_eq (vector unsigned long long, vector unsigned long long);
17010 int vec_all_ge (vector long long, vector long long);
17011 int vec_all_ge (vector unsigned long long, vector unsigned long long);
17012 int vec_all_gt (vector long long, vector long long);
17013 int vec_all_gt (vector unsigned long long, vector unsigned long long);
17014 int vec_all_le (vector long long, vector long long);
17015 int vec_all_le (vector unsigned long long, vector unsigned long long);
17016 int vec_all_lt (vector long long, vector long long);
17017 int vec_all_lt (vector unsigned long long, vector unsigned long long);
17018 int vec_all_ne (vector long long, vector long long);
17019 int vec_all_ne (vector unsigned long long, vector unsigned long long);
17020
17021 int vec_any_eq (vector long long, vector long long);
17022 int vec_any_eq (vector unsigned long long, vector unsigned long long);
17023 int vec_any_ge (vector long long, vector long long);
17024 int vec_any_ge (vector unsigned long long, vector unsigned long long);
17025 int vec_any_gt (vector long long, vector long long);
17026 int vec_any_gt (vector unsigned long long, vector unsigned long long);
17027 int vec_any_le (vector long long, vector long long);
17028 int vec_any_le (vector unsigned long long, vector unsigned long long);
17029 int vec_any_lt (vector long long, vector long long);
17030 int vec_any_lt (vector unsigned long long, vector unsigned long long);
17031 int vec_any_ne (vector long long, vector long long);
17032 int vec_any_ne (vector unsigned long long, vector unsigned long long);
17033
17034 vector long long vec_eqv (vector long long, vector long long);
17035 vector long long vec_eqv (vector bool long long, vector long long);
17036 vector long long vec_eqv (vector long long, vector bool long long);
17037 vector unsigned long long vec_eqv (vector unsigned long long,
17038 vector unsigned long long);
17039 vector unsigned long long vec_eqv (vector bool long long,
17040 vector unsigned long long);
17041 vector unsigned long long vec_eqv (vector unsigned long long,
17042 vector bool long long);
17043 vector int vec_eqv (vector int, vector int);
17044 vector int vec_eqv (vector bool int, vector int);
17045 vector int vec_eqv (vector int, vector bool int);
17046 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
17047 vector unsigned int vec_eqv (vector bool unsigned int,
17048 vector unsigned int);
17049 vector unsigned int vec_eqv (vector unsigned int,
17050 vector bool unsigned int);
17051 vector short vec_eqv (vector short, vector short);
17052 vector short vec_eqv (vector bool short, vector short);
17053 vector short vec_eqv (vector short, vector bool short);
17054 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
17055 vector unsigned short vec_eqv (vector bool unsigned short,
17056 vector unsigned short);
17057 vector unsigned short vec_eqv (vector unsigned short,
17058 vector bool unsigned short);
17059 vector signed char vec_eqv (vector signed char, vector signed char);
17060 vector signed char vec_eqv (vector bool signed char, vector signed char);
17061 vector signed char vec_eqv (vector signed char, vector bool signed char);
17062 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
17063 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
17064 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
17065
17066 vector long long vec_max (vector long long, vector long long);
17067 vector unsigned long long vec_max (vector unsigned long long,
17068 vector unsigned long long);
17069
17070 vector signed int vec_mergee (vector signed int, vector signed int);
17071 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
17072 vector bool int vec_mergee (vector bool int, vector bool int);
17073
17074 vector signed int vec_mergeo (vector signed int, vector signed int);
17075 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
17076 vector bool int vec_mergeo (vector bool int, vector bool int);
17077
17078 vector long long vec_min (vector long long, vector long long);
17079 vector unsigned long long vec_min (vector unsigned long long,
17080 vector unsigned long long);
17081
17082 vector long long vec_nand (vector long long, vector long long);
17083 vector long long vec_nand (vector bool long long, vector long long);
17084 vector long long vec_nand (vector long long, vector bool long long);
17085 vector unsigned long long vec_nand (vector unsigned long long,
17086 vector unsigned long long);
17087 vector unsigned long long vec_nand (vector bool long long,
17088 vector unsigned long long);
17089 vector unsigned long long vec_nand (vector unsigned long long,
17090 vector bool long long);
17091 vector int vec_nand (vector int, vector int);
17092 vector int vec_nand (vector bool int, vector int);
17093 vector int vec_nand (vector int, vector bool int);
17094 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
17095 vector unsigned int vec_nand (vector bool unsigned int,
17096 vector unsigned int);
17097 vector unsigned int vec_nand (vector unsigned int,
17098 vector bool unsigned int);
17099 vector short vec_nand (vector short, vector short);
17100 vector short vec_nand (vector bool short, vector short);
17101 vector short vec_nand (vector short, vector bool short);
17102 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
17103 vector unsigned short vec_nand (vector bool unsigned short,
17104 vector unsigned short);
17105 vector unsigned short vec_nand (vector unsigned short,
17106 vector bool unsigned short);
17107 vector signed char vec_nand (vector signed char, vector signed char);
17108 vector signed char vec_nand (vector bool signed char, vector signed char);
17109 vector signed char vec_nand (vector signed char, vector bool signed char);
17110 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
17111 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
17112 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
17113
17114 vector long long vec_orc (vector long long, vector long long);
17115 vector long long vec_orc (vector bool long long, vector long long);
17116 vector long long vec_orc (vector long long, vector bool long long);
17117 vector unsigned long long vec_orc (vector unsigned long long,
17118 vector unsigned long long);
17119 vector unsigned long long vec_orc (vector bool long long,
17120 vector unsigned long long);
17121 vector unsigned long long vec_orc (vector unsigned long long,
17122 vector bool long long);
17123 vector int vec_orc (vector int, vector int);
17124 vector int vec_orc (vector bool int, vector int);
17125 vector int vec_orc (vector int, vector bool int);
17126 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
17127 vector unsigned int vec_orc (vector bool unsigned int,
17128 vector unsigned int);
17129 vector unsigned int vec_orc (vector unsigned int,
17130 vector bool unsigned int);
17131 vector short vec_orc (vector short, vector short);
17132 vector short vec_orc (vector bool short, vector short);
17133 vector short vec_orc (vector short, vector bool short);
17134 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
17135 vector unsigned short vec_orc (vector bool unsigned short,
17136 vector unsigned short);
17137 vector unsigned short vec_orc (vector unsigned short,
17138 vector bool unsigned short);
17139 vector signed char vec_orc (vector signed char, vector signed char);
17140 vector signed char vec_orc (vector bool signed char, vector signed char);
17141 vector signed char vec_orc (vector signed char, vector bool signed char);
17142 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
17143 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
17144 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
17145
17146 vector int vec_pack (vector long long, vector long long);
17147 vector unsigned int vec_pack (vector unsigned long long,
17148 vector unsigned long long);
17149 vector bool int vec_pack (vector bool long long, vector bool long long);
17150
17151 vector int vec_packs (vector long long, vector long long);
17152 vector unsigned int vec_packs (vector unsigned long long,
17153 vector unsigned long long);
17154
17155 vector unsigned int vec_packsu (vector long long, vector long long);
17156 vector unsigned int vec_packsu (vector unsigned long long,
17157 vector unsigned long long);
17158
17159 vector long long vec_rl (vector long long,
17160 vector unsigned long long);
17161 vector long long vec_rl (vector unsigned long long,
17162 vector unsigned long long);
17163
17164 vector long long vec_sl (vector long long, vector unsigned long long);
17165 vector long long vec_sl (vector unsigned long long,
17166 vector unsigned long long);
17167
17168 vector long long vec_sr (vector long long, vector unsigned long long);
17169 vector unsigned long long char vec_sr (vector unsigned long long,
17170 vector unsigned long long);
17171
17172 vector long long vec_sra (vector long long, vector unsigned long long);
17173 vector unsigned long long vec_sra (vector unsigned long long,
17174 vector unsigned long long);
17175
17176 vector long long vec_sub (vector long long, vector long long);
17177 vector unsigned long long vec_sub (vector unsigned long long,
17178 vector unsigned long long);
17179
17180 vector long long vec_unpackh (vector int);
17181 vector unsigned long long vec_unpackh (vector unsigned int);
17182
17183 vector long long vec_unpackl (vector int);
17184 vector unsigned long long vec_unpackl (vector unsigned int);
17185
17186 vector long long vec_vaddudm (vector long long, vector long long);
17187 vector long long vec_vaddudm (vector bool long long, vector long long);
17188 vector long long vec_vaddudm (vector long long, vector bool long long);
17189 vector unsigned long long vec_vaddudm (vector unsigned long long,
17190 vector unsigned long long);
17191 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
17192 vector unsigned long long);
17193 vector unsigned long long vec_vaddudm (vector unsigned long long,
17194 vector bool unsigned long long);
17195
17196 vector long long vec_vbpermq (vector signed char, vector signed char);
17197 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
17198
17199 vector long long vec_cntlz (vector long long);
17200 vector unsigned long long vec_cntlz (vector unsigned long long);
17201 vector int vec_cntlz (vector int);
17202 vector unsigned int vec_cntlz (vector int);
17203 vector short vec_cntlz (vector short);
17204 vector unsigned short vec_cntlz (vector unsigned short);
17205 vector signed char vec_cntlz (vector signed char);
17206 vector unsigned char vec_cntlz (vector unsigned char);
17207
17208 vector long long vec_vclz (vector long long);
17209 vector unsigned long long vec_vclz (vector unsigned long long);
17210 vector int vec_vclz (vector int);
17211 vector unsigned int vec_vclz (vector int);
17212 vector short vec_vclz (vector short);
17213 vector unsigned short vec_vclz (vector unsigned short);
17214 vector signed char vec_vclz (vector signed char);
17215 vector unsigned char vec_vclz (vector unsigned char);
17216
17217 vector signed char vec_vclzb (vector signed char);
17218 vector unsigned char vec_vclzb (vector unsigned char);
17219
17220 vector long long vec_vclzd (vector long long);
17221 vector unsigned long long vec_vclzd (vector unsigned long long);
17222
17223 vector short vec_vclzh (vector short);
17224 vector unsigned short vec_vclzh (vector unsigned short);
17225
17226 vector int vec_vclzw (vector int);
17227 vector unsigned int vec_vclzw (vector int);
17228
17229 vector signed char vec_vgbbd (vector signed char);
17230 vector unsigned char vec_vgbbd (vector unsigned char);
17231
17232 vector long long vec_vmaxsd (vector long long, vector long long);
17233
17234 vector unsigned long long vec_vmaxud (vector unsigned long long,
17235 unsigned vector long long);
17236
17237 vector long long vec_vminsd (vector long long, vector long long);
17238
17239 vector unsigned long long vec_vminud (vector long long,
17240 vector long long);
17241
17242 vector int vec_vpksdss (vector long long, vector long long);
17243 vector unsigned int vec_vpksdss (vector long long, vector long long);
17244
17245 vector unsigned int vec_vpkudus (vector unsigned long long,
17246 vector unsigned long long);
17247
17248 vector int vec_vpkudum (vector long long, vector long long);
17249 vector unsigned int vec_vpkudum (vector unsigned long long,
17250 vector unsigned long long);
17251 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
17252
17253 vector long long vec_vpopcnt (vector long long);
17254 vector unsigned long long vec_vpopcnt (vector unsigned long long);
17255 vector int vec_vpopcnt (vector int);
17256 vector unsigned int vec_vpopcnt (vector int);
17257 vector short vec_vpopcnt (vector short);
17258 vector unsigned short vec_vpopcnt (vector unsigned short);
17259 vector signed char vec_vpopcnt (vector signed char);
17260 vector unsigned char vec_vpopcnt (vector unsigned char);
17261
17262 vector signed char vec_vpopcntb (vector signed char);
17263 vector unsigned char vec_vpopcntb (vector unsigned char);
17264
17265 vector long long vec_vpopcntd (vector long long);
17266 vector unsigned long long vec_vpopcntd (vector unsigned long long);
17267
17268 vector short vec_vpopcnth (vector short);
17269 vector unsigned short vec_vpopcnth (vector unsigned short);
17270
17271 vector int vec_vpopcntw (vector int);
17272 vector unsigned int vec_vpopcntw (vector int);
17273
17274 vector long long vec_vrld (vector long long, vector unsigned long long);
17275 vector unsigned long long vec_vrld (vector unsigned long long,
17276 vector unsigned long long);
17277
17278 vector long long vec_vsld (vector long long, vector unsigned long long);
17279 vector long long vec_vsld (vector unsigned long long,
17280 vector unsigned long long);
17281
17282 vector long long vec_vsrad (vector long long, vector unsigned long long);
17283 vector unsigned long long vec_vsrad (vector unsigned long long,
17284 vector unsigned long long);
17285
17286 vector long long vec_vsrd (vector long long, vector unsigned long long);
17287 vector unsigned long long char vec_vsrd (vector unsigned long long,
17288 vector unsigned long long);
17289
17290 vector long long vec_vsubudm (vector long long, vector long long);
17291 vector long long vec_vsubudm (vector bool long long, vector long long);
17292 vector long long vec_vsubudm (vector long long, vector bool long long);
17293 vector unsigned long long vec_vsubudm (vector unsigned long long,
17294 vector unsigned long long);
17295 vector unsigned long long vec_vsubudm (vector bool long long,
17296 vector unsigned long long);
17297 vector unsigned long long vec_vsubudm (vector unsigned long long,
17298 vector bool long long);
17299
17300 vector long long vec_vupkhsw (vector int);
17301 vector unsigned long long vec_vupkhsw (vector unsigned int);
17302
17303 vector long long vec_vupklsw (vector int);
17304 vector unsigned long long vec_vupklsw (vector int);
17305 @end smallexample
17306
17307 If the ISA 2.07 additions to the vector/scalar (power8-vector)
17308 instruction set are available, the following additional functions are
17309 available for 64-bit targets. New vector types
17310 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
17311 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
17312 builtins.
17313
17314 The normal vector extract, and set operations work on
17315 @var{vector __int128_t} and @var{vector __uint128_t} types,
17316 but the index value must be 0.
17317
17318 @smallexample
17319 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
17320 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
17321
17322 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
17323 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
17324
17325 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
17326 vector __int128_t);
17327 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
17328 vector __uint128_t);
17329
17330 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
17331 vector __int128_t);
17332 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
17333 vector __uint128_t);
17334
17335 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
17336 vector __int128_t);
17337 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
17338 vector __uint128_t);
17339
17340 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
17341 vector __int128_t);
17342 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
17343 vector __uint128_t);
17344
17345 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
17346 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
17347
17348 __int128_t vec_vsubuqm (__int128_t, __int128_t);
17349 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
17350
17351 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
17352 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
17353 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
17354 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
17355 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
17356 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
17357 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
17358 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
17359 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
17360 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
17361 @end smallexample
17362
17363 If the ISA 3.0 additions to the vector/scalar (power9-vector)
17364 instruction set are available:
17365
17366 @smallexample
17367 vector long long vec_vctz (vector long long);
17368 vector unsigned long long vec_vctz (vector unsigned long long);
17369 vector int vec_vctz (vector int);
17370 vector unsigned int vec_vctz (vector int);
17371 vector short vec_vctz (vector short);
17372 vector unsigned short vec_vctz (vector unsigned short);
17373 vector signed char vec_vctz (vector signed char);
17374 vector unsigned char vec_vctz (vector unsigned char);
17375
17376 vector signed char vec_vctzb (vector signed char);
17377 vector unsigned char vec_vctzb (vector unsigned char);
17378
17379 vector long long vec_vctzd (vector long long);
17380 vector unsigned long long vec_vctzd (vector unsigned long long);
17381
17382 vector short vec_vctzh (vector short);
17383 vector unsigned short vec_vctzh (vector unsigned short);
17384
17385 vector int vec_vctzw (vector int);
17386 vector unsigned int vec_vctzw (vector int);
17387
17388 vector int vec_vprtyb (vector int);
17389 vector unsigned int vec_vprtyb (vector unsigned int);
17390 vector long long vec_vprtyb (vector long long);
17391 vector unsigned long long vec_vprtyb (vector unsigned long long);
17392
17393 vector int vec_vprtybw (vector int);
17394 vector unsigned int vec_vprtybw (vector unsigned int);
17395
17396 vector long long vec_vprtybd (vector long long);
17397 vector unsigned long long vec_vprtybd (vector unsigned long long);
17398 @end smallexample
17399
17400
17401 If the ISA 3.0 additions to the vector/scalar (power9-vector)
17402 instruction set are available for 64-bit targets:
17403
17404 @smallexample
17405 vector long vec_vprtyb (vector long);
17406 vector unsigned long vec_vprtyb (vector unsigned long);
17407 vector __int128_t vec_vprtyb (vector __int128_t);
17408 vector __uint128_t vec_vprtyb (vector __uint128_t);
17409
17410 vector long vec_vprtybd (vector long);
17411 vector unsigned long vec_vprtybd (vector unsigned long);
17412
17413 vector __int128_t vec_vprtybq (vector __int128_t);
17414 vector __uint128_t vec_vprtybd (vector __uint128_t);
17415 @end smallexample
17416
17417 The following built-in vector functions are available for the PowerPC family
17418 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9})
17419 or with @option{-mpower9-vector}:
17420 @smallexample
17421 __vector unsigned char
17422 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
17423 __vector unsigned char
17424 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
17425 @end smallexample
17426
17427 The @code{vec_slv} and @code{vec_srv} functions operate on
17428 all of the bytes of their @code{src} and @code{shift_distance}
17429 arguments in parallel. The behavior of the @code{vec_slv} is as if
17430 there existed a temporary array of 17 unsigned characters
17431 @code{slv_array} within which elements 0 through 15 are the same as
17432 the entries in the @code{src} array and element 16 equals 0. The
17433 result returned from the @code{vec_slv} function is a
17434 @code{__vector} of 16 unsigned characters within which element
17435 @code{i} is computed using the C expression
17436 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
17437 shift_distance[i]))},
17438 with this resulting value coerced to the @code{unsigned char} type.
17439 The behavior of the @code{vec_srv} is as if
17440 there existed a temporary array of 17 unsigned characters
17441 @code{srv_array} within which element 0 equals zero and
17442 elements 1 through 16 equal the elements 0 through 15 of
17443 the @code{src} array. The
17444 result returned from the @code{vec_srv} function is a
17445 @code{__vector} of 16 unsigned characters within which element
17446 @code{i} is computed using the C expression
17447 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
17448 (0x07 & shift_distance[i]))},
17449 with this resulting value coerced to the @code{unsigned char} type.
17450
17451 If the cryptographic instructions are enabled (@option{-mcrypto} or
17452 @option{-mcpu=power8}), the following builtins are enabled.
17453
17454 @smallexample
17455 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
17456
17457 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
17458 vector unsigned long long);
17459
17460 vector unsigned long long __builtin_crypto_vcipherlast
17461 (vector unsigned long long,
17462 vector unsigned long long);
17463
17464 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
17465 vector unsigned long long);
17466
17467 vector unsigned long long __builtin_crypto_vncipherlast
17468 (vector unsigned long long,
17469 vector unsigned long long);
17470
17471 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
17472 vector unsigned char,
17473 vector unsigned char);
17474
17475 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
17476 vector unsigned short,
17477 vector unsigned short);
17478
17479 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
17480 vector unsigned int,
17481 vector unsigned int);
17482
17483 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
17484 vector unsigned long long,
17485 vector unsigned long long);
17486
17487 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
17488 vector unsigned char);
17489
17490 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
17491 vector unsigned short);
17492
17493 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
17494 vector unsigned int);
17495
17496 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
17497 vector unsigned long long);
17498
17499 vector unsigned long long __builtin_crypto_vshasigmad
17500 (vector unsigned long long, int, int);
17501
17502 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
17503 int, int);
17504 @end smallexample
17505
17506 The second argument to the @var{__builtin_crypto_vshasigmad} and
17507 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
17508 integer that is 0 or 1. The third argument to these builtin functions
17509 must be a constant integer in the range of 0 to 15.
17510
17511 If the ISA 3.0 additions to the vector/scalar (power9-vector)
17512 instruction set are available, the following additional functions are
17513 available for both 32-bit and 64-bit targets.
17514
17515 vector short vec_xl (int, vector short *);
17516 vector short vec_xl (int, short *);
17517 vector unsigned short vec_xl (int, vector unsigned short *);
17518 vector unsigned short vec_xl (int, unsigned short *);
17519 vector char vec_xl (int, vector char *);
17520 vector char vec_xl (int, char *);
17521 vector unsigned char vec_xl (int, vector unsigned char *);
17522 vector unsigned char vec_xl (int, unsigned char *);
17523
17524 void vec_xst (vector short, int, vector short *);
17525 void vec_xst (vector short, int, short *);
17526 void vec_xst (vector unsigned short, int, vector unsigned short *);
17527 void vec_xst (vector unsigned short, int, unsigned short *);
17528 void vec_xst (vector char, int, vector char *);
17529 void vec_xst (vector char, int, char *);
17530 void vec_xst (vector unsigned char, int, vector unsigned char *);
17531 void vec_xst (vector unsigned char, int, unsigned char *);
17532
17533 @node PowerPC Hardware Transactional Memory Built-in Functions
17534 @subsection PowerPC Hardware Transactional Memory Built-in Functions
17535 GCC provides two interfaces for accessing the Hardware Transactional
17536 Memory (HTM) instructions available on some of the PowerPC family
17537 of processors (eg, POWER8). The two interfaces come in a low level
17538 interface, consisting of built-in functions specific to PowerPC and a
17539 higher level interface consisting of inline functions that are common
17540 between PowerPC and S/390.
17541
17542 @subsubsection PowerPC HTM Low Level Built-in Functions
17543
17544 The following low level built-in functions are available with
17545 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
17546 They all generate the machine instruction that is part of the name.
17547
17548 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
17549 the full 4-bit condition register value set by their associated hardware
17550 instruction. The header file @code{htmintrin.h} defines some macros that can
17551 be used to decipher the return value. The @code{__builtin_tbegin} builtin
17552 returns a simple true or false value depending on whether a transaction was
17553 successfully started or not. The arguments of the builtins match exactly the
17554 type and order of the associated hardware instruction's operands, except for
17555 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
17556 Refer to the ISA manual for a description of each instruction's operands.
17557
17558 @smallexample
17559 unsigned int __builtin_tbegin (unsigned int)
17560 unsigned int __builtin_tend (unsigned int)
17561
17562 unsigned int __builtin_tabort (unsigned int)
17563 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
17564 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
17565 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
17566 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
17567
17568 unsigned int __builtin_tcheck (void)
17569 unsigned int __builtin_treclaim (unsigned int)
17570 unsigned int __builtin_trechkpt (void)
17571 unsigned int __builtin_tsr (unsigned int)
17572 @end smallexample
17573
17574 In addition to the above HTM built-ins, we have added built-ins for
17575 some common extended mnemonics of the HTM instructions:
17576
17577 @smallexample
17578 unsigned int __builtin_tendall (void)
17579 unsigned int __builtin_tresume (void)
17580 unsigned int __builtin_tsuspend (void)
17581 @end smallexample
17582
17583 Note that the semantics of the above HTM builtins are required to mimic
17584 the locking semantics used for critical sections. Builtins that are used
17585 to create a new transaction or restart a suspended transaction must have
17586 lock acquisition like semantics while those builtins that end or suspend a
17587 transaction must have lock release like semantics. Specifically, this must
17588 mimic lock semantics as specified by C++11, for example: Lock acquisition is
17589 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
17590 that returns 0, and lock release is as-if an execution of
17591 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
17592 implicit implementation-defined lock used for all transactions. The HTM
17593 instructions associated with with the builtins inherently provide the
17594 correct acquisition and release hardware barriers required. However,
17595 the compiler must also be prohibited from moving loads and stores across
17596 the builtins in a way that would violate their semantics. This has been
17597 accomplished by adding memory barriers to the associated HTM instructions
17598 (which is a conservative approach to provide acquire and release semantics).
17599 Earlier versions of the compiler did not treat the HTM instructions as
17600 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
17601 be used to determine whether the current compiler treats HTM instructions
17602 as memory barriers or not. This allows the user to explicitly add memory
17603 barriers to their code when using an older version of the compiler.
17604
17605 The following set of built-in functions are available to gain access
17606 to the HTM specific special purpose registers.
17607
17608 @smallexample
17609 unsigned long __builtin_get_texasr (void)
17610 unsigned long __builtin_get_texasru (void)
17611 unsigned long __builtin_get_tfhar (void)
17612 unsigned long __builtin_get_tfiar (void)
17613
17614 void __builtin_set_texasr (unsigned long);
17615 void __builtin_set_texasru (unsigned long);
17616 void __builtin_set_tfhar (unsigned long);
17617 void __builtin_set_tfiar (unsigned long);
17618 @end smallexample
17619
17620 Example usage of these low level built-in functions may look like:
17621
17622 @smallexample
17623 #include <htmintrin.h>
17624
17625 int num_retries = 10;
17626
17627 while (1)
17628 @{
17629 if (__builtin_tbegin (0))
17630 @{
17631 /* Transaction State Initiated. */
17632 if (is_locked (lock))
17633 __builtin_tabort (0);
17634 ... transaction code...
17635 __builtin_tend (0);
17636 break;
17637 @}
17638 else
17639 @{
17640 /* Transaction State Failed. Use locks if the transaction
17641 failure is "persistent" or we've tried too many times. */
17642 if (num_retries-- <= 0
17643 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
17644 @{
17645 acquire_lock (lock);
17646 ... non transactional fallback path...
17647 release_lock (lock);
17648 break;
17649 @}
17650 @}
17651 @}
17652 @end smallexample
17653
17654 One final built-in function has been added that returns the value of
17655 the 2-bit Transaction State field of the Machine Status Register (MSR)
17656 as stored in @code{CR0}.
17657
17658 @smallexample
17659 unsigned long __builtin_ttest (void)
17660 @end smallexample
17661
17662 This built-in can be used to determine the current transaction state
17663 using the following code example:
17664
17665 @smallexample
17666 #include <htmintrin.h>
17667
17668 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
17669
17670 if (tx_state == _HTM_TRANSACTIONAL)
17671 @{
17672 /* Code to use in transactional state. */
17673 @}
17674 else if (tx_state == _HTM_NONTRANSACTIONAL)
17675 @{
17676 /* Code to use in non-transactional state. */
17677 @}
17678 else if (tx_state == _HTM_SUSPENDED)
17679 @{
17680 /* Code to use in transaction suspended state. */
17681 @}
17682 @end smallexample
17683
17684 @subsubsection PowerPC HTM High Level Inline Functions
17685
17686 The following high level HTM interface is made available by including
17687 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
17688 where CPU is `power8' or later. This interface is common between PowerPC
17689 and S/390, allowing users to write one HTM source implementation that
17690 can be compiled and executed on either system.
17691
17692 @smallexample
17693 long __TM_simple_begin (void)
17694 long __TM_begin (void* const TM_buff)
17695 long __TM_end (void)
17696 void __TM_abort (void)
17697 void __TM_named_abort (unsigned char const code)
17698 void __TM_resume (void)
17699 void __TM_suspend (void)
17700
17701 long __TM_is_user_abort (void* const TM_buff)
17702 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
17703 long __TM_is_illegal (void* const TM_buff)
17704 long __TM_is_footprint_exceeded (void* const TM_buff)
17705 long __TM_nesting_depth (void* const TM_buff)
17706 long __TM_is_nested_too_deep(void* const TM_buff)
17707 long __TM_is_conflict(void* const TM_buff)
17708 long __TM_is_failure_persistent(void* const TM_buff)
17709 long __TM_failure_address(void* const TM_buff)
17710 long long __TM_failure_code(void* const TM_buff)
17711 @end smallexample
17712
17713 Using these common set of HTM inline functions, we can create
17714 a more portable version of the HTM example in the previous
17715 section that will work on either PowerPC or S/390:
17716
17717 @smallexample
17718 #include <htmxlintrin.h>
17719
17720 int num_retries = 10;
17721 TM_buff_type TM_buff;
17722
17723 while (1)
17724 @{
17725 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
17726 @{
17727 /* Transaction State Initiated. */
17728 if (is_locked (lock))
17729 __TM_abort ();
17730 ... transaction code...
17731 __TM_end ();
17732 break;
17733 @}
17734 else
17735 @{
17736 /* Transaction State Failed. Use locks if the transaction
17737 failure is "persistent" or we've tried too many times. */
17738 if (num_retries-- <= 0
17739 || __TM_is_failure_persistent (TM_buff))
17740 @{
17741 acquire_lock (lock);
17742 ... non transactional fallback path...
17743 release_lock (lock);
17744 break;
17745 @}
17746 @}
17747 @}
17748 @end smallexample
17749
17750 @node RX Built-in Functions
17751 @subsection RX Built-in Functions
17752 GCC supports some of the RX instructions which cannot be expressed in
17753 the C programming language via the use of built-in functions. The
17754 following functions are supported:
17755
17756 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
17757 Generates the @code{brk} machine instruction.
17758 @end deftypefn
17759
17760 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
17761 Generates the @code{clrpsw} machine instruction to clear the specified
17762 bit in the processor status word.
17763 @end deftypefn
17764
17765 @deftypefn {Built-in Function} void __builtin_rx_int (int)
17766 Generates the @code{int} machine instruction to generate an interrupt
17767 with the specified value.
17768 @end deftypefn
17769
17770 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
17771 Generates the @code{machi} machine instruction to add the result of
17772 multiplying the top 16 bits of the two arguments into the
17773 accumulator.
17774 @end deftypefn
17775
17776 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
17777 Generates the @code{maclo} machine instruction to add the result of
17778 multiplying the bottom 16 bits of the two arguments into the
17779 accumulator.
17780 @end deftypefn
17781
17782 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
17783 Generates the @code{mulhi} machine instruction to place the result of
17784 multiplying the top 16 bits of the two arguments into the
17785 accumulator.
17786 @end deftypefn
17787
17788 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
17789 Generates the @code{mullo} machine instruction to place the result of
17790 multiplying the bottom 16 bits of the two arguments into the
17791 accumulator.
17792 @end deftypefn
17793
17794 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
17795 Generates the @code{mvfachi} machine instruction to read the top
17796 32 bits of the accumulator.
17797 @end deftypefn
17798
17799 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
17800 Generates the @code{mvfacmi} machine instruction to read the middle
17801 32 bits of the accumulator.
17802 @end deftypefn
17803
17804 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
17805 Generates the @code{mvfc} machine instruction which reads the control
17806 register specified in its argument and returns its value.
17807 @end deftypefn
17808
17809 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
17810 Generates the @code{mvtachi} machine instruction to set the top
17811 32 bits of the accumulator.
17812 @end deftypefn
17813
17814 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
17815 Generates the @code{mvtaclo} machine instruction to set the bottom
17816 32 bits of the accumulator.
17817 @end deftypefn
17818
17819 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
17820 Generates the @code{mvtc} machine instruction which sets control
17821 register number @code{reg} to @code{val}.
17822 @end deftypefn
17823
17824 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
17825 Generates the @code{mvtipl} machine instruction set the interrupt
17826 priority level.
17827 @end deftypefn
17828
17829 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
17830 Generates the @code{racw} machine instruction to round the accumulator
17831 according to the specified mode.
17832 @end deftypefn
17833
17834 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
17835 Generates the @code{revw} machine instruction which swaps the bytes in
17836 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
17837 and also bits 16--23 occupy bits 24--31 and vice versa.
17838 @end deftypefn
17839
17840 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
17841 Generates the @code{rmpa} machine instruction which initiates a
17842 repeated multiply and accumulate sequence.
17843 @end deftypefn
17844
17845 @deftypefn {Built-in Function} void __builtin_rx_round (float)
17846 Generates the @code{round} machine instruction which returns the
17847 floating-point argument rounded according to the current rounding mode
17848 set in the floating-point status word register.
17849 @end deftypefn
17850
17851 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
17852 Generates the @code{sat} machine instruction which returns the
17853 saturated value of the argument.
17854 @end deftypefn
17855
17856 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
17857 Generates the @code{setpsw} machine instruction to set the specified
17858 bit in the processor status word.
17859 @end deftypefn
17860
17861 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
17862 Generates the @code{wait} machine instruction.
17863 @end deftypefn
17864
17865 @node S/390 System z Built-in Functions
17866 @subsection S/390 System z Built-in Functions
17867 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
17868 Generates the @code{tbegin} machine instruction starting a
17869 non-constrained hardware transaction. If the parameter is non-NULL the
17870 memory area is used to store the transaction diagnostic buffer and
17871 will be passed as first operand to @code{tbegin}. This buffer can be
17872 defined using the @code{struct __htm_tdb} C struct defined in
17873 @code{htmintrin.h} and must reside on a double-word boundary. The
17874 second tbegin operand is set to @code{0xff0c}. This enables
17875 save/restore of all GPRs and disables aborts for FPR and AR
17876 manipulations inside the transaction body. The condition code set by
17877 the tbegin instruction is returned as integer value. The tbegin
17878 instruction by definition overwrites the content of all FPRs. The
17879 compiler will generate code which saves and restores the FPRs. For
17880 soft-float code it is recommended to used the @code{*_nofloat}
17881 variant. In order to prevent a TDB from being written it is required
17882 to pass a constant zero value as parameter. Passing a zero value
17883 through a variable is not sufficient. Although modifications of
17884 access registers inside the transaction will not trigger an
17885 transaction abort it is not supported to actually modify them. Access
17886 registers do not get saved when entering a transaction. They will have
17887 undefined state when reaching the abort code.
17888 @end deftypefn
17889
17890 Macros for the possible return codes of tbegin are defined in the
17891 @code{htmintrin.h} header file:
17892
17893 @table @code
17894 @item _HTM_TBEGIN_STARTED
17895 @code{tbegin} has been executed as part of normal processing. The
17896 transaction body is supposed to be executed.
17897 @item _HTM_TBEGIN_INDETERMINATE
17898 The transaction was aborted due to an indeterminate condition which
17899 might be persistent.
17900 @item _HTM_TBEGIN_TRANSIENT
17901 The transaction aborted due to a transient failure. The transaction
17902 should be re-executed in that case.
17903 @item _HTM_TBEGIN_PERSISTENT
17904 The transaction aborted due to a persistent failure. Re-execution
17905 under same circumstances will not be productive.
17906 @end table
17907
17908 @defmac _HTM_FIRST_USER_ABORT_CODE
17909 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
17910 specifies the first abort code which can be used for
17911 @code{__builtin_tabort}. Values below this threshold are reserved for
17912 machine use.
17913 @end defmac
17914
17915 @deftp {Data type} {struct __htm_tdb}
17916 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
17917 the structure of the transaction diagnostic block as specified in the
17918 Principles of Operation manual chapter 5-91.
17919 @end deftp
17920
17921 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
17922 Same as @code{__builtin_tbegin} but without FPR saves and restores.
17923 Using this variant in code making use of FPRs will leave the FPRs in
17924 undefined state when entering the transaction abort handler code.
17925 @end deftypefn
17926
17927 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
17928 In addition to @code{__builtin_tbegin} a loop for transient failures
17929 is generated. If tbegin returns a condition code of 2 the transaction
17930 will be retried as often as specified in the second argument. The
17931 perform processor assist instruction is used to tell the CPU about the
17932 number of fails so far.
17933 @end deftypefn
17934
17935 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
17936 Same as @code{__builtin_tbegin_retry} but without FPR saves and
17937 restores. Using this variant in code making use of FPRs will leave
17938 the FPRs in undefined state when entering the transaction abort
17939 handler code.
17940 @end deftypefn
17941
17942 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
17943 Generates the @code{tbeginc} machine instruction starting a constrained
17944 hardware transaction. The second operand is set to @code{0xff08}.
17945 @end deftypefn
17946
17947 @deftypefn {Built-in Function} int __builtin_tend (void)
17948 Generates the @code{tend} machine instruction finishing a transaction
17949 and making the changes visible to other threads. The condition code
17950 generated by tend is returned as integer value.
17951 @end deftypefn
17952
17953 @deftypefn {Built-in Function} void __builtin_tabort (int)
17954 Generates the @code{tabort} machine instruction with the specified
17955 abort code. Abort codes from 0 through 255 are reserved and will
17956 result in an error message.
17957 @end deftypefn
17958
17959 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
17960 Generates the @code{ppa rX,rY,1} machine instruction. Where the
17961 integer parameter is loaded into rX and a value of zero is loaded into
17962 rY. The integer parameter specifies the number of times the
17963 transaction repeatedly aborted.
17964 @end deftypefn
17965
17966 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
17967 Generates the @code{etnd} machine instruction. The current nesting
17968 depth is returned as integer value. For a nesting depth of 0 the code
17969 is not executed as part of an transaction.
17970 @end deftypefn
17971
17972 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
17973
17974 Generates the @code{ntstg} machine instruction. The second argument
17975 is written to the first arguments location. The store operation will
17976 not be rolled-back in case of an transaction abort.
17977 @end deftypefn
17978
17979 @node SH Built-in Functions
17980 @subsection SH Built-in Functions
17981 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
17982 families of processors:
17983
17984 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
17985 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
17986 used by system code that manages threads and execution contexts. The compiler
17987 normally does not generate code that modifies the contents of @samp{GBR} and
17988 thus the value is preserved across function calls. Changing the @samp{GBR}
17989 value in user code must be done with caution, since the compiler might use
17990 @samp{GBR} in order to access thread local variables.
17991
17992 @end deftypefn
17993
17994 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
17995 Returns the value that is currently set in the @samp{GBR} register.
17996 Memory loads and stores that use the thread pointer as a base address are
17997 turned into @samp{GBR} based displacement loads and stores, if possible.
17998 For example:
17999 @smallexample
18000 struct my_tcb
18001 @{
18002 int a, b, c, d, e;
18003 @};
18004
18005 int get_tcb_value (void)
18006 @{
18007 // Generate @samp{mov.l @@(8,gbr),r0} instruction
18008 return ((my_tcb*)__builtin_thread_pointer ())->c;
18009 @}
18010
18011 @end smallexample
18012 @end deftypefn
18013
18014 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
18015 Returns the value that is currently set in the @samp{FPSCR} register.
18016 @end deftypefn
18017
18018 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
18019 Sets the @samp{FPSCR} register to the specified value @var{val}, while
18020 preserving the current values of the FR, SZ and PR bits.
18021 @end deftypefn
18022
18023 @node SPARC VIS Built-in Functions
18024 @subsection SPARC VIS Built-in Functions
18025
18026 GCC supports SIMD operations on the SPARC using both the generic vector
18027 extensions (@pxref{Vector Extensions}) as well as built-in functions for
18028 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
18029 switch, the VIS extension is exposed as the following built-in functions:
18030
18031 @smallexample
18032 typedef int v1si __attribute__ ((vector_size (4)));
18033 typedef int v2si __attribute__ ((vector_size (8)));
18034 typedef short v4hi __attribute__ ((vector_size (8)));
18035 typedef short v2hi __attribute__ ((vector_size (4)));
18036 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
18037 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
18038
18039 void __builtin_vis_write_gsr (int64_t);
18040 int64_t __builtin_vis_read_gsr (void);
18041
18042 void * __builtin_vis_alignaddr (void *, long);
18043 void * __builtin_vis_alignaddrl (void *, long);
18044 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
18045 v2si __builtin_vis_faligndatav2si (v2si, v2si);
18046 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
18047 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
18048
18049 v4hi __builtin_vis_fexpand (v4qi);
18050
18051 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
18052 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
18053 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
18054 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
18055 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
18056 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
18057 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
18058
18059 v4qi __builtin_vis_fpack16 (v4hi);
18060 v8qi __builtin_vis_fpack32 (v2si, v8qi);
18061 v2hi __builtin_vis_fpackfix (v2si);
18062 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
18063
18064 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
18065
18066 long __builtin_vis_edge8 (void *, void *);
18067 long __builtin_vis_edge8l (void *, void *);
18068 long __builtin_vis_edge16 (void *, void *);
18069 long __builtin_vis_edge16l (void *, void *);
18070 long __builtin_vis_edge32 (void *, void *);
18071 long __builtin_vis_edge32l (void *, void *);
18072
18073 long __builtin_vis_fcmple16 (v4hi, v4hi);
18074 long __builtin_vis_fcmple32 (v2si, v2si);
18075 long __builtin_vis_fcmpne16 (v4hi, v4hi);
18076 long __builtin_vis_fcmpne32 (v2si, v2si);
18077 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
18078 long __builtin_vis_fcmpgt32 (v2si, v2si);
18079 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
18080 long __builtin_vis_fcmpeq32 (v2si, v2si);
18081
18082 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
18083 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
18084 v2si __builtin_vis_fpadd32 (v2si, v2si);
18085 v1si __builtin_vis_fpadd32s (v1si, v1si);
18086 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
18087 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
18088 v2si __builtin_vis_fpsub32 (v2si, v2si);
18089 v1si __builtin_vis_fpsub32s (v1si, v1si);
18090
18091 long __builtin_vis_array8 (long, long);
18092 long __builtin_vis_array16 (long, long);
18093 long __builtin_vis_array32 (long, long);
18094 @end smallexample
18095
18096 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
18097 functions also become available:
18098
18099 @smallexample
18100 long __builtin_vis_bmask (long, long);
18101 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
18102 v2si __builtin_vis_bshufflev2si (v2si, v2si);
18103 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
18104 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
18105
18106 long __builtin_vis_edge8n (void *, void *);
18107 long __builtin_vis_edge8ln (void *, void *);
18108 long __builtin_vis_edge16n (void *, void *);
18109 long __builtin_vis_edge16ln (void *, void *);
18110 long __builtin_vis_edge32n (void *, void *);
18111 long __builtin_vis_edge32ln (void *, void *);
18112 @end smallexample
18113
18114 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
18115 functions also become available:
18116
18117 @smallexample
18118 void __builtin_vis_cmask8 (long);
18119 void __builtin_vis_cmask16 (long);
18120 void __builtin_vis_cmask32 (long);
18121
18122 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
18123
18124 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
18125 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
18126 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
18127 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
18128 v2si __builtin_vis_fsll16 (v2si, v2si);
18129 v2si __builtin_vis_fslas16 (v2si, v2si);
18130 v2si __builtin_vis_fsrl16 (v2si, v2si);
18131 v2si __builtin_vis_fsra16 (v2si, v2si);
18132
18133 long __builtin_vis_pdistn (v8qi, v8qi);
18134
18135 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
18136
18137 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
18138 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
18139
18140 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
18141 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
18142 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
18143 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
18144 v2si __builtin_vis_fpadds32 (v2si, v2si);
18145 v1si __builtin_vis_fpadds32s (v1si, v1si);
18146 v2si __builtin_vis_fpsubs32 (v2si, v2si);
18147 v1si __builtin_vis_fpsubs32s (v1si, v1si);
18148
18149 long __builtin_vis_fucmple8 (v8qi, v8qi);
18150 long __builtin_vis_fucmpne8 (v8qi, v8qi);
18151 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
18152 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
18153
18154 float __builtin_vis_fhadds (float, float);
18155 double __builtin_vis_fhaddd (double, double);
18156 float __builtin_vis_fhsubs (float, float);
18157 double __builtin_vis_fhsubd (double, double);
18158 float __builtin_vis_fnhadds (float, float);
18159 double __builtin_vis_fnhaddd (double, double);
18160
18161 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
18162 int64_t __builtin_vis_xmulx (int64_t, int64_t);
18163 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
18164 @end smallexample
18165
18166 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
18167 functions also become available:
18168
18169 @smallexample
18170 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
18171 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
18172 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
18173 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
18174
18175 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
18176 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
18177 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
18178 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
18179
18180 long __builtin_vis_fpcmple8 (v8qi, v8qi);
18181 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
18182 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
18183 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
18184 long __builtin_vis_fpcmpule32 (v2si, v2si);
18185 long __builtin_vis_fpcmpugt32 (v2si, v2si);
18186
18187 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
18188 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
18189 v2si __builtin_vis_fpmax32 (v2si, v2si);
18190
18191 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
18192 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
18193 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
18194
18195
18196 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
18197 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
18198 v2si __builtin_vis_fpmin32 (v2si, v2si);
18199
18200 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
18201 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
18202 v2si __builtin_vis_fpminu32 (v2si, v2si);
18203 @end smallexample
18204
18205 @node SPU Built-in Functions
18206 @subsection SPU Built-in Functions
18207
18208 GCC provides extensions for the SPU processor as described in the
18209 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
18210 found at @uref{http://cell.scei.co.jp/} or
18211 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
18212 implementation differs in several ways.
18213
18214 @itemize @bullet
18215
18216 @item
18217 The optional extension of specifying vector constants in parentheses is
18218 not supported.
18219
18220 @item
18221 A vector initializer requires no cast if the vector constant is of the
18222 same type as the variable it is initializing.
18223
18224 @item
18225 If @code{signed} or @code{unsigned} is omitted, the signedness of the
18226 vector type is the default signedness of the base type. The default
18227 varies depending on the operating system, so a portable program should
18228 always specify the signedness.
18229
18230 @item
18231 By default, the keyword @code{__vector} is added. The macro
18232 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
18233 undefined.
18234
18235 @item
18236 GCC allows using a @code{typedef} name as the type specifier for a
18237 vector type.
18238
18239 @item
18240 For C, overloaded functions are implemented with macros so the following
18241 does not work:
18242
18243 @smallexample
18244 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
18245 @end smallexample
18246
18247 @noindent
18248 Since @code{spu_add} is a macro, the vector constant in the example
18249 is treated as four separate arguments. Wrap the entire argument in
18250 parentheses for this to work.
18251
18252 @item
18253 The extended version of @code{__builtin_expect} is not supported.
18254
18255 @end itemize
18256
18257 @emph{Note:} Only the interface described in the aforementioned
18258 specification is supported. Internally, GCC uses built-in functions to
18259 implement the required functionality, but these are not supported and
18260 are subject to change without notice.
18261
18262 @node TI C6X Built-in Functions
18263 @subsection TI C6X Built-in Functions
18264
18265 GCC provides intrinsics to access certain instructions of the TI C6X
18266 processors. These intrinsics, listed below, are available after
18267 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
18268 to C6X instructions.
18269
18270 @smallexample
18271
18272 int _sadd (int, int)
18273 int _ssub (int, int)
18274 int _sadd2 (int, int)
18275 int _ssub2 (int, int)
18276 long long _mpy2 (int, int)
18277 long long _smpy2 (int, int)
18278 int _add4 (int, int)
18279 int _sub4 (int, int)
18280 int _saddu4 (int, int)
18281
18282 int _smpy (int, int)
18283 int _smpyh (int, int)
18284 int _smpyhl (int, int)
18285 int _smpylh (int, int)
18286
18287 int _sshl (int, int)
18288 int _subc (int, int)
18289
18290 int _avg2 (int, int)
18291 int _avgu4 (int, int)
18292
18293 int _clrr (int, int)
18294 int _extr (int, int)
18295 int _extru (int, int)
18296 int _abs (int)
18297 int _abs2 (int)
18298
18299 @end smallexample
18300
18301 @node TILE-Gx Built-in Functions
18302 @subsection TILE-Gx Built-in Functions
18303
18304 GCC provides intrinsics to access every instruction of the TILE-Gx
18305 processor. The intrinsics are of the form:
18306
18307 @smallexample
18308
18309 unsigned long long __insn_@var{op} (...)
18310
18311 @end smallexample
18312
18313 Where @var{op} is the name of the instruction. Refer to the ISA manual
18314 for the complete list of instructions.
18315
18316 GCC also provides intrinsics to directly access the network registers.
18317 The intrinsics are:
18318
18319 @smallexample
18320
18321 unsigned long long __tile_idn0_receive (void)
18322 unsigned long long __tile_idn1_receive (void)
18323 unsigned long long __tile_udn0_receive (void)
18324 unsigned long long __tile_udn1_receive (void)
18325 unsigned long long __tile_udn2_receive (void)
18326 unsigned long long __tile_udn3_receive (void)
18327 void __tile_idn_send (unsigned long long)
18328 void __tile_udn_send (unsigned long long)
18329
18330 @end smallexample
18331
18332 The intrinsic @code{void __tile_network_barrier (void)} is used to
18333 guarantee that no network operations before it are reordered with
18334 those after it.
18335
18336 @node TILEPro Built-in Functions
18337 @subsection TILEPro Built-in Functions
18338
18339 GCC provides intrinsics to access every instruction of the TILEPro
18340 processor. The intrinsics are of the form:
18341
18342 @smallexample
18343
18344 unsigned __insn_@var{op} (...)
18345
18346 @end smallexample
18347
18348 @noindent
18349 where @var{op} is the name of the instruction. Refer to the ISA manual
18350 for the complete list of instructions.
18351
18352 GCC also provides intrinsics to directly access the network registers.
18353 The intrinsics are:
18354
18355 @smallexample
18356
18357 unsigned __tile_idn0_receive (void)
18358 unsigned __tile_idn1_receive (void)
18359 unsigned __tile_sn_receive (void)
18360 unsigned __tile_udn0_receive (void)
18361 unsigned __tile_udn1_receive (void)
18362 unsigned __tile_udn2_receive (void)
18363 unsigned __tile_udn3_receive (void)
18364 void __tile_idn_send (unsigned)
18365 void __tile_sn_send (unsigned)
18366 void __tile_udn_send (unsigned)
18367
18368 @end smallexample
18369
18370 The intrinsic @code{void __tile_network_barrier (void)} is used to
18371 guarantee that no network operations before it are reordered with
18372 those after it.
18373
18374 @node x86 Built-in Functions
18375 @subsection x86 Built-in Functions
18376
18377 These built-in functions are available for the x86-32 and x86-64 family
18378 of computers, depending on the command-line switches used.
18379
18380 If you specify command-line switches such as @option{-msse},
18381 the compiler could use the extended instruction sets even if the built-ins
18382 are not used explicitly in the program. For this reason, applications
18383 that perform run-time CPU detection must compile separate files for each
18384 supported architecture, using the appropriate flags. In particular,
18385 the file containing the CPU detection code should be compiled without
18386 these options.
18387
18388 The following machine modes are available for use with MMX built-in functions
18389 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
18390 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
18391 vector of eight 8-bit integers. Some of the built-in functions operate on
18392 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
18393
18394 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
18395 of two 32-bit floating-point values.
18396
18397 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
18398 floating-point values. Some instructions use a vector of four 32-bit
18399 integers, these use @code{V4SI}. Finally, some instructions operate on an
18400 entire vector register, interpreting it as a 128-bit integer, these use mode
18401 @code{TI}.
18402
18403 In 64-bit mode, the x86-64 family of processors uses additional built-in
18404 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
18405 floating point and @code{TC} 128-bit complex floating-point values.
18406
18407 The following floating-point built-in functions are available in 64-bit
18408 mode. All of them implement the function that is part of the name.
18409
18410 @smallexample
18411 __float128 __builtin_fabsq (__float128)
18412 __float128 __builtin_copysignq (__float128, __float128)
18413 @end smallexample
18414
18415 The following built-in function is always available.
18416
18417 @table @code
18418 @item void __builtin_ia32_pause (void)
18419 Generates the @code{pause} machine instruction with a compiler memory
18420 barrier.
18421 @end table
18422
18423 The following floating-point built-in functions are made available in the
18424 64-bit mode.
18425
18426 @table @code
18427 @item __float128 __builtin_infq (void)
18428 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
18429 @findex __builtin_infq
18430
18431 @item __float128 __builtin_huge_valq (void)
18432 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
18433 @findex __builtin_huge_valq
18434 @end table
18435
18436 The following built-in functions are always available and can be used to
18437 check the target platform type.
18438
18439 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
18440 This function runs the CPU detection code to check the type of CPU and the
18441 features supported. This built-in function needs to be invoked along with the built-in functions
18442 to check CPU type and features, @code{__builtin_cpu_is} and
18443 @code{__builtin_cpu_supports}, only when used in a function that is
18444 executed before any constructors are called. The CPU detection code is
18445 automatically executed in a very high priority constructor.
18446
18447 For example, this function has to be used in @code{ifunc} resolvers that
18448 check for CPU type using the built-in functions @code{__builtin_cpu_is}
18449 and @code{__builtin_cpu_supports}, or in constructors on targets that
18450 don't support constructor priority.
18451 @smallexample
18452
18453 static void (*resolve_memcpy (void)) (void)
18454 @{
18455 // ifunc resolvers fire before constructors, explicitly call the init
18456 // function.
18457 __builtin_cpu_init ();
18458 if (__builtin_cpu_supports ("ssse3"))
18459 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
18460 else
18461 return default_memcpy;
18462 @}
18463
18464 void *memcpy (void *, const void *, size_t)
18465 __attribute__ ((ifunc ("resolve_memcpy")));
18466 @end smallexample
18467
18468 @end deftypefn
18469
18470 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
18471 This function returns a positive integer if the run-time CPU
18472 is of type @var{cpuname}
18473 and returns @code{0} otherwise. The following CPU names can be detected:
18474
18475 @table @samp
18476 @item intel
18477 Intel CPU.
18478
18479 @item atom
18480 Intel Atom CPU.
18481
18482 @item core2
18483 Intel Core 2 CPU.
18484
18485 @item corei7
18486 Intel Core i7 CPU.
18487
18488 @item nehalem
18489 Intel Core i7 Nehalem CPU.
18490
18491 @item westmere
18492 Intel Core i7 Westmere CPU.
18493
18494 @item sandybridge
18495 Intel Core i7 Sandy Bridge CPU.
18496
18497 @item amd
18498 AMD CPU.
18499
18500 @item amdfam10h
18501 AMD Family 10h CPU.
18502
18503 @item barcelona
18504 AMD Family 10h Barcelona CPU.
18505
18506 @item shanghai
18507 AMD Family 10h Shanghai CPU.
18508
18509 @item istanbul
18510 AMD Family 10h Istanbul CPU.
18511
18512 @item btver1
18513 AMD Family 14h CPU.
18514
18515 @item amdfam15h
18516 AMD Family 15h CPU.
18517
18518 @item bdver1
18519 AMD Family 15h Bulldozer version 1.
18520
18521 @item bdver2
18522 AMD Family 15h Bulldozer version 2.
18523
18524 @item bdver3
18525 AMD Family 15h Bulldozer version 3.
18526
18527 @item bdver4
18528 AMD Family 15h Bulldozer version 4.
18529
18530 @item btver2
18531 AMD Family 16h CPU.
18532
18533 @item znver1
18534 AMD Family 17h CPU.
18535 @end table
18536
18537 Here is an example:
18538 @smallexample
18539 if (__builtin_cpu_is ("corei7"))
18540 @{
18541 do_corei7 (); // Core i7 specific implementation.
18542 @}
18543 else
18544 @{
18545 do_generic (); // Generic implementation.
18546 @}
18547 @end smallexample
18548 @end deftypefn
18549
18550 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
18551 This function returns a positive integer if the run-time CPU
18552 supports @var{feature}
18553 and returns @code{0} otherwise. The following features can be detected:
18554
18555 @table @samp
18556 @item cmov
18557 CMOV instruction.
18558 @item mmx
18559 MMX instructions.
18560 @item popcnt
18561 POPCNT instruction.
18562 @item sse
18563 SSE instructions.
18564 @item sse2
18565 SSE2 instructions.
18566 @item sse3
18567 SSE3 instructions.
18568 @item ssse3
18569 SSSE3 instructions.
18570 @item sse4.1
18571 SSE4.1 instructions.
18572 @item sse4.2
18573 SSE4.2 instructions.
18574 @item avx
18575 AVX instructions.
18576 @item avx2
18577 AVX2 instructions.
18578 @item avx512f
18579 AVX512F instructions.
18580 @end table
18581
18582 Here is an example:
18583 @smallexample
18584 if (__builtin_cpu_supports ("popcnt"))
18585 @{
18586 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
18587 @}
18588 else
18589 @{
18590 count = generic_countbits (n); //generic implementation.
18591 @}
18592 @end smallexample
18593 @end deftypefn
18594
18595
18596 The following built-in functions are made available by @option{-mmmx}.
18597 All of them generate the machine instruction that is part of the name.
18598
18599 @smallexample
18600 v8qi __builtin_ia32_paddb (v8qi, v8qi)
18601 v4hi __builtin_ia32_paddw (v4hi, v4hi)
18602 v2si __builtin_ia32_paddd (v2si, v2si)
18603 v8qi __builtin_ia32_psubb (v8qi, v8qi)
18604 v4hi __builtin_ia32_psubw (v4hi, v4hi)
18605 v2si __builtin_ia32_psubd (v2si, v2si)
18606 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
18607 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
18608 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
18609 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
18610 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
18611 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
18612 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
18613 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
18614 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
18615 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
18616 di __builtin_ia32_pand (di, di)
18617 di __builtin_ia32_pandn (di,di)
18618 di __builtin_ia32_por (di, di)
18619 di __builtin_ia32_pxor (di, di)
18620 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
18621 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
18622 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
18623 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
18624 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
18625 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
18626 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
18627 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
18628 v2si __builtin_ia32_punpckhdq (v2si, v2si)
18629 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
18630 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
18631 v2si __builtin_ia32_punpckldq (v2si, v2si)
18632 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
18633 v4hi __builtin_ia32_packssdw (v2si, v2si)
18634 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
18635
18636 v4hi __builtin_ia32_psllw (v4hi, v4hi)
18637 v2si __builtin_ia32_pslld (v2si, v2si)
18638 v1di __builtin_ia32_psllq (v1di, v1di)
18639 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
18640 v2si __builtin_ia32_psrld (v2si, v2si)
18641 v1di __builtin_ia32_psrlq (v1di, v1di)
18642 v4hi __builtin_ia32_psraw (v4hi, v4hi)
18643 v2si __builtin_ia32_psrad (v2si, v2si)
18644 v4hi __builtin_ia32_psllwi (v4hi, int)
18645 v2si __builtin_ia32_pslldi (v2si, int)
18646 v1di __builtin_ia32_psllqi (v1di, int)
18647 v4hi __builtin_ia32_psrlwi (v4hi, int)
18648 v2si __builtin_ia32_psrldi (v2si, int)
18649 v1di __builtin_ia32_psrlqi (v1di, int)
18650 v4hi __builtin_ia32_psrawi (v4hi, int)
18651 v2si __builtin_ia32_psradi (v2si, int)
18652
18653 @end smallexample
18654
18655 The following built-in functions are made available either with
18656 @option{-msse}, or with a combination of @option{-m3dnow} and
18657 @option{-march=athlon}. All of them generate the machine
18658 instruction that is part of the name.
18659
18660 @smallexample
18661 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
18662 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
18663 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
18664 v1di __builtin_ia32_psadbw (v8qi, v8qi)
18665 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
18666 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
18667 v8qi __builtin_ia32_pminub (v8qi, v8qi)
18668 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
18669 int __builtin_ia32_pmovmskb (v8qi)
18670 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
18671 void __builtin_ia32_movntq (di *, di)
18672 void __builtin_ia32_sfence (void)
18673 @end smallexample
18674
18675 The following built-in functions are available when @option{-msse} is used.
18676 All of them generate the machine instruction that is part of the name.
18677
18678 @smallexample
18679 int __builtin_ia32_comieq (v4sf, v4sf)
18680 int __builtin_ia32_comineq (v4sf, v4sf)
18681 int __builtin_ia32_comilt (v4sf, v4sf)
18682 int __builtin_ia32_comile (v4sf, v4sf)
18683 int __builtin_ia32_comigt (v4sf, v4sf)
18684 int __builtin_ia32_comige (v4sf, v4sf)
18685 int __builtin_ia32_ucomieq (v4sf, v4sf)
18686 int __builtin_ia32_ucomineq (v4sf, v4sf)
18687 int __builtin_ia32_ucomilt (v4sf, v4sf)
18688 int __builtin_ia32_ucomile (v4sf, v4sf)
18689 int __builtin_ia32_ucomigt (v4sf, v4sf)
18690 int __builtin_ia32_ucomige (v4sf, v4sf)
18691 v4sf __builtin_ia32_addps (v4sf, v4sf)
18692 v4sf __builtin_ia32_subps (v4sf, v4sf)
18693 v4sf __builtin_ia32_mulps (v4sf, v4sf)
18694 v4sf __builtin_ia32_divps (v4sf, v4sf)
18695 v4sf __builtin_ia32_addss (v4sf, v4sf)
18696 v4sf __builtin_ia32_subss (v4sf, v4sf)
18697 v4sf __builtin_ia32_mulss (v4sf, v4sf)
18698 v4sf __builtin_ia32_divss (v4sf, v4sf)
18699 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
18700 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
18701 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
18702 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
18703 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
18704 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
18705 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
18706 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
18707 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
18708 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
18709 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
18710 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
18711 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
18712 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
18713 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
18714 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
18715 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
18716 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
18717 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
18718 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
18719 v4sf __builtin_ia32_maxps (v4sf, v4sf)
18720 v4sf __builtin_ia32_maxss (v4sf, v4sf)
18721 v4sf __builtin_ia32_minps (v4sf, v4sf)
18722 v4sf __builtin_ia32_minss (v4sf, v4sf)
18723 v4sf __builtin_ia32_andps (v4sf, v4sf)
18724 v4sf __builtin_ia32_andnps (v4sf, v4sf)
18725 v4sf __builtin_ia32_orps (v4sf, v4sf)
18726 v4sf __builtin_ia32_xorps (v4sf, v4sf)
18727 v4sf __builtin_ia32_movss (v4sf, v4sf)
18728 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
18729 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
18730 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
18731 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
18732 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
18733 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
18734 v2si __builtin_ia32_cvtps2pi (v4sf)
18735 int __builtin_ia32_cvtss2si (v4sf)
18736 v2si __builtin_ia32_cvttps2pi (v4sf)
18737 int __builtin_ia32_cvttss2si (v4sf)
18738 v4sf __builtin_ia32_rcpps (v4sf)
18739 v4sf __builtin_ia32_rsqrtps (v4sf)
18740 v4sf __builtin_ia32_sqrtps (v4sf)
18741 v4sf __builtin_ia32_rcpss (v4sf)
18742 v4sf __builtin_ia32_rsqrtss (v4sf)
18743 v4sf __builtin_ia32_sqrtss (v4sf)
18744 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
18745 void __builtin_ia32_movntps (float *, v4sf)
18746 int __builtin_ia32_movmskps (v4sf)
18747 @end smallexample
18748
18749 The following built-in functions are available when @option{-msse} is used.
18750
18751 @table @code
18752 @item v4sf __builtin_ia32_loadups (float *)
18753 Generates the @code{movups} machine instruction as a load from memory.
18754 @item void __builtin_ia32_storeups (float *, v4sf)
18755 Generates the @code{movups} machine instruction as a store to memory.
18756 @item v4sf __builtin_ia32_loadss (float *)
18757 Generates the @code{movss} machine instruction as a load from memory.
18758 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
18759 Generates the @code{movhps} machine instruction as a load from memory.
18760 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
18761 Generates the @code{movlps} machine instruction as a load from memory
18762 @item void __builtin_ia32_storehps (v2sf *, v4sf)
18763 Generates the @code{movhps} machine instruction as a store to memory.
18764 @item void __builtin_ia32_storelps (v2sf *, v4sf)
18765 Generates the @code{movlps} machine instruction as a store to memory.
18766 @end table
18767
18768 The following built-in functions are available when @option{-msse2} is used.
18769 All of them generate the machine instruction that is part of the name.
18770
18771 @smallexample
18772 int __builtin_ia32_comisdeq (v2df, v2df)
18773 int __builtin_ia32_comisdlt (v2df, v2df)
18774 int __builtin_ia32_comisdle (v2df, v2df)
18775 int __builtin_ia32_comisdgt (v2df, v2df)
18776 int __builtin_ia32_comisdge (v2df, v2df)
18777 int __builtin_ia32_comisdneq (v2df, v2df)
18778 int __builtin_ia32_ucomisdeq (v2df, v2df)
18779 int __builtin_ia32_ucomisdlt (v2df, v2df)
18780 int __builtin_ia32_ucomisdle (v2df, v2df)
18781 int __builtin_ia32_ucomisdgt (v2df, v2df)
18782 int __builtin_ia32_ucomisdge (v2df, v2df)
18783 int __builtin_ia32_ucomisdneq (v2df, v2df)
18784 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
18785 v2df __builtin_ia32_cmpltpd (v2df, v2df)
18786 v2df __builtin_ia32_cmplepd (v2df, v2df)
18787 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
18788 v2df __builtin_ia32_cmpgepd (v2df, v2df)
18789 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
18790 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
18791 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
18792 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
18793 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
18794 v2df __builtin_ia32_cmpngepd (v2df, v2df)
18795 v2df __builtin_ia32_cmpordpd (v2df, v2df)
18796 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
18797 v2df __builtin_ia32_cmpltsd (v2df, v2df)
18798 v2df __builtin_ia32_cmplesd (v2df, v2df)
18799 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
18800 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
18801 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
18802 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
18803 v2df __builtin_ia32_cmpordsd (v2df, v2df)
18804 v2di __builtin_ia32_paddq (v2di, v2di)
18805 v2di __builtin_ia32_psubq (v2di, v2di)
18806 v2df __builtin_ia32_addpd (v2df, v2df)
18807 v2df __builtin_ia32_subpd (v2df, v2df)
18808 v2df __builtin_ia32_mulpd (v2df, v2df)
18809 v2df __builtin_ia32_divpd (v2df, v2df)
18810 v2df __builtin_ia32_addsd (v2df, v2df)
18811 v2df __builtin_ia32_subsd (v2df, v2df)
18812 v2df __builtin_ia32_mulsd (v2df, v2df)
18813 v2df __builtin_ia32_divsd (v2df, v2df)
18814 v2df __builtin_ia32_minpd (v2df, v2df)
18815 v2df __builtin_ia32_maxpd (v2df, v2df)
18816 v2df __builtin_ia32_minsd (v2df, v2df)
18817 v2df __builtin_ia32_maxsd (v2df, v2df)
18818 v2df __builtin_ia32_andpd (v2df, v2df)
18819 v2df __builtin_ia32_andnpd (v2df, v2df)
18820 v2df __builtin_ia32_orpd (v2df, v2df)
18821 v2df __builtin_ia32_xorpd (v2df, v2df)
18822 v2df __builtin_ia32_movsd (v2df, v2df)
18823 v2df __builtin_ia32_unpckhpd (v2df, v2df)
18824 v2df __builtin_ia32_unpcklpd (v2df, v2df)
18825 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
18826 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
18827 v4si __builtin_ia32_paddd128 (v4si, v4si)
18828 v2di __builtin_ia32_paddq128 (v2di, v2di)
18829 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
18830 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
18831 v4si __builtin_ia32_psubd128 (v4si, v4si)
18832 v2di __builtin_ia32_psubq128 (v2di, v2di)
18833 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
18834 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
18835 v2di __builtin_ia32_pand128 (v2di, v2di)
18836 v2di __builtin_ia32_pandn128 (v2di, v2di)
18837 v2di __builtin_ia32_por128 (v2di, v2di)
18838 v2di __builtin_ia32_pxor128 (v2di, v2di)
18839 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
18840 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
18841 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
18842 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
18843 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
18844 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
18845 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
18846 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
18847 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
18848 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
18849 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
18850 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
18851 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
18852 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
18853 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
18854 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
18855 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
18856 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
18857 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
18858 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
18859 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
18860 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
18861 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
18862 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
18863 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
18864 v2df __builtin_ia32_loadupd (double *)
18865 void __builtin_ia32_storeupd (double *, v2df)
18866 v2df __builtin_ia32_loadhpd (v2df, double const *)
18867 v2df __builtin_ia32_loadlpd (v2df, double const *)
18868 int __builtin_ia32_movmskpd (v2df)
18869 int __builtin_ia32_pmovmskb128 (v16qi)
18870 void __builtin_ia32_movnti (int *, int)
18871 void __builtin_ia32_movnti64 (long long int *, long long int)
18872 void __builtin_ia32_movntpd (double *, v2df)
18873 void __builtin_ia32_movntdq (v2df *, v2df)
18874 v4si __builtin_ia32_pshufd (v4si, int)
18875 v8hi __builtin_ia32_pshuflw (v8hi, int)
18876 v8hi __builtin_ia32_pshufhw (v8hi, int)
18877 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
18878 v2df __builtin_ia32_sqrtpd (v2df)
18879 v2df __builtin_ia32_sqrtsd (v2df)
18880 v2df __builtin_ia32_shufpd (v2df, v2df, int)
18881 v2df __builtin_ia32_cvtdq2pd (v4si)
18882 v4sf __builtin_ia32_cvtdq2ps (v4si)
18883 v4si __builtin_ia32_cvtpd2dq (v2df)
18884 v2si __builtin_ia32_cvtpd2pi (v2df)
18885 v4sf __builtin_ia32_cvtpd2ps (v2df)
18886 v4si __builtin_ia32_cvttpd2dq (v2df)
18887 v2si __builtin_ia32_cvttpd2pi (v2df)
18888 v2df __builtin_ia32_cvtpi2pd (v2si)
18889 int __builtin_ia32_cvtsd2si (v2df)
18890 int __builtin_ia32_cvttsd2si (v2df)
18891 long long __builtin_ia32_cvtsd2si64 (v2df)
18892 long long __builtin_ia32_cvttsd2si64 (v2df)
18893 v4si __builtin_ia32_cvtps2dq (v4sf)
18894 v2df __builtin_ia32_cvtps2pd (v4sf)
18895 v4si __builtin_ia32_cvttps2dq (v4sf)
18896 v2df __builtin_ia32_cvtsi2sd (v2df, int)
18897 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
18898 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
18899 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
18900 void __builtin_ia32_clflush (const void *)
18901 void __builtin_ia32_lfence (void)
18902 void __builtin_ia32_mfence (void)
18903 v16qi __builtin_ia32_loaddqu (const char *)
18904 void __builtin_ia32_storedqu (char *, v16qi)
18905 v1di __builtin_ia32_pmuludq (v2si, v2si)
18906 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
18907 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
18908 v4si __builtin_ia32_pslld128 (v4si, v4si)
18909 v2di __builtin_ia32_psllq128 (v2di, v2di)
18910 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
18911 v4si __builtin_ia32_psrld128 (v4si, v4si)
18912 v2di __builtin_ia32_psrlq128 (v2di, v2di)
18913 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
18914 v4si __builtin_ia32_psrad128 (v4si, v4si)
18915 v2di __builtin_ia32_pslldqi128 (v2di, int)
18916 v8hi __builtin_ia32_psllwi128 (v8hi, int)
18917 v4si __builtin_ia32_pslldi128 (v4si, int)
18918 v2di __builtin_ia32_psllqi128 (v2di, int)
18919 v2di __builtin_ia32_psrldqi128 (v2di, int)
18920 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
18921 v4si __builtin_ia32_psrldi128 (v4si, int)
18922 v2di __builtin_ia32_psrlqi128 (v2di, int)
18923 v8hi __builtin_ia32_psrawi128 (v8hi, int)
18924 v4si __builtin_ia32_psradi128 (v4si, int)
18925 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
18926 v2di __builtin_ia32_movq128 (v2di)
18927 @end smallexample
18928
18929 The following built-in functions are available when @option{-msse3} is used.
18930 All of them generate the machine instruction that is part of the name.
18931
18932 @smallexample
18933 v2df __builtin_ia32_addsubpd (v2df, v2df)
18934 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
18935 v2df __builtin_ia32_haddpd (v2df, v2df)
18936 v4sf __builtin_ia32_haddps (v4sf, v4sf)
18937 v2df __builtin_ia32_hsubpd (v2df, v2df)
18938 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
18939 v16qi __builtin_ia32_lddqu (char const *)
18940 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
18941 v4sf __builtin_ia32_movshdup (v4sf)
18942 v4sf __builtin_ia32_movsldup (v4sf)
18943 void __builtin_ia32_mwait (unsigned int, unsigned int)
18944 @end smallexample
18945
18946 The following built-in functions are available when @option{-mssse3} is used.
18947 All of them generate the machine instruction that is part of the name.
18948
18949 @smallexample
18950 v2si __builtin_ia32_phaddd (v2si, v2si)
18951 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
18952 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
18953 v2si __builtin_ia32_phsubd (v2si, v2si)
18954 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
18955 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
18956 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
18957 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
18958 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
18959 v8qi __builtin_ia32_psignb (v8qi, v8qi)
18960 v2si __builtin_ia32_psignd (v2si, v2si)
18961 v4hi __builtin_ia32_psignw (v4hi, v4hi)
18962 v1di __builtin_ia32_palignr (v1di, v1di, int)
18963 v8qi __builtin_ia32_pabsb (v8qi)
18964 v2si __builtin_ia32_pabsd (v2si)
18965 v4hi __builtin_ia32_pabsw (v4hi)
18966 @end smallexample
18967
18968 The following built-in functions are available when @option{-mssse3} is used.
18969 All of them generate the machine instruction that is part of the name.
18970
18971 @smallexample
18972 v4si __builtin_ia32_phaddd128 (v4si, v4si)
18973 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
18974 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
18975 v4si __builtin_ia32_phsubd128 (v4si, v4si)
18976 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
18977 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
18978 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
18979 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
18980 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
18981 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
18982 v4si __builtin_ia32_psignd128 (v4si, v4si)
18983 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
18984 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
18985 v16qi __builtin_ia32_pabsb128 (v16qi)
18986 v4si __builtin_ia32_pabsd128 (v4si)
18987 v8hi __builtin_ia32_pabsw128 (v8hi)
18988 @end smallexample
18989
18990 The following built-in functions are available when @option{-msse4.1} is
18991 used. All of them generate the machine instruction that is part of the
18992 name.
18993
18994 @smallexample
18995 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
18996 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
18997 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
18998 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
18999 v2df __builtin_ia32_dppd (v2df, v2df, const int)
19000 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
19001 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
19002 v2di __builtin_ia32_movntdqa (v2di *);
19003 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
19004 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
19005 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
19006 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
19007 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
19008 v8hi __builtin_ia32_phminposuw128 (v8hi)
19009 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
19010 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
19011 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
19012 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
19013 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
19014 v4si __builtin_ia32_pminsd128 (v4si, v4si)
19015 v4si __builtin_ia32_pminud128 (v4si, v4si)
19016 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
19017 v4si __builtin_ia32_pmovsxbd128 (v16qi)
19018 v2di __builtin_ia32_pmovsxbq128 (v16qi)
19019 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
19020 v2di __builtin_ia32_pmovsxdq128 (v4si)
19021 v4si __builtin_ia32_pmovsxwd128 (v8hi)
19022 v2di __builtin_ia32_pmovsxwq128 (v8hi)
19023 v4si __builtin_ia32_pmovzxbd128 (v16qi)
19024 v2di __builtin_ia32_pmovzxbq128 (v16qi)
19025 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
19026 v2di __builtin_ia32_pmovzxdq128 (v4si)
19027 v4si __builtin_ia32_pmovzxwd128 (v8hi)
19028 v2di __builtin_ia32_pmovzxwq128 (v8hi)
19029 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
19030 v4si __builtin_ia32_pmulld128 (v4si, v4si)
19031 int __builtin_ia32_ptestc128 (v2di, v2di)
19032 int __builtin_ia32_ptestnzc128 (v2di, v2di)
19033 int __builtin_ia32_ptestz128 (v2di, v2di)
19034 v2df __builtin_ia32_roundpd (v2df, const int)
19035 v4sf __builtin_ia32_roundps (v4sf, const int)
19036 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
19037 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
19038 @end smallexample
19039
19040 The following built-in functions are available when @option{-msse4.1} is
19041 used.
19042
19043 @table @code
19044 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
19045 Generates the @code{insertps} machine instruction.
19046 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
19047 Generates the @code{pextrb} machine instruction.
19048 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
19049 Generates the @code{pinsrb} machine instruction.
19050 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
19051 Generates the @code{pinsrd} machine instruction.
19052 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
19053 Generates the @code{pinsrq} machine instruction in 64bit mode.
19054 @end table
19055
19056 The following built-in functions are changed to generate new SSE4.1
19057 instructions when @option{-msse4.1} is used.
19058
19059 @table @code
19060 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
19061 Generates the @code{extractps} machine instruction.
19062 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
19063 Generates the @code{pextrd} machine instruction.
19064 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
19065 Generates the @code{pextrq} machine instruction in 64bit mode.
19066 @end table
19067
19068 The following built-in functions are available when @option{-msse4.2} is
19069 used. All of them generate the machine instruction that is part of the
19070 name.
19071
19072 @smallexample
19073 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
19074 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
19075 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
19076 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
19077 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
19078 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
19079 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
19080 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
19081 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
19082 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
19083 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
19084 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
19085 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
19086 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
19087 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
19088 @end smallexample
19089
19090 The following built-in functions are available when @option{-msse4.2} is
19091 used.
19092
19093 @table @code
19094 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
19095 Generates the @code{crc32b} machine instruction.
19096 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
19097 Generates the @code{crc32w} machine instruction.
19098 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
19099 Generates the @code{crc32l} machine instruction.
19100 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
19101 Generates the @code{crc32q} machine instruction.
19102 @end table
19103
19104 The following built-in functions are changed to generate new SSE4.2
19105 instructions when @option{-msse4.2} is used.
19106
19107 @table @code
19108 @item int __builtin_popcount (unsigned int)
19109 Generates the @code{popcntl} machine instruction.
19110 @item int __builtin_popcountl (unsigned long)
19111 Generates the @code{popcntl} or @code{popcntq} machine instruction,
19112 depending on the size of @code{unsigned long}.
19113 @item int __builtin_popcountll (unsigned long long)
19114 Generates the @code{popcntq} machine instruction.
19115 @end table
19116
19117 The following built-in functions are available when @option{-mavx} is
19118 used. All of them generate the machine instruction that is part of the
19119 name.
19120
19121 @smallexample
19122 v4df __builtin_ia32_addpd256 (v4df,v4df)
19123 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
19124 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
19125 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
19126 v4df __builtin_ia32_andnpd256 (v4df,v4df)
19127 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
19128 v4df __builtin_ia32_andpd256 (v4df,v4df)
19129 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
19130 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
19131 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
19132 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
19133 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
19134 v2df __builtin_ia32_cmppd (v2df,v2df,int)
19135 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
19136 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
19137 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
19138 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
19139 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
19140 v4df __builtin_ia32_cvtdq2pd256 (v4si)
19141 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
19142 v4si __builtin_ia32_cvtpd2dq256 (v4df)
19143 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
19144 v8si __builtin_ia32_cvtps2dq256 (v8sf)
19145 v4df __builtin_ia32_cvtps2pd256 (v4sf)
19146 v4si __builtin_ia32_cvttpd2dq256 (v4df)
19147 v8si __builtin_ia32_cvttps2dq256 (v8sf)
19148 v4df __builtin_ia32_divpd256 (v4df,v4df)
19149 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
19150 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
19151 v4df __builtin_ia32_haddpd256 (v4df,v4df)
19152 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
19153 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
19154 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
19155 v32qi __builtin_ia32_lddqu256 (pcchar)
19156 v32qi __builtin_ia32_loaddqu256 (pcchar)
19157 v4df __builtin_ia32_loadupd256 (pcdouble)
19158 v8sf __builtin_ia32_loadups256 (pcfloat)
19159 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
19160 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
19161 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
19162 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
19163 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
19164 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
19165 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
19166 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
19167 v4df __builtin_ia32_maxpd256 (v4df,v4df)
19168 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
19169 v4df __builtin_ia32_minpd256 (v4df,v4df)
19170 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
19171 v4df __builtin_ia32_movddup256 (v4df)
19172 int __builtin_ia32_movmskpd256 (v4df)
19173 int __builtin_ia32_movmskps256 (v8sf)
19174 v8sf __builtin_ia32_movshdup256 (v8sf)
19175 v8sf __builtin_ia32_movsldup256 (v8sf)
19176 v4df __builtin_ia32_mulpd256 (v4df,v4df)
19177 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
19178 v4df __builtin_ia32_orpd256 (v4df,v4df)
19179 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
19180 v2df __builtin_ia32_pd_pd256 (v4df)
19181 v4df __builtin_ia32_pd256_pd (v2df)
19182 v4sf __builtin_ia32_ps_ps256 (v8sf)
19183 v8sf __builtin_ia32_ps256_ps (v4sf)
19184 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
19185 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
19186 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
19187 v8sf __builtin_ia32_rcpps256 (v8sf)
19188 v4df __builtin_ia32_roundpd256 (v4df,int)
19189 v8sf __builtin_ia32_roundps256 (v8sf,int)
19190 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
19191 v8sf __builtin_ia32_rsqrtps256 (v8sf)
19192 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
19193 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
19194 v4si __builtin_ia32_si_si256 (v8si)
19195 v8si __builtin_ia32_si256_si (v4si)
19196 v4df __builtin_ia32_sqrtpd256 (v4df)
19197 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
19198 v8sf __builtin_ia32_sqrtps256 (v8sf)
19199 void __builtin_ia32_storedqu256 (pchar,v32qi)
19200 void __builtin_ia32_storeupd256 (pdouble,v4df)
19201 void __builtin_ia32_storeups256 (pfloat,v8sf)
19202 v4df __builtin_ia32_subpd256 (v4df,v4df)
19203 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
19204 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
19205 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
19206 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
19207 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
19208 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
19209 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
19210 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
19211 v4sf __builtin_ia32_vbroadcastss (pcfloat)
19212 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
19213 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
19214 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
19215 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
19216 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
19217 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
19218 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
19219 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
19220 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
19221 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
19222 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
19223 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
19224 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
19225 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
19226 v2df __builtin_ia32_vpermilpd (v2df,int)
19227 v4df __builtin_ia32_vpermilpd256 (v4df,int)
19228 v4sf __builtin_ia32_vpermilps (v4sf,int)
19229 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
19230 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
19231 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
19232 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
19233 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
19234 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
19235 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
19236 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
19237 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
19238 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
19239 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
19240 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
19241 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
19242 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
19243 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
19244 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
19245 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
19246 void __builtin_ia32_vzeroall (void)
19247 void __builtin_ia32_vzeroupper (void)
19248 v4df __builtin_ia32_xorpd256 (v4df,v4df)
19249 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
19250 @end smallexample
19251
19252 The following built-in functions are available when @option{-mavx2} is
19253 used. All of them generate the machine instruction that is part of the
19254 name.
19255
19256 @smallexample
19257 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
19258 v32qi __builtin_ia32_pabsb256 (v32qi)
19259 v16hi __builtin_ia32_pabsw256 (v16hi)
19260 v8si __builtin_ia32_pabsd256 (v8si)
19261 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
19262 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
19263 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
19264 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
19265 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
19266 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
19267 v8si __builtin_ia32_paddd256 (v8si,v8si)
19268 v4di __builtin_ia32_paddq256 (v4di,v4di)
19269 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
19270 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
19271 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
19272 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
19273 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
19274 v4di __builtin_ia32_andsi256 (v4di,v4di)
19275 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
19276 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
19277 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
19278 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
19279 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
19280 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
19281 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
19282 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
19283 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
19284 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
19285 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
19286 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
19287 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
19288 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
19289 v8si __builtin_ia32_phaddd256 (v8si,v8si)
19290 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
19291 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
19292 v8si __builtin_ia32_phsubd256 (v8si,v8si)
19293 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
19294 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
19295 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
19296 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
19297 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
19298 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
19299 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
19300 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
19301 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
19302 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
19303 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
19304 v8si __builtin_ia32_pminsd256 (v8si,v8si)
19305 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
19306 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
19307 v8si __builtin_ia32_pminud256 (v8si,v8si)
19308 int __builtin_ia32_pmovmskb256 (v32qi)
19309 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
19310 v8si __builtin_ia32_pmovsxbd256 (v16qi)
19311 v4di __builtin_ia32_pmovsxbq256 (v16qi)
19312 v8si __builtin_ia32_pmovsxwd256 (v8hi)
19313 v4di __builtin_ia32_pmovsxwq256 (v8hi)
19314 v4di __builtin_ia32_pmovsxdq256 (v4si)
19315 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
19316 v8si __builtin_ia32_pmovzxbd256 (v16qi)
19317 v4di __builtin_ia32_pmovzxbq256 (v16qi)
19318 v8si __builtin_ia32_pmovzxwd256 (v8hi)
19319 v4di __builtin_ia32_pmovzxwq256 (v8hi)
19320 v4di __builtin_ia32_pmovzxdq256 (v4si)
19321 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
19322 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
19323 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
19324 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
19325 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
19326 v8si __builtin_ia32_pmulld256 (v8si,v8si)
19327 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
19328 v4di __builtin_ia32_por256 (v4di,v4di)
19329 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
19330 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
19331 v8si __builtin_ia32_pshufd256 (v8si,int)
19332 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
19333 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
19334 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
19335 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
19336 v8si __builtin_ia32_psignd256 (v8si,v8si)
19337 v4di __builtin_ia32_pslldqi256 (v4di,int)
19338 v16hi __builtin_ia32_psllwi256 (16hi,int)
19339 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
19340 v8si __builtin_ia32_pslldi256 (v8si,int)
19341 v8si __builtin_ia32_pslld256(v8si,v4si)
19342 v4di __builtin_ia32_psllqi256 (v4di,int)
19343 v4di __builtin_ia32_psllq256(v4di,v2di)
19344 v16hi __builtin_ia32_psrawi256 (v16hi,int)
19345 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
19346 v8si __builtin_ia32_psradi256 (v8si,int)
19347 v8si __builtin_ia32_psrad256 (v8si,v4si)
19348 v4di __builtin_ia32_psrldqi256 (v4di, int)
19349 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
19350 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
19351 v8si __builtin_ia32_psrldi256 (v8si,int)
19352 v8si __builtin_ia32_psrld256 (v8si,v4si)
19353 v4di __builtin_ia32_psrlqi256 (v4di,int)
19354 v4di __builtin_ia32_psrlq256(v4di,v2di)
19355 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
19356 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
19357 v8si __builtin_ia32_psubd256 (v8si,v8si)
19358 v4di __builtin_ia32_psubq256 (v4di,v4di)
19359 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
19360 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
19361 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
19362 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
19363 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
19364 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
19365 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
19366 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
19367 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
19368 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
19369 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
19370 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
19371 v4di __builtin_ia32_pxor256 (v4di,v4di)
19372 v4di __builtin_ia32_movntdqa256 (pv4di)
19373 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
19374 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
19375 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
19376 v4di __builtin_ia32_vbroadcastsi256 (v2di)
19377 v4si __builtin_ia32_pblendd128 (v4si,v4si)
19378 v8si __builtin_ia32_pblendd256 (v8si,v8si)
19379 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
19380 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
19381 v8si __builtin_ia32_pbroadcastd256 (v4si)
19382 v4di __builtin_ia32_pbroadcastq256 (v2di)
19383 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
19384 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
19385 v4si __builtin_ia32_pbroadcastd128 (v4si)
19386 v2di __builtin_ia32_pbroadcastq128 (v2di)
19387 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
19388 v4df __builtin_ia32_permdf256 (v4df,int)
19389 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
19390 v4di __builtin_ia32_permdi256 (v4di,int)
19391 v4di __builtin_ia32_permti256 (v4di,v4di,int)
19392 v4di __builtin_ia32_extract128i256 (v4di,int)
19393 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
19394 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
19395 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
19396 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
19397 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
19398 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
19399 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
19400 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
19401 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
19402 v8si __builtin_ia32_psllv8si (v8si,v8si)
19403 v4si __builtin_ia32_psllv4si (v4si,v4si)
19404 v4di __builtin_ia32_psllv4di (v4di,v4di)
19405 v2di __builtin_ia32_psllv2di (v2di,v2di)
19406 v8si __builtin_ia32_psrav8si (v8si,v8si)
19407 v4si __builtin_ia32_psrav4si (v4si,v4si)
19408 v8si __builtin_ia32_psrlv8si (v8si,v8si)
19409 v4si __builtin_ia32_psrlv4si (v4si,v4si)
19410 v4di __builtin_ia32_psrlv4di (v4di,v4di)
19411 v2di __builtin_ia32_psrlv2di (v2di,v2di)
19412 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
19413 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
19414 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
19415 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
19416 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
19417 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
19418 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
19419 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
19420 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
19421 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
19422 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
19423 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
19424 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
19425 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
19426 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
19427 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
19428 @end smallexample
19429
19430 The following built-in functions are available when @option{-maes} is
19431 used. All of them generate the machine instruction that is part of the
19432 name.
19433
19434 @smallexample
19435 v2di __builtin_ia32_aesenc128 (v2di, v2di)
19436 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
19437 v2di __builtin_ia32_aesdec128 (v2di, v2di)
19438 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
19439 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
19440 v2di __builtin_ia32_aesimc128 (v2di)
19441 @end smallexample
19442
19443 The following built-in function is available when @option{-mpclmul} is
19444 used.
19445
19446 @table @code
19447 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
19448 Generates the @code{pclmulqdq} machine instruction.
19449 @end table
19450
19451 The following built-in function is available when @option{-mfsgsbase} is
19452 used. All of them generate the machine instruction that is part of the
19453 name.
19454
19455 @smallexample
19456 unsigned int __builtin_ia32_rdfsbase32 (void)
19457 unsigned long long __builtin_ia32_rdfsbase64 (void)
19458 unsigned int __builtin_ia32_rdgsbase32 (void)
19459 unsigned long long __builtin_ia32_rdgsbase64 (void)
19460 void _writefsbase_u32 (unsigned int)
19461 void _writefsbase_u64 (unsigned long long)
19462 void _writegsbase_u32 (unsigned int)
19463 void _writegsbase_u64 (unsigned long long)
19464 @end smallexample
19465
19466 The following built-in function is available when @option{-mrdrnd} is
19467 used. All of them generate the machine instruction that is part of the
19468 name.
19469
19470 @smallexample
19471 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
19472 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
19473 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
19474 @end smallexample
19475
19476 The following built-in functions are available when @option{-msse4a} is used.
19477 All of them generate the machine instruction that is part of the name.
19478
19479 @smallexample
19480 void __builtin_ia32_movntsd (double *, v2df)
19481 void __builtin_ia32_movntss (float *, v4sf)
19482 v2di __builtin_ia32_extrq (v2di, v16qi)
19483 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
19484 v2di __builtin_ia32_insertq (v2di, v2di)
19485 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
19486 @end smallexample
19487
19488 The following built-in functions are available when @option{-mxop} is used.
19489 @smallexample
19490 v2df __builtin_ia32_vfrczpd (v2df)
19491 v4sf __builtin_ia32_vfrczps (v4sf)
19492 v2df __builtin_ia32_vfrczsd (v2df)
19493 v4sf __builtin_ia32_vfrczss (v4sf)
19494 v4df __builtin_ia32_vfrczpd256 (v4df)
19495 v8sf __builtin_ia32_vfrczps256 (v8sf)
19496 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
19497 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
19498 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
19499 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
19500 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
19501 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
19502 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
19503 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
19504 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
19505 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
19506 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
19507 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
19508 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
19509 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
19510 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19511 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
19512 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
19513 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
19514 v4si __builtin_ia32_vpcomequd (v4si, v4si)
19515 v2di __builtin_ia32_vpcomequq (v2di, v2di)
19516 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
19517 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
19518 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
19519 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
19520 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
19521 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
19522 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
19523 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
19524 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
19525 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
19526 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
19527 v4si __builtin_ia32_vpcomged (v4si, v4si)
19528 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
19529 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
19530 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
19531 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
19532 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
19533 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
19534 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
19535 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
19536 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
19537 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
19538 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
19539 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
19540 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
19541 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
19542 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
19543 v4si __builtin_ia32_vpcomled (v4si, v4si)
19544 v2di __builtin_ia32_vpcomleq (v2di, v2di)
19545 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
19546 v4si __builtin_ia32_vpcomleud (v4si, v4si)
19547 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
19548 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
19549 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
19550 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
19551 v4si __builtin_ia32_vpcomltd (v4si, v4si)
19552 v2di __builtin_ia32_vpcomltq (v2di, v2di)
19553 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
19554 v4si __builtin_ia32_vpcomltud (v4si, v4si)
19555 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
19556 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
19557 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
19558 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
19559 v4si __builtin_ia32_vpcomned (v4si, v4si)
19560 v2di __builtin_ia32_vpcomneq (v2di, v2di)
19561 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
19562 v4si __builtin_ia32_vpcomneud (v4si, v4si)
19563 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
19564 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
19565 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
19566 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
19567 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
19568 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
19569 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
19570 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
19571 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
19572 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
19573 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
19574 v4si __builtin_ia32_vphaddbd (v16qi)
19575 v2di __builtin_ia32_vphaddbq (v16qi)
19576 v8hi __builtin_ia32_vphaddbw (v16qi)
19577 v2di __builtin_ia32_vphadddq (v4si)
19578 v4si __builtin_ia32_vphaddubd (v16qi)
19579 v2di __builtin_ia32_vphaddubq (v16qi)
19580 v8hi __builtin_ia32_vphaddubw (v16qi)
19581 v2di __builtin_ia32_vphaddudq (v4si)
19582 v4si __builtin_ia32_vphadduwd (v8hi)
19583 v2di __builtin_ia32_vphadduwq (v8hi)
19584 v4si __builtin_ia32_vphaddwd (v8hi)
19585 v2di __builtin_ia32_vphaddwq (v8hi)
19586 v8hi __builtin_ia32_vphsubbw (v16qi)
19587 v2di __builtin_ia32_vphsubdq (v4si)
19588 v4si __builtin_ia32_vphsubwd (v8hi)
19589 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
19590 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
19591 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
19592 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
19593 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
19594 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
19595 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
19596 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
19597 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
19598 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
19599 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
19600 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
19601 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
19602 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
19603 v4si __builtin_ia32_vprotd (v4si, v4si)
19604 v2di __builtin_ia32_vprotq (v2di, v2di)
19605 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
19606 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
19607 v4si __builtin_ia32_vpshad (v4si, v4si)
19608 v2di __builtin_ia32_vpshaq (v2di, v2di)
19609 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
19610 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
19611 v4si __builtin_ia32_vpshld (v4si, v4si)
19612 v2di __builtin_ia32_vpshlq (v2di, v2di)
19613 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
19614 @end smallexample
19615
19616 The following built-in functions are available when @option{-mfma4} is used.
19617 All of them generate the machine instruction that is part of the name.
19618
19619 @smallexample
19620 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
19621 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
19622 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
19623 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
19624 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
19625 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
19626 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
19627 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
19628 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
19629 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
19630 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
19631 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
19632 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
19633 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
19634 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
19635 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
19636 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
19637 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
19638 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
19639 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
19640 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
19641 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
19642 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
19643 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
19644 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
19645 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
19646 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
19647 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
19648 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
19649 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
19650 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
19651 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
19652
19653 @end smallexample
19654
19655 The following built-in functions are available when @option{-mlwp} is used.
19656
19657 @smallexample
19658 void __builtin_ia32_llwpcb16 (void *);
19659 void __builtin_ia32_llwpcb32 (void *);
19660 void __builtin_ia32_llwpcb64 (void *);
19661 void * __builtin_ia32_llwpcb16 (void);
19662 void * __builtin_ia32_llwpcb32 (void);
19663 void * __builtin_ia32_llwpcb64 (void);
19664 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
19665 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
19666 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
19667 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
19668 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
19669 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
19670 @end smallexample
19671
19672 The following built-in functions are available when @option{-mbmi} is used.
19673 All of them generate the machine instruction that is part of the name.
19674 @smallexample
19675 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
19676 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
19677 @end smallexample
19678
19679 The following built-in functions are available when @option{-mbmi2} is used.
19680 All of them generate the machine instruction that is part of the name.
19681 @smallexample
19682 unsigned int _bzhi_u32 (unsigned int, unsigned int)
19683 unsigned int _pdep_u32 (unsigned int, unsigned int)
19684 unsigned int _pext_u32 (unsigned int, unsigned int)
19685 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
19686 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
19687 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
19688 @end smallexample
19689
19690 The following built-in functions are available when @option{-mlzcnt} is used.
19691 All of them generate the machine instruction that is part of the name.
19692 @smallexample
19693 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
19694 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
19695 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
19696 @end smallexample
19697
19698 The following built-in functions are available when @option{-mfxsr} is used.
19699 All of them generate the machine instruction that is part of the name.
19700 @smallexample
19701 void __builtin_ia32_fxsave (void *)
19702 void __builtin_ia32_fxrstor (void *)
19703 void __builtin_ia32_fxsave64 (void *)
19704 void __builtin_ia32_fxrstor64 (void *)
19705 @end smallexample
19706
19707 The following built-in functions are available when @option{-mxsave} is used.
19708 All of them generate the machine instruction that is part of the name.
19709 @smallexample
19710 void __builtin_ia32_xsave (void *, long long)
19711 void __builtin_ia32_xrstor (void *, long long)
19712 void __builtin_ia32_xsave64 (void *, long long)
19713 void __builtin_ia32_xrstor64 (void *, long long)
19714 @end smallexample
19715
19716 The following built-in functions are available when @option{-mxsaveopt} is used.
19717 All of them generate the machine instruction that is part of the name.
19718 @smallexample
19719 void __builtin_ia32_xsaveopt (void *, long long)
19720 void __builtin_ia32_xsaveopt64 (void *, long long)
19721 @end smallexample
19722
19723 The following built-in functions are available when @option{-mtbm} is used.
19724 Both of them generate the immediate form of the bextr machine instruction.
19725 @smallexample
19726 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
19727 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
19728 @end smallexample
19729
19730
19731 The following built-in functions are available when @option{-m3dnow} is used.
19732 All of them generate the machine instruction that is part of the name.
19733
19734 @smallexample
19735 void __builtin_ia32_femms (void)
19736 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
19737 v2si __builtin_ia32_pf2id (v2sf)
19738 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
19739 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
19740 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
19741 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
19742 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
19743 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
19744 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
19745 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
19746 v2sf __builtin_ia32_pfrcp (v2sf)
19747 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
19748 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
19749 v2sf __builtin_ia32_pfrsqrt (v2sf)
19750 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
19751 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
19752 v2sf __builtin_ia32_pi2fd (v2si)
19753 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
19754 @end smallexample
19755
19756 The following built-in functions are available when both @option{-m3dnow}
19757 and @option{-march=athlon} are used. All of them generate the machine
19758 instruction that is part of the name.
19759
19760 @smallexample
19761 v2si __builtin_ia32_pf2iw (v2sf)
19762 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
19763 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
19764 v2sf __builtin_ia32_pi2fw (v2si)
19765 v2sf __builtin_ia32_pswapdsf (v2sf)
19766 v2si __builtin_ia32_pswapdsi (v2si)
19767 @end smallexample
19768
19769 The following built-in functions are available when @option{-mrtm} is used
19770 They are used for restricted transactional memory. These are the internal
19771 low level functions. Normally the functions in
19772 @ref{x86 transactional memory intrinsics} should be used instead.
19773
19774 @smallexample
19775 int __builtin_ia32_xbegin ()
19776 void __builtin_ia32_xend ()
19777 void __builtin_ia32_xabort (status)
19778 int __builtin_ia32_xtest ()
19779 @end smallexample
19780
19781 The following built-in functions are available when @option{-mmwaitx} is used.
19782 All of them generate the machine instruction that is part of the name.
19783 @smallexample
19784 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
19785 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
19786 @end smallexample
19787
19788 The following built-in functions are available when @option{-mclzero} is used.
19789 All of them generate the machine instruction that is part of the name.
19790 @smallexample
19791 void __builtin_i32_clzero (void *)
19792 @end smallexample
19793
19794 The following built-in functions are available when @option{-mpku} is used.
19795 They generate reads and writes to PKRU.
19796 @smallexample
19797 void __builtin_ia32_wrpkru (unsigned int)
19798 unsigned int __builtin_ia32_rdpkru ()
19799 @end smallexample
19800
19801 @node x86 transactional memory intrinsics
19802 @subsection x86 Transactional Memory Intrinsics
19803
19804 These hardware transactional memory intrinsics for x86 allow you to use
19805 memory transactions with RTM (Restricted Transactional Memory).
19806 This support is enabled with the @option{-mrtm} option.
19807 For using HLE (Hardware Lock Elision) see
19808 @ref{x86 specific memory model extensions for transactional memory} instead.
19809
19810 A memory transaction commits all changes to memory in an atomic way,
19811 as visible to other threads. If the transaction fails it is rolled back
19812 and all side effects discarded.
19813
19814 Generally there is no guarantee that a memory transaction ever succeeds
19815 and suitable fallback code always needs to be supplied.
19816
19817 @deftypefn {RTM Function} {unsigned} _xbegin ()
19818 Start a RTM (Restricted Transactional Memory) transaction.
19819 Returns @code{_XBEGIN_STARTED} when the transaction
19820 started successfully (note this is not 0, so the constant has to be
19821 explicitly tested).
19822
19823 If the transaction aborts, all side-effects
19824 are undone and an abort code encoded as a bit mask is returned.
19825 The following macros are defined:
19826
19827 @table @code
19828 @item _XABORT_EXPLICIT
19829 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
19830 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
19831 @item _XABORT_RETRY
19832 Transaction retry is possible.
19833 @item _XABORT_CONFLICT
19834 Transaction abort due to a memory conflict with another thread.
19835 @item _XABORT_CAPACITY
19836 Transaction abort due to the transaction using too much memory.
19837 @item _XABORT_DEBUG
19838 Transaction abort due to a debug trap.
19839 @item _XABORT_NESTED
19840 Transaction abort in an inner nested transaction.
19841 @end table
19842
19843 There is no guarantee
19844 any transaction ever succeeds, so there always needs to be a valid
19845 fallback path.
19846 @end deftypefn
19847
19848 @deftypefn {RTM Function} {void} _xend ()
19849 Commit the current transaction. When no transaction is active this faults.
19850 All memory side-effects of the transaction become visible
19851 to other threads in an atomic manner.
19852 @end deftypefn
19853
19854 @deftypefn {RTM Function} {int} _xtest ()
19855 Return a nonzero value if a transaction is currently active, otherwise 0.
19856 @end deftypefn
19857
19858 @deftypefn {RTM Function} {void} _xabort (status)
19859 Abort the current transaction. When no transaction is active this is a no-op.
19860 The @var{status} is an 8-bit constant; its value is encoded in the return
19861 value from @code{_xbegin}.
19862 @end deftypefn
19863
19864 Here is an example showing handling for @code{_XABORT_RETRY}
19865 and a fallback path for other failures:
19866
19867 @smallexample
19868 #include <immintrin.h>
19869
19870 int n_tries, max_tries;
19871 unsigned status = _XABORT_EXPLICIT;
19872 ...
19873
19874 for (n_tries = 0; n_tries < max_tries; n_tries++)
19875 @{
19876 status = _xbegin ();
19877 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
19878 break;
19879 @}
19880 if (status == _XBEGIN_STARTED)
19881 @{
19882 ... transaction code...
19883 _xend ();
19884 @}
19885 else
19886 @{
19887 ... non-transactional fallback path...
19888 @}
19889 @end smallexample
19890
19891 @noindent
19892 Note that, in most cases, the transactional and non-transactional code
19893 must synchronize together to ensure consistency.
19894
19895 @node Target Format Checks
19896 @section Format Checks Specific to Particular Target Machines
19897
19898 For some target machines, GCC supports additional options to the
19899 format attribute
19900 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
19901
19902 @menu
19903 * Solaris Format Checks::
19904 * Darwin Format Checks::
19905 @end menu
19906
19907 @node Solaris Format Checks
19908 @subsection Solaris Format Checks
19909
19910 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
19911 check. @code{cmn_err} accepts a subset of the standard @code{printf}
19912 conversions, and the two-argument @code{%b} conversion for displaying
19913 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
19914
19915 @node Darwin Format Checks
19916 @subsection Darwin Format Checks
19917
19918 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
19919 attribute context. Declarations made with such attribution are parsed for correct syntax
19920 and format argument types. However, parsing of the format string itself is currently undefined
19921 and is not carried out by this version of the compiler.
19922
19923 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
19924 also be used as format arguments. Note that the relevant headers are only likely to be
19925 available on Darwin (OSX) installations. On such installations, the XCode and system
19926 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
19927 associated functions.
19928
19929 @node Pragmas
19930 @section Pragmas Accepted by GCC
19931 @cindex pragmas
19932 @cindex @code{#pragma}
19933
19934 GCC supports several types of pragmas, primarily in order to compile
19935 code originally written for other compilers. Note that in general
19936 we do not recommend the use of pragmas; @xref{Function Attributes},
19937 for further explanation.
19938
19939 @menu
19940 * AArch64 Pragmas::
19941 * ARM Pragmas::
19942 * M32C Pragmas::
19943 * MeP Pragmas::
19944 * RS/6000 and PowerPC Pragmas::
19945 * S/390 Pragmas::
19946 * Darwin Pragmas::
19947 * Solaris Pragmas::
19948 * Symbol-Renaming Pragmas::
19949 * Structure-Layout Pragmas::
19950 * Weak Pragmas::
19951 * Diagnostic Pragmas::
19952 * Visibility Pragmas::
19953 * Push/Pop Macro Pragmas::
19954 * Function Specific Option Pragmas::
19955 * Loop-Specific Pragmas::
19956 @end menu
19957
19958 @node AArch64 Pragmas
19959 @subsection AArch64 Pragmas
19960
19961 The pragmas defined by the AArch64 target correspond to the AArch64
19962 target function attributes. They can be specified as below:
19963 @smallexample
19964 #pragma GCC target("string")
19965 @end smallexample
19966
19967 where @code{@var{string}} can be any string accepted as an AArch64 target
19968 attribute. @xref{AArch64 Function Attributes}, for more details
19969 on the permissible values of @code{string}.
19970
19971 @node ARM Pragmas
19972 @subsection ARM Pragmas
19973
19974 The ARM target defines pragmas for controlling the default addition of
19975 @code{long_call} and @code{short_call} attributes to functions.
19976 @xref{Function Attributes}, for information about the effects of these
19977 attributes.
19978
19979 @table @code
19980 @item long_calls
19981 @cindex pragma, long_calls
19982 Set all subsequent functions to have the @code{long_call} attribute.
19983
19984 @item no_long_calls
19985 @cindex pragma, no_long_calls
19986 Set all subsequent functions to have the @code{short_call} attribute.
19987
19988 @item long_calls_off
19989 @cindex pragma, long_calls_off
19990 Do not affect the @code{long_call} or @code{short_call} attributes of
19991 subsequent functions.
19992 @end table
19993
19994 @node M32C Pragmas
19995 @subsection M32C Pragmas
19996
19997 @table @code
19998 @item GCC memregs @var{number}
19999 @cindex pragma, memregs
20000 Overrides the command-line option @code{-memregs=} for the current
20001 file. Use with care! This pragma must be before any function in the
20002 file, and mixing different memregs values in different objects may
20003 make them incompatible. This pragma is useful when a
20004 performance-critical function uses a memreg for temporary values,
20005 as it may allow you to reduce the number of memregs used.
20006
20007 @item ADDRESS @var{name} @var{address}
20008 @cindex pragma, address
20009 For any declared symbols matching @var{name}, this does three things
20010 to that symbol: it forces the symbol to be located at the given
20011 address (a number), it forces the symbol to be volatile, and it
20012 changes the symbol's scope to be static. This pragma exists for
20013 compatibility with other compilers, but note that the common
20014 @code{1234H} numeric syntax is not supported (use @code{0x1234}
20015 instead). Example:
20016
20017 @smallexample
20018 #pragma ADDRESS port3 0x103
20019 char port3;
20020 @end smallexample
20021
20022 @end table
20023
20024 @node MeP Pragmas
20025 @subsection MeP Pragmas
20026
20027 @table @code
20028
20029 @item custom io_volatile (on|off)
20030 @cindex pragma, custom io_volatile
20031 Overrides the command-line option @code{-mio-volatile} for the current
20032 file. Note that for compatibility with future GCC releases, this
20033 option should only be used once before any @code{io} variables in each
20034 file.
20035
20036 @item GCC coprocessor available @var{registers}
20037 @cindex pragma, coprocessor available
20038 Specifies which coprocessor registers are available to the register
20039 allocator. @var{registers} may be a single register, register range
20040 separated by ellipses, or comma-separated list of those. Example:
20041
20042 @smallexample
20043 #pragma GCC coprocessor available $c0...$c10, $c28
20044 @end smallexample
20045
20046 @item GCC coprocessor call_saved @var{registers}
20047 @cindex pragma, coprocessor call_saved
20048 Specifies which coprocessor registers are to be saved and restored by
20049 any function using them. @var{registers} may be a single register,
20050 register range separated by ellipses, or comma-separated list of
20051 those. Example:
20052
20053 @smallexample
20054 #pragma GCC coprocessor call_saved $c4...$c6, $c31
20055 @end smallexample
20056
20057 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
20058 @cindex pragma, coprocessor subclass
20059 Creates and defines a register class. These register classes can be
20060 used by inline @code{asm} constructs. @var{registers} may be a single
20061 register, register range separated by ellipses, or comma-separated
20062 list of those. Example:
20063
20064 @smallexample
20065 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
20066
20067 asm ("cpfoo %0" : "=B" (x));
20068 @end smallexample
20069
20070 @item GCC disinterrupt @var{name} , @var{name} @dots{}
20071 @cindex pragma, disinterrupt
20072 For the named functions, the compiler adds code to disable interrupts
20073 for the duration of those functions. If any functions so named
20074 are not encountered in the source, a warning is emitted that the pragma is
20075 not used. Examples:
20076
20077 @smallexample
20078 #pragma disinterrupt foo
20079 #pragma disinterrupt bar, grill
20080 int foo () @{ @dots{} @}
20081 @end smallexample
20082
20083 @item GCC call @var{name} , @var{name} @dots{}
20084 @cindex pragma, call
20085 For the named functions, the compiler always uses a register-indirect
20086 call model when calling the named functions. Examples:
20087
20088 @smallexample
20089 extern int foo ();
20090 #pragma call foo
20091 @end smallexample
20092
20093 @end table
20094
20095 @node RS/6000 and PowerPC Pragmas
20096 @subsection RS/6000 and PowerPC Pragmas
20097
20098 The RS/6000 and PowerPC targets define one pragma for controlling
20099 whether or not the @code{longcall} attribute is added to function
20100 declarations by default. This pragma overrides the @option{-mlongcall}
20101 option, but not the @code{longcall} and @code{shortcall} attributes.
20102 @xref{RS/6000 and PowerPC Options}, for more information about when long
20103 calls are and are not necessary.
20104
20105 @table @code
20106 @item longcall (1)
20107 @cindex pragma, longcall
20108 Apply the @code{longcall} attribute to all subsequent function
20109 declarations.
20110
20111 @item longcall (0)
20112 Do not apply the @code{longcall} attribute to subsequent function
20113 declarations.
20114 @end table
20115
20116 @c Describe h8300 pragmas here.
20117 @c Describe sh pragmas here.
20118 @c Describe v850 pragmas here.
20119
20120 @node S/390 Pragmas
20121 @subsection S/390 Pragmas
20122
20123 The pragmas defined by the S/390 target correspond to the S/390
20124 target function attributes and some the additional options:
20125
20126 @table @samp
20127 @item zvector
20128 @itemx no-zvector
20129 @end table
20130
20131 Note that options of the pragma, unlike options of the target
20132 attribute, do change the value of preprocessor macros like
20133 @code{__VEC__}. They can be specified as below:
20134
20135 @smallexample
20136 #pragma GCC target("string[,string]...")
20137 #pragma GCC target("string"[,"string"]...)
20138 @end smallexample
20139
20140 @node Darwin Pragmas
20141 @subsection Darwin Pragmas
20142
20143 The following pragmas are available for all architectures running the
20144 Darwin operating system. These are useful for compatibility with other
20145 Mac OS compilers.
20146
20147 @table @code
20148 @item mark @var{tokens}@dots{}
20149 @cindex pragma, mark
20150 This pragma is accepted, but has no effect.
20151
20152 @item options align=@var{alignment}
20153 @cindex pragma, options align
20154 This pragma sets the alignment of fields in structures. The values of
20155 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
20156 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
20157 properly; to restore the previous setting, use @code{reset} for the
20158 @var{alignment}.
20159
20160 @item segment @var{tokens}@dots{}
20161 @cindex pragma, segment
20162 This pragma is accepted, but has no effect.
20163
20164 @item unused (@var{var} [, @var{var}]@dots{})
20165 @cindex pragma, unused
20166 This pragma declares variables to be possibly unused. GCC does not
20167 produce warnings for the listed variables. The effect is similar to
20168 that of the @code{unused} attribute, except that this pragma may appear
20169 anywhere within the variables' scopes.
20170 @end table
20171
20172 @node Solaris Pragmas
20173 @subsection Solaris Pragmas
20174
20175 The Solaris target supports @code{#pragma redefine_extname}
20176 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
20177 @code{#pragma} directives for compatibility with the system compiler.
20178
20179 @table @code
20180 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
20181 @cindex pragma, align
20182
20183 Increase the minimum alignment of each @var{variable} to @var{alignment}.
20184 This is the same as GCC's @code{aligned} attribute @pxref{Variable
20185 Attributes}). Macro expansion occurs on the arguments to this pragma
20186 when compiling C and Objective-C@. It does not currently occur when
20187 compiling C++, but this is a bug which may be fixed in a future
20188 release.
20189
20190 @item fini (@var{function} [, @var{function}]...)
20191 @cindex pragma, fini
20192
20193 This pragma causes each listed @var{function} to be called after
20194 main, or during shared module unloading, by adding a call to the
20195 @code{.fini} section.
20196
20197 @item init (@var{function} [, @var{function}]...)
20198 @cindex pragma, init
20199
20200 This pragma causes each listed @var{function} to be called during
20201 initialization (before @code{main}) or during shared module loading, by
20202 adding a call to the @code{.init} section.
20203
20204 @end table
20205
20206 @node Symbol-Renaming Pragmas
20207 @subsection Symbol-Renaming Pragmas
20208
20209 GCC supports a @code{#pragma} directive that changes the name used in
20210 assembly for a given declaration. While this pragma is supported on all
20211 platforms, it is intended primarily to provide compatibility with the
20212 Solaris system headers. This effect can also be achieved using the asm
20213 labels extension (@pxref{Asm Labels}).
20214
20215 @table @code
20216 @item redefine_extname @var{oldname} @var{newname}
20217 @cindex pragma, redefine_extname
20218
20219 This pragma gives the C function @var{oldname} the assembly symbol
20220 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
20221 is defined if this pragma is available (currently on all platforms).
20222 @end table
20223
20224 This pragma and the asm labels extension interact in a complicated
20225 manner. Here are some corner cases you may want to be aware of:
20226
20227 @enumerate
20228 @item This pragma silently applies only to declarations with external
20229 linkage. Asm labels do not have this restriction.
20230
20231 @item In C++, this pragma silently applies only to declarations with
20232 ``C'' linkage. Again, asm labels do not have this restriction.
20233
20234 @item If either of the ways of changing the assembly name of a
20235 declaration are applied to a declaration whose assembly name has
20236 already been determined (either by a previous use of one of these
20237 features, or because the compiler needed the assembly name in order to
20238 generate code), and the new name is different, a warning issues and
20239 the name does not change.
20240
20241 @item The @var{oldname} used by @code{#pragma redefine_extname} is
20242 always the C-language name.
20243 @end enumerate
20244
20245 @node Structure-Layout Pragmas
20246 @subsection Structure-Layout Pragmas
20247
20248 For compatibility with Microsoft Windows compilers, GCC supports a
20249 set of @code{#pragma} directives that change the maximum alignment of
20250 members of structures (other than zero-width bit-fields), unions, and
20251 classes subsequently defined. The @var{n} value below always is required
20252 to be a small power of two and specifies the new alignment in bytes.
20253
20254 @enumerate
20255 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
20256 @item @code{#pragma pack()} sets the alignment to the one that was in
20257 effect when compilation started (see also command-line option
20258 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
20259 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
20260 setting on an internal stack and then optionally sets the new alignment.
20261 @item @code{#pragma pack(pop)} restores the alignment setting to the one
20262 saved at the top of the internal stack (and removes that stack entry).
20263 Note that @code{#pragma pack([@var{n}])} does not influence this internal
20264 stack; thus it is possible to have @code{#pragma pack(push)} followed by
20265 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
20266 @code{#pragma pack(pop)}.
20267 @end enumerate
20268
20269 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
20270 directive which lays out structures and unions subsequently defined as the
20271 documented @code{__attribute__ ((ms_struct))}.
20272
20273 @enumerate
20274 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
20275 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
20276 @item @code{#pragma ms_struct reset} goes back to the default layout.
20277 @end enumerate
20278
20279 Most targets also support the @code{#pragma scalar_storage_order} directive
20280 which lays out structures and unions subsequently defined as the documented
20281 @code{__attribute__ ((scalar_storage_order))}.
20282
20283 @enumerate
20284 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
20285 of the scalar fields to big-endian.
20286 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
20287 of the scalar fields to little-endian.
20288 @item @code{#pragma scalar_storage_order default} goes back to the endianness
20289 that was in effect when compilation started (see also command-line option
20290 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
20291 @end enumerate
20292
20293 @node Weak Pragmas
20294 @subsection Weak Pragmas
20295
20296 For compatibility with SVR4, GCC supports a set of @code{#pragma}
20297 directives for declaring symbols to be weak, and defining weak
20298 aliases.
20299
20300 @table @code
20301 @item #pragma weak @var{symbol}
20302 @cindex pragma, weak
20303 This pragma declares @var{symbol} to be weak, as if the declaration
20304 had the attribute of the same name. The pragma may appear before
20305 or after the declaration of @var{symbol}. It is not an error for
20306 @var{symbol} to never be defined at all.
20307
20308 @item #pragma weak @var{symbol1} = @var{symbol2}
20309 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
20310 It is an error if @var{symbol2} is not defined in the current
20311 translation unit.
20312 @end table
20313
20314 @node Diagnostic Pragmas
20315 @subsection Diagnostic Pragmas
20316
20317 GCC allows the user to selectively enable or disable certain types of
20318 diagnostics, and change the kind of the diagnostic. For example, a
20319 project's policy might require that all sources compile with
20320 @option{-Werror} but certain files might have exceptions allowing
20321 specific types of warnings. Or, a project might selectively enable
20322 diagnostics and treat them as errors depending on which preprocessor
20323 macros are defined.
20324
20325 @table @code
20326 @item #pragma GCC diagnostic @var{kind} @var{option}
20327 @cindex pragma, diagnostic
20328
20329 Modifies the disposition of a diagnostic. Note that not all
20330 diagnostics are modifiable; at the moment only warnings (normally
20331 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
20332 Use @option{-fdiagnostics-show-option} to determine which diagnostics
20333 are controllable and which option controls them.
20334
20335 @var{kind} is @samp{error} to treat this diagnostic as an error,
20336 @samp{warning} to treat it like a warning (even if @option{-Werror} is
20337 in effect), or @samp{ignored} if the diagnostic is to be ignored.
20338 @var{option} is a double quoted string that matches the command-line
20339 option.
20340
20341 @smallexample
20342 #pragma GCC diagnostic warning "-Wformat"
20343 #pragma GCC diagnostic error "-Wformat"
20344 #pragma GCC diagnostic ignored "-Wformat"
20345 @end smallexample
20346
20347 Note that these pragmas override any command-line options. GCC keeps
20348 track of the location of each pragma, and issues diagnostics according
20349 to the state as of that point in the source file. Thus, pragmas occurring
20350 after a line do not affect diagnostics caused by that line.
20351
20352 @item #pragma GCC diagnostic push
20353 @itemx #pragma GCC diagnostic pop
20354
20355 Causes GCC to remember the state of the diagnostics as of each
20356 @code{push}, and restore to that point at each @code{pop}. If a
20357 @code{pop} has no matching @code{push}, the command-line options are
20358 restored.
20359
20360 @smallexample
20361 #pragma GCC diagnostic error "-Wuninitialized"
20362 foo(a); /* error is given for this one */
20363 #pragma GCC diagnostic push
20364 #pragma GCC diagnostic ignored "-Wuninitialized"
20365 foo(b); /* no diagnostic for this one */
20366 #pragma GCC diagnostic pop
20367 foo(c); /* error is given for this one */
20368 #pragma GCC diagnostic pop
20369 foo(d); /* depends on command-line options */
20370 @end smallexample
20371
20372 @end table
20373
20374 GCC also offers a simple mechanism for printing messages during
20375 compilation.
20376
20377 @table @code
20378 @item #pragma message @var{string}
20379 @cindex pragma, diagnostic
20380
20381 Prints @var{string} as a compiler message on compilation. The message
20382 is informational only, and is neither a compilation warning nor an error.
20383
20384 @smallexample
20385 #pragma message "Compiling " __FILE__ "..."
20386 @end smallexample
20387
20388 @var{string} may be parenthesized, and is printed with location
20389 information. For example,
20390
20391 @smallexample
20392 #define DO_PRAGMA(x) _Pragma (#x)
20393 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
20394
20395 TODO(Remember to fix this)
20396 @end smallexample
20397
20398 @noindent
20399 prints @samp{/tmp/file.c:4: note: #pragma message:
20400 TODO - Remember to fix this}.
20401
20402 @end table
20403
20404 @node Visibility Pragmas
20405 @subsection Visibility Pragmas
20406
20407 @table @code
20408 @item #pragma GCC visibility push(@var{visibility})
20409 @itemx #pragma GCC visibility pop
20410 @cindex pragma, visibility
20411
20412 This pragma allows the user to set the visibility for multiple
20413 declarations without having to give each a visibility attribute
20414 (@pxref{Function Attributes}).
20415
20416 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
20417 declarations. Class members and template specializations are not
20418 affected; if you want to override the visibility for a particular
20419 member or instantiation, you must use an attribute.
20420
20421 @end table
20422
20423
20424 @node Push/Pop Macro Pragmas
20425 @subsection Push/Pop Macro Pragmas
20426
20427 For compatibility with Microsoft Windows compilers, GCC supports
20428 @samp{#pragma push_macro(@var{"macro_name"})}
20429 and @samp{#pragma pop_macro(@var{"macro_name"})}.
20430
20431 @table @code
20432 @item #pragma push_macro(@var{"macro_name"})
20433 @cindex pragma, push_macro
20434 This pragma saves the value of the macro named as @var{macro_name} to
20435 the top of the stack for this macro.
20436
20437 @item #pragma pop_macro(@var{"macro_name"})
20438 @cindex pragma, pop_macro
20439 This pragma sets the value of the macro named as @var{macro_name} to
20440 the value on top of the stack for this macro. If the stack for
20441 @var{macro_name} is empty, the value of the macro remains unchanged.
20442 @end table
20443
20444 For example:
20445
20446 @smallexample
20447 #define X 1
20448 #pragma push_macro("X")
20449 #undef X
20450 #define X -1
20451 #pragma pop_macro("X")
20452 int x [X];
20453 @end smallexample
20454
20455 @noindent
20456 In this example, the definition of X as 1 is saved by @code{#pragma
20457 push_macro} and restored by @code{#pragma pop_macro}.
20458
20459 @node Function Specific Option Pragmas
20460 @subsection Function Specific Option Pragmas
20461
20462 @table @code
20463 @item #pragma GCC target (@var{"string"}...)
20464 @cindex pragma GCC target
20465
20466 This pragma allows you to set target specific options for functions
20467 defined later in the source file. One or more strings can be
20468 specified. Each function that is defined after this point is as
20469 if @code{attribute((target("STRING")))} was specified for that
20470 function. The parenthesis around the options is optional.
20471 @xref{Function Attributes}, for more information about the
20472 @code{target} attribute and the attribute syntax.
20473
20474 The @code{#pragma GCC target} pragma is presently implemented for
20475 x86, PowerPC, and Nios II targets only.
20476 @end table
20477
20478 @table @code
20479 @item #pragma GCC optimize (@var{"string"}...)
20480 @cindex pragma GCC optimize
20481
20482 This pragma allows you to set global optimization options for functions
20483 defined later in the source file. One or more strings can be
20484 specified. Each function that is defined after this point is as
20485 if @code{attribute((optimize("STRING")))} was specified for that
20486 function. The parenthesis around the options is optional.
20487 @xref{Function Attributes}, for more information about the
20488 @code{optimize} attribute and the attribute syntax.
20489 @end table
20490
20491 @table @code
20492 @item #pragma GCC push_options
20493 @itemx #pragma GCC pop_options
20494 @cindex pragma GCC push_options
20495 @cindex pragma GCC pop_options
20496
20497 These pragmas maintain a stack of the current target and optimization
20498 options. It is intended for include files where you temporarily want
20499 to switch to using a different @samp{#pragma GCC target} or
20500 @samp{#pragma GCC optimize} and then to pop back to the previous
20501 options.
20502 @end table
20503
20504 @table @code
20505 @item #pragma GCC reset_options
20506 @cindex pragma GCC reset_options
20507
20508 This pragma clears the current @code{#pragma GCC target} and
20509 @code{#pragma GCC optimize} to use the default switches as specified
20510 on the command line.
20511 @end table
20512
20513 @node Loop-Specific Pragmas
20514 @subsection Loop-Specific Pragmas
20515
20516 @table @code
20517 @item #pragma GCC ivdep
20518 @cindex pragma GCC ivdep
20519 @end table
20520
20521 With this pragma, the programmer asserts that there are no loop-carried
20522 dependencies which would prevent consecutive iterations of
20523 the following loop from executing concurrently with SIMD
20524 (single instruction multiple data) instructions.
20525
20526 For example, the compiler can only unconditionally vectorize the following
20527 loop with the pragma:
20528
20529 @smallexample
20530 void foo (int n, int *a, int *b, int *c)
20531 @{
20532 int i, j;
20533 #pragma GCC ivdep
20534 for (i = 0; i < n; ++i)
20535 a[i] = b[i] + c[i];
20536 @}
20537 @end smallexample
20538
20539 @noindent
20540 In this example, using the @code{restrict} qualifier had the same
20541 effect. In the following example, that would not be possible. Assume
20542 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
20543 that it can unconditionally vectorize the following loop:
20544
20545 @smallexample
20546 void ignore_vec_dep (int *a, int k, int c, int m)
20547 @{
20548 #pragma GCC ivdep
20549 for (int i = 0; i < m; i++)
20550 a[i] = a[i + k] * c;
20551 @}
20552 @end smallexample
20553
20554
20555 @node Unnamed Fields
20556 @section Unnamed Structure and Union Fields
20557 @cindex @code{struct}
20558 @cindex @code{union}
20559
20560 As permitted by ISO C11 and for compatibility with other compilers,
20561 GCC allows you to define
20562 a structure or union that contains, as fields, structures and unions
20563 without names. For example:
20564
20565 @smallexample
20566 struct @{
20567 int a;
20568 union @{
20569 int b;
20570 float c;
20571 @};
20572 int d;
20573 @} foo;
20574 @end smallexample
20575
20576 @noindent
20577 In this example, you are able to access members of the unnamed
20578 union with code like @samp{foo.b}. Note that only unnamed structs and
20579 unions are allowed, you may not have, for example, an unnamed
20580 @code{int}.
20581
20582 You must never create such structures that cause ambiguous field definitions.
20583 For example, in this structure:
20584
20585 @smallexample
20586 struct @{
20587 int a;
20588 struct @{
20589 int a;
20590 @};
20591 @} foo;
20592 @end smallexample
20593
20594 @noindent
20595 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
20596 The compiler gives errors for such constructs.
20597
20598 @opindex fms-extensions
20599 Unless @option{-fms-extensions} is used, the unnamed field must be a
20600 structure or union definition without a tag (for example, @samp{struct
20601 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
20602 also be a definition with a tag such as @samp{struct foo @{ int a;
20603 @};}, a reference to a previously defined structure or union such as
20604 @samp{struct foo;}, or a reference to a @code{typedef} name for a
20605 previously defined structure or union type.
20606
20607 @opindex fplan9-extensions
20608 The option @option{-fplan9-extensions} enables
20609 @option{-fms-extensions} as well as two other extensions. First, a
20610 pointer to a structure is automatically converted to a pointer to an
20611 anonymous field for assignments and function calls. For example:
20612
20613 @smallexample
20614 struct s1 @{ int a; @};
20615 struct s2 @{ struct s1; @};
20616 extern void f1 (struct s1 *);
20617 void f2 (struct s2 *p) @{ f1 (p); @}
20618 @end smallexample
20619
20620 @noindent
20621 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
20622 converted into a pointer to the anonymous field.
20623
20624 Second, when the type of an anonymous field is a @code{typedef} for a
20625 @code{struct} or @code{union}, code may refer to the field using the
20626 name of the @code{typedef}.
20627
20628 @smallexample
20629 typedef struct @{ int a; @} s1;
20630 struct s2 @{ s1; @};
20631 s1 f1 (struct s2 *p) @{ return p->s1; @}
20632 @end smallexample
20633
20634 These usages are only permitted when they are not ambiguous.
20635
20636 @node Thread-Local
20637 @section Thread-Local Storage
20638 @cindex Thread-Local Storage
20639 @cindex @acronym{TLS}
20640 @cindex @code{__thread}
20641
20642 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
20643 are allocated such that there is one instance of the variable per extant
20644 thread. The runtime model GCC uses to implement this originates
20645 in the IA-64 processor-specific ABI, but has since been migrated
20646 to other processors as well. It requires significant support from
20647 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
20648 system libraries (@file{libc.so} and @file{libpthread.so}), so it
20649 is not available everywhere.
20650
20651 At the user level, the extension is visible with a new storage
20652 class keyword: @code{__thread}. For example:
20653
20654 @smallexample
20655 __thread int i;
20656 extern __thread struct state s;
20657 static __thread char *p;
20658 @end smallexample
20659
20660 The @code{__thread} specifier may be used alone, with the @code{extern}
20661 or @code{static} specifiers, but with no other storage class specifier.
20662 When used with @code{extern} or @code{static}, @code{__thread} must appear
20663 immediately after the other storage class specifier.
20664
20665 The @code{__thread} specifier may be applied to any global, file-scoped
20666 static, function-scoped static, or static data member of a class. It may
20667 not be applied to block-scoped automatic or non-static data member.
20668
20669 When the address-of operator is applied to a thread-local variable, it is
20670 evaluated at run time and returns the address of the current thread's
20671 instance of that variable. An address so obtained may be used by any
20672 thread. When a thread terminates, any pointers to thread-local variables
20673 in that thread become invalid.
20674
20675 No static initialization may refer to the address of a thread-local variable.
20676
20677 In C++, if an initializer is present for a thread-local variable, it must
20678 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
20679 standard.
20680
20681 See @uref{http://www.akkadia.org/drepper/tls.pdf,
20682 ELF Handling For Thread-Local Storage} for a detailed explanation of
20683 the four thread-local storage addressing models, and how the runtime
20684 is expected to function.
20685
20686 @menu
20687 * C99 Thread-Local Edits::
20688 * C++98 Thread-Local Edits::
20689 @end menu
20690
20691 @node C99 Thread-Local Edits
20692 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
20693
20694 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
20695 that document the exact semantics of the language extension.
20696
20697 @itemize @bullet
20698 @item
20699 @cite{5.1.2 Execution environments}
20700
20701 Add new text after paragraph 1
20702
20703 @quotation
20704 Within either execution environment, a @dfn{thread} is a flow of
20705 control within a program. It is implementation defined whether
20706 or not there may be more than one thread associated with a program.
20707 It is implementation defined how threads beyond the first are
20708 created, the name and type of the function called at thread
20709 startup, and how threads may be terminated. However, objects
20710 with thread storage duration shall be initialized before thread
20711 startup.
20712 @end quotation
20713
20714 @item
20715 @cite{6.2.4 Storage durations of objects}
20716
20717 Add new text before paragraph 3
20718
20719 @quotation
20720 An object whose identifier is declared with the storage-class
20721 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
20722 Its lifetime is the entire execution of the thread, and its
20723 stored value is initialized only once, prior to thread startup.
20724 @end quotation
20725
20726 @item
20727 @cite{6.4.1 Keywords}
20728
20729 Add @code{__thread}.
20730
20731 @item
20732 @cite{6.7.1 Storage-class specifiers}
20733
20734 Add @code{__thread} to the list of storage class specifiers in
20735 paragraph 1.
20736
20737 Change paragraph 2 to
20738
20739 @quotation
20740 With the exception of @code{__thread}, at most one storage-class
20741 specifier may be given [@dots{}]. The @code{__thread} specifier may
20742 be used alone, or immediately following @code{extern} or
20743 @code{static}.
20744 @end quotation
20745
20746 Add new text after paragraph 6
20747
20748 @quotation
20749 The declaration of an identifier for a variable that has
20750 block scope that specifies @code{__thread} shall also
20751 specify either @code{extern} or @code{static}.
20752
20753 The @code{__thread} specifier shall be used only with
20754 variables.
20755 @end quotation
20756 @end itemize
20757
20758 @node C++98 Thread-Local Edits
20759 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
20760
20761 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
20762 that document the exact semantics of the language extension.
20763
20764 @itemize @bullet
20765 @item
20766 @b{[intro.execution]}
20767
20768 New text after paragraph 4
20769
20770 @quotation
20771 A @dfn{thread} is a flow of control within the abstract machine.
20772 It is implementation defined whether or not there may be more than
20773 one thread.
20774 @end quotation
20775
20776 New text after paragraph 7
20777
20778 @quotation
20779 It is unspecified whether additional action must be taken to
20780 ensure when and whether side effects are visible to other threads.
20781 @end quotation
20782
20783 @item
20784 @b{[lex.key]}
20785
20786 Add @code{__thread}.
20787
20788 @item
20789 @b{[basic.start.main]}
20790
20791 Add after paragraph 5
20792
20793 @quotation
20794 The thread that begins execution at the @code{main} function is called
20795 the @dfn{main thread}. It is implementation defined how functions
20796 beginning threads other than the main thread are designated or typed.
20797 A function so designated, as well as the @code{main} function, is called
20798 a @dfn{thread startup function}. It is implementation defined what
20799 happens if a thread startup function returns. It is implementation
20800 defined what happens to other threads when any thread calls @code{exit}.
20801 @end quotation
20802
20803 @item
20804 @b{[basic.start.init]}
20805
20806 Add after paragraph 4
20807
20808 @quotation
20809 The storage for an object of thread storage duration shall be
20810 statically initialized before the first statement of the thread startup
20811 function. An object of thread storage duration shall not require
20812 dynamic initialization.
20813 @end quotation
20814
20815 @item
20816 @b{[basic.start.term]}
20817
20818 Add after paragraph 3
20819
20820 @quotation
20821 The type of an object with thread storage duration shall not have a
20822 non-trivial destructor, nor shall it be an array type whose elements
20823 (directly or indirectly) have non-trivial destructors.
20824 @end quotation
20825
20826 @item
20827 @b{[basic.stc]}
20828
20829 Add ``thread storage duration'' to the list in paragraph 1.
20830
20831 Change paragraph 2
20832
20833 @quotation
20834 Thread, static, and automatic storage durations are associated with
20835 objects introduced by declarations [@dots{}].
20836 @end quotation
20837
20838 Add @code{__thread} to the list of specifiers in paragraph 3.
20839
20840 @item
20841 @b{[basic.stc.thread]}
20842
20843 New section before @b{[basic.stc.static]}
20844
20845 @quotation
20846 The keyword @code{__thread} applied to a non-local object gives the
20847 object thread storage duration.
20848
20849 A local variable or class data member declared both @code{static}
20850 and @code{__thread} gives the variable or member thread storage
20851 duration.
20852 @end quotation
20853
20854 @item
20855 @b{[basic.stc.static]}
20856
20857 Change paragraph 1
20858
20859 @quotation
20860 All objects that have neither thread storage duration, dynamic
20861 storage duration nor are local [@dots{}].
20862 @end quotation
20863
20864 @item
20865 @b{[dcl.stc]}
20866
20867 Add @code{__thread} to the list in paragraph 1.
20868
20869 Change paragraph 1
20870
20871 @quotation
20872 With the exception of @code{__thread}, at most one
20873 @var{storage-class-specifier} shall appear in a given
20874 @var{decl-specifier-seq}. The @code{__thread} specifier may
20875 be used alone, or immediately following the @code{extern} or
20876 @code{static} specifiers. [@dots{}]
20877 @end quotation
20878
20879 Add after paragraph 5
20880
20881 @quotation
20882 The @code{__thread} specifier can be applied only to the names of objects
20883 and to anonymous unions.
20884 @end quotation
20885
20886 @item
20887 @b{[class.mem]}
20888
20889 Add after paragraph 6
20890
20891 @quotation
20892 Non-@code{static} members shall not be @code{__thread}.
20893 @end quotation
20894 @end itemize
20895
20896 @node Binary constants
20897 @section Binary Constants using the @samp{0b} Prefix
20898 @cindex Binary constants using the @samp{0b} prefix
20899
20900 Integer constants can be written as binary constants, consisting of a
20901 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
20902 @samp{0B}. This is particularly useful in environments that operate a
20903 lot on the bit level (like microcontrollers).
20904
20905 The following statements are identical:
20906
20907 @smallexample
20908 i = 42;
20909 i = 0x2a;
20910 i = 052;
20911 i = 0b101010;
20912 @end smallexample
20913
20914 The type of these constants follows the same rules as for octal or
20915 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
20916 can be applied.
20917
20918 @node C++ Extensions
20919 @chapter Extensions to the C++ Language
20920 @cindex extensions, C++ language
20921 @cindex C++ language extensions
20922
20923 The GNU compiler provides these extensions to the C++ language (and you
20924 can also use most of the C language extensions in your C++ programs). If you
20925 want to write code that checks whether these features are available, you can
20926 test for the GNU compiler the same way as for C programs: check for a
20927 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
20928 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
20929 Predefined Macros,cpp,The GNU C Preprocessor}).
20930
20931 @menu
20932 * C++ Volatiles:: What constitutes an access to a volatile object.
20933 * Restricted Pointers:: C99 restricted pointers and references.
20934 * Vague Linkage:: Where G++ puts inlines, vtables and such.
20935 * C++ Interface:: You can use a single C++ header file for both
20936 declarations and definitions.
20937 * Template Instantiation:: Methods for ensuring that exactly one copy of
20938 each needed template instantiation is emitted.
20939 * Bound member functions:: You can extract a function pointer to the
20940 method denoted by a @samp{->*} or @samp{.*} expression.
20941 * C++ Attributes:: Variable, function, and type attributes for C++ only.
20942 * Function Multiversioning:: Declaring multiple function versions.
20943 * Namespace Association:: Strong using-directives for namespace association.
20944 * Type Traits:: Compiler support for type traits.
20945 * C++ Concepts:: Improved support for generic programming.
20946 * Java Exceptions:: Tweaking exception handling to work with Java.
20947 * Deprecated Features:: Things will disappear from G++.
20948 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
20949 @end menu
20950
20951 @node C++ Volatiles
20952 @section When is a Volatile C++ Object Accessed?
20953 @cindex accessing volatiles
20954 @cindex volatile read
20955 @cindex volatile write
20956 @cindex volatile access
20957
20958 The C++ standard differs from the C standard in its treatment of
20959 volatile objects. It fails to specify what constitutes a volatile
20960 access, except to say that C++ should behave in a similar manner to C
20961 with respect to volatiles, where possible. However, the different
20962 lvalueness of expressions between C and C++ complicate the behavior.
20963 G++ behaves the same as GCC for volatile access, @xref{C
20964 Extensions,,Volatiles}, for a description of GCC's behavior.
20965
20966 The C and C++ language specifications differ when an object is
20967 accessed in a void context:
20968
20969 @smallexample
20970 volatile int *src = @var{somevalue};
20971 *src;
20972 @end smallexample
20973
20974 The C++ standard specifies that such expressions do not undergo lvalue
20975 to rvalue conversion, and that the type of the dereferenced object may
20976 be incomplete. The C++ standard does not specify explicitly that it
20977 is lvalue to rvalue conversion that is responsible for causing an
20978 access. There is reason to believe that it is, because otherwise
20979 certain simple expressions become undefined. However, because it
20980 would surprise most programmers, G++ treats dereferencing a pointer to
20981 volatile object of complete type as GCC would do for an equivalent
20982 type in C@. When the object has incomplete type, G++ issues a
20983 warning; if you wish to force an error, you must force a conversion to
20984 rvalue with, for instance, a static cast.
20985
20986 When using a reference to volatile, G++ does not treat equivalent
20987 expressions as accesses to volatiles, but instead issues a warning that
20988 no volatile is accessed. The rationale for this is that otherwise it
20989 becomes difficult to determine where volatile access occur, and not
20990 possible to ignore the return value from functions returning volatile
20991 references. Again, if you wish to force a read, cast the reference to
20992 an rvalue.
20993
20994 G++ implements the same behavior as GCC does when assigning to a
20995 volatile object---there is no reread of the assigned-to object, the
20996 assigned rvalue is reused. Note that in C++ assignment expressions
20997 are lvalues, and if used as an lvalue, the volatile object is
20998 referred to. For instance, @var{vref} refers to @var{vobj}, as
20999 expected, in the following example:
21000
21001 @smallexample
21002 volatile int vobj;
21003 volatile int &vref = vobj = @var{something};
21004 @end smallexample
21005
21006 @node Restricted Pointers
21007 @section Restricting Pointer Aliasing
21008 @cindex restricted pointers
21009 @cindex restricted references
21010 @cindex restricted this pointer
21011
21012 As with the C front end, G++ understands the C99 feature of restricted pointers,
21013 specified with the @code{__restrict__}, or @code{__restrict} type
21014 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
21015 language flag, @code{restrict} is not a keyword in C++.
21016
21017 In addition to allowing restricted pointers, you can specify restricted
21018 references, which indicate that the reference is not aliased in the local
21019 context.
21020
21021 @smallexample
21022 void fn (int *__restrict__ rptr, int &__restrict__ rref)
21023 @{
21024 /* @r{@dots{}} */
21025 @}
21026 @end smallexample
21027
21028 @noindent
21029 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
21030 @var{rref} refers to a (different) unaliased integer.
21031
21032 You may also specify whether a member function's @var{this} pointer is
21033 unaliased by using @code{__restrict__} as a member function qualifier.
21034
21035 @smallexample
21036 void T::fn () __restrict__
21037 @{
21038 /* @r{@dots{}} */
21039 @}
21040 @end smallexample
21041
21042 @noindent
21043 Within the body of @code{T::fn}, @var{this} has the effective
21044 definition @code{T *__restrict__ const this}. Notice that the
21045 interpretation of a @code{__restrict__} member function qualifier is
21046 different to that of @code{const} or @code{volatile} qualifier, in that it
21047 is applied to the pointer rather than the object. This is consistent with
21048 other compilers that implement restricted pointers.
21049
21050 As with all outermost parameter qualifiers, @code{__restrict__} is
21051 ignored in function definition matching. This means you only need to
21052 specify @code{__restrict__} in a function definition, rather than
21053 in a function prototype as well.
21054
21055 @node Vague Linkage
21056 @section Vague Linkage
21057 @cindex vague linkage
21058
21059 There are several constructs in C++ that require space in the object
21060 file but are not clearly tied to a single translation unit. We say that
21061 these constructs have ``vague linkage''. Typically such constructs are
21062 emitted wherever they are needed, though sometimes we can be more
21063 clever.
21064
21065 @table @asis
21066 @item Inline Functions
21067 Inline functions are typically defined in a header file which can be
21068 included in many different compilations. Hopefully they can usually be
21069 inlined, but sometimes an out-of-line copy is necessary, if the address
21070 of the function is taken or if inlining fails. In general, we emit an
21071 out-of-line copy in all translation units where one is needed. As an
21072 exception, we only emit inline virtual functions with the vtable, since
21073 it always requires a copy.
21074
21075 Local static variables and string constants used in an inline function
21076 are also considered to have vague linkage, since they must be shared
21077 between all inlined and out-of-line instances of the function.
21078
21079 @item VTables
21080 @cindex vtable
21081 C++ virtual functions are implemented in most compilers using a lookup
21082 table, known as a vtable. The vtable contains pointers to the virtual
21083 functions provided by a class, and each object of the class contains a
21084 pointer to its vtable (or vtables, in some multiple-inheritance
21085 situations). If the class declares any non-inline, non-pure virtual
21086 functions, the first one is chosen as the ``key method'' for the class,
21087 and the vtable is only emitted in the translation unit where the key
21088 method is defined.
21089
21090 @emph{Note:} If the chosen key method is later defined as inline, the
21091 vtable is still emitted in every translation unit that defines it.
21092 Make sure that any inline virtuals are declared inline in the class
21093 body, even if they are not defined there.
21094
21095 @item @code{type_info} objects
21096 @cindex @code{type_info}
21097 @cindex RTTI
21098 C++ requires information about types to be written out in order to
21099 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
21100 For polymorphic classes (classes with virtual functions), the @samp{type_info}
21101 object is written out along with the vtable so that @samp{dynamic_cast}
21102 can determine the dynamic type of a class object at run time. For all
21103 other types, we write out the @samp{type_info} object when it is used: when
21104 applying @samp{typeid} to an expression, throwing an object, or
21105 referring to a type in a catch clause or exception specification.
21106
21107 @item Template Instantiations
21108 Most everything in this section also applies to template instantiations,
21109 but there are other options as well.
21110 @xref{Template Instantiation,,Where's the Template?}.
21111
21112 @end table
21113
21114 When used with GNU ld version 2.8 or later on an ELF system such as
21115 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
21116 these constructs will be discarded at link time. This is known as
21117 COMDAT support.
21118
21119 On targets that don't support COMDAT, but do support weak symbols, GCC
21120 uses them. This way one copy overrides all the others, but
21121 the unused copies still take up space in the executable.
21122
21123 For targets that do not support either COMDAT or weak symbols,
21124 most entities with vague linkage are emitted as local symbols to
21125 avoid duplicate definition errors from the linker. This does not happen
21126 for local statics in inlines, however, as having multiple copies
21127 almost certainly breaks things.
21128
21129 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
21130 another way to control placement of these constructs.
21131
21132 @node C++ Interface
21133 @section C++ Interface and Implementation Pragmas
21134
21135 @cindex interface and implementation headers, C++
21136 @cindex C++ interface and implementation headers
21137 @cindex pragmas, interface and implementation
21138
21139 @code{#pragma interface} and @code{#pragma implementation} provide the
21140 user with a way of explicitly directing the compiler to emit entities
21141 with vague linkage (and debugging information) in a particular
21142 translation unit.
21143
21144 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
21145 by COMDAT support and the ``key method'' heuristic
21146 mentioned in @ref{Vague Linkage}. Using them can actually cause your
21147 program to grow due to unnecessary out-of-line copies of inline
21148 functions.
21149
21150 @table @code
21151 @item #pragma interface
21152 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
21153 @kindex #pragma interface
21154 Use this directive in @emph{header files} that define object classes, to save
21155 space in most of the object files that use those classes. Normally,
21156 local copies of certain information (backup copies of inline member
21157 functions, debugging information, and the internal tables that implement
21158 virtual functions) must be kept in each object file that includes class
21159 definitions. You can use this pragma to avoid such duplication. When a
21160 header file containing @samp{#pragma interface} is included in a
21161 compilation, this auxiliary information is not generated (unless
21162 the main input source file itself uses @samp{#pragma implementation}).
21163 Instead, the object files contain references to be resolved at link
21164 time.
21165
21166 The second form of this directive is useful for the case where you have
21167 multiple headers with the same name in different directories. If you
21168 use this form, you must specify the same string to @samp{#pragma
21169 implementation}.
21170
21171 @item #pragma implementation
21172 @itemx #pragma implementation "@var{objects}.h"
21173 @kindex #pragma implementation
21174 Use this pragma in a @emph{main input file}, when you want full output from
21175 included header files to be generated (and made globally visible). The
21176 included header file, in turn, should use @samp{#pragma interface}.
21177 Backup copies of inline member functions, debugging information, and the
21178 internal tables used to implement virtual functions are all generated in
21179 implementation files.
21180
21181 @cindex implied @code{#pragma implementation}
21182 @cindex @code{#pragma implementation}, implied
21183 @cindex naming convention, implementation headers
21184 If you use @samp{#pragma implementation} with no argument, it applies to
21185 an include file with the same basename@footnote{A file's @dfn{basename}
21186 is the name stripped of all leading path information and of trailing
21187 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
21188 file. For example, in @file{allclass.cc}, giving just
21189 @samp{#pragma implementation}
21190 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
21191
21192 Use the string argument if you want a single implementation file to
21193 include code from multiple header files. (You must also use
21194 @samp{#include} to include the header file; @samp{#pragma
21195 implementation} only specifies how to use the file---it doesn't actually
21196 include it.)
21197
21198 There is no way to split up the contents of a single header file into
21199 multiple implementation files.
21200 @end table
21201
21202 @cindex inlining and C++ pragmas
21203 @cindex C++ pragmas, effect on inlining
21204 @cindex pragmas in C++, effect on inlining
21205 @samp{#pragma implementation} and @samp{#pragma interface} also have an
21206 effect on function inlining.
21207
21208 If you define a class in a header file marked with @samp{#pragma
21209 interface}, the effect on an inline function defined in that class is
21210 similar to an explicit @code{extern} declaration---the compiler emits
21211 no code at all to define an independent version of the function. Its
21212 definition is used only for inlining with its callers.
21213
21214 @opindex fno-implement-inlines
21215 Conversely, when you include the same header file in a main source file
21216 that declares it as @samp{#pragma implementation}, the compiler emits
21217 code for the function itself; this defines a version of the function
21218 that can be found via pointers (or by callers compiled without
21219 inlining). If all calls to the function can be inlined, you can avoid
21220 emitting the function by compiling with @option{-fno-implement-inlines}.
21221 If any calls are not inlined, you will get linker errors.
21222
21223 @node Template Instantiation
21224 @section Where's the Template?
21225 @cindex template instantiation
21226
21227 C++ templates were the first language feature to require more
21228 intelligence from the environment than was traditionally found on a UNIX
21229 system. Somehow the compiler and linker have to make sure that each
21230 template instance occurs exactly once in the executable if it is needed,
21231 and not at all otherwise. There are two basic approaches to this
21232 problem, which are referred to as the Borland model and the Cfront model.
21233
21234 @table @asis
21235 @item Borland model
21236 Borland C++ solved the template instantiation problem by adding the code
21237 equivalent of common blocks to their linker; the compiler emits template
21238 instances in each translation unit that uses them, and the linker
21239 collapses them together. The advantage of this model is that the linker
21240 only has to consider the object files themselves; there is no external
21241 complexity to worry about. The disadvantage is that compilation time
21242 is increased because the template code is being compiled repeatedly.
21243 Code written for this model tends to include definitions of all
21244 templates in the header file, since they must be seen to be
21245 instantiated.
21246
21247 @item Cfront model
21248 The AT&T C++ translator, Cfront, solved the template instantiation
21249 problem by creating the notion of a template repository, an
21250 automatically maintained place where template instances are stored. A
21251 more modern version of the repository works as follows: As individual
21252 object files are built, the compiler places any template definitions and
21253 instantiations encountered in the repository. At link time, the link
21254 wrapper adds in the objects in the repository and compiles any needed
21255 instances that were not previously emitted. The advantages of this
21256 model are more optimal compilation speed and the ability to use the
21257 system linker; to implement the Borland model a compiler vendor also
21258 needs to replace the linker. The disadvantages are vastly increased
21259 complexity, and thus potential for error; for some code this can be
21260 just as transparent, but in practice it can been very difficult to build
21261 multiple programs in one directory and one program in multiple
21262 directories. Code written for this model tends to separate definitions
21263 of non-inline member templates into a separate file, which should be
21264 compiled separately.
21265 @end table
21266
21267 G++ implements the Borland model on targets where the linker supports it,
21268 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
21269 Otherwise G++ implements neither automatic model.
21270
21271 You have the following options for dealing with template instantiations:
21272
21273 @enumerate
21274 @item
21275 Do nothing. Code written for the Borland model works fine, but
21276 each translation unit contains instances of each of the templates it
21277 uses. The duplicate instances will be discarded by the linker, but in
21278 a large program, this can lead to an unacceptable amount of code
21279 duplication in object files or shared libraries.
21280
21281 Duplicate instances of a template can be avoided by defining an explicit
21282 instantiation in one object file, and preventing the compiler from doing
21283 implicit instantiations in any other object files by using an explicit
21284 instantiation declaration, using the @code{extern template} syntax:
21285
21286 @smallexample
21287 extern template int max (int, int);
21288 @end smallexample
21289
21290 This syntax is defined in the C++ 2011 standard, but has been supported by
21291 G++ and other compilers since well before 2011.
21292
21293 Explicit instantiations can be used for the largest or most frequently
21294 duplicated instances, without having to know exactly which other instances
21295 are used in the rest of the program. You can scatter the explicit
21296 instantiations throughout your program, perhaps putting them in the
21297 translation units where the instances are used or the translation units
21298 that define the templates themselves; you can put all of the explicit
21299 instantiations you need into one big file; or you can create small files
21300 like
21301
21302 @smallexample
21303 #include "Foo.h"
21304 #include "Foo.cc"
21305
21306 template class Foo<int>;
21307 template ostream& operator <<
21308 (ostream&, const Foo<int>&);
21309 @end smallexample
21310
21311 @noindent
21312 for each of the instances you need, and create a template instantiation
21313 library from those.
21314
21315 This is the simplest option, but also offers flexibility and
21316 fine-grained control when necessary. It is also the most portable
21317 alternative and programs using this approach will work with most modern
21318 compilers.
21319
21320 @item
21321 @opindex frepo
21322 Compile your template-using code with @option{-frepo}. The compiler
21323 generates files with the extension @samp{.rpo} listing all of the
21324 template instantiations used in the corresponding object files that
21325 could be instantiated there; the link wrapper, @samp{collect2},
21326 then updates the @samp{.rpo} files to tell the compiler where to place
21327 those instantiations and rebuild any affected object files. The
21328 link-time overhead is negligible after the first pass, as the compiler
21329 continues to place the instantiations in the same files.
21330
21331 This can be a suitable option for application code written for the Borland
21332 model, as it usually just works. Code written for the Cfront model
21333 needs to be modified so that the template definitions are available at
21334 one or more points of instantiation; usually this is as simple as adding
21335 @code{#include <tmethods.cc>} to the end of each template header.
21336
21337 For library code, if you want the library to provide all of the template
21338 instantiations it needs, just try to link all of its object files
21339 together; the link will fail, but cause the instantiations to be
21340 generated as a side effect. Be warned, however, that this may cause
21341 conflicts if multiple libraries try to provide the same instantiations.
21342 For greater control, use explicit instantiation as described in the next
21343 option.
21344
21345 @item
21346 @opindex fno-implicit-templates
21347 Compile your code with @option{-fno-implicit-templates} to disable the
21348 implicit generation of template instances, and explicitly instantiate
21349 all the ones you use. This approach requires more knowledge of exactly
21350 which instances you need than do the others, but it's less
21351 mysterious and allows greater control if you want to ensure that only
21352 the intended instances are used.
21353
21354 If you are using Cfront-model code, you can probably get away with not
21355 using @option{-fno-implicit-templates} when compiling files that don't
21356 @samp{#include} the member template definitions.
21357
21358 If you use one big file to do the instantiations, you may want to
21359 compile it without @option{-fno-implicit-templates} so you get all of the
21360 instances required by your explicit instantiations (but not by any
21361 other files) without having to specify them as well.
21362
21363 In addition to forward declaration of explicit instantiations
21364 (with @code{extern}), G++ has extended the template instantiation
21365 syntax to support instantiation of the compiler support data for a
21366 template class (i.e.@: the vtable) without instantiating any of its
21367 members (with @code{inline}), and instantiation of only the static data
21368 members of a template class, without the support data or member
21369 functions (with @code{static}):
21370
21371 @smallexample
21372 inline template class Foo<int>;
21373 static template class Foo<int>;
21374 @end smallexample
21375 @end enumerate
21376
21377 @node Bound member functions
21378 @section Extracting the Function Pointer from a Bound Pointer to Member Function
21379 @cindex pmf
21380 @cindex pointer to member function
21381 @cindex bound pointer to member function
21382
21383 In C++, pointer to member functions (PMFs) are implemented using a wide
21384 pointer of sorts to handle all the possible call mechanisms; the PMF
21385 needs to store information about how to adjust the @samp{this} pointer,
21386 and if the function pointed to is virtual, where to find the vtable, and
21387 where in the vtable to look for the member function. If you are using
21388 PMFs in an inner loop, you should really reconsider that decision. If
21389 that is not an option, you can extract the pointer to the function that
21390 would be called for a given object/PMF pair and call it directly inside
21391 the inner loop, to save a bit of time.
21392
21393 Note that you still pay the penalty for the call through a
21394 function pointer; on most modern architectures, such a call defeats the
21395 branch prediction features of the CPU@. This is also true of normal
21396 virtual function calls.
21397
21398 The syntax for this extension is
21399
21400 @smallexample
21401 extern A a;
21402 extern int (A::*fp)();
21403 typedef int (*fptr)(A *);
21404
21405 fptr p = (fptr)(a.*fp);
21406 @end smallexample
21407
21408 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
21409 no object is needed to obtain the address of the function. They can be
21410 converted to function pointers directly:
21411
21412 @smallexample
21413 fptr p1 = (fptr)(&A::foo);
21414 @end smallexample
21415
21416 @opindex Wno-pmf-conversions
21417 You must specify @option{-Wno-pmf-conversions} to use this extension.
21418
21419 @node C++ Attributes
21420 @section C++-Specific Variable, Function, and Type Attributes
21421
21422 Some attributes only make sense for C++ programs.
21423
21424 @table @code
21425 @item abi_tag ("@var{tag}", ...)
21426 @cindex @code{abi_tag} function attribute
21427 @cindex @code{abi_tag} variable attribute
21428 @cindex @code{abi_tag} type attribute
21429 The @code{abi_tag} attribute can be applied to a function, variable, or class
21430 declaration. It modifies the mangled name of the entity to
21431 incorporate the tag name, in order to distinguish the function or
21432 class from an earlier version with a different ABI; perhaps the class
21433 has changed size, or the function has a different return type that is
21434 not encoded in the mangled name.
21435
21436 The attribute can also be applied to an inline namespace, but does not
21437 affect the mangled name of the namespace; in this case it is only used
21438 for @option{-Wabi-tag} warnings and automatic tagging of functions and
21439 variables. Tagging inline namespaces is generally preferable to
21440 tagging individual declarations, but the latter is sometimes
21441 necessary, such as when only certain members of a class need to be
21442 tagged.
21443
21444 The argument can be a list of strings of arbitrary length. The
21445 strings are sorted on output, so the order of the list is
21446 unimportant.
21447
21448 A redeclaration of an entity must not add new ABI tags,
21449 since doing so would change the mangled name.
21450
21451 The ABI tags apply to a name, so all instantiations and
21452 specializations of a template have the same tags. The attribute will
21453 be ignored if applied to an explicit specialization or instantiation.
21454
21455 The @option{-Wabi-tag} flag enables a warning about a class which does
21456 not have all the ABI tags used by its subobjects and virtual functions; for users with code
21457 that needs to coexist with an earlier ABI, using this option can help
21458 to find all affected types that need to be tagged.
21459
21460 When a type involving an ABI tag is used as the type of a variable or
21461 return type of a function where that tag is not already present in the
21462 signature of the function, the tag is automatically applied to the
21463 variable or function. @option{-Wabi-tag} also warns about this
21464 situation; this warning can be avoided by explicitly tagging the
21465 variable or function or moving it into a tagged inline namespace.
21466
21467 @item init_priority (@var{priority})
21468 @cindex @code{init_priority} variable attribute
21469
21470 In Standard C++, objects defined at namespace scope are guaranteed to be
21471 initialized in an order in strict accordance with that of their definitions
21472 @emph{in a given translation unit}. No guarantee is made for initializations
21473 across translation units. However, GNU C++ allows users to control the
21474 order of initialization of objects defined at namespace scope with the
21475 @code{init_priority} attribute by specifying a relative @var{priority},
21476 a constant integral expression currently bounded between 101 and 65535
21477 inclusive. Lower numbers indicate a higher priority.
21478
21479 In the following example, @code{A} would normally be created before
21480 @code{B}, but the @code{init_priority} attribute reverses that order:
21481
21482 @smallexample
21483 Some_Class A __attribute__ ((init_priority (2000)));
21484 Some_Class B __attribute__ ((init_priority (543)));
21485 @end smallexample
21486
21487 @noindent
21488 Note that the particular values of @var{priority} do not matter; only their
21489 relative ordering.
21490
21491 @item java_interface
21492 @cindex @code{java_interface} type attribute
21493
21494 This type attribute informs C++ that the class is a Java interface. It may
21495 only be applied to classes declared within an @code{extern "Java"} block.
21496 Calls to methods declared in this interface are dispatched using GCJ's
21497 interface table mechanism, instead of regular virtual table dispatch.
21498
21499 @item warn_unused
21500 @cindex @code{warn_unused} type attribute
21501
21502 For C++ types with non-trivial constructors and/or destructors it is
21503 impossible for the compiler to determine whether a variable of this
21504 type is truly unused if it is not referenced. This type attribute
21505 informs the compiler that variables of this type should be warned
21506 about if they appear to be unused, just like variables of fundamental
21507 types.
21508
21509 This attribute is appropriate for types which just represent a value,
21510 such as @code{std::string}; it is not appropriate for types which
21511 control a resource, such as @code{std::lock_guard}.
21512
21513 This attribute is also accepted in C, but it is unnecessary because C
21514 does not have constructors or destructors.
21515
21516 @end table
21517
21518 See also @ref{Namespace Association}.
21519
21520 @node Function Multiversioning
21521 @section Function Multiversioning
21522 @cindex function versions
21523
21524 With the GNU C++ front end, for x86 targets, you may specify multiple
21525 versions of a function, where each function is specialized for a
21526 specific target feature. At runtime, the appropriate version of the
21527 function is automatically executed depending on the characteristics of
21528 the execution platform. Here is an example.
21529
21530 @smallexample
21531 __attribute__ ((target ("default")))
21532 int foo ()
21533 @{
21534 // The default version of foo.
21535 return 0;
21536 @}
21537
21538 __attribute__ ((target ("sse4.2")))
21539 int foo ()
21540 @{
21541 // foo version for SSE4.2
21542 return 1;
21543 @}
21544
21545 __attribute__ ((target ("arch=atom")))
21546 int foo ()
21547 @{
21548 // foo version for the Intel ATOM processor
21549 return 2;
21550 @}
21551
21552 __attribute__ ((target ("arch=amdfam10")))
21553 int foo ()
21554 @{
21555 // foo version for the AMD Family 0x10 processors.
21556 return 3;
21557 @}
21558
21559 int main ()
21560 @{
21561 int (*p)() = &foo;
21562 assert ((*p) () == foo ());
21563 return 0;
21564 @}
21565 @end smallexample
21566
21567 In the above example, four versions of function foo are created. The
21568 first version of foo with the target attribute "default" is the default
21569 version. This version gets executed when no other target specific
21570 version qualifies for execution on a particular platform. A new version
21571 of foo is created by using the same function signature but with a
21572 different target string. Function foo is called or a pointer to it is
21573 taken just like a regular function. GCC takes care of doing the
21574 dispatching to call the right version at runtime. Refer to the
21575 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
21576 Function Multiversioning} for more details.
21577
21578 @node Namespace Association
21579 @section Namespace Association
21580
21581 @strong{Caution:} The semantics of this extension are equivalent
21582 to C++ 2011 inline namespaces. Users should use inline namespaces
21583 instead as this extension will be removed in future versions of G++.
21584
21585 A using-directive with @code{__attribute ((strong))} is stronger
21586 than a normal using-directive in two ways:
21587
21588 @itemize @bullet
21589 @item
21590 Templates from the used namespace can be specialized and explicitly
21591 instantiated as though they were members of the using namespace.
21592
21593 @item
21594 The using namespace is considered an associated namespace of all
21595 templates in the used namespace for purposes of argument-dependent
21596 name lookup.
21597 @end itemize
21598
21599 The used namespace must be nested within the using namespace so that
21600 normal unqualified lookup works properly.
21601
21602 This is useful for composing a namespace transparently from
21603 implementation namespaces. For example:
21604
21605 @smallexample
21606 namespace std @{
21607 namespace debug @{
21608 template <class T> struct A @{ @};
21609 @}
21610 using namespace debug __attribute ((__strong__));
21611 template <> struct A<int> @{ @}; // @r{OK to specialize}
21612
21613 template <class T> void f (A<T>);
21614 @}
21615
21616 int main()
21617 @{
21618 f (std::A<float>()); // @r{lookup finds} std::f
21619 f (std::A<int>());
21620 @}
21621 @end smallexample
21622
21623 @node Type Traits
21624 @section Type Traits
21625
21626 The C++ front end implements syntactic extensions that allow
21627 compile-time determination of
21628 various characteristics of a type (or of a
21629 pair of types).
21630
21631 @table @code
21632 @item __has_nothrow_assign (type)
21633 If @code{type} is const qualified or is a reference type then the trait is
21634 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
21635 is true, else if @code{type} is a cv class or union type with copy assignment
21636 operators that are known not to throw an exception then the trait is true,
21637 else it is false. Requires: @code{type} shall be a complete type,
21638 (possibly cv-qualified) @code{void}, or an array of unknown bound.
21639
21640 @item __has_nothrow_copy (type)
21641 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
21642 @code{type} is a cv class or union type with copy constructors that
21643 are known not to throw an exception then the trait is true, else it is false.
21644 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
21645 @code{void}, or an array of unknown bound.
21646
21647 @item __has_nothrow_constructor (type)
21648 If @code{__has_trivial_constructor (type)} is true then the trait is
21649 true, else if @code{type} is a cv class or union type (or array
21650 thereof) with a default constructor that is known not to throw an
21651 exception then the trait is true, else it is false. Requires:
21652 @code{type} shall be a complete type, (possibly cv-qualified)
21653 @code{void}, or an array of unknown bound.
21654
21655 @item __has_trivial_assign (type)
21656 If @code{type} is const qualified or is a reference type then the trait is
21657 false. Otherwise if @code{__is_pod (type)} is true then the trait is
21658 true, else if @code{type} is a cv class or union type with a trivial
21659 copy assignment ([class.copy]) then the trait is true, else it is
21660 false. Requires: @code{type} shall be a complete type, (possibly
21661 cv-qualified) @code{void}, or an array of unknown bound.
21662
21663 @item __has_trivial_copy (type)
21664 If @code{__is_pod (type)} is true or @code{type} is a reference type
21665 then the trait is true, else if @code{type} is a cv class or union type
21666 with a trivial copy constructor ([class.copy]) then the trait
21667 is true, else it is false. Requires: @code{type} shall be a complete
21668 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21669
21670 @item __has_trivial_constructor (type)
21671 If @code{__is_pod (type)} is true then the trait is true, else if
21672 @code{type} is a cv class or union type (or array thereof) with a
21673 trivial default constructor ([class.ctor]) then the trait is true,
21674 else it is false. Requires: @code{type} shall be a complete
21675 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21676
21677 @item __has_trivial_destructor (type)
21678 If @code{__is_pod (type)} is true or @code{type} is a reference type then
21679 the trait is true, else if @code{type} is a cv class or union type (or
21680 array thereof) with a trivial destructor ([class.dtor]) then the trait
21681 is true, else it is false. Requires: @code{type} shall be a complete
21682 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21683
21684 @item __has_virtual_destructor (type)
21685 If @code{type} is a class type with a virtual destructor
21686 ([class.dtor]) then the trait is true, else it is false. Requires:
21687 @code{type} shall be a complete type, (possibly cv-qualified)
21688 @code{void}, or an array of unknown bound.
21689
21690 @item __is_abstract (type)
21691 If @code{type} is an abstract class ([class.abstract]) then the trait
21692 is true, else it is false. Requires: @code{type} shall be a complete
21693 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21694
21695 @item __is_base_of (base_type, derived_type)
21696 If @code{base_type} is a base class of @code{derived_type}
21697 ([class.derived]) then the trait is true, otherwise it is false.
21698 Top-level cv qualifications of @code{base_type} and
21699 @code{derived_type} are ignored. For the purposes of this trait, a
21700 class type is considered is own base. Requires: if @code{__is_class
21701 (base_type)} and @code{__is_class (derived_type)} are true and
21702 @code{base_type} and @code{derived_type} are not the same type
21703 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
21704 type. A diagnostic is produced if this requirement is not met.
21705
21706 @item __is_class (type)
21707 If @code{type} is a cv class type, and not a union type
21708 ([basic.compound]) the trait is true, else it is false.
21709
21710 @item __is_empty (type)
21711 If @code{__is_class (type)} is false then the trait is false.
21712 Otherwise @code{type} is considered empty if and only if: @code{type}
21713 has no non-static data members, or all non-static data members, if
21714 any, are bit-fields of length 0, and @code{type} has no virtual
21715 members, and @code{type} has no virtual base classes, and @code{type}
21716 has no base classes @code{base_type} for which
21717 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
21718 be a complete type, (possibly cv-qualified) @code{void}, or an array
21719 of unknown bound.
21720
21721 @item __is_enum (type)
21722 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
21723 true, else it is false.
21724
21725 @item __is_literal_type (type)
21726 If @code{type} is a literal type ([basic.types]) the trait is
21727 true, else it is false. Requires: @code{type} shall be a complete type,
21728 (possibly cv-qualified) @code{void}, or an array of unknown bound.
21729
21730 @item __is_pod (type)
21731 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
21732 else it is false. Requires: @code{type} shall be a complete type,
21733 (possibly cv-qualified) @code{void}, or an array of unknown bound.
21734
21735 @item __is_polymorphic (type)
21736 If @code{type} is a polymorphic class ([class.virtual]) then the trait
21737 is true, else it is false. Requires: @code{type} shall be a complete
21738 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21739
21740 @item __is_standard_layout (type)
21741 If @code{type} is a standard-layout type ([basic.types]) the trait is
21742 true, else it is false. Requires: @code{type} shall be a complete
21743 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21744
21745 @item __is_trivial (type)
21746 If @code{type} is a trivial type ([basic.types]) the trait is
21747 true, else it is false. Requires: @code{type} shall be a complete
21748 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
21749
21750 @item __is_union (type)
21751 If @code{type} is a cv union type ([basic.compound]) the trait is
21752 true, else it is false.
21753
21754 @item __underlying_type (type)
21755 The underlying type of @code{type}. Requires: @code{type} shall be
21756 an enumeration type ([dcl.enum]).
21757
21758 @end table
21759
21760
21761 @node C++ Concepts
21762 @section C++ Concepts
21763
21764 C++ concepts provide much-improved support for generic programming. In
21765 particular, they allow the specification of constraints on template arguments.
21766 The constraints are used to extend the usual overloading and partial
21767 specialization capabilities of the language, allowing generic data structures
21768 and algorithms to be ``refined'' based on their properties rather than their
21769 type names.
21770
21771 The following keywords are reserved for concepts.
21772
21773 @table @code
21774 @item assumes
21775 States an expression as an assumption, and if possible, verifies that the
21776 assumption is valid. For example, @code{assume(n > 0)}.
21777
21778 @item axiom
21779 Introduces an axiom definition. Axioms introduce requirements on values.
21780
21781 @item forall
21782 Introduces a universally quantified object in an axiom. For example,
21783 @code{forall (int n) n + 0 == n}).
21784
21785 @item concept
21786 Introduces a concept definition. Concepts are sets of syntactic and semantic
21787 requirements on types and their values.
21788
21789 @item requires
21790 Introduces constraints on template arguments or requirements for a member
21791 function of a class template.
21792
21793 @end table
21794
21795 The front end also exposes a number of internal mechanism that can be used
21796 to simplify the writing of type traits. Note that some of these traits are
21797 likely to be removed in the future.
21798
21799 @table @code
21800 @item __is_same (type1, type2)
21801 A binary type trait: true whenever the type arguments are the same.
21802
21803 @end table
21804
21805
21806 @node Java Exceptions
21807 @section Java Exceptions
21808
21809 The Java language uses a slightly different exception handling model
21810 from C++. Normally, GNU C++ automatically detects when you are
21811 writing C++ code that uses Java exceptions, and handle them
21812 appropriately. However, if C++ code only needs to execute destructors
21813 when Java exceptions are thrown through it, GCC guesses incorrectly.
21814 Sample problematic code is:
21815
21816 @smallexample
21817 struct S @{ ~S(); @};
21818 extern void bar(); // @r{is written in Java, and may throw exceptions}
21819 void foo()
21820 @{
21821 S s;
21822 bar();
21823 @}
21824 @end smallexample
21825
21826 @noindent
21827 The usual effect of an incorrect guess is a link failure, complaining of
21828 a missing routine called @samp{__gxx_personality_v0}.
21829
21830 You can inform the compiler that Java exceptions are to be used in a
21831 translation unit, irrespective of what it might think, by writing
21832 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
21833 @samp{#pragma} must appear before any functions that throw or catch
21834 exceptions, or run destructors when exceptions are thrown through them.
21835
21836 You cannot mix Java and C++ exceptions in the same translation unit. It
21837 is believed to be safe to throw a C++ exception from one file through
21838 another file compiled for the Java exception model, or vice versa, but
21839 there may be bugs in this area.
21840
21841 @node Deprecated Features
21842 @section Deprecated Features
21843
21844 In the past, the GNU C++ compiler was extended to experiment with new
21845 features, at a time when the C++ language was still evolving. Now that
21846 the C++ standard is complete, some of those features are superseded by
21847 superior alternatives. Using the old features might cause a warning in
21848 some cases that the feature will be dropped in the future. In other
21849 cases, the feature might be gone already.
21850
21851 While the list below is not exhaustive, it documents some of the options
21852 that are now deprecated:
21853
21854 @table @code
21855 @item -fexternal-templates
21856 @itemx -falt-external-templates
21857 These are two of the many ways for G++ to implement template
21858 instantiation. @xref{Template Instantiation}. The C++ standard clearly
21859 defines how template definitions have to be organized across
21860 implementation units. G++ has an implicit instantiation mechanism that
21861 should work just fine for standard-conforming code.
21862
21863 @item -fstrict-prototype
21864 @itemx -fno-strict-prototype
21865 Previously it was possible to use an empty prototype parameter list to
21866 indicate an unspecified number of parameters (like C), rather than no
21867 parameters, as C++ demands. This feature has been removed, except where
21868 it is required for backwards compatibility. @xref{Backwards Compatibility}.
21869 @end table
21870
21871 G++ allows a virtual function returning @samp{void *} to be overridden
21872 by one returning a different pointer type. This extension to the
21873 covariant return type rules is now deprecated and will be removed from a
21874 future version.
21875
21876 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
21877 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
21878 and are now removed from G++. Code using these operators should be
21879 modified to use @code{std::min} and @code{std::max} instead.
21880
21881 The named return value extension has been deprecated, and is now
21882 removed from G++.
21883
21884 The use of initializer lists with new expressions has been deprecated,
21885 and is now removed from G++.
21886
21887 Floating and complex non-type template parameters have been deprecated,
21888 and are now removed from G++.
21889
21890 The implicit typename extension has been deprecated and is now
21891 removed from G++.
21892
21893 The use of default arguments in function pointers, function typedefs
21894 and other places where they are not permitted by the standard is
21895 deprecated and will be removed from a future version of G++.
21896
21897 G++ allows floating-point literals to appear in integral constant expressions,
21898 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
21899 This extension is deprecated and will be removed from a future version.
21900
21901 G++ allows static data members of const floating-point type to be declared
21902 with an initializer in a class definition. The standard only allows
21903 initializers for static members of const integral types and const
21904 enumeration types so this extension has been deprecated and will be removed
21905 from a future version.
21906
21907 @node Backwards Compatibility
21908 @section Backwards Compatibility
21909 @cindex Backwards Compatibility
21910 @cindex ARM [Annotated C++ Reference Manual]
21911
21912 Now that there is a definitive ISO standard C++, G++ has a specification
21913 to adhere to. The C++ language evolved over time, and features that
21914 used to be acceptable in previous drafts of the standard, such as the ARM
21915 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
21916 compilation of C++ written to such drafts, G++ contains some backwards
21917 compatibilities. @emph{All such backwards compatibility features are
21918 liable to disappear in future versions of G++.} They should be considered
21919 deprecated. @xref{Deprecated Features}.
21920
21921 @table @code
21922 @item For scope
21923 If a variable is declared at for scope, it used to remain in scope until
21924 the end of the scope that contained the for statement (rather than just
21925 within the for scope). G++ retains this, but issues a warning, if such a
21926 variable is accessed outside the for scope.
21927
21928 @item Implicit C language
21929 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
21930 scope to set the language. On such systems, all header files are
21931 implicitly scoped inside a C language scope. Also, an empty prototype
21932 @code{()} is treated as an unspecified number of arguments, rather
21933 than no arguments, as C++ demands.
21934 @end table
21935
21936 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
21937 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr