re PR target/65837 ([arm-linux-gnueabihf] lto1 target specific builtin not available)
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2015 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 2
920 debug info format can represent this, so use of DWARF 2 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 On PowerPC Linux, Freebsd and Darwin systems, the default for
958 @code{long double} is to use the IBM extended floating point format
959 that uses a pair of @code{double} values to extend the precision.
960 This means that the mode @code{TCmode} was already used by the
961 traditional IBM long double format, and you would need to use the mode
962 @code{KCmode}:
963
964 @smallexample
965 typedef _Complex float __attribute__((mode(KC))) _Complex128;
966 @end smallexample
967
968 Not all targets support additional floating-point types. @code{__float80}
969 and @code{__float128} types are supported on x86 and IA-64 targets.
970 The @code{__float128} type is supported on hppa HP-UX.
971 The @code{__float128} type is supported on PowerPC systems by default
972 if the vector scalar instruction set (VSX) is enabled.
973
974 On the PowerPC, @code{__ibm128} provides access to the IBM extended
975 double format, and it is intended to be used by the library functions
976 that handle conversions if/when long double is changed to be IEEE
977 128-bit floating point.
978
979 @node Half-Precision
980 @section Half-Precision Floating Point
981 @cindex half-precision floating point
982 @cindex @code{__fp16} data type
983
984 On ARM targets, GCC supports half-precision (16-bit) floating point via
985 the @code{__fp16} type. You must enable this type explicitly
986 with the @option{-mfp16-format} command-line option in order to use it.
987
988 ARM supports two incompatible representations for half-precision
989 floating-point values. You must choose one of the representations and
990 use it consistently in your program.
991
992 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
993 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
994 There are 11 bits of significand precision, approximately 3
995 decimal digits.
996
997 Specifying @option{-mfp16-format=alternative} selects the ARM
998 alternative format. This representation is similar to the IEEE
999 format, but does not support infinities or NaNs. Instead, the range
1000 of exponents is extended, so that this format can represent normalized
1001 values in the range of @math{2^{-14}} to 131008.
1002
1003 The @code{__fp16} type is a storage format only. For purposes
1004 of arithmetic and other operations, @code{__fp16} values in C or C++
1005 expressions are automatically promoted to @code{float}. In addition,
1006 you cannot declare a function with a return value or parameters
1007 of type @code{__fp16}.
1008
1009 Note that conversions from @code{double} to @code{__fp16}
1010 involve an intermediate conversion to @code{float}. Because
1011 of rounding, this can sometimes produce a different result than a
1012 direct conversion.
1013
1014 ARM provides hardware support for conversions between
1015 @code{__fp16} and @code{float} values
1016 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1017 code using these hardware instructions if you compile with
1018 options to select an FPU that provides them;
1019 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1020 in addition to the @option{-mfp16-format} option to select
1021 a half-precision format.
1022
1023 Language-level support for the @code{__fp16} data type is
1024 independent of whether GCC generates code using hardware floating-point
1025 instructions. In cases where hardware support is not specified, GCC
1026 implements conversions between @code{__fp16} and @code{float} values
1027 as library calls.
1028
1029 @node Decimal Float
1030 @section Decimal Floating Types
1031 @cindex decimal floating types
1032 @cindex @code{_Decimal32} data type
1033 @cindex @code{_Decimal64} data type
1034 @cindex @code{_Decimal128} data type
1035 @cindex @code{df} integer suffix
1036 @cindex @code{dd} integer suffix
1037 @cindex @code{dl} integer suffix
1038 @cindex @code{DF} integer suffix
1039 @cindex @code{DD} integer suffix
1040 @cindex @code{DL} integer suffix
1041
1042 As an extension, GNU C supports decimal floating types as
1043 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1044 floating types in GCC will evolve as the draft technical report changes.
1045 Calling conventions for any target might also change. Not all targets
1046 support decimal floating types.
1047
1048 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1049 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1050 @code{float}, @code{double}, and @code{long double} whose radix is not
1051 specified by the C standard but is usually two.
1052
1053 Support for decimal floating types includes the arithmetic operators
1054 add, subtract, multiply, divide; unary arithmetic operators;
1055 relational operators; equality operators; and conversions to and from
1056 integer and other floating types. Use a suffix @samp{df} or
1057 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1058 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1059 @code{_Decimal128}.
1060
1061 GCC support of decimal float as specified by the draft technical report
1062 is incomplete:
1063
1064 @itemize @bullet
1065 @item
1066 When the value of a decimal floating type cannot be represented in the
1067 integer type to which it is being converted, the result is undefined
1068 rather than the result value specified by the draft technical report.
1069
1070 @item
1071 GCC does not provide the C library functionality associated with
1072 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1073 @file{wchar.h}, which must come from a separate C library implementation.
1074 Because of this the GNU C compiler does not define macro
1075 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1076 the technical report.
1077 @end itemize
1078
1079 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1080 are supported by the DWARF 2 debug information format.
1081
1082 @node Hex Floats
1083 @section Hex Floats
1084 @cindex hex floats
1085
1086 ISO C99 supports floating-point numbers written not only in the usual
1087 decimal notation, such as @code{1.55e1}, but also numbers such as
1088 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1089 supports this in C90 mode (except in some cases when strictly
1090 conforming) and in C++. In that format the
1091 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1092 mandatory. The exponent is a decimal number that indicates the power of
1093 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1094 @tex
1095 $1 {15\over16}$,
1096 @end tex
1097 @ifnottex
1098 1 15/16,
1099 @end ifnottex
1100 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1101 is the same as @code{1.55e1}.
1102
1103 Unlike for floating-point numbers in the decimal notation the exponent
1104 is always required in the hexadecimal notation. Otherwise the compiler
1105 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1106 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1107 extension for floating-point constants of type @code{float}.
1108
1109 @node Fixed-Point
1110 @section Fixed-Point Types
1111 @cindex fixed-point types
1112 @cindex @code{_Fract} data type
1113 @cindex @code{_Accum} data type
1114 @cindex @code{_Sat} data type
1115 @cindex @code{hr} fixed-suffix
1116 @cindex @code{r} fixed-suffix
1117 @cindex @code{lr} fixed-suffix
1118 @cindex @code{llr} fixed-suffix
1119 @cindex @code{uhr} fixed-suffix
1120 @cindex @code{ur} fixed-suffix
1121 @cindex @code{ulr} fixed-suffix
1122 @cindex @code{ullr} fixed-suffix
1123 @cindex @code{hk} fixed-suffix
1124 @cindex @code{k} fixed-suffix
1125 @cindex @code{lk} fixed-suffix
1126 @cindex @code{llk} fixed-suffix
1127 @cindex @code{uhk} fixed-suffix
1128 @cindex @code{uk} fixed-suffix
1129 @cindex @code{ulk} fixed-suffix
1130 @cindex @code{ullk} fixed-suffix
1131 @cindex @code{HR} fixed-suffix
1132 @cindex @code{R} fixed-suffix
1133 @cindex @code{LR} fixed-suffix
1134 @cindex @code{LLR} fixed-suffix
1135 @cindex @code{UHR} fixed-suffix
1136 @cindex @code{UR} fixed-suffix
1137 @cindex @code{ULR} fixed-suffix
1138 @cindex @code{ULLR} fixed-suffix
1139 @cindex @code{HK} fixed-suffix
1140 @cindex @code{K} fixed-suffix
1141 @cindex @code{LK} fixed-suffix
1142 @cindex @code{LLK} fixed-suffix
1143 @cindex @code{UHK} fixed-suffix
1144 @cindex @code{UK} fixed-suffix
1145 @cindex @code{ULK} fixed-suffix
1146 @cindex @code{ULLK} fixed-suffix
1147
1148 As an extension, GNU C supports fixed-point types as
1149 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1150 types in GCC will evolve as the draft technical report changes.
1151 Calling conventions for any target might also change. Not all targets
1152 support fixed-point types.
1153
1154 The fixed-point types are
1155 @code{short _Fract},
1156 @code{_Fract},
1157 @code{long _Fract},
1158 @code{long long _Fract},
1159 @code{unsigned short _Fract},
1160 @code{unsigned _Fract},
1161 @code{unsigned long _Fract},
1162 @code{unsigned long long _Fract},
1163 @code{_Sat short _Fract},
1164 @code{_Sat _Fract},
1165 @code{_Sat long _Fract},
1166 @code{_Sat long long _Fract},
1167 @code{_Sat unsigned short _Fract},
1168 @code{_Sat unsigned _Fract},
1169 @code{_Sat unsigned long _Fract},
1170 @code{_Sat unsigned long long _Fract},
1171 @code{short _Accum},
1172 @code{_Accum},
1173 @code{long _Accum},
1174 @code{long long _Accum},
1175 @code{unsigned short _Accum},
1176 @code{unsigned _Accum},
1177 @code{unsigned long _Accum},
1178 @code{unsigned long long _Accum},
1179 @code{_Sat short _Accum},
1180 @code{_Sat _Accum},
1181 @code{_Sat long _Accum},
1182 @code{_Sat long long _Accum},
1183 @code{_Sat unsigned short _Accum},
1184 @code{_Sat unsigned _Accum},
1185 @code{_Sat unsigned long _Accum},
1186 @code{_Sat unsigned long long _Accum}.
1187
1188 Fixed-point data values contain fractional and optional integral parts.
1189 The format of fixed-point data varies and depends on the target machine.
1190
1191 Support for fixed-point types includes:
1192 @itemize @bullet
1193 @item
1194 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1195 @item
1196 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1197 @item
1198 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1199 @item
1200 binary shift operators (@code{<<}, @code{>>})
1201 @item
1202 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1203 @item
1204 equality operators (@code{==}, @code{!=})
1205 @item
1206 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1207 @code{<<=}, @code{>>=})
1208 @item
1209 conversions to and from integer, floating-point, or fixed-point types
1210 @end itemize
1211
1212 Use a suffix in a fixed-point literal constant:
1213 @itemize
1214 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1215 @code{_Sat short _Fract}
1216 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1217 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1218 @code{_Sat long _Fract}
1219 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1220 @code{_Sat long long _Fract}
1221 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1222 @code{_Sat unsigned short _Fract}
1223 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1224 @code{_Sat unsigned _Fract}
1225 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1226 @code{_Sat unsigned long _Fract}
1227 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1228 and @code{_Sat unsigned long long _Fract}
1229 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1230 @code{_Sat short _Accum}
1231 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1232 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1233 @code{_Sat long _Accum}
1234 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1235 @code{_Sat long long _Accum}
1236 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1237 @code{_Sat unsigned short _Accum}
1238 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1239 @code{_Sat unsigned _Accum}
1240 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1241 @code{_Sat unsigned long _Accum}
1242 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1243 and @code{_Sat unsigned long long _Accum}
1244 @end itemize
1245
1246 GCC support of fixed-point types as specified by the draft technical report
1247 is incomplete:
1248
1249 @itemize @bullet
1250 @item
1251 Pragmas to control overflow and rounding behaviors are not implemented.
1252 @end itemize
1253
1254 Fixed-point types are supported by the DWARF 2 debug information format.
1255
1256 @node Named Address Spaces
1257 @section Named Address Spaces
1258 @cindex Named Address Spaces
1259
1260 As an extension, GNU C supports named address spaces as
1261 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1262 address spaces in GCC will evolve as the draft technical report
1263 changes. Calling conventions for any target might also change. At
1264 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1265 address spaces other than the generic address space.
1266
1267 Address space identifiers may be used exactly like any other C type
1268 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1269 document for more details.
1270
1271 @anchor{AVR Named Address Spaces}
1272 @subsection AVR Named Address Spaces
1273
1274 On the AVR target, there are several address spaces that can be used
1275 in order to put read-only data into the flash memory and access that
1276 data by means of the special instructions @code{LPM} or @code{ELPM}
1277 needed to read from flash.
1278
1279 Per default, any data including read-only data is located in RAM
1280 (the generic address space) so that non-generic address spaces are
1281 needed to locate read-only data in flash memory
1282 @emph{and} to generate the right instructions to access this data
1283 without using (inline) assembler code.
1284
1285 @table @code
1286 @item __flash
1287 @cindex @code{__flash} AVR Named Address Spaces
1288 The @code{__flash} qualifier locates data in the
1289 @code{.progmem.data} section. Data is read using the @code{LPM}
1290 instruction. Pointers to this address space are 16 bits wide.
1291
1292 @item __flash1
1293 @itemx __flash2
1294 @itemx __flash3
1295 @itemx __flash4
1296 @itemx __flash5
1297 @cindex @code{__flash1} AVR Named Address Spaces
1298 @cindex @code{__flash2} AVR Named Address Spaces
1299 @cindex @code{__flash3} AVR Named Address Spaces
1300 @cindex @code{__flash4} AVR Named Address Spaces
1301 @cindex @code{__flash5} AVR Named Address Spaces
1302 These are 16-bit address spaces locating data in section
1303 @code{.progmem@var{N}.data} where @var{N} refers to
1304 address space @code{__flash@var{N}}.
1305 The compiler sets the @code{RAMPZ} segment register appropriately
1306 before reading data by means of the @code{ELPM} instruction.
1307
1308 @item __memx
1309 @cindex @code{__memx} AVR Named Address Spaces
1310 This is a 24-bit address space that linearizes flash and RAM:
1311 If the high bit of the address is set, data is read from
1312 RAM using the lower two bytes as RAM address.
1313 If the high bit of the address is clear, data is read from flash
1314 with @code{RAMPZ} set according to the high byte of the address.
1315 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1316
1317 Objects in this address space are located in @code{.progmemx.data}.
1318 @end table
1319
1320 @b{Example}
1321
1322 @smallexample
1323 char my_read (const __flash char ** p)
1324 @{
1325 /* p is a pointer to RAM that points to a pointer to flash.
1326 The first indirection of p reads that flash pointer
1327 from RAM and the second indirection reads a char from this
1328 flash address. */
1329
1330 return **p;
1331 @}
1332
1333 /* Locate array[] in flash memory */
1334 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1335
1336 int i = 1;
1337
1338 int main (void)
1339 @{
1340 /* Return 17 by reading from flash memory */
1341 return array[array[i]];
1342 @}
1343 @end smallexample
1344
1345 @noindent
1346 For each named address space supported by avr-gcc there is an equally
1347 named but uppercase built-in macro defined.
1348 The purpose is to facilitate testing if respective address space
1349 support is available or not:
1350
1351 @smallexample
1352 #ifdef __FLASH
1353 const __flash int var = 1;
1354
1355 int read_var (void)
1356 @{
1357 return var;
1358 @}
1359 #else
1360 #include <avr/pgmspace.h> /* From AVR-LibC */
1361
1362 const int var PROGMEM = 1;
1363
1364 int read_var (void)
1365 @{
1366 return (int) pgm_read_word (&var);
1367 @}
1368 #endif /* __FLASH */
1369 @end smallexample
1370
1371 @noindent
1372 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1373 locates data in flash but
1374 accesses to these data read from generic address space, i.e.@:
1375 from RAM,
1376 so that you need special accessors like @code{pgm_read_byte}
1377 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1378 together with attribute @code{progmem}.
1379
1380 @noindent
1381 @b{Limitations and caveats}
1382
1383 @itemize
1384 @item
1385 Reading across the 64@tie{}KiB section boundary of
1386 the @code{__flash} or @code{__flash@var{N}} address spaces
1387 shows undefined behavior. The only address space that
1388 supports reading across the 64@tie{}KiB flash segment boundaries is
1389 @code{__memx}.
1390
1391 @item
1392 If you use one of the @code{__flash@var{N}} address spaces
1393 you must arrange your linker script to locate the
1394 @code{.progmem@var{N}.data} sections according to your needs.
1395
1396 @item
1397 Any data or pointers to the non-generic address spaces must
1398 be qualified as @code{const}, i.e.@: as read-only data.
1399 This still applies if the data in one of these address
1400 spaces like software version number or calibration lookup table are intended to
1401 be changed after load time by, say, a boot loader. In this case
1402 the right qualification is @code{const} @code{volatile} so that the compiler
1403 must not optimize away known values or insert them
1404 as immediates into operands of instructions.
1405
1406 @item
1407 The following code initializes a variable @code{pfoo}
1408 located in static storage with a 24-bit address:
1409 @smallexample
1410 extern const __memx char foo;
1411 const __memx void *pfoo = &foo;
1412 @end smallexample
1413
1414 @noindent
1415 Such code requires at least binutils 2.23, see
1416 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1417
1418 @end itemize
1419
1420 @subsection M32C Named Address Spaces
1421 @cindex @code{__far} M32C Named Address Spaces
1422
1423 On the M32C target, with the R8C and M16C CPU variants, variables
1424 qualified with @code{__far} are accessed using 32-bit addresses in
1425 order to access memory beyond the first 64@tie{}Ki bytes. If
1426 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1427 effect.
1428
1429 @subsection RL78 Named Address Spaces
1430 @cindex @code{__far} RL78 Named Address Spaces
1431
1432 On the RL78 target, variables qualified with @code{__far} are accessed
1433 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1434 addresses. Non-far variables are assumed to appear in the topmost
1435 64@tie{}KiB of the address space.
1436
1437 @subsection SPU Named Address Spaces
1438 @cindex @code{__ea} SPU Named Address Spaces
1439
1440 On the SPU target variables may be declared as
1441 belonging to another address space by qualifying the type with the
1442 @code{__ea} address space identifier:
1443
1444 @smallexample
1445 extern int __ea i;
1446 @end smallexample
1447
1448 @noindent
1449 The compiler generates special code to access the variable @code{i}.
1450 It may use runtime library
1451 support, or generate special machine instructions to access that address
1452 space.
1453
1454 @subsection x86 Named Address Spaces
1455 @cindex x86 named address spaces
1456
1457 On the x86 target, variables may be declared as being relative
1458 to the @code{%fs} or @code{%gs} segments.
1459
1460 @table @code
1461 @item __seg_fs
1462 @itemx __seg_gs
1463 @cindex @code{__seg_fs} x86 named address space
1464 @cindex @code{__seg_gs} x86 named address space
1465 The object is accessed with the respective segment override prefix.
1466
1467 The respective segment base must be set via some method specific to
1468 the operating system. Rather than require an expensive system call
1469 to retrieve the segment base, these address spaces are not considered
1470 to be subspaces of the generic (flat) address space. This means that
1471 explicit casts are required to convert pointers between these address
1472 spaces and the generic address space. In practice the application
1473 should cast to @code{uintptr_t} and apply the segment base offset
1474 that it installed previously.
1475
1476 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1477 defined when these address spaces are supported.
1478
1479 @item __seg_tls
1480 @cindex @code{__seg_tls} x86 named address space
1481 Some operating systems define either the @code{%fs} or @code{%gs}
1482 segment as the thread-local storage base for each thread. Objects
1483 within this address space are accessed with the appropriate
1484 segment override prefix.
1485
1486 The pointer located at address 0 within the segment contains the
1487 offset of the segment within the generic address space. Thus this
1488 address space is considered a subspace of the generic address space,
1489 and the known segment offset is applied when converting addresses
1490 to and from the generic address space.
1491
1492 The preprocessor symbol @code{__SEG_TLS} is defined when this
1493 address space is supported.
1494
1495 @end table
1496
1497 @node Zero Length
1498 @section Arrays of Length Zero
1499 @cindex arrays of length zero
1500 @cindex zero-length arrays
1501 @cindex length-zero arrays
1502 @cindex flexible array members
1503
1504 Zero-length arrays are allowed in GNU C@. They are very useful as the
1505 last element of a structure that is really a header for a variable-length
1506 object:
1507
1508 @smallexample
1509 struct line @{
1510 int length;
1511 char contents[0];
1512 @};
1513
1514 struct line *thisline = (struct line *)
1515 malloc (sizeof (struct line) + this_length);
1516 thisline->length = this_length;
1517 @end smallexample
1518
1519 In ISO C90, you would have to give @code{contents} a length of 1, which
1520 means either you waste space or complicate the argument to @code{malloc}.
1521
1522 In ISO C99, you would use a @dfn{flexible array member}, which is
1523 slightly different in syntax and semantics:
1524
1525 @itemize @bullet
1526 @item
1527 Flexible array members are written as @code{contents[]} without
1528 the @code{0}.
1529
1530 @item
1531 Flexible array members have incomplete type, and so the @code{sizeof}
1532 operator may not be applied. As a quirk of the original implementation
1533 of zero-length arrays, @code{sizeof} evaluates to zero.
1534
1535 @item
1536 Flexible array members may only appear as the last member of a
1537 @code{struct} that is otherwise non-empty.
1538
1539 @item
1540 A structure containing a flexible array member, or a union containing
1541 such a structure (possibly recursively), may not be a member of a
1542 structure or an element of an array. (However, these uses are
1543 permitted by GCC as extensions.)
1544 @end itemize
1545
1546 Non-empty initialization of zero-length
1547 arrays is treated like any case where there are more initializer
1548 elements than the array holds, in that a suitable warning about ``excess
1549 elements in array'' is given, and the excess elements (all of them, in
1550 this case) are ignored.
1551
1552 GCC allows static initialization of flexible array members.
1553 This is equivalent to defining a new structure containing the original
1554 structure followed by an array of sufficient size to contain the data.
1555 E.g.@: in the following, @code{f1} is constructed as if it were declared
1556 like @code{f2}.
1557
1558 @smallexample
1559 struct f1 @{
1560 int x; int y[];
1561 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1562
1563 struct f2 @{
1564 struct f1 f1; int data[3];
1565 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1566 @end smallexample
1567
1568 @noindent
1569 The convenience of this extension is that @code{f1} has the desired
1570 type, eliminating the need to consistently refer to @code{f2.f1}.
1571
1572 This has symmetry with normal static arrays, in that an array of
1573 unknown size is also written with @code{[]}.
1574
1575 Of course, this extension only makes sense if the extra data comes at
1576 the end of a top-level object, as otherwise we would be overwriting
1577 data at subsequent offsets. To avoid undue complication and confusion
1578 with initialization of deeply nested arrays, we simply disallow any
1579 non-empty initialization except when the structure is the top-level
1580 object. For example:
1581
1582 @smallexample
1583 struct foo @{ int x; int y[]; @};
1584 struct bar @{ struct foo z; @};
1585
1586 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1587 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1588 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1589 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1590 @end smallexample
1591
1592 @node Empty Structures
1593 @section Structures with No Members
1594 @cindex empty structures
1595 @cindex zero-size structures
1596
1597 GCC permits a C structure to have no members:
1598
1599 @smallexample
1600 struct empty @{
1601 @};
1602 @end smallexample
1603
1604 The structure has size zero. In C++, empty structures are part
1605 of the language. G++ treats empty structures as if they had a single
1606 member of type @code{char}.
1607
1608 @node Variable Length
1609 @section Arrays of Variable Length
1610 @cindex variable-length arrays
1611 @cindex arrays of variable length
1612 @cindex VLAs
1613
1614 Variable-length automatic arrays are allowed in ISO C99, and as an
1615 extension GCC accepts them in C90 mode and in C++. These arrays are
1616 declared like any other automatic arrays, but with a length that is not
1617 a constant expression. The storage is allocated at the point of
1618 declaration and deallocated when the block scope containing the declaration
1619 exits. For
1620 example:
1621
1622 @smallexample
1623 FILE *
1624 concat_fopen (char *s1, char *s2, char *mode)
1625 @{
1626 char str[strlen (s1) + strlen (s2) + 1];
1627 strcpy (str, s1);
1628 strcat (str, s2);
1629 return fopen (str, mode);
1630 @}
1631 @end smallexample
1632
1633 @cindex scope of a variable length array
1634 @cindex variable-length array scope
1635 @cindex deallocating variable length arrays
1636 Jumping or breaking out of the scope of the array name deallocates the
1637 storage. Jumping into the scope is not allowed; you get an error
1638 message for it.
1639
1640 @cindex variable-length array in a structure
1641 As an extension, GCC accepts variable-length arrays as a member of
1642 a structure or a union. For example:
1643
1644 @smallexample
1645 void
1646 foo (int n)
1647 @{
1648 struct S @{ int x[n]; @};
1649 @}
1650 @end smallexample
1651
1652 @cindex @code{alloca} vs variable-length arrays
1653 You can use the function @code{alloca} to get an effect much like
1654 variable-length arrays. The function @code{alloca} is available in
1655 many other C implementations (but not in all). On the other hand,
1656 variable-length arrays are more elegant.
1657
1658 There are other differences between these two methods. Space allocated
1659 with @code{alloca} exists until the containing @emph{function} returns.
1660 The space for a variable-length array is deallocated as soon as the array
1661 name's scope ends. (If you use both variable-length arrays and
1662 @code{alloca} in the same function, deallocation of a variable-length array
1663 also deallocates anything more recently allocated with @code{alloca}.)
1664
1665 You can also use variable-length arrays as arguments to functions:
1666
1667 @smallexample
1668 struct entry
1669 tester (int len, char data[len][len])
1670 @{
1671 /* @r{@dots{}} */
1672 @}
1673 @end smallexample
1674
1675 The length of an array is computed once when the storage is allocated
1676 and is remembered for the scope of the array in case you access it with
1677 @code{sizeof}.
1678
1679 If you want to pass the array first and the length afterward, you can
1680 use a forward declaration in the parameter list---another GNU extension.
1681
1682 @smallexample
1683 struct entry
1684 tester (int len; char data[len][len], int len)
1685 @{
1686 /* @r{@dots{}} */
1687 @}
1688 @end smallexample
1689
1690 @cindex parameter forward declaration
1691 The @samp{int len} before the semicolon is a @dfn{parameter forward
1692 declaration}, and it serves the purpose of making the name @code{len}
1693 known when the declaration of @code{data} is parsed.
1694
1695 You can write any number of such parameter forward declarations in the
1696 parameter list. They can be separated by commas or semicolons, but the
1697 last one must end with a semicolon, which is followed by the ``real''
1698 parameter declarations. Each forward declaration must match a ``real''
1699 declaration in parameter name and data type. ISO C99 does not support
1700 parameter forward declarations.
1701
1702 @node Variadic Macros
1703 @section Macros with a Variable Number of Arguments.
1704 @cindex variable number of arguments
1705 @cindex macro with variable arguments
1706 @cindex rest argument (in macro)
1707 @cindex variadic macros
1708
1709 In the ISO C standard of 1999, a macro can be declared to accept a
1710 variable number of arguments much as a function can. The syntax for
1711 defining the macro is similar to that of a function. Here is an
1712 example:
1713
1714 @smallexample
1715 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1716 @end smallexample
1717
1718 @noindent
1719 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1720 such a macro, it represents the zero or more tokens until the closing
1721 parenthesis that ends the invocation, including any commas. This set of
1722 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1723 wherever it appears. See the CPP manual for more information.
1724
1725 GCC has long supported variadic macros, and used a different syntax that
1726 allowed you to give a name to the variable arguments just like any other
1727 argument. Here is an example:
1728
1729 @smallexample
1730 #define debug(format, args...) fprintf (stderr, format, args)
1731 @end smallexample
1732
1733 @noindent
1734 This is in all ways equivalent to the ISO C example above, but arguably
1735 more readable and descriptive.
1736
1737 GNU CPP has two further variadic macro extensions, and permits them to
1738 be used with either of the above forms of macro definition.
1739
1740 In standard C, you are not allowed to leave the variable argument out
1741 entirely; but you are allowed to pass an empty argument. For example,
1742 this invocation is invalid in ISO C, because there is no comma after
1743 the string:
1744
1745 @smallexample
1746 debug ("A message")
1747 @end smallexample
1748
1749 GNU CPP permits you to completely omit the variable arguments in this
1750 way. In the above examples, the compiler would complain, though since
1751 the expansion of the macro still has the extra comma after the format
1752 string.
1753
1754 To help solve this problem, CPP behaves specially for variable arguments
1755 used with the token paste operator, @samp{##}. If instead you write
1756
1757 @smallexample
1758 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1759 @end smallexample
1760
1761 @noindent
1762 and if the variable arguments are omitted or empty, the @samp{##}
1763 operator causes the preprocessor to remove the comma before it. If you
1764 do provide some variable arguments in your macro invocation, GNU CPP
1765 does not complain about the paste operation and instead places the
1766 variable arguments after the comma. Just like any other pasted macro
1767 argument, these arguments are not macro expanded.
1768
1769 @node Escaped Newlines
1770 @section Slightly Looser Rules for Escaped Newlines
1771 @cindex escaped newlines
1772 @cindex newlines (escaped)
1773
1774 The preprocessor treatment of escaped newlines is more relaxed
1775 than that specified by the C90 standard, which requires the newline
1776 to immediately follow a backslash.
1777 GCC's implementation allows whitespace in the form
1778 of spaces, horizontal and vertical tabs, and form feeds between the
1779 backslash and the subsequent newline. The preprocessor issues a
1780 warning, but treats it as a valid escaped newline and combines the two
1781 lines to form a single logical line. This works within comments and
1782 tokens, as well as between tokens. Comments are @emph{not} treated as
1783 whitespace for the purposes of this relaxation, since they have not
1784 yet been replaced with spaces.
1785
1786 @node Subscripting
1787 @section Non-Lvalue Arrays May Have Subscripts
1788 @cindex subscripting
1789 @cindex arrays, non-lvalue
1790
1791 @cindex subscripting and function values
1792 In ISO C99, arrays that are not lvalues still decay to pointers, and
1793 may be subscripted, although they may not be modified or used after
1794 the next sequence point and the unary @samp{&} operator may not be
1795 applied to them. As an extension, GNU C allows such arrays to be
1796 subscripted in C90 mode, though otherwise they do not decay to
1797 pointers outside C99 mode. For example,
1798 this is valid in GNU C though not valid in C90:
1799
1800 @smallexample
1801 @group
1802 struct foo @{int a[4];@};
1803
1804 struct foo f();
1805
1806 bar (int index)
1807 @{
1808 return f().a[index];
1809 @}
1810 @end group
1811 @end smallexample
1812
1813 @node Pointer Arith
1814 @section Arithmetic on @code{void}- and Function-Pointers
1815 @cindex void pointers, arithmetic
1816 @cindex void, size of pointer to
1817 @cindex function pointers, arithmetic
1818 @cindex function, size of pointer to
1819
1820 In GNU C, addition and subtraction operations are supported on pointers to
1821 @code{void} and on pointers to functions. This is done by treating the
1822 size of a @code{void} or of a function as 1.
1823
1824 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1825 and on function types, and returns 1.
1826
1827 @opindex Wpointer-arith
1828 The option @option{-Wpointer-arith} requests a warning if these extensions
1829 are used.
1830
1831 @node Pointers to Arrays
1832 @section Pointers to Arrays with Qualifiers Work as Expected
1833 @cindex pointers to arrays
1834 @cindex const qualifier
1835
1836 In GNU C, pointers to arrays with qualifiers work similar to pointers
1837 to other qualified types. For example, a value of type @code{int (*)[5]}
1838 can be used to initialize a variable of type @code{const int (*)[5]}.
1839 These types are incompatible in ISO C because the @code{const} qualifier
1840 is formally attached to the element type of the array and not the
1841 array itself.
1842
1843 @smallexample
1844 extern void
1845 transpose (int N, int M, double out[M][N], const double in[N][M]);
1846 double x[3][2];
1847 double y[2][3];
1848 @r{@dots{}}
1849 transpose(3, 2, y, x);
1850 @end smallexample
1851
1852 @node Initializers
1853 @section Non-Constant Initializers
1854 @cindex initializers, non-constant
1855 @cindex non-constant initializers
1856
1857 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1858 automatic variable are not required to be constant expressions in GNU C@.
1859 Here is an example of an initializer with run-time varying elements:
1860
1861 @smallexample
1862 foo (float f, float g)
1863 @{
1864 float beat_freqs[2] = @{ f-g, f+g @};
1865 /* @r{@dots{}} */
1866 @}
1867 @end smallexample
1868
1869 @node Compound Literals
1870 @section Compound Literals
1871 @cindex constructor expressions
1872 @cindex initializations in expressions
1873 @cindex structures, constructor expression
1874 @cindex expressions, constructor
1875 @cindex compound literals
1876 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1877
1878 ISO C99 supports compound literals. A compound literal looks like
1879 a cast containing an initializer. Its value is an object of the
1880 type specified in the cast, containing the elements specified in
1881 the initializer; it is an lvalue. As an extension, GCC supports
1882 compound literals in C90 mode and in C++, though the semantics are
1883 somewhat different in C++.
1884
1885 Usually, the specified type is a structure. Assume that
1886 @code{struct foo} and @code{structure} are declared as shown:
1887
1888 @smallexample
1889 struct foo @{int a; char b[2];@} structure;
1890 @end smallexample
1891
1892 @noindent
1893 Here is an example of constructing a @code{struct foo} with a compound literal:
1894
1895 @smallexample
1896 structure = ((struct foo) @{x + y, 'a', 0@});
1897 @end smallexample
1898
1899 @noindent
1900 This is equivalent to writing the following:
1901
1902 @smallexample
1903 @{
1904 struct foo temp = @{x + y, 'a', 0@};
1905 structure = temp;
1906 @}
1907 @end smallexample
1908
1909 You can also construct an array, though this is dangerous in C++, as
1910 explained below. If all the elements of the compound literal are
1911 (made up of) simple constant expressions, suitable for use in
1912 initializers of objects of static storage duration, then the compound
1913 literal can be coerced to a pointer to its first element and used in
1914 such an initializer, as shown here:
1915
1916 @smallexample
1917 char **foo = (char *[]) @{ "x", "y", "z" @};
1918 @end smallexample
1919
1920 Compound literals for scalar types and union types are
1921 also allowed, but then the compound literal is equivalent
1922 to a cast.
1923
1924 As a GNU extension, GCC allows initialization of objects with static storage
1925 duration by compound literals (which is not possible in ISO C99, because
1926 the initializer is not a constant).
1927 It is handled as if the object is initialized only with the bracket
1928 enclosed list if the types of the compound literal and the object match.
1929 The initializer list of the compound literal must be constant.
1930 If the object being initialized has array type of unknown size, the size is
1931 determined by compound literal size.
1932
1933 @smallexample
1934 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1935 static int y[] = (int []) @{1, 2, 3@};
1936 static int z[] = (int [3]) @{1@};
1937 @end smallexample
1938
1939 @noindent
1940 The above lines are equivalent to the following:
1941 @smallexample
1942 static struct foo x = @{1, 'a', 'b'@};
1943 static int y[] = @{1, 2, 3@};
1944 static int z[] = @{1, 0, 0@};
1945 @end smallexample
1946
1947 In C, a compound literal designates an unnamed object with static or
1948 automatic storage duration. In C++, a compound literal designates a
1949 temporary object, which only lives until the end of its
1950 full-expression. As a result, well-defined C code that takes the
1951 address of a subobject of a compound literal can be undefined in C++,
1952 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1953 For instance, if the array compound literal example above appeared
1954 inside a function, any subsequent use of @samp{foo} in C++ has
1955 undefined behavior because the lifetime of the array ends after the
1956 declaration of @samp{foo}.
1957
1958 As an optimization, the C++ compiler sometimes gives array compound
1959 literals longer lifetimes: when the array either appears outside a
1960 function or has const-qualified type. If @samp{foo} and its
1961 initializer had elements of @samp{char *const} type rather than
1962 @samp{char *}, or if @samp{foo} were a global variable, the array
1963 would have static storage duration. But it is probably safest just to
1964 avoid the use of array compound literals in code compiled as C++.
1965
1966 @node Designated Inits
1967 @section Designated Initializers
1968 @cindex initializers with labeled elements
1969 @cindex labeled elements in initializers
1970 @cindex case labels in initializers
1971 @cindex designated initializers
1972
1973 Standard C90 requires the elements of an initializer to appear in a fixed
1974 order, the same as the order of the elements in the array or structure
1975 being initialized.
1976
1977 In ISO C99 you can give the elements in any order, specifying the array
1978 indices or structure field names they apply to, and GNU C allows this as
1979 an extension in C90 mode as well. This extension is not
1980 implemented in GNU C++.
1981
1982 To specify an array index, write
1983 @samp{[@var{index}] =} before the element value. For example,
1984
1985 @smallexample
1986 int a[6] = @{ [4] = 29, [2] = 15 @};
1987 @end smallexample
1988
1989 @noindent
1990 is equivalent to
1991
1992 @smallexample
1993 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1994 @end smallexample
1995
1996 @noindent
1997 The index values must be constant expressions, even if the array being
1998 initialized is automatic.
1999
2000 An alternative syntax for this that has been obsolete since GCC 2.5 but
2001 GCC still accepts is to write @samp{[@var{index}]} before the element
2002 value, with no @samp{=}.
2003
2004 To initialize a range of elements to the same value, write
2005 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2006 extension. For example,
2007
2008 @smallexample
2009 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2010 @end smallexample
2011
2012 @noindent
2013 If the value in it has side-effects, the side-effects happen only once,
2014 not for each initialized field by the range initializer.
2015
2016 @noindent
2017 Note that the length of the array is the highest value specified
2018 plus one.
2019
2020 In a structure initializer, specify the name of a field to initialize
2021 with @samp{.@var{fieldname} =} before the element value. For example,
2022 given the following structure,
2023
2024 @smallexample
2025 struct point @{ int x, y; @};
2026 @end smallexample
2027
2028 @noindent
2029 the following initialization
2030
2031 @smallexample
2032 struct point p = @{ .y = yvalue, .x = xvalue @};
2033 @end smallexample
2034
2035 @noindent
2036 is equivalent to
2037
2038 @smallexample
2039 struct point p = @{ xvalue, yvalue @};
2040 @end smallexample
2041
2042 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2043 @samp{@var{fieldname}:}, as shown here:
2044
2045 @smallexample
2046 struct point p = @{ y: yvalue, x: xvalue @};
2047 @end smallexample
2048
2049 Omitted field members are implicitly initialized the same as objects
2050 that have static storage duration.
2051
2052 @cindex designators
2053 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2054 @dfn{designator}. You can also use a designator (or the obsolete colon
2055 syntax) when initializing a union, to specify which element of the union
2056 should be used. For example,
2057
2058 @smallexample
2059 union foo @{ int i; double d; @};
2060
2061 union foo f = @{ .d = 4 @};
2062 @end smallexample
2063
2064 @noindent
2065 converts 4 to a @code{double} to store it in the union using
2066 the second element. By contrast, casting 4 to type @code{union foo}
2067 stores it into the union as the integer @code{i}, since it is
2068 an integer. (@xref{Cast to Union}.)
2069
2070 You can combine this technique of naming elements with ordinary C
2071 initialization of successive elements. Each initializer element that
2072 does not have a designator applies to the next consecutive element of the
2073 array or structure. For example,
2074
2075 @smallexample
2076 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2077 @end smallexample
2078
2079 @noindent
2080 is equivalent to
2081
2082 @smallexample
2083 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2084 @end smallexample
2085
2086 Labeling the elements of an array initializer is especially useful
2087 when the indices are characters or belong to an @code{enum} type.
2088 For example:
2089
2090 @smallexample
2091 int whitespace[256]
2092 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2093 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2094 @end smallexample
2095
2096 @cindex designator lists
2097 You can also write a series of @samp{.@var{fieldname}} and
2098 @samp{[@var{index}]} designators before an @samp{=} to specify a
2099 nested subobject to initialize; the list is taken relative to the
2100 subobject corresponding to the closest surrounding brace pair. For
2101 example, with the @samp{struct point} declaration above:
2102
2103 @smallexample
2104 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2105 @end smallexample
2106
2107 @noindent
2108 If the same field is initialized multiple times, it has the value from
2109 the last initialization. If any such overridden initialization has
2110 side-effect, it is unspecified whether the side-effect happens or not.
2111 Currently, GCC discards them and issues a warning.
2112
2113 @node Case Ranges
2114 @section Case Ranges
2115 @cindex case ranges
2116 @cindex ranges in case statements
2117
2118 You can specify a range of consecutive values in a single @code{case} label,
2119 like this:
2120
2121 @smallexample
2122 case @var{low} ... @var{high}:
2123 @end smallexample
2124
2125 @noindent
2126 This has the same effect as the proper number of individual @code{case}
2127 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2128
2129 This feature is especially useful for ranges of ASCII character codes:
2130
2131 @smallexample
2132 case 'A' ... 'Z':
2133 @end smallexample
2134
2135 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2136 it may be parsed wrong when you use it with integer values. For example,
2137 write this:
2138
2139 @smallexample
2140 case 1 ... 5:
2141 @end smallexample
2142
2143 @noindent
2144 rather than this:
2145
2146 @smallexample
2147 case 1...5:
2148 @end smallexample
2149
2150 @node Cast to Union
2151 @section Cast to a Union Type
2152 @cindex cast to a union
2153 @cindex union, casting to a
2154
2155 A cast to union type is similar to other casts, except that the type
2156 specified is a union type. You can specify the type either with
2157 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2158 a constructor, not a cast, and hence does not yield an lvalue like
2159 normal casts. (@xref{Compound Literals}.)
2160
2161 The types that may be cast to the union type are those of the members
2162 of the union. Thus, given the following union and variables:
2163
2164 @smallexample
2165 union foo @{ int i; double d; @};
2166 int x;
2167 double y;
2168 @end smallexample
2169
2170 @noindent
2171 both @code{x} and @code{y} can be cast to type @code{union foo}.
2172
2173 Using the cast as the right-hand side of an assignment to a variable of
2174 union type is equivalent to storing in a member of the union:
2175
2176 @smallexample
2177 union foo u;
2178 /* @r{@dots{}} */
2179 u = (union foo) x @equiv{} u.i = x
2180 u = (union foo) y @equiv{} u.d = y
2181 @end smallexample
2182
2183 You can also use the union cast as a function argument:
2184
2185 @smallexample
2186 void hack (union foo);
2187 /* @r{@dots{}} */
2188 hack ((union foo) x);
2189 @end smallexample
2190
2191 @node Mixed Declarations
2192 @section Mixed Declarations and Code
2193 @cindex mixed declarations and code
2194 @cindex declarations, mixed with code
2195 @cindex code, mixed with declarations
2196
2197 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2198 within compound statements. As an extension, GNU C also allows this in
2199 C90 mode. For example, you could do:
2200
2201 @smallexample
2202 int i;
2203 /* @r{@dots{}} */
2204 i++;
2205 int j = i + 2;
2206 @end smallexample
2207
2208 Each identifier is visible from where it is declared until the end of
2209 the enclosing block.
2210
2211 @node Function Attributes
2212 @section Declaring Attributes of Functions
2213 @cindex function attributes
2214 @cindex declaring attributes of functions
2215 @cindex @code{volatile} applied to function
2216 @cindex @code{const} applied to function
2217
2218 In GNU C, you can use function attributes to declare certain things
2219 about functions called in your program which help the compiler
2220 optimize calls and check your code more carefully. For example, you
2221 can use attributes to declare that a function never returns
2222 (@code{noreturn}), returns a value depending only on its arguments
2223 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2224
2225 You can also use attributes to control memory placement, code
2226 generation options or call/return conventions within the function
2227 being annotated. Many of these attributes are target-specific. For
2228 example, many targets support attributes for defining interrupt
2229 handler functions, which typically must follow special register usage
2230 and return conventions.
2231
2232 Function attributes are introduced by the @code{__attribute__} keyword
2233 on a declaration, followed by an attribute specification inside double
2234 parentheses. You can specify multiple attributes in a declaration by
2235 separating them by commas within the double parentheses or by
2236 immediately following an attribute declaration with another attribute
2237 declaration. @xref{Attribute Syntax}, for the exact rules on
2238 attribute syntax and placement.
2239
2240 GCC also supports attributes on
2241 variable declarations (@pxref{Variable Attributes}),
2242 labels (@pxref{Label Attributes}),
2243 enumerators (@pxref{Enumerator Attributes}),
2244 and types (@pxref{Type Attributes}).
2245
2246 There is some overlap between the purposes of attributes and pragmas
2247 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2248 found convenient to use @code{__attribute__} to achieve a natural
2249 attachment of attributes to their corresponding declarations, whereas
2250 @code{#pragma} is of use for compatibility with other compilers
2251 or constructs that do not naturally form part of the grammar.
2252
2253 In addition to the attributes documented here,
2254 GCC plugins may provide their own attributes.
2255
2256 @menu
2257 * Common Function Attributes::
2258 * AArch64 Function Attributes::
2259 * ARC Function Attributes::
2260 * ARM Function Attributes::
2261 * AVR Function Attributes::
2262 * Blackfin Function Attributes::
2263 * CR16 Function Attributes::
2264 * Epiphany Function Attributes::
2265 * H8/300 Function Attributes::
2266 * IA-64 Function Attributes::
2267 * M32C Function Attributes::
2268 * M32R/D Function Attributes::
2269 * m68k Function Attributes::
2270 * MCORE Function Attributes::
2271 * MeP Function Attributes::
2272 * MicroBlaze Function Attributes::
2273 * Microsoft Windows Function Attributes::
2274 * MIPS Function Attributes::
2275 * MSP430 Function Attributes::
2276 * NDS32 Function Attributes::
2277 * Nios II Function Attributes::
2278 * PowerPC Function Attributes::
2279 * RL78 Function Attributes::
2280 * RX Function Attributes::
2281 * S/390 Function Attributes::
2282 * SH Function Attributes::
2283 * SPU Function Attributes::
2284 * Symbian OS Function Attributes::
2285 * Visium Function Attributes::
2286 * x86 Function Attributes::
2287 * Xstormy16 Function Attributes::
2288 @end menu
2289
2290 @node Common Function Attributes
2291 @subsection Common Function Attributes
2292
2293 The following attributes are supported on most targets.
2294
2295 @table @code
2296 @c Keep this table alphabetized by attribute name. Treat _ as space.
2297
2298 @item alias ("@var{target}")
2299 @cindex @code{alias} function attribute
2300 The @code{alias} attribute causes the declaration to be emitted as an
2301 alias for another symbol, which must be specified. For instance,
2302
2303 @smallexample
2304 void __f () @{ /* @r{Do something.} */; @}
2305 void f () __attribute__ ((weak, alias ("__f")));
2306 @end smallexample
2307
2308 @noindent
2309 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2310 mangled name for the target must be used. It is an error if @samp{__f}
2311 is not defined in the same translation unit.
2312
2313 This attribute requires assembler and object file support,
2314 and may not be available on all targets.
2315
2316 @item aligned (@var{alignment})
2317 @cindex @code{aligned} function attribute
2318 This attribute specifies a minimum alignment for the function,
2319 measured in bytes.
2320
2321 You cannot use this attribute to decrease the alignment of a function,
2322 only to increase it. However, when you explicitly specify a function
2323 alignment this overrides the effect of the
2324 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2325 function.
2326
2327 Note that the effectiveness of @code{aligned} attributes may be
2328 limited by inherent limitations in your linker. On many systems, the
2329 linker is only able to arrange for functions to be aligned up to a
2330 certain maximum alignment. (For some linkers, the maximum supported
2331 alignment may be very very small.) See your linker documentation for
2332 further information.
2333
2334 The @code{aligned} attribute can also be used for variables and fields
2335 (@pxref{Variable Attributes}.)
2336
2337 @item alloc_align
2338 @cindex @code{alloc_align} function attribute
2339 The @code{alloc_align} attribute is used to tell the compiler that the
2340 function return value points to memory, where the returned pointer minimum
2341 alignment is given by one of the functions parameters. GCC uses this
2342 information to improve pointer alignment analysis.
2343
2344 The function parameter denoting the allocated alignment is specified by
2345 one integer argument, whose number is the argument of the attribute.
2346 Argument numbering starts at one.
2347
2348 For instance,
2349
2350 @smallexample
2351 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2352 @end smallexample
2353
2354 @noindent
2355 declares that @code{my_memalign} returns memory with minimum alignment
2356 given by parameter 1.
2357
2358 @item alloc_size
2359 @cindex @code{alloc_size} function attribute
2360 The @code{alloc_size} attribute is used to tell the compiler that the
2361 function return value points to memory, where the size is given by
2362 one or two of the functions parameters. GCC uses this
2363 information to improve the correctness of @code{__builtin_object_size}.
2364
2365 The function parameter(s) denoting the allocated size are specified by
2366 one or two integer arguments supplied to the attribute. The allocated size
2367 is either the value of the single function argument specified or the product
2368 of the two function arguments specified. Argument numbering starts at
2369 one.
2370
2371 For instance,
2372
2373 @smallexample
2374 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2375 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2376 @end smallexample
2377
2378 @noindent
2379 declares that @code{my_calloc} returns memory of the size given by
2380 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2381 of the size given by parameter 2.
2382
2383 @item always_inline
2384 @cindex @code{always_inline} function attribute
2385 Generally, functions are not inlined unless optimization is specified.
2386 For functions declared inline, this attribute inlines the function
2387 independent of any restrictions that otherwise apply to inlining.
2388 Failure to inline such a function is diagnosed as an error.
2389 Note that if such a function is called indirectly the compiler may
2390 or may not inline it depending on optimization level and a failure
2391 to inline an indirect call may or may not be diagnosed.
2392
2393 @item artificial
2394 @cindex @code{artificial} function attribute
2395 This attribute is useful for small inline wrappers that if possible
2396 should appear during debugging as a unit. Depending on the debug
2397 info format it either means marking the function as artificial
2398 or using the caller location for all instructions within the inlined
2399 body.
2400
2401 @item assume_aligned
2402 @cindex @code{assume_aligned} function attribute
2403 The @code{assume_aligned} attribute is used to tell the compiler that the
2404 function return value points to memory, where the returned pointer minimum
2405 alignment is given by the first argument.
2406 If the attribute has two arguments, the second argument is misalignment offset.
2407
2408 For instance
2409
2410 @smallexample
2411 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2412 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2413 @end smallexample
2414
2415 @noindent
2416 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2417 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2418 to 8.
2419
2420 @item bnd_instrument
2421 @cindex @code{bnd_instrument} function attribute
2422 The @code{bnd_instrument} attribute on functions is used to inform the
2423 compiler that the function should be instrumented when compiled
2424 with the @option{-fchkp-instrument-marked-only} option.
2425
2426 @item bnd_legacy
2427 @cindex @code{bnd_legacy} function attribute
2428 @cindex Pointer Bounds Checker attributes
2429 The @code{bnd_legacy} attribute on functions is used to inform the
2430 compiler that the function should not be instrumented when compiled
2431 with the @option{-fcheck-pointer-bounds} option.
2432
2433 @item cold
2434 @cindex @code{cold} function attribute
2435 The @code{cold} attribute on functions is used to inform the compiler that
2436 the function is unlikely to be executed. The function is optimized for
2437 size rather than speed and on many targets it is placed into a special
2438 subsection of the text section so all cold functions appear close together,
2439 improving code locality of non-cold parts of program. The paths leading
2440 to calls of cold functions within code are marked as unlikely by the branch
2441 prediction mechanism. It is thus useful to mark functions used to handle
2442 unlikely conditions, such as @code{perror}, as cold to improve optimization
2443 of hot functions that do call marked functions in rare occasions.
2444
2445 When profile feedback is available, via @option{-fprofile-use}, cold functions
2446 are automatically detected and this attribute is ignored.
2447
2448 @item const
2449 @cindex @code{const} function attribute
2450 @cindex functions that have no side effects
2451 Many functions do not examine any values except their arguments, and
2452 have no effects except the return value. Basically this is just slightly
2453 more strict class than the @code{pure} attribute below, since function is not
2454 allowed to read global memory.
2455
2456 @cindex pointer arguments
2457 Note that a function that has pointer arguments and examines the data
2458 pointed to must @emph{not} be declared @code{const}. Likewise, a
2459 function that calls a non-@code{const} function usually must not be
2460 @code{const}. It does not make sense for a @code{const} function to
2461 return @code{void}.
2462
2463 @item constructor
2464 @itemx destructor
2465 @itemx constructor (@var{priority})
2466 @itemx destructor (@var{priority})
2467 @cindex @code{constructor} function attribute
2468 @cindex @code{destructor} function attribute
2469 The @code{constructor} attribute causes the function to be called
2470 automatically before execution enters @code{main ()}. Similarly, the
2471 @code{destructor} attribute causes the function to be called
2472 automatically after @code{main ()} completes or @code{exit ()} is
2473 called. Functions with these attributes are useful for
2474 initializing data that is used implicitly during the execution of
2475 the program.
2476
2477 You may provide an optional integer priority to control the order in
2478 which constructor and destructor functions are run. A constructor
2479 with a smaller priority number runs before a constructor with a larger
2480 priority number; the opposite relationship holds for destructors. So,
2481 if you have a constructor that allocates a resource and a destructor
2482 that deallocates the same resource, both functions typically have the
2483 same priority. The priorities for constructor and destructor
2484 functions are the same as those specified for namespace-scope C++
2485 objects (@pxref{C++ Attributes}).
2486
2487 These attributes are not currently implemented for Objective-C@.
2488
2489 @item deprecated
2490 @itemx deprecated (@var{msg})
2491 @cindex @code{deprecated} function attribute
2492 The @code{deprecated} attribute results in a warning if the function
2493 is used anywhere in the source file. This is useful when identifying
2494 functions that are expected to be removed in a future version of a
2495 program. The warning also includes the location of the declaration
2496 of the deprecated function, to enable users to easily find further
2497 information about why the function is deprecated, or what they should
2498 do instead. Note that the warnings only occurs for uses:
2499
2500 @smallexample
2501 int old_fn () __attribute__ ((deprecated));
2502 int old_fn ();
2503 int (*fn_ptr)() = old_fn;
2504 @end smallexample
2505
2506 @noindent
2507 results in a warning on line 3 but not line 2. The optional @var{msg}
2508 argument, which must be a string, is printed in the warning if
2509 present.
2510
2511 The @code{deprecated} attribute can also be used for variables and
2512 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2513
2514 @item error ("@var{message}")
2515 @itemx warning ("@var{message}")
2516 @cindex @code{error} function attribute
2517 @cindex @code{warning} function attribute
2518 If the @code{error} or @code{warning} attribute
2519 is used on a function declaration and a call to such a function
2520 is not eliminated through dead code elimination or other optimizations,
2521 an error or warning (respectively) that includes @var{message} is diagnosed.
2522 This is useful
2523 for compile-time checking, especially together with @code{__builtin_constant_p}
2524 and inline functions where checking the inline function arguments is not
2525 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2526
2527 While it is possible to leave the function undefined and thus invoke
2528 a link failure (to define the function with
2529 a message in @code{.gnu.warning*} section),
2530 when using these attributes the problem is diagnosed
2531 earlier and with exact location of the call even in presence of inline
2532 functions or when not emitting debugging information.
2533
2534 @item externally_visible
2535 @cindex @code{externally_visible} function attribute
2536 This attribute, attached to a global variable or function, nullifies
2537 the effect of the @option{-fwhole-program} command-line option, so the
2538 object remains visible outside the current compilation unit.
2539
2540 If @option{-fwhole-program} is used together with @option{-flto} and
2541 @command{gold} is used as the linker plugin,
2542 @code{externally_visible} attributes are automatically added to functions
2543 (not variable yet due to a current @command{gold} issue)
2544 that are accessed outside of LTO objects according to resolution file
2545 produced by @command{gold}.
2546 For other linkers that cannot generate resolution file,
2547 explicit @code{externally_visible} attributes are still necessary.
2548
2549 @item flatten
2550 @cindex @code{flatten} function attribute
2551 Generally, inlining into a function is limited. For a function marked with
2552 this attribute, every call inside this function is inlined, if possible.
2553 Whether the function itself is considered for inlining depends on its size and
2554 the current inlining parameters.
2555
2556 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2557 @cindex @code{format} function attribute
2558 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2559 @opindex Wformat
2560 The @code{format} attribute specifies that a function takes @code{printf},
2561 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2562 should be type-checked against a format string. For example, the
2563 declaration:
2564
2565 @smallexample
2566 extern int
2567 my_printf (void *my_object, const char *my_format, ...)
2568 __attribute__ ((format (printf, 2, 3)));
2569 @end smallexample
2570
2571 @noindent
2572 causes the compiler to check the arguments in calls to @code{my_printf}
2573 for consistency with the @code{printf} style format string argument
2574 @code{my_format}.
2575
2576 The parameter @var{archetype} determines how the format string is
2577 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2578 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2579 @code{strfmon}. (You can also use @code{__printf__},
2580 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2581 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2582 @code{ms_strftime} are also present.
2583 @var{archetype} values such as @code{printf} refer to the formats accepted
2584 by the system's C runtime library,
2585 while values prefixed with @samp{gnu_} always refer
2586 to the formats accepted by the GNU C Library. On Microsoft Windows
2587 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2588 @file{msvcrt.dll} library.
2589 The parameter @var{string-index}
2590 specifies which argument is the format string argument (starting
2591 from 1), while @var{first-to-check} is the number of the first
2592 argument to check against the format string. For functions
2593 where the arguments are not available to be checked (such as
2594 @code{vprintf}), specify the third parameter as zero. In this case the
2595 compiler only checks the format string for consistency. For
2596 @code{strftime} formats, the third parameter is required to be zero.
2597 Since non-static C++ methods have an implicit @code{this} argument, the
2598 arguments of such methods should be counted from two, not one, when
2599 giving values for @var{string-index} and @var{first-to-check}.
2600
2601 In the example above, the format string (@code{my_format}) is the second
2602 argument of the function @code{my_print}, and the arguments to check
2603 start with the third argument, so the correct parameters for the format
2604 attribute are 2 and 3.
2605
2606 @opindex ffreestanding
2607 @opindex fno-builtin
2608 The @code{format} attribute allows you to identify your own functions
2609 that take format strings as arguments, so that GCC can check the
2610 calls to these functions for errors. The compiler always (unless
2611 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2612 for the standard library functions @code{printf}, @code{fprintf},
2613 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2614 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2615 warnings are requested (using @option{-Wformat}), so there is no need to
2616 modify the header file @file{stdio.h}. In C99 mode, the functions
2617 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2618 @code{vsscanf} are also checked. Except in strictly conforming C
2619 standard modes, the X/Open function @code{strfmon} is also checked as
2620 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2621 @xref{C Dialect Options,,Options Controlling C Dialect}.
2622
2623 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2624 recognized in the same context. Declarations including these format attributes
2625 are parsed for correct syntax, however the result of checking of such format
2626 strings is not yet defined, and is not carried out by this version of the
2627 compiler.
2628
2629 The target may also provide additional types of format checks.
2630 @xref{Target Format Checks,,Format Checks Specific to Particular
2631 Target Machines}.
2632
2633 @item format_arg (@var{string-index})
2634 @cindex @code{format_arg} function attribute
2635 @opindex Wformat-nonliteral
2636 The @code{format_arg} attribute specifies that a function takes a format
2637 string for a @code{printf}, @code{scanf}, @code{strftime} or
2638 @code{strfmon} style function and modifies it (for example, to translate
2639 it into another language), so the result can be passed to a
2640 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2641 function (with the remaining arguments to the format function the same
2642 as they would have been for the unmodified string). For example, the
2643 declaration:
2644
2645 @smallexample
2646 extern char *
2647 my_dgettext (char *my_domain, const char *my_format)
2648 __attribute__ ((format_arg (2)));
2649 @end smallexample
2650
2651 @noindent
2652 causes the compiler to check the arguments in calls to a @code{printf},
2653 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2654 format string argument is a call to the @code{my_dgettext} function, for
2655 consistency with the format string argument @code{my_format}. If the
2656 @code{format_arg} attribute had not been specified, all the compiler
2657 could tell in such calls to format functions would be that the format
2658 string argument is not constant; this would generate a warning when
2659 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2660 without the attribute.
2661
2662 The parameter @var{string-index} specifies which argument is the format
2663 string argument (starting from one). Since non-static C++ methods have
2664 an implicit @code{this} argument, the arguments of such methods should
2665 be counted from two.
2666
2667 The @code{format_arg} attribute allows you to identify your own
2668 functions that modify format strings, so that GCC can check the
2669 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2670 type function whose operands are a call to one of your own function.
2671 The compiler always treats @code{gettext}, @code{dgettext}, and
2672 @code{dcgettext} in this manner except when strict ISO C support is
2673 requested by @option{-ansi} or an appropriate @option{-std} option, or
2674 @option{-ffreestanding} or @option{-fno-builtin}
2675 is used. @xref{C Dialect Options,,Options
2676 Controlling C Dialect}.
2677
2678 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2679 @code{NSString} reference for compatibility with the @code{format} attribute
2680 above.
2681
2682 The target may also allow additional types in @code{format-arg} attributes.
2683 @xref{Target Format Checks,,Format Checks Specific to Particular
2684 Target Machines}.
2685
2686 @item gnu_inline
2687 @cindex @code{gnu_inline} function attribute
2688 This attribute should be used with a function that is also declared
2689 with the @code{inline} keyword. It directs GCC to treat the function
2690 as if it were defined in gnu90 mode even when compiling in C99 or
2691 gnu99 mode.
2692
2693 If the function is declared @code{extern}, then this definition of the
2694 function is used only for inlining. In no case is the function
2695 compiled as a standalone function, not even if you take its address
2696 explicitly. Such an address becomes an external reference, as if you
2697 had only declared the function, and had not defined it. This has
2698 almost the effect of a macro. The way to use this is to put a
2699 function definition in a header file with this attribute, and put
2700 another copy of the function, without @code{extern}, in a library
2701 file. The definition in the header file causes most calls to the
2702 function to be inlined. If any uses of the function remain, they
2703 refer to the single copy in the library. Note that the two
2704 definitions of the functions need not be precisely the same, although
2705 if they do not have the same effect your program may behave oddly.
2706
2707 In C, if the function is neither @code{extern} nor @code{static}, then
2708 the function is compiled as a standalone function, as well as being
2709 inlined where possible.
2710
2711 This is how GCC traditionally handled functions declared
2712 @code{inline}. Since ISO C99 specifies a different semantics for
2713 @code{inline}, this function attribute is provided as a transition
2714 measure and as a useful feature in its own right. This attribute is
2715 available in GCC 4.1.3 and later. It is available if either of the
2716 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2717 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2718 Function is As Fast As a Macro}.
2719
2720 In C++, this attribute does not depend on @code{extern} in any way,
2721 but it still requires the @code{inline} keyword to enable its special
2722 behavior.
2723
2724 @item hot
2725 @cindex @code{hot} function attribute
2726 The @code{hot} attribute on a function is used to inform the compiler that
2727 the function is a hot spot of the compiled program. The function is
2728 optimized more aggressively and on many targets it is placed into a special
2729 subsection of the text section so all hot functions appear close together,
2730 improving locality.
2731
2732 When profile feedback is available, via @option{-fprofile-use}, hot functions
2733 are automatically detected and this attribute is ignored.
2734
2735 @item ifunc ("@var{resolver}")
2736 @cindex @code{ifunc} function attribute
2737 @cindex indirect functions
2738 @cindex functions that are dynamically resolved
2739 The @code{ifunc} attribute is used to mark a function as an indirect
2740 function using the STT_GNU_IFUNC symbol type extension to the ELF
2741 standard. This allows the resolution of the symbol value to be
2742 determined dynamically at load time, and an optimized version of the
2743 routine can be selected for the particular processor or other system
2744 characteristics determined then. To use this attribute, first define
2745 the implementation functions available, and a resolver function that
2746 returns a pointer to the selected implementation function. The
2747 implementation functions' declarations must match the API of the
2748 function being implemented, the resolver's declaration is be a
2749 function returning pointer to void function returning void:
2750
2751 @smallexample
2752 void *my_memcpy (void *dst, const void *src, size_t len)
2753 @{
2754 @dots{}
2755 @}
2756
2757 static void (*resolve_memcpy (void)) (void)
2758 @{
2759 return my_memcpy; // we'll just always select this routine
2760 @}
2761 @end smallexample
2762
2763 @noindent
2764 The exported header file declaring the function the user calls would
2765 contain:
2766
2767 @smallexample
2768 extern void *memcpy (void *, const void *, size_t);
2769 @end smallexample
2770
2771 @noindent
2772 allowing the user to call this as a regular function, unaware of the
2773 implementation. Finally, the indirect function needs to be defined in
2774 the same translation unit as the resolver function:
2775
2776 @smallexample
2777 void *memcpy (void *, const void *, size_t)
2778 __attribute__ ((ifunc ("resolve_memcpy")));
2779 @end smallexample
2780
2781 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2782 and GNU C Library version 2.11.1 are required to use this feature.
2783
2784 @item interrupt
2785 @itemx interrupt_handler
2786 Many GCC back ends support attributes to indicate that a function is
2787 an interrupt handler, which tells the compiler to generate function
2788 entry and exit sequences that differ from those from regular
2789 functions. The exact syntax and behavior are target-specific;
2790 refer to the following subsections for details.
2791
2792 @item leaf
2793 @cindex @code{leaf} function attribute
2794 Calls to external functions with this attribute must return to the current
2795 compilation unit only by return or by exception handling. In particular, leaf
2796 functions are not allowed to call callback function passed to it from the current
2797 compilation unit or directly call functions exported by the unit or longjmp
2798 into the unit. Leaf function might still call functions from other compilation
2799 units and thus they are not necessarily leaf in the sense that they contain no
2800 function calls at all.
2801
2802 The attribute is intended for library functions to improve dataflow analysis.
2803 The compiler takes the hint that any data not escaping the current compilation unit can
2804 not be used or modified by the leaf function. For example, the @code{sin} function
2805 is a leaf function, but @code{qsort} is not.
2806
2807 Note that leaf functions might invoke signals and signal handlers might be
2808 defined in the current compilation unit and use static variables. The only
2809 compliant way to write such a signal handler is to declare such variables
2810 @code{volatile}.
2811
2812 The attribute has no effect on functions defined within the current compilation
2813 unit. This is to allow easy merging of multiple compilation units into one,
2814 for example, by using the link-time optimization. For this reason the
2815 attribute is not allowed on types to annotate indirect calls.
2816
2817
2818 @item malloc
2819 @cindex @code{malloc} function attribute
2820 @cindex functions that behave like malloc
2821 This tells the compiler that a function is @code{malloc}-like, i.e.,
2822 that the pointer @var{P} returned by the function cannot alias any
2823 other pointer valid when the function returns, and moreover no
2824 pointers to valid objects occur in any storage addressed by @var{P}.
2825
2826 Using this attribute can improve optimization. Functions like
2827 @code{malloc} and @code{calloc} have this property because they return
2828 a pointer to uninitialized or zeroed-out storage. However, functions
2829 like @code{realloc} do not have this property, as they can return a
2830 pointer to storage containing pointers.
2831
2832 @item no_icf
2833 @cindex @code{no_icf} function attribute
2834 This function attribute prevents a functions from being merged with another
2835 semantically equivalent function.
2836
2837 @item no_instrument_function
2838 @cindex @code{no_instrument_function} function attribute
2839 @opindex finstrument-functions
2840 If @option{-finstrument-functions} is given, profiling function calls are
2841 generated at entry and exit of most user-compiled functions.
2842 Functions with this attribute are not so instrumented.
2843
2844 @item no_reorder
2845 @cindex @code{no_reorder} function attribute
2846 Do not reorder functions or variables marked @code{no_reorder}
2847 against each other or top level assembler statements the executable.
2848 The actual order in the program will depend on the linker command
2849 line. Static variables marked like this are also not removed.
2850 This has a similar effect
2851 as the @option{-fno-toplevel-reorder} option, but only applies to the
2852 marked symbols.
2853
2854 @item no_sanitize_address
2855 @itemx no_address_safety_analysis
2856 @cindex @code{no_sanitize_address} function attribute
2857 The @code{no_sanitize_address} attribute on functions is used
2858 to inform the compiler that it should not instrument memory accesses
2859 in the function when compiling with the @option{-fsanitize=address} option.
2860 The @code{no_address_safety_analysis} is a deprecated alias of the
2861 @code{no_sanitize_address} attribute, new code should use
2862 @code{no_sanitize_address}.
2863
2864 @item no_sanitize_thread
2865 @cindex @code{no_sanitize_thread} function attribute
2866 The @code{no_sanitize_thread} attribute on functions is used
2867 to inform the compiler that it should not instrument memory accesses
2868 in the function when compiling with the @option{-fsanitize=thread} option.
2869
2870 @item no_sanitize_undefined
2871 @cindex @code{no_sanitize_undefined} function attribute
2872 The @code{no_sanitize_undefined} attribute on functions is used
2873 to inform the compiler that it should not check for undefined behavior
2874 in the function when compiling with the @option{-fsanitize=undefined} option.
2875
2876 @item no_split_stack
2877 @cindex @code{no_split_stack} function attribute
2878 @opindex fsplit-stack
2879 If @option{-fsplit-stack} is given, functions have a small
2880 prologue which decides whether to split the stack. Functions with the
2881 @code{no_split_stack} attribute do not have that prologue, and thus
2882 may run with only a small amount of stack space available.
2883
2884 @item noclone
2885 @cindex @code{noclone} function attribute
2886 This function attribute prevents a function from being considered for
2887 cloning---a mechanism that produces specialized copies of functions
2888 and which is (currently) performed by interprocedural constant
2889 propagation.
2890
2891 @item noinline
2892 @cindex @code{noinline} function attribute
2893 This function attribute prevents a function from being considered for
2894 inlining.
2895 @c Don't enumerate the optimizations by name here; we try to be
2896 @c future-compatible with this mechanism.
2897 If the function does not have side-effects, there are optimizations
2898 other than inlining that cause function calls to be optimized away,
2899 although the function call is live. To keep such calls from being
2900 optimized away, put
2901 @smallexample
2902 asm ("");
2903 @end smallexample
2904
2905 @noindent
2906 (@pxref{Extended Asm}) in the called function, to serve as a special
2907 side-effect.
2908
2909 @item nonnull (@var{arg-index}, @dots{})
2910 @cindex @code{nonnull} function attribute
2911 @cindex functions with non-null pointer arguments
2912 The @code{nonnull} attribute specifies that some function parameters should
2913 be non-null pointers. For instance, the declaration:
2914
2915 @smallexample
2916 extern void *
2917 my_memcpy (void *dest, const void *src, size_t len)
2918 __attribute__((nonnull (1, 2)));
2919 @end smallexample
2920
2921 @noindent
2922 causes the compiler to check that, in calls to @code{my_memcpy},
2923 arguments @var{dest} and @var{src} are non-null. If the compiler
2924 determines that a null pointer is passed in an argument slot marked
2925 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2926 is issued. The compiler may also choose to make optimizations based
2927 on the knowledge that certain function arguments will never be null.
2928
2929 If no argument index list is given to the @code{nonnull} attribute,
2930 all pointer arguments are marked as non-null. To illustrate, the
2931 following declaration is equivalent to the previous example:
2932
2933 @smallexample
2934 extern void *
2935 my_memcpy (void *dest, const void *src, size_t len)
2936 __attribute__((nonnull));
2937 @end smallexample
2938
2939 @item noreturn
2940 @cindex @code{noreturn} function attribute
2941 @cindex functions that never return
2942 A few standard library functions, such as @code{abort} and @code{exit},
2943 cannot return. GCC knows this automatically. Some programs define
2944 their own functions that never return. You can declare them
2945 @code{noreturn} to tell the compiler this fact. For example,
2946
2947 @smallexample
2948 @group
2949 void fatal () __attribute__ ((noreturn));
2950
2951 void
2952 fatal (/* @r{@dots{}} */)
2953 @{
2954 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2955 exit (1);
2956 @}
2957 @end group
2958 @end smallexample
2959
2960 The @code{noreturn} keyword tells the compiler to assume that
2961 @code{fatal} cannot return. It can then optimize without regard to what
2962 would happen if @code{fatal} ever did return. This makes slightly
2963 better code. More importantly, it helps avoid spurious warnings of
2964 uninitialized variables.
2965
2966 The @code{noreturn} keyword does not affect the exceptional path when that
2967 applies: a @code{noreturn}-marked function may still return to the caller
2968 by throwing an exception or calling @code{longjmp}.
2969
2970 Do not assume that registers saved by the calling function are
2971 restored before calling the @code{noreturn} function.
2972
2973 It does not make sense for a @code{noreturn} function to have a return
2974 type other than @code{void}.
2975
2976 @item nothrow
2977 @cindex @code{nothrow} function attribute
2978 The @code{nothrow} attribute is used to inform the compiler that a
2979 function cannot throw an exception. For example, most functions in
2980 the standard C library can be guaranteed not to throw an exception
2981 with the notable exceptions of @code{qsort} and @code{bsearch} that
2982 take function pointer arguments.
2983
2984 @item noplt
2985 @cindex @code{noplt} function attribute
2986 The @code{noplt} attribute is the counterpart to option @option{-fno-plt} and
2987 does not use PLT for calls to functions marked with this attribute in position
2988 independent code.
2989
2990 @smallexample
2991 @group
2992 /* Externally defined function foo. */
2993 int foo () __attribute__ ((noplt));
2994
2995 int
2996 main (/* @r{@dots{}} */)
2997 @{
2998 /* @r{@dots{}} */
2999 foo ();
3000 /* @r{@dots{}} */
3001 @}
3002 @end group
3003 @end smallexample
3004
3005 The @code{noplt} attribute on function foo tells the compiler to assume that
3006 the function foo is externally defined and the call to foo must avoid the PLT
3007 in position independent code.
3008
3009 Additionally, a few targets also convert calls to those functions that are
3010 marked to not use the PLT to use the GOT instead for non-position independent
3011 code.
3012
3013 @item optimize
3014 @cindex @code{optimize} function attribute
3015 The @code{optimize} attribute is used to specify that a function is to
3016 be compiled with different optimization options than specified on the
3017 command line. Arguments can either be numbers or strings. Numbers
3018 are assumed to be an optimization level. Strings that begin with
3019 @code{O} are assumed to be an optimization option, while other options
3020 are assumed to be used with a @code{-f} prefix. You can also use the
3021 @samp{#pragma GCC optimize} pragma to set the optimization options
3022 that affect more than one function.
3023 @xref{Function Specific Option Pragmas}, for details about the
3024 @samp{#pragma GCC optimize} pragma.
3025
3026 This can be used for instance to have frequently-executed functions
3027 compiled with more aggressive optimization options that produce faster
3028 and larger code, while other functions can be compiled with less
3029 aggressive options.
3030
3031 @item pure
3032 @cindex @code{pure} function attribute
3033 @cindex functions that have no side effects
3034 Many functions have no effects except the return value and their
3035 return value depends only on the parameters and/or global variables.
3036 Such a function can be subject
3037 to common subexpression elimination and loop optimization just as an
3038 arithmetic operator would be. These functions should be declared
3039 with the attribute @code{pure}. For example,
3040
3041 @smallexample
3042 int square (int) __attribute__ ((pure));
3043 @end smallexample
3044
3045 @noindent
3046 says that the hypothetical function @code{square} is safe to call
3047 fewer times than the program says.
3048
3049 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3050 Interesting non-pure functions are functions with infinite loops or those
3051 depending on volatile memory or other system resource, that may change between
3052 two consecutive calls (such as @code{feof} in a multithreading environment).
3053
3054 @item returns_nonnull
3055 @cindex @code{returns_nonnull} function attribute
3056 The @code{returns_nonnull} attribute specifies that the function
3057 return value should be a non-null pointer. For instance, the declaration:
3058
3059 @smallexample
3060 extern void *
3061 mymalloc (size_t len) __attribute__((returns_nonnull));
3062 @end smallexample
3063
3064 @noindent
3065 lets the compiler optimize callers based on the knowledge
3066 that the return value will never be null.
3067
3068 @item returns_twice
3069 @cindex @code{returns_twice} function attribute
3070 @cindex functions that return more than once
3071 The @code{returns_twice} attribute tells the compiler that a function may
3072 return more than one time. The compiler ensures that all registers
3073 are dead before calling such a function and emits a warning about
3074 the variables that may be clobbered after the second return from the
3075 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3076 The @code{longjmp}-like counterpart of such function, if any, might need
3077 to be marked with the @code{noreturn} attribute.
3078
3079 @item section ("@var{section-name}")
3080 @cindex @code{section} function attribute
3081 @cindex functions in arbitrary sections
3082 Normally, the compiler places the code it generates in the @code{text} section.
3083 Sometimes, however, you need additional sections, or you need certain
3084 particular functions to appear in special sections. The @code{section}
3085 attribute specifies that a function lives in a particular section.
3086 For example, the declaration:
3087
3088 @smallexample
3089 extern void foobar (void) __attribute__ ((section ("bar")));
3090 @end smallexample
3091
3092 @noindent
3093 puts the function @code{foobar} in the @code{bar} section.
3094
3095 Some file formats do not support arbitrary sections so the @code{section}
3096 attribute is not available on all platforms.
3097 If you need to map the entire contents of a module to a particular
3098 section, consider using the facilities of the linker instead.
3099
3100 @item sentinel
3101 @cindex @code{sentinel} function attribute
3102 This function attribute ensures that a parameter in a function call is
3103 an explicit @code{NULL}. The attribute is only valid on variadic
3104 functions. By default, the sentinel is located at position zero, the
3105 last parameter of the function call. If an optional integer position
3106 argument P is supplied to the attribute, the sentinel must be located at
3107 position P counting backwards from the end of the argument list.
3108
3109 @smallexample
3110 __attribute__ ((sentinel))
3111 is equivalent to
3112 __attribute__ ((sentinel(0)))
3113 @end smallexample
3114
3115 The attribute is automatically set with a position of 0 for the built-in
3116 functions @code{execl} and @code{execlp}. The built-in function
3117 @code{execle} has the attribute set with a position of 1.
3118
3119 A valid @code{NULL} in this context is defined as zero with any pointer
3120 type. If your system defines the @code{NULL} macro with an integer type
3121 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3122 with a copy that redefines NULL appropriately.
3123
3124 The warnings for missing or incorrect sentinels are enabled with
3125 @option{-Wformat}.
3126
3127 @item stack_protect
3128 @cindex @code{stack_protect} function attribute
3129 This function attribute make a stack protection of the function if
3130 flags @option{fstack-protector} or @option{fstack-protector-strong}
3131 or @option{fstack-protector-explicit} are set.
3132
3133 @item target_clones (@var{options})
3134 @cindex @code{target_clones} function attribute
3135 The @code{target_clones} attribute is used to specify that a function is to
3136 be cloned into multiple versions compiled with different target options
3137 than specified on the command line. The supported options and restrictions
3138 are the same as for @code{target} attribute.
3139
3140 For instance on an x86, you could compile a function with
3141 @code{target_clones("sse4.1,avx")}. It will create 2 function clones,
3142 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3143 At the function call it will create resolver @code{ifunc}, that will
3144 dynamically call a clone suitable for current architecture.
3145
3146 @item target (@var{options})
3147 @cindex @code{target} function attribute
3148 Multiple target back ends implement the @code{target} attribute
3149 to specify that a function is to
3150 be compiled with different target options than specified on the
3151 command line. This can be used for instance to have functions
3152 compiled with a different ISA (instruction set architecture) than the
3153 default. You can also use the @samp{#pragma GCC target} pragma to set
3154 more than one function to be compiled with specific target options.
3155 @xref{Function Specific Option Pragmas}, for details about the
3156 @samp{#pragma GCC target} pragma.
3157
3158 For instance, on an x86, you could declare one function with the
3159 @code{target("sse4.1,arch=core2")} attribute and another with
3160 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3161 compiling the first function with @option{-msse4.1} and
3162 @option{-march=core2} options, and the second function with
3163 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3164 to make sure that a function is only invoked on a machine that
3165 supports the particular ISA it is compiled for (for example by using
3166 @code{cpuid} on x86 to determine what feature bits and architecture
3167 family are used).
3168
3169 @smallexample
3170 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3171 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3172 @end smallexample
3173
3174 You can either use multiple
3175 strings separated by commas to specify multiple options,
3176 or separate the options with a comma (@samp{,}) within a single string.
3177
3178 The options supported are specific to each target; refer to @ref{x86
3179 Function Attributes}, @ref{PowerPC Function Attributes},
3180 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3181 for details.
3182
3183 @item unused
3184 @cindex @code{unused} function attribute
3185 This attribute, attached to a function, means that the function is meant
3186 to be possibly unused. GCC does not produce a warning for this
3187 function.
3188
3189 @item used
3190 @cindex @code{used} function attribute
3191 This attribute, attached to a function, means that code must be emitted
3192 for the function even if it appears that the function is not referenced.
3193 This is useful, for example, when the function is referenced only in
3194 inline assembly.
3195
3196 When applied to a member function of a C++ class template, the
3197 attribute also means that the function is instantiated if the
3198 class itself is instantiated.
3199
3200 @item visibility ("@var{visibility_type}")
3201 @cindex @code{visibility} function attribute
3202 This attribute affects the linkage of the declaration to which it is attached.
3203 There are four supported @var{visibility_type} values: default,
3204 hidden, protected or internal visibility.
3205
3206 @smallexample
3207 void __attribute__ ((visibility ("protected")))
3208 f () @{ /* @r{Do something.} */; @}
3209 int i __attribute__ ((visibility ("hidden")));
3210 @end smallexample
3211
3212 The possible values of @var{visibility_type} correspond to the
3213 visibility settings in the ELF gABI.
3214
3215 @table @code
3216 @c keep this list of visibilities in alphabetical order.
3217
3218 @item default
3219 Default visibility is the normal case for the object file format.
3220 This value is available for the visibility attribute to override other
3221 options that may change the assumed visibility of entities.
3222
3223 On ELF, default visibility means that the declaration is visible to other
3224 modules and, in shared libraries, means that the declared entity may be
3225 overridden.
3226
3227 On Darwin, default visibility means that the declaration is visible to
3228 other modules.
3229
3230 Default visibility corresponds to ``external linkage'' in the language.
3231
3232 @item hidden
3233 Hidden visibility indicates that the entity declared has a new
3234 form of linkage, which we call ``hidden linkage''. Two
3235 declarations of an object with hidden linkage refer to the same object
3236 if they are in the same shared object.
3237
3238 @item internal
3239 Internal visibility is like hidden visibility, but with additional
3240 processor specific semantics. Unless otherwise specified by the
3241 psABI, GCC defines internal visibility to mean that a function is
3242 @emph{never} called from another module. Compare this with hidden
3243 functions which, while they cannot be referenced directly by other
3244 modules, can be referenced indirectly via function pointers. By
3245 indicating that a function cannot be called from outside the module,
3246 GCC may for instance omit the load of a PIC register since it is known
3247 that the calling function loaded the correct value.
3248
3249 @item protected
3250 Protected visibility is like default visibility except that it
3251 indicates that references within the defining module bind to the
3252 definition in that module. That is, the declared entity cannot be
3253 overridden by another module.
3254
3255 @end table
3256
3257 All visibilities are supported on many, but not all, ELF targets
3258 (supported when the assembler supports the @samp{.visibility}
3259 pseudo-op). Default visibility is supported everywhere. Hidden
3260 visibility is supported on Darwin targets.
3261
3262 The visibility attribute should be applied only to declarations that
3263 would otherwise have external linkage. The attribute should be applied
3264 consistently, so that the same entity should not be declared with
3265 different settings of the attribute.
3266
3267 In C++, the visibility attribute applies to types as well as functions
3268 and objects, because in C++ types have linkage. A class must not have
3269 greater visibility than its non-static data member types and bases,
3270 and class members default to the visibility of their class. Also, a
3271 declaration without explicit visibility is limited to the visibility
3272 of its type.
3273
3274 In C++, you can mark member functions and static member variables of a
3275 class with the visibility attribute. This is useful if you know a
3276 particular method or static member variable should only be used from
3277 one shared object; then you can mark it hidden while the rest of the
3278 class has default visibility. Care must be taken to avoid breaking
3279 the One Definition Rule; for example, it is usually not useful to mark
3280 an inline method as hidden without marking the whole class as hidden.
3281
3282 A C++ namespace declaration can also have the visibility attribute.
3283
3284 @smallexample
3285 namespace nspace1 __attribute__ ((visibility ("protected")))
3286 @{ /* @r{Do something.} */; @}
3287 @end smallexample
3288
3289 This attribute applies only to the particular namespace body, not to
3290 other definitions of the same namespace; it is equivalent to using
3291 @samp{#pragma GCC visibility} before and after the namespace
3292 definition (@pxref{Visibility Pragmas}).
3293
3294 In C++, if a template argument has limited visibility, this
3295 restriction is implicitly propagated to the template instantiation.
3296 Otherwise, template instantiations and specializations default to the
3297 visibility of their template.
3298
3299 If both the template and enclosing class have explicit visibility, the
3300 visibility from the template is used.
3301
3302 @item warn_unused_result
3303 @cindex @code{warn_unused_result} function attribute
3304 The @code{warn_unused_result} attribute causes a warning to be emitted
3305 if a caller of the function with this attribute does not use its
3306 return value. This is useful for functions where not checking
3307 the result is either a security problem or always a bug, such as
3308 @code{realloc}.
3309
3310 @smallexample
3311 int fn () __attribute__ ((warn_unused_result));
3312 int foo ()
3313 @{
3314 if (fn () < 0) return -1;
3315 fn ();
3316 return 0;
3317 @}
3318 @end smallexample
3319
3320 @noindent
3321 results in warning on line 5.
3322
3323 @item weak
3324 @cindex @code{weak} function attribute
3325 The @code{weak} attribute causes the declaration to be emitted as a weak
3326 symbol rather than a global. This is primarily useful in defining
3327 library functions that can be overridden in user code, though it can
3328 also be used with non-function declarations. Weak symbols are supported
3329 for ELF targets, and also for a.out targets when using the GNU assembler
3330 and linker.
3331
3332 @item weakref
3333 @itemx weakref ("@var{target}")
3334 @cindex @code{weakref} function attribute
3335 The @code{weakref} attribute marks a declaration as a weak reference.
3336 Without arguments, it should be accompanied by an @code{alias} attribute
3337 naming the target symbol. Optionally, the @var{target} may be given as
3338 an argument to @code{weakref} itself. In either case, @code{weakref}
3339 implicitly marks the declaration as @code{weak}. Without a
3340 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3341 @code{weakref} is equivalent to @code{weak}.
3342
3343 @smallexample
3344 static int x() __attribute__ ((weakref ("y")));
3345 /* is equivalent to... */
3346 static int x() __attribute__ ((weak, weakref, alias ("y")));
3347 /* and to... */
3348 static int x() __attribute__ ((weakref));
3349 static int x() __attribute__ ((alias ("y")));
3350 @end smallexample
3351
3352 A weak reference is an alias that does not by itself require a
3353 definition to be given for the target symbol. If the target symbol is
3354 only referenced through weak references, then it becomes a @code{weak}
3355 undefined symbol. If it is directly referenced, however, then such
3356 strong references prevail, and a definition is required for the
3357 symbol, not necessarily in the same translation unit.
3358
3359 The effect is equivalent to moving all references to the alias to a
3360 separate translation unit, renaming the alias to the aliased symbol,
3361 declaring it as weak, compiling the two separate translation units and
3362 performing a reloadable link on them.
3363
3364 At present, a declaration to which @code{weakref} is attached can
3365 only be @code{static}.
3366
3367 @item lower
3368 @itemx upper
3369 @itemx either
3370 @cindex lower memory region on the MSP430
3371 @cindex upper memory region on the MSP430
3372 @cindex either memory region on the MSP430
3373 On the MSP430 target these attributes can be used to specify whether
3374 the function or variable should be placed into low memory, high
3375 memory, or the placement should be left to the linker to decide. The
3376 attributes are only significant if compiling for the MSP430X
3377 architecture.
3378
3379 The attributes work in conjunction with a linker script that has been
3380 augmented to specify where to place sections with a @code{.lower} and
3381 a @code{.upper} prefix. So for example as well as placing the
3382 @code{.data} section the script would also specify the placement of a
3383 @code{.lower.data} and a @code{.upper.data} section. The intention
3384 being that @code{lower} sections are placed into a small but easier to
3385 access memory region and the upper sections are placed into a larger, but
3386 slower to access region.
3387
3388 The @code{either} attribute is special. It tells the linker to place
3389 the object into the corresponding @code{lower} section if there is
3390 room for it. If there is insufficient room then the object is placed
3391 into the corresponding @code{upper} section instead. Note - the
3392 placement algorithm is not very sophisticated. It will not attempt to
3393 find an optimal packing of the @code{lower} sections. It just makes
3394 one pass over the objects and does the best that it can. Using the
3395 @option{-ffunction-sections} and @option{-fdata-sections} command line
3396 options can help the packing however, since they produce smaller,
3397 easier to pack regions.
3398
3399 @item reentrant
3400 On the MSP430 a function can be given the @code{reentant} attribute.
3401 This makes the function disable interrupts upon entry and enable
3402 interrupts upon exit. Reentrant functions cannot be @code{naked}.
3403
3404 @item critical
3405 On the MSP430 a function can be given the @code{critical} attribute.
3406 This makes the function disable interrupts upon entry and restore the
3407 previous interrupt enabled/disabled state upon exit. A function
3408 cannot have both the @code{reentrant} and @code{critical} attributes.
3409 Critical functions cannot be @code{naked}.
3410
3411 @item wakeup
3412 On the MSP430 a function can be given the @code{wakeup} attribute.
3413 Such a function must also have the @code{interrupt} attribute. When a
3414 function with the @code{wakeup} attribute exists the processor will be
3415 woken up from any low-power state in which it may be residing.
3416
3417 @end table
3418
3419 @c This is the end of the target-independent attribute table
3420
3421 @node AArch64 Function Attributes
3422 @subsection AArch64 Function Attributes
3423
3424 The following target-specific function attributes are available for the
3425 AArch64 target. For the most part, these options mirror the behavior of
3426 similar command-line options (@pxref{AArch64 Options}), but on a
3427 per-function basis.
3428
3429 @table @code
3430 @item general-regs-only
3431 @cindex @code{general-regs-only} function attribute, AArch64
3432 Indicates that no floating-point or Advanced SIMD registers should be
3433 used when generating code for this function. If the function explicitly
3434 uses floating-point code, then the compiler gives an error. This is
3435 the same behavior as that of the command-line option
3436 @option{-mgeneral-regs-only}.
3437
3438 @item fix-cortex-a53-835769
3439 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3440 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3441 applied to this function. To explicitly disable the workaround for this
3442 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3443 This corresponds to the behavior of the command line options
3444 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3445
3446 @item cmodel=
3447 @cindex @code{cmodel=} function attribute, AArch64
3448 Indicates that code should be generated for a particular code model for
3449 this function. The behavior and permissible arguments are the same as
3450 for the command line option @option{-mcmodel=}.
3451
3452 @item strict-align
3453 @cindex @code{strict-align} function attribute, AArch64
3454 Indicates that the compiler should not assume that unaligned memory references
3455 are handled by the system. The behavior is the same as for the command-line
3456 option @option{-mstrict-align}.
3457
3458 @item omit-leaf-frame-pointer
3459 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3460 Indicates that the frame pointer should be omitted for a leaf function call.
3461 To keep the frame pointer, the inverse attribute
3462 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3463 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3464 and @option{-mno-omit-leaf-frame-pointer}.
3465
3466 @item tls-dialect=
3467 @cindex @code{tls-dialect=} function attribute, AArch64
3468 Specifies the TLS dialect to use for this function. The behavior and
3469 permissible arguments are the same as for the command-line option
3470 @option{-mtls-dialect=}.
3471
3472 @item arch=
3473 @cindex @code{arch=} function attribute, AArch64
3474 Specifies the architecture version and architectural extensions to use
3475 for this function. The behavior and permissible arguments are the same as
3476 for the @option{-march=} command-line option.
3477
3478 @item tune=
3479 @cindex @code{tune=} function attribute, AArch64
3480 Specifies the core for which to tune the performance of this function.
3481 The behavior and permissible arguments are the same as for the @option{-mtune=}
3482 command-line option.
3483
3484 @item cpu=
3485 @cindex @code{cpu=} function attribute, AArch64
3486 Specifies the core for which to tune the performance of this function and also
3487 whose architectural features to use. The behavior and valid arguments are the
3488 same as for the @option{-mcpu=} command-line option.
3489
3490 @end table
3491
3492 The above target attributes can be specified as follows:
3493
3494 @smallexample
3495 __attribute__((target("@var{attr-string}")))
3496 int
3497 f (int a)
3498 @{
3499 return a + 5;
3500 @}
3501 @end smallexample
3502
3503 where @code{@var{attr-string}} is one of the attribute strings specified above.
3504
3505 Additionally, the architectural extension string may be specified on its
3506 own. This can be used to turn on and off particular architectural extensions
3507 without having to specify a particular architecture version or core. Example:
3508
3509 @smallexample
3510 __attribute__((target("+crc+nocrypto")))
3511 int
3512 foo (int a)
3513 @{
3514 return a + 5;
3515 @}
3516 @end smallexample
3517
3518 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3519 extension and disables the @code{crypto} extension for the function @code{foo}
3520 without modifying an existing @option{-march=} or @option{-mcpu} option.
3521
3522 Multiple target function attributes can be specified by separating them with
3523 a comma. For example:
3524 @smallexample
3525 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3526 int
3527 foo (int a)
3528 @{
3529 return a + 5;
3530 @}
3531 @end smallexample
3532
3533 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3534 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3535
3536 @subsubsection Inlining rules
3537 Specifying target attributes on individual functions or performing link-time
3538 optimization across translation units compiled with different target options
3539 can affect function inlining rules:
3540
3541 In particular, a caller function can inline a callee function only if the
3542 architectural features available to the callee are a subset of the features
3543 available to the caller.
3544 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3545 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3546 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3547 because the all the architectural features that function @code{bar} requires
3548 are available to function @code{foo}. Conversely, function @code{bar} cannot
3549 inline function @code{foo}.
3550
3551 Additionally inlining a function compiled with @option{-mstrict-align} into a
3552 function compiled without @code{-mstrict-align} is not allowed.
3553 However, inlining a function compiled without @option{-mstrict-align} into a
3554 function compiled with @option{-mstrict-align} is allowed.
3555
3556 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3557 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3558 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3559 architectural feature rules specified above.
3560
3561 @node ARC Function Attributes
3562 @subsection ARC Function Attributes
3563
3564 These function attributes are supported by the ARC back end:
3565
3566 @table @code
3567 @item interrupt
3568 @cindex @code{interrupt} function attribute, ARC
3569 Use this attribute to indicate
3570 that the specified function is an interrupt handler. The compiler generates
3571 function entry and exit sequences suitable for use in an interrupt handler
3572 when this attribute is present.
3573
3574 On the ARC, you must specify the kind of interrupt to be handled
3575 in a parameter to the interrupt attribute like this:
3576
3577 @smallexample
3578 void f () __attribute__ ((interrupt ("ilink1")));
3579 @end smallexample
3580
3581 Permissible values for this parameter are: @w{@code{ilink1}} and
3582 @w{@code{ilink2}}.
3583
3584 @item long_call
3585 @itemx medium_call
3586 @itemx short_call
3587 @cindex @code{long_call} function attribute, ARC
3588 @cindex @code{medium_call} function attribute, ARC
3589 @cindex @code{short_call} function attribute, ARC
3590 @cindex indirect calls, ARC
3591 These attributes specify how a particular function is called.
3592 These attributes override the
3593 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3594 command-line switches and @code{#pragma long_calls} settings.
3595
3596 For ARC, a function marked with the @code{long_call} attribute is
3597 always called using register-indirect jump-and-link instructions,
3598 thereby enabling the called function to be placed anywhere within the
3599 32-bit address space. A function marked with the @code{medium_call}
3600 attribute will always be close enough to be called with an unconditional
3601 branch-and-link instruction, which has a 25-bit offset from
3602 the call site. A function marked with the @code{short_call}
3603 attribute will always be close enough to be called with a conditional
3604 branch-and-link instruction, which has a 21-bit offset from
3605 the call site.
3606 @end table
3607
3608 @node ARM Function Attributes
3609 @subsection ARM Function Attributes
3610
3611 These function attributes are supported for ARM targets:
3612
3613 @table @code
3614 @item interrupt
3615 @cindex @code{interrupt} function attribute, ARM
3616 Use this attribute to indicate
3617 that the specified function is an interrupt handler. The compiler generates
3618 function entry and exit sequences suitable for use in an interrupt handler
3619 when this attribute is present.
3620
3621 You can specify the kind of interrupt to be handled by
3622 adding an optional parameter to the interrupt attribute like this:
3623
3624 @smallexample
3625 void f () __attribute__ ((interrupt ("IRQ")));
3626 @end smallexample
3627
3628 @noindent
3629 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3630 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3631
3632 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3633 may be called with a word-aligned stack pointer.
3634
3635 @item isr
3636 @cindex @code{isr} function attribute, ARM
3637 Use this attribute on ARM to write Interrupt Service Routines. This is an
3638 alias to the @code{interrupt} attribute above.
3639
3640 @item long_call
3641 @itemx short_call
3642 @cindex @code{long_call} function attribute, ARM
3643 @cindex @code{short_call} function attribute, ARM
3644 @cindex indirect calls, ARM
3645 These attributes specify how a particular function is called.
3646 These attributes override the
3647 @option{-mlong-calls} (@pxref{ARM Options})
3648 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3649 @code{long_call} attribute indicates that the function might be far
3650 away from the call site and require a different (more expensive)
3651 calling sequence. The @code{short_call} attribute always places
3652 the offset to the function from the call site into the @samp{BL}
3653 instruction directly.
3654
3655 @item naked
3656 @cindex @code{naked} function attribute, ARM
3657 This attribute allows the compiler to construct the
3658 requisite function declaration, while allowing the body of the
3659 function to be assembly code. The specified function will not have
3660 prologue/epilogue sequences generated by the compiler. Only basic
3661 @code{asm} statements can safely be included in naked functions
3662 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3663 basic @code{asm} and C code may appear to work, they cannot be
3664 depended upon to work reliably and are not supported.
3665
3666 @item pcs
3667 @cindex @code{pcs} function attribute, ARM
3668
3669 The @code{pcs} attribute can be used to control the calling convention
3670 used for a function on ARM. The attribute takes an argument that specifies
3671 the calling convention to use.
3672
3673 When compiling using the AAPCS ABI (or a variant of it) then valid
3674 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3675 order to use a variant other than @code{"aapcs"} then the compiler must
3676 be permitted to use the appropriate co-processor registers (i.e., the
3677 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3678 For example,
3679
3680 @smallexample
3681 /* Argument passed in r0, and result returned in r0+r1. */
3682 double f2d (float) __attribute__((pcs("aapcs")));
3683 @end smallexample
3684
3685 Variadic functions always use the @code{"aapcs"} calling convention and
3686 the compiler rejects attempts to specify an alternative.
3687
3688 @item target (@var{options})
3689 @cindex @code{target} function attribute
3690 As discussed in @ref{Common Function Attributes}, this attribute
3691 allows specification of target-specific compilation options.
3692
3693 On ARM, the following options are allowed:
3694
3695 @table @samp
3696 @item thumb
3697 @cindex @code{target("thumb")} function attribute, ARM
3698 Force code generation in the Thumb (T16/T32) ISA, depending on the
3699 architecture level.
3700
3701 @item arm
3702 @cindex @code{target("arm")} function attribute, ARM
3703 Force code generation in the ARM (A32) ISA.
3704
3705 Functions from different modes can be inlined in the caller's mode.
3706
3707 @item fpu=
3708 @cindex @code{target("fpu=")} function attribute, ARM
3709 Specifies the fpu for which to tune the performance of this function.
3710 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3711 command-line option.
3712
3713 @end table
3714
3715 @end table
3716
3717 @node AVR Function Attributes
3718 @subsection AVR Function Attributes
3719
3720 These function attributes are supported by the AVR back end:
3721
3722 @table @code
3723 @item interrupt
3724 @cindex @code{interrupt} function attribute, AVR
3725 Use this attribute to indicate
3726 that the specified function is an interrupt handler. The compiler generates
3727 function entry and exit sequences suitable for use in an interrupt handler
3728 when this attribute is present.
3729
3730 On the AVR, the hardware globally disables interrupts when an
3731 interrupt is executed. The first instruction of an interrupt handler
3732 declared with this attribute is a @code{SEI} instruction to
3733 re-enable interrupts. See also the @code{signal} function attribute
3734 that does not insert a @code{SEI} instruction. If both @code{signal} and
3735 @code{interrupt} are specified for the same function, @code{signal}
3736 is silently ignored.
3737
3738 @item naked
3739 @cindex @code{naked} function attribute, AVR
3740 This attribute allows the compiler to construct the
3741 requisite function declaration, while allowing the body of the
3742 function to be assembly code. The specified function will not have
3743 prologue/epilogue sequences generated by the compiler. Only basic
3744 @code{asm} statements can safely be included in naked functions
3745 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3746 basic @code{asm} and C code may appear to work, they cannot be
3747 depended upon to work reliably and are not supported.
3748
3749 @item OS_main
3750 @itemx OS_task
3751 @cindex @code{OS_main} function attribute, AVR
3752 @cindex @code{OS_task} function attribute, AVR
3753 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3754 do not save/restore any call-saved register in their prologue/epilogue.
3755
3756 The @code{OS_main} attribute can be used when there @emph{is
3757 guarantee} that interrupts are disabled at the time when the function
3758 is entered. This saves resources when the stack pointer has to be
3759 changed to set up a frame for local variables.
3760
3761 The @code{OS_task} attribute can be used when there is @emph{no
3762 guarantee} that interrupts are disabled at that time when the function
3763 is entered like for, e@.g@. task functions in a multi-threading operating
3764 system. In that case, changing the stack pointer register is
3765 guarded by save/clear/restore of the global interrupt enable flag.
3766
3767 The differences to the @code{naked} function attribute are:
3768 @itemize @bullet
3769 @item @code{naked} functions do not have a return instruction whereas
3770 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3771 @code{RETI} return instruction.
3772 @item @code{naked} functions do not set up a frame for local variables
3773 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3774 as needed.
3775 @end itemize
3776
3777 @item signal
3778 @cindex @code{signal} function attribute, AVR
3779 Use this attribute on the AVR to indicate that the specified
3780 function is an interrupt handler. The compiler generates function
3781 entry and exit sequences suitable for use in an interrupt handler when this
3782 attribute is present.
3783
3784 See also the @code{interrupt} function attribute.
3785
3786 The AVR hardware globally disables interrupts when an interrupt is executed.
3787 Interrupt handler functions defined with the @code{signal} attribute
3788 do not re-enable interrupts. It is save to enable interrupts in a
3789 @code{signal} handler. This ``save'' only applies to the code
3790 generated by the compiler and not to the IRQ layout of the
3791 application which is responsibility of the application.
3792
3793 If both @code{signal} and @code{interrupt} are specified for the same
3794 function, @code{signal} is silently ignored.
3795 @end table
3796
3797 @node Blackfin Function Attributes
3798 @subsection Blackfin Function Attributes
3799
3800 These function attributes are supported by the Blackfin back end:
3801
3802 @table @code
3803
3804 @item exception_handler
3805 @cindex @code{exception_handler} function attribute
3806 @cindex exception handler functions, Blackfin
3807 Use this attribute on the Blackfin to indicate that the specified function
3808 is an exception handler. The compiler generates function entry and
3809 exit sequences suitable for use in an exception handler when this
3810 attribute is present.
3811
3812 @item interrupt_handler
3813 @cindex @code{interrupt_handler} function attribute, Blackfin
3814 Use this attribute to
3815 indicate that the specified function is an interrupt handler. The compiler
3816 generates function entry and exit sequences suitable for use in an
3817 interrupt handler when this attribute is present.
3818
3819 @item kspisusp
3820 @cindex @code{kspisusp} function attribute, Blackfin
3821 @cindex User stack pointer in interrupts on the Blackfin
3822 When used together with @code{interrupt_handler}, @code{exception_handler}
3823 or @code{nmi_handler}, code is generated to load the stack pointer
3824 from the USP register in the function prologue.
3825
3826 @item l1_text
3827 @cindex @code{l1_text} function attribute, Blackfin
3828 This attribute specifies a function to be placed into L1 Instruction
3829 SRAM@. The function is put into a specific section named @code{.l1.text}.
3830 With @option{-mfdpic}, function calls with a such function as the callee
3831 or caller uses inlined PLT.
3832
3833 @item l2
3834 @cindex @code{l2} function attribute, Blackfin
3835 This attribute specifies a function to be placed into L2
3836 SRAM. The function is put into a specific section named
3837 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3838 an inlined PLT.
3839
3840 @item longcall
3841 @itemx shortcall
3842 @cindex indirect calls, Blackfin
3843 @cindex @code{longcall} function attribute, Blackfin
3844 @cindex @code{shortcall} function attribute, Blackfin
3845 The @code{longcall} attribute
3846 indicates that the function might be far away from the call site and
3847 require a different (more expensive) calling sequence. The
3848 @code{shortcall} attribute indicates that the function is always close
3849 enough for the shorter calling sequence to be used. These attributes
3850 override the @option{-mlongcall} switch.
3851
3852 @item nesting
3853 @cindex @code{nesting} function attribute, Blackfin
3854 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3855 Use this attribute together with @code{interrupt_handler},
3856 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3857 entry code should enable nested interrupts or exceptions.
3858
3859 @item nmi_handler
3860 @cindex @code{nmi_handler} function attribute, Blackfin
3861 @cindex NMI handler functions on the Blackfin processor
3862 Use this attribute on the Blackfin to indicate that the specified function
3863 is an NMI handler. The compiler generates function entry and
3864 exit sequences suitable for use in an NMI handler when this
3865 attribute is present.
3866
3867 @item saveall
3868 @cindex @code{saveall} function attribute, Blackfin
3869 @cindex save all registers on the Blackfin
3870 Use this attribute to indicate that
3871 all registers except the stack pointer should be saved in the prologue
3872 regardless of whether they are used or not.
3873 @end table
3874
3875 @node CR16 Function Attributes
3876 @subsection CR16 Function Attributes
3877
3878 These function attributes are supported by the CR16 back end:
3879
3880 @table @code
3881 @item interrupt
3882 @cindex @code{interrupt} function attribute, CR16
3883 Use this attribute to indicate
3884 that the specified function is an interrupt handler. The compiler generates
3885 function entry and exit sequences suitable for use in an interrupt handler
3886 when this attribute is present.
3887 @end table
3888
3889 @node Epiphany Function Attributes
3890 @subsection Epiphany Function Attributes
3891
3892 These function attributes are supported by the Epiphany back end:
3893
3894 @table @code
3895 @item disinterrupt
3896 @cindex @code{disinterrupt} function attribute, Epiphany
3897 This attribute causes the compiler to emit
3898 instructions to disable interrupts for the duration of the given
3899 function.
3900
3901 @item forwarder_section
3902 @cindex @code{forwarder_section} function attribute, Epiphany
3903 This attribute modifies the behavior of an interrupt handler.
3904 The interrupt handler may be in external memory which cannot be
3905 reached by a branch instruction, so generate a local memory trampoline
3906 to transfer control. The single parameter identifies the section where
3907 the trampoline is placed.
3908
3909 @item interrupt
3910 @cindex @code{interrupt} function attribute, Epiphany
3911 Use this attribute to indicate
3912 that the specified function is an interrupt handler. The compiler generates
3913 function entry and exit sequences suitable for use in an interrupt handler
3914 when this attribute is present. It may also generate
3915 a special section with code to initialize the interrupt vector table.
3916
3917 On Epiphany targets one or more optional parameters can be added like this:
3918
3919 @smallexample
3920 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3921 @end smallexample
3922
3923 Permissible values for these parameters are: @w{@code{reset}},
3924 @w{@code{software_exception}}, @w{@code{page_miss}},
3925 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3926 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3927 Multiple parameters indicate that multiple entries in the interrupt
3928 vector table should be initialized for this function, i.e.@: for each
3929 parameter @w{@var{name}}, a jump to the function is emitted in
3930 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3931 entirely, in which case no interrupt vector table entry is provided.
3932
3933 Note that interrupts are enabled inside the function
3934 unless the @code{disinterrupt} attribute is also specified.
3935
3936 The following examples are all valid uses of these attributes on
3937 Epiphany targets:
3938 @smallexample
3939 void __attribute__ ((interrupt)) universal_handler ();
3940 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3941 void __attribute__ ((interrupt ("dma0, dma1")))
3942 universal_dma_handler ();
3943 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3944 fast_timer_handler ();
3945 void __attribute__ ((interrupt ("dma0, dma1"),
3946 forwarder_section ("tramp")))
3947 external_dma_handler ();
3948 @end smallexample
3949
3950 @item long_call
3951 @itemx short_call
3952 @cindex @code{long_call} function attribute, Epiphany
3953 @cindex @code{short_call} function attribute, Epiphany
3954 @cindex indirect calls, Epiphany
3955 These attributes specify how a particular function is called.
3956 These attributes override the
3957 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3958 command-line switch and @code{#pragma long_calls} settings.
3959 @end table
3960
3961
3962 @node H8/300 Function Attributes
3963 @subsection H8/300 Function Attributes
3964
3965 These function attributes are available for H8/300 targets:
3966
3967 @table @code
3968 @item function_vector
3969 @cindex @code{function_vector} function attribute, H8/300
3970 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3971 that the specified function should be called through the function vector.
3972 Calling a function through the function vector reduces code size; however,
3973 the function vector has a limited size (maximum 128 entries on the H8/300
3974 and 64 entries on the H8/300H and H8S)
3975 and shares space with the interrupt vector.
3976
3977 @item interrupt_handler
3978 @cindex @code{interrupt_handler} function attribute, H8/300
3979 Use this attribute on the H8/300, H8/300H, and H8S to
3980 indicate that the specified function is an interrupt handler. The compiler
3981 generates function entry and exit sequences suitable for use in an
3982 interrupt handler when this attribute is present.
3983
3984 @item saveall
3985 @cindex @code{saveall} function attribute, H8/300
3986 @cindex save all registers on the H8/300, H8/300H, and H8S
3987 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3988 all registers except the stack pointer should be saved in the prologue
3989 regardless of whether they are used or not.
3990 @end table
3991
3992 @node IA-64 Function Attributes
3993 @subsection IA-64 Function Attributes
3994
3995 These function attributes are supported on IA-64 targets:
3996
3997 @table @code
3998 @item syscall_linkage
3999 @cindex @code{syscall_linkage} function attribute, IA-64
4000 This attribute is used to modify the IA-64 calling convention by marking
4001 all input registers as live at all function exits. This makes it possible
4002 to restart a system call after an interrupt without having to save/restore
4003 the input registers. This also prevents kernel data from leaking into
4004 application code.
4005
4006 @item version_id
4007 @cindex @code{version_id} function attribute, IA-64
4008 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4009 symbol to contain a version string, thus allowing for function level
4010 versioning. HP-UX system header files may use function level versioning
4011 for some system calls.
4012
4013 @smallexample
4014 extern int foo () __attribute__((version_id ("20040821")));
4015 @end smallexample
4016
4017 @noindent
4018 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4019 @end table
4020
4021 @node M32C Function Attributes
4022 @subsection M32C Function Attributes
4023
4024 These function attributes are supported by the M32C back end:
4025
4026 @table @code
4027 @item bank_switch
4028 @cindex @code{bank_switch} function attribute, M32C
4029 When added to an interrupt handler with the M32C port, causes the
4030 prologue and epilogue to use bank switching to preserve the registers
4031 rather than saving them on the stack.
4032
4033 @item fast_interrupt
4034 @cindex @code{fast_interrupt} function attribute, M32C
4035 Use this attribute on the M32C port to indicate that the specified
4036 function is a fast interrupt handler. This is just like the
4037 @code{interrupt} attribute, except that @code{freit} is used to return
4038 instead of @code{reit}.
4039
4040 @item function_vector
4041 @cindex @code{function_vector} function attribute, M16C/M32C
4042 On M16C/M32C targets, the @code{function_vector} attribute declares a
4043 special page subroutine call function. Use of this attribute reduces
4044 the code size by 2 bytes for each call generated to the
4045 subroutine. The argument to the attribute is the vector number entry
4046 from the special page vector table which contains the 16 low-order
4047 bits of the subroutine's entry address. Each vector table has special
4048 page number (18 to 255) that is used in @code{jsrs} instructions.
4049 Jump addresses of the routines are generated by adding 0x0F0000 (in
4050 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4051 2-byte addresses set in the vector table. Therefore you need to ensure
4052 that all the special page vector routines should get mapped within the
4053 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4054 (for M32C).
4055
4056 In the following example 2 bytes are saved for each call to
4057 function @code{foo}.
4058
4059 @smallexample
4060 void foo (void) __attribute__((function_vector(0x18)));
4061 void foo (void)
4062 @{
4063 @}
4064
4065 void bar (void)
4066 @{
4067 foo();
4068 @}
4069 @end smallexample
4070
4071 If functions are defined in one file and are called in another file,
4072 then be sure to write this declaration in both files.
4073
4074 This attribute is ignored for R8C target.
4075
4076 @item interrupt
4077 @cindex @code{interrupt} function attribute, M32C
4078 Use this attribute to indicate
4079 that the specified function is an interrupt handler. The compiler generates
4080 function entry and exit sequences suitable for use in an interrupt handler
4081 when this attribute is present.
4082 @end table
4083
4084 @node M32R/D Function Attributes
4085 @subsection M32R/D Function Attributes
4086
4087 These function attributes are supported by the M32R/D back end:
4088
4089 @table @code
4090 @item interrupt
4091 @cindex @code{interrupt} function attribute, M32R/D
4092 Use this attribute to indicate
4093 that the specified function is an interrupt handler. The compiler generates
4094 function entry and exit sequences suitable for use in an interrupt handler
4095 when this attribute is present.
4096
4097 @item model (@var{model-name})
4098 @cindex @code{model} function attribute, M32R/D
4099 @cindex function addressability on the M32R/D
4100
4101 On the M32R/D, use this attribute to set the addressability of an
4102 object, and of the code generated for a function. The identifier
4103 @var{model-name} is one of @code{small}, @code{medium}, or
4104 @code{large}, representing each of the code models.
4105
4106 Small model objects live in the lower 16MB of memory (so that their
4107 addresses can be loaded with the @code{ld24} instruction), and are
4108 callable with the @code{bl} instruction.
4109
4110 Medium model objects may live anywhere in the 32-bit address space (the
4111 compiler generates @code{seth/add3} instructions to load their addresses),
4112 and are callable with the @code{bl} instruction.
4113
4114 Large model objects may live anywhere in the 32-bit address space (the
4115 compiler generates @code{seth/add3} instructions to load their addresses),
4116 and may not be reachable with the @code{bl} instruction (the compiler
4117 generates the much slower @code{seth/add3/jl} instruction sequence).
4118 @end table
4119
4120 @node m68k Function Attributes
4121 @subsection m68k Function Attributes
4122
4123 These function attributes are supported by the m68k back end:
4124
4125 @table @code
4126 @item interrupt
4127 @itemx interrupt_handler
4128 @cindex @code{interrupt} function attribute, m68k
4129 @cindex @code{interrupt_handler} function attribute, m68k
4130 Use this attribute to
4131 indicate that the specified function is an interrupt handler. The compiler
4132 generates function entry and exit sequences suitable for use in an
4133 interrupt handler when this attribute is present. Either name may be used.
4134
4135 @item interrupt_thread
4136 @cindex @code{interrupt_thread} function attribute, fido
4137 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4138 that the specified function is an interrupt handler that is designed
4139 to run as a thread. The compiler omits generate prologue/epilogue
4140 sequences and replaces the return instruction with a @code{sleep}
4141 instruction. This attribute is available only on fido.
4142 @end table
4143
4144 @node MCORE Function Attributes
4145 @subsection MCORE Function Attributes
4146
4147 These function attributes are supported by the MCORE back end:
4148
4149 @table @code
4150 @item naked
4151 @cindex @code{naked} function attribute, MCORE
4152 This attribute allows the compiler to construct the
4153 requisite function declaration, while allowing the body of the
4154 function to be assembly code. The specified function will not have
4155 prologue/epilogue sequences generated by the compiler. Only basic
4156 @code{asm} statements can safely be included in naked functions
4157 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4158 basic @code{asm} and C code may appear to work, they cannot be
4159 depended upon to work reliably and are not supported.
4160 @end table
4161
4162 @node MeP Function Attributes
4163 @subsection MeP Function Attributes
4164
4165 These function attributes are supported by the MeP back end:
4166
4167 @table @code
4168 @item disinterrupt
4169 @cindex @code{disinterrupt} function attribute, MeP
4170 On MeP targets, this attribute causes the compiler to emit
4171 instructions to disable interrupts for the duration of the given
4172 function.
4173
4174 @item interrupt
4175 @cindex @code{interrupt} function attribute, MeP
4176 Use this attribute to indicate
4177 that the specified function is an interrupt handler. The compiler generates
4178 function entry and exit sequences suitable for use in an interrupt handler
4179 when this attribute is present.
4180
4181 @item near
4182 @cindex @code{near} function attribute, MeP
4183 This attribute causes the compiler to assume the called
4184 function is close enough to use the normal calling convention,
4185 overriding the @option{-mtf} command-line option.
4186
4187 @item far
4188 @cindex @code{far} function attribute, MeP
4189 On MeP targets this causes the compiler to use a calling convention
4190 that assumes the called function is too far away for the built-in
4191 addressing modes.
4192
4193 @item vliw
4194 @cindex @code{vliw} function attribute, MeP
4195 The @code{vliw} attribute tells the compiler to emit
4196 instructions in VLIW mode instead of core mode. Note that this
4197 attribute is not allowed unless a VLIW coprocessor has been configured
4198 and enabled through command-line options.
4199 @end table
4200
4201 @node MicroBlaze Function Attributes
4202 @subsection MicroBlaze Function Attributes
4203
4204 These function attributes are supported on MicroBlaze targets:
4205
4206 @table @code
4207 @item save_volatiles
4208 @cindex @code{save_volatiles} function attribute, MicroBlaze
4209 Use this attribute to indicate that the function is
4210 an interrupt handler. All volatile registers (in addition to non-volatile
4211 registers) are saved in the function prologue. If the function is a leaf
4212 function, only volatiles used by the function are saved. A normal function
4213 return is generated instead of a return from interrupt.
4214
4215 @item break_handler
4216 @cindex @code{break_handler} function attribute, MicroBlaze
4217 @cindex break handler functions
4218 Use this attribute to indicate that
4219 the specified function is a break handler. The compiler generates function
4220 entry and exit sequences suitable for use in an break handler when this
4221 attribute is present. The return from @code{break_handler} is done through
4222 the @code{rtbd} instead of @code{rtsd}.
4223
4224 @smallexample
4225 void f () __attribute__ ((break_handler));
4226 @end smallexample
4227 @end table
4228
4229 @node Microsoft Windows Function Attributes
4230 @subsection Microsoft Windows Function Attributes
4231
4232 The following attributes are available on Microsoft Windows and Symbian OS
4233 targets.
4234
4235 @table @code
4236 @item dllexport
4237 @cindex @code{dllexport} function attribute
4238 @cindex @code{__declspec(dllexport)}
4239 On Microsoft Windows targets and Symbian OS targets the
4240 @code{dllexport} attribute causes the compiler to provide a global
4241 pointer to a pointer in a DLL, so that it can be referenced with the
4242 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4243 name is formed by combining @code{_imp__} and the function or variable
4244 name.
4245
4246 You can use @code{__declspec(dllexport)} as a synonym for
4247 @code{__attribute__ ((dllexport))} for compatibility with other
4248 compilers.
4249
4250 On systems that support the @code{visibility} attribute, this
4251 attribute also implies ``default'' visibility. It is an error to
4252 explicitly specify any other visibility.
4253
4254 GCC's default behavior is to emit all inline functions with the
4255 @code{dllexport} attribute. Since this can cause object file-size bloat,
4256 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4257 ignore the attribute for inlined functions unless the
4258 @option{-fkeep-inline-functions} flag is used instead.
4259
4260 The attribute is ignored for undefined symbols.
4261
4262 When applied to C++ classes, the attribute marks defined non-inlined
4263 member functions and static data members as exports. Static consts
4264 initialized in-class are not marked unless they are also defined
4265 out-of-class.
4266
4267 For Microsoft Windows targets there are alternative methods for
4268 including the symbol in the DLL's export table such as using a
4269 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4270 the @option{--export-all} linker flag.
4271
4272 @item dllimport
4273 @cindex @code{dllimport} function attribute
4274 @cindex @code{__declspec(dllimport)}
4275 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4276 attribute causes the compiler to reference a function or variable via
4277 a global pointer to a pointer that is set up by the DLL exporting the
4278 symbol. The attribute implies @code{extern}. On Microsoft Windows
4279 targets, the pointer name is formed by combining @code{_imp__} and the
4280 function or variable name.
4281
4282 You can use @code{__declspec(dllimport)} as a synonym for
4283 @code{__attribute__ ((dllimport))} for compatibility with other
4284 compilers.
4285
4286 On systems that support the @code{visibility} attribute, this
4287 attribute also implies ``default'' visibility. It is an error to
4288 explicitly specify any other visibility.
4289
4290 Currently, the attribute is ignored for inlined functions. If the
4291 attribute is applied to a symbol @emph{definition}, an error is reported.
4292 If a symbol previously declared @code{dllimport} is later defined, the
4293 attribute is ignored in subsequent references, and a warning is emitted.
4294 The attribute is also overridden by a subsequent declaration as
4295 @code{dllexport}.
4296
4297 When applied to C++ classes, the attribute marks non-inlined
4298 member functions and static data members as imports. However, the
4299 attribute is ignored for virtual methods to allow creation of vtables
4300 using thunks.
4301
4302 On the SH Symbian OS target the @code{dllimport} attribute also has
4303 another affect---it can cause the vtable and run-time type information
4304 for a class to be exported. This happens when the class has a
4305 dllimported constructor or a non-inline, non-pure virtual function
4306 and, for either of those two conditions, the class also has an inline
4307 constructor or destructor and has a key function that is defined in
4308 the current translation unit.
4309
4310 For Microsoft Windows targets the use of the @code{dllimport}
4311 attribute on functions is not necessary, but provides a small
4312 performance benefit by eliminating a thunk in the DLL@. The use of the
4313 @code{dllimport} attribute on imported variables can be avoided by passing the
4314 @option{--enable-auto-import} switch to the GNU linker. As with
4315 functions, using the attribute for a variable eliminates a thunk in
4316 the DLL@.
4317
4318 One drawback to using this attribute is that a pointer to a
4319 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4320 address. However, a pointer to a @emph{function} with the
4321 @code{dllimport} attribute can be used as a constant initializer; in
4322 this case, the address of a stub function in the import lib is
4323 referenced. On Microsoft Windows targets, the attribute can be disabled
4324 for functions by setting the @option{-mnop-fun-dllimport} flag.
4325 @end table
4326
4327 @node MIPS Function Attributes
4328 @subsection MIPS Function Attributes
4329
4330 These function attributes are supported by the MIPS back end:
4331
4332 @table @code
4333 @item interrupt
4334 @cindex @code{interrupt} function attribute, MIPS
4335 Use this attribute to indicate that the specified function is an interrupt
4336 handler. The compiler generates function entry and exit sequences suitable
4337 for use in an interrupt handler when this attribute is present.
4338 An optional argument is supported for the interrupt attribute which allows
4339 the interrupt mode to be described. By default GCC assumes the external
4340 interrupt controller (EIC) mode is in use, this can be explicitly set using
4341 @code{eic}. When interrupts are non-masked then the requested Interrupt
4342 Priority Level (IPL) is copied to the current IPL which has the effect of only
4343 enabling higher priority interrupts. To use vectored interrupt mode use
4344 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4345 the behaviour of the non-masked interrupt support and GCC will arrange to mask
4346 all interrupts from sw0 up to and including the specified interrupt vector.
4347
4348 You can use the following attributes to modify the behavior
4349 of an interrupt handler:
4350 @table @code
4351 @item use_shadow_register_set
4352 @cindex @code{use_shadow_register_set} function attribute, MIPS
4353 Assume that the handler uses a shadow register set, instead of
4354 the main general-purpose registers. An optional argument @code{intstack} is
4355 supported to indicate that the shadow register set contains a valid stack
4356 pointer.
4357
4358 @item keep_interrupts_masked
4359 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4360 Keep interrupts masked for the whole function. Without this attribute,
4361 GCC tries to reenable interrupts for as much of the function as it can.
4362
4363 @item use_debug_exception_return
4364 @cindex @code{use_debug_exception_return} function attribute, MIPS
4365 Return using the @code{deret} instruction. Interrupt handlers that don't
4366 have this attribute return using @code{eret} instead.
4367 @end table
4368
4369 You can use any combination of these attributes, as shown below:
4370 @smallexample
4371 void __attribute__ ((interrupt)) v0 ();
4372 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4373 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4374 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4375 void __attribute__ ((interrupt, use_shadow_register_set,
4376 keep_interrupts_masked)) v4 ();
4377 void __attribute__ ((interrupt, use_shadow_register_set,
4378 use_debug_exception_return)) v5 ();
4379 void __attribute__ ((interrupt, keep_interrupts_masked,
4380 use_debug_exception_return)) v6 ();
4381 void __attribute__ ((interrupt, use_shadow_register_set,
4382 keep_interrupts_masked,
4383 use_debug_exception_return)) v7 ();
4384 void __attribute__ ((interrupt("eic"))) v8 ();
4385 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4386 @end smallexample
4387
4388 @item long_call
4389 @itemx near
4390 @itemx far
4391 @cindex indirect calls, MIPS
4392 @cindex @code{long_call} function attribute, MIPS
4393 @cindex @code{near} function attribute, MIPS
4394 @cindex @code{far} function attribute, MIPS
4395 These attributes specify how a particular function is called on MIPS@.
4396 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4397 command-line switch. The @code{long_call} and @code{far} attributes are
4398 synonyms, and cause the compiler to always call
4399 the function by first loading its address into a register, and then using
4400 the contents of that register. The @code{near} attribute has the opposite
4401 effect; it specifies that non-PIC calls should be made using the more
4402 efficient @code{jal} instruction.
4403
4404 @item mips16
4405 @itemx nomips16
4406 @cindex @code{mips16} function attribute, MIPS
4407 @cindex @code{nomips16} function attribute, MIPS
4408
4409 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4410 function attributes to locally select or turn off MIPS16 code generation.
4411 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4412 while MIPS16 code generation is disabled for functions with the
4413 @code{nomips16} attribute. These attributes override the
4414 @option{-mips16} and @option{-mno-mips16} options on the command line
4415 (@pxref{MIPS Options}).
4416
4417 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4418 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4419 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4420 may interact badly with some GCC extensions such as @code{__builtin_apply}
4421 (@pxref{Constructing Calls}).
4422
4423 @item micromips, MIPS
4424 @itemx nomicromips, MIPS
4425 @cindex @code{micromips} function attribute
4426 @cindex @code{nomicromips} function attribute
4427
4428 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4429 function attributes to locally select or turn off microMIPS code generation.
4430 A function with the @code{micromips} attribute is emitted as microMIPS code,
4431 while microMIPS code generation is disabled for functions with the
4432 @code{nomicromips} attribute. These attributes override the
4433 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4434 (@pxref{MIPS Options}).
4435
4436 When compiling files containing mixed microMIPS and non-microMIPS code, the
4437 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4438 command line,
4439 not that within individual functions. Mixed microMIPS and non-microMIPS code
4440 may interact badly with some GCC extensions such as @code{__builtin_apply}
4441 (@pxref{Constructing Calls}).
4442
4443 @item nocompression
4444 @cindex @code{nocompression} function attribute, MIPS
4445 On MIPS targets, you can use the @code{nocompression} function attribute
4446 to locally turn off MIPS16 and microMIPS code generation. This attribute
4447 overrides the @option{-mips16} and @option{-mmicromips} options on the
4448 command line (@pxref{MIPS Options}).
4449 @end table
4450
4451 @node MSP430 Function Attributes
4452 @subsection MSP430 Function Attributes
4453
4454 These function attributes are supported by the MSP430 back end:
4455
4456 @table @code
4457 @item critical
4458 @cindex @code{critical} function attribute, MSP430
4459 Critical functions disable interrupts upon entry and restore the
4460 previous interrupt state upon exit. Critical functions cannot also
4461 have the @code{naked} or @code{reentrant} attributes. They can have
4462 the @code{interrupt} attribute.
4463
4464 @item interrupt
4465 @cindex @code{interrupt} function attribute, MSP430
4466 Use this attribute to indicate
4467 that the specified function is an interrupt handler. The compiler generates
4468 function entry and exit sequences suitable for use in an interrupt handler
4469 when this attribute is present.
4470
4471 You can provide an argument to the interrupt
4472 attribute which specifies a name or number. If the argument is a
4473 number it indicates the slot in the interrupt vector table (0 - 31) to
4474 which this handler should be assigned. If the argument is a name it
4475 is treated as a symbolic name for the vector slot. These names should
4476 match up with appropriate entries in the linker script. By default
4477 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4478 @code{reset} for vector 31 are recognized.
4479
4480 @item naked
4481 @cindex @code{naked} function attribute, MSP430
4482 This attribute allows the compiler to construct the
4483 requisite function declaration, while allowing the body of the
4484 function to be assembly code. The specified function will not have
4485 prologue/epilogue sequences generated by the compiler. Only basic
4486 @code{asm} statements can safely be included in naked functions
4487 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4488 basic @code{asm} and C code may appear to work, they cannot be
4489 depended upon to work reliably and are not supported.
4490
4491 @item reentrant
4492 @cindex @code{reentrant} function attribute, MSP430
4493 Reentrant functions disable interrupts upon entry and enable them
4494 upon exit. Reentrant functions cannot also have the @code{naked}
4495 or @code{critical} attributes. They can have the @code{interrupt}
4496 attribute.
4497
4498 @item wakeup
4499 @cindex @code{wakeup} function attribute, MSP430
4500 This attribute only applies to interrupt functions. It is silently
4501 ignored if applied to a non-interrupt function. A wakeup interrupt
4502 function will rouse the processor from any low-power state that it
4503 might be in when the function exits.
4504 @end table
4505
4506 @node NDS32 Function Attributes
4507 @subsection NDS32 Function Attributes
4508
4509 These function attributes are supported by the NDS32 back end:
4510
4511 @table @code
4512 @item exception
4513 @cindex @code{exception} function attribute
4514 @cindex exception handler functions, NDS32
4515 Use this attribute on the NDS32 target to indicate that the specified function
4516 is an exception handler. The compiler will generate corresponding sections
4517 for use in an exception handler.
4518
4519 @item interrupt
4520 @cindex @code{interrupt} function attribute, NDS32
4521 On NDS32 target, this attribute indicates that the specified function
4522 is an interrupt handler. The compiler generates corresponding sections
4523 for use in an interrupt handler. You can use the following attributes
4524 to modify the behavior:
4525 @table @code
4526 @item nested
4527 @cindex @code{nested} function attribute, NDS32
4528 This interrupt service routine is interruptible.
4529 @item not_nested
4530 @cindex @code{not_nested} function attribute, NDS32
4531 This interrupt service routine is not interruptible.
4532 @item nested_ready
4533 @cindex @code{nested_ready} function attribute, NDS32
4534 This interrupt service routine is interruptible after @code{PSW.GIE}
4535 (global interrupt enable) is set. This allows interrupt service routine to
4536 finish some short critical code before enabling interrupts.
4537 @item save_all
4538 @cindex @code{save_all} function attribute, NDS32
4539 The system will help save all registers into stack before entering
4540 interrupt handler.
4541 @item partial_save
4542 @cindex @code{partial_save} function attribute, NDS32
4543 The system will help save caller registers into stack before entering
4544 interrupt handler.
4545 @end table
4546
4547 @item naked
4548 @cindex @code{naked} function attribute, NDS32
4549 This attribute allows the compiler to construct the
4550 requisite function declaration, while allowing the body of the
4551 function to be assembly code. The specified function will not have
4552 prologue/epilogue sequences generated by the compiler. Only basic
4553 @code{asm} statements can safely be included in naked functions
4554 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4555 basic @code{asm} and C code may appear to work, they cannot be
4556 depended upon to work reliably and are not supported.
4557
4558 @item reset
4559 @cindex @code{reset} function attribute, NDS32
4560 @cindex reset handler functions
4561 Use this attribute on the NDS32 target to indicate that the specified function
4562 is a reset handler. The compiler will generate corresponding sections
4563 for use in a reset handler. You can use the following attributes
4564 to provide extra exception handling:
4565 @table @code
4566 @item nmi
4567 @cindex @code{nmi} function attribute, NDS32
4568 Provide a user-defined function to handle NMI exception.
4569 @item warm
4570 @cindex @code{warm} function attribute, NDS32
4571 Provide a user-defined function to handle warm reset exception.
4572 @end table
4573 @end table
4574
4575 @node Nios II Function Attributes
4576 @subsection Nios II Function Attributes
4577
4578 These function attributes are supported by the Nios II back end:
4579
4580 @table @code
4581 @item target (@var{options})
4582 @cindex @code{target} function attribute
4583 As discussed in @ref{Common Function Attributes}, this attribute
4584 allows specification of target-specific compilation options.
4585
4586 When compiling for Nios II, the following options are allowed:
4587
4588 @table @samp
4589 @item custom-@var{insn}=@var{N}
4590 @itemx no-custom-@var{insn}
4591 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4592 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4593 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4594 custom instruction with encoding @var{N} when generating code that uses
4595 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4596 the custom instruction @var{insn}.
4597 These target attributes correspond to the
4598 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4599 command-line options, and support the same set of @var{insn} keywords.
4600 @xref{Nios II Options}, for more information.
4601
4602 @item custom-fpu-cfg=@var{name}
4603 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4604 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4605 command-line option, to select a predefined set of custom instructions
4606 named @var{name}.
4607 @xref{Nios II Options}, for more information.
4608 @end table
4609 @end table
4610
4611 @node PowerPC Function Attributes
4612 @subsection PowerPC Function Attributes
4613
4614 These function attributes are supported by the PowerPC back end:
4615
4616 @table @code
4617 @item longcall
4618 @itemx shortcall
4619 @cindex indirect calls, PowerPC
4620 @cindex @code{longcall} function attribute, PowerPC
4621 @cindex @code{shortcall} function attribute, PowerPC
4622 The @code{longcall} attribute
4623 indicates that the function might be far away from the call site and
4624 require a different (more expensive) calling sequence. The
4625 @code{shortcall} attribute indicates that the function is always close
4626 enough for the shorter calling sequence to be used. These attributes
4627 override both the @option{-mlongcall} switch and
4628 the @code{#pragma longcall} setting.
4629
4630 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4631 calls are necessary.
4632
4633 @item target (@var{options})
4634 @cindex @code{target} function attribute
4635 As discussed in @ref{Common Function Attributes}, this attribute
4636 allows specification of target-specific compilation options.
4637
4638 On the PowerPC, the following options are allowed:
4639
4640 @table @samp
4641 @item altivec
4642 @itemx no-altivec
4643 @cindex @code{target("altivec")} function attribute, PowerPC
4644 Generate code that uses (does not use) AltiVec instructions. In
4645 32-bit code, you cannot enable AltiVec instructions unless
4646 @option{-mabi=altivec} is used on the command line.
4647
4648 @item cmpb
4649 @itemx no-cmpb
4650 @cindex @code{target("cmpb")} function attribute, PowerPC
4651 Generate code that uses (does not use) the compare bytes instruction
4652 implemented on the POWER6 processor and other processors that support
4653 the PowerPC V2.05 architecture.
4654
4655 @item dlmzb
4656 @itemx no-dlmzb
4657 @cindex @code{target("dlmzb")} function attribute, PowerPC
4658 Generate code that uses (does not use) the string-search @samp{dlmzb}
4659 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4660 generated by default when targeting those processors.
4661
4662 @item fprnd
4663 @itemx no-fprnd
4664 @cindex @code{target("fprnd")} function attribute, PowerPC
4665 Generate code that uses (does not use) the FP round to integer
4666 instructions implemented on the POWER5+ processor and other processors
4667 that support the PowerPC V2.03 architecture.
4668
4669 @item hard-dfp
4670 @itemx no-hard-dfp
4671 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4672 Generate code that uses (does not use) the decimal floating-point
4673 instructions implemented on some POWER processors.
4674
4675 @item isel
4676 @itemx no-isel
4677 @cindex @code{target("isel")} function attribute, PowerPC
4678 Generate code that uses (does not use) ISEL instruction.
4679
4680 @item mfcrf
4681 @itemx no-mfcrf
4682 @cindex @code{target("mfcrf")} function attribute, PowerPC
4683 Generate code that uses (does not use) the move from condition
4684 register field instruction implemented on the POWER4 processor and
4685 other processors that support the PowerPC V2.01 architecture.
4686
4687 @item mfpgpr
4688 @itemx no-mfpgpr
4689 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4690 Generate code that uses (does not use) the FP move to/from general
4691 purpose register instructions implemented on the POWER6X processor and
4692 other processors that support the extended PowerPC V2.05 architecture.
4693
4694 @item mulhw
4695 @itemx no-mulhw
4696 @cindex @code{target("mulhw")} function attribute, PowerPC
4697 Generate code that uses (does not use) the half-word multiply and
4698 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4699 These instructions are generated by default when targeting those
4700 processors.
4701
4702 @item multiple
4703 @itemx no-multiple
4704 @cindex @code{target("multiple")} function attribute, PowerPC
4705 Generate code that uses (does not use) the load multiple word
4706 instructions and the store multiple word instructions.
4707
4708 @item update
4709 @itemx no-update
4710 @cindex @code{target("update")} function attribute, PowerPC
4711 Generate code that uses (does not use) the load or store instructions
4712 that update the base register to the address of the calculated memory
4713 location.
4714
4715 @item popcntb
4716 @itemx no-popcntb
4717 @cindex @code{target("popcntb")} function attribute, PowerPC
4718 Generate code that uses (does not use) the popcount and double-precision
4719 FP reciprocal estimate instruction implemented on the POWER5
4720 processor and other processors that support the PowerPC V2.02
4721 architecture.
4722
4723 @item popcntd
4724 @itemx no-popcntd
4725 @cindex @code{target("popcntd")} function attribute, PowerPC
4726 Generate code that uses (does not use) the popcount instruction
4727 implemented on the POWER7 processor and other processors that support
4728 the PowerPC V2.06 architecture.
4729
4730 @item powerpc-gfxopt
4731 @itemx no-powerpc-gfxopt
4732 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4733 Generate code that uses (does not use) the optional PowerPC
4734 architecture instructions in the Graphics group, including
4735 floating-point select.
4736
4737 @item powerpc-gpopt
4738 @itemx no-powerpc-gpopt
4739 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4740 Generate code that uses (does not use) the optional PowerPC
4741 architecture instructions in the General Purpose group, including
4742 floating-point square root.
4743
4744 @item recip-precision
4745 @itemx no-recip-precision
4746 @cindex @code{target("recip-precision")} function attribute, PowerPC
4747 Assume (do not assume) that the reciprocal estimate instructions
4748 provide higher-precision estimates than is mandated by the PowerPC
4749 ABI.
4750
4751 @item string
4752 @itemx no-string
4753 @cindex @code{target("string")} function attribute, PowerPC
4754 Generate code that uses (does not use) the load string instructions
4755 and the store string word instructions to save multiple registers and
4756 do small block moves.
4757
4758 @item vsx
4759 @itemx no-vsx
4760 @cindex @code{target("vsx")} function attribute, PowerPC
4761 Generate code that uses (does not use) vector/scalar (VSX)
4762 instructions, and also enable the use of built-in functions that allow
4763 more direct access to the VSX instruction set. In 32-bit code, you
4764 cannot enable VSX or AltiVec instructions unless
4765 @option{-mabi=altivec} is used on the command line.
4766
4767 @item friz
4768 @itemx no-friz
4769 @cindex @code{target("friz")} function attribute, PowerPC
4770 Generate (do not generate) the @code{friz} instruction when the
4771 @option{-funsafe-math-optimizations} option is used to optimize
4772 rounding a floating-point value to 64-bit integer and back to floating
4773 point. The @code{friz} instruction does not return the same value if
4774 the floating-point number is too large to fit in an integer.
4775
4776 @item avoid-indexed-addresses
4777 @itemx no-avoid-indexed-addresses
4778 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4779 Generate code that tries to avoid (not avoid) the use of indexed load
4780 or store instructions.
4781
4782 @item paired
4783 @itemx no-paired
4784 @cindex @code{target("paired")} function attribute, PowerPC
4785 Generate code that uses (does not use) the generation of PAIRED simd
4786 instructions.
4787
4788 @item longcall
4789 @itemx no-longcall
4790 @cindex @code{target("longcall")} function attribute, PowerPC
4791 Generate code that assumes (does not assume) that all calls are far
4792 away so that a longer more expensive calling sequence is required.
4793
4794 @item cpu=@var{CPU}
4795 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4796 Specify the architecture to generate code for when compiling the
4797 function. If you select the @code{target("cpu=power7")} attribute when
4798 generating 32-bit code, VSX and AltiVec instructions are not generated
4799 unless you use the @option{-mabi=altivec} option on the command line.
4800
4801 @item tune=@var{TUNE}
4802 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4803 Specify the architecture to tune for when compiling the function. If
4804 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4805 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4806 compilation tunes for the @var{CPU} architecture, and not the
4807 default tuning specified on the command line.
4808 @end table
4809
4810 On the PowerPC, the inliner does not inline a
4811 function that has different target options than the caller, unless the
4812 callee has a subset of the target options of the caller.
4813 @end table
4814
4815 @node RL78 Function Attributes
4816 @subsection RL78 Function Attributes
4817
4818 These function attributes are supported by the RL78 back end:
4819
4820 @table @code
4821 @item interrupt
4822 @itemx brk_interrupt
4823 @cindex @code{interrupt} function attribute, RL78
4824 @cindex @code{brk_interrupt} function attribute, RL78
4825 These attributes indicate
4826 that the specified function is an interrupt handler. The compiler generates
4827 function entry and exit sequences suitable for use in an interrupt handler
4828 when this attribute is present.
4829
4830 Use @code{brk_interrupt} instead of @code{interrupt} for
4831 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4832 that must end with @code{RETB} instead of @code{RETI}).
4833
4834 @item naked
4835 @cindex @code{naked} function attribute, RL78
4836 This attribute allows the compiler to construct the
4837 requisite function declaration, while allowing the body of the
4838 function to be assembly code. The specified function will not have
4839 prologue/epilogue sequences generated by the compiler. Only basic
4840 @code{asm} statements can safely be included in naked functions
4841 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4842 basic @code{asm} and C code may appear to work, they cannot be
4843 depended upon to work reliably and are not supported.
4844 @end table
4845
4846 @node RX Function Attributes
4847 @subsection RX Function Attributes
4848
4849 These function attributes are supported by the RX back end:
4850
4851 @table @code
4852 @item fast_interrupt
4853 @cindex @code{fast_interrupt} function attribute, RX
4854 Use this attribute on the RX port to indicate that the specified
4855 function is a fast interrupt handler. This is just like the
4856 @code{interrupt} attribute, except that @code{freit} is used to return
4857 instead of @code{reit}.
4858
4859 @item interrupt
4860 @cindex @code{interrupt} function attribute, RX
4861 Use this attribute to indicate
4862 that the specified function is an interrupt handler. The compiler generates
4863 function entry and exit sequences suitable for use in an interrupt handler
4864 when this attribute is present.
4865
4866 On RX targets, you may specify one or more vector numbers as arguments
4867 to the attribute, as well as naming an alternate table name.
4868 Parameters are handled sequentially, so one handler can be assigned to
4869 multiple entries in multiple tables. One may also pass the magic
4870 string @code{"$default"} which causes the function to be used for any
4871 unfilled slots in the current table.
4872
4873 This example shows a simple assignment of a function to one vector in
4874 the default table (note that preprocessor macros may be used for
4875 chip-specific symbolic vector names):
4876 @smallexample
4877 void __attribute__ ((interrupt (5))) txd1_handler ();
4878 @end smallexample
4879
4880 This example assigns a function to two slots in the default table
4881 (using preprocessor macros defined elsewhere) and makes it the default
4882 for the @code{dct} table:
4883 @smallexample
4884 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4885 txd1_handler ();
4886 @end smallexample
4887
4888 @item naked
4889 @cindex @code{naked} function attribute, RX
4890 This attribute allows the compiler to construct the
4891 requisite function declaration, while allowing the body of the
4892 function to be assembly code. The specified function will not have
4893 prologue/epilogue sequences generated by the compiler. Only basic
4894 @code{asm} statements can safely be included in naked functions
4895 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4896 basic @code{asm} and C code may appear to work, they cannot be
4897 depended upon to work reliably and are not supported.
4898
4899 @item vector
4900 @cindex @code{vector} function attribute, RX
4901 This RX attribute is similar to the @code{interrupt} attribute, including its
4902 parameters, but does not make the function an interrupt-handler type
4903 function (i.e. it retains the normal C function calling ABI). See the
4904 @code{interrupt} attribute for a description of its arguments.
4905 @end table
4906
4907 @node S/390 Function Attributes
4908 @subsection S/390 Function Attributes
4909
4910 These function attributes are supported on the S/390:
4911
4912 @table @code
4913 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4914 @cindex @code{hotpatch} function attribute, S/390
4915
4916 On S/390 System z targets, you can use this function attribute to
4917 make GCC generate a ``hot-patching'' function prologue. If the
4918 @option{-mhotpatch=} command-line option is used at the same time,
4919 the @code{hotpatch} attribute takes precedence. The first of the
4920 two arguments specifies the number of halfwords to be added before
4921 the function label. A second argument can be used to specify the
4922 number of halfwords to be added after the function label. For
4923 both arguments the maximum allowed value is 1000000.
4924
4925 If both arguments are zero, hotpatching is disabled.
4926 @end table
4927
4928 @node SH Function Attributes
4929 @subsection SH Function Attributes
4930
4931 These function attributes are supported on the SH family of processors:
4932
4933 @table @code
4934 @item function_vector
4935 @cindex @code{function_vector} function attribute, SH
4936 @cindex calling functions through the function vector on SH2A
4937 On SH2A targets, this attribute declares a function to be called using the
4938 TBR relative addressing mode. The argument to this attribute is the entry
4939 number of the same function in a vector table containing all the TBR
4940 relative addressable functions. For correct operation the TBR must be setup
4941 accordingly to point to the start of the vector table before any functions with
4942 this attribute are invoked. Usually a good place to do the initialization is
4943 the startup routine. The TBR relative vector table can have at max 256 function
4944 entries. The jumps to these functions are generated using a SH2A specific,
4945 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
4946 from GNU binutils version 2.7 or later for this attribute to work correctly.
4947
4948 In an application, for a function being called once, this attribute
4949 saves at least 8 bytes of code; and if other successive calls are being
4950 made to the same function, it saves 2 bytes of code per each of these
4951 calls.
4952
4953 @item interrupt_handler
4954 @cindex @code{interrupt_handler} function attribute, SH
4955 Use this attribute to
4956 indicate that the specified function is an interrupt handler. The compiler
4957 generates function entry and exit sequences suitable for use in an
4958 interrupt handler when this attribute is present.
4959
4960 @item nosave_low_regs
4961 @cindex @code{nosave_low_regs} function attribute, SH
4962 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
4963 function should not save and restore registers R0..R7. This can be used on SH3*
4964 and SH4* targets that have a second R0..R7 register bank for non-reentrant
4965 interrupt handlers.
4966
4967 @item renesas
4968 @cindex @code{renesas} function attribute, SH
4969 On SH targets this attribute specifies that the function or struct follows the
4970 Renesas ABI.
4971
4972 @item resbank
4973 @cindex @code{resbank} function attribute, SH
4974 On the SH2A target, this attribute enables the high-speed register
4975 saving and restoration using a register bank for @code{interrupt_handler}
4976 routines. Saving to the bank is performed automatically after the CPU
4977 accepts an interrupt that uses a register bank.
4978
4979 The nineteen 32-bit registers comprising general register R0 to R14,
4980 control register GBR, and system registers MACH, MACL, and PR and the
4981 vector table address offset are saved into a register bank. Register
4982 banks are stacked in first-in last-out (FILO) sequence. Restoration
4983 from the bank is executed by issuing a RESBANK instruction.
4984
4985 @item sp_switch
4986 @cindex @code{sp_switch} function attribute, SH
4987 Use this attribute on the SH to indicate an @code{interrupt_handler}
4988 function should switch to an alternate stack. It expects a string
4989 argument that names a global variable holding the address of the
4990 alternate stack.
4991
4992 @smallexample
4993 void *alt_stack;
4994 void f () __attribute__ ((interrupt_handler,
4995 sp_switch ("alt_stack")));
4996 @end smallexample
4997
4998 @item trap_exit
4999 @cindex @code{trap_exit} function attribute, SH
5000 Use this attribute on the SH for an @code{interrupt_handler} to return using
5001 @code{trapa} instead of @code{rte}. This attribute expects an integer
5002 argument specifying the trap number to be used.
5003
5004 @item trapa_handler
5005 @cindex @code{trapa_handler} function attribute, SH
5006 On SH targets this function attribute is similar to @code{interrupt_handler}
5007 but it does not save and restore all registers.
5008 @end table
5009
5010 @node SPU Function Attributes
5011 @subsection SPU Function Attributes
5012
5013 These function attributes are supported by the SPU back end:
5014
5015 @table @code
5016 @item naked
5017 @cindex @code{naked} function attribute, SPU
5018 This attribute allows the compiler to construct the
5019 requisite function declaration, while allowing the body of the
5020 function to be assembly code. The specified function will not have
5021 prologue/epilogue sequences generated by the compiler. Only basic
5022 @code{asm} statements can safely be included in naked functions
5023 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5024 basic @code{asm} and C code may appear to work, they cannot be
5025 depended upon to work reliably and are not supported.
5026 @end table
5027
5028 @node Symbian OS Function Attributes
5029 @subsection Symbian OS Function Attributes
5030
5031 @xref{Microsoft Windows Function Attributes}, for discussion of the
5032 @code{dllexport} and @code{dllimport} attributes.
5033
5034 @node Visium Function Attributes
5035 @subsection Visium Function Attributes
5036
5037 These function attributes are supported by the Visium back end:
5038
5039 @table @code
5040 @item interrupt
5041 @cindex @code{interrupt} function attribute, Visium
5042 Use this attribute to indicate
5043 that the specified function is an interrupt handler. The compiler generates
5044 function entry and exit sequences suitable for use in an interrupt handler
5045 when this attribute is present.
5046 @end table
5047
5048 @node x86 Function Attributes
5049 @subsection x86 Function Attributes
5050
5051 These function attributes are supported by the x86 back end:
5052
5053 @table @code
5054 @item cdecl
5055 @cindex @code{cdecl} function attribute, x86-32
5056 @cindex functions that pop the argument stack on x86-32
5057 @opindex mrtd
5058 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5059 assume that the calling function pops off the stack space used to
5060 pass arguments. This is
5061 useful to override the effects of the @option{-mrtd} switch.
5062
5063 @item fastcall
5064 @cindex @code{fastcall} function attribute, x86-32
5065 @cindex functions that pop the argument stack on x86-32
5066 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5067 pass the first argument (if of integral type) in the register ECX and
5068 the second argument (if of integral type) in the register EDX@. Subsequent
5069 and other typed arguments are passed on the stack. The called function
5070 pops the arguments off the stack. If the number of arguments is variable all
5071 arguments are pushed on the stack.
5072
5073 @item thiscall
5074 @cindex @code{thiscall} function attribute, x86-32
5075 @cindex functions that pop the argument stack on x86-32
5076 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5077 pass the first argument (if of integral type) in the register ECX.
5078 Subsequent and other typed arguments are passed on the stack. The called
5079 function pops the arguments off the stack.
5080 If the number of arguments is variable all arguments are pushed on the
5081 stack.
5082 The @code{thiscall} attribute is intended for C++ non-static member functions.
5083 As a GCC extension, this calling convention can be used for C functions
5084 and for static member methods.
5085
5086 @item ms_abi
5087 @itemx sysv_abi
5088 @cindex @code{ms_abi} function attribute, x86
5089 @cindex @code{sysv_abi} function attribute, x86
5090
5091 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5092 to indicate which calling convention should be used for a function. The
5093 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5094 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5095 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5096 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5097
5098 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5099 requires the @option{-maccumulate-outgoing-args} option.
5100
5101 @item callee_pop_aggregate_return (@var{number})
5102 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5103
5104 On x86-32 targets, you can use this attribute to control how
5105 aggregates are returned in memory. If the caller is responsible for
5106 popping the hidden pointer together with the rest of the arguments, specify
5107 @var{number} equal to zero. If callee is responsible for popping the
5108 hidden pointer, specify @var{number} equal to one.
5109
5110 The default x86-32 ABI assumes that the callee pops the
5111 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5112 the compiler assumes that the
5113 caller pops the stack for hidden pointer.
5114
5115 @item ms_hook_prologue
5116 @cindex @code{ms_hook_prologue} function attribute, x86
5117
5118 On 32-bit and 64-bit x86 targets, you can use
5119 this function attribute to make GCC generate the ``hot-patching'' function
5120 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5121 and newer.
5122
5123 @item regparm (@var{number})
5124 @cindex @code{regparm} function attribute, x86
5125 @cindex functions that are passed arguments in registers on x86-32
5126 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5127 pass arguments number one to @var{number} if they are of integral type
5128 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5129 take a variable number of arguments continue to be passed all of their
5130 arguments on the stack.
5131
5132 Beware that on some ELF systems this attribute is unsuitable for
5133 global functions in shared libraries with lazy binding (which is the
5134 default). Lazy binding sends the first call via resolving code in
5135 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5136 per the standard calling conventions. Solaris 8 is affected by this.
5137 Systems with the GNU C Library version 2.1 or higher
5138 and FreeBSD are believed to be
5139 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5140 disabled with the linker or the loader if desired, to avoid the
5141 problem.)
5142
5143 @item sseregparm
5144 @cindex @code{sseregparm} function attribute, x86
5145 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5146 causes the compiler to pass up to 3 floating-point arguments in
5147 SSE registers instead of on the stack. Functions that take a
5148 variable number of arguments continue to pass all of their
5149 floating-point arguments on the stack.
5150
5151 @item force_align_arg_pointer
5152 @cindex @code{force_align_arg_pointer} function attribute, x86
5153 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5154 applied to individual function definitions, generating an alternate
5155 prologue and epilogue that realigns the run-time stack if necessary.
5156 This supports mixing legacy codes that run with a 4-byte aligned stack
5157 with modern codes that keep a 16-byte stack for SSE compatibility.
5158
5159 @item stdcall
5160 @cindex @code{stdcall} function attribute, x86-32
5161 @cindex functions that pop the argument stack on x86-32
5162 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5163 assume that the called function pops off the stack space used to
5164 pass arguments, unless it takes a variable number of arguments.
5165
5166 @item target (@var{options})
5167 @cindex @code{target} function attribute
5168 As discussed in @ref{Common Function Attributes}, this attribute
5169 allows specification of target-specific compilation options.
5170
5171 On the x86, the following options are allowed:
5172 @table @samp
5173 @item abm
5174 @itemx no-abm
5175 @cindex @code{target("abm")} function attribute, x86
5176 Enable/disable the generation of the advanced bit instructions.
5177
5178 @item aes
5179 @itemx no-aes
5180 @cindex @code{target("aes")} function attribute, x86
5181 Enable/disable the generation of the AES instructions.
5182
5183 @item default
5184 @cindex @code{target("default")} function attribute, x86
5185 @xref{Function Multiversioning}, where it is used to specify the
5186 default function version.
5187
5188 @item mmx
5189 @itemx no-mmx
5190 @cindex @code{target("mmx")} function attribute, x86
5191 Enable/disable the generation of the MMX instructions.
5192
5193 @item pclmul
5194 @itemx no-pclmul
5195 @cindex @code{target("pclmul")} function attribute, x86
5196 Enable/disable the generation of the PCLMUL instructions.
5197
5198 @item popcnt
5199 @itemx no-popcnt
5200 @cindex @code{target("popcnt")} function attribute, x86
5201 Enable/disable the generation of the POPCNT instruction.
5202
5203 @item sse
5204 @itemx no-sse
5205 @cindex @code{target("sse")} function attribute, x86
5206 Enable/disable the generation of the SSE instructions.
5207
5208 @item sse2
5209 @itemx no-sse2
5210 @cindex @code{target("sse2")} function attribute, x86
5211 Enable/disable the generation of the SSE2 instructions.
5212
5213 @item sse3
5214 @itemx no-sse3
5215 @cindex @code{target("sse3")} function attribute, x86
5216 Enable/disable the generation of the SSE3 instructions.
5217
5218 @item sse4
5219 @itemx no-sse4
5220 @cindex @code{target("sse4")} function attribute, x86
5221 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5222 and SSE4.2).
5223
5224 @item sse4.1
5225 @itemx no-sse4.1
5226 @cindex @code{target("sse4.1")} function attribute, x86
5227 Enable/disable the generation of the sse4.1 instructions.
5228
5229 @item sse4.2
5230 @itemx no-sse4.2
5231 @cindex @code{target("sse4.2")} function attribute, x86
5232 Enable/disable the generation of the sse4.2 instructions.
5233
5234 @item sse4a
5235 @itemx no-sse4a
5236 @cindex @code{target("sse4a")} function attribute, x86
5237 Enable/disable the generation of the SSE4A instructions.
5238
5239 @item fma4
5240 @itemx no-fma4
5241 @cindex @code{target("fma4")} function attribute, x86
5242 Enable/disable the generation of the FMA4 instructions.
5243
5244 @item xop
5245 @itemx no-xop
5246 @cindex @code{target("xop")} function attribute, x86
5247 Enable/disable the generation of the XOP instructions.
5248
5249 @item lwp
5250 @itemx no-lwp
5251 @cindex @code{target("lwp")} function attribute, x86
5252 Enable/disable the generation of the LWP instructions.
5253
5254 @item ssse3
5255 @itemx no-ssse3
5256 @cindex @code{target("ssse3")} function attribute, x86
5257 Enable/disable the generation of the SSSE3 instructions.
5258
5259 @item cld
5260 @itemx no-cld
5261 @cindex @code{target("cld")} function attribute, x86
5262 Enable/disable the generation of the CLD before string moves.
5263
5264 @item fancy-math-387
5265 @itemx no-fancy-math-387
5266 @cindex @code{target("fancy-math-387")} function attribute, x86
5267 Enable/disable the generation of the @code{sin}, @code{cos}, and
5268 @code{sqrt} instructions on the 387 floating-point unit.
5269
5270 @item fused-madd
5271 @itemx no-fused-madd
5272 @cindex @code{target("fused-madd")} function attribute, x86
5273 Enable/disable the generation of the fused multiply/add instructions.
5274
5275 @item ieee-fp
5276 @itemx no-ieee-fp
5277 @cindex @code{target("ieee-fp")} function attribute, x86
5278 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5279
5280 @item inline-all-stringops
5281 @itemx no-inline-all-stringops
5282 @cindex @code{target("inline-all-stringops")} function attribute, x86
5283 Enable/disable inlining of string operations.
5284
5285 @item inline-stringops-dynamically
5286 @itemx no-inline-stringops-dynamically
5287 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5288 Enable/disable the generation of the inline code to do small string
5289 operations and calling the library routines for large operations.
5290
5291 @item align-stringops
5292 @itemx no-align-stringops
5293 @cindex @code{target("align-stringops")} function attribute, x86
5294 Do/do not align destination of inlined string operations.
5295
5296 @item recip
5297 @itemx no-recip
5298 @cindex @code{target("recip")} function attribute, x86
5299 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5300 instructions followed an additional Newton-Raphson step instead of
5301 doing a floating-point division.
5302
5303 @item arch=@var{ARCH}
5304 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5305 Specify the architecture to generate code for in compiling the function.
5306
5307 @item tune=@var{TUNE}
5308 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5309 Specify the architecture to tune for in compiling the function.
5310
5311 @item fpmath=@var{FPMATH}
5312 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5313 Specify which floating-point unit to use. You must specify the
5314 @code{target("fpmath=sse,387")} option as
5315 @code{target("fpmath=sse+387")} because the comma would separate
5316 different options.
5317 @end table
5318
5319 On the x86, the inliner does not inline a
5320 function that has different target options than the caller, unless the
5321 callee has a subset of the target options of the caller. For example
5322 a function declared with @code{target("sse3")} can inline a function
5323 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5324 @end table
5325
5326 @node Xstormy16 Function Attributes
5327 @subsection Xstormy16 Function Attributes
5328
5329 These function attributes are supported by the Xstormy16 back end:
5330
5331 @table @code
5332 @item interrupt
5333 @cindex @code{interrupt} function attribute, Xstormy16
5334 Use this attribute to indicate
5335 that the specified function is an interrupt handler. The compiler generates
5336 function entry and exit sequences suitable for use in an interrupt handler
5337 when this attribute is present.
5338 @end table
5339
5340 @node Variable Attributes
5341 @section Specifying Attributes of Variables
5342 @cindex attribute of variables
5343 @cindex variable attributes
5344
5345 The keyword @code{__attribute__} allows you to specify special
5346 attributes of variables or structure fields. This keyword is followed
5347 by an attribute specification inside double parentheses. Some
5348 attributes are currently defined generically for variables.
5349 Other attributes are defined for variables on particular target
5350 systems. Other attributes are available for functions
5351 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5352 enumerators (@pxref{Enumerator Attributes}), and for types
5353 (@pxref{Type Attributes}).
5354 Other front ends might define more attributes
5355 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5356
5357 @xref{Attribute Syntax}, for details of the exact syntax for using
5358 attributes.
5359
5360 @menu
5361 * Common Variable Attributes::
5362 * AVR Variable Attributes::
5363 * Blackfin Variable Attributes::
5364 * H8/300 Variable Attributes::
5365 * IA-64 Variable Attributes::
5366 * M32R/D Variable Attributes::
5367 * MeP Variable Attributes::
5368 * Microsoft Windows Variable Attributes::
5369 * MSP430 Variable Attributes::
5370 * PowerPC Variable Attributes::
5371 * SPU Variable Attributes::
5372 * x86 Variable Attributes::
5373 * Xstormy16 Variable Attributes::
5374 @end menu
5375
5376 @node Common Variable Attributes
5377 @subsection Common Variable Attributes
5378
5379 The following attributes are supported on most targets.
5380
5381 @table @code
5382 @cindex @code{aligned} variable attribute
5383 @item aligned (@var{alignment})
5384 This attribute specifies a minimum alignment for the variable or
5385 structure field, measured in bytes. For example, the declaration:
5386
5387 @smallexample
5388 int x __attribute__ ((aligned (16))) = 0;
5389 @end smallexample
5390
5391 @noindent
5392 causes the compiler to allocate the global variable @code{x} on a
5393 16-byte boundary. On a 68040, this could be used in conjunction with
5394 an @code{asm} expression to access the @code{move16} instruction which
5395 requires 16-byte aligned operands.
5396
5397 You can also specify the alignment of structure fields. For example, to
5398 create a double-word aligned @code{int} pair, you could write:
5399
5400 @smallexample
5401 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5402 @end smallexample
5403
5404 @noindent
5405 This is an alternative to creating a union with a @code{double} member,
5406 which forces the union to be double-word aligned.
5407
5408 As in the preceding examples, you can explicitly specify the alignment
5409 (in bytes) that you wish the compiler to use for a given variable or
5410 structure field. Alternatively, you can leave out the alignment factor
5411 and just ask the compiler to align a variable or field to the
5412 default alignment for the target architecture you are compiling for.
5413 The default alignment is sufficient for all scalar types, but may not be
5414 enough for all vector types on a target that supports vector operations.
5415 The default alignment is fixed for a particular target ABI.
5416
5417 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5418 which is the largest alignment ever used for any data type on the
5419 target machine you are compiling for. For example, you could write:
5420
5421 @smallexample
5422 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5423 @end smallexample
5424
5425 The compiler automatically sets the alignment for the declared
5426 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5427 often make copy operations more efficient, because the compiler can
5428 use whatever instructions copy the biggest chunks of memory when
5429 performing copies to or from the variables or fields that you have
5430 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5431 may change depending on command-line options.
5432
5433 When used on a struct, or struct member, the @code{aligned} attribute can
5434 only increase the alignment; in order to decrease it, the @code{packed}
5435 attribute must be specified as well. When used as part of a typedef, the
5436 @code{aligned} attribute can both increase and decrease alignment, and
5437 specifying the @code{packed} attribute generates a warning.
5438
5439 Note that the effectiveness of @code{aligned} attributes may be limited
5440 by inherent limitations in your linker. On many systems, the linker is
5441 only able to arrange for variables to be aligned up to a certain maximum
5442 alignment. (For some linkers, the maximum supported alignment may
5443 be very very small.) If your linker is only able to align variables
5444 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5445 in an @code{__attribute__} still only provides you with 8-byte
5446 alignment. See your linker documentation for further information.
5447
5448 The @code{aligned} attribute can also be used for functions
5449 (@pxref{Common Function Attributes}.)
5450
5451 @item cleanup (@var{cleanup_function})
5452 @cindex @code{cleanup} variable attribute
5453 The @code{cleanup} attribute runs a function when the variable goes
5454 out of scope. This attribute can only be applied to auto function
5455 scope variables; it may not be applied to parameters or variables
5456 with static storage duration. The function must take one parameter,
5457 a pointer to a type compatible with the variable. The return value
5458 of the function (if any) is ignored.
5459
5460 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5461 is run during the stack unwinding that happens during the
5462 processing of the exception. Note that the @code{cleanup} attribute
5463 does not allow the exception to be caught, only to perform an action.
5464 It is undefined what happens if @var{cleanup_function} does not
5465 return normally.
5466
5467 @item common
5468 @itemx nocommon
5469 @cindex @code{common} variable attribute
5470 @cindex @code{nocommon} variable attribute
5471 @opindex fcommon
5472 @opindex fno-common
5473 The @code{common} attribute requests GCC to place a variable in
5474 ``common'' storage. The @code{nocommon} attribute requests the
5475 opposite---to allocate space for it directly.
5476
5477 These attributes override the default chosen by the
5478 @option{-fno-common} and @option{-fcommon} flags respectively.
5479
5480 @item deprecated
5481 @itemx deprecated (@var{msg})
5482 @cindex @code{deprecated} variable attribute
5483 The @code{deprecated} attribute results in a warning if the variable
5484 is used anywhere in the source file. This is useful when identifying
5485 variables that are expected to be removed in a future version of a
5486 program. The warning also includes the location of the declaration
5487 of the deprecated variable, to enable users to easily find further
5488 information about why the variable is deprecated, or what they should
5489 do instead. Note that the warning only occurs for uses:
5490
5491 @smallexample
5492 extern int old_var __attribute__ ((deprecated));
5493 extern int old_var;
5494 int new_fn () @{ return old_var; @}
5495 @end smallexample
5496
5497 @noindent
5498 results in a warning on line 3 but not line 2. The optional @var{msg}
5499 argument, which must be a string, is printed in the warning if
5500 present.
5501
5502 The @code{deprecated} attribute can also be used for functions and
5503 types (@pxref{Common Function Attributes},
5504 @pxref{Common Type Attributes}).
5505
5506 @item mode (@var{mode})
5507 @cindex @code{mode} variable attribute
5508 This attribute specifies the data type for the declaration---whichever
5509 type corresponds to the mode @var{mode}. This in effect lets you
5510 request an integer or floating-point type according to its width.
5511
5512 You may also specify a mode of @code{byte} or @code{__byte__} to
5513 indicate the mode corresponding to a one-byte integer, @code{word} or
5514 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5515 or @code{__pointer__} for the mode used to represent pointers.
5516
5517 @item packed
5518 @cindex @code{packed} variable attribute
5519 The @code{packed} attribute specifies that a variable or structure field
5520 should have the smallest possible alignment---one byte for a variable,
5521 and one bit for a field, unless you specify a larger value with the
5522 @code{aligned} attribute.
5523
5524 Here is a structure in which the field @code{x} is packed, so that it
5525 immediately follows @code{a}:
5526
5527 @smallexample
5528 struct foo
5529 @{
5530 char a;
5531 int x[2] __attribute__ ((packed));
5532 @};
5533 @end smallexample
5534
5535 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5536 @code{packed} attribute on bit-fields of type @code{char}. This has
5537 been fixed in GCC 4.4 but the change can lead to differences in the
5538 structure layout. See the documentation of
5539 @option{-Wpacked-bitfield-compat} for more information.
5540
5541 @item section ("@var{section-name}")
5542 @cindex @code{section} variable attribute
5543 Normally, the compiler places the objects it generates in sections like
5544 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5545 or you need certain particular variables to appear in special sections,
5546 for example to map to special hardware. The @code{section}
5547 attribute specifies that a variable (or function) lives in a particular
5548 section. For example, this small program uses several specific section names:
5549
5550 @smallexample
5551 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5552 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5553 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5554 int init_data __attribute__ ((section ("INITDATA")));
5555
5556 main()
5557 @{
5558 /* @r{Initialize stack pointer} */
5559 init_sp (stack + sizeof (stack));
5560
5561 /* @r{Initialize initialized data} */
5562 memcpy (&init_data, &data, &edata - &data);
5563
5564 /* @r{Turn on the serial ports} */
5565 init_duart (&a);
5566 init_duart (&b);
5567 @}
5568 @end smallexample
5569
5570 @noindent
5571 Use the @code{section} attribute with
5572 @emph{global} variables and not @emph{local} variables,
5573 as shown in the example.
5574
5575 You may use the @code{section} attribute with initialized or
5576 uninitialized global variables but the linker requires
5577 each object be defined once, with the exception that uninitialized
5578 variables tentatively go in the @code{common} (or @code{bss}) section
5579 and can be multiply ``defined''. Using the @code{section} attribute
5580 changes what section the variable goes into and may cause the
5581 linker to issue an error if an uninitialized variable has multiple
5582 definitions. You can force a variable to be initialized with the
5583 @option{-fno-common} flag or the @code{nocommon} attribute.
5584
5585 Some file formats do not support arbitrary sections so the @code{section}
5586 attribute is not available on all platforms.
5587 If you need to map the entire contents of a module to a particular
5588 section, consider using the facilities of the linker instead.
5589
5590 @item tls_model ("@var{tls_model}")
5591 @cindex @code{tls_model} variable attribute
5592 The @code{tls_model} attribute sets thread-local storage model
5593 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5594 overriding @option{-ftls-model=} command-line switch on a per-variable
5595 basis.
5596 The @var{tls_model} argument should be one of @code{global-dynamic},
5597 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5598
5599 Not all targets support this attribute.
5600
5601 @item unused
5602 @cindex @code{unused} variable attribute
5603 This attribute, attached to a variable, means that the variable is meant
5604 to be possibly unused. GCC does not produce a warning for this
5605 variable.
5606
5607 @item used
5608 @cindex @code{used} variable attribute
5609 This attribute, attached to a variable with static storage, means that
5610 the variable must be emitted even if it appears that the variable is not
5611 referenced.
5612
5613 When applied to a static data member of a C++ class template, the
5614 attribute also means that the member is instantiated if the
5615 class itself is instantiated.
5616
5617 @item vector_size (@var{bytes})
5618 @cindex @code{vector_size} variable attribute
5619 This attribute specifies the vector size for the variable, measured in
5620 bytes. For example, the declaration:
5621
5622 @smallexample
5623 int foo __attribute__ ((vector_size (16)));
5624 @end smallexample
5625
5626 @noindent
5627 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5628 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5629 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5630
5631 This attribute is only applicable to integral and float scalars,
5632 although arrays, pointers, and function return values are allowed in
5633 conjunction with this construct.
5634
5635 Aggregates with this attribute are invalid, even if they are of the same
5636 size as a corresponding scalar. For example, the declaration:
5637
5638 @smallexample
5639 struct S @{ int a; @};
5640 struct S __attribute__ ((vector_size (16))) foo;
5641 @end smallexample
5642
5643 @noindent
5644 is invalid even if the size of the structure is the same as the size of
5645 the @code{int}.
5646
5647 @item weak
5648 @cindex @code{weak} variable attribute
5649 The @code{weak} attribute is described in
5650 @ref{Common Function Attributes}.
5651
5652 @end table
5653
5654 @node AVR Variable Attributes
5655 @subsection AVR Variable Attributes
5656
5657 @table @code
5658 @item progmem
5659 @cindex @code{progmem} variable attribute, AVR
5660 The @code{progmem} attribute is used on the AVR to place read-only
5661 data in the non-volatile program memory (flash). The @code{progmem}
5662 attribute accomplishes this by putting respective variables into a
5663 section whose name starts with @code{.progmem}.
5664
5665 This attribute works similar to the @code{section} attribute
5666 but adds additional checking. Notice that just like the
5667 @code{section} attribute, @code{progmem} affects the location
5668 of the data but not how this data is accessed.
5669
5670 In order to read data located with the @code{progmem} attribute
5671 (inline) assembler must be used.
5672 @smallexample
5673 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5674 #include <avr/pgmspace.h>
5675
5676 /* Locate var in flash memory */
5677 const int var[2] PROGMEM = @{ 1, 2 @};
5678
5679 int read_var (int i)
5680 @{
5681 /* Access var[] by accessor macro from avr/pgmspace.h */
5682 return (int) pgm_read_word (& var[i]);
5683 @}
5684 @end smallexample
5685
5686 AVR is a Harvard architecture processor and data and read-only data
5687 normally resides in the data memory (RAM).
5688
5689 See also the @ref{AVR Named Address Spaces} section for
5690 an alternate way to locate and access data in flash memory.
5691
5692 @item io
5693 @itemx io (@var{addr})
5694 @cindex @code{io} variable attribute, AVR
5695 Variables with the @code{io} attribute are used to address
5696 memory-mapped peripherals in the io address range.
5697 If an address is specified, the variable
5698 is assigned that address, and the value is interpreted as an
5699 address in the data address space.
5700 Example:
5701
5702 @smallexample
5703 volatile int porta __attribute__((io (0x22)));
5704 @end smallexample
5705
5706 The address specified in the address in the data address range.
5707
5708 Otherwise, the variable it is not assigned an address, but the
5709 compiler will still use in/out instructions where applicable,
5710 assuming some other module assigns an address in the io address range.
5711 Example:
5712
5713 @smallexample
5714 extern volatile int porta __attribute__((io));
5715 @end smallexample
5716
5717 @item io_low
5718 @itemx io_low (@var{addr})
5719 @cindex @code{io_low} variable attribute, AVR
5720 This is like the @code{io} attribute, but additionally it informs the
5721 compiler that the object lies in the lower half of the I/O area,
5722 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5723 instructions.
5724
5725 @item address
5726 @itemx address (@var{addr})
5727 @cindex @code{address} variable attribute, AVR
5728 Variables with the @code{address} attribute are used to address
5729 memory-mapped peripherals that may lie outside the io address range.
5730
5731 @smallexample
5732 volatile int porta __attribute__((address (0x600)));
5733 @end smallexample
5734
5735 @end table
5736
5737 @node Blackfin Variable Attributes
5738 @subsection Blackfin Variable Attributes
5739
5740 Three attributes are currently defined for the Blackfin.
5741
5742 @table @code
5743 @item l1_data
5744 @itemx l1_data_A
5745 @itemx l1_data_B
5746 @cindex @code{l1_data} variable attribute, Blackfin
5747 @cindex @code{l1_data_A} variable attribute, Blackfin
5748 @cindex @code{l1_data_B} variable attribute, Blackfin
5749 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5750 Variables with @code{l1_data} attribute are put into the specific section
5751 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5752 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5753 attribute are put into the specific section named @code{.l1.data.B}.
5754
5755 @item l2
5756 @cindex @code{l2} variable attribute, Blackfin
5757 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5758 Variables with @code{l2} attribute are put into the specific section
5759 named @code{.l2.data}.
5760 @end table
5761
5762 @node H8/300 Variable Attributes
5763 @subsection H8/300 Variable Attributes
5764
5765 These variable attributes are available for H8/300 targets:
5766
5767 @table @code
5768 @item eightbit_data
5769 @cindex @code{eightbit_data} variable attribute, H8/300
5770 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5771 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5772 variable should be placed into the eight-bit data section.
5773 The compiler generates more efficient code for certain operations
5774 on data in the eight-bit data area. Note the eight-bit data area is limited to
5775 256 bytes of data.
5776
5777 You must use GAS and GLD from GNU binutils version 2.7 or later for
5778 this attribute to work correctly.
5779
5780 @item tiny_data
5781 @cindex @code{tiny_data} variable attribute, H8/300
5782 @cindex tiny data section on the H8/300H and H8S
5783 Use this attribute on the H8/300H and H8S to indicate that the specified
5784 variable should be placed into the tiny data section.
5785 The compiler generates more efficient code for loads and stores
5786 on data in the tiny data section. Note the tiny data area is limited to
5787 slightly under 32KB of data.
5788
5789 @end table
5790
5791 @node IA-64 Variable Attributes
5792 @subsection IA-64 Variable Attributes
5793
5794 The IA-64 back end supports the following variable attribute:
5795
5796 @table @code
5797 @item model (@var{model-name})
5798 @cindex @code{model} variable attribute, IA-64
5799
5800 On IA-64, use this attribute to set the addressability of an object.
5801 At present, the only supported identifier for @var{model-name} is
5802 @code{small}, indicating addressability via ``small'' (22-bit)
5803 addresses (so that their addresses can be loaded with the @code{addl}
5804 instruction). Caveat: such addressing is by definition not position
5805 independent and hence this attribute must not be used for objects
5806 defined by shared libraries.
5807
5808 @end table
5809
5810 @node M32R/D Variable Attributes
5811 @subsection M32R/D Variable Attributes
5812
5813 One attribute is currently defined for the M32R/D@.
5814
5815 @table @code
5816 @item model (@var{model-name})
5817 @cindex @code{model-name} variable attribute, M32R/D
5818 @cindex variable addressability on the M32R/D
5819 Use this attribute on the M32R/D to set the addressability of an object.
5820 The identifier @var{model-name} is one of @code{small}, @code{medium},
5821 or @code{large}, representing each of the code models.
5822
5823 Small model objects live in the lower 16MB of memory (so that their
5824 addresses can be loaded with the @code{ld24} instruction).
5825
5826 Medium and large model objects may live anywhere in the 32-bit address space
5827 (the compiler generates @code{seth/add3} instructions to load their
5828 addresses).
5829 @end table
5830
5831 @node MeP Variable Attributes
5832 @subsection MeP Variable Attributes
5833
5834 The MeP target has a number of addressing modes and busses. The
5835 @code{near} space spans the standard memory space's first 16 megabytes
5836 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5837 The @code{based} space is a 128-byte region in the memory space that
5838 is addressed relative to the @code{$tp} register. The @code{tiny}
5839 space is a 65536-byte region relative to the @code{$gp} register. In
5840 addition to these memory regions, the MeP target has a separate 16-bit
5841 control bus which is specified with @code{cb} attributes.
5842
5843 @table @code
5844
5845 @item based
5846 @cindex @code{based} variable attribute, MeP
5847 Any variable with the @code{based} attribute is assigned to the
5848 @code{.based} section, and is accessed with relative to the
5849 @code{$tp} register.
5850
5851 @item tiny
5852 @cindex @code{tiny} variable attribute, MeP
5853 Likewise, the @code{tiny} attribute assigned variables to the
5854 @code{.tiny} section, relative to the @code{$gp} register.
5855
5856 @item near
5857 @cindex @code{near} variable attribute, MeP
5858 Variables with the @code{near} attribute are assumed to have addresses
5859 that fit in a 24-bit addressing mode. This is the default for large
5860 variables (@code{-mtiny=4} is the default) but this attribute can
5861 override @code{-mtiny=} for small variables, or override @code{-ml}.
5862
5863 @item far
5864 @cindex @code{far} variable attribute, MeP
5865 Variables with the @code{far} attribute are addressed using a full
5866 32-bit address. Since this covers the entire memory space, this
5867 allows modules to make no assumptions about where variables might be
5868 stored.
5869
5870 @item io
5871 @cindex @code{io} variable attribute, MeP
5872 @itemx io (@var{addr})
5873 Variables with the @code{io} attribute are used to address
5874 memory-mapped peripherals. If an address is specified, the variable
5875 is assigned that address, else it is not assigned an address (it is
5876 assumed some other module assigns an address). Example:
5877
5878 @smallexample
5879 int timer_count __attribute__((io(0x123)));
5880 @end smallexample
5881
5882 @item cb
5883 @itemx cb (@var{addr})
5884 @cindex @code{cb} variable attribute, MeP
5885 Variables with the @code{cb} attribute are used to access the control
5886 bus, using special instructions. @code{addr} indicates the control bus
5887 address. Example:
5888
5889 @smallexample
5890 int cpu_clock __attribute__((cb(0x123)));
5891 @end smallexample
5892
5893 @end table
5894
5895 @node Microsoft Windows Variable Attributes
5896 @subsection Microsoft Windows Variable Attributes
5897
5898 You can use these attributes on Microsoft Windows targets.
5899 @ref{x86 Variable Attributes} for additional Windows compatibility
5900 attributes available on all x86 targets.
5901
5902 @table @code
5903 @item dllimport
5904 @itemx dllexport
5905 @cindex @code{dllimport} variable attribute
5906 @cindex @code{dllexport} variable attribute
5907 The @code{dllimport} and @code{dllexport} attributes are described in
5908 @ref{Microsoft Windows Function Attributes}.
5909
5910 @item selectany
5911 @cindex @code{selectany} variable attribute
5912 The @code{selectany} attribute causes an initialized global variable to
5913 have link-once semantics. When multiple definitions of the variable are
5914 encountered by the linker, the first is selected and the remainder are
5915 discarded. Following usage by the Microsoft compiler, the linker is told
5916 @emph{not} to warn about size or content differences of the multiple
5917 definitions.
5918
5919 Although the primary usage of this attribute is for POD types, the
5920 attribute can also be applied to global C++ objects that are initialized
5921 by a constructor. In this case, the static initialization and destruction
5922 code for the object is emitted in each translation defining the object,
5923 but the calls to the constructor and destructor are protected by a
5924 link-once guard variable.
5925
5926 The @code{selectany} attribute is only available on Microsoft Windows
5927 targets. You can use @code{__declspec (selectany)} as a synonym for
5928 @code{__attribute__ ((selectany))} for compatibility with other
5929 compilers.
5930
5931 @item shared
5932 @cindex @code{shared} variable attribute
5933 On Microsoft Windows, in addition to putting variable definitions in a named
5934 section, the section can also be shared among all running copies of an
5935 executable or DLL@. For example, this small program defines shared data
5936 by putting it in a named section @code{shared} and marking the section
5937 shareable:
5938
5939 @smallexample
5940 int foo __attribute__((section ("shared"), shared)) = 0;
5941
5942 int
5943 main()
5944 @{
5945 /* @r{Read and write foo. All running
5946 copies see the same value.} */
5947 return 0;
5948 @}
5949 @end smallexample
5950
5951 @noindent
5952 You may only use the @code{shared} attribute along with @code{section}
5953 attribute with a fully-initialized global definition because of the way
5954 linkers work. See @code{section} attribute for more information.
5955
5956 The @code{shared} attribute is only available on Microsoft Windows@.
5957
5958 @end table
5959
5960 @node MSP430 Variable Attributes
5961 @subsection MSP430 Variable Attributes
5962
5963 @table @code
5964 @item noinit
5965 @cindex @code{noinit} MSP430 variable attribute
5966 Any data with the @code{noinit} attribute will not be initialised by
5967 the C runtime startup code, or the program loader. Not initialising
5968 data in this way can reduce program startup times.
5969
5970 @item persistent
5971 @cindex @code{persistent} MSP430 variable attribute
5972 Any variable with the @code{persistent} attribute will not be
5973 initialised by the C runtime startup code. Instead its value will be
5974 set once, when the application is loaded, and then never initialised
5975 again, even if the processor is reset or the program restarts.
5976 Persistent data is intended to be placed into FLASH RAM, where its
5977 value will be retained across resets. The linker script being used to
5978 create the application should ensure that persistent data is correctly
5979 placed.
5980
5981 @item lower
5982 @itemx upper
5983 @itemx either
5984 @cindex @code{lower} memory region on the MSP430
5985 @cindex @code{upper} memory region on the MSP430
5986 @cindex @code{either} memory region on the MSP430
5987 These attributes are the same as the MSP430 function attributes of the
5988 same name. These attributes can be applied to both functions and
5989 variables.
5990 @end table
5991
5992 @node PowerPC Variable Attributes
5993 @subsection PowerPC Variable Attributes
5994
5995 Three attributes currently are defined for PowerPC configurations:
5996 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
5997
5998 @cindex @code{ms_struct} variable attribute, PowerPC
5999 @cindex @code{gcc_struct} variable attribute, PowerPC
6000 For full documentation of the struct attributes please see the
6001 documentation in @ref{x86 Variable Attributes}.
6002
6003 @cindex @code{altivec} variable attribute, PowerPC
6004 For documentation of @code{altivec} attribute please see the
6005 documentation in @ref{PowerPC Type Attributes}.
6006
6007 @node SPU Variable Attributes
6008 @subsection SPU Variable Attributes
6009
6010 @cindex @code{spu_vector} variable attribute, SPU
6011 The SPU supports the @code{spu_vector} attribute for variables. For
6012 documentation of this attribute please see the documentation in
6013 @ref{SPU Type Attributes}.
6014
6015 @node x86 Variable Attributes
6016 @subsection x86 Variable Attributes
6017
6018 Two attributes are currently defined for x86 configurations:
6019 @code{ms_struct} and @code{gcc_struct}.
6020
6021 @table @code
6022 @item ms_struct
6023 @itemx gcc_struct
6024 @cindex @code{ms_struct} variable attribute, x86
6025 @cindex @code{gcc_struct} variable attribute, x86
6026
6027 If @code{packed} is used on a structure, or if bit-fields are used,
6028 it may be that the Microsoft ABI lays out the structure differently
6029 than the way GCC normally does. Particularly when moving packed
6030 data between functions compiled with GCC and the native Microsoft compiler
6031 (either via function call or as data in a file), it may be necessary to access
6032 either format.
6033
6034 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6035 compilers to match the native Microsoft compiler.
6036
6037 The Microsoft structure layout algorithm is fairly simple with the exception
6038 of the bit-field packing.
6039 The padding and alignment of members of structures and whether a bit-field
6040 can straddle a storage-unit boundary are determine by these rules:
6041
6042 @enumerate
6043 @item Structure members are stored sequentially in the order in which they are
6044 declared: the first member has the lowest memory address and the last member
6045 the highest.
6046
6047 @item Every data object has an alignment requirement. The alignment requirement
6048 for all data except structures, unions, and arrays is either the size of the
6049 object or the current packing size (specified with either the
6050 @code{aligned} attribute or the @code{pack} pragma),
6051 whichever is less. For structures, unions, and arrays,
6052 the alignment requirement is the largest alignment requirement of its members.
6053 Every object is allocated an offset so that:
6054
6055 @smallexample
6056 offset % alignment_requirement == 0
6057 @end smallexample
6058
6059 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
6060 unit if the integral types are the same size and if the next bit-field fits
6061 into the current allocation unit without crossing the boundary imposed by the
6062 common alignment requirements of the bit-fields.
6063 @end enumerate
6064
6065 MSVC interprets zero-length bit-fields in the following ways:
6066
6067 @enumerate
6068 @item If a zero-length bit-field is inserted between two bit-fields that
6069 are normally coalesced, the bit-fields are not coalesced.
6070
6071 For example:
6072
6073 @smallexample
6074 struct
6075 @{
6076 unsigned long bf_1 : 12;
6077 unsigned long : 0;
6078 unsigned long bf_2 : 12;
6079 @} t1;
6080 @end smallexample
6081
6082 @noindent
6083 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
6084 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
6085
6086 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
6087 alignment of the zero-length bit-field is greater than the member that follows it,
6088 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
6089
6090 For example:
6091
6092 @smallexample
6093 struct
6094 @{
6095 char foo : 4;
6096 short : 0;
6097 char bar;
6098 @} t2;
6099
6100 struct
6101 @{
6102 char foo : 4;
6103 short : 0;
6104 double bar;
6105 @} t3;
6106 @end smallexample
6107
6108 @noindent
6109 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
6110 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
6111 bit-field does not affect the alignment of @code{bar} or, as a result, the size
6112 of the structure.
6113
6114 Taking this into account, it is important to note the following:
6115
6116 @enumerate
6117 @item If a zero-length bit-field follows a normal bit-field, the type of the
6118 zero-length bit-field may affect the alignment of the structure as whole. For
6119 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
6120 normal bit-field, and is of type short.
6121
6122 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
6123 still affect the alignment of the structure:
6124
6125 @smallexample
6126 struct
6127 @{
6128 char foo : 6;
6129 long : 0;
6130 @} t4;
6131 @end smallexample
6132
6133 @noindent
6134 Here, @code{t4} takes up 4 bytes.
6135 @end enumerate
6136
6137 @item Zero-length bit-fields following non-bit-field members are ignored:
6138
6139 @smallexample
6140 struct
6141 @{
6142 char foo;
6143 long : 0;
6144 char bar;
6145 @} t5;
6146 @end smallexample
6147
6148 @noindent
6149 Here, @code{t5} takes up 2 bytes.
6150 @end enumerate
6151 @end table
6152
6153 @node Xstormy16 Variable Attributes
6154 @subsection Xstormy16 Variable Attributes
6155
6156 One attribute is currently defined for xstormy16 configurations:
6157 @code{below100}.
6158
6159 @table @code
6160 @item below100
6161 @cindex @code{below100} variable attribute, Xstormy16
6162
6163 If a variable has the @code{below100} attribute (@code{BELOW100} is
6164 allowed also), GCC places the variable in the first 0x100 bytes of
6165 memory and use special opcodes to access it. Such variables are
6166 placed in either the @code{.bss_below100} section or the
6167 @code{.data_below100} section.
6168
6169 @end table
6170
6171 @node Type Attributes
6172 @section Specifying Attributes of Types
6173 @cindex attribute of types
6174 @cindex type attributes
6175
6176 The keyword @code{__attribute__} allows you to specify special
6177 attributes of types. Some type attributes apply only to @code{struct}
6178 and @code{union} types, while others can apply to any type defined
6179 via a @code{typedef} declaration. Other attributes are defined for
6180 functions (@pxref{Function Attributes}), labels (@pxref{Label
6181 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6182 variables (@pxref{Variable Attributes}).
6183
6184 The @code{__attribute__} keyword is followed by an attribute specification
6185 inside double parentheses.
6186
6187 You may specify type attributes in an enum, struct or union type
6188 declaration or definition by placing them immediately after the
6189 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6190 syntax is to place them just past the closing curly brace of the
6191 definition.
6192
6193 You can also include type attributes in a @code{typedef} declaration.
6194 @xref{Attribute Syntax}, for details of the exact syntax for using
6195 attributes.
6196
6197 @menu
6198 * Common Type Attributes::
6199 * ARM Type Attributes::
6200 * MeP Type Attributes::
6201 * PowerPC Type Attributes::
6202 * SPU Type Attributes::
6203 * x86 Type Attributes::
6204 @end menu
6205
6206 @node Common Type Attributes
6207 @subsection Common Type Attributes
6208
6209 The following type attributes are supported on most targets.
6210
6211 @table @code
6212 @cindex @code{aligned} type attribute
6213 @item aligned (@var{alignment})
6214 This attribute specifies a minimum alignment (in bytes) for variables
6215 of the specified type. For example, the declarations:
6216
6217 @smallexample
6218 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6219 typedef int more_aligned_int __attribute__ ((aligned (8)));
6220 @end smallexample
6221
6222 @noindent
6223 force the compiler to ensure (as far as it can) that each variable whose
6224 type is @code{struct S} or @code{more_aligned_int} is allocated and
6225 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6226 variables of type @code{struct S} aligned to 8-byte boundaries allows
6227 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6228 store) instructions when copying one variable of type @code{struct S} to
6229 another, thus improving run-time efficiency.
6230
6231 Note that the alignment of any given @code{struct} or @code{union} type
6232 is required by the ISO C standard to be at least a perfect multiple of
6233 the lowest common multiple of the alignments of all of the members of
6234 the @code{struct} or @code{union} in question. This means that you @emph{can}
6235 effectively adjust the alignment of a @code{struct} or @code{union}
6236 type by attaching an @code{aligned} attribute to any one of the members
6237 of such a type, but the notation illustrated in the example above is a
6238 more obvious, intuitive, and readable way to request the compiler to
6239 adjust the alignment of an entire @code{struct} or @code{union} type.
6240
6241 As in the preceding example, you can explicitly specify the alignment
6242 (in bytes) that you wish the compiler to use for a given @code{struct}
6243 or @code{union} type. Alternatively, you can leave out the alignment factor
6244 and just ask the compiler to align a type to the maximum
6245 useful alignment for the target machine you are compiling for. For
6246 example, you could write:
6247
6248 @smallexample
6249 struct S @{ short f[3]; @} __attribute__ ((aligned));
6250 @end smallexample
6251
6252 Whenever you leave out the alignment factor in an @code{aligned}
6253 attribute specification, the compiler automatically sets the alignment
6254 for the type to the largest alignment that is ever used for any data
6255 type on the target machine you are compiling for. Doing this can often
6256 make copy operations more efficient, because the compiler can use
6257 whatever instructions copy the biggest chunks of memory when performing
6258 copies to or from the variables that have types that you have aligned
6259 this way.
6260
6261 In the example above, if the size of each @code{short} is 2 bytes, then
6262 the size of the entire @code{struct S} type is 6 bytes. The smallest
6263 power of two that is greater than or equal to that is 8, so the
6264 compiler sets the alignment for the entire @code{struct S} type to 8
6265 bytes.
6266
6267 Note that although you can ask the compiler to select a time-efficient
6268 alignment for a given type and then declare only individual stand-alone
6269 objects of that type, the compiler's ability to select a time-efficient
6270 alignment is primarily useful only when you plan to create arrays of
6271 variables having the relevant (efficiently aligned) type. If you
6272 declare or use arrays of variables of an efficiently-aligned type, then
6273 it is likely that your program also does pointer arithmetic (or
6274 subscripting, which amounts to the same thing) on pointers to the
6275 relevant type, and the code that the compiler generates for these
6276 pointer arithmetic operations is often more efficient for
6277 efficiently-aligned types than for other types.
6278
6279 The @code{aligned} attribute can only increase the alignment; but you
6280 can decrease it by specifying @code{packed} as well. See below.
6281
6282 Note that the effectiveness of @code{aligned} attributes may be limited
6283 by inherent limitations in your linker. On many systems, the linker is
6284 only able to arrange for variables to be aligned up to a certain maximum
6285 alignment. (For some linkers, the maximum supported alignment may
6286 be very very small.) If your linker is only able to align variables
6287 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6288 in an @code{__attribute__} still only provides you with 8-byte
6289 alignment. See your linker documentation for further information.
6290
6291 @opindex fshort-enums
6292 Specifying this attribute for @code{struct} and @code{union} types is
6293 equivalent to specifying the @code{packed} attribute on each of the
6294 structure or union members. Specifying the @option{-fshort-enums}
6295 flag on the line is equivalent to specifying the @code{packed}
6296 attribute on all @code{enum} definitions.
6297
6298 In the following example @code{struct my_packed_struct}'s members are
6299 packed closely together, but the internal layout of its @code{s} member
6300 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6301 be packed too.
6302
6303 @smallexample
6304 struct my_unpacked_struct
6305 @{
6306 char c;
6307 int i;
6308 @};
6309
6310 struct __attribute__ ((__packed__)) my_packed_struct
6311 @{
6312 char c;
6313 int i;
6314 struct my_unpacked_struct s;
6315 @};
6316 @end smallexample
6317
6318 You may only specify this attribute on the definition of an @code{enum},
6319 @code{struct} or @code{union}, not on a @code{typedef} that does not
6320 also define the enumerated type, structure or union.
6321
6322 @item bnd_variable_size
6323 @cindex @code{bnd_variable_size} type attribute
6324 @cindex Pointer Bounds Checker attributes
6325 When applied to a structure field, this attribute tells Pointer
6326 Bounds Checker that the size of this field should not be computed
6327 using static type information. It may be used to mark variably-sized
6328 static array fields placed at the end of a structure.
6329
6330 @smallexample
6331 struct S
6332 @{
6333 int size;
6334 char data[1];
6335 @}
6336 S *p = (S *)malloc (sizeof(S) + 100);
6337 p->data[10] = 0; //Bounds violation
6338 @end smallexample
6339
6340 @noindent
6341 By using an attribute for the field we may avoid unwanted bound
6342 violation checks:
6343
6344 @smallexample
6345 struct S
6346 @{
6347 int size;
6348 char data[1] __attribute__((bnd_variable_size));
6349 @}
6350 S *p = (S *)malloc (sizeof(S) + 100);
6351 p->data[10] = 0; //OK
6352 @end smallexample
6353
6354 @item deprecated
6355 @itemx deprecated (@var{msg})
6356 @cindex @code{deprecated} type attribute
6357 The @code{deprecated} attribute results in a warning if the type
6358 is used anywhere in the source file. This is useful when identifying
6359 types that are expected to be removed in a future version of a program.
6360 If possible, the warning also includes the location of the declaration
6361 of the deprecated type, to enable users to easily find further
6362 information about why the type is deprecated, or what they should do
6363 instead. Note that the warnings only occur for uses and then only
6364 if the type is being applied to an identifier that itself is not being
6365 declared as deprecated.
6366
6367 @smallexample
6368 typedef int T1 __attribute__ ((deprecated));
6369 T1 x;
6370 typedef T1 T2;
6371 T2 y;
6372 typedef T1 T3 __attribute__ ((deprecated));
6373 T3 z __attribute__ ((deprecated));
6374 @end smallexample
6375
6376 @noindent
6377 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6378 warning is issued for line 4 because T2 is not explicitly
6379 deprecated. Line 5 has no warning because T3 is explicitly
6380 deprecated. Similarly for line 6. The optional @var{msg}
6381 argument, which must be a string, is printed in the warning if
6382 present.
6383
6384 The @code{deprecated} attribute can also be used for functions and
6385 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6386
6387 @item designated_init
6388 @cindex @code{designated_init} type attribute
6389 This attribute may only be applied to structure types. It indicates
6390 that any initialization of an object of this type must use designated
6391 initializers rather than positional initializers. The intent of this
6392 attribute is to allow the programmer to indicate that a structure's
6393 layout may change, and that therefore relying on positional
6394 initialization will result in future breakage.
6395
6396 GCC emits warnings based on this attribute by default; use
6397 @option{-Wno-designated-init} to suppress them.
6398
6399 @item may_alias
6400 @cindex @code{may_alias} type attribute
6401 Accesses through pointers to types with this attribute are not subject
6402 to type-based alias analysis, but are instead assumed to be able to alias
6403 any other type of objects.
6404 In the context of section 6.5 paragraph 7 of the C99 standard,
6405 an lvalue expression
6406 dereferencing such a pointer is treated like having a character type.
6407 See @option{-fstrict-aliasing} for more information on aliasing issues.
6408 This extension exists to support some vector APIs, in which pointers to
6409 one vector type are permitted to alias pointers to a different vector type.
6410
6411 Note that an object of a type with this attribute does not have any
6412 special semantics.
6413
6414 Example of use:
6415
6416 @smallexample
6417 typedef short __attribute__((__may_alias__)) short_a;
6418
6419 int
6420 main (void)
6421 @{
6422 int a = 0x12345678;
6423 short_a *b = (short_a *) &a;
6424
6425 b[1] = 0;
6426
6427 if (a == 0x12345678)
6428 abort();
6429
6430 exit(0);
6431 @}
6432 @end smallexample
6433
6434 @noindent
6435 If you replaced @code{short_a} with @code{short} in the variable
6436 declaration, the above program would abort when compiled with
6437 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6438 above.
6439
6440 @item packed
6441 @cindex @code{packed} type attribute
6442 This attribute, attached to @code{struct} or @code{union} type
6443 definition, specifies that each member (other than zero-width bit-fields)
6444 of the structure or union is placed to minimize the memory required. When
6445 attached to an @code{enum} definition, it indicates that the smallest
6446 integral type should be used.
6447
6448 @item scalar_storage_order ("@var{endianness}")
6449 @cindex @code{scalar_storage_order} type attribute
6450 When attached to a @code{union} or a @code{struct}, this attribute sets
6451 the storage order, aka endianness, of the scalar fields of the type, as
6452 well as the array fields whose component is scalar. The supported
6453 endianness are @code{big-endian} and @code{little-endian}. The attribute
6454 has no effects on fields which are themselves a @code{union}, a @code{struct}
6455 or an array whose component is a @code{union} or a @code{struct}, and it is
6456 possible to have fields with a different scalar storage order than the
6457 enclosing type.
6458
6459 This attribute is supported only for targets that use a uniform default
6460 scalar storage order (fortunately, most of them), i.e. targets that store
6461 the scalars either all in big-endian or all in little-endian.
6462
6463 Additional restrictions are enforced for types with the reverse scalar
6464 storage order with regard to the scalar storage order of the target:
6465
6466 @itemize
6467 @item Taking the address of a scalar field of a @code{union} or a
6468 @code{struct} with reverse scalar storage order is not permitted and will
6469 yield an error.
6470 @item Taking the address of an array field, whose component is scalar, of
6471 a @code{union} or a @code{struct} with reverse scalar storage order is
6472 permitted but will yield a warning, unless @option{-Wno-scalar-storage-order}
6473 is specified.
6474 @item Taking the address of a @code{union} or a @code{struct} with reverse
6475 scalar storage order is permitted.
6476 @end itemize
6477
6478 These restrictions exist because the storage order attribute is lost when
6479 the address of a scalar or the address of an array with scalar component
6480 is taken, so storing indirectly through this address will generally not work.
6481 The second case is nevertheless allowed to be able to perform a block copy
6482 from or to the array.
6483
6484 @item transparent_union
6485 @cindex @code{transparent_union} type attribute
6486
6487 This attribute, attached to a @code{union} type definition, indicates
6488 that any function parameter having that union type causes calls to that
6489 function to be treated in a special way.
6490
6491 First, the argument corresponding to a transparent union type can be of
6492 any type in the union; no cast is required. Also, if the union contains
6493 a pointer type, the corresponding argument can be a null pointer
6494 constant or a void pointer expression; and if the union contains a void
6495 pointer type, the corresponding argument can be any pointer expression.
6496 If the union member type is a pointer, qualifiers like @code{const} on
6497 the referenced type must be respected, just as with normal pointer
6498 conversions.
6499
6500 Second, the argument is passed to the function using the calling
6501 conventions of the first member of the transparent union, not the calling
6502 conventions of the union itself. All members of the union must have the
6503 same machine representation; this is necessary for this argument passing
6504 to work properly.
6505
6506 Transparent unions are designed for library functions that have multiple
6507 interfaces for compatibility reasons. For example, suppose the
6508 @code{wait} function must accept either a value of type @code{int *} to
6509 comply with POSIX, or a value of type @code{union wait *} to comply with
6510 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6511 @code{wait} would accept both kinds of arguments, but it would also
6512 accept any other pointer type and this would make argument type checking
6513 less useful. Instead, @code{<sys/wait.h>} might define the interface
6514 as follows:
6515
6516 @smallexample
6517 typedef union __attribute__ ((__transparent_union__))
6518 @{
6519 int *__ip;
6520 union wait *__up;
6521 @} wait_status_ptr_t;
6522
6523 pid_t wait (wait_status_ptr_t);
6524 @end smallexample
6525
6526 @noindent
6527 This interface allows either @code{int *} or @code{union wait *}
6528 arguments to be passed, using the @code{int *} calling convention.
6529 The program can call @code{wait} with arguments of either type:
6530
6531 @smallexample
6532 int w1 () @{ int w; return wait (&w); @}
6533 int w2 () @{ union wait w; return wait (&w); @}
6534 @end smallexample
6535
6536 @noindent
6537 With this interface, @code{wait}'s implementation might look like this:
6538
6539 @smallexample
6540 pid_t wait (wait_status_ptr_t p)
6541 @{
6542 return waitpid (-1, p.__ip, 0);
6543 @}
6544 @end smallexample
6545
6546 @item unused
6547 @cindex @code{unused} type attribute
6548 When attached to a type (including a @code{union} or a @code{struct}),
6549 this attribute means that variables of that type are meant to appear
6550 possibly unused. GCC does not produce a warning for any variables of
6551 that type, even if the variable appears to do nothing. This is often
6552 the case with lock or thread classes, which are usually defined and then
6553 not referenced, but contain constructors and destructors that have
6554 nontrivial bookkeeping functions.
6555
6556 @item visibility
6557 @cindex @code{visibility} type attribute
6558 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6559 applied to class, struct, union and enum types. Unlike other type
6560 attributes, the attribute must appear between the initial keyword and
6561 the name of the type; it cannot appear after the body of the type.
6562
6563 Note that the type visibility is applied to vague linkage entities
6564 associated with the class (vtable, typeinfo node, etc.). In
6565 particular, if a class is thrown as an exception in one shared object
6566 and caught in another, the class must have default visibility.
6567 Otherwise the two shared objects are unable to use the same
6568 typeinfo node and exception handling will break.
6569
6570 @end table
6571
6572 To specify multiple attributes, separate them by commas within the
6573 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6574 packed))}.
6575
6576 @node ARM Type Attributes
6577 @subsection ARM Type Attributes
6578
6579 @cindex @code{notshared} type attribute, ARM
6580 On those ARM targets that support @code{dllimport} (such as Symbian
6581 OS), you can use the @code{notshared} attribute to indicate that the
6582 virtual table and other similar data for a class should not be
6583 exported from a DLL@. For example:
6584
6585 @smallexample
6586 class __declspec(notshared) C @{
6587 public:
6588 __declspec(dllimport) C();
6589 virtual void f();
6590 @}
6591
6592 __declspec(dllexport)
6593 C::C() @{@}
6594 @end smallexample
6595
6596 @noindent
6597 In this code, @code{C::C} is exported from the current DLL, but the
6598 virtual table for @code{C} is not exported. (You can use
6599 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6600 most Symbian OS code uses @code{__declspec}.)
6601
6602 @node MeP Type Attributes
6603 @subsection MeP Type Attributes
6604
6605 @cindex @code{based} type attribute, MeP
6606 @cindex @code{tiny} type attribute, MeP
6607 @cindex @code{near} type attribute, MeP
6608 @cindex @code{far} type attribute, MeP
6609 Many of the MeP variable attributes may be applied to types as well.
6610 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6611 @code{far} attributes may be applied to either. The @code{io} and
6612 @code{cb} attributes may not be applied to types.
6613
6614 @node PowerPC Type Attributes
6615 @subsection PowerPC Type Attributes
6616
6617 Three attributes currently are defined for PowerPC configurations:
6618 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6619
6620 @cindex @code{ms_struct} type attribute, PowerPC
6621 @cindex @code{gcc_struct} type attribute, PowerPC
6622 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6623 attributes please see the documentation in @ref{x86 Type Attributes}.
6624
6625 @cindex @code{altivec} type attribute, PowerPC
6626 The @code{altivec} attribute allows one to declare AltiVec vector data
6627 types supported by the AltiVec Programming Interface Manual. The
6628 attribute requires an argument to specify one of three vector types:
6629 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6630 and @code{bool__} (always followed by unsigned).
6631
6632 @smallexample
6633 __attribute__((altivec(vector__)))
6634 __attribute__((altivec(pixel__))) unsigned short
6635 __attribute__((altivec(bool__))) unsigned
6636 @end smallexample
6637
6638 These attributes mainly are intended to support the @code{__vector},
6639 @code{__pixel}, and @code{__bool} AltiVec keywords.
6640
6641 @node SPU Type Attributes
6642 @subsection SPU Type Attributes
6643
6644 @cindex @code{spu_vector} type attribute, SPU
6645 The SPU supports the @code{spu_vector} attribute for types. This attribute
6646 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6647 Language Extensions Specification. It is intended to support the
6648 @code{__vector} keyword.
6649
6650 @node x86 Type Attributes
6651 @subsection x86 Type Attributes
6652
6653 Two attributes are currently defined for x86 configurations:
6654 @code{ms_struct} and @code{gcc_struct}.
6655
6656 @table @code
6657
6658 @item ms_struct
6659 @itemx gcc_struct
6660 @cindex @code{ms_struct} type attribute, x86
6661 @cindex @code{gcc_struct} type attribute, x86
6662
6663 If @code{packed} is used on a structure, or if bit-fields are used
6664 it may be that the Microsoft ABI packs them differently
6665 than GCC normally packs them. Particularly when moving packed
6666 data between functions compiled with GCC and the native Microsoft compiler
6667 (either via function call or as data in a file), it may be necessary to access
6668 either format.
6669
6670 Currently @option{-m[no-]ms-bitfields} is provided for the Microsoft Windows x86
6671 compilers to match the native Microsoft compiler.
6672 @end table
6673
6674 @node Label Attributes
6675 @section Label Attributes
6676 @cindex Label Attributes
6677
6678 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6679 details of the exact syntax for using attributes. Other attributes are
6680 available for functions (@pxref{Function Attributes}), variables
6681 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6682 and for types (@pxref{Type Attributes}).
6683
6684 This example uses the @code{cold} label attribute to indicate the
6685 @code{ErrorHandling} branch is unlikely to be taken and that the
6686 @code{ErrorHandling} label is unused:
6687
6688 @smallexample
6689
6690 asm goto ("some asm" : : : : NoError);
6691
6692 /* This branch (the fall-through from the asm) is less commonly used */
6693 ErrorHandling:
6694 __attribute__((cold, unused)); /* Semi-colon is required here */
6695 printf("error\n");
6696 return 0;
6697
6698 NoError:
6699 printf("no error\n");
6700 return 1;
6701 @end smallexample
6702
6703 @table @code
6704 @item unused
6705 @cindex @code{unused} label attribute
6706 This feature is intended for program-generated code that may contain
6707 unused labels, but which is compiled with @option{-Wall}. It is
6708 not normally appropriate to use in it human-written code, though it
6709 could be useful in cases where the code that jumps to the label is
6710 contained within an @code{#ifdef} conditional.
6711
6712 @item hot
6713 @cindex @code{hot} label attribute
6714 The @code{hot} attribute on a label is used to inform the compiler that
6715 the path following the label is more likely than paths that are not so
6716 annotated. This attribute is used in cases where @code{__builtin_expect}
6717 cannot be used, for instance with computed goto or @code{asm goto}.
6718
6719 @item cold
6720 @cindex @code{cold} label attribute
6721 The @code{cold} attribute on labels is used to inform the compiler that
6722 the path following the label is unlikely to be executed. This attribute
6723 is used in cases where @code{__builtin_expect} cannot be used, for instance
6724 with computed goto or @code{asm goto}.
6725
6726 @end table
6727
6728 @node Enumerator Attributes
6729 @section Enumerator Attributes
6730 @cindex Enumerator Attributes
6731
6732 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6733 details of the exact syntax for using attributes. Other attributes are
6734 available for functions (@pxref{Function Attributes}), variables
6735 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6736 and for types (@pxref{Type Attributes}).
6737
6738 This example uses the @code{deprecated} enumerator attribute to indicate the
6739 @code{oldval} enumerator is deprecated:
6740
6741 @smallexample
6742 enum E @{
6743 oldval __attribute__((deprecated)),
6744 newval
6745 @};
6746
6747 int
6748 fn (void)
6749 @{
6750 return oldval;
6751 @}
6752 @end smallexample
6753
6754 @table @code
6755 @item deprecated
6756 @cindex @code{deprecated} enumerator attribute
6757 The @code{deprecated} attribute results in a warning if the enumerator
6758 is used anywhere in the source file. This is useful when identifying
6759 enumerators that are expected to be removed in a future version of a
6760 program. The warning also includes the location of the declaration
6761 of the deprecated enumerator, to enable users to easily find further
6762 information about why the enumerator is deprecated, or what they should
6763 do instead. Note that the warnings only occurs for uses.
6764
6765 @end table
6766
6767 @node Attribute Syntax
6768 @section Attribute Syntax
6769 @cindex attribute syntax
6770
6771 This section describes the syntax with which @code{__attribute__} may be
6772 used, and the constructs to which attribute specifiers bind, for the C
6773 language. Some details may vary for C++ and Objective-C@. Because of
6774 infelicities in the grammar for attributes, some forms described here
6775 may not be successfully parsed in all cases.
6776
6777 There are some problems with the semantics of attributes in C++. For
6778 example, there are no manglings for attributes, although they may affect
6779 code generation, so problems may arise when attributed types are used in
6780 conjunction with templates or overloading. Similarly, @code{typeid}
6781 does not distinguish between types with different attributes. Support
6782 for attributes in C++ may be restricted in future to attributes on
6783 declarations only, but not on nested declarators.
6784
6785 @xref{Function Attributes}, for details of the semantics of attributes
6786 applying to functions. @xref{Variable Attributes}, for details of the
6787 semantics of attributes applying to variables. @xref{Type Attributes},
6788 for details of the semantics of attributes applying to structure, union
6789 and enumerated types.
6790 @xref{Label Attributes}, for details of the semantics of attributes
6791 applying to labels.
6792 @xref{Enumerator Attributes}, for details of the semantics of attributes
6793 applying to enumerators.
6794
6795 An @dfn{attribute specifier} is of the form
6796 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6797 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6798 each attribute is one of the following:
6799
6800 @itemize @bullet
6801 @item
6802 Empty. Empty attributes are ignored.
6803
6804 @item
6805 An attribute name
6806 (which may be an identifier such as @code{unused}, or a reserved
6807 word such as @code{const}).
6808
6809 @item
6810 An attribute name followed by a parenthesized list of
6811 parameters for the attribute.
6812 These parameters take one of the following forms:
6813
6814 @itemize @bullet
6815 @item
6816 An identifier. For example, @code{mode} attributes use this form.
6817
6818 @item
6819 An identifier followed by a comma and a non-empty comma-separated list
6820 of expressions. For example, @code{format} attributes use this form.
6821
6822 @item
6823 A possibly empty comma-separated list of expressions. For example,
6824 @code{format_arg} attributes use this form with the list being a single
6825 integer constant expression, and @code{alias} attributes use this form
6826 with the list being a single string constant.
6827 @end itemize
6828 @end itemize
6829
6830 An @dfn{attribute specifier list} is a sequence of one or more attribute
6831 specifiers, not separated by any other tokens.
6832
6833 You may optionally specify attribute names with @samp{__}
6834 preceding and following the name.
6835 This allows you to use them in header files without
6836 being concerned about a possible macro of the same name. For example,
6837 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6838
6839
6840 @subsubheading Label Attributes
6841
6842 In GNU C, an attribute specifier list may appear after the colon following a
6843 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6844 attributes on labels if the attribute specifier is immediately
6845 followed by a semicolon (i.e., the label applies to an empty
6846 statement). If the semicolon is missing, C++ label attributes are
6847 ambiguous, as it is permissible for a declaration, which could begin
6848 with an attribute list, to be labelled in C++. Declarations cannot be
6849 labelled in C90 or C99, so the ambiguity does not arise there.
6850
6851 @subsubheading Enumerator Attributes
6852
6853 In GNU C, an attribute specifier list may appear as part of an enumerator.
6854 The attribute goes after the enumeration constant, before @code{=}, if
6855 present. The optional attribute in the enumerator appertains to the
6856 enumeration constant. It is not possible to place the attribute after
6857 the constant expression, if present.
6858
6859 @subsubheading Type Attributes
6860
6861 An attribute specifier list may appear as part of a @code{struct},
6862 @code{union} or @code{enum} specifier. It may go either immediately
6863 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6864 the closing brace. The former syntax is preferred.
6865 Where attribute specifiers follow the closing brace, they are considered
6866 to relate to the structure, union or enumerated type defined, not to any
6867 enclosing declaration the type specifier appears in, and the type
6868 defined is not complete until after the attribute specifiers.
6869 @c Otherwise, there would be the following problems: a shift/reduce
6870 @c conflict between attributes binding the struct/union/enum and
6871 @c binding to the list of specifiers/qualifiers; and "aligned"
6872 @c attributes could use sizeof for the structure, but the size could be
6873 @c changed later by "packed" attributes.
6874
6875
6876 @subsubheading All other attributes
6877
6878 Otherwise, an attribute specifier appears as part of a declaration,
6879 counting declarations of unnamed parameters and type names, and relates
6880 to that declaration (which may be nested in another declaration, for
6881 example in the case of a parameter declaration), or to a particular declarator
6882 within a declaration. Where an
6883 attribute specifier is applied to a parameter declared as a function or
6884 an array, it should apply to the function or array rather than the
6885 pointer to which the parameter is implicitly converted, but this is not
6886 yet correctly implemented.
6887
6888 Any list of specifiers and qualifiers at the start of a declaration may
6889 contain attribute specifiers, whether or not such a list may in that
6890 context contain storage class specifiers. (Some attributes, however,
6891 are essentially in the nature of storage class specifiers, and only make
6892 sense where storage class specifiers may be used; for example,
6893 @code{section}.) There is one necessary limitation to this syntax: the
6894 first old-style parameter declaration in a function definition cannot
6895 begin with an attribute specifier, because such an attribute applies to
6896 the function instead by syntax described below (which, however, is not
6897 yet implemented in this case). In some other cases, attribute
6898 specifiers are permitted by this grammar but not yet supported by the
6899 compiler. All attribute specifiers in this place relate to the
6900 declaration as a whole. In the obsolescent usage where a type of
6901 @code{int} is implied by the absence of type specifiers, such a list of
6902 specifiers and qualifiers may be an attribute specifier list with no
6903 other specifiers or qualifiers.
6904
6905 At present, the first parameter in a function prototype must have some
6906 type specifier that is not an attribute specifier; this resolves an
6907 ambiguity in the interpretation of @code{void f(int
6908 (__attribute__((foo)) x))}, but is subject to change. At present, if
6909 the parentheses of a function declarator contain only attributes then
6910 those attributes are ignored, rather than yielding an error or warning
6911 or implying a single parameter of type int, but this is subject to
6912 change.
6913
6914 An attribute specifier list may appear immediately before a declarator
6915 (other than the first) in a comma-separated list of declarators in a
6916 declaration of more than one identifier using a single list of
6917 specifiers and qualifiers. Such attribute specifiers apply
6918 only to the identifier before whose declarator they appear. For
6919 example, in
6920
6921 @smallexample
6922 __attribute__((noreturn)) void d0 (void),
6923 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6924 d2 (void);
6925 @end smallexample
6926
6927 @noindent
6928 the @code{noreturn} attribute applies to all the functions
6929 declared; the @code{format} attribute only applies to @code{d1}.
6930
6931 An attribute specifier list may appear immediately before the comma,
6932 @code{=} or semicolon terminating the declaration of an identifier other
6933 than a function definition. Such attribute specifiers apply
6934 to the declared object or function. Where an
6935 assembler name for an object or function is specified (@pxref{Asm
6936 Labels}), the attribute must follow the @code{asm}
6937 specification.
6938
6939 An attribute specifier list may, in future, be permitted to appear after
6940 the declarator in a function definition (before any old-style parameter
6941 declarations or the function body).
6942
6943 Attribute specifiers may be mixed with type qualifiers appearing inside
6944 the @code{[]} of a parameter array declarator, in the C99 construct by
6945 which such qualifiers are applied to the pointer to which the array is
6946 implicitly converted. Such attribute specifiers apply to the pointer,
6947 not to the array, but at present this is not implemented and they are
6948 ignored.
6949
6950 An attribute specifier list may appear at the start of a nested
6951 declarator. At present, there are some limitations in this usage: the
6952 attributes correctly apply to the declarator, but for most individual
6953 attributes the semantics this implies are not implemented.
6954 When attribute specifiers follow the @code{*} of a pointer
6955 declarator, they may be mixed with any type qualifiers present.
6956 The following describes the formal semantics of this syntax. It makes the
6957 most sense if you are familiar with the formal specification of
6958 declarators in the ISO C standard.
6959
6960 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6961 D1}, where @code{T} contains declaration specifiers that specify a type
6962 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6963 contains an identifier @var{ident}. The type specified for @var{ident}
6964 for derived declarators whose type does not include an attribute
6965 specifier is as in the ISO C standard.
6966
6967 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
6968 and the declaration @code{T D} specifies the type
6969 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6970 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6971 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
6972
6973 If @code{D1} has the form @code{*
6974 @var{type-qualifier-and-attribute-specifier-list} D}, and the
6975 declaration @code{T D} specifies the type
6976 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6977 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6978 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
6979 @var{ident}.
6980
6981 For example,
6982
6983 @smallexample
6984 void (__attribute__((noreturn)) ****f) (void);
6985 @end smallexample
6986
6987 @noindent
6988 specifies the type ``pointer to pointer to pointer to pointer to
6989 non-returning function returning @code{void}''. As another example,
6990
6991 @smallexample
6992 char *__attribute__((aligned(8))) *f;
6993 @end smallexample
6994
6995 @noindent
6996 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
6997 Note again that this does not work with most attributes; for example,
6998 the usage of @samp{aligned} and @samp{noreturn} attributes given above
6999 is not yet supported.
7000
7001 For compatibility with existing code written for compiler versions that
7002 did not implement attributes on nested declarators, some laxity is
7003 allowed in the placing of attributes. If an attribute that only applies
7004 to types is applied to a declaration, it is treated as applying to
7005 the type of that declaration. If an attribute that only applies to
7006 declarations is applied to the type of a declaration, it is treated
7007 as applying to that declaration; and, for compatibility with code
7008 placing the attributes immediately before the identifier declared, such
7009 an attribute applied to a function return type is treated as
7010 applying to the function type, and such an attribute applied to an array
7011 element type is treated as applying to the array type. If an
7012 attribute that only applies to function types is applied to a
7013 pointer-to-function type, it is treated as applying to the pointer
7014 target type; if such an attribute is applied to a function return type
7015 that is not a pointer-to-function type, it is treated as applying
7016 to the function type.
7017
7018 @node Function Prototypes
7019 @section Prototypes and Old-Style Function Definitions
7020 @cindex function prototype declarations
7021 @cindex old-style function definitions
7022 @cindex promotion of formal parameters
7023
7024 GNU C extends ISO C to allow a function prototype to override a later
7025 old-style non-prototype definition. Consider the following example:
7026
7027 @smallexample
7028 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7029 #ifdef __STDC__
7030 #define P(x) x
7031 #else
7032 #define P(x) ()
7033 #endif
7034
7035 /* @r{Prototype function declaration.} */
7036 int isroot P((uid_t));
7037
7038 /* @r{Old-style function definition.} */
7039 int
7040 isroot (x) /* @r{??? lossage here ???} */
7041 uid_t x;
7042 @{
7043 return x == 0;
7044 @}
7045 @end smallexample
7046
7047 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7048 not allow this example, because subword arguments in old-style
7049 non-prototype definitions are promoted. Therefore in this example the
7050 function definition's argument is really an @code{int}, which does not
7051 match the prototype argument type of @code{short}.
7052
7053 This restriction of ISO C makes it hard to write code that is portable
7054 to traditional C compilers, because the programmer does not know
7055 whether the @code{uid_t} type is @code{short}, @code{int}, or
7056 @code{long}. Therefore, in cases like these GNU C allows a prototype
7057 to override a later old-style definition. More precisely, in GNU C, a
7058 function prototype argument type overrides the argument type specified
7059 by a later old-style definition if the former type is the same as the
7060 latter type before promotion. Thus in GNU C the above example is
7061 equivalent to the following:
7062
7063 @smallexample
7064 int isroot (uid_t);
7065
7066 int
7067 isroot (uid_t x)
7068 @{
7069 return x == 0;
7070 @}
7071 @end smallexample
7072
7073 @noindent
7074 GNU C++ does not support old-style function definitions, so this
7075 extension is irrelevant.
7076
7077 @node C++ Comments
7078 @section C++ Style Comments
7079 @cindex @code{//}
7080 @cindex C++ comments
7081 @cindex comments, C++ style
7082
7083 In GNU C, you may use C++ style comments, which start with @samp{//} and
7084 continue until the end of the line. Many other C implementations allow
7085 such comments, and they are included in the 1999 C standard. However,
7086 C++ style comments are not recognized if you specify an @option{-std}
7087 option specifying a version of ISO C before C99, or @option{-ansi}
7088 (equivalent to @option{-std=c90}).
7089
7090 @node Dollar Signs
7091 @section Dollar Signs in Identifier Names
7092 @cindex $
7093 @cindex dollar signs in identifier names
7094 @cindex identifier names, dollar signs in
7095
7096 In GNU C, you may normally use dollar signs in identifier names.
7097 This is because many traditional C implementations allow such identifiers.
7098 However, dollar signs in identifiers are not supported on a few target
7099 machines, typically because the target assembler does not allow them.
7100
7101 @node Character Escapes
7102 @section The Character @key{ESC} in Constants
7103
7104 You can use the sequence @samp{\e} in a string or character constant to
7105 stand for the ASCII character @key{ESC}.
7106
7107 @node Alignment
7108 @section Inquiring on Alignment of Types or Variables
7109 @cindex alignment
7110 @cindex type alignment
7111 @cindex variable alignment
7112
7113 The keyword @code{__alignof__} allows you to inquire about how an object
7114 is aligned, or the minimum alignment usually required by a type. Its
7115 syntax is just like @code{sizeof}.
7116
7117 For example, if the target machine requires a @code{double} value to be
7118 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7119 This is true on many RISC machines. On more traditional machine
7120 designs, @code{__alignof__ (double)} is 4 or even 2.
7121
7122 Some machines never actually require alignment; they allow reference to any
7123 data type even at an odd address. For these machines, @code{__alignof__}
7124 reports the smallest alignment that GCC gives the data type, usually as
7125 mandated by the target ABI.
7126
7127 If the operand of @code{__alignof__} is an lvalue rather than a type,
7128 its value is the required alignment for its type, taking into account
7129 any minimum alignment specified with GCC's @code{__attribute__}
7130 extension (@pxref{Variable Attributes}). For example, after this
7131 declaration:
7132
7133 @smallexample
7134 struct foo @{ int x; char y; @} foo1;
7135 @end smallexample
7136
7137 @noindent
7138 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7139 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7140
7141 It is an error to ask for the alignment of an incomplete type.
7142
7143
7144 @node Inline
7145 @section An Inline Function is As Fast As a Macro
7146 @cindex inline functions
7147 @cindex integrating function code
7148 @cindex open coding
7149 @cindex macros, inline alternative
7150
7151 By declaring a function inline, you can direct GCC to make
7152 calls to that function faster. One way GCC can achieve this is to
7153 integrate that function's code into the code for its callers. This
7154 makes execution faster by eliminating the function-call overhead; in
7155 addition, if any of the actual argument values are constant, their
7156 known values may permit simplifications at compile time so that not
7157 all of the inline function's code needs to be included. The effect on
7158 code size is less predictable; object code may be larger or smaller
7159 with function inlining, depending on the particular case. You can
7160 also direct GCC to try to integrate all ``simple enough'' functions
7161 into their callers with the option @option{-finline-functions}.
7162
7163 GCC implements three different semantics of declaring a function
7164 inline. One is available with @option{-std=gnu89} or
7165 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7166 on all inline declarations, another when
7167 @option{-std=c99}, @option{-std=c11},
7168 @option{-std=gnu99} or @option{-std=gnu11}
7169 (without @option{-fgnu89-inline}), and the third
7170 is used when compiling C++.
7171
7172 To declare a function inline, use the @code{inline} keyword in its
7173 declaration, like this:
7174
7175 @smallexample
7176 static inline int
7177 inc (int *a)
7178 @{
7179 return (*a)++;
7180 @}
7181 @end smallexample
7182
7183 If you are writing a header file to be included in ISO C90 programs, write
7184 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7185
7186 The three types of inlining behave similarly in two important cases:
7187 when the @code{inline} keyword is used on a @code{static} function,
7188 like the example above, and when a function is first declared without
7189 using the @code{inline} keyword and then is defined with
7190 @code{inline}, like this:
7191
7192 @smallexample
7193 extern int inc (int *a);
7194 inline int
7195 inc (int *a)
7196 @{
7197 return (*a)++;
7198 @}
7199 @end smallexample
7200
7201 In both of these common cases, the program behaves the same as if you
7202 had not used the @code{inline} keyword, except for its speed.
7203
7204 @cindex inline functions, omission of
7205 @opindex fkeep-inline-functions
7206 When a function is both inline and @code{static}, if all calls to the
7207 function are integrated into the caller, and the function's address is
7208 never used, then the function's own assembler code is never referenced.
7209 In this case, GCC does not actually output assembler code for the
7210 function, unless you specify the option @option{-fkeep-inline-functions}.
7211 If there is a nonintegrated call, then the function is compiled to
7212 assembler code as usual. The function must also be compiled as usual if
7213 the program refers to its address, because that can't be inlined.
7214
7215 @opindex Winline
7216 Note that certain usages in a function definition can make it unsuitable
7217 for inline substitution. Among these usages are: variadic functions,
7218 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7219 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7220 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7221 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7222 function marked @code{inline} could not be substituted, and gives the
7223 reason for the failure.
7224
7225 @cindex automatic @code{inline} for C++ member fns
7226 @cindex @code{inline} automatic for C++ member fns
7227 @cindex member fns, automatically @code{inline}
7228 @cindex C++ member fns, automatically @code{inline}
7229 @opindex fno-default-inline
7230 As required by ISO C++, GCC considers member functions defined within
7231 the body of a class to be marked inline even if they are
7232 not explicitly declared with the @code{inline} keyword. You can
7233 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7234 Options,,Options Controlling C++ Dialect}.
7235
7236 GCC does not inline any functions when not optimizing unless you specify
7237 the @samp{always_inline} attribute for the function, like this:
7238
7239 @smallexample
7240 /* @r{Prototype.} */
7241 inline void foo (const char) __attribute__((always_inline));
7242 @end smallexample
7243
7244 The remainder of this section is specific to GNU C90 inlining.
7245
7246 @cindex non-static inline function
7247 When an inline function is not @code{static}, then the compiler must assume
7248 that there may be calls from other source files; since a global symbol can
7249 be defined only once in any program, the function must not be defined in
7250 the other source files, so the calls therein cannot be integrated.
7251 Therefore, a non-@code{static} inline function is always compiled on its
7252 own in the usual fashion.
7253
7254 If you specify both @code{inline} and @code{extern} in the function
7255 definition, then the definition is used only for inlining. In no case
7256 is the function compiled on its own, not even if you refer to its
7257 address explicitly. Such an address becomes an external reference, as
7258 if you had only declared the function, and had not defined it.
7259
7260 This combination of @code{inline} and @code{extern} has almost the
7261 effect of a macro. The way to use it is to put a function definition in
7262 a header file with these keywords, and put another copy of the
7263 definition (lacking @code{inline} and @code{extern}) in a library file.
7264 The definition in the header file causes most calls to the function
7265 to be inlined. If any uses of the function remain, they refer to
7266 the single copy in the library.
7267
7268 @node Volatiles
7269 @section When is a Volatile Object Accessed?
7270 @cindex accessing volatiles
7271 @cindex volatile read
7272 @cindex volatile write
7273 @cindex volatile access
7274
7275 C has the concept of volatile objects. These are normally accessed by
7276 pointers and used for accessing hardware or inter-thread
7277 communication. The standard encourages compilers to refrain from
7278 optimizations concerning accesses to volatile objects, but leaves it
7279 implementation defined as to what constitutes a volatile access. The
7280 minimum requirement is that at a sequence point all previous accesses
7281 to volatile objects have stabilized and no subsequent accesses have
7282 occurred. Thus an implementation is free to reorder and combine
7283 volatile accesses that occur between sequence points, but cannot do
7284 so for accesses across a sequence point. The use of volatile does
7285 not allow you to violate the restriction on updating objects multiple
7286 times between two sequence points.
7287
7288 Accesses to non-volatile objects are not ordered with respect to
7289 volatile accesses. You cannot use a volatile object as a memory
7290 barrier to order a sequence of writes to non-volatile memory. For
7291 instance:
7292
7293 @smallexample
7294 int *ptr = @var{something};
7295 volatile int vobj;
7296 *ptr = @var{something};
7297 vobj = 1;
7298 @end smallexample
7299
7300 @noindent
7301 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7302 that the write to @var{*ptr} occurs by the time the update
7303 of @var{vobj} happens. If you need this guarantee, you must use
7304 a stronger memory barrier such as:
7305
7306 @smallexample
7307 int *ptr = @var{something};
7308 volatile int vobj;
7309 *ptr = @var{something};
7310 asm volatile ("" : : : "memory");
7311 vobj = 1;
7312 @end smallexample
7313
7314 A scalar volatile object is read when it is accessed in a void context:
7315
7316 @smallexample
7317 volatile int *src = @var{somevalue};
7318 *src;
7319 @end smallexample
7320
7321 Such expressions are rvalues, and GCC implements this as a
7322 read of the volatile object being pointed to.
7323
7324 Assignments are also expressions and have an rvalue. However when
7325 assigning to a scalar volatile, the volatile object is not reread,
7326 regardless of whether the assignment expression's rvalue is used or
7327 not. If the assignment's rvalue is used, the value is that assigned
7328 to the volatile object. For instance, there is no read of @var{vobj}
7329 in all the following cases:
7330
7331 @smallexample
7332 int obj;
7333 volatile int vobj;
7334 vobj = @var{something};
7335 obj = vobj = @var{something};
7336 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7337 obj = (@var{something}, vobj = @var{anotherthing});
7338 @end smallexample
7339
7340 If you need to read the volatile object after an assignment has
7341 occurred, you must use a separate expression with an intervening
7342 sequence point.
7343
7344 As bit-fields are not individually addressable, volatile bit-fields may
7345 be implicitly read when written to, or when adjacent bit-fields are
7346 accessed. Bit-field operations may be optimized such that adjacent
7347 bit-fields are only partially accessed, if they straddle a storage unit
7348 boundary. For these reasons it is unwise to use volatile bit-fields to
7349 access hardware.
7350
7351 @node Using Assembly Language with C
7352 @section How to Use Inline Assembly Language in C Code
7353 @cindex @code{asm} keyword
7354 @cindex assembly language in C
7355 @cindex inline assembly language
7356 @cindex mixing assembly language and C
7357
7358 The @code{asm} keyword allows you to embed assembler instructions
7359 within C code. GCC provides two forms of inline @code{asm}
7360 statements. A @dfn{basic @code{asm}} statement is one with no
7361 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7362 statement (@pxref{Extended Asm}) includes one or more operands.
7363 The extended form is preferred for mixing C and assembly language
7364 within a function, but to include assembly language at
7365 top level you must use basic @code{asm}.
7366
7367 You can also use the @code{asm} keyword to override the assembler name
7368 for a C symbol, or to place a C variable in a specific register.
7369
7370 @menu
7371 * Basic Asm:: Inline assembler without operands.
7372 * Extended Asm:: Inline assembler with operands.
7373 * Constraints:: Constraints for @code{asm} operands
7374 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7375 * Explicit Register Variables:: Defining variables residing in specified
7376 registers.
7377 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7378 @end menu
7379
7380 @node Basic Asm
7381 @subsection Basic Asm --- Assembler Instructions Without Operands
7382 @cindex basic @code{asm}
7383 @cindex assembly language in C, basic
7384
7385 A basic @code{asm} statement has the following syntax:
7386
7387 @example
7388 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7389 @end example
7390
7391 The @code{asm} keyword is a GNU extension.
7392 When writing code that can be compiled with @option{-ansi} and the
7393 various @option{-std} options, use @code{__asm__} instead of
7394 @code{asm} (@pxref{Alternate Keywords}).
7395
7396 @subsubheading Qualifiers
7397 @table @code
7398 @item volatile
7399 The optional @code{volatile} qualifier has no effect.
7400 All basic @code{asm} blocks are implicitly volatile.
7401 @end table
7402
7403 @subsubheading Parameters
7404 @table @var
7405
7406 @item AssemblerInstructions
7407 This is a literal string that specifies the assembler code. The string can
7408 contain any instructions recognized by the assembler, including directives.
7409 GCC does not parse the assembler instructions themselves and
7410 does not know what they mean or even whether they are valid assembler input.
7411
7412 You may place multiple assembler instructions together in a single @code{asm}
7413 string, separated by the characters normally used in assembly code for the
7414 system. A combination that works in most places is a newline to break the
7415 line, plus a tab character (written as @samp{\n\t}).
7416 Some assemblers allow semicolons as a line separator. However,
7417 note that some assembler dialects use semicolons to start a comment.
7418 @end table
7419
7420 @subsubheading Remarks
7421 Using extended @code{asm} typically produces smaller, safer, and more
7422 efficient code, and in most cases it is a better solution than basic
7423 @code{asm}. However, there are two situations where only basic @code{asm}
7424 can be used:
7425
7426 @itemize @bullet
7427 @item
7428 Extended @code{asm} statements have to be inside a C
7429 function, so to write inline assembly language at file scope (``top-level''),
7430 outside of C functions, you must use basic @code{asm}.
7431 You can use this technique to emit assembler directives,
7432 define assembly language macros that can be invoked elsewhere in the file,
7433 or write entire functions in assembly language.
7434
7435 @item
7436 Functions declared
7437 with the @code{naked} attribute also require basic @code{asm}
7438 (@pxref{Function Attributes}).
7439 @end itemize
7440
7441 Safely accessing C data and calling functions from basic @code{asm} is more
7442 complex than it may appear. To access C data, it is better to use extended
7443 @code{asm}.
7444
7445 Do not expect a sequence of @code{asm} statements to remain perfectly
7446 consecutive after compilation. If certain instructions need to remain
7447 consecutive in the output, put them in a single multi-instruction @code{asm}
7448 statement. Note that GCC's optimizers can move @code{asm} statements
7449 relative to other code, including across jumps.
7450
7451 @code{asm} statements may not perform jumps into other @code{asm} statements.
7452 GCC does not know about these jumps, and therefore cannot take
7453 account of them when deciding how to optimize. Jumps from @code{asm} to C
7454 labels are only supported in extended @code{asm}.
7455
7456 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7457 assembly code when optimizing. This can lead to unexpected duplicate
7458 symbol errors during compilation if your assembly code defines symbols or
7459 labels.
7460
7461 Since GCC does not parse the @var{AssemblerInstructions}, it has no
7462 visibility of any symbols it references. This may result in GCC discarding
7463 those symbols as unreferenced.
7464
7465 The compiler copies the assembler instructions in a basic @code{asm}
7466 verbatim to the assembly language output file, without
7467 processing dialects or any of the @samp{%} operators that are available with
7468 extended @code{asm}. This results in minor differences between basic
7469 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7470 registers you might use @samp{%eax} in basic @code{asm} and
7471 @samp{%%eax} in extended @code{asm}.
7472
7473 On targets such as x86 that support multiple assembler dialects,
7474 all basic @code{asm} blocks use the assembler dialect specified by the
7475 @option{-masm} command-line option (@pxref{x86 Options}).
7476 Basic @code{asm} provides no
7477 mechanism to provide different assembler strings for different dialects.
7478
7479 Here is an example of basic @code{asm} for i386:
7480
7481 @example
7482 /* Note that this code will not compile with -masm=intel */
7483 #define DebugBreak() asm("int $3")
7484 @end example
7485
7486 @node Extended Asm
7487 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7488 @cindex extended @code{asm}
7489 @cindex assembly language in C, extended
7490
7491 With extended @code{asm} you can read and write C variables from
7492 assembler and perform jumps from assembler code to C labels.
7493 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7494 the operand parameters after the assembler template:
7495
7496 @example
7497 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7498 : @var{OutputOperands}
7499 @r{[} : @var{InputOperands}
7500 @r{[} : @var{Clobbers} @r{]} @r{]})
7501
7502 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7503 :
7504 : @var{InputOperands}
7505 : @var{Clobbers}
7506 : @var{GotoLabels})
7507 @end example
7508
7509 The @code{asm} keyword is a GNU extension.
7510 When writing code that can be compiled with @option{-ansi} and the
7511 various @option{-std} options, use @code{__asm__} instead of
7512 @code{asm} (@pxref{Alternate Keywords}).
7513
7514 @subsubheading Qualifiers
7515 @table @code
7516
7517 @item volatile
7518 The typical use of extended @code{asm} statements is to manipulate input
7519 values to produce output values. However, your @code{asm} statements may
7520 also produce side effects. If so, you may need to use the @code{volatile}
7521 qualifier to disable certain optimizations. @xref{Volatile}.
7522
7523 @item goto
7524 This qualifier informs the compiler that the @code{asm} statement may
7525 perform a jump to one of the labels listed in the @var{GotoLabels}.
7526 @xref{GotoLabels}.
7527 @end table
7528
7529 @subsubheading Parameters
7530 @table @var
7531 @item AssemblerTemplate
7532 This is a literal string that is the template for the assembler code. It is a
7533 combination of fixed text and tokens that refer to the input, output,
7534 and goto parameters. @xref{AssemblerTemplate}.
7535
7536 @item OutputOperands
7537 A comma-separated list of the C variables modified by the instructions in the
7538 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7539
7540 @item InputOperands
7541 A comma-separated list of C expressions read by the instructions in the
7542 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7543
7544 @item Clobbers
7545 A comma-separated list of registers or other values changed by the
7546 @var{AssemblerTemplate}, beyond those listed as outputs.
7547 An empty list is permitted. @xref{Clobbers}.
7548
7549 @item GotoLabels
7550 When you are using the @code{goto} form of @code{asm}, this section contains
7551 the list of all C labels to which the code in the
7552 @var{AssemblerTemplate} may jump.
7553 @xref{GotoLabels}.
7554
7555 @code{asm} statements may not perform jumps into other @code{asm} statements,
7556 only to the listed @var{GotoLabels}.
7557 GCC's optimizers do not know about other jumps; therefore they cannot take
7558 account of them when deciding how to optimize.
7559 @end table
7560
7561 The total number of input + output + goto operands is limited to 30.
7562
7563 @subsubheading Remarks
7564 The @code{asm} statement allows you to include assembly instructions directly
7565 within C code. This may help you to maximize performance in time-sensitive
7566 code or to access assembly instructions that are not readily available to C
7567 programs.
7568
7569 Note that extended @code{asm} statements must be inside a function. Only
7570 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7571 Functions declared with the @code{naked} attribute also require basic
7572 @code{asm} (@pxref{Function Attributes}).
7573
7574 While the uses of @code{asm} are many and varied, it may help to think of an
7575 @code{asm} statement as a series of low-level instructions that convert input
7576 parameters to output parameters. So a simple (if not particularly useful)
7577 example for i386 using @code{asm} might look like this:
7578
7579 @example
7580 int src = 1;
7581 int dst;
7582
7583 asm ("mov %1, %0\n\t"
7584 "add $1, %0"
7585 : "=r" (dst)
7586 : "r" (src));
7587
7588 printf("%d\n", dst);
7589 @end example
7590
7591 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7592
7593 @anchor{Volatile}
7594 @subsubsection Volatile
7595 @cindex volatile @code{asm}
7596 @cindex @code{asm} volatile
7597
7598 GCC's optimizers sometimes discard @code{asm} statements if they determine
7599 there is no need for the output variables. Also, the optimizers may move
7600 code out of loops if they believe that the code will always return the same
7601 result (i.e. none of its input values change between calls). Using the
7602 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7603 that have no output operands, including @code{asm goto} statements,
7604 are implicitly volatile.
7605
7606 This i386 code demonstrates a case that does not use (or require) the
7607 @code{volatile} qualifier. If it is performing assertion checking, this code
7608 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7609 unreferenced by any code. As a result, the optimizers can discard the
7610 @code{asm} statement, which in turn removes the need for the entire
7611 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7612 isn't needed you allow the optimizers to produce the most efficient code
7613 possible.
7614
7615 @example
7616 void DoCheck(uint32_t dwSomeValue)
7617 @{
7618 uint32_t dwRes;
7619
7620 // Assumes dwSomeValue is not zero.
7621 asm ("bsfl %1,%0"
7622 : "=r" (dwRes)
7623 : "r" (dwSomeValue)
7624 : "cc");
7625
7626 assert(dwRes > 3);
7627 @}
7628 @end example
7629
7630 The next example shows a case where the optimizers can recognize that the input
7631 (@code{dwSomeValue}) never changes during the execution of the function and can
7632 therefore move the @code{asm} outside the loop to produce more efficient code.
7633 Again, using @code{volatile} disables this type of optimization.
7634
7635 @example
7636 void do_print(uint32_t dwSomeValue)
7637 @{
7638 uint32_t dwRes;
7639
7640 for (uint32_t x=0; x < 5; x++)
7641 @{
7642 // Assumes dwSomeValue is not zero.
7643 asm ("bsfl %1,%0"
7644 : "=r" (dwRes)
7645 : "r" (dwSomeValue)
7646 : "cc");
7647
7648 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7649 @}
7650 @}
7651 @end example
7652
7653 The following example demonstrates a case where you need to use the
7654 @code{volatile} qualifier.
7655 It uses the x86 @code{rdtsc} instruction, which reads
7656 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7657 the optimizers might assume that the @code{asm} block will always return the
7658 same value and therefore optimize away the second call.
7659
7660 @example
7661 uint64_t msr;
7662
7663 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7664 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7665 "or %%rdx, %0" // 'Or' in the lower bits.
7666 : "=a" (msr)
7667 :
7668 : "rdx");
7669
7670 printf("msr: %llx\n", msr);
7671
7672 // Do other work...
7673
7674 // Reprint the timestamp
7675 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7676 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7677 "or %%rdx, %0" // 'Or' in the lower bits.
7678 : "=a" (msr)
7679 :
7680 : "rdx");
7681
7682 printf("msr: %llx\n", msr);
7683 @end example
7684
7685 GCC's optimizers do not treat this code like the non-volatile code in the
7686 earlier examples. They do not move it out of loops or omit it on the
7687 assumption that the result from a previous call is still valid.
7688
7689 Note that the compiler can move even volatile @code{asm} instructions relative
7690 to other code, including across jump instructions. For example, on many
7691 targets there is a system register that controls the rounding mode of
7692 floating-point operations. Setting it with a volatile @code{asm}, as in the
7693 following PowerPC example, does not work reliably.
7694
7695 @example
7696 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7697 sum = x + y;
7698 @end example
7699
7700 The compiler may move the addition back before the volatile @code{asm}. To
7701 make it work as expected, add an artificial dependency to the @code{asm} by
7702 referencing a variable in the subsequent code, for example:
7703
7704 @example
7705 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7706 sum = x + y;
7707 @end example
7708
7709 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7710 assembly code when optimizing. This can lead to unexpected duplicate symbol
7711 errors during compilation if your asm code defines symbols or labels.
7712 Using @samp{%=}
7713 (@pxref{AssemblerTemplate}) may help resolve this problem.
7714
7715 @anchor{AssemblerTemplate}
7716 @subsubsection Assembler Template
7717 @cindex @code{asm} assembler template
7718
7719 An assembler template is a literal string containing assembler instructions.
7720 The compiler replaces tokens in the template that refer
7721 to inputs, outputs, and goto labels,
7722 and then outputs the resulting string to the assembler. The
7723 string can contain any instructions recognized by the assembler, including
7724 directives. GCC does not parse the assembler instructions
7725 themselves and does not know what they mean or even whether they are valid
7726 assembler input. However, it does count the statements
7727 (@pxref{Size of an asm}).
7728
7729 You may place multiple assembler instructions together in a single @code{asm}
7730 string, separated by the characters normally used in assembly code for the
7731 system. A combination that works in most places is a newline to break the
7732 line, plus a tab character to move to the instruction field (written as
7733 @samp{\n\t}).
7734 Some assemblers allow semicolons as a line separator. However, note
7735 that some assembler dialects use semicolons to start a comment.
7736
7737 Do not expect a sequence of @code{asm} statements to remain perfectly
7738 consecutive after compilation, even when you are using the @code{volatile}
7739 qualifier. If certain instructions need to remain consecutive in the output,
7740 put them in a single multi-instruction asm statement.
7741
7742 Accessing data from C programs without using input/output operands (such as
7743 by using global symbols directly from the assembler template) may not work as
7744 expected. Similarly, calling functions directly from an assembler template
7745 requires a detailed understanding of the target assembler and ABI.
7746
7747 Since GCC does not parse the assembler template,
7748 it has no visibility of any
7749 symbols it references. This may result in GCC discarding those symbols as
7750 unreferenced unless they are also listed as input, output, or goto operands.
7751
7752 @subsubheading Special format strings
7753
7754 In addition to the tokens described by the input, output, and goto operands,
7755 these tokens have special meanings in the assembler template:
7756
7757 @table @samp
7758 @item %%
7759 Outputs a single @samp{%} into the assembler code.
7760
7761 @item %=
7762 Outputs a number that is unique to each instance of the @code{asm}
7763 statement in the entire compilation. This option is useful when creating local
7764 labels and referring to them multiple times in a single template that
7765 generates multiple assembler instructions.
7766
7767 @item %@{
7768 @itemx %|
7769 @itemx %@}
7770 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7771 into the assembler code. When unescaped, these characters have special
7772 meaning to indicate multiple assembler dialects, as described below.
7773 @end table
7774
7775 @subsubheading Multiple assembler dialects in @code{asm} templates
7776
7777 On targets such as x86, GCC supports multiple assembler dialects.
7778 The @option{-masm} option controls which dialect GCC uses as its
7779 default for inline assembler. The target-specific documentation for the
7780 @option{-masm} option contains the list of supported dialects, as well as the
7781 default dialect if the option is not specified. This information may be
7782 important to understand, since assembler code that works correctly when
7783 compiled using one dialect will likely fail if compiled using another.
7784 @xref{x86 Options}.
7785
7786 If your code needs to support multiple assembler dialects (for example, if
7787 you are writing public headers that need to support a variety of compilation
7788 options), use constructs of this form:
7789
7790 @example
7791 @{ dialect0 | dialect1 | dialect2... @}
7792 @end example
7793
7794 This construct outputs @code{dialect0}
7795 when using dialect #0 to compile the code,
7796 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7797 braces than the number of dialects the compiler supports, the construct
7798 outputs nothing.
7799
7800 For example, if an x86 compiler supports two dialects
7801 (@samp{att}, @samp{intel}), an
7802 assembler template such as this:
7803
7804 @example
7805 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7806 @end example
7807
7808 @noindent
7809 is equivalent to one of
7810
7811 @example
7812 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7813 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7814 @end example
7815
7816 Using that same compiler, this code:
7817
7818 @example
7819 "xchg@{l@}\t@{%%@}ebx, %1"
7820 @end example
7821
7822 @noindent
7823 corresponds to either
7824
7825 @example
7826 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7827 "xchg\tebx, %1" @r{/* intel dialect */}
7828 @end example
7829
7830 There is no support for nesting dialect alternatives.
7831
7832 @anchor{OutputOperands}
7833 @subsubsection Output Operands
7834 @cindex @code{asm} output operands
7835
7836 An @code{asm} statement has zero or more output operands indicating the names
7837 of C variables modified by the assembler code.
7838
7839 In this i386 example, @code{old} (referred to in the template string as
7840 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7841 (@code{%2}) is an input:
7842
7843 @example
7844 bool old;
7845
7846 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7847 "sbb %0,%0" // Use the CF to calculate old.
7848 : "=r" (old), "+rm" (*Base)
7849 : "Ir" (Offset)
7850 : "cc");
7851
7852 return old;
7853 @end example
7854
7855 Operands are separated by commas. Each operand has this format:
7856
7857 @example
7858 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7859 @end example
7860
7861 @table @var
7862 @item asmSymbolicName
7863 Specifies a symbolic name for the operand.
7864 Reference the name in the assembler template
7865 by enclosing it in square brackets
7866 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7867 that contains the definition. Any valid C variable name is acceptable,
7868 including names already defined in the surrounding code. No two operands
7869 within the same @code{asm} statement can use the same symbolic name.
7870
7871 When not using an @var{asmSymbolicName}, use the (zero-based) position
7872 of the operand
7873 in the list of operands in the assembler template. For example if there are
7874 three output operands, use @samp{%0} in the template to refer to the first,
7875 @samp{%1} for the second, and @samp{%2} for the third.
7876
7877 @item constraint
7878 A string constant specifying constraints on the placement of the operand;
7879 @xref{Constraints}, for details.
7880
7881 Output constraints must begin with either @samp{=} (a variable overwriting an
7882 existing value) or @samp{+} (when reading and writing). When using
7883 @samp{=}, do not assume the location contains the existing value
7884 on entry to the @code{asm}, except
7885 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7886
7887 After the prefix, there must be one or more additional constraints
7888 (@pxref{Constraints}) that describe where the value resides. Common
7889 constraints include @samp{r} for register and @samp{m} for memory.
7890 When you list more than one possible location (for example, @code{"=rm"}),
7891 the compiler chooses the most efficient one based on the current context.
7892 If you list as many alternates as the @code{asm} statement allows, you permit
7893 the optimizers to produce the best possible code.
7894 If you must use a specific register, but your Machine Constraints do not
7895 provide sufficient control to select the specific register you want,
7896 local register variables may provide a solution (@pxref{Local Register
7897 Variables}).
7898
7899 @item cvariablename
7900 Specifies a C lvalue expression to hold the output, typically a variable name.
7901 The enclosing parentheses are a required part of the syntax.
7902
7903 @end table
7904
7905 When the compiler selects the registers to use to
7906 represent the output operands, it does not use any of the clobbered registers
7907 (@pxref{Clobbers}).
7908
7909 Output operand expressions must be lvalues. The compiler cannot check whether
7910 the operands have data types that are reasonable for the instruction being
7911 executed. For output expressions that are not directly addressable (for
7912 example a bit-field), the constraint must allow a register. In that case, GCC
7913 uses the register as the output of the @code{asm}, and then stores that
7914 register into the output.
7915
7916 Operands using the @samp{+} constraint modifier count as two operands
7917 (that is, both as input and output) towards the total maximum of 30 operands
7918 per @code{asm} statement.
7919
7920 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7921 operands that must not overlap an input. Otherwise,
7922 GCC may allocate the output operand in the same register as an unrelated
7923 input operand, on the assumption that the assembler code consumes its
7924 inputs before producing outputs. This assumption may be false if the assembler
7925 code actually consists of more than one instruction.
7926
7927 The same problem can occur if one output parameter (@var{a}) allows a register
7928 constraint and another output parameter (@var{b}) allows a memory constraint.
7929 The code generated by GCC to access the memory address in @var{b} can contain
7930 registers which @emph{might} be shared by @var{a}, and GCC considers those
7931 registers to be inputs to the asm. As above, GCC assumes that such input
7932 registers are consumed before any outputs are written. This assumption may
7933 result in incorrect behavior if the asm writes to @var{a} before using
7934 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7935 ensures that modifying @var{a} does not affect the address referenced by
7936 @var{b}. Otherwise, the location of @var{b}
7937 is undefined if @var{a} is modified before using @var{b}.
7938
7939 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
7940 instead of simply @samp{%2}). Typically these qualifiers are hardware
7941 dependent. The list of supported modifiers for x86 is found at
7942 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7943
7944 If the C code that follows the @code{asm} makes no use of any of the output
7945 operands, use @code{volatile} for the @code{asm} statement to prevent the
7946 optimizers from discarding the @code{asm} statement as unneeded
7947 (see @ref{Volatile}).
7948
7949 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
7950 references the first output operand as @code{%0} (were there a second, it
7951 would be @code{%1}, etc). The number of the first input operand is one greater
7952 than that of the last output operand. In this i386 example, that makes
7953 @code{Mask} referenced as @code{%1}:
7954
7955 @example
7956 uint32_t Mask = 1234;
7957 uint32_t Index;
7958
7959 asm ("bsfl %1, %0"
7960 : "=r" (Index)
7961 : "r" (Mask)
7962 : "cc");
7963 @end example
7964
7965 That code overwrites the variable @code{Index} (@samp{=}),
7966 placing the value in a register (@samp{r}).
7967 Using the generic @samp{r} constraint instead of a constraint for a specific
7968 register allows the compiler to pick the register to use, which can result
7969 in more efficient code. This may not be possible if an assembler instruction
7970 requires a specific register.
7971
7972 The following i386 example uses the @var{asmSymbolicName} syntax.
7973 It produces the
7974 same result as the code above, but some may consider it more readable or more
7975 maintainable since reordering index numbers is not necessary when adding or
7976 removing operands. The names @code{aIndex} and @code{aMask}
7977 are only used in this example to emphasize which
7978 names get used where.
7979 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7980
7981 @example
7982 uint32_t Mask = 1234;
7983 uint32_t Index;
7984
7985 asm ("bsfl %[aMask], %[aIndex]"
7986 : [aIndex] "=r" (Index)
7987 : [aMask] "r" (Mask)
7988 : "cc");
7989 @end example
7990
7991 Here are some more examples of output operands.
7992
7993 @example
7994 uint32_t c = 1;
7995 uint32_t d;
7996 uint32_t *e = &c;
7997
7998 asm ("mov %[e], %[d]"
7999 : [d] "=rm" (d)
8000 : [e] "rm" (*e));
8001 @end example
8002
8003 Here, @code{d} may either be in a register or in memory. Since the compiler
8004 might already have the current value of the @code{uint32_t} location
8005 pointed to by @code{e}
8006 in a register, you can enable it to choose the best location
8007 for @code{d} by specifying both constraints.
8008
8009 @anchor{FlagOutputOperands}
8010 @subsection Flag Output Operands
8011 @cindex @code{asm} flag output operands
8012
8013 Some targets have a special register that holds the ``flags'' for the
8014 result of an operation or comparison. Normally, the contents of that
8015 register are either unmodifed by the asm, or the asm is considered to
8016 clobber the contents.
8017
8018 On some targets, a special form of output operand exists by which
8019 conditions in the flags register may be outputs of the asm. The set of
8020 conditions supported are target specific, but the general rule is that
8021 the output variable must be a scalar integer, and the value will be boolean.
8022 When supported, the target will define the preprocessor symbol
8023 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8024
8025 Because of the special nature of the flag output operands, the constraint
8026 may not include alternatives.
8027
8028 Most often, the target has only one flags register, and thus is an implied
8029 operand of many instructions. In this case, the operand should not be
8030 referenced within the assembler template via @code{%0} etc, as there's
8031 no corresponding text in the assembly language.
8032
8033 @table @asis
8034 @item x86 family
8035 The flag output constraints for the x86 family are of the form
8036 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8037 conditions defined in the ISA manual for @code{j@var{cc}} or
8038 @code{set@var{cc}}.
8039
8040 @table @code
8041 @item a
8042 ``above'' or unsigned greater than
8043 @item ae
8044 ``above or equal'' or unsigned greater than or equal
8045 @item b
8046 ``below'' or unsigned less than
8047 @item be
8048 ``below or equal'' or unsigned less than or equal
8049 @item c
8050 carry flag set
8051 @item e
8052 @itemx z
8053 ``equal'' or zero flag set
8054 @item g
8055 signed greater than
8056 @item ge
8057 signed greater than or equal
8058 @item l
8059 signed less than
8060 @item le
8061 signed less than or equal
8062 @item o
8063 overflow flag set
8064 @item p
8065 parity flag set
8066 @item s
8067 sign flag set
8068 @item na
8069 @itemx nae
8070 @itemx nb
8071 @itemx nbe
8072 @itemx nc
8073 @itemx ne
8074 @itemx ng
8075 @itemx nge
8076 @itemx nl
8077 @itemx nle
8078 @itemx no
8079 @itemx np
8080 @itemx ns
8081 @itemx nz
8082 ``not'' @var{flag}, or inverted versions of those above
8083 @end table
8084
8085 @end table
8086
8087 @anchor{InputOperands}
8088 @subsubsection Input Operands
8089 @cindex @code{asm} input operands
8090 @cindex @code{asm} expressions
8091
8092 Input operands make values from C variables and expressions available to the
8093 assembly code.
8094
8095 Operands are separated by commas. Each operand has this format:
8096
8097 @example
8098 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8099 @end example
8100
8101 @table @var
8102 @item asmSymbolicName
8103 Specifies a symbolic name for the operand.
8104 Reference the name in the assembler template
8105 by enclosing it in square brackets
8106 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8107 that contains the definition. Any valid C variable name is acceptable,
8108 including names already defined in the surrounding code. No two operands
8109 within the same @code{asm} statement can use the same symbolic name.
8110
8111 When not using an @var{asmSymbolicName}, use the (zero-based) position
8112 of the operand
8113 in the list of operands in the assembler template. For example if there are
8114 two output operands and three inputs,
8115 use @samp{%2} in the template to refer to the first input operand,
8116 @samp{%3} for the second, and @samp{%4} for the third.
8117
8118 @item constraint
8119 A string constant specifying constraints on the placement of the operand;
8120 @xref{Constraints}, for details.
8121
8122 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8123 When you list more than one possible location (for example, @samp{"irm"}),
8124 the compiler chooses the most efficient one based on the current context.
8125 If you must use a specific register, but your Machine Constraints do not
8126 provide sufficient control to select the specific register you want,
8127 local register variables may provide a solution (@pxref{Local Register
8128 Variables}).
8129
8130 Input constraints can also be digits (for example, @code{"0"}). This indicates
8131 that the specified input must be in the same place as the output constraint
8132 at the (zero-based) index in the output constraint list.
8133 When using @var{asmSymbolicName} syntax for the output operands,
8134 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8135
8136 @item cexpression
8137 This is the C variable or expression being passed to the @code{asm} statement
8138 as input. The enclosing parentheses are a required part of the syntax.
8139
8140 @end table
8141
8142 When the compiler selects the registers to use to represent the input
8143 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8144
8145 If there are no output operands but there are input operands, place two
8146 consecutive colons where the output operands would go:
8147
8148 @example
8149 __asm__ ("some instructions"
8150 : /* No outputs. */
8151 : "r" (Offset / 8));
8152 @end example
8153
8154 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8155 (except for inputs tied to outputs). The compiler assumes that on exit from
8156 the @code{asm} statement these operands contain the same values as they
8157 had before executing the statement.
8158 It is @emph{not} possible to use clobbers
8159 to inform the compiler that the values in these inputs are changing. One
8160 common work-around is to tie the changing input variable to an output variable
8161 that never gets used. Note, however, that if the code that follows the
8162 @code{asm} statement makes no use of any of the output operands, the GCC
8163 optimizers may discard the @code{asm} statement as unneeded
8164 (see @ref{Volatile}).
8165
8166 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8167 instead of simply @samp{%2}). Typically these qualifiers are hardware
8168 dependent. The list of supported modifiers for x86 is found at
8169 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8170
8171 In this example using the fictitious @code{combine} instruction, the
8172 constraint @code{"0"} for input operand 1 says that it must occupy the same
8173 location as output operand 0. Only input operands may use numbers in
8174 constraints, and they must each refer to an output operand. Only a number (or
8175 the symbolic assembler name) in the constraint can guarantee that one operand
8176 is in the same place as another. The mere fact that @code{foo} is the value of
8177 both operands is not enough to guarantee that they are in the same place in
8178 the generated assembler code.
8179
8180 @example
8181 asm ("combine %2, %0"
8182 : "=r" (foo)
8183 : "0" (foo), "g" (bar));
8184 @end example
8185
8186 Here is an example using symbolic names.
8187
8188 @example
8189 asm ("cmoveq %1, %2, %[result]"
8190 : [result] "=r"(result)
8191 : "r" (test), "r" (new), "[result]" (old));
8192 @end example
8193
8194 @anchor{Clobbers}
8195 @subsubsection Clobbers
8196 @cindex @code{asm} clobbers
8197
8198 While the compiler is aware of changes to entries listed in the output
8199 operands, the inline @code{asm} code may modify more than just the outputs. For
8200 example, calculations may require additional registers, or the processor may
8201 overwrite a register as a side effect of a particular assembler instruction.
8202 In order to inform the compiler of these changes, list them in the clobber
8203 list. Clobber list items are either register names or the special clobbers
8204 (listed below). Each clobber list item is a string constant
8205 enclosed in double quotes and separated by commas.
8206
8207 Clobber descriptions may not in any way overlap with an input or output
8208 operand. For example, you may not have an operand describing a register class
8209 with one member when listing that register in the clobber list. Variables
8210 declared to live in specific registers (@pxref{Explicit Register
8211 Variables}) and used
8212 as @code{asm} input or output operands must have no part mentioned in the
8213 clobber description. In particular, there is no way to specify that input
8214 operands get modified without also specifying them as output operands.
8215
8216 When the compiler selects which registers to use to represent input and output
8217 operands, it does not use any of the clobbered registers. As a result,
8218 clobbered registers are available for any use in the assembler code.
8219
8220 Here is a realistic example for the VAX showing the use of clobbered
8221 registers:
8222
8223 @example
8224 asm volatile ("movc3 %0, %1, %2"
8225 : /* No outputs. */
8226 : "g" (from), "g" (to), "g" (count)
8227 : "r0", "r1", "r2", "r3", "r4", "r5");
8228 @end example
8229
8230 Also, there are two special clobber arguments:
8231
8232 @table @code
8233 @item "cc"
8234 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8235 register. On some machines, GCC represents the condition codes as a specific
8236 hardware register; @code{"cc"} serves to name this register.
8237 On other machines, condition code handling is different,
8238 and specifying @code{"cc"} has no effect. But
8239 it is valid no matter what the target.
8240
8241 @item "memory"
8242 The @code{"memory"} clobber tells the compiler that the assembly code
8243 performs memory
8244 reads or writes to items other than those listed in the input and output
8245 operands (for example, accessing the memory pointed to by one of the input
8246 parameters). To ensure memory contains correct values, GCC may need to flush
8247 specific register values to memory before executing the @code{asm}. Further,
8248 the compiler does not assume that any values read from memory before an
8249 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8250 needed.
8251 Using the @code{"memory"} clobber effectively forms a read/write
8252 memory barrier for the compiler.
8253
8254 Note that this clobber does not prevent the @emph{processor} from doing
8255 speculative reads past the @code{asm} statement. To prevent that, you need
8256 processor-specific fence instructions.
8257
8258 Flushing registers to memory has performance implications and may be an issue
8259 for time-sensitive code. You can use a trick to avoid this if the size of
8260 the memory being accessed is known at compile time. For example, if accessing
8261 ten bytes of a string, use a memory input like:
8262
8263 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8264
8265 @end table
8266
8267 @anchor{GotoLabels}
8268 @subsubsection Goto Labels
8269 @cindex @code{asm} goto labels
8270
8271 @code{asm goto} allows assembly code to jump to one or more C labels. The
8272 @var{GotoLabels} section in an @code{asm goto} statement contains
8273 a comma-separated
8274 list of all C labels to which the assembler code may jump. GCC assumes that
8275 @code{asm} execution falls through to the next statement (if this is not the
8276 case, consider using the @code{__builtin_unreachable} intrinsic after the
8277 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8278 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8279 Attributes}).
8280
8281 An @code{asm goto} statement cannot have outputs.
8282 This is due to an internal restriction of
8283 the compiler: control transfer instructions cannot have outputs.
8284 If the assembler code does modify anything, use the @code{"memory"} clobber
8285 to force the
8286 optimizers to flush all register values to memory and reload them if
8287 necessary after the @code{asm} statement.
8288
8289 Also note that an @code{asm goto} statement is always implicitly
8290 considered volatile.
8291
8292 To reference a label in the assembler template,
8293 prefix it with @samp{%l} (lowercase @samp{L}) followed
8294 by its (zero-based) position in @var{GotoLabels} plus the number of input
8295 operands. For example, if the @code{asm} has three inputs and references two
8296 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8297
8298 Alternately, you can reference labels using the actual C label name enclosed
8299 in brackets. For example, to reference a label named @code{carry}, you can
8300 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8301 section when using this approach.
8302
8303 Here is an example of @code{asm goto} for i386:
8304
8305 @example
8306 asm goto (
8307 "btl %1, %0\n\t"
8308 "jc %l2"
8309 : /* No outputs. */
8310 : "r" (p1), "r" (p2)
8311 : "cc"
8312 : carry);
8313
8314 return 0;
8315
8316 carry:
8317 return 1;
8318 @end example
8319
8320 The following example shows an @code{asm goto} that uses a memory clobber.
8321
8322 @example
8323 int frob(int x)
8324 @{
8325 int y;
8326 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8327 : /* No outputs. */
8328 : "r"(x), "r"(&y)
8329 : "r5", "memory"
8330 : error);
8331 return y;
8332 error:
8333 return -1;
8334 @}
8335 @end example
8336
8337 @anchor{x86Operandmodifiers}
8338 @subsubsection x86 Operand Modifiers
8339
8340 References to input, output, and goto operands in the assembler template
8341 of extended @code{asm} statements can use
8342 modifiers to affect the way the operands are formatted in
8343 the code output to the assembler. For example, the
8344 following code uses the @samp{h} and @samp{b} modifiers for x86:
8345
8346 @example
8347 uint16_t num;
8348 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8349 @end example
8350
8351 @noindent
8352 These modifiers generate this assembler code:
8353
8354 @example
8355 xchg %ah, %al
8356 @end example
8357
8358 The rest of this discussion uses the following code for illustrative purposes.
8359
8360 @example
8361 int main()
8362 @{
8363 int iInt = 1;
8364
8365 top:
8366
8367 asm volatile goto ("some assembler instructions here"
8368 : /* No outputs. */
8369 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8370 : /* No clobbers. */
8371 : top);
8372 @}
8373 @end example
8374
8375 With no modifiers, this is what the output from the operands would be for the
8376 @samp{att} and @samp{intel} dialects of assembler:
8377
8378 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8379 @headitem Operand @tab masm=att @tab masm=intel
8380 @item @code{%0}
8381 @tab @code{%eax}
8382 @tab @code{eax}
8383 @item @code{%1}
8384 @tab @code{$2}
8385 @tab @code{2}
8386 @item @code{%2}
8387 @tab @code{$.L2}
8388 @tab @code{OFFSET FLAT:.L2}
8389 @end multitable
8390
8391 The table below shows the list of supported modifiers and their effects.
8392
8393 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8394 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8395 @item @code{z}
8396 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8397 @tab @code{%z0}
8398 @tab @code{l}
8399 @tab
8400 @item @code{b}
8401 @tab Print the QImode name of the register.
8402 @tab @code{%b0}
8403 @tab @code{%al}
8404 @tab @code{al}
8405 @item @code{h}
8406 @tab Print the QImode name for a ``high'' register.
8407 @tab @code{%h0}
8408 @tab @code{%ah}
8409 @tab @code{ah}
8410 @item @code{w}
8411 @tab Print the HImode name of the register.
8412 @tab @code{%w0}
8413 @tab @code{%ax}
8414 @tab @code{ax}
8415 @item @code{k}
8416 @tab Print the SImode name of the register.
8417 @tab @code{%k0}
8418 @tab @code{%eax}
8419 @tab @code{eax}
8420 @item @code{q}
8421 @tab Print the DImode name of the register.
8422 @tab @code{%q0}
8423 @tab @code{%rax}
8424 @tab @code{rax}
8425 @item @code{l}
8426 @tab Print the label name with no punctuation.
8427 @tab @code{%l2}
8428 @tab @code{.L2}
8429 @tab @code{.L2}
8430 @item @code{c}
8431 @tab Require a constant operand and print the constant expression with no punctuation.
8432 @tab @code{%c1}
8433 @tab @code{2}
8434 @tab @code{2}
8435 @end multitable
8436
8437 @anchor{x86floatingpointasmoperands}
8438 @subsubsection x86 Floating-Point @code{asm} Operands
8439
8440 On x86 targets, there are several rules on the usage of stack-like registers
8441 in the operands of an @code{asm}. These rules apply only to the operands
8442 that are stack-like registers:
8443
8444 @enumerate
8445 @item
8446 Given a set of input registers that die in an @code{asm}, it is
8447 necessary to know which are implicitly popped by the @code{asm}, and
8448 which must be explicitly popped by GCC@.
8449
8450 An input register that is implicitly popped by the @code{asm} must be
8451 explicitly clobbered, unless it is constrained to match an
8452 output operand.
8453
8454 @item
8455 For any input register that is implicitly popped by an @code{asm}, it is
8456 necessary to know how to adjust the stack to compensate for the pop.
8457 If any non-popped input is closer to the top of the reg-stack than
8458 the implicitly popped register, it would not be possible to know what the
8459 stack looked like---it's not clear how the rest of the stack ``slides
8460 up''.
8461
8462 All implicitly popped input registers must be closer to the top of
8463 the reg-stack than any input that is not implicitly popped.
8464
8465 It is possible that if an input dies in an @code{asm}, the compiler might
8466 use the input register for an output reload. Consider this example:
8467
8468 @smallexample
8469 asm ("foo" : "=t" (a) : "f" (b));
8470 @end smallexample
8471
8472 @noindent
8473 This code says that input @code{b} is not popped by the @code{asm}, and that
8474 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8475 deeper after the @code{asm} than it was before. But, it is possible that
8476 reload may think that it can use the same register for both the input and
8477 the output.
8478
8479 To prevent this from happening,
8480 if any input operand uses the @samp{f} constraint, all output register
8481 constraints must use the @samp{&} early-clobber modifier.
8482
8483 The example above is correctly written as:
8484
8485 @smallexample
8486 asm ("foo" : "=&t" (a) : "f" (b));
8487 @end smallexample
8488
8489 @item
8490 Some operands need to be in particular places on the stack. All
8491 output operands fall in this category---GCC has no other way to
8492 know which registers the outputs appear in unless you indicate
8493 this in the constraints.
8494
8495 Output operands must specifically indicate which register an output
8496 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8497 constraints must select a class with a single register.
8498
8499 @item
8500 Output operands may not be ``inserted'' between existing stack registers.
8501 Since no 387 opcode uses a read/write operand, all output operands
8502 are dead before the @code{asm}, and are pushed by the @code{asm}.
8503 It makes no sense to push anywhere but the top of the reg-stack.
8504
8505 Output operands must start at the top of the reg-stack: output
8506 operands may not ``skip'' a register.
8507
8508 @item
8509 Some @code{asm} statements may need extra stack space for internal
8510 calculations. This can be guaranteed by clobbering stack registers
8511 unrelated to the inputs and outputs.
8512
8513 @end enumerate
8514
8515 This @code{asm}
8516 takes one input, which is internally popped, and produces two outputs.
8517
8518 @smallexample
8519 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8520 @end smallexample
8521
8522 @noindent
8523 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8524 and replaces them with one output. The @code{st(1)} clobber is necessary
8525 for the compiler to know that @code{fyl2xp1} pops both inputs.
8526
8527 @smallexample
8528 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8529 @end smallexample
8530
8531 @lowersections
8532 @include md.texi
8533 @raisesections
8534
8535 @node Asm Labels
8536 @subsection Controlling Names Used in Assembler Code
8537 @cindex assembler names for identifiers
8538 @cindex names used in assembler code
8539 @cindex identifiers, names in assembler code
8540
8541 You can specify the name to be used in the assembler code for a C
8542 function or variable by writing the @code{asm} (or @code{__asm__})
8543 keyword after the declarator.
8544 It is up to you to make sure that the assembler names you choose do not
8545 conflict with any other assembler symbols, or reference registers.
8546
8547 @subsubheading Assembler names for data:
8548
8549 This sample shows how to specify the assembler name for data:
8550
8551 @smallexample
8552 int foo asm ("myfoo") = 2;
8553 @end smallexample
8554
8555 @noindent
8556 This specifies that the name to be used for the variable @code{foo} in
8557 the assembler code should be @samp{myfoo} rather than the usual
8558 @samp{_foo}.
8559
8560 On systems where an underscore is normally prepended to the name of a C
8561 variable, this feature allows you to define names for the
8562 linker that do not start with an underscore.
8563
8564 GCC does not support using this feature with a non-static local variable
8565 since such variables do not have assembler names. If you are
8566 trying to put the variable in a particular register, see
8567 @ref{Explicit Register Variables}.
8568
8569 @subsubheading Assembler names for functions:
8570
8571 To specify the assembler name for functions, write a declaration for the
8572 function before its definition and put @code{asm} there, like this:
8573
8574 @smallexample
8575 int func (int x, int y) asm ("MYFUNC");
8576
8577 int func (int x, int y)
8578 @{
8579 /* @r{@dots{}} */
8580 @end smallexample
8581
8582 @noindent
8583 This specifies that the name to be used for the function @code{func} in
8584 the assembler code should be @code{MYFUNC}.
8585
8586 @node Explicit Register Variables
8587 @subsection Variables in Specified Registers
8588 @anchor{Explicit Reg Vars}
8589 @cindex explicit register variables
8590 @cindex variables in specified registers
8591 @cindex specified registers
8592
8593 GNU C allows you to associate specific hardware registers with C
8594 variables. In almost all cases, allowing the compiler to assign
8595 registers produces the best code. However under certain unusual
8596 circumstances, more precise control over the variable storage is
8597 required.
8598
8599 Both global and local variables can be associated with a register. The
8600 consequences of performing this association are very different between
8601 the two, as explained in the sections below.
8602
8603 @menu
8604 * Global Register Variables:: Variables declared at global scope.
8605 * Local Register Variables:: Variables declared within a function.
8606 @end menu
8607
8608 @node Global Register Variables
8609 @subsubsection Defining Global Register Variables
8610 @anchor{Global Reg Vars}
8611 @cindex global register variables
8612 @cindex registers, global variables in
8613 @cindex registers, global allocation
8614
8615 You can define a global register variable and associate it with a specified
8616 register like this:
8617
8618 @smallexample
8619 register int *foo asm ("r12");
8620 @end smallexample
8621
8622 @noindent
8623 Here @code{r12} is the name of the register that should be used. Note that
8624 this is the same syntax used for defining local register variables, but for
8625 a global variable the declaration appears outside a function. The
8626 @code{register} keyword is required, and cannot be combined with
8627 @code{static}. The register name must be a valid register name for the
8628 target platform.
8629
8630 Registers are a scarce resource on most systems and allowing the
8631 compiler to manage their usage usually results in the best code. However,
8632 under special circumstances it can make sense to reserve some globally.
8633 For example this may be useful in programs such as programming language
8634 interpreters that have a couple of global variables that are accessed
8635 very often.
8636
8637 After defining a global register variable, for the current compilation
8638 unit:
8639
8640 @itemize @bullet
8641 @item The register is reserved entirely for this use, and will not be
8642 allocated for any other purpose.
8643 @item The register is not saved and restored by any functions.
8644 @item Stores into this register are never deleted even if they appear to be
8645 dead, but references may be deleted, moved or simplified.
8646 @end itemize
8647
8648 Note that these points @emph{only} apply to code that is compiled with the
8649 definition. The behavior of code that is merely linked in (for example
8650 code from libraries) is not affected.
8651
8652 If you want to recompile source files that do not actually use your global
8653 register variable so they do not use the specified register for any other
8654 purpose, you need not actually add the global register declaration to
8655 their source code. It suffices to specify the compiler option
8656 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8657 register.
8658
8659 @subsubheading Declaring the variable
8660
8661 Global register variables can not have initial values, because an
8662 executable file has no means to supply initial contents for a register.
8663
8664 When selecting a register, choose one that is normally saved and
8665 restored by function calls on your machine. This ensures that code
8666 which is unaware of this reservation (such as library routines) will
8667 restore it before returning.
8668
8669 On machines with register windows, be sure to choose a global
8670 register that is not affected magically by the function call mechanism.
8671
8672 @subsubheading Using the variable
8673
8674 @cindex @code{qsort}, and global register variables
8675 When calling routines that are not aware of the reservation, be
8676 cautious if those routines call back into code which uses them. As an
8677 example, if you call the system library version of @code{qsort}, it may
8678 clobber your registers during execution, but (if you have selected
8679 appropriate registers) it will restore them before returning. However
8680 it will @emph{not} restore them before calling @code{qsort}'s comparison
8681 function. As a result, global values will not reliably be available to
8682 the comparison function unless the @code{qsort} function itself is rebuilt.
8683
8684 Similarly, it is not safe to access the global register variables from signal
8685 handlers or from more than one thread of control. Unless you recompile
8686 them specially for the task at hand, the system library routines may
8687 temporarily use the register for other things.
8688
8689 @cindex register variable after @code{longjmp}
8690 @cindex global register after @code{longjmp}
8691 @cindex value after @code{longjmp}
8692 @findex longjmp
8693 @findex setjmp
8694 On most machines, @code{longjmp} restores to each global register
8695 variable the value it had at the time of the @code{setjmp}. On some
8696 machines, however, @code{longjmp} does not change the value of global
8697 register variables. To be portable, the function that called @code{setjmp}
8698 should make other arrangements to save the values of the global register
8699 variables, and to restore them in a @code{longjmp}. This way, the same
8700 thing happens regardless of what @code{longjmp} does.
8701
8702 Eventually there may be a way of asking the compiler to choose a register
8703 automatically, but first we need to figure out how it should choose and
8704 how to enable you to guide the choice. No solution is evident.
8705
8706 @node Local Register Variables
8707 @subsubsection Specifying Registers for Local Variables
8708 @anchor{Local Reg Vars}
8709 @cindex local variables, specifying registers
8710 @cindex specifying registers for local variables
8711 @cindex registers for local variables
8712
8713 You can define a local register variable and associate it with a specified
8714 register like this:
8715
8716 @smallexample
8717 register int *foo asm ("r12");
8718 @end smallexample
8719
8720 @noindent
8721 Here @code{r12} is the name of the register that should be used. Note
8722 that this is the same syntax used for defining global register variables,
8723 but for a local variable the declaration appears within a function. The
8724 @code{register} keyword is required, and cannot be combined with
8725 @code{static}. The register name must be a valid register name for the
8726 target platform.
8727
8728 As with global register variables, it is recommended that you choose
8729 a register that is normally saved and restored by function calls on your
8730 machine, so that calls to library routines will not clobber it.
8731
8732 The only supported use for this feature is to specify registers
8733 for input and output operands when calling Extended @code{asm}
8734 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8735 particular machine don't provide sufficient control to select the desired
8736 register. To force an operand into a register, create a local variable
8737 and specify the register name after the variable's declaration. Then use
8738 the local variable for the @code{asm} operand and specify any constraint
8739 letter that matches the register:
8740
8741 @smallexample
8742 register int *p1 asm ("r0") = @dots{};
8743 register int *p2 asm ("r1") = @dots{};
8744 register int *result asm ("r0");
8745 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8746 @end smallexample
8747
8748 @emph{Warning:} In the above example, be aware that a register (for example
8749 @code{r0}) can be call-clobbered by subsequent code, including function
8750 calls and library calls for arithmetic operators on other variables (for
8751 example the initialization of @code{p2}). In this case, use temporary
8752 variables for expressions between the register assignments:
8753
8754 @smallexample
8755 int t1 = @dots{};
8756 register int *p1 asm ("r0") = @dots{};
8757 register int *p2 asm ("r1") = t1;
8758 register int *result asm ("r0");
8759 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8760 @end smallexample
8761
8762 Defining a register variable does not reserve the register. Other than
8763 when invoking the Extended @code{asm}, the contents of the specified
8764 register are not guaranteed. For this reason, the following uses
8765 are explicitly @emph{not} supported. If they appear to work, it is only
8766 happenstance, and may stop working as intended due to (seemingly)
8767 unrelated changes in surrounding code, or even minor changes in the
8768 optimization of a future version of gcc:
8769
8770 @itemize @bullet
8771 @item Passing parameters to or from Basic @code{asm}
8772 @item Passing parameters to or from Extended @code{asm} without using input
8773 or output operands.
8774 @item Passing parameters to or from routines written in assembler (or
8775 other languages) using non-standard calling conventions.
8776 @end itemize
8777
8778 Some developers use Local Register Variables in an attempt to improve
8779 gcc's allocation of registers, especially in large functions. In this
8780 case the register name is essentially a hint to the register allocator.
8781 While in some instances this can generate better code, improvements are
8782 subject to the whims of the allocator/optimizers. Since there are no
8783 guarantees that your improvements won't be lost, this usage of Local
8784 Register Variables is discouraged.
8785
8786 On the MIPS platform, there is related use for local register variables
8787 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8788 Defining coprocessor specifics for MIPS targets, gccint,
8789 GNU Compiler Collection (GCC) Internals}).
8790
8791 @node Size of an asm
8792 @subsection Size of an @code{asm}
8793
8794 Some targets require that GCC track the size of each instruction used
8795 in order to generate correct code. Because the final length of the
8796 code produced by an @code{asm} statement is only known by the
8797 assembler, GCC must make an estimate as to how big it will be. It
8798 does this by counting the number of instructions in the pattern of the
8799 @code{asm} and multiplying that by the length of the longest
8800 instruction supported by that processor. (When working out the number
8801 of instructions, it assumes that any occurrence of a newline or of
8802 whatever statement separator character is supported by the assembler --
8803 typically @samp{;} --- indicates the end of an instruction.)
8804
8805 Normally, GCC's estimate is adequate to ensure that correct
8806 code is generated, but it is possible to confuse the compiler if you use
8807 pseudo instructions or assembler macros that expand into multiple real
8808 instructions, or if you use assembler directives that expand to more
8809 space in the object file than is needed for a single instruction.
8810 If this happens then the assembler may produce a diagnostic saying that
8811 a label is unreachable.
8812
8813 @node Alternate Keywords
8814 @section Alternate Keywords
8815 @cindex alternate keywords
8816 @cindex keywords, alternate
8817
8818 @option{-ansi} and the various @option{-std} options disable certain
8819 keywords. This causes trouble when you want to use GNU C extensions, or
8820 a general-purpose header file that should be usable by all programs,
8821 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8822 @code{inline} are not available in programs compiled with
8823 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8824 program compiled with @option{-std=c99} or @option{-std=c11}). The
8825 ISO C99 keyword
8826 @code{restrict} is only available when @option{-std=gnu99} (which will
8827 eventually be the default) or @option{-std=c99} (or the equivalent
8828 @option{-std=iso9899:1999}), or an option for a later standard
8829 version, is used.
8830
8831 The way to solve these problems is to put @samp{__} at the beginning and
8832 end of each problematical keyword. For example, use @code{__asm__}
8833 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8834
8835 Other C compilers won't accept these alternative keywords; if you want to
8836 compile with another compiler, you can define the alternate keywords as
8837 macros to replace them with the customary keywords. It looks like this:
8838
8839 @smallexample
8840 #ifndef __GNUC__
8841 #define __asm__ asm
8842 #endif
8843 @end smallexample
8844
8845 @findex __extension__
8846 @opindex pedantic
8847 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8848 You can
8849 prevent such warnings within one expression by writing
8850 @code{__extension__} before the expression. @code{__extension__} has no
8851 effect aside from this.
8852
8853 @node Incomplete Enums
8854 @section Incomplete @code{enum} Types
8855
8856 You can define an @code{enum} tag without specifying its possible values.
8857 This results in an incomplete type, much like what you get if you write
8858 @code{struct foo} without describing the elements. A later declaration
8859 that does specify the possible values completes the type.
8860
8861 You can't allocate variables or storage using the type while it is
8862 incomplete. However, you can work with pointers to that type.
8863
8864 This extension may not be very useful, but it makes the handling of
8865 @code{enum} more consistent with the way @code{struct} and @code{union}
8866 are handled.
8867
8868 This extension is not supported by GNU C++.
8869
8870 @node Function Names
8871 @section Function Names as Strings
8872 @cindex @code{__func__} identifier
8873 @cindex @code{__FUNCTION__} identifier
8874 @cindex @code{__PRETTY_FUNCTION__} identifier
8875
8876 GCC provides three magic variables that hold the name of the current
8877 function, as a string. The first of these is @code{__func__}, which
8878 is part of the C99 standard:
8879
8880 The identifier @code{__func__} is implicitly declared by the translator
8881 as if, immediately following the opening brace of each function
8882 definition, the declaration
8883
8884 @smallexample
8885 static const char __func__[] = "function-name";
8886 @end smallexample
8887
8888 @noindent
8889 appeared, where function-name is the name of the lexically-enclosing
8890 function. This name is the unadorned name of the function.
8891
8892 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8893 backward compatibility with old versions of GCC.
8894
8895 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8896 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8897 the type signature of the function as well as its bare name. For
8898 example, this program:
8899
8900 @smallexample
8901 extern "C" @{
8902 extern int printf (char *, ...);
8903 @}
8904
8905 class a @{
8906 public:
8907 void sub (int i)
8908 @{
8909 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8910 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8911 @}
8912 @};
8913
8914 int
8915 main (void)
8916 @{
8917 a ax;
8918 ax.sub (0);
8919 return 0;
8920 @}
8921 @end smallexample
8922
8923 @noindent
8924 gives this output:
8925
8926 @smallexample
8927 __FUNCTION__ = sub
8928 __PRETTY_FUNCTION__ = void a::sub(int)
8929 @end smallexample
8930
8931 These identifiers are variables, not preprocessor macros, and may not
8932 be used to initialize @code{char} arrays or be concatenated with other string
8933 literals.
8934
8935 @node Return Address
8936 @section Getting the Return or Frame Address of a Function
8937
8938 These functions may be used to get information about the callers of a
8939 function.
8940
8941 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8942 This function returns the return address of the current function, or of
8943 one of its callers. The @var{level} argument is number of frames to
8944 scan up the call stack. A value of @code{0} yields the return address
8945 of the current function, a value of @code{1} yields the return address
8946 of the caller of the current function, and so forth. When inlining
8947 the expected behavior is that the function returns the address of
8948 the function that is returned to. To work around this behavior use
8949 the @code{noinline} function attribute.
8950
8951 The @var{level} argument must be a constant integer.
8952
8953 On some machines it may be impossible to determine the return address of
8954 any function other than the current one; in such cases, or when the top
8955 of the stack has been reached, this function returns @code{0} or a
8956 random value. In addition, @code{__builtin_frame_address} may be used
8957 to determine if the top of the stack has been reached.
8958
8959 Additional post-processing of the returned value may be needed, see
8960 @code{__builtin_extract_return_addr}.
8961
8962 Calling this function with a nonzero argument can have unpredictable
8963 effects, including crashing the calling program. As a result, calls
8964 that are considered unsafe are diagnosed when the @option{-Wframe-address}
8965 option is in effect. Such calls should only be made in debugging
8966 situations.
8967 @end deftypefn
8968
8969 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8970 The address as returned by @code{__builtin_return_address} may have to be fed
8971 through this function to get the actual encoded address. For example, on the
8972 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8973 platforms an offset has to be added for the true next instruction to be
8974 executed.
8975
8976 If no fixup is needed, this function simply passes through @var{addr}.
8977 @end deftypefn
8978
8979 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
8980 This function does the reverse of @code{__builtin_extract_return_addr}.
8981 @end deftypefn
8982
8983 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
8984 This function is similar to @code{__builtin_return_address}, but it
8985 returns the address of the function frame rather than the return address
8986 of the function. Calling @code{__builtin_frame_address} with a value of
8987 @code{0} yields the frame address of the current function, a value of
8988 @code{1} yields the frame address of the caller of the current function,
8989 and so forth.
8990
8991 The frame is the area on the stack that holds local variables and saved
8992 registers. The frame address is normally the address of the first word
8993 pushed on to the stack by the function. However, the exact definition
8994 depends upon the processor and the calling convention. If the processor
8995 has a dedicated frame pointer register, and the function has a frame,
8996 then @code{__builtin_frame_address} returns the value of the frame
8997 pointer register.
8998
8999 On some machines it may be impossible to determine the frame address of
9000 any function other than the current one; in such cases, or when the top
9001 of the stack has been reached, this function returns @code{0} if
9002 the first frame pointer is properly initialized by the startup code.
9003
9004 Calling this function with a nonzero argument can have unpredictable
9005 effects, including crashing the calling program. As a result, calls
9006 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9007 option is in effect. Such calls should only be made in debugging
9008 situations.
9009 @end deftypefn
9010
9011 @node Vector Extensions
9012 @section Using Vector Instructions through Built-in Functions
9013
9014 On some targets, the instruction set contains SIMD vector instructions which
9015 operate on multiple values contained in one large register at the same time.
9016 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9017 this way.
9018
9019 The first step in using these extensions is to provide the necessary data
9020 types. This should be done using an appropriate @code{typedef}:
9021
9022 @smallexample
9023 typedef int v4si __attribute__ ((vector_size (16)));
9024 @end smallexample
9025
9026 @noindent
9027 The @code{int} type specifies the base type, while the attribute specifies
9028 the vector size for the variable, measured in bytes. For example, the
9029 declaration above causes the compiler to set the mode for the @code{v4si}
9030 type to be 16 bytes wide and divided into @code{int} sized units. For
9031 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9032 corresponding mode of @code{foo} is @acronym{V4SI}.
9033
9034 The @code{vector_size} attribute is only applicable to integral and
9035 float scalars, although arrays, pointers, and function return values
9036 are allowed in conjunction with this construct. Only sizes that are
9037 a power of two are currently allowed.
9038
9039 All the basic integer types can be used as base types, both as signed
9040 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9041 @code{long long}. In addition, @code{float} and @code{double} can be
9042 used to build floating-point vector types.
9043
9044 Specifying a combination that is not valid for the current architecture
9045 causes GCC to synthesize the instructions using a narrower mode.
9046 For example, if you specify a variable of type @code{V4SI} and your
9047 architecture does not allow for this specific SIMD type, GCC
9048 produces code that uses 4 @code{SIs}.
9049
9050 The types defined in this manner can be used with a subset of normal C
9051 operations. Currently, GCC allows using the following operators
9052 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9053
9054 The operations behave like C++ @code{valarrays}. Addition is defined as
9055 the addition of the corresponding elements of the operands. For
9056 example, in the code below, each of the 4 elements in @var{a} is
9057 added to the corresponding 4 elements in @var{b} and the resulting
9058 vector is stored in @var{c}.
9059
9060 @smallexample
9061 typedef int v4si __attribute__ ((vector_size (16)));
9062
9063 v4si a, b, c;
9064
9065 c = a + b;
9066 @end smallexample
9067
9068 Subtraction, multiplication, division, and the logical operations
9069 operate in a similar manner. Likewise, the result of using the unary
9070 minus or complement operators on a vector type is a vector whose
9071 elements are the negative or complemented values of the corresponding
9072 elements in the operand.
9073
9074 It is possible to use shifting operators @code{<<}, @code{>>} on
9075 integer-type vectors. The operation is defined as following: @code{@{a0,
9076 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9077 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9078 elements.
9079
9080 For convenience, it is allowed to use a binary vector operation
9081 where one operand is a scalar. In that case the compiler transforms
9082 the scalar operand into a vector where each element is the scalar from
9083 the operation. The transformation happens only if the scalar could be
9084 safely converted to the vector-element type.
9085 Consider the following code.
9086
9087 @smallexample
9088 typedef int v4si __attribute__ ((vector_size (16)));
9089
9090 v4si a, b, c;
9091 long l;
9092
9093 a = b + 1; /* a = b + @{1,1,1,1@}; */
9094 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9095
9096 a = l + a; /* Error, cannot convert long to int. */
9097 @end smallexample
9098
9099 Vectors can be subscripted as if the vector were an array with
9100 the same number of elements and base type. Out of bound accesses
9101 invoke undefined behavior at run time. Warnings for out of bound
9102 accesses for vector subscription can be enabled with
9103 @option{-Warray-bounds}.
9104
9105 Vector comparison is supported with standard comparison
9106 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9107 vector expressions of integer-type or real-type. Comparison between
9108 integer-type vectors and real-type vectors are not supported. The
9109 result of the comparison is a vector of the same width and number of
9110 elements as the comparison operands with a signed integral element
9111 type.
9112
9113 Vectors are compared element-wise producing 0 when comparison is false
9114 and -1 (constant of the appropriate type where all bits are set)
9115 otherwise. Consider the following example.
9116
9117 @smallexample
9118 typedef int v4si __attribute__ ((vector_size (16)));
9119
9120 v4si a = @{1,2,3,4@};
9121 v4si b = @{3,2,1,4@};
9122 v4si c;
9123
9124 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9125 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9126 @end smallexample
9127
9128 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9129 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9130 integer vector with the same number of elements of the same size as @code{b}
9131 and @code{c}, computes all three arguments and creates a vector
9132 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9133 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9134 As in the case of binary operations, this syntax is also accepted when
9135 one of @code{b} or @code{c} is a scalar that is then transformed into a
9136 vector. If both @code{b} and @code{c} are scalars and the type of
9137 @code{true?b:c} has the same size as the element type of @code{a}, then
9138 @code{b} and @code{c} are converted to a vector type whose elements have
9139 this type and with the same number of elements as @code{a}.
9140
9141 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9142 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9143 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9144 For mixed operations between a scalar @code{s} and a vector @code{v},
9145 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9146 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9147
9148 Vector shuffling is available using functions
9149 @code{__builtin_shuffle (vec, mask)} and
9150 @code{__builtin_shuffle (vec0, vec1, mask)}.
9151 Both functions construct a permutation of elements from one or two
9152 vectors and return a vector of the same type as the input vector(s).
9153 The @var{mask} is an integral vector with the same width (@var{W})
9154 and element count (@var{N}) as the output vector.
9155
9156 The elements of the input vectors are numbered in memory ordering of
9157 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9158 elements of @var{mask} are considered modulo @var{N} in the single-operand
9159 case and modulo @math{2*@var{N}} in the two-operand case.
9160
9161 Consider the following example,
9162
9163 @smallexample
9164 typedef int v4si __attribute__ ((vector_size (16)));
9165
9166 v4si a = @{1,2,3,4@};
9167 v4si b = @{5,6,7,8@};
9168 v4si mask1 = @{0,1,1,3@};
9169 v4si mask2 = @{0,4,2,5@};
9170 v4si res;
9171
9172 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9173 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9174 @end smallexample
9175
9176 Note that @code{__builtin_shuffle} is intentionally semantically
9177 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9178
9179 You can declare variables and use them in function calls and returns, as
9180 well as in assignments and some casts. You can specify a vector type as
9181 a return type for a function. Vector types can also be used as function
9182 arguments. It is possible to cast from one vector type to another,
9183 provided they are of the same size (in fact, you can also cast vectors
9184 to and from other datatypes of the same size).
9185
9186 You cannot operate between vectors of different lengths or different
9187 signedness without a cast.
9188
9189 @node Offsetof
9190 @section Support for @code{offsetof}
9191 @findex __builtin_offsetof
9192
9193 GCC implements for both C and C++ a syntactic extension to implement
9194 the @code{offsetof} macro.
9195
9196 @smallexample
9197 primary:
9198 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9199
9200 offsetof_member_designator:
9201 @code{identifier}
9202 | offsetof_member_designator "." @code{identifier}
9203 | offsetof_member_designator "[" @code{expr} "]"
9204 @end smallexample
9205
9206 This extension is sufficient such that
9207
9208 @smallexample
9209 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9210 @end smallexample
9211
9212 @noindent
9213 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9214 may be dependent. In either case, @var{member} may consist of a single
9215 identifier, or a sequence of member accesses and array references.
9216
9217 @node __sync Builtins
9218 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9219
9220 The following built-in functions
9221 are intended to be compatible with those described
9222 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9223 section 7.4. As such, they depart from normal GCC practice by not using
9224 the @samp{__builtin_} prefix and also by being overloaded so that they
9225 work on multiple types.
9226
9227 The definition given in the Intel documentation allows only for the use of
9228 the types @code{int}, @code{long}, @code{long long} or their unsigned
9229 counterparts. GCC allows any integral scalar or pointer type that is
9230 1, 2, 4 or 8 bytes in length.
9231
9232 These functions are implemented in terms of the @samp{__atomic}
9233 builtins (@pxref{__atomic Builtins}). They should not be used for new
9234 code which should use the @samp{__atomic} builtins instead.
9235
9236 Not all operations are supported by all target processors. If a particular
9237 operation cannot be implemented on the target processor, a warning is
9238 generated and a call to an external function is generated. The external
9239 function carries the same name as the built-in version,
9240 with an additional suffix
9241 @samp{_@var{n}} where @var{n} is the size of the data type.
9242
9243 @c ??? Should we have a mechanism to suppress this warning? This is almost
9244 @c useful for implementing the operation under the control of an external
9245 @c mutex.
9246
9247 In most cases, these built-in functions are considered a @dfn{full barrier}.
9248 That is,
9249 no memory operand is moved across the operation, either forward or
9250 backward. Further, instructions are issued as necessary to prevent the
9251 processor from speculating loads across the operation and from queuing stores
9252 after the operation.
9253
9254 All of the routines are described in the Intel documentation to take
9255 ``an optional list of variables protected by the memory barrier''. It's
9256 not clear what is meant by that; it could mean that @emph{only} the
9257 listed variables are protected, or it could mean a list of additional
9258 variables to be protected. The list is ignored by GCC which treats it as
9259 empty. GCC interprets an empty list as meaning that all globally
9260 accessible variables should be protected.
9261
9262 @table @code
9263 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9264 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9265 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9266 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9267 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9268 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9269 @findex __sync_fetch_and_add
9270 @findex __sync_fetch_and_sub
9271 @findex __sync_fetch_and_or
9272 @findex __sync_fetch_and_and
9273 @findex __sync_fetch_and_xor
9274 @findex __sync_fetch_and_nand
9275 These built-in functions perform the operation suggested by the name, and
9276 returns the value that had previously been in memory. That is,
9277
9278 @smallexample
9279 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9280 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9281 @end smallexample
9282
9283 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9284 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9285
9286 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9287 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9288 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9289 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9290 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9291 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9292 @findex __sync_add_and_fetch
9293 @findex __sync_sub_and_fetch
9294 @findex __sync_or_and_fetch
9295 @findex __sync_and_and_fetch
9296 @findex __sync_xor_and_fetch
9297 @findex __sync_nand_and_fetch
9298 These built-in functions perform the operation suggested by the name, and
9299 return the new value. That is,
9300
9301 @smallexample
9302 @{ *ptr @var{op}= value; return *ptr; @}
9303 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9304 @end smallexample
9305
9306 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9307 as @code{*ptr = ~(*ptr & value)} instead of
9308 @code{*ptr = ~*ptr & value}.
9309
9310 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9311 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9312 @findex __sync_bool_compare_and_swap
9313 @findex __sync_val_compare_and_swap
9314 These built-in functions perform an atomic compare and swap.
9315 That is, if the current
9316 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9317 @code{*@var{ptr}}.
9318
9319 The ``bool'' version returns true if the comparison is successful and
9320 @var{newval} is written. The ``val'' version returns the contents
9321 of @code{*@var{ptr}} before the operation.
9322
9323 @item __sync_synchronize (...)
9324 @findex __sync_synchronize
9325 This built-in function issues a full memory barrier.
9326
9327 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9328 @findex __sync_lock_test_and_set
9329 This built-in function, as described by Intel, is not a traditional test-and-set
9330 operation, but rather an atomic exchange operation. It writes @var{value}
9331 into @code{*@var{ptr}}, and returns the previous contents of
9332 @code{*@var{ptr}}.
9333
9334 Many targets have only minimal support for such locks, and do not support
9335 a full exchange operation. In this case, a target may support reduced
9336 functionality here by which the @emph{only} valid value to store is the
9337 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9338 is implementation defined.
9339
9340 This built-in function is not a full barrier,
9341 but rather an @dfn{acquire barrier}.
9342 This means that references after the operation cannot move to (or be
9343 speculated to) before the operation, but previous memory stores may not
9344 be globally visible yet, and previous memory loads may not yet be
9345 satisfied.
9346
9347 @item void __sync_lock_release (@var{type} *ptr, ...)
9348 @findex __sync_lock_release
9349 This built-in function releases the lock acquired by
9350 @code{__sync_lock_test_and_set}.
9351 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9352
9353 This built-in function is not a full barrier,
9354 but rather a @dfn{release barrier}.
9355 This means that all previous memory stores are globally visible, and all
9356 previous memory loads have been satisfied, but following memory reads
9357 are not prevented from being speculated to before the barrier.
9358 @end table
9359
9360 @node __atomic Builtins
9361 @section Built-in Functions for Memory Model Aware Atomic Operations
9362
9363 The following built-in functions approximately match the requirements
9364 for the C++11 memory model. They are all
9365 identified by being prefixed with @samp{__atomic} and most are
9366 overloaded so that they work with multiple types.
9367
9368 These functions are intended to replace the legacy @samp{__sync}
9369 builtins. The main difference is that the memory order that is requested
9370 is a parameter to the functions. New code should always use the
9371 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9372
9373 Note that the @samp{__atomic} builtins assume that programs will
9374 conform to the C++11 memory model. In particular, they assume
9375 that programs are free of data races. See the C++11 standard for
9376 detailed requirements.
9377
9378 The @samp{__atomic} builtins can be used with any integral scalar or
9379 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9380 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9381 supported by the architecture.
9382
9383 The four non-arithmetic functions (load, store, exchange, and
9384 compare_exchange) all have a generic version as well. This generic
9385 version works on any data type. It uses the lock-free built-in function
9386 if the specific data type size makes that possible; otherwise, an
9387 external call is left to be resolved at run time. This external call is
9388 the same format with the addition of a @samp{size_t} parameter inserted
9389 as the first parameter indicating the size of the object being pointed to.
9390 All objects must be the same size.
9391
9392 There are 6 different memory orders that can be specified. These map
9393 to the C++11 memory orders with the same names, see the C++11 standard
9394 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9395 on atomic synchronization} for detailed definitions. Individual
9396 targets may also support additional memory orders for use on specific
9397 architectures. Refer to the target documentation for details of
9398 these.
9399
9400 An atomic operation can both constrain code motion and
9401 be mapped to hardware instructions for synchronization between threads
9402 (e.g., a fence). To which extent this happens is controlled by the
9403 memory orders, which are listed here in approximately ascending order of
9404 strength. The description of each memory order is only meant to roughly
9405 illustrate the effects and is not a specification; see the C++11
9406 memory model for precise semantics.
9407
9408 @table @code
9409 @item __ATOMIC_RELAXED
9410 Implies no inter-thread ordering constraints.
9411 @item __ATOMIC_CONSUME
9412 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9413 memory order because of a deficiency in C++11's semantics for
9414 @code{memory_order_consume}.
9415 @item __ATOMIC_ACQUIRE
9416 Creates an inter-thread happens-before constraint from the release (or
9417 stronger) semantic store to this acquire load. Can prevent hoisting
9418 of code to before the operation.
9419 @item __ATOMIC_RELEASE
9420 Creates an inter-thread happens-before constraint to acquire (or stronger)
9421 semantic loads that read from this release store. Can prevent sinking
9422 of code to after the operation.
9423 @item __ATOMIC_ACQ_REL
9424 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9425 @code{__ATOMIC_RELEASE}.
9426 @item __ATOMIC_SEQ_CST
9427 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9428 @end table
9429
9430 Note that in the C++11 memory model, @emph{fences} (e.g.,
9431 @samp{__atomic_thread_fence}) take effect in combination with other
9432 atomic operations on specific memory locations (e.g., atomic loads);
9433 operations on specific memory locations do not necessarily affect other
9434 operations in the same way.
9435
9436 Target architectures are encouraged to provide their own patterns for
9437 each of the atomic built-in functions. If no target is provided, the original
9438 non-memory model set of @samp{__sync} atomic built-in functions are
9439 used, along with any required synchronization fences surrounding it in
9440 order to achieve the proper behavior. Execution in this case is subject
9441 to the same restrictions as those built-in functions.
9442
9443 If there is no pattern or mechanism to provide a lock-free instruction
9444 sequence, a call is made to an external routine with the same parameters
9445 to be resolved at run time.
9446
9447 When implementing patterns for these built-in functions, the memory order
9448 parameter can be ignored as long as the pattern implements the most
9449 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9450 orders execute correctly with this memory order but they may not execute as
9451 efficiently as they could with a more appropriate implementation of the
9452 relaxed requirements.
9453
9454 Note that the C++11 standard allows for the memory order parameter to be
9455 determined at run time rather than at compile time. These built-in
9456 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9457 than invoke a runtime library call or inline a switch statement. This is
9458 standard compliant, safe, and the simplest approach for now.
9459
9460 The memory order parameter is a signed int, but only the lower 16 bits are
9461 reserved for the memory order. The remainder of the signed int is reserved
9462 for target use and should be 0. Use of the predefined atomic values
9463 ensures proper usage.
9464
9465 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9466 This built-in function implements an atomic load operation. It returns the
9467 contents of @code{*@var{ptr}}.
9468
9469 The valid memory order variants are
9470 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9471 and @code{__ATOMIC_CONSUME}.
9472
9473 @end deftypefn
9474
9475 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9476 This is the generic version of an atomic load. It returns the
9477 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9478
9479 @end deftypefn
9480
9481 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9482 This built-in function implements an atomic store operation. It writes
9483 @code{@var{val}} into @code{*@var{ptr}}.
9484
9485 The valid memory order variants are
9486 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9487
9488 @end deftypefn
9489
9490 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9491 This is the generic version of an atomic store. It stores the value
9492 of @code{*@var{val}} into @code{*@var{ptr}}.
9493
9494 @end deftypefn
9495
9496 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9497 This built-in function implements an atomic exchange operation. It writes
9498 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9499 @code{*@var{ptr}}.
9500
9501 The valid memory order variants are
9502 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9503 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9504
9505 @end deftypefn
9506
9507 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9508 This is the generic version of an atomic exchange. It stores the
9509 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9510 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9511
9512 @end deftypefn
9513
9514 @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)
9515 This built-in function implements an atomic compare and exchange operation.
9516 This compares the contents of @code{*@var{ptr}} with the contents of
9517 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9518 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9519 equal, the operation is a @emph{read} and the current contents of
9520 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
9521 for weak compare_exchange, and false for the strong variation. Many targets
9522 only offer the strong variation and ignore the parameter. When in doubt, use
9523 the strong variation.
9524
9525 True is returned if @var{desired} is written into
9526 @code{*@var{ptr}} and the operation is considered to conform to the
9527 memory order specified by @var{success_memorder}. There are no
9528 restrictions on what memory order can be used here.
9529
9530 False is returned otherwise, and the operation is considered to conform
9531 to @var{failure_memorder}. This memory order cannot be
9532 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9533 stronger order than that specified by @var{success_memorder}.
9534
9535 @end deftypefn
9536
9537 @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)
9538 This built-in function implements the generic version of
9539 @code{__atomic_compare_exchange}. The function is virtually identical to
9540 @code{__atomic_compare_exchange_n}, except the desired value is also a
9541 pointer.
9542
9543 @end deftypefn
9544
9545 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9546 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9547 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9548 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9549 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9550 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9551 These built-in functions perform the operation suggested by the name, and
9552 return the result of the operation. That is,
9553
9554 @smallexample
9555 @{ *ptr @var{op}= val; return *ptr; @}
9556 @end smallexample
9557
9558 All memory orders are valid.
9559
9560 @end deftypefn
9561
9562 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9563 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9564 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9565 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9566 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9567 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9568 These built-in functions perform the operation suggested by the name, and
9569 return the value that had previously been in @code{*@var{ptr}}. That is,
9570
9571 @smallexample
9572 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9573 @end smallexample
9574
9575 All memory orders are valid.
9576
9577 @end deftypefn
9578
9579 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9580
9581 This built-in function performs an atomic test-and-set operation on
9582 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9583 defined nonzero ``set'' value and the return value is @code{true} if and only
9584 if the previous contents were ``set''.
9585 It should be only used for operands of type @code{bool} or @code{char}. For
9586 other types only part of the value may be set.
9587
9588 All memory orders are valid.
9589
9590 @end deftypefn
9591
9592 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9593
9594 This built-in function performs an atomic clear operation on
9595 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9596 It should be only used for operands of type @code{bool} or @code{char} and
9597 in conjunction with @code{__atomic_test_and_set}.
9598 For other types it may only clear partially. If the type is not @code{bool}
9599 prefer using @code{__atomic_store}.
9600
9601 The valid memory order variants are
9602 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9603 @code{__ATOMIC_RELEASE}.
9604
9605 @end deftypefn
9606
9607 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9608
9609 This built-in function acts as a synchronization fence between threads
9610 based on the specified memory order.
9611
9612 All memory orders are valid.
9613
9614 @end deftypefn
9615
9616 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9617
9618 This built-in function acts as a synchronization fence between a thread
9619 and signal handlers based in the same thread.
9620
9621 All memory orders are valid.
9622
9623 @end deftypefn
9624
9625 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9626
9627 This built-in function returns true if objects of @var{size} bytes always
9628 generate lock-free atomic instructions for the target architecture.
9629 @var{size} must resolve to a compile-time constant and the result also
9630 resolves to a compile-time constant.
9631
9632 @var{ptr} is an optional pointer to the object that may be used to determine
9633 alignment. A value of 0 indicates typical alignment should be used. The
9634 compiler may also ignore this parameter.
9635
9636 @smallexample
9637 if (_atomic_always_lock_free (sizeof (long long), 0))
9638 @end smallexample
9639
9640 @end deftypefn
9641
9642 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9643
9644 This built-in function returns true if objects of @var{size} bytes always
9645 generate lock-free atomic instructions for the target architecture. If
9646 the built-in function is not known to be lock-free, a call is made to a
9647 runtime routine named @code{__atomic_is_lock_free}.
9648
9649 @var{ptr} is an optional pointer to the object that may be used to determine
9650 alignment. A value of 0 indicates typical alignment should be used. The
9651 compiler may also ignore this parameter.
9652 @end deftypefn
9653
9654 @node Integer Overflow Builtins
9655 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9656
9657 The following built-in functions allow performing simple arithmetic operations
9658 together with checking whether the operations overflowed.
9659
9660 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9661 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9662 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9663 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9664 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9665 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9666 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9667
9668 These built-in functions promote the first two operands into infinite precision signed
9669 type and perform addition on those promoted operands. The result is then
9670 cast to the type the third pointer argument points to and stored there.
9671 If the stored result is equal to the infinite precision result, the built-in
9672 functions return false, otherwise they return true. As the addition is
9673 performed in infinite signed precision, these built-in functions have fully defined
9674 behavior for all argument values.
9675
9676 The first built-in function allows arbitrary integral types for operands and
9677 the result type must be pointer to some integer type, the rest of the built-in
9678 functions have explicit integer types.
9679
9680 The compiler will attempt to use hardware instructions to implement
9681 these built-in functions where possible, like conditional jump on overflow
9682 after addition, conditional jump on carry etc.
9683
9684 @end deftypefn
9685
9686 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9687 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9688 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9689 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9690 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9691 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9692 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9693
9694 These built-in functions are similar to the add overflow checking built-in
9695 functions above, except they perform subtraction, subtract the second argument
9696 from the first one, instead of addition.
9697
9698 @end deftypefn
9699
9700 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9701 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9702 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9703 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9704 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9705 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9706 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9707
9708 These built-in functions are similar to the add overflow checking built-in
9709 functions above, except they perform multiplication, instead of addition.
9710
9711 @end deftypefn
9712
9713 @node x86 specific memory model extensions for transactional memory
9714 @section x86-Specific Memory Model Extensions for Transactional Memory
9715
9716 The x86 architecture supports additional memory ordering flags
9717 to mark lock critical sections for hardware lock elision.
9718 These must be specified in addition to an existing memory order to
9719 atomic intrinsics.
9720
9721 @table @code
9722 @item __ATOMIC_HLE_ACQUIRE
9723 Start lock elision on a lock variable.
9724 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9725 @item __ATOMIC_HLE_RELEASE
9726 End lock elision on a lock variable.
9727 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9728 @end table
9729
9730 When a lock acquire fails, it is required for good performance to abort
9731 the transaction quickly. This can be done with a @code{_mm_pause}.
9732
9733 @smallexample
9734 #include <immintrin.h> // For _mm_pause
9735
9736 int lockvar;
9737
9738 /* Acquire lock with lock elision */
9739 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9740 _mm_pause(); /* Abort failed transaction */
9741 ...
9742 /* Free lock with lock elision */
9743 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9744 @end smallexample
9745
9746 @node Object Size Checking
9747 @section Object Size Checking Built-in Functions
9748 @findex __builtin_object_size
9749 @findex __builtin___memcpy_chk
9750 @findex __builtin___mempcpy_chk
9751 @findex __builtin___memmove_chk
9752 @findex __builtin___memset_chk
9753 @findex __builtin___strcpy_chk
9754 @findex __builtin___stpcpy_chk
9755 @findex __builtin___strncpy_chk
9756 @findex __builtin___strcat_chk
9757 @findex __builtin___strncat_chk
9758 @findex __builtin___sprintf_chk
9759 @findex __builtin___snprintf_chk
9760 @findex __builtin___vsprintf_chk
9761 @findex __builtin___vsnprintf_chk
9762 @findex __builtin___printf_chk
9763 @findex __builtin___vprintf_chk
9764 @findex __builtin___fprintf_chk
9765 @findex __builtin___vfprintf_chk
9766
9767 GCC implements a limited buffer overflow protection mechanism
9768 that can prevent some buffer overflow attacks.
9769
9770 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9771 is a built-in construct that returns a constant number of bytes from
9772 @var{ptr} to the end of the object @var{ptr} pointer points to
9773 (if known at compile time). @code{__builtin_object_size} never evaluates
9774 its arguments for side-effects. If there are any side-effects in them, it
9775 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9776 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9777 point to and all of them are known at compile time, the returned number
9778 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9779 0 and minimum if nonzero. If it is not possible to determine which objects
9780 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9781 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9782 for @var{type} 2 or 3.
9783
9784 @var{type} is an integer constant from 0 to 3. If the least significant
9785 bit is clear, objects are whole variables, if it is set, a closest
9786 surrounding subobject is considered the object a pointer points to.
9787 The second bit determines if maximum or minimum of remaining bytes
9788 is computed.
9789
9790 @smallexample
9791 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9792 char *p = &var.buf1[1], *q = &var.b;
9793
9794 /* Here the object p points to is var. */
9795 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9796 /* The subobject p points to is var.buf1. */
9797 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9798 /* The object q points to is var. */
9799 assert (__builtin_object_size (q, 0)
9800 == (char *) (&var + 1) - (char *) &var.b);
9801 /* The subobject q points to is var.b. */
9802 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9803 @end smallexample
9804 @end deftypefn
9805
9806 There are built-in functions added for many common string operation
9807 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9808 built-in is provided. This built-in has an additional last argument,
9809 which is the number of bytes remaining in object the @var{dest}
9810 argument points to or @code{(size_t) -1} if the size is not known.
9811
9812 The built-in functions are optimized into the normal string functions
9813 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9814 it is known at compile time that the destination object will not
9815 be overflown. If the compiler can determine at compile time the
9816 object will be always overflown, it issues a warning.
9817
9818 The intended use can be e.g.@:
9819
9820 @smallexample
9821 #undef memcpy
9822 #define bos0(dest) __builtin_object_size (dest, 0)
9823 #define memcpy(dest, src, n) \
9824 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9825
9826 char *volatile p;
9827 char buf[10];
9828 /* It is unknown what object p points to, so this is optimized
9829 into plain memcpy - no checking is possible. */
9830 memcpy (p, "abcde", n);
9831 /* Destination is known and length too. It is known at compile
9832 time there will be no overflow. */
9833 memcpy (&buf[5], "abcde", 5);
9834 /* Destination is known, but the length is not known at compile time.
9835 This will result in __memcpy_chk call that can check for overflow
9836 at run time. */
9837 memcpy (&buf[5], "abcde", n);
9838 /* Destination is known and it is known at compile time there will
9839 be overflow. There will be a warning and __memcpy_chk call that
9840 will abort the program at run time. */
9841 memcpy (&buf[6], "abcde", 5);
9842 @end smallexample
9843
9844 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9845 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9846 @code{strcat} and @code{strncat}.
9847
9848 There are also checking built-in functions for formatted output functions.
9849 @smallexample
9850 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9851 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9852 const char *fmt, ...);
9853 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9854 va_list ap);
9855 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9856 const char *fmt, va_list ap);
9857 @end smallexample
9858
9859 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9860 etc.@: functions and can contain implementation specific flags on what
9861 additional security measures the checking function might take, such as
9862 handling @code{%n} differently.
9863
9864 The @var{os} argument is the object size @var{s} points to, like in the
9865 other built-in functions. There is a small difference in the behavior
9866 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9867 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9868 the checking function is called with @var{os} argument set to
9869 @code{(size_t) -1}.
9870
9871 In addition to this, there are checking built-in functions
9872 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9873 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9874 These have just one additional argument, @var{flag}, right before
9875 format string @var{fmt}. If the compiler is able to optimize them to
9876 @code{fputc} etc.@: functions, it does, otherwise the checking function
9877 is called and the @var{flag} argument passed to it.
9878
9879 @node Pointer Bounds Checker builtins
9880 @section Pointer Bounds Checker Built-in Functions
9881 @cindex Pointer Bounds Checker builtins
9882 @findex __builtin___bnd_set_ptr_bounds
9883 @findex __builtin___bnd_narrow_ptr_bounds
9884 @findex __builtin___bnd_copy_ptr_bounds
9885 @findex __builtin___bnd_init_ptr_bounds
9886 @findex __builtin___bnd_null_ptr_bounds
9887 @findex __builtin___bnd_store_ptr_bounds
9888 @findex __builtin___bnd_chk_ptr_lbounds
9889 @findex __builtin___bnd_chk_ptr_ubounds
9890 @findex __builtin___bnd_chk_ptr_bounds
9891 @findex __builtin___bnd_get_ptr_lbound
9892 @findex __builtin___bnd_get_ptr_ubound
9893
9894 GCC provides a set of built-in functions to control Pointer Bounds Checker
9895 instrumentation. Note that all Pointer Bounds Checker builtins can be used
9896 even if you compile with Pointer Bounds Checker off
9897 (@option{-fno-check-pointer-bounds}).
9898 The behavior may differ in such case as documented below.
9899
9900 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9901
9902 This built-in function returns a new pointer with the value of @var{q}, and
9903 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
9904 Bounds Checker off, the built-in function just returns the first argument.
9905
9906 @smallexample
9907 extern void *__wrap_malloc (size_t n)
9908 @{
9909 void *p = (void *)__real_malloc (n);
9910 if (!p) return __builtin___bnd_null_ptr_bounds (p);
9911 return __builtin___bnd_set_ptr_bounds (p, n);
9912 @}
9913 @end smallexample
9914
9915 @end deftypefn
9916
9917 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
9918
9919 This built-in function returns a new pointer with the value of @var{p}
9920 and associates it with the narrowed bounds formed by the intersection
9921 of bounds associated with @var{q} and the bounds
9922 [@var{p}, @var{p} + @var{size} - 1].
9923 With Pointer Bounds Checker off, the built-in function just returns the first
9924 argument.
9925
9926 @smallexample
9927 void init_objects (object *objs, size_t size)
9928 @{
9929 size_t i;
9930 /* Initialize objects one-by-one passing pointers with bounds of
9931 an object, not the full array of objects. */
9932 for (i = 0; i < size; i++)
9933 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9934 sizeof(object)));
9935 @}
9936 @end smallexample
9937
9938 @end deftypefn
9939
9940 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9941
9942 This built-in function returns a new pointer with the value of @var{q},
9943 and associates it with the bounds already associated with pointer @var{r}.
9944 With Pointer Bounds Checker off, the built-in function just returns the first
9945 argument.
9946
9947 @smallexample
9948 /* Here is a way to get pointer to object's field but
9949 still with the full object's bounds. */
9950 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
9951 objptr);
9952 @end smallexample
9953
9954 @end deftypefn
9955
9956 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
9957
9958 This built-in function returns a new pointer with the value of @var{q}, and
9959 associates it with INIT (allowing full memory access) bounds. With Pointer
9960 Bounds Checker off, the built-in function just returns the first argument.
9961
9962 @end deftypefn
9963
9964 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
9965
9966 This built-in function returns a new pointer with the value of @var{q}, and
9967 associates it with NULL (allowing no memory access) bounds. With Pointer
9968 Bounds Checker off, the built-in function just returns the first argument.
9969
9970 @end deftypefn
9971
9972 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
9973
9974 This built-in function stores the bounds associated with pointer @var{ptr_val}
9975 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
9976 bounds from legacy code without touching the associated pointer's memory when
9977 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
9978 function call is ignored.
9979
9980 @end deftypefn
9981
9982 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
9983
9984 This built-in function checks if the pointer @var{q} is within the lower
9985 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
9986 function call is ignored.
9987
9988 @smallexample
9989 extern void *__wrap_memset (void *dst, int c, size_t len)
9990 @{
9991 if (len > 0)
9992 @{
9993 __builtin___bnd_chk_ptr_lbounds (dst);
9994 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
9995 __real_memset (dst, c, len);
9996 @}
9997 return dst;
9998 @}
9999 @end smallexample
10000
10001 @end deftypefn
10002
10003 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10004
10005 This built-in function checks if the pointer @var{q} is within the upper
10006 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10007 function call is ignored.
10008
10009 @end deftypefn
10010
10011 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10012
10013 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10014 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10015 off, the built-in function call is ignored.
10016
10017 @smallexample
10018 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10019 @{
10020 if (n > 0)
10021 @{
10022 __bnd_chk_ptr_bounds (dst, n);
10023 __bnd_chk_ptr_bounds (src, n);
10024 __real_memcpy (dst, src, n);
10025 @}
10026 return dst;
10027 @}
10028 @end smallexample
10029
10030 @end deftypefn
10031
10032 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10033
10034 This built-in function returns the lower bound associated
10035 with the pointer @var{q}, as a pointer value.
10036 This is useful for debugging using @code{printf}.
10037 With Pointer Bounds Checker off, the built-in function returns 0.
10038
10039 @smallexample
10040 void *lb = __builtin___bnd_get_ptr_lbound (q);
10041 void *ub = __builtin___bnd_get_ptr_ubound (q);
10042 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10043 @end smallexample
10044
10045 @end deftypefn
10046
10047 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10048
10049 This built-in function returns the upper bound (which is a pointer) associated
10050 with the pointer @var{q}. With Pointer Bounds Checker off,
10051 the built-in function returns -1.
10052
10053 @end deftypefn
10054
10055 @node Cilk Plus Builtins
10056 @section Cilk Plus C/C++ Language Extension Built-in Functions
10057
10058 GCC provides support for the following built-in reduction functions if Cilk Plus
10059 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10060
10061 @itemize @bullet
10062 @item @code{__sec_implicit_index}
10063 @item @code{__sec_reduce}
10064 @item @code{__sec_reduce_add}
10065 @item @code{__sec_reduce_all_nonzero}
10066 @item @code{__sec_reduce_all_zero}
10067 @item @code{__sec_reduce_any_nonzero}
10068 @item @code{__sec_reduce_any_zero}
10069 @item @code{__sec_reduce_max}
10070 @item @code{__sec_reduce_min}
10071 @item @code{__sec_reduce_max_ind}
10072 @item @code{__sec_reduce_min_ind}
10073 @item @code{__sec_reduce_mul}
10074 @item @code{__sec_reduce_mutating}
10075 @end itemize
10076
10077 Further details and examples about these built-in functions are described
10078 in the Cilk Plus language manual which can be found at
10079 @uref{http://www.cilkplus.org}.
10080
10081 @node Other Builtins
10082 @section Other Built-in Functions Provided by GCC
10083 @cindex built-in functions
10084 @findex __builtin_call_with_static_chain
10085 @findex __builtin_fpclassify
10086 @findex __builtin_isfinite
10087 @findex __builtin_isnormal
10088 @findex __builtin_isgreater
10089 @findex __builtin_isgreaterequal
10090 @findex __builtin_isinf_sign
10091 @findex __builtin_isless
10092 @findex __builtin_islessequal
10093 @findex __builtin_islessgreater
10094 @findex __builtin_isunordered
10095 @findex __builtin_powi
10096 @findex __builtin_powif
10097 @findex __builtin_powil
10098 @findex _Exit
10099 @findex _exit
10100 @findex abort
10101 @findex abs
10102 @findex acos
10103 @findex acosf
10104 @findex acosh
10105 @findex acoshf
10106 @findex acoshl
10107 @findex acosl
10108 @findex alloca
10109 @findex asin
10110 @findex asinf
10111 @findex asinh
10112 @findex asinhf
10113 @findex asinhl
10114 @findex asinl
10115 @findex atan
10116 @findex atan2
10117 @findex atan2f
10118 @findex atan2l
10119 @findex atanf
10120 @findex atanh
10121 @findex atanhf
10122 @findex atanhl
10123 @findex atanl
10124 @findex bcmp
10125 @findex bzero
10126 @findex cabs
10127 @findex cabsf
10128 @findex cabsl
10129 @findex cacos
10130 @findex cacosf
10131 @findex cacosh
10132 @findex cacoshf
10133 @findex cacoshl
10134 @findex cacosl
10135 @findex calloc
10136 @findex carg
10137 @findex cargf
10138 @findex cargl
10139 @findex casin
10140 @findex casinf
10141 @findex casinh
10142 @findex casinhf
10143 @findex casinhl
10144 @findex casinl
10145 @findex catan
10146 @findex catanf
10147 @findex catanh
10148 @findex catanhf
10149 @findex catanhl
10150 @findex catanl
10151 @findex cbrt
10152 @findex cbrtf
10153 @findex cbrtl
10154 @findex ccos
10155 @findex ccosf
10156 @findex ccosh
10157 @findex ccoshf
10158 @findex ccoshl
10159 @findex ccosl
10160 @findex ceil
10161 @findex ceilf
10162 @findex ceill
10163 @findex cexp
10164 @findex cexpf
10165 @findex cexpl
10166 @findex cimag
10167 @findex cimagf
10168 @findex cimagl
10169 @findex clog
10170 @findex clogf
10171 @findex clogl
10172 @findex conj
10173 @findex conjf
10174 @findex conjl
10175 @findex copysign
10176 @findex copysignf
10177 @findex copysignl
10178 @findex cos
10179 @findex cosf
10180 @findex cosh
10181 @findex coshf
10182 @findex coshl
10183 @findex cosl
10184 @findex cpow
10185 @findex cpowf
10186 @findex cpowl
10187 @findex cproj
10188 @findex cprojf
10189 @findex cprojl
10190 @findex creal
10191 @findex crealf
10192 @findex creall
10193 @findex csin
10194 @findex csinf
10195 @findex csinh
10196 @findex csinhf
10197 @findex csinhl
10198 @findex csinl
10199 @findex csqrt
10200 @findex csqrtf
10201 @findex csqrtl
10202 @findex ctan
10203 @findex ctanf
10204 @findex ctanh
10205 @findex ctanhf
10206 @findex ctanhl
10207 @findex ctanl
10208 @findex dcgettext
10209 @findex dgettext
10210 @findex drem
10211 @findex dremf
10212 @findex dreml
10213 @findex erf
10214 @findex erfc
10215 @findex erfcf
10216 @findex erfcl
10217 @findex erff
10218 @findex erfl
10219 @findex exit
10220 @findex exp
10221 @findex exp10
10222 @findex exp10f
10223 @findex exp10l
10224 @findex exp2
10225 @findex exp2f
10226 @findex exp2l
10227 @findex expf
10228 @findex expl
10229 @findex expm1
10230 @findex expm1f
10231 @findex expm1l
10232 @findex fabs
10233 @findex fabsf
10234 @findex fabsl
10235 @findex fdim
10236 @findex fdimf
10237 @findex fdiml
10238 @findex ffs
10239 @findex floor
10240 @findex floorf
10241 @findex floorl
10242 @findex fma
10243 @findex fmaf
10244 @findex fmal
10245 @findex fmax
10246 @findex fmaxf
10247 @findex fmaxl
10248 @findex fmin
10249 @findex fminf
10250 @findex fminl
10251 @findex fmod
10252 @findex fmodf
10253 @findex fmodl
10254 @findex fprintf
10255 @findex fprintf_unlocked
10256 @findex fputs
10257 @findex fputs_unlocked
10258 @findex frexp
10259 @findex frexpf
10260 @findex frexpl
10261 @findex fscanf
10262 @findex gamma
10263 @findex gammaf
10264 @findex gammal
10265 @findex gamma_r
10266 @findex gammaf_r
10267 @findex gammal_r
10268 @findex gettext
10269 @findex hypot
10270 @findex hypotf
10271 @findex hypotl
10272 @findex ilogb
10273 @findex ilogbf
10274 @findex ilogbl
10275 @findex imaxabs
10276 @findex index
10277 @findex isalnum
10278 @findex isalpha
10279 @findex isascii
10280 @findex isblank
10281 @findex iscntrl
10282 @findex isdigit
10283 @findex isgraph
10284 @findex islower
10285 @findex isprint
10286 @findex ispunct
10287 @findex isspace
10288 @findex isupper
10289 @findex iswalnum
10290 @findex iswalpha
10291 @findex iswblank
10292 @findex iswcntrl
10293 @findex iswdigit
10294 @findex iswgraph
10295 @findex iswlower
10296 @findex iswprint
10297 @findex iswpunct
10298 @findex iswspace
10299 @findex iswupper
10300 @findex iswxdigit
10301 @findex isxdigit
10302 @findex j0
10303 @findex j0f
10304 @findex j0l
10305 @findex j1
10306 @findex j1f
10307 @findex j1l
10308 @findex jn
10309 @findex jnf
10310 @findex jnl
10311 @findex labs
10312 @findex ldexp
10313 @findex ldexpf
10314 @findex ldexpl
10315 @findex lgamma
10316 @findex lgammaf
10317 @findex lgammal
10318 @findex lgamma_r
10319 @findex lgammaf_r
10320 @findex lgammal_r
10321 @findex llabs
10322 @findex llrint
10323 @findex llrintf
10324 @findex llrintl
10325 @findex llround
10326 @findex llroundf
10327 @findex llroundl
10328 @findex log
10329 @findex log10
10330 @findex log10f
10331 @findex log10l
10332 @findex log1p
10333 @findex log1pf
10334 @findex log1pl
10335 @findex log2
10336 @findex log2f
10337 @findex log2l
10338 @findex logb
10339 @findex logbf
10340 @findex logbl
10341 @findex logf
10342 @findex logl
10343 @findex lrint
10344 @findex lrintf
10345 @findex lrintl
10346 @findex lround
10347 @findex lroundf
10348 @findex lroundl
10349 @findex malloc
10350 @findex memchr
10351 @findex memcmp
10352 @findex memcpy
10353 @findex mempcpy
10354 @findex memset
10355 @findex modf
10356 @findex modff
10357 @findex modfl
10358 @findex nearbyint
10359 @findex nearbyintf
10360 @findex nearbyintl
10361 @findex nextafter
10362 @findex nextafterf
10363 @findex nextafterl
10364 @findex nexttoward
10365 @findex nexttowardf
10366 @findex nexttowardl
10367 @findex pow
10368 @findex pow10
10369 @findex pow10f
10370 @findex pow10l
10371 @findex powf
10372 @findex powl
10373 @findex printf
10374 @findex printf_unlocked
10375 @findex putchar
10376 @findex puts
10377 @findex remainder
10378 @findex remainderf
10379 @findex remainderl
10380 @findex remquo
10381 @findex remquof
10382 @findex remquol
10383 @findex rindex
10384 @findex rint
10385 @findex rintf
10386 @findex rintl
10387 @findex round
10388 @findex roundf
10389 @findex roundl
10390 @findex scalb
10391 @findex scalbf
10392 @findex scalbl
10393 @findex scalbln
10394 @findex scalblnf
10395 @findex scalblnf
10396 @findex scalbn
10397 @findex scalbnf
10398 @findex scanfnl
10399 @findex signbit
10400 @findex signbitf
10401 @findex signbitl
10402 @findex signbitd32
10403 @findex signbitd64
10404 @findex signbitd128
10405 @findex significand
10406 @findex significandf
10407 @findex significandl
10408 @findex sin
10409 @findex sincos
10410 @findex sincosf
10411 @findex sincosl
10412 @findex sinf
10413 @findex sinh
10414 @findex sinhf
10415 @findex sinhl
10416 @findex sinl
10417 @findex snprintf
10418 @findex sprintf
10419 @findex sqrt
10420 @findex sqrtf
10421 @findex sqrtl
10422 @findex sscanf
10423 @findex stpcpy
10424 @findex stpncpy
10425 @findex strcasecmp
10426 @findex strcat
10427 @findex strchr
10428 @findex strcmp
10429 @findex strcpy
10430 @findex strcspn
10431 @findex strdup
10432 @findex strfmon
10433 @findex strftime
10434 @findex strlen
10435 @findex strncasecmp
10436 @findex strncat
10437 @findex strncmp
10438 @findex strncpy
10439 @findex strndup
10440 @findex strpbrk
10441 @findex strrchr
10442 @findex strspn
10443 @findex strstr
10444 @findex tan
10445 @findex tanf
10446 @findex tanh
10447 @findex tanhf
10448 @findex tanhl
10449 @findex tanl
10450 @findex tgamma
10451 @findex tgammaf
10452 @findex tgammal
10453 @findex toascii
10454 @findex tolower
10455 @findex toupper
10456 @findex towlower
10457 @findex towupper
10458 @findex trunc
10459 @findex truncf
10460 @findex truncl
10461 @findex vfprintf
10462 @findex vfscanf
10463 @findex vprintf
10464 @findex vscanf
10465 @findex vsnprintf
10466 @findex vsprintf
10467 @findex vsscanf
10468 @findex y0
10469 @findex y0f
10470 @findex y0l
10471 @findex y1
10472 @findex y1f
10473 @findex y1l
10474 @findex yn
10475 @findex ynf
10476 @findex ynl
10477
10478 GCC provides a large number of built-in functions other than the ones
10479 mentioned above. Some of these are for internal use in the processing
10480 of exceptions or variable-length argument lists and are not
10481 documented here because they may change from time to time; we do not
10482 recommend general use of these functions.
10483
10484 The remaining functions are provided for optimization purposes.
10485
10486 With the exception of built-ins that have library equivalents such as
10487 the standard C library functions discussed below, or that expand to
10488 library calls, GCC built-in functions are always expanded inline and
10489 thus do not have corresponding entry points and their address cannot
10490 be obtained. Attempting to use them in an expression other than
10491 a function call results in a compile-time error.
10492
10493 @opindex fno-builtin
10494 GCC includes built-in versions of many of the functions in the standard
10495 C library. These functions come in two forms: one whose names start with
10496 the @code{__builtin_} prefix, and the other without. Both forms have the
10497 same type (including prototype), the same address (when their address is
10498 taken), and the same meaning as the C library functions even if you specify
10499 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10500 functions are only optimized in certain cases; if they are not optimized in
10501 a particular case, a call to the library function is emitted.
10502
10503 @opindex ansi
10504 @opindex std
10505 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10506 @option{-std=c99} or @option{-std=c11}), the functions
10507 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10508 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10509 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10510 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10511 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10512 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10513 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10514 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10515 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10516 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10517 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10518 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10519 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10520 @code{significandl}, @code{significand}, @code{sincosf},
10521 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10522 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10523 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10524 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10525 @code{yn}
10526 may be handled as built-in functions.
10527 All these functions have corresponding versions
10528 prefixed with @code{__builtin_}, which may be used even in strict C90
10529 mode.
10530
10531 The ISO C99 functions
10532 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10533 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10534 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10535 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10536 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10537 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10538 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10539 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10540 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10541 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10542 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10543 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10544 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10545 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10546 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10547 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10548 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10549 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10550 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10551 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10552 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10553 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10554 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10555 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10556 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10557 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10558 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10559 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10560 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10561 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10562 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10563 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10564 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10565 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10566 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10567 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10568 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10569 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10570 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10571 are handled as built-in functions
10572 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10573
10574 There are also built-in versions of the ISO C99 functions
10575 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10576 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10577 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10578 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10579 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10580 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10581 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10582 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10583 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10584 that are recognized in any mode since ISO C90 reserves these names for
10585 the purpose to which ISO C99 puts them. All these functions have
10586 corresponding versions prefixed with @code{__builtin_}.
10587
10588 The ISO C94 functions
10589 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10590 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10591 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10592 @code{towupper}
10593 are handled as built-in functions
10594 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10595
10596 The ISO C90 functions
10597 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10598 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10599 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10600 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10601 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10602 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10603 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10604 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10605 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10606 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10607 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10608 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10609 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10610 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10611 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10612 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10613 are all recognized as built-in functions unless
10614 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10615 is specified for an individual function). All of these functions have
10616 corresponding versions prefixed with @code{__builtin_}.
10617
10618 GCC provides built-in versions of the ISO C99 floating-point comparison
10619 macros that avoid raising exceptions for unordered operands. They have
10620 the same names as the standard macros ( @code{isgreater},
10621 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10622 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10623 prefixed. We intend for a library implementor to be able to simply
10624 @code{#define} each standard macro to its built-in equivalent.
10625 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10626 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10627 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10628 built-in functions appear both with and without the @code{__builtin_} prefix.
10629
10630 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10631
10632 You can use the built-in function @code{__builtin_types_compatible_p} to
10633 determine whether two types are the same.
10634
10635 This built-in function returns 1 if the unqualified versions of the
10636 types @var{type1} and @var{type2} (which are types, not expressions) are
10637 compatible, 0 otherwise. The result of this built-in function can be
10638 used in integer constant expressions.
10639
10640 This built-in function ignores top level qualifiers (e.g., @code{const},
10641 @code{volatile}). For example, @code{int} is equivalent to @code{const
10642 int}.
10643
10644 The type @code{int[]} and @code{int[5]} are compatible. On the other
10645 hand, @code{int} and @code{char *} are not compatible, even if the size
10646 of their types, on the particular architecture are the same. Also, the
10647 amount of pointer indirection is taken into account when determining
10648 similarity. Consequently, @code{short *} is not similar to
10649 @code{short **}. Furthermore, two types that are typedefed are
10650 considered compatible if their underlying types are compatible.
10651
10652 An @code{enum} type is not considered to be compatible with another
10653 @code{enum} type even if both are compatible with the same integer
10654 type; this is what the C standard specifies.
10655 For example, @code{enum @{foo, bar@}} is not similar to
10656 @code{enum @{hot, dog@}}.
10657
10658 You typically use this function in code whose execution varies
10659 depending on the arguments' types. For example:
10660
10661 @smallexample
10662 #define foo(x) \
10663 (@{ \
10664 typeof (x) tmp = (x); \
10665 if (__builtin_types_compatible_p (typeof (x), long double)) \
10666 tmp = foo_long_double (tmp); \
10667 else if (__builtin_types_compatible_p (typeof (x), double)) \
10668 tmp = foo_double (tmp); \
10669 else if (__builtin_types_compatible_p (typeof (x), float)) \
10670 tmp = foo_float (tmp); \
10671 else \
10672 abort (); \
10673 tmp; \
10674 @})
10675 @end smallexample
10676
10677 @emph{Note:} This construct is only available for C@.
10678
10679 @end deftypefn
10680
10681 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10682
10683 The @var{call_exp} expression must be a function call, and the
10684 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10685 is passed to the function call in the target's static chain location.
10686 The result of builtin is the result of the function call.
10687
10688 @emph{Note:} This builtin is only available for C@.
10689 This builtin can be used to call Go closures from C.
10690
10691 @end deftypefn
10692
10693 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10694
10695 You can use the built-in function @code{__builtin_choose_expr} to
10696 evaluate code depending on the value of a constant expression. This
10697 built-in function returns @var{exp1} if @var{const_exp}, which is an
10698 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10699
10700 This built-in function is analogous to the @samp{? :} operator in C,
10701 except that the expression returned has its type unaltered by promotion
10702 rules. Also, the built-in function does not evaluate the expression
10703 that is not chosen. For example, if @var{const_exp} evaluates to true,
10704 @var{exp2} is not evaluated even if it has side-effects.
10705
10706 This built-in function can return an lvalue if the chosen argument is an
10707 lvalue.
10708
10709 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10710 type. Similarly, if @var{exp2} is returned, its return type is the same
10711 as @var{exp2}.
10712
10713 Example:
10714
10715 @smallexample
10716 #define foo(x) \
10717 __builtin_choose_expr ( \
10718 __builtin_types_compatible_p (typeof (x), double), \
10719 foo_double (x), \
10720 __builtin_choose_expr ( \
10721 __builtin_types_compatible_p (typeof (x), float), \
10722 foo_float (x), \
10723 /* @r{The void expression results in a compile-time error} \
10724 @r{when assigning the result to something.} */ \
10725 (void)0))
10726 @end smallexample
10727
10728 @emph{Note:} This construct is only available for C@. Furthermore, the
10729 unused expression (@var{exp1} or @var{exp2} depending on the value of
10730 @var{const_exp}) may still generate syntax errors. This may change in
10731 future revisions.
10732
10733 @end deftypefn
10734
10735 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10736
10737 The built-in function @code{__builtin_complex} is provided for use in
10738 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10739 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10740 real binary floating-point type, and the result has the corresponding
10741 complex type with real and imaginary parts @var{real} and @var{imag}.
10742 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10743 infinities, NaNs and negative zeros are involved.
10744
10745 @end deftypefn
10746
10747 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10748 You can use the built-in function @code{__builtin_constant_p} to
10749 determine if a value is known to be constant at compile time and hence
10750 that GCC can perform constant-folding on expressions involving that
10751 value. The argument of the function is the value to test. The function
10752 returns the integer 1 if the argument is known to be a compile-time
10753 constant and 0 if it is not known to be a compile-time constant. A
10754 return of 0 does not indicate that the value is @emph{not} a constant,
10755 but merely that GCC cannot prove it is a constant with the specified
10756 value of the @option{-O} option.
10757
10758 You typically use this function in an embedded application where
10759 memory is a critical resource. If you have some complex calculation,
10760 you may want it to be folded if it involves constants, but need to call
10761 a function if it does not. For example:
10762
10763 @smallexample
10764 #define Scale_Value(X) \
10765 (__builtin_constant_p (X) \
10766 ? ((X) * SCALE + OFFSET) : Scale (X))
10767 @end smallexample
10768
10769 You may use this built-in function in either a macro or an inline
10770 function. However, if you use it in an inlined function and pass an
10771 argument of the function as the argument to the built-in, GCC
10772 never returns 1 when you call the inline function with a string constant
10773 or compound literal (@pxref{Compound Literals}) and does not return 1
10774 when you pass a constant numeric value to the inline function unless you
10775 specify the @option{-O} option.
10776
10777 You may also use @code{__builtin_constant_p} in initializers for static
10778 data. For instance, you can write
10779
10780 @smallexample
10781 static const int table[] = @{
10782 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10783 /* @r{@dots{}} */
10784 @};
10785 @end smallexample
10786
10787 @noindent
10788 This is an acceptable initializer even if @var{EXPRESSION} is not a
10789 constant expression, including the case where
10790 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10791 folded to a constant but @var{EXPRESSION} contains operands that are
10792 not otherwise permitted in a static initializer (for example,
10793 @code{0 && foo ()}). GCC must be more conservative about evaluating the
10794 built-in in this case, because it has no opportunity to perform
10795 optimization.
10796 @end deftypefn
10797
10798 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10799 @opindex fprofile-arcs
10800 You may use @code{__builtin_expect} to provide the compiler with
10801 branch prediction information. In general, you should prefer to
10802 use actual profile feedback for this (@option{-fprofile-arcs}), as
10803 programmers are notoriously bad at predicting how their programs
10804 actually perform. However, there are applications in which this
10805 data is hard to collect.
10806
10807 The return value is the value of @var{exp}, which should be an integral
10808 expression. The semantics of the built-in are that it is expected that
10809 @var{exp} == @var{c}. For example:
10810
10811 @smallexample
10812 if (__builtin_expect (x, 0))
10813 foo ();
10814 @end smallexample
10815
10816 @noindent
10817 indicates that we do not expect to call @code{foo}, since
10818 we expect @code{x} to be zero. Since you are limited to integral
10819 expressions for @var{exp}, you should use constructions such as
10820
10821 @smallexample
10822 if (__builtin_expect (ptr != NULL, 1))
10823 foo (*ptr);
10824 @end smallexample
10825
10826 @noindent
10827 when testing pointer or floating-point values.
10828 @end deftypefn
10829
10830 @deftypefn {Built-in Function} void __builtin_trap (void)
10831 This function causes the program to exit abnormally. GCC implements
10832 this function by using a target-dependent mechanism (such as
10833 intentionally executing an illegal instruction) or by calling
10834 @code{abort}. The mechanism used may vary from release to release so
10835 you should not rely on any particular implementation.
10836 @end deftypefn
10837
10838 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10839 If control flow reaches the point of the @code{__builtin_unreachable},
10840 the program is undefined. It is useful in situations where the
10841 compiler cannot deduce the unreachability of the code.
10842
10843 One such case is immediately following an @code{asm} statement that
10844 either never terminates, or one that transfers control elsewhere
10845 and never returns. In this example, without the
10846 @code{__builtin_unreachable}, GCC issues a warning that control
10847 reaches the end of a non-void function. It also generates code
10848 to return after the @code{asm}.
10849
10850 @smallexample
10851 int f (int c, int v)
10852 @{
10853 if (c)
10854 @{
10855 return v;
10856 @}
10857 else
10858 @{
10859 asm("jmp error_handler");
10860 __builtin_unreachable ();
10861 @}
10862 @}
10863 @end smallexample
10864
10865 @noindent
10866 Because the @code{asm} statement unconditionally transfers control out
10867 of the function, control never reaches the end of the function
10868 body. The @code{__builtin_unreachable} is in fact unreachable and
10869 communicates this fact to the compiler.
10870
10871 Another use for @code{__builtin_unreachable} is following a call a
10872 function that never returns but that is not declared
10873 @code{__attribute__((noreturn))}, as in this example:
10874
10875 @smallexample
10876 void function_that_never_returns (void);
10877
10878 int g (int c)
10879 @{
10880 if (c)
10881 @{
10882 return 1;
10883 @}
10884 else
10885 @{
10886 function_that_never_returns ();
10887 __builtin_unreachable ();
10888 @}
10889 @}
10890 @end smallexample
10891
10892 @end deftypefn
10893
10894 @deftypefn {Built-in Function} void *__builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10895 This function returns its first argument, and allows the compiler
10896 to assume that the returned pointer is at least @var{align} bytes
10897 aligned. This built-in can have either two or three arguments,
10898 if it has three, the third argument should have integer type, and
10899 if it is nonzero means misalignment offset. For example:
10900
10901 @smallexample
10902 void *x = __builtin_assume_aligned (arg, 16);
10903 @end smallexample
10904
10905 @noindent
10906 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10907 16-byte aligned, while:
10908
10909 @smallexample
10910 void *x = __builtin_assume_aligned (arg, 32, 8);
10911 @end smallexample
10912
10913 @noindent
10914 means that the compiler can assume for @code{x}, set to @code{arg}, that
10915 @code{(char *) x - 8} is 32-byte aligned.
10916 @end deftypefn
10917
10918 @deftypefn {Built-in Function} int __builtin_LINE ()
10919 This function is the equivalent to the preprocessor @code{__LINE__}
10920 macro and returns the line number of the invocation of the built-in.
10921 In a C++ default argument for a function @var{F}, it gets the line number of
10922 the call to @var{F}.
10923 @end deftypefn
10924
10925 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10926 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10927 macro and returns the function name the invocation of the built-in is in.
10928 @end deftypefn
10929
10930 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10931 This function is the equivalent to the preprocessor @code{__FILE__}
10932 macro and returns the file name the invocation of the built-in is in.
10933 In a C++ default argument for a function @var{F}, it gets the file name of
10934 the call to @var{F}.
10935 @end deftypefn
10936
10937 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10938 This function is used to flush the processor's instruction cache for
10939 the region of memory between @var{begin} inclusive and @var{end}
10940 exclusive. Some targets require that the instruction cache be
10941 flushed, after modifying memory containing code, in order to obtain
10942 deterministic behavior.
10943
10944 If the target does not require instruction cache flushes,
10945 @code{__builtin___clear_cache} has no effect. Otherwise either
10946 instructions are emitted in-line to clear the instruction cache or a
10947 call to the @code{__clear_cache} function in libgcc is made.
10948 @end deftypefn
10949
10950 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10951 This function is used to minimize cache-miss latency by moving data into
10952 a cache before it is accessed.
10953 You can insert calls to @code{__builtin_prefetch} into code for which
10954 you know addresses of data in memory that is likely to be accessed soon.
10955 If the target supports them, data prefetch instructions are generated.
10956 If the prefetch is done early enough before the access then the data will
10957 be in the cache by the time it is accessed.
10958
10959 The value of @var{addr} is the address of the memory to prefetch.
10960 There are two optional arguments, @var{rw} and @var{locality}.
10961 The value of @var{rw} is a compile-time constant one or zero; one
10962 means that the prefetch is preparing for a write to the memory address
10963 and zero, the default, means that the prefetch is preparing for a read.
10964 The value @var{locality} must be a compile-time constant integer between
10965 zero and three. A value of zero means that the data has no temporal
10966 locality, so it need not be left in the cache after the access. A value
10967 of three means that the data has a high degree of temporal locality and
10968 should be left in all levels of cache possible. Values of one and two
10969 mean, respectively, a low or moderate degree of temporal locality. The
10970 default is three.
10971
10972 @smallexample
10973 for (i = 0; i < n; i++)
10974 @{
10975 a[i] = a[i] + b[i];
10976 __builtin_prefetch (&a[i+j], 1, 1);
10977 __builtin_prefetch (&b[i+j], 0, 1);
10978 /* @r{@dots{}} */
10979 @}
10980 @end smallexample
10981
10982 Data prefetch does not generate faults if @var{addr} is invalid, but
10983 the address expression itself must be valid. For example, a prefetch
10984 of @code{p->next} does not fault if @code{p->next} is not a valid
10985 address, but evaluation faults if @code{p} is not a valid address.
10986
10987 If the target does not support data prefetch, the address expression
10988 is evaluated if it includes side effects but no other code is generated
10989 and GCC does not issue a warning.
10990 @end deftypefn
10991
10992 @deftypefn {Built-in Function} double __builtin_huge_val (void)
10993 Returns a positive infinity, if supported by the floating-point format,
10994 else @code{DBL_MAX}. This function is suitable for implementing the
10995 ISO C macro @code{HUGE_VAL}.
10996 @end deftypefn
10997
10998 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
10999 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11000 @end deftypefn
11001
11002 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11003 Similar to @code{__builtin_huge_val}, except the return
11004 type is @code{long double}.
11005 @end deftypefn
11006
11007 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11008 This built-in implements the C99 fpclassify functionality. The first
11009 five int arguments should be the target library's notion of the
11010 possible FP classes and are used for return values. They must be
11011 constant values and they must appear in this order: @code{FP_NAN},
11012 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11013 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11014 to classify. GCC treats the last argument as type-generic, which
11015 means it does not do default promotion from float to double.
11016 @end deftypefn
11017
11018 @deftypefn {Built-in Function} double __builtin_inf (void)
11019 Similar to @code{__builtin_huge_val}, except a warning is generated
11020 if the target floating-point format does not support infinities.
11021 @end deftypefn
11022
11023 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11024 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11025 @end deftypefn
11026
11027 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11028 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11029 @end deftypefn
11030
11031 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11032 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11033 @end deftypefn
11034
11035 @deftypefn {Built-in Function} float __builtin_inff (void)
11036 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11037 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11038 @end deftypefn
11039
11040 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11041 Similar to @code{__builtin_inf}, except the return
11042 type is @code{long double}.
11043 @end deftypefn
11044
11045 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11046 Similar to @code{isinf}, except the return value is -1 for
11047 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11048 Note while the parameter list is an
11049 ellipsis, this function only accepts exactly one floating-point
11050 argument. GCC treats this parameter as type-generic, which means it
11051 does not do default promotion from float to double.
11052 @end deftypefn
11053
11054 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11055 This is an implementation of the ISO C99 function @code{nan}.
11056
11057 Since ISO C99 defines this function in terms of @code{strtod}, which we
11058 do not implement, a description of the parsing is in order. The string
11059 is parsed as by @code{strtol}; that is, the base is recognized by
11060 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11061 in the significand such that the least significant bit of the number
11062 is at the least significant bit of the significand. The number is
11063 truncated to fit the significand field provided. The significand is
11064 forced to be a quiet NaN@.
11065
11066 This function, if given a string literal all of which would have been
11067 consumed by @code{strtol}, is evaluated early enough that it is considered a
11068 compile-time constant.
11069 @end deftypefn
11070
11071 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11072 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11073 @end deftypefn
11074
11075 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11076 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11077 @end deftypefn
11078
11079 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11080 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11081 @end deftypefn
11082
11083 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11084 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11085 @end deftypefn
11086
11087 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11088 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11089 @end deftypefn
11090
11091 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11092 Similar to @code{__builtin_nan}, except the significand is forced
11093 to be a signaling NaN@. The @code{nans} function is proposed by
11094 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11095 @end deftypefn
11096
11097 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11098 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11099 @end deftypefn
11100
11101 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11102 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11103 @end deftypefn
11104
11105 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11106 Returns one plus the index of the least significant 1-bit of @var{x}, or
11107 if @var{x} is zero, returns zero.
11108 @end deftypefn
11109
11110 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11111 Returns the number of leading 0-bits in @var{x}, starting at the most
11112 significant bit position. If @var{x} is 0, the result is undefined.
11113 @end deftypefn
11114
11115 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11116 Returns the number of trailing 0-bits in @var{x}, starting at the least
11117 significant bit position. If @var{x} is 0, the result is undefined.
11118 @end deftypefn
11119
11120 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11121 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11122 number of bits following the most significant bit that are identical
11123 to it. There are no special cases for 0 or other values.
11124 @end deftypefn
11125
11126 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11127 Returns the number of 1-bits in @var{x}.
11128 @end deftypefn
11129
11130 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11131 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11132 modulo 2.
11133 @end deftypefn
11134
11135 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11136 Similar to @code{__builtin_ffs}, except the argument type is
11137 @code{long}.
11138 @end deftypefn
11139
11140 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11141 Similar to @code{__builtin_clz}, except the argument type is
11142 @code{unsigned long}.
11143 @end deftypefn
11144
11145 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11146 Similar to @code{__builtin_ctz}, except the argument type is
11147 @code{unsigned long}.
11148 @end deftypefn
11149
11150 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11151 Similar to @code{__builtin_clrsb}, except the argument type is
11152 @code{long}.
11153 @end deftypefn
11154
11155 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11156 Similar to @code{__builtin_popcount}, except the argument type is
11157 @code{unsigned long}.
11158 @end deftypefn
11159
11160 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11161 Similar to @code{__builtin_parity}, except the argument type is
11162 @code{unsigned long}.
11163 @end deftypefn
11164
11165 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11166 Similar to @code{__builtin_ffs}, except the argument type is
11167 @code{long long}.
11168 @end deftypefn
11169
11170 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11171 Similar to @code{__builtin_clz}, except the argument type is
11172 @code{unsigned long long}.
11173 @end deftypefn
11174
11175 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11176 Similar to @code{__builtin_ctz}, except the argument type is
11177 @code{unsigned long long}.
11178 @end deftypefn
11179
11180 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11181 Similar to @code{__builtin_clrsb}, except the argument type is
11182 @code{long long}.
11183 @end deftypefn
11184
11185 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11186 Similar to @code{__builtin_popcount}, except the argument type is
11187 @code{unsigned long long}.
11188 @end deftypefn
11189
11190 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11191 Similar to @code{__builtin_parity}, except the argument type is
11192 @code{unsigned long long}.
11193 @end deftypefn
11194
11195 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11196 Returns the first argument raised to the power of the second. Unlike the
11197 @code{pow} function no guarantees about precision and rounding are made.
11198 @end deftypefn
11199
11200 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11201 Similar to @code{__builtin_powi}, except the argument and return types
11202 are @code{float}.
11203 @end deftypefn
11204
11205 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11206 Similar to @code{__builtin_powi}, except the argument and return types
11207 are @code{long double}.
11208 @end deftypefn
11209
11210 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11211 Returns @var{x} with the order of the bytes reversed; for example,
11212 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11213 exactly 8 bits.
11214 @end deftypefn
11215
11216 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11217 Similar to @code{__builtin_bswap16}, except the argument and return types
11218 are 32 bit.
11219 @end deftypefn
11220
11221 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11222 Similar to @code{__builtin_bswap32}, except the argument and return types
11223 are 64 bit.
11224 @end deftypefn
11225
11226 @node Target Builtins
11227 @section Built-in Functions Specific to Particular Target Machines
11228
11229 On some target machines, GCC supports many built-in functions specific
11230 to those machines. Generally these generate calls to specific machine
11231 instructions, but allow the compiler to schedule those calls.
11232
11233 @menu
11234 * AArch64 Built-in Functions::
11235 * Alpha Built-in Functions::
11236 * Altera Nios II Built-in Functions::
11237 * ARC Built-in Functions::
11238 * ARC SIMD Built-in Functions::
11239 * ARM iWMMXt Built-in Functions::
11240 * ARM C Language Extensions (ACLE)::
11241 * ARM Floating Point Status and Control Intrinsics::
11242 * AVR Built-in Functions::
11243 * Blackfin Built-in Functions::
11244 * FR-V Built-in Functions::
11245 * MIPS DSP Built-in Functions::
11246 * MIPS Paired-Single Support::
11247 * MIPS Loongson Built-in Functions::
11248 * Other MIPS Built-in Functions::
11249 * MSP430 Built-in Functions::
11250 * NDS32 Built-in Functions::
11251 * picoChip Built-in Functions::
11252 * PowerPC Built-in Functions::
11253 * PowerPC AltiVec/VSX Built-in Functions::
11254 * PowerPC Hardware Transactional Memory Built-in Functions::
11255 * RX Built-in Functions::
11256 * S/390 System z Built-in Functions::
11257 * SH Built-in Functions::
11258 * SPARC VIS Built-in Functions::
11259 * SPU Built-in Functions::
11260 * TI C6X Built-in Functions::
11261 * TILE-Gx Built-in Functions::
11262 * TILEPro Built-in Functions::
11263 * x86 Built-in Functions::
11264 * x86 transactional memory intrinsics::
11265 @end menu
11266
11267 @node AArch64 Built-in Functions
11268 @subsection AArch64 Built-in Functions
11269
11270 These built-in functions are available for the AArch64 family of
11271 processors.
11272 @smallexample
11273 unsigned int __builtin_aarch64_get_fpcr ()
11274 void __builtin_aarch64_set_fpcr (unsigned int)
11275 unsigned int __builtin_aarch64_get_fpsr ()
11276 void __builtin_aarch64_set_fpsr (unsigned int)
11277 @end smallexample
11278
11279 @node Alpha Built-in Functions
11280 @subsection Alpha Built-in Functions
11281
11282 These built-in functions are available for the Alpha family of
11283 processors, depending on the command-line switches used.
11284
11285 The following built-in functions are always available. They
11286 all generate the machine instruction that is part of the name.
11287
11288 @smallexample
11289 long __builtin_alpha_implver (void)
11290 long __builtin_alpha_rpcc (void)
11291 long __builtin_alpha_amask (long)
11292 long __builtin_alpha_cmpbge (long, long)
11293 long __builtin_alpha_extbl (long, long)
11294 long __builtin_alpha_extwl (long, long)
11295 long __builtin_alpha_extll (long, long)
11296 long __builtin_alpha_extql (long, long)
11297 long __builtin_alpha_extwh (long, long)
11298 long __builtin_alpha_extlh (long, long)
11299 long __builtin_alpha_extqh (long, long)
11300 long __builtin_alpha_insbl (long, long)
11301 long __builtin_alpha_inswl (long, long)
11302 long __builtin_alpha_insll (long, long)
11303 long __builtin_alpha_insql (long, long)
11304 long __builtin_alpha_inswh (long, long)
11305 long __builtin_alpha_inslh (long, long)
11306 long __builtin_alpha_insqh (long, long)
11307 long __builtin_alpha_mskbl (long, long)
11308 long __builtin_alpha_mskwl (long, long)
11309 long __builtin_alpha_mskll (long, long)
11310 long __builtin_alpha_mskql (long, long)
11311 long __builtin_alpha_mskwh (long, long)
11312 long __builtin_alpha_msklh (long, long)
11313 long __builtin_alpha_mskqh (long, long)
11314 long __builtin_alpha_umulh (long, long)
11315 long __builtin_alpha_zap (long, long)
11316 long __builtin_alpha_zapnot (long, long)
11317 @end smallexample
11318
11319 The following built-in functions are always with @option{-mmax}
11320 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11321 later. They all generate the machine instruction that is part
11322 of the name.
11323
11324 @smallexample
11325 long __builtin_alpha_pklb (long)
11326 long __builtin_alpha_pkwb (long)
11327 long __builtin_alpha_unpkbl (long)
11328 long __builtin_alpha_unpkbw (long)
11329 long __builtin_alpha_minub8 (long, long)
11330 long __builtin_alpha_minsb8 (long, long)
11331 long __builtin_alpha_minuw4 (long, long)
11332 long __builtin_alpha_minsw4 (long, long)
11333 long __builtin_alpha_maxub8 (long, long)
11334 long __builtin_alpha_maxsb8 (long, long)
11335 long __builtin_alpha_maxuw4 (long, long)
11336 long __builtin_alpha_maxsw4 (long, long)
11337 long __builtin_alpha_perr (long, long)
11338 @end smallexample
11339
11340 The following built-in functions are always with @option{-mcix}
11341 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11342 later. They all generate the machine instruction that is part
11343 of the name.
11344
11345 @smallexample
11346 long __builtin_alpha_cttz (long)
11347 long __builtin_alpha_ctlz (long)
11348 long __builtin_alpha_ctpop (long)
11349 @end smallexample
11350
11351 The following built-in functions are available on systems that use the OSF/1
11352 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11353 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11354 @code{rdval} and @code{wrval}.
11355
11356 @smallexample
11357 void *__builtin_thread_pointer (void)
11358 void __builtin_set_thread_pointer (void *)
11359 @end smallexample
11360
11361 @node Altera Nios II Built-in Functions
11362 @subsection Altera Nios II Built-in Functions
11363
11364 These built-in functions are available for the Altera Nios II
11365 family of processors.
11366
11367 The following built-in functions are always available. They
11368 all generate the machine instruction that is part of the name.
11369
11370 @example
11371 int __builtin_ldbio (volatile const void *)
11372 int __builtin_ldbuio (volatile const void *)
11373 int __builtin_ldhio (volatile const void *)
11374 int __builtin_ldhuio (volatile const void *)
11375 int __builtin_ldwio (volatile const void *)
11376 void __builtin_stbio (volatile void *, int)
11377 void __builtin_sthio (volatile void *, int)
11378 void __builtin_stwio (volatile void *, int)
11379 void __builtin_sync (void)
11380 int __builtin_rdctl (int)
11381 int __builtin_rdprs (int, int)
11382 void __builtin_wrctl (int, int)
11383 void __builtin_flushd (volatile void *)
11384 void __builtin_flushda (volatile void *)
11385 int __builtin_wrpie (int);
11386 void __builtin_eni (int);
11387 int __builtin_ldex (volatile const void *)
11388 int __builtin_stex (volatile void *, int)
11389 int __builtin_ldsex (volatile const void *)
11390 int __builtin_stsex (volatile void *, int)
11391 @end example
11392
11393 The following built-in functions are always available. They
11394 all generate a Nios II Custom Instruction. The name of the
11395 function represents the types that the function takes and
11396 returns. The letter before the @code{n} is the return type
11397 or void if absent. The @code{n} represents the first parameter
11398 to all the custom instructions, the custom instruction number.
11399 The two letters after the @code{n} represent the up to two
11400 parameters to the function.
11401
11402 The letters represent the following data types:
11403 @table @code
11404 @item <no letter>
11405 @code{void} for return type and no parameter for parameter types.
11406
11407 @item i
11408 @code{int} for return type and parameter type
11409
11410 @item f
11411 @code{float} for return type and parameter type
11412
11413 @item p
11414 @code{void *} for return type and parameter type
11415
11416 @end table
11417
11418 And the function names are:
11419 @example
11420 void __builtin_custom_n (void)
11421 void __builtin_custom_ni (int)
11422 void __builtin_custom_nf (float)
11423 void __builtin_custom_np (void *)
11424 void __builtin_custom_nii (int, int)
11425 void __builtin_custom_nif (int, float)
11426 void __builtin_custom_nip (int, void *)
11427 void __builtin_custom_nfi (float, int)
11428 void __builtin_custom_nff (float, float)
11429 void __builtin_custom_nfp (float, void *)
11430 void __builtin_custom_npi (void *, int)
11431 void __builtin_custom_npf (void *, float)
11432 void __builtin_custom_npp (void *, void *)
11433 int __builtin_custom_in (void)
11434 int __builtin_custom_ini (int)
11435 int __builtin_custom_inf (float)
11436 int __builtin_custom_inp (void *)
11437 int __builtin_custom_inii (int, int)
11438 int __builtin_custom_inif (int, float)
11439 int __builtin_custom_inip (int, void *)
11440 int __builtin_custom_infi (float, int)
11441 int __builtin_custom_inff (float, float)
11442 int __builtin_custom_infp (float, void *)
11443 int __builtin_custom_inpi (void *, int)
11444 int __builtin_custom_inpf (void *, float)
11445 int __builtin_custom_inpp (void *, void *)
11446 float __builtin_custom_fn (void)
11447 float __builtin_custom_fni (int)
11448 float __builtin_custom_fnf (float)
11449 float __builtin_custom_fnp (void *)
11450 float __builtin_custom_fnii (int, int)
11451 float __builtin_custom_fnif (int, float)
11452 float __builtin_custom_fnip (int, void *)
11453 float __builtin_custom_fnfi (float, int)
11454 float __builtin_custom_fnff (float, float)
11455 float __builtin_custom_fnfp (float, void *)
11456 float __builtin_custom_fnpi (void *, int)
11457 float __builtin_custom_fnpf (void *, float)
11458 float __builtin_custom_fnpp (void *, void *)
11459 void * __builtin_custom_pn (void)
11460 void * __builtin_custom_pni (int)
11461 void * __builtin_custom_pnf (float)
11462 void * __builtin_custom_pnp (void *)
11463 void * __builtin_custom_pnii (int, int)
11464 void * __builtin_custom_pnif (int, float)
11465 void * __builtin_custom_pnip (int, void *)
11466 void * __builtin_custom_pnfi (float, int)
11467 void * __builtin_custom_pnff (float, float)
11468 void * __builtin_custom_pnfp (float, void *)
11469 void * __builtin_custom_pnpi (void *, int)
11470 void * __builtin_custom_pnpf (void *, float)
11471 void * __builtin_custom_pnpp (void *, void *)
11472 @end example
11473
11474 @node ARC Built-in Functions
11475 @subsection ARC Built-in Functions
11476
11477 The following built-in functions are provided for ARC targets. The
11478 built-ins generate the corresponding assembly instructions. In the
11479 examples given below, the generated code often requires an operand or
11480 result to be in a register. Where necessary further code will be
11481 generated to ensure this is true, but for brevity this is not
11482 described in each case.
11483
11484 @emph{Note:} Using a built-in to generate an instruction not supported
11485 by a target may cause problems. At present the compiler is not
11486 guaranteed to detect such misuse, and as a result an internal compiler
11487 error may be generated.
11488
11489 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11490 Return 1 if @var{val} is known to have the byte alignment given
11491 by @var{alignval}, otherwise return 0.
11492 Note that this is different from
11493 @smallexample
11494 __alignof__(*(char *)@var{val}) >= alignval
11495 @end smallexample
11496 because __alignof__ sees only the type of the dereference, whereas
11497 __builtin_arc_align uses alignment information from the pointer
11498 as well as from the pointed-to type.
11499 The information available will depend on optimization level.
11500 @end deftypefn
11501
11502 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11503 Generates
11504 @example
11505 brk
11506 @end example
11507 @end deftypefn
11508
11509 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11510 The operand is the number of a register to be read. Generates:
11511 @example
11512 mov @var{dest}, r@var{regno}
11513 @end example
11514 where the value in @var{dest} will be the result returned from the
11515 built-in.
11516 @end deftypefn
11517
11518 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11519 The first operand is the number of a register to be written, the
11520 second operand is a compile time constant to write into that
11521 register. Generates:
11522 @example
11523 mov r@var{regno}, @var{val}
11524 @end example
11525 @end deftypefn
11526
11527 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11528 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11529 Generates:
11530 @example
11531 divaw @var{dest}, @var{a}, @var{b}
11532 @end example
11533 where the value in @var{dest} will be the result returned from the
11534 built-in.
11535 @end deftypefn
11536
11537 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11538 Generates
11539 @example
11540 flag @var{a}
11541 @end example
11542 @end deftypefn
11543
11544 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11545 The operand, @var{auxv}, is the address of an auxiliary register and
11546 must be a compile time constant. Generates:
11547 @example
11548 lr @var{dest}, [@var{auxr}]
11549 @end example
11550 Where the value in @var{dest} will be the result returned from the
11551 built-in.
11552 @end deftypefn
11553
11554 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11555 Only available with @option{-mmul64}. Generates:
11556 @example
11557 mul64 @var{a}, @var{b}
11558 @end example
11559 @end deftypefn
11560
11561 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11562 Only available with @option{-mmul64}. Generates:
11563 @example
11564 mulu64 @var{a}, @var{b}
11565 @end example
11566 @end deftypefn
11567
11568 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11569 Generates:
11570 @example
11571 nop
11572 @end example
11573 @end deftypefn
11574
11575 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11576 Only valid if the @samp{norm} instruction is available through the
11577 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11578 Generates:
11579 @example
11580 norm @var{dest}, @var{src}
11581 @end example
11582 Where the value in @var{dest} will be the result returned from the
11583 built-in.
11584 @end deftypefn
11585
11586 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11587 Only valid if the @samp{normw} instruction is available through the
11588 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11589 Generates:
11590 @example
11591 normw @var{dest}, @var{src}
11592 @end example
11593 Where the value in @var{dest} will be the result returned from the
11594 built-in.
11595 @end deftypefn
11596
11597 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11598 Generates:
11599 @example
11600 rtie
11601 @end example
11602 @end deftypefn
11603
11604 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11605 Generates:
11606 @example
11607 sleep @var{a}
11608 @end example
11609 @end deftypefn
11610
11611 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11612 The first argument, @var{auxv}, is the address of an auxiliary
11613 register, the second argument, @var{val}, is a compile time constant
11614 to be written to the register. Generates:
11615 @example
11616 sr @var{auxr}, [@var{val}]
11617 @end example
11618 @end deftypefn
11619
11620 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11621 Only valid with @option{-mswap}. Generates:
11622 @example
11623 swap @var{dest}, @var{src}
11624 @end example
11625 Where the value in @var{dest} will be the result returned from the
11626 built-in.
11627 @end deftypefn
11628
11629 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11630 Generates:
11631 @example
11632 swi
11633 @end example
11634 @end deftypefn
11635
11636 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11637 Only available with @option{-mcpu=ARC700}. Generates:
11638 @example
11639 sync
11640 @end example
11641 @end deftypefn
11642
11643 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11644 Only available with @option{-mcpu=ARC700}. Generates:
11645 @example
11646 trap_s @var{c}
11647 @end example
11648 @end deftypefn
11649
11650 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11651 Only available with @option{-mcpu=ARC700}. Generates:
11652 @example
11653 unimp_s
11654 @end example
11655 @end deftypefn
11656
11657 The instructions generated by the following builtins are not
11658 considered as candidates for scheduling. They are not moved around by
11659 the compiler during scheduling, and thus can be expected to appear
11660 where they are put in the C code:
11661 @example
11662 __builtin_arc_brk()
11663 __builtin_arc_core_read()
11664 __builtin_arc_core_write()
11665 __builtin_arc_flag()
11666 __builtin_arc_lr()
11667 __builtin_arc_sleep()
11668 __builtin_arc_sr()
11669 __builtin_arc_swi()
11670 @end example
11671
11672 @node ARC SIMD Built-in Functions
11673 @subsection ARC SIMD Built-in Functions
11674
11675 SIMD builtins provided by the compiler can be used to generate the
11676 vector instructions. This section describes the available builtins
11677 and their usage in programs. With the @option{-msimd} option, the
11678 compiler provides 128-bit vector types, which can be specified using
11679 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11680 can be included to use the following predefined types:
11681 @example
11682 typedef int __v4si __attribute__((vector_size(16)));
11683 typedef short __v8hi __attribute__((vector_size(16)));
11684 @end example
11685
11686 These types can be used to define 128-bit variables. The built-in
11687 functions listed in the following section can be used on these
11688 variables to generate the vector operations.
11689
11690 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11691 @file{arc-simd.h} also provides equivalent macros called
11692 @code{_@var{someinsn}} that can be used for programming ease and
11693 improved readability. The following macros for DMA control are also
11694 provided:
11695 @example
11696 #define _setup_dma_in_channel_reg _vdiwr
11697 #define _setup_dma_out_channel_reg _vdowr
11698 @end example
11699
11700 The following is a complete list of all the SIMD built-ins provided
11701 for ARC, grouped by calling signature.
11702
11703 The following take two @code{__v8hi} arguments and return a
11704 @code{__v8hi} result:
11705 @example
11706 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11707 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11708 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11709 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11710 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11711 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11712 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11713 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11714 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11715 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11716 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11717 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11718 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11719 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11720 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11721 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11722 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11723 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11724 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11725 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11726 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11727 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11728 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11729 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11730 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11731 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11732 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11733 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11734 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11735 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11736 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11737 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11738 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11739 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11740 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11741 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11742 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11743 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11744 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11745 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11746 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11747 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11748 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11749 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11750 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11751 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11752 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11753 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11754 @end example
11755
11756 The following take one @code{__v8hi} and one @code{int} argument and return a
11757 @code{__v8hi} result:
11758
11759 @example
11760 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11761 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11762 __v8hi __builtin_arc_vbminw (__v8hi, int)
11763 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11764 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11765 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11766 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11767 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11768 @end example
11769
11770 The following take one @code{__v8hi} argument and one @code{int} argument which
11771 must be a 3-bit compile time constant indicating a register number
11772 I0-I7. They return a @code{__v8hi} result.
11773 @example
11774 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11775 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11776 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11777 @end example
11778
11779 The following take one @code{__v8hi} argument and one @code{int}
11780 argument which must be a 6-bit compile time constant. They return a
11781 @code{__v8hi} result.
11782 @example
11783 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11784 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11785 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11786 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11787 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11788 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11789 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11790 @end example
11791
11792 The following take one @code{__v8hi} argument and one @code{int} argument which
11793 must be a 8-bit compile time constant. They return a @code{__v8hi}
11794 result.
11795 @example
11796 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11797 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11798 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11799 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11800 @end example
11801
11802 The following take two @code{int} arguments, the second of which which
11803 must be a 8-bit compile time constant. They return a @code{__v8hi}
11804 result:
11805 @example
11806 __v8hi __builtin_arc_vmovaw (int, const int)
11807 __v8hi __builtin_arc_vmovw (int, const int)
11808 __v8hi __builtin_arc_vmovzw (int, const int)
11809 @end example
11810
11811 The following take a single @code{__v8hi} argument and return a
11812 @code{__v8hi} result:
11813 @example
11814 __v8hi __builtin_arc_vabsaw (__v8hi)
11815 __v8hi __builtin_arc_vabsw (__v8hi)
11816 __v8hi __builtin_arc_vaddsuw (__v8hi)
11817 __v8hi __builtin_arc_vexch1 (__v8hi)
11818 __v8hi __builtin_arc_vexch2 (__v8hi)
11819 __v8hi __builtin_arc_vexch4 (__v8hi)
11820 __v8hi __builtin_arc_vsignw (__v8hi)
11821 __v8hi __builtin_arc_vupbaw (__v8hi)
11822 __v8hi __builtin_arc_vupbw (__v8hi)
11823 __v8hi __builtin_arc_vupsbaw (__v8hi)
11824 __v8hi __builtin_arc_vupsbw (__v8hi)
11825 @end example
11826
11827 The following take two @code{int} arguments and return no result:
11828 @example
11829 void __builtin_arc_vdirun (int, int)
11830 void __builtin_arc_vdorun (int, int)
11831 @end example
11832
11833 The following take two @code{int} arguments and return no result. The
11834 first argument must a 3-bit compile time constant indicating one of
11835 the DR0-DR7 DMA setup channels:
11836 @example
11837 void __builtin_arc_vdiwr (const int, int)
11838 void __builtin_arc_vdowr (const int, int)
11839 @end example
11840
11841 The following take an @code{int} argument and return no result:
11842 @example
11843 void __builtin_arc_vendrec (int)
11844 void __builtin_arc_vrec (int)
11845 void __builtin_arc_vrecrun (int)
11846 void __builtin_arc_vrun (int)
11847 @end example
11848
11849 The following take a @code{__v8hi} argument and two @code{int}
11850 arguments and return a @code{__v8hi} result. The second argument must
11851 be a 3-bit compile time constants, indicating one the registers I0-I7,
11852 and the third argument must be an 8-bit compile time constant.
11853
11854 @emph{Note:} Although the equivalent hardware instructions do not take
11855 an SIMD register as an operand, these builtins overwrite the relevant
11856 bits of the @code{__v8hi} register provided as the first argument with
11857 the value loaded from the @code{[Ib, u8]} location in the SDM.
11858
11859 @example
11860 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11861 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11862 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11863 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11864 @end example
11865
11866 The following take two @code{int} arguments and return a @code{__v8hi}
11867 result. The first argument must be a 3-bit compile time constants,
11868 indicating one the registers I0-I7, and the second argument must be an
11869 8-bit compile time constant.
11870
11871 @example
11872 __v8hi __builtin_arc_vld128 (const int, const int)
11873 __v8hi __builtin_arc_vld64w (const int, const int)
11874 @end example
11875
11876 The following take a @code{__v8hi} argument and two @code{int}
11877 arguments and return no result. The second argument must be a 3-bit
11878 compile time constants, indicating one the registers I0-I7, and the
11879 third argument must be an 8-bit compile time constant.
11880
11881 @example
11882 void __builtin_arc_vst128 (__v8hi, const int, const int)
11883 void __builtin_arc_vst64 (__v8hi, const int, const int)
11884 @end example
11885
11886 The following take a @code{__v8hi} argument and three @code{int}
11887 arguments and return no result. The second argument must be a 3-bit
11888 compile-time constant, identifying the 16-bit sub-register to be
11889 stored, the third argument must be a 3-bit compile time constants,
11890 indicating one the registers I0-I7, and the fourth argument must be an
11891 8-bit compile time constant.
11892
11893 @example
11894 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11895 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11896 @end example
11897
11898 @node ARM iWMMXt Built-in Functions
11899 @subsection ARM iWMMXt Built-in Functions
11900
11901 These built-in functions are available for the ARM family of
11902 processors when the @option{-mcpu=iwmmxt} switch is used:
11903
11904 @smallexample
11905 typedef int v2si __attribute__ ((vector_size (8)));
11906 typedef short v4hi __attribute__ ((vector_size (8)));
11907 typedef char v8qi __attribute__ ((vector_size (8)));
11908
11909 int __builtin_arm_getwcgr0 (void)
11910 void __builtin_arm_setwcgr0 (int)
11911 int __builtin_arm_getwcgr1 (void)
11912 void __builtin_arm_setwcgr1 (int)
11913 int __builtin_arm_getwcgr2 (void)
11914 void __builtin_arm_setwcgr2 (int)
11915 int __builtin_arm_getwcgr3 (void)
11916 void __builtin_arm_setwcgr3 (int)
11917 int __builtin_arm_textrmsb (v8qi, int)
11918 int __builtin_arm_textrmsh (v4hi, int)
11919 int __builtin_arm_textrmsw (v2si, int)
11920 int __builtin_arm_textrmub (v8qi, int)
11921 int __builtin_arm_textrmuh (v4hi, int)
11922 int __builtin_arm_textrmuw (v2si, int)
11923 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11924 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11925 v2si __builtin_arm_tinsrw (v2si, int, int)
11926 long long __builtin_arm_tmia (long long, int, int)
11927 long long __builtin_arm_tmiabb (long long, int, int)
11928 long long __builtin_arm_tmiabt (long long, int, int)
11929 long long __builtin_arm_tmiaph (long long, int, int)
11930 long long __builtin_arm_tmiatb (long long, int, int)
11931 long long __builtin_arm_tmiatt (long long, int, int)
11932 int __builtin_arm_tmovmskb (v8qi)
11933 int __builtin_arm_tmovmskh (v4hi)
11934 int __builtin_arm_tmovmskw (v2si)
11935 long long __builtin_arm_waccb (v8qi)
11936 long long __builtin_arm_wacch (v4hi)
11937 long long __builtin_arm_waccw (v2si)
11938 v8qi __builtin_arm_waddb (v8qi, v8qi)
11939 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11940 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11941 v4hi __builtin_arm_waddh (v4hi, v4hi)
11942 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11943 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11944 v2si __builtin_arm_waddw (v2si, v2si)
11945 v2si __builtin_arm_waddwss (v2si, v2si)
11946 v2si __builtin_arm_waddwus (v2si, v2si)
11947 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11948 long long __builtin_arm_wand(long long, long long)
11949 long long __builtin_arm_wandn (long long, long long)
11950 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11951 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11952 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11953 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11954 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
11955 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
11956 v2si __builtin_arm_wcmpeqw (v2si, v2si)
11957 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
11958 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
11959 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
11960 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
11961 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
11962 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
11963 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
11964 long long __builtin_arm_wmacsz (v4hi, v4hi)
11965 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
11966 long long __builtin_arm_wmacuz (v4hi, v4hi)
11967 v4hi __builtin_arm_wmadds (v4hi, v4hi)
11968 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
11969 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
11970 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
11971 v2si __builtin_arm_wmaxsw (v2si, v2si)
11972 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
11973 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
11974 v2si __builtin_arm_wmaxuw (v2si, v2si)
11975 v8qi __builtin_arm_wminsb (v8qi, v8qi)
11976 v4hi __builtin_arm_wminsh (v4hi, v4hi)
11977 v2si __builtin_arm_wminsw (v2si, v2si)
11978 v8qi __builtin_arm_wminub (v8qi, v8qi)
11979 v4hi __builtin_arm_wminuh (v4hi, v4hi)
11980 v2si __builtin_arm_wminuw (v2si, v2si)
11981 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
11982 v4hi __builtin_arm_wmulul (v4hi, v4hi)
11983 v4hi __builtin_arm_wmulum (v4hi, v4hi)
11984 long long __builtin_arm_wor (long long, long long)
11985 v2si __builtin_arm_wpackdss (long long, long long)
11986 v2si __builtin_arm_wpackdus (long long, long long)
11987 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
11988 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
11989 v4hi __builtin_arm_wpackwss (v2si, v2si)
11990 v4hi __builtin_arm_wpackwus (v2si, v2si)
11991 long long __builtin_arm_wrord (long long, long long)
11992 long long __builtin_arm_wrordi (long long, int)
11993 v4hi __builtin_arm_wrorh (v4hi, long long)
11994 v4hi __builtin_arm_wrorhi (v4hi, int)
11995 v2si __builtin_arm_wrorw (v2si, long long)
11996 v2si __builtin_arm_wrorwi (v2si, int)
11997 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
11998 v2si __builtin_arm_wsadbz (v8qi, v8qi)
11999 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12000 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12001 v4hi __builtin_arm_wshufh (v4hi, int)
12002 long long __builtin_arm_wslld (long long, long long)
12003 long long __builtin_arm_wslldi (long long, int)
12004 v4hi __builtin_arm_wsllh (v4hi, long long)
12005 v4hi __builtin_arm_wsllhi (v4hi, int)
12006 v2si __builtin_arm_wsllw (v2si, long long)
12007 v2si __builtin_arm_wsllwi (v2si, int)
12008 long long __builtin_arm_wsrad (long long, long long)
12009 long long __builtin_arm_wsradi (long long, int)
12010 v4hi __builtin_arm_wsrah (v4hi, long long)
12011 v4hi __builtin_arm_wsrahi (v4hi, int)
12012 v2si __builtin_arm_wsraw (v2si, long long)
12013 v2si __builtin_arm_wsrawi (v2si, int)
12014 long long __builtin_arm_wsrld (long long, long long)
12015 long long __builtin_arm_wsrldi (long long, int)
12016 v4hi __builtin_arm_wsrlh (v4hi, long long)
12017 v4hi __builtin_arm_wsrlhi (v4hi, int)
12018 v2si __builtin_arm_wsrlw (v2si, long long)
12019 v2si __builtin_arm_wsrlwi (v2si, int)
12020 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12021 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12022 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12023 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12024 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12025 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12026 v2si __builtin_arm_wsubw (v2si, v2si)
12027 v2si __builtin_arm_wsubwss (v2si, v2si)
12028 v2si __builtin_arm_wsubwus (v2si, v2si)
12029 v4hi __builtin_arm_wunpckehsb (v8qi)
12030 v2si __builtin_arm_wunpckehsh (v4hi)
12031 long long __builtin_arm_wunpckehsw (v2si)
12032 v4hi __builtin_arm_wunpckehub (v8qi)
12033 v2si __builtin_arm_wunpckehuh (v4hi)
12034 long long __builtin_arm_wunpckehuw (v2si)
12035 v4hi __builtin_arm_wunpckelsb (v8qi)
12036 v2si __builtin_arm_wunpckelsh (v4hi)
12037 long long __builtin_arm_wunpckelsw (v2si)
12038 v4hi __builtin_arm_wunpckelub (v8qi)
12039 v2si __builtin_arm_wunpckeluh (v4hi)
12040 long long __builtin_arm_wunpckeluw (v2si)
12041 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12042 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12043 v2si __builtin_arm_wunpckihw (v2si, v2si)
12044 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12045 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12046 v2si __builtin_arm_wunpckilw (v2si, v2si)
12047 long long __builtin_arm_wxor (long long, long long)
12048 long long __builtin_arm_wzero ()
12049 @end smallexample
12050
12051
12052 @node ARM C Language Extensions (ACLE)
12053 @subsection ARM C Language Extensions (ACLE)
12054
12055 GCC implements extensions for C as described in the ARM C Language
12056 Extensions (ACLE) specification, which can be found at
12057 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12058
12059 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12060 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12061 intrinsics can be found at
12062 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12063 The built-in intrinsics for the Advanced SIMD extension are available when
12064 NEON is enabled.
12065
12066 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12067 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12068 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12069 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12070 intrinsics yet.
12071
12072 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12073 availability of extensions.
12074
12075 @node ARM Floating Point Status and Control Intrinsics
12076 @subsection ARM Floating Point Status and Control Intrinsics
12077
12078 These built-in functions are available for the ARM family of
12079 processors with floating-point unit.
12080
12081 @smallexample
12082 unsigned int __builtin_arm_get_fpscr ()
12083 void __builtin_arm_set_fpscr (unsigned int)
12084 @end smallexample
12085
12086 @node AVR Built-in Functions
12087 @subsection AVR Built-in Functions
12088
12089 For each built-in function for AVR, there is an equally named,
12090 uppercase built-in macro defined. That way users can easily query if
12091 or if not a specific built-in is implemented or not. For example, if
12092 @code{__builtin_avr_nop} is available the macro
12093 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12094
12095 The following built-in functions map to the respective machine
12096 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12097 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12098 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12099 as library call if no hardware multiplier is available.
12100
12101 @smallexample
12102 void __builtin_avr_nop (void)
12103 void __builtin_avr_sei (void)
12104 void __builtin_avr_cli (void)
12105 void __builtin_avr_sleep (void)
12106 void __builtin_avr_wdr (void)
12107 unsigned char __builtin_avr_swap (unsigned char)
12108 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12109 int __builtin_avr_fmuls (char, char)
12110 int __builtin_avr_fmulsu (char, unsigned char)
12111 @end smallexample
12112
12113 In order to delay execution for a specific number of cycles, GCC
12114 implements
12115 @smallexample
12116 void __builtin_avr_delay_cycles (unsigned long ticks)
12117 @end smallexample
12118
12119 @noindent
12120 @code{ticks} is the number of ticks to delay execution. Note that this
12121 built-in does not take into account the effect of interrupts that
12122 might increase delay time. @code{ticks} must be a compile-time
12123 integer constant; delays with a variable number of cycles are not supported.
12124
12125 @smallexample
12126 char __builtin_avr_flash_segment (const __memx void*)
12127 @end smallexample
12128
12129 @noindent
12130 This built-in takes a byte address to the 24-bit
12131 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12132 the number of the flash segment (the 64 KiB chunk) where the address
12133 points to. Counting starts at @code{0}.
12134 If the address does not point to flash memory, return @code{-1}.
12135
12136 @smallexample
12137 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12138 @end smallexample
12139
12140 @noindent
12141 Insert bits from @var{bits} into @var{val} and return the resulting
12142 value. The nibbles of @var{map} determine how the insertion is
12143 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12144 @enumerate
12145 @item If @var{X} is @code{0xf},
12146 then the @var{n}-th bit of @var{val} is returned unaltered.
12147
12148 @item If X is in the range 0@dots{}7,
12149 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12150
12151 @item If X is in the range 8@dots{}@code{0xe},
12152 then the @var{n}-th result bit is undefined.
12153 @end enumerate
12154
12155 @noindent
12156 One typical use case for this built-in is adjusting input and
12157 output values to non-contiguous port layouts. Some examples:
12158
12159 @smallexample
12160 // same as val, bits is unused
12161 __builtin_avr_insert_bits (0xffffffff, bits, val)
12162 @end smallexample
12163
12164 @smallexample
12165 // same as bits, val is unused
12166 __builtin_avr_insert_bits (0x76543210, bits, val)
12167 @end smallexample
12168
12169 @smallexample
12170 // same as rotating bits by 4
12171 __builtin_avr_insert_bits (0x32107654, bits, 0)
12172 @end smallexample
12173
12174 @smallexample
12175 // high nibble of result is the high nibble of val
12176 // low nibble of result is the low nibble of bits
12177 __builtin_avr_insert_bits (0xffff3210, bits, val)
12178 @end smallexample
12179
12180 @smallexample
12181 // reverse the bit order of bits
12182 __builtin_avr_insert_bits (0x01234567, bits, 0)
12183 @end smallexample
12184
12185 @node Blackfin Built-in Functions
12186 @subsection Blackfin Built-in Functions
12187
12188 Currently, there are two Blackfin-specific built-in functions. These are
12189 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12190 using inline assembly; by using these built-in functions the compiler can
12191 automatically add workarounds for hardware errata involving these
12192 instructions. These functions are named as follows:
12193
12194 @smallexample
12195 void __builtin_bfin_csync (void)
12196 void __builtin_bfin_ssync (void)
12197 @end smallexample
12198
12199 @node FR-V Built-in Functions
12200 @subsection FR-V Built-in Functions
12201
12202 GCC provides many FR-V-specific built-in functions. In general,
12203 these functions are intended to be compatible with those described
12204 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12205 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12206 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12207 pointer rather than by value.
12208
12209 Most of the functions are named after specific FR-V instructions.
12210 Such functions are said to be ``directly mapped'' and are summarized
12211 here in tabular form.
12212
12213 @menu
12214 * Argument Types::
12215 * Directly-mapped Integer Functions::
12216 * Directly-mapped Media Functions::
12217 * Raw read/write Functions::
12218 * Other Built-in Functions::
12219 @end menu
12220
12221 @node Argument Types
12222 @subsubsection Argument Types
12223
12224 The arguments to the built-in functions can be divided into three groups:
12225 register numbers, compile-time constants and run-time values. In order
12226 to make this classification clear at a glance, the arguments and return
12227 values are given the following pseudo types:
12228
12229 @multitable @columnfractions .20 .30 .15 .35
12230 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12231 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12232 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12233 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12234 @item @code{uw2} @tab @code{unsigned long long} @tab No
12235 @tab an unsigned doubleword
12236 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12237 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12238 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12239 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12240 @end multitable
12241
12242 These pseudo types are not defined by GCC, they are simply a notational
12243 convenience used in this manual.
12244
12245 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12246 and @code{sw2} are evaluated at run time. They correspond to
12247 register operands in the underlying FR-V instructions.
12248
12249 @code{const} arguments represent immediate operands in the underlying
12250 FR-V instructions. They must be compile-time constants.
12251
12252 @code{acc} arguments are evaluated at compile time and specify the number
12253 of an accumulator register. For example, an @code{acc} argument of 2
12254 selects the ACC2 register.
12255
12256 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12257 number of an IACC register. See @pxref{Other Built-in Functions}
12258 for more details.
12259
12260 @node Directly-mapped Integer Functions
12261 @subsubsection Directly-Mapped Integer Functions
12262
12263 The functions listed below map directly to FR-V I-type instructions.
12264
12265 @multitable @columnfractions .45 .32 .23
12266 @item Function prototype @tab Example usage @tab Assembly output
12267 @item @code{sw1 __ADDSS (sw1, sw1)}
12268 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12269 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12270 @item @code{sw1 __SCAN (sw1, sw1)}
12271 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12272 @tab @code{SCAN @var{a},@var{b},@var{c}}
12273 @item @code{sw1 __SCUTSS (sw1)}
12274 @tab @code{@var{b} = __SCUTSS (@var{a})}
12275 @tab @code{SCUTSS @var{a},@var{b}}
12276 @item @code{sw1 __SLASS (sw1, sw1)}
12277 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12278 @tab @code{SLASS @var{a},@var{b},@var{c}}
12279 @item @code{void __SMASS (sw1, sw1)}
12280 @tab @code{__SMASS (@var{a}, @var{b})}
12281 @tab @code{SMASS @var{a},@var{b}}
12282 @item @code{void __SMSSS (sw1, sw1)}
12283 @tab @code{__SMSSS (@var{a}, @var{b})}
12284 @tab @code{SMSSS @var{a},@var{b}}
12285 @item @code{void __SMU (sw1, sw1)}
12286 @tab @code{__SMU (@var{a}, @var{b})}
12287 @tab @code{SMU @var{a},@var{b}}
12288 @item @code{sw2 __SMUL (sw1, sw1)}
12289 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12290 @tab @code{SMUL @var{a},@var{b},@var{c}}
12291 @item @code{sw1 __SUBSS (sw1, sw1)}
12292 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12293 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12294 @item @code{uw2 __UMUL (uw1, uw1)}
12295 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12296 @tab @code{UMUL @var{a},@var{b},@var{c}}
12297 @end multitable
12298
12299 @node Directly-mapped Media Functions
12300 @subsubsection Directly-Mapped Media Functions
12301
12302 The functions listed below map directly to FR-V M-type instructions.
12303
12304 @multitable @columnfractions .45 .32 .23
12305 @item Function prototype @tab Example usage @tab Assembly output
12306 @item @code{uw1 __MABSHS (sw1)}
12307 @tab @code{@var{b} = __MABSHS (@var{a})}
12308 @tab @code{MABSHS @var{a},@var{b}}
12309 @item @code{void __MADDACCS (acc, acc)}
12310 @tab @code{__MADDACCS (@var{b}, @var{a})}
12311 @tab @code{MADDACCS @var{a},@var{b}}
12312 @item @code{sw1 __MADDHSS (sw1, sw1)}
12313 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12314 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12315 @item @code{uw1 __MADDHUS (uw1, uw1)}
12316 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12317 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12318 @item @code{uw1 __MAND (uw1, uw1)}
12319 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12320 @tab @code{MAND @var{a},@var{b},@var{c}}
12321 @item @code{void __MASACCS (acc, acc)}
12322 @tab @code{__MASACCS (@var{b}, @var{a})}
12323 @tab @code{MASACCS @var{a},@var{b}}
12324 @item @code{uw1 __MAVEH (uw1, uw1)}
12325 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12326 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12327 @item @code{uw2 __MBTOH (uw1)}
12328 @tab @code{@var{b} = __MBTOH (@var{a})}
12329 @tab @code{MBTOH @var{a},@var{b}}
12330 @item @code{void __MBTOHE (uw1 *, uw1)}
12331 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12332 @tab @code{MBTOHE @var{a},@var{b}}
12333 @item @code{void __MCLRACC (acc)}
12334 @tab @code{__MCLRACC (@var{a})}
12335 @tab @code{MCLRACC @var{a}}
12336 @item @code{void __MCLRACCA (void)}
12337 @tab @code{__MCLRACCA ()}
12338 @tab @code{MCLRACCA}
12339 @item @code{uw1 __Mcop1 (uw1, uw1)}
12340 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12341 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12342 @item @code{uw1 __Mcop2 (uw1, uw1)}
12343 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12344 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12345 @item @code{uw1 __MCPLHI (uw2, const)}
12346 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12347 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12348 @item @code{uw1 __MCPLI (uw2, const)}
12349 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12350 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12351 @item @code{void __MCPXIS (acc, sw1, sw1)}
12352 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12353 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12354 @item @code{void __MCPXIU (acc, uw1, uw1)}
12355 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12356 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12357 @item @code{void __MCPXRS (acc, sw1, sw1)}
12358 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12359 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12360 @item @code{void __MCPXRU (acc, uw1, uw1)}
12361 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12362 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12363 @item @code{uw1 __MCUT (acc, uw1)}
12364 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12365 @tab @code{MCUT @var{a},@var{b},@var{c}}
12366 @item @code{uw1 __MCUTSS (acc, sw1)}
12367 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12368 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12369 @item @code{void __MDADDACCS (acc, acc)}
12370 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12371 @tab @code{MDADDACCS @var{a},@var{b}}
12372 @item @code{void __MDASACCS (acc, acc)}
12373 @tab @code{__MDASACCS (@var{b}, @var{a})}
12374 @tab @code{MDASACCS @var{a},@var{b}}
12375 @item @code{uw2 __MDCUTSSI (acc, const)}
12376 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12377 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12378 @item @code{uw2 __MDPACKH (uw2, uw2)}
12379 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12380 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12381 @item @code{uw2 __MDROTLI (uw2, const)}
12382 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12383 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12384 @item @code{void __MDSUBACCS (acc, acc)}
12385 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12386 @tab @code{MDSUBACCS @var{a},@var{b}}
12387 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12388 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12389 @tab @code{MDUNPACKH @var{a},@var{b}}
12390 @item @code{uw2 __MEXPDHD (uw1, const)}
12391 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12392 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12393 @item @code{uw1 __MEXPDHW (uw1, const)}
12394 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12395 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12396 @item @code{uw1 __MHDSETH (uw1, const)}
12397 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12398 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12399 @item @code{sw1 __MHDSETS (const)}
12400 @tab @code{@var{b} = __MHDSETS (@var{a})}
12401 @tab @code{MHDSETS #@var{a},@var{b}}
12402 @item @code{uw1 __MHSETHIH (uw1, const)}
12403 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12404 @tab @code{MHSETHIH #@var{a},@var{b}}
12405 @item @code{sw1 __MHSETHIS (sw1, const)}
12406 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12407 @tab @code{MHSETHIS #@var{a},@var{b}}
12408 @item @code{uw1 __MHSETLOH (uw1, const)}
12409 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12410 @tab @code{MHSETLOH #@var{a},@var{b}}
12411 @item @code{sw1 __MHSETLOS (sw1, const)}
12412 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12413 @tab @code{MHSETLOS #@var{a},@var{b}}
12414 @item @code{uw1 __MHTOB (uw2)}
12415 @tab @code{@var{b} = __MHTOB (@var{a})}
12416 @tab @code{MHTOB @var{a},@var{b}}
12417 @item @code{void __MMACHS (acc, sw1, sw1)}
12418 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12419 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12420 @item @code{void __MMACHU (acc, uw1, uw1)}
12421 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12422 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12423 @item @code{void __MMRDHS (acc, sw1, sw1)}
12424 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12425 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12426 @item @code{void __MMRDHU (acc, uw1, uw1)}
12427 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12428 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12429 @item @code{void __MMULHS (acc, sw1, sw1)}
12430 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12431 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12432 @item @code{void __MMULHU (acc, uw1, uw1)}
12433 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12434 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12435 @item @code{void __MMULXHS (acc, sw1, sw1)}
12436 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12437 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12438 @item @code{void __MMULXHU (acc, uw1, uw1)}
12439 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12440 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12441 @item @code{uw1 __MNOT (uw1)}
12442 @tab @code{@var{b} = __MNOT (@var{a})}
12443 @tab @code{MNOT @var{a},@var{b}}
12444 @item @code{uw1 __MOR (uw1, uw1)}
12445 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12446 @tab @code{MOR @var{a},@var{b},@var{c}}
12447 @item @code{uw1 __MPACKH (uh, uh)}
12448 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12449 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12450 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12451 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12452 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12453 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12454 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12455 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12456 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12457 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12458 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12459 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12460 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12461 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12462 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12463 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12464 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12465 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12466 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12467 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12468 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12469 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12470 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12471 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12472 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12473 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12474 @item @code{void __MQMACHS (acc, sw2, sw2)}
12475 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12476 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12477 @item @code{void __MQMACHU (acc, uw2, uw2)}
12478 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12479 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12480 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12481 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12482 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12483 @item @code{void __MQMULHS (acc, sw2, sw2)}
12484 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12485 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12486 @item @code{void __MQMULHU (acc, uw2, uw2)}
12487 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12488 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12489 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12490 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12491 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12492 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12493 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12494 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12495 @item @code{sw2 __MQSATHS (sw2, sw2)}
12496 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12497 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12498 @item @code{uw2 __MQSLLHI (uw2, int)}
12499 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12500 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12501 @item @code{sw2 __MQSRAHI (sw2, int)}
12502 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12503 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12504 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12505 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12506 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12507 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12508 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12509 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12510 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12511 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12512 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12513 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12514 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12515 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12516 @item @code{uw1 __MRDACC (acc)}
12517 @tab @code{@var{b} = __MRDACC (@var{a})}
12518 @tab @code{MRDACC @var{a},@var{b}}
12519 @item @code{uw1 __MRDACCG (acc)}
12520 @tab @code{@var{b} = __MRDACCG (@var{a})}
12521 @tab @code{MRDACCG @var{a},@var{b}}
12522 @item @code{uw1 __MROTLI (uw1, const)}
12523 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12524 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12525 @item @code{uw1 __MROTRI (uw1, const)}
12526 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12527 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12528 @item @code{sw1 __MSATHS (sw1, sw1)}
12529 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12530 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12531 @item @code{uw1 __MSATHU (uw1, uw1)}
12532 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12533 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12534 @item @code{uw1 __MSLLHI (uw1, const)}
12535 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12536 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12537 @item @code{sw1 __MSRAHI (sw1, const)}
12538 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12539 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12540 @item @code{uw1 __MSRLHI (uw1, const)}
12541 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12542 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12543 @item @code{void __MSUBACCS (acc, acc)}
12544 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12545 @tab @code{MSUBACCS @var{a},@var{b}}
12546 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12547 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12548 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12549 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12550 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12551 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12552 @item @code{void __MTRAP (void)}
12553 @tab @code{__MTRAP ()}
12554 @tab @code{MTRAP}
12555 @item @code{uw2 __MUNPACKH (uw1)}
12556 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12557 @tab @code{MUNPACKH @var{a},@var{b}}
12558 @item @code{uw1 __MWCUT (uw2, uw1)}
12559 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12560 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12561 @item @code{void __MWTACC (acc, uw1)}
12562 @tab @code{__MWTACC (@var{b}, @var{a})}
12563 @tab @code{MWTACC @var{a},@var{b}}
12564 @item @code{void __MWTACCG (acc, uw1)}
12565 @tab @code{__MWTACCG (@var{b}, @var{a})}
12566 @tab @code{MWTACCG @var{a},@var{b}}
12567 @item @code{uw1 __MXOR (uw1, uw1)}
12568 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12569 @tab @code{MXOR @var{a},@var{b},@var{c}}
12570 @end multitable
12571
12572 @node Raw read/write Functions
12573 @subsubsection Raw Read/Write Functions
12574
12575 This sections describes built-in functions related to read and write
12576 instructions to access memory. These functions generate
12577 @code{membar} instructions to flush the I/O load and stores where
12578 appropriate, as described in Fujitsu's manual described above.
12579
12580 @table @code
12581
12582 @item unsigned char __builtin_read8 (void *@var{data})
12583 @item unsigned short __builtin_read16 (void *@var{data})
12584 @item unsigned long __builtin_read32 (void *@var{data})
12585 @item unsigned long long __builtin_read64 (void *@var{data})
12586
12587 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12588 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12589 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12590 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12591 @end table
12592
12593 @node Other Built-in Functions
12594 @subsubsection Other Built-in Functions
12595
12596 This section describes built-in functions that are not named after
12597 a specific FR-V instruction.
12598
12599 @table @code
12600 @item sw2 __IACCreadll (iacc @var{reg})
12601 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12602 for future expansion and must be 0.
12603
12604 @item sw1 __IACCreadl (iacc @var{reg})
12605 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12606 Other values of @var{reg} are rejected as invalid.
12607
12608 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12609 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12610 is reserved for future expansion and must be 0.
12611
12612 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12613 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12614 is 1. Other values of @var{reg} are rejected as invalid.
12615
12616 @item void __data_prefetch0 (const void *@var{x})
12617 Use the @code{dcpl} instruction to load the contents of address @var{x}
12618 into the data cache.
12619
12620 @item void __data_prefetch (const void *@var{x})
12621 Use the @code{nldub} instruction to load the contents of address @var{x}
12622 into the data cache. The instruction is issued in slot I1@.
12623 @end table
12624
12625 @node MIPS DSP Built-in Functions
12626 @subsection MIPS DSP Built-in Functions
12627
12628 The MIPS DSP Application-Specific Extension (ASE) includes new
12629 instructions that are designed to improve the performance of DSP and
12630 media applications. It provides instructions that operate on packed
12631 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12632
12633 GCC supports MIPS DSP operations using both the generic
12634 vector extensions (@pxref{Vector Extensions}) and a collection of
12635 MIPS-specific built-in functions. Both kinds of support are
12636 enabled by the @option{-mdsp} command-line option.
12637
12638 Revision 2 of the ASE was introduced in the second half of 2006.
12639 This revision adds extra instructions to the original ASE, but is
12640 otherwise backwards-compatible with it. You can select revision 2
12641 using the command-line option @option{-mdspr2}; this option implies
12642 @option{-mdsp}.
12643
12644 The SCOUNT and POS bits of the DSP control register are global. The
12645 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12646 POS bits. During optimization, the compiler does not delete these
12647 instructions and it does not delete calls to functions containing
12648 these instructions.
12649
12650 At present, GCC only provides support for operations on 32-bit
12651 vectors. The vector type associated with 8-bit integer data is
12652 usually called @code{v4i8}, the vector type associated with Q7
12653 is usually called @code{v4q7}, the vector type associated with 16-bit
12654 integer data is usually called @code{v2i16}, and the vector type
12655 associated with Q15 is usually called @code{v2q15}. They can be
12656 defined in C as follows:
12657
12658 @smallexample
12659 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12660 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12661 typedef short v2i16 __attribute__ ((vector_size(4)));
12662 typedef short v2q15 __attribute__ ((vector_size(4)));
12663 @end smallexample
12664
12665 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12666 initialized in the same way as aggregates. For example:
12667
12668 @smallexample
12669 v4i8 a = @{1, 2, 3, 4@};
12670 v4i8 b;
12671 b = (v4i8) @{5, 6, 7, 8@};
12672
12673 v2q15 c = @{0x0fcb, 0x3a75@};
12674 v2q15 d;
12675 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12676 @end smallexample
12677
12678 @emph{Note:} The CPU's endianness determines the order in which values
12679 are packed. On little-endian targets, the first value is the least
12680 significant and the last value is the most significant. The opposite
12681 order applies to big-endian targets. For example, the code above
12682 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12683 and @code{4} on big-endian targets.
12684
12685 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12686 representation. As shown in this example, the integer representation
12687 of a Q7 value can be obtained by multiplying the fractional value by
12688 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12689 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12690 @code{0x1.0p31}.
12691
12692 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12693 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12694 and @code{c} and @code{d} are @code{v2q15} values.
12695
12696 @multitable @columnfractions .50 .50
12697 @item C code @tab MIPS instruction
12698 @item @code{a + b} @tab @code{addu.qb}
12699 @item @code{c + d} @tab @code{addq.ph}
12700 @item @code{a - b} @tab @code{subu.qb}
12701 @item @code{c - d} @tab @code{subq.ph}
12702 @end multitable
12703
12704 The table below lists the @code{v2i16} operation for which
12705 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12706 @code{v2i16} values.
12707
12708 @multitable @columnfractions .50 .50
12709 @item C code @tab MIPS instruction
12710 @item @code{e * f} @tab @code{mul.ph}
12711 @end multitable
12712
12713 It is easier to describe the DSP built-in functions if we first define
12714 the following types:
12715
12716 @smallexample
12717 typedef int q31;
12718 typedef int i32;
12719 typedef unsigned int ui32;
12720 typedef long long a64;
12721 @end smallexample
12722
12723 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12724 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12725 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12726 @code{long long}, but we use @code{a64} to indicate values that are
12727 placed in one of the four DSP accumulators (@code{$ac0},
12728 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12729
12730 Also, some built-in functions prefer or require immediate numbers as
12731 parameters, because the corresponding DSP instructions accept both immediate
12732 numbers and register operands, or accept immediate numbers only. The
12733 immediate parameters are listed as follows.
12734
12735 @smallexample
12736 imm0_3: 0 to 3.
12737 imm0_7: 0 to 7.
12738 imm0_15: 0 to 15.
12739 imm0_31: 0 to 31.
12740 imm0_63: 0 to 63.
12741 imm0_255: 0 to 255.
12742 imm_n32_31: -32 to 31.
12743 imm_n512_511: -512 to 511.
12744 @end smallexample
12745
12746 The following built-in functions map directly to a particular MIPS DSP
12747 instruction. Please refer to the architecture specification
12748 for details on what each instruction does.
12749
12750 @smallexample
12751 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12752 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12753 q31 __builtin_mips_addq_s_w (q31, q31)
12754 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12755 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12756 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12757 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12758 q31 __builtin_mips_subq_s_w (q31, q31)
12759 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12760 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12761 i32 __builtin_mips_addsc (i32, i32)
12762 i32 __builtin_mips_addwc (i32, i32)
12763 i32 __builtin_mips_modsub (i32, i32)
12764 i32 __builtin_mips_raddu_w_qb (v4i8)
12765 v2q15 __builtin_mips_absq_s_ph (v2q15)
12766 q31 __builtin_mips_absq_s_w (q31)
12767 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12768 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12769 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12770 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12771 q31 __builtin_mips_preceq_w_phl (v2q15)
12772 q31 __builtin_mips_preceq_w_phr (v2q15)
12773 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12774 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12775 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12776 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12777 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12778 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12779 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12780 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12781 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12782 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12783 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12784 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12785 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12786 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12787 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12788 q31 __builtin_mips_shll_s_w (q31, i32)
12789 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12790 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12791 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12792 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12793 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12794 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12795 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12796 q31 __builtin_mips_shra_r_w (q31, i32)
12797 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12798 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12799 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12800 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12801 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12802 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12803 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12804 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12805 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12806 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12807 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12808 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12809 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12810 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12811 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12812 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12813 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12814 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12815 i32 __builtin_mips_bitrev (i32)
12816 i32 __builtin_mips_insv (i32, i32)
12817 v4i8 __builtin_mips_repl_qb (imm0_255)
12818 v4i8 __builtin_mips_repl_qb (i32)
12819 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12820 v2q15 __builtin_mips_repl_ph (i32)
12821 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12822 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12823 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12824 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12825 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12826 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12827 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12828 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12829 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12830 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12831 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12832 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12833 i32 __builtin_mips_extr_w (a64, imm0_31)
12834 i32 __builtin_mips_extr_w (a64, i32)
12835 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12836 i32 __builtin_mips_extr_s_h (a64, i32)
12837 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12838 i32 __builtin_mips_extr_rs_w (a64, i32)
12839 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12840 i32 __builtin_mips_extr_r_w (a64, i32)
12841 i32 __builtin_mips_extp (a64, imm0_31)
12842 i32 __builtin_mips_extp (a64, i32)
12843 i32 __builtin_mips_extpdp (a64, imm0_31)
12844 i32 __builtin_mips_extpdp (a64, i32)
12845 a64 __builtin_mips_shilo (a64, imm_n32_31)
12846 a64 __builtin_mips_shilo (a64, i32)
12847 a64 __builtin_mips_mthlip (a64, i32)
12848 void __builtin_mips_wrdsp (i32, imm0_63)
12849 i32 __builtin_mips_rddsp (imm0_63)
12850 i32 __builtin_mips_lbux (void *, i32)
12851 i32 __builtin_mips_lhx (void *, i32)
12852 i32 __builtin_mips_lwx (void *, i32)
12853 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12854 i32 __builtin_mips_bposge32 (void)
12855 a64 __builtin_mips_madd (a64, i32, i32);
12856 a64 __builtin_mips_maddu (a64, ui32, ui32);
12857 a64 __builtin_mips_msub (a64, i32, i32);
12858 a64 __builtin_mips_msubu (a64, ui32, ui32);
12859 a64 __builtin_mips_mult (i32, i32);
12860 a64 __builtin_mips_multu (ui32, ui32);
12861 @end smallexample
12862
12863 The following built-in functions map directly to a particular MIPS DSP REV 2
12864 instruction. Please refer to the architecture specification
12865 for details on what each instruction does.
12866
12867 @smallexample
12868 v4q7 __builtin_mips_absq_s_qb (v4q7);
12869 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12870 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12871 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12872 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12873 i32 __builtin_mips_append (i32, i32, imm0_31);
12874 i32 __builtin_mips_balign (i32, i32, imm0_3);
12875 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12876 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12877 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12878 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12879 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12880 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12881 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12882 q31 __builtin_mips_mulq_rs_w (q31, q31);
12883 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12884 q31 __builtin_mips_mulq_s_w (q31, q31);
12885 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12886 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12887 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12888 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12889 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12890 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12891 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12892 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12893 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12894 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12895 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12896 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12897 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12898 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12899 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12900 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12901 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12902 q31 __builtin_mips_addqh_w (q31, q31);
12903 q31 __builtin_mips_addqh_r_w (q31, q31);
12904 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12905 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12906 q31 __builtin_mips_subqh_w (q31, q31);
12907 q31 __builtin_mips_subqh_r_w (q31, q31);
12908 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12909 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12910 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12911 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12912 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12913 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12914 @end smallexample
12915
12916
12917 @node MIPS Paired-Single Support
12918 @subsection MIPS Paired-Single Support
12919
12920 The MIPS64 architecture includes a number of instructions that
12921 operate on pairs of single-precision floating-point values.
12922 Each pair is packed into a 64-bit floating-point register,
12923 with one element being designated the ``upper half'' and
12924 the other being designated the ``lower half''.
12925
12926 GCC supports paired-single operations using both the generic
12927 vector extensions (@pxref{Vector Extensions}) and a collection of
12928 MIPS-specific built-in functions. Both kinds of support are
12929 enabled by the @option{-mpaired-single} command-line option.
12930
12931 The vector type associated with paired-single values is usually
12932 called @code{v2sf}. It can be defined in C as follows:
12933
12934 @smallexample
12935 typedef float v2sf __attribute__ ((vector_size (8)));
12936 @end smallexample
12937
12938 @code{v2sf} values are initialized in the same way as aggregates.
12939 For example:
12940
12941 @smallexample
12942 v2sf a = @{1.5, 9.1@};
12943 v2sf b;
12944 float e, f;
12945 b = (v2sf) @{e, f@};
12946 @end smallexample
12947
12948 @emph{Note:} The CPU's endianness determines which value is stored in
12949 the upper half of a register and which value is stored in the lower half.
12950 On little-endian targets, the first value is the lower one and the second
12951 value is the upper one. The opposite order applies to big-endian targets.
12952 For example, the code above sets the lower half of @code{a} to
12953 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12954
12955 @node MIPS Loongson Built-in Functions
12956 @subsection MIPS Loongson Built-in Functions
12957
12958 GCC provides intrinsics to access the SIMD instructions provided by the
12959 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
12960 available after inclusion of the @code{loongson.h} header file,
12961 operate on the following 64-bit vector types:
12962
12963 @itemize
12964 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12965 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12966 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12967 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12968 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12969 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12970 @end itemize
12971
12972 The intrinsics provided are listed below; each is named after the
12973 machine instruction to which it corresponds, with suffixes added as
12974 appropriate to distinguish intrinsics that expand to the same machine
12975 instruction yet have different argument types. Refer to the architecture
12976 documentation for a description of the functionality of each
12977 instruction.
12978
12979 @smallexample
12980 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12981 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12982 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12983 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12984 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12985 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12986 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12987 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12988 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12989 uint64_t paddd_u (uint64_t s, uint64_t t);
12990 int64_t paddd_s (int64_t s, int64_t t);
12991 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12992 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12993 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12994 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12995 uint64_t pandn_ud (uint64_t s, uint64_t t);
12996 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12997 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12998 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12999 int64_t pandn_sd (int64_t s, int64_t t);
13000 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13001 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13002 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13003 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13004 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13005 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13006 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13007 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13008 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13009 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13010 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13011 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13012 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13013 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13014 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13015 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13016 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13017 uint16x4_t pextrh_u (uint16x4_t s, int field);
13018 int16x4_t pextrh_s (int16x4_t s, int field);
13019 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13020 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13021 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13022 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13023 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13024 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13025 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13026 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13027 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13028 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13029 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13030 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13031 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13032 uint8x8_t pmovmskb_u (uint8x8_t s);
13033 int8x8_t pmovmskb_s (int8x8_t s);
13034 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13035 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13036 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13037 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13038 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13039 uint16x4_t biadd (uint8x8_t s);
13040 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13041 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13042 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13043 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13044 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13045 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13046 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13047 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13048 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13049 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13050 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13051 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13052 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13053 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13054 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13055 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13056 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13057 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13058 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13059 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13060 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13061 uint64_t psubd_u (uint64_t s, uint64_t t);
13062 int64_t psubd_s (int64_t s, int64_t t);
13063 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13064 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13065 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13066 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13067 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13068 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13069 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13070 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13071 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13072 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13073 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13074 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13075 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13076 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13077 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13078 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13079 @end smallexample
13080
13081 @menu
13082 * Paired-Single Arithmetic::
13083 * Paired-Single Built-in Functions::
13084 * MIPS-3D Built-in Functions::
13085 @end menu
13086
13087 @node Paired-Single Arithmetic
13088 @subsubsection Paired-Single Arithmetic
13089
13090 The table below lists the @code{v2sf} operations for which hardware
13091 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13092 values and @code{x} is an integral value.
13093
13094 @multitable @columnfractions .50 .50
13095 @item C code @tab MIPS instruction
13096 @item @code{a + b} @tab @code{add.ps}
13097 @item @code{a - b} @tab @code{sub.ps}
13098 @item @code{-a} @tab @code{neg.ps}
13099 @item @code{a * b} @tab @code{mul.ps}
13100 @item @code{a * b + c} @tab @code{madd.ps}
13101 @item @code{a * b - c} @tab @code{msub.ps}
13102 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13103 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13104 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13105 @end multitable
13106
13107 Note that the multiply-accumulate instructions can be disabled
13108 using the command-line option @code{-mno-fused-madd}.
13109
13110 @node Paired-Single Built-in Functions
13111 @subsubsection Paired-Single Built-in Functions
13112
13113 The following paired-single functions map directly to a particular
13114 MIPS instruction. Please refer to the architecture specification
13115 for details on what each instruction does.
13116
13117 @table @code
13118 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13119 Pair lower lower (@code{pll.ps}).
13120
13121 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13122 Pair upper lower (@code{pul.ps}).
13123
13124 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13125 Pair lower upper (@code{plu.ps}).
13126
13127 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13128 Pair upper upper (@code{puu.ps}).
13129
13130 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13131 Convert pair to paired single (@code{cvt.ps.s}).
13132
13133 @item float __builtin_mips_cvt_s_pl (v2sf)
13134 Convert pair lower to single (@code{cvt.s.pl}).
13135
13136 @item float __builtin_mips_cvt_s_pu (v2sf)
13137 Convert pair upper to single (@code{cvt.s.pu}).
13138
13139 @item v2sf __builtin_mips_abs_ps (v2sf)
13140 Absolute value (@code{abs.ps}).
13141
13142 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13143 Align variable (@code{alnv.ps}).
13144
13145 @emph{Note:} The value of the third parameter must be 0 or 4
13146 modulo 8, otherwise the result is unpredictable. Please read the
13147 instruction description for details.
13148 @end table
13149
13150 The following multi-instruction functions are also available.
13151 In each case, @var{cond} can be any of the 16 floating-point conditions:
13152 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13153 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13154 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13155
13156 @table @code
13157 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13158 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13159 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13160 @code{movt.ps}/@code{movf.ps}).
13161
13162 The @code{movt} functions return the value @var{x} computed by:
13163
13164 @smallexample
13165 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13166 mov.ps @var{x},@var{c}
13167 movt.ps @var{x},@var{d},@var{cc}
13168 @end smallexample
13169
13170 The @code{movf} functions are similar but use @code{movf.ps} instead
13171 of @code{movt.ps}.
13172
13173 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13174 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13175 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13176 @code{bc1t}/@code{bc1f}).
13177
13178 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13179 and return either the upper or lower half of the result. For example:
13180
13181 @smallexample
13182 v2sf a, b;
13183 if (__builtin_mips_upper_c_eq_ps (a, b))
13184 upper_halves_are_equal ();
13185 else
13186 upper_halves_are_unequal ();
13187
13188 if (__builtin_mips_lower_c_eq_ps (a, b))
13189 lower_halves_are_equal ();
13190 else
13191 lower_halves_are_unequal ();
13192 @end smallexample
13193 @end table
13194
13195 @node MIPS-3D Built-in Functions
13196 @subsubsection MIPS-3D Built-in Functions
13197
13198 The MIPS-3D Application-Specific Extension (ASE) includes additional
13199 paired-single instructions that are designed to improve the performance
13200 of 3D graphics operations. Support for these instructions is controlled
13201 by the @option{-mips3d} command-line option.
13202
13203 The functions listed below map directly to a particular MIPS-3D
13204 instruction. Please refer to the architecture specification for
13205 more details on what each instruction does.
13206
13207 @table @code
13208 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13209 Reduction add (@code{addr.ps}).
13210
13211 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13212 Reduction multiply (@code{mulr.ps}).
13213
13214 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13215 Convert paired single to paired word (@code{cvt.pw.ps}).
13216
13217 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13218 Convert paired word to paired single (@code{cvt.ps.pw}).
13219
13220 @item float __builtin_mips_recip1_s (float)
13221 @itemx double __builtin_mips_recip1_d (double)
13222 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13223 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13224
13225 @item float __builtin_mips_recip2_s (float, float)
13226 @itemx double __builtin_mips_recip2_d (double, double)
13227 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13228 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13229
13230 @item float __builtin_mips_rsqrt1_s (float)
13231 @itemx double __builtin_mips_rsqrt1_d (double)
13232 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13233 Reduced-precision reciprocal square root (sequence step 1)
13234 (@code{rsqrt1.@var{fmt}}).
13235
13236 @item float __builtin_mips_rsqrt2_s (float, float)
13237 @itemx double __builtin_mips_rsqrt2_d (double, double)
13238 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13239 Reduced-precision reciprocal square root (sequence step 2)
13240 (@code{rsqrt2.@var{fmt}}).
13241 @end table
13242
13243 The following multi-instruction functions are also available.
13244 In each case, @var{cond} can be any of the 16 floating-point conditions:
13245 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13246 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13247 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13248
13249 @table @code
13250 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13251 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13252 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13253 @code{bc1t}/@code{bc1f}).
13254
13255 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13256 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13257 For example:
13258
13259 @smallexample
13260 float a, b;
13261 if (__builtin_mips_cabs_eq_s (a, b))
13262 true ();
13263 else
13264 false ();
13265 @end smallexample
13266
13267 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13268 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13269 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13270 @code{bc1t}/@code{bc1f}).
13271
13272 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13273 and return either the upper or lower half of the result. For example:
13274
13275 @smallexample
13276 v2sf a, b;
13277 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13278 upper_halves_are_equal ();
13279 else
13280 upper_halves_are_unequal ();
13281
13282 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13283 lower_halves_are_equal ();
13284 else
13285 lower_halves_are_unequal ();
13286 @end smallexample
13287
13288 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13289 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13290 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13291 @code{movt.ps}/@code{movf.ps}).
13292
13293 The @code{movt} functions return the value @var{x} computed by:
13294
13295 @smallexample
13296 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13297 mov.ps @var{x},@var{c}
13298 movt.ps @var{x},@var{d},@var{cc}
13299 @end smallexample
13300
13301 The @code{movf} functions are similar but use @code{movf.ps} instead
13302 of @code{movt.ps}.
13303
13304 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13305 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13306 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13307 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13308 Comparison of two paired-single values
13309 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13310 @code{bc1any2t}/@code{bc1any2f}).
13311
13312 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13313 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13314 result is true and the @code{all} forms return true if both results are true.
13315 For example:
13316
13317 @smallexample
13318 v2sf a, b;
13319 if (__builtin_mips_any_c_eq_ps (a, b))
13320 one_is_true ();
13321 else
13322 both_are_false ();
13323
13324 if (__builtin_mips_all_c_eq_ps (a, b))
13325 both_are_true ();
13326 else
13327 one_is_false ();
13328 @end smallexample
13329
13330 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13331 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13332 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13333 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13334 Comparison of four paired-single values
13335 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13336 @code{bc1any4t}/@code{bc1any4f}).
13337
13338 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13339 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13340 The @code{any} forms return true if any of the four results are true
13341 and the @code{all} forms return true if all four results are true.
13342 For example:
13343
13344 @smallexample
13345 v2sf a, b, c, d;
13346 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13347 some_are_true ();
13348 else
13349 all_are_false ();
13350
13351 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13352 all_are_true ();
13353 else
13354 some_are_false ();
13355 @end smallexample
13356 @end table
13357
13358 @node Other MIPS Built-in Functions
13359 @subsection Other MIPS Built-in Functions
13360
13361 GCC provides other MIPS-specific built-in functions:
13362
13363 @table @code
13364 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13365 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13366 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13367 when this function is available.
13368
13369 @item unsigned int __builtin_mips_get_fcsr (void)
13370 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13371 Get and set the contents of the floating-point control and status register
13372 (FPU control register 31). These functions are only available in hard-float
13373 code but can be called in both MIPS16 and non-MIPS16 contexts.
13374
13375 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13376 register except the condition codes, which GCC assumes are preserved.
13377 @end table
13378
13379 @node MSP430 Built-in Functions
13380 @subsection MSP430 Built-in Functions
13381
13382 GCC provides a couple of special builtin functions to aid in the
13383 writing of interrupt handlers in C.
13384
13385 @table @code
13386 @item __bic_SR_register_on_exit (int @var{mask})
13387 This clears the indicated bits in the saved copy of the status register
13388 currently residing on the stack. This only works inside interrupt
13389 handlers and the changes to the status register will only take affect
13390 once the handler returns.
13391
13392 @item __bis_SR_register_on_exit (int @var{mask})
13393 This sets the indicated bits in the saved copy of the status register
13394 currently residing on the stack. This only works inside interrupt
13395 handlers and the changes to the status register will only take affect
13396 once the handler returns.
13397
13398 @item __delay_cycles (long long @var{cycles})
13399 This inserts an instruction sequence that takes exactly @var{cycles}
13400 cycles (between 0 and about 17E9) to complete. The inserted sequence
13401 may use jumps, loops, or no-ops, and does not interfere with any other
13402 instructions. Note that @var{cycles} must be a compile-time constant
13403 integer - that is, you must pass a number, not a variable that may be
13404 optimized to a constant later. The number of cycles delayed by this
13405 builtin is exact.
13406 @end table
13407
13408 @node NDS32 Built-in Functions
13409 @subsection NDS32 Built-in Functions
13410
13411 These built-in functions are available for the NDS32 target:
13412
13413 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13414 Insert an ISYNC instruction into the instruction stream where
13415 @var{addr} is an instruction address for serialization.
13416 @end deftypefn
13417
13418 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13419 Insert an ISB instruction into the instruction stream.
13420 @end deftypefn
13421
13422 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13423 Return the content of a system register which is mapped by @var{sr}.
13424 @end deftypefn
13425
13426 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13427 Return the content of a user space register which is mapped by @var{usr}.
13428 @end deftypefn
13429
13430 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13431 Move the @var{value} to a system register which is mapped by @var{sr}.
13432 @end deftypefn
13433
13434 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13435 Move the @var{value} to a user space register which is mapped by @var{usr}.
13436 @end deftypefn
13437
13438 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13439 Enable global interrupt.
13440 @end deftypefn
13441
13442 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13443 Disable global interrupt.
13444 @end deftypefn
13445
13446 @node picoChip Built-in Functions
13447 @subsection picoChip Built-in Functions
13448
13449 GCC provides an interface to selected machine instructions from the
13450 picoChip instruction set.
13451
13452 @table @code
13453 @item int __builtin_sbc (int @var{value})
13454 Sign bit count. Return the number of consecutive bits in @var{value}
13455 that have the same value as the sign bit. The result is the number of
13456 leading sign bits minus one, giving the number of redundant sign bits in
13457 @var{value}.
13458
13459 @item int __builtin_byteswap (int @var{value})
13460 Byte swap. Return the result of swapping the upper and lower bytes of
13461 @var{value}.
13462
13463 @item int __builtin_brev (int @var{value})
13464 Bit reversal. Return the result of reversing the bits in
13465 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13466 and so on.
13467
13468 @item int __builtin_adds (int @var{x}, int @var{y})
13469 Saturating addition. Return the result of adding @var{x} and @var{y},
13470 storing the value 32767 if the result overflows.
13471
13472 @item int __builtin_subs (int @var{x}, int @var{y})
13473 Saturating subtraction. Return the result of subtracting @var{y} from
13474 @var{x}, storing the value @minus{}32768 if the result overflows.
13475
13476 @item void __builtin_halt (void)
13477 Halt. The processor stops execution. This built-in is useful for
13478 implementing assertions.
13479
13480 @end table
13481
13482 @node PowerPC Built-in Functions
13483 @subsection PowerPC Built-in Functions
13484
13485 These built-in functions are available for the PowerPC family of
13486 processors:
13487 @smallexample
13488 float __builtin_recipdivf (float, float);
13489 float __builtin_rsqrtf (float);
13490 double __builtin_recipdiv (double, double);
13491 double __builtin_rsqrt (double);
13492 uint64_t __builtin_ppc_get_timebase ();
13493 unsigned long __builtin_ppc_mftb ();
13494 double __builtin_unpack_longdouble (long double, int);
13495 long double __builtin_pack_longdouble (double, double);
13496 @end smallexample
13497
13498 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13499 @code{__builtin_rsqrtf} functions generate multiple instructions to
13500 implement the reciprocal sqrt functionality using reciprocal sqrt
13501 estimate instructions.
13502
13503 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13504 functions generate multiple instructions to implement division using
13505 the reciprocal estimate instructions.
13506
13507 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13508 functions generate instructions to read the Time Base Register. The
13509 @code{__builtin_ppc_get_timebase} function may generate multiple
13510 instructions and always returns the 64 bits of the Time Base Register.
13511 The @code{__builtin_ppc_mftb} function always generates one instruction and
13512 returns the Time Base Register value as an unsigned long, throwing away
13513 the most significant word on 32-bit environments.
13514
13515 The following built-in functions are available for the PowerPC family
13516 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13517 or @option{-mpopcntd}):
13518 @smallexample
13519 long __builtin_bpermd (long, long);
13520 int __builtin_divwe (int, int);
13521 int __builtin_divweo (int, int);
13522 unsigned int __builtin_divweu (unsigned int, unsigned int);
13523 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13524 long __builtin_divde (long, long);
13525 long __builtin_divdeo (long, long);
13526 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13527 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13528 unsigned int cdtbcd (unsigned int);
13529 unsigned int cbcdtd (unsigned int);
13530 unsigned int addg6s (unsigned int, unsigned int);
13531 @end smallexample
13532
13533 The @code{__builtin_divde}, @code{__builtin_divdeo},
13534 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13535 64-bit environment support ISA 2.06 or later.
13536
13537 The following built-in functions are available for the PowerPC family
13538 of processors when hardware decimal floating point
13539 (@option{-mhard-dfp}) is available:
13540 @smallexample
13541 _Decimal64 __builtin_dxex (_Decimal64);
13542 _Decimal128 __builtin_dxexq (_Decimal128);
13543 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13544 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13545 _Decimal64 __builtin_denbcd (int, _Decimal64);
13546 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13547 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13548 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13549 _Decimal64 __builtin_dscli (_Decimal64, int);
13550 _Decimal128 __builtin_dscliq (_Decimal128, int);
13551 _Decimal64 __builtin_dscri (_Decimal64, int);
13552 _Decimal128 __builtin_dscriq (_Decimal128, int);
13553 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13554 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13555 @end smallexample
13556
13557 The following built-in functions are available for the PowerPC family
13558 of processors when the Vector Scalar (vsx) instruction set is
13559 available:
13560 @smallexample
13561 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13562 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13563 unsigned long long);
13564 @end smallexample
13565
13566 @node PowerPC AltiVec/VSX Built-in Functions
13567 @subsection PowerPC AltiVec Built-in Functions
13568
13569 GCC provides an interface for the PowerPC family of processors to access
13570 the AltiVec operations described in Motorola's AltiVec Programming
13571 Interface Manual. The interface is made available by including
13572 @code{<altivec.h>} and using @option{-maltivec} and
13573 @option{-mabi=altivec}. The interface supports the following vector
13574 types.
13575
13576 @smallexample
13577 vector unsigned char
13578 vector signed char
13579 vector bool char
13580
13581 vector unsigned short
13582 vector signed short
13583 vector bool short
13584 vector pixel
13585
13586 vector unsigned int
13587 vector signed int
13588 vector bool int
13589 vector float
13590 @end smallexample
13591
13592 If @option{-mvsx} is used the following additional vector types are
13593 implemented.
13594
13595 @smallexample
13596 vector unsigned long
13597 vector signed long
13598 vector double
13599 @end smallexample
13600
13601 The long types are only implemented for 64-bit code generation, and
13602 the long type is only used in the floating point/integer conversion
13603 instructions.
13604
13605 GCC's implementation of the high-level language interface available from
13606 C and C++ code differs from Motorola's documentation in several ways.
13607
13608 @itemize @bullet
13609
13610 @item
13611 A vector constant is a list of constant expressions within curly braces.
13612
13613 @item
13614 A vector initializer requires no cast if the vector constant is of the
13615 same type as the variable it is initializing.
13616
13617 @item
13618 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13619 vector type is the default signedness of the base type. The default
13620 varies depending on the operating system, so a portable program should
13621 always specify the signedness.
13622
13623 @item
13624 Compiling with @option{-maltivec} adds keywords @code{__vector},
13625 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13626 @code{bool}. When compiling ISO C, the context-sensitive substitution
13627 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13628 disabled. To use them, you must include @code{<altivec.h>} instead.
13629
13630 @item
13631 GCC allows using a @code{typedef} name as the type specifier for a
13632 vector type.
13633
13634 @item
13635 For C, overloaded functions are implemented with macros so the following
13636 does not work:
13637
13638 @smallexample
13639 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13640 @end smallexample
13641
13642 @noindent
13643 Since @code{vec_add} is a macro, the vector constant in the example
13644 is treated as four separate arguments. Wrap the entire argument in
13645 parentheses for this to work.
13646 @end itemize
13647
13648 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13649 Internally, GCC uses built-in functions to achieve the functionality in
13650 the aforementioned header file, but they are not supported and are
13651 subject to change without notice.
13652
13653 The following interfaces are supported for the generic and specific
13654 AltiVec operations and the AltiVec predicates. In cases where there
13655 is a direct mapping between generic and specific operations, only the
13656 generic names are shown here, although the specific operations can also
13657 be used.
13658
13659 Arguments that are documented as @code{const int} require literal
13660 integral values within the range required for that operation.
13661
13662 @smallexample
13663 vector signed char vec_abs (vector signed char);
13664 vector signed short vec_abs (vector signed short);
13665 vector signed int vec_abs (vector signed int);
13666 vector float vec_abs (vector float);
13667
13668 vector signed char vec_abss (vector signed char);
13669 vector signed short vec_abss (vector signed short);
13670 vector signed int vec_abss (vector signed int);
13671
13672 vector signed char vec_add (vector bool char, vector signed char);
13673 vector signed char vec_add (vector signed char, vector bool char);
13674 vector signed char vec_add (vector signed char, vector signed char);
13675 vector unsigned char vec_add (vector bool char, vector unsigned char);
13676 vector unsigned char vec_add (vector unsigned char, vector bool char);
13677 vector unsigned char vec_add (vector unsigned char,
13678 vector unsigned char);
13679 vector signed short vec_add (vector bool short, vector signed short);
13680 vector signed short vec_add (vector signed short, vector bool short);
13681 vector signed short vec_add (vector signed short, vector signed short);
13682 vector unsigned short vec_add (vector bool short,
13683 vector unsigned short);
13684 vector unsigned short vec_add (vector unsigned short,
13685 vector bool short);
13686 vector unsigned short vec_add (vector unsigned short,
13687 vector unsigned short);
13688 vector signed int vec_add (vector bool int, vector signed int);
13689 vector signed int vec_add (vector signed int, vector bool int);
13690 vector signed int vec_add (vector signed int, vector signed int);
13691 vector unsigned int vec_add (vector bool int, vector unsigned int);
13692 vector unsigned int vec_add (vector unsigned int, vector bool int);
13693 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13694 vector float vec_add (vector float, vector float);
13695
13696 vector float vec_vaddfp (vector float, vector float);
13697
13698 vector signed int vec_vadduwm (vector bool int, vector signed int);
13699 vector signed int vec_vadduwm (vector signed int, vector bool int);
13700 vector signed int vec_vadduwm (vector signed int, vector signed int);
13701 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13702 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13703 vector unsigned int vec_vadduwm (vector unsigned int,
13704 vector unsigned int);
13705
13706 vector signed short vec_vadduhm (vector bool short,
13707 vector signed short);
13708 vector signed short vec_vadduhm (vector signed short,
13709 vector bool short);
13710 vector signed short vec_vadduhm (vector signed short,
13711 vector signed short);
13712 vector unsigned short vec_vadduhm (vector bool short,
13713 vector unsigned short);
13714 vector unsigned short vec_vadduhm (vector unsigned short,
13715 vector bool short);
13716 vector unsigned short vec_vadduhm (vector unsigned short,
13717 vector unsigned short);
13718
13719 vector signed char vec_vaddubm (vector bool char, vector signed char);
13720 vector signed char vec_vaddubm (vector signed char, vector bool char);
13721 vector signed char vec_vaddubm (vector signed char, vector signed char);
13722 vector unsigned char vec_vaddubm (vector bool char,
13723 vector unsigned char);
13724 vector unsigned char vec_vaddubm (vector unsigned char,
13725 vector bool char);
13726 vector unsigned char vec_vaddubm (vector unsigned char,
13727 vector unsigned char);
13728
13729 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13730
13731 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13732 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13733 vector unsigned char vec_adds (vector unsigned char,
13734 vector unsigned char);
13735 vector signed char vec_adds (vector bool char, vector signed char);
13736 vector signed char vec_adds (vector signed char, vector bool char);
13737 vector signed char vec_adds (vector signed char, vector signed char);
13738 vector unsigned short vec_adds (vector bool short,
13739 vector unsigned short);
13740 vector unsigned short vec_adds (vector unsigned short,
13741 vector bool short);
13742 vector unsigned short vec_adds (vector unsigned short,
13743 vector unsigned short);
13744 vector signed short vec_adds (vector bool short, vector signed short);
13745 vector signed short vec_adds (vector signed short, vector bool short);
13746 vector signed short vec_adds (vector signed short, vector signed short);
13747 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13748 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13749 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13750 vector signed int vec_adds (vector bool int, vector signed int);
13751 vector signed int vec_adds (vector signed int, vector bool int);
13752 vector signed int vec_adds (vector signed int, vector signed int);
13753
13754 vector signed int vec_vaddsws (vector bool int, vector signed int);
13755 vector signed int vec_vaddsws (vector signed int, vector bool int);
13756 vector signed int vec_vaddsws (vector signed int, vector signed int);
13757
13758 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13759 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13760 vector unsigned int vec_vadduws (vector unsigned int,
13761 vector unsigned int);
13762
13763 vector signed short vec_vaddshs (vector bool short,
13764 vector signed short);
13765 vector signed short vec_vaddshs (vector signed short,
13766 vector bool short);
13767 vector signed short vec_vaddshs (vector signed short,
13768 vector signed short);
13769
13770 vector unsigned short vec_vadduhs (vector bool short,
13771 vector unsigned short);
13772 vector unsigned short vec_vadduhs (vector unsigned short,
13773 vector bool short);
13774 vector unsigned short vec_vadduhs (vector unsigned short,
13775 vector unsigned short);
13776
13777 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13778 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13779 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13780
13781 vector unsigned char vec_vaddubs (vector bool char,
13782 vector unsigned char);
13783 vector unsigned char vec_vaddubs (vector unsigned char,
13784 vector bool char);
13785 vector unsigned char vec_vaddubs (vector unsigned char,
13786 vector unsigned char);
13787
13788 vector float vec_and (vector float, vector float);
13789 vector float vec_and (vector float, vector bool int);
13790 vector float vec_and (vector bool int, vector float);
13791 vector bool int vec_and (vector bool int, vector bool int);
13792 vector signed int vec_and (vector bool int, vector signed int);
13793 vector signed int vec_and (vector signed int, vector bool int);
13794 vector signed int vec_and (vector signed int, vector signed int);
13795 vector unsigned int vec_and (vector bool int, vector unsigned int);
13796 vector unsigned int vec_and (vector unsigned int, vector bool int);
13797 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13798 vector bool short vec_and (vector bool short, vector bool short);
13799 vector signed short vec_and (vector bool short, vector signed short);
13800 vector signed short vec_and (vector signed short, vector bool short);
13801 vector signed short vec_and (vector signed short, vector signed short);
13802 vector unsigned short vec_and (vector bool short,
13803 vector unsigned short);
13804 vector unsigned short vec_and (vector unsigned short,
13805 vector bool short);
13806 vector unsigned short vec_and (vector unsigned short,
13807 vector unsigned short);
13808 vector signed char vec_and (vector bool char, vector signed char);
13809 vector bool char vec_and (vector bool char, vector bool char);
13810 vector signed char vec_and (vector signed char, vector bool char);
13811 vector signed char vec_and (vector signed char, vector signed char);
13812 vector unsigned char vec_and (vector bool char, vector unsigned char);
13813 vector unsigned char vec_and (vector unsigned char, vector bool char);
13814 vector unsigned char vec_and (vector unsigned char,
13815 vector unsigned char);
13816
13817 vector float vec_andc (vector float, vector float);
13818 vector float vec_andc (vector float, vector bool int);
13819 vector float vec_andc (vector bool int, vector float);
13820 vector bool int vec_andc (vector bool int, vector bool int);
13821 vector signed int vec_andc (vector bool int, vector signed int);
13822 vector signed int vec_andc (vector signed int, vector bool int);
13823 vector signed int vec_andc (vector signed int, vector signed int);
13824 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13825 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13826 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13827 vector bool short vec_andc (vector bool short, vector bool short);
13828 vector signed short vec_andc (vector bool short, vector signed short);
13829 vector signed short vec_andc (vector signed short, vector bool short);
13830 vector signed short vec_andc (vector signed short, vector signed short);
13831 vector unsigned short vec_andc (vector bool short,
13832 vector unsigned short);
13833 vector unsigned short vec_andc (vector unsigned short,
13834 vector bool short);
13835 vector unsigned short vec_andc (vector unsigned short,
13836 vector unsigned short);
13837 vector signed char vec_andc (vector bool char, vector signed char);
13838 vector bool char vec_andc (vector bool char, vector bool char);
13839 vector signed char vec_andc (vector signed char, vector bool char);
13840 vector signed char vec_andc (vector signed char, vector signed char);
13841 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13842 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13843 vector unsigned char vec_andc (vector unsigned char,
13844 vector unsigned char);
13845
13846 vector unsigned char vec_avg (vector unsigned char,
13847 vector unsigned char);
13848 vector signed char vec_avg (vector signed char, vector signed char);
13849 vector unsigned short vec_avg (vector unsigned short,
13850 vector unsigned short);
13851 vector signed short vec_avg (vector signed short, vector signed short);
13852 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13853 vector signed int vec_avg (vector signed int, vector signed int);
13854
13855 vector signed int vec_vavgsw (vector signed int, vector signed int);
13856
13857 vector unsigned int vec_vavguw (vector unsigned int,
13858 vector unsigned int);
13859
13860 vector signed short vec_vavgsh (vector signed short,
13861 vector signed short);
13862
13863 vector unsigned short vec_vavguh (vector unsigned short,
13864 vector unsigned short);
13865
13866 vector signed char vec_vavgsb (vector signed char, vector signed char);
13867
13868 vector unsigned char vec_vavgub (vector unsigned char,
13869 vector unsigned char);
13870
13871 vector float vec_copysign (vector float);
13872
13873 vector float vec_ceil (vector float);
13874
13875 vector signed int vec_cmpb (vector float, vector float);
13876
13877 vector bool char vec_cmpeq (vector signed char, vector signed char);
13878 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13879 vector bool short vec_cmpeq (vector signed short, vector signed short);
13880 vector bool short vec_cmpeq (vector unsigned short,
13881 vector unsigned short);
13882 vector bool int vec_cmpeq (vector signed int, vector signed int);
13883 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13884 vector bool int vec_cmpeq (vector float, vector float);
13885
13886 vector bool int vec_vcmpeqfp (vector float, vector float);
13887
13888 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13889 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13890
13891 vector bool short vec_vcmpequh (vector signed short,
13892 vector signed short);
13893 vector bool short vec_vcmpequh (vector unsigned short,
13894 vector unsigned short);
13895
13896 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13897 vector bool char vec_vcmpequb (vector unsigned char,
13898 vector unsigned char);
13899
13900 vector bool int vec_cmpge (vector float, vector float);
13901
13902 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13903 vector bool char vec_cmpgt (vector signed char, vector signed char);
13904 vector bool short vec_cmpgt (vector unsigned short,
13905 vector unsigned short);
13906 vector bool short vec_cmpgt (vector signed short, vector signed short);
13907 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13908 vector bool int vec_cmpgt (vector signed int, vector signed int);
13909 vector bool int vec_cmpgt (vector float, vector float);
13910
13911 vector bool int vec_vcmpgtfp (vector float, vector float);
13912
13913 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13914
13915 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13916
13917 vector bool short vec_vcmpgtsh (vector signed short,
13918 vector signed short);
13919
13920 vector bool short vec_vcmpgtuh (vector unsigned short,
13921 vector unsigned short);
13922
13923 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13924
13925 vector bool char vec_vcmpgtub (vector unsigned char,
13926 vector unsigned char);
13927
13928 vector bool int vec_cmple (vector float, vector float);
13929
13930 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13931 vector bool char vec_cmplt (vector signed char, vector signed char);
13932 vector bool short vec_cmplt (vector unsigned short,
13933 vector unsigned short);
13934 vector bool short vec_cmplt (vector signed short, vector signed short);
13935 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13936 vector bool int vec_cmplt (vector signed int, vector signed int);
13937 vector bool int vec_cmplt (vector float, vector float);
13938
13939 vector float vec_cpsgn (vector float, vector float);
13940
13941 vector float vec_ctf (vector unsigned int, const int);
13942 vector float vec_ctf (vector signed int, const int);
13943 vector double vec_ctf (vector unsigned long, const int);
13944 vector double vec_ctf (vector signed long, const int);
13945
13946 vector float vec_vcfsx (vector signed int, const int);
13947
13948 vector float vec_vcfux (vector unsigned int, const int);
13949
13950 vector signed int vec_cts (vector float, const int);
13951 vector signed long vec_cts (vector double, const int);
13952
13953 vector unsigned int vec_ctu (vector float, const int);
13954 vector unsigned long vec_ctu (vector double, const int);
13955
13956 void vec_dss (const int);
13957
13958 void vec_dssall (void);
13959
13960 void vec_dst (const vector unsigned char *, int, const int);
13961 void vec_dst (const vector signed char *, int, const int);
13962 void vec_dst (const vector bool char *, int, const int);
13963 void vec_dst (const vector unsigned short *, int, const int);
13964 void vec_dst (const vector signed short *, int, const int);
13965 void vec_dst (const vector bool short *, int, const int);
13966 void vec_dst (const vector pixel *, int, const int);
13967 void vec_dst (const vector unsigned int *, int, const int);
13968 void vec_dst (const vector signed int *, int, const int);
13969 void vec_dst (const vector bool int *, int, const int);
13970 void vec_dst (const vector float *, int, const int);
13971 void vec_dst (const unsigned char *, int, const int);
13972 void vec_dst (const signed char *, int, const int);
13973 void vec_dst (const unsigned short *, int, const int);
13974 void vec_dst (const short *, int, const int);
13975 void vec_dst (const unsigned int *, int, const int);
13976 void vec_dst (const int *, int, const int);
13977 void vec_dst (const unsigned long *, int, const int);
13978 void vec_dst (const long *, int, const int);
13979 void vec_dst (const float *, int, const int);
13980
13981 void vec_dstst (const vector unsigned char *, int, const int);
13982 void vec_dstst (const vector signed char *, int, const int);
13983 void vec_dstst (const vector bool char *, int, const int);
13984 void vec_dstst (const vector unsigned short *, int, const int);
13985 void vec_dstst (const vector signed short *, int, const int);
13986 void vec_dstst (const vector bool short *, int, const int);
13987 void vec_dstst (const vector pixel *, int, const int);
13988 void vec_dstst (const vector unsigned int *, int, const int);
13989 void vec_dstst (const vector signed int *, int, const int);
13990 void vec_dstst (const vector bool int *, int, const int);
13991 void vec_dstst (const vector float *, int, const int);
13992 void vec_dstst (const unsigned char *, int, const int);
13993 void vec_dstst (const signed char *, int, const int);
13994 void vec_dstst (const unsigned short *, int, const int);
13995 void vec_dstst (const short *, int, const int);
13996 void vec_dstst (const unsigned int *, int, const int);
13997 void vec_dstst (const int *, int, const int);
13998 void vec_dstst (const unsigned long *, int, const int);
13999 void vec_dstst (const long *, int, const int);
14000 void vec_dstst (const float *, int, const int);
14001
14002 void vec_dststt (const vector unsigned char *, int, const int);
14003 void vec_dststt (const vector signed char *, int, const int);
14004 void vec_dststt (const vector bool char *, int, const int);
14005 void vec_dststt (const vector unsigned short *, int, const int);
14006 void vec_dststt (const vector signed short *, int, const int);
14007 void vec_dststt (const vector bool short *, int, const int);
14008 void vec_dststt (const vector pixel *, int, const int);
14009 void vec_dststt (const vector unsigned int *, int, const int);
14010 void vec_dststt (const vector signed int *, int, const int);
14011 void vec_dststt (const vector bool int *, int, const int);
14012 void vec_dststt (const vector float *, int, const int);
14013 void vec_dststt (const unsigned char *, int, const int);
14014 void vec_dststt (const signed char *, int, const int);
14015 void vec_dststt (const unsigned short *, int, const int);
14016 void vec_dststt (const short *, int, const int);
14017 void vec_dststt (const unsigned int *, int, const int);
14018 void vec_dststt (const int *, int, const int);
14019 void vec_dststt (const unsigned long *, int, const int);
14020 void vec_dststt (const long *, int, const int);
14021 void vec_dststt (const float *, int, const int);
14022
14023 void vec_dstt (const vector unsigned char *, int, const int);
14024 void vec_dstt (const vector signed char *, int, const int);
14025 void vec_dstt (const vector bool char *, int, const int);
14026 void vec_dstt (const vector unsigned short *, int, const int);
14027 void vec_dstt (const vector signed short *, int, const int);
14028 void vec_dstt (const vector bool short *, int, const int);
14029 void vec_dstt (const vector pixel *, int, const int);
14030 void vec_dstt (const vector unsigned int *, int, const int);
14031 void vec_dstt (const vector signed int *, int, const int);
14032 void vec_dstt (const vector bool int *, int, const int);
14033 void vec_dstt (const vector float *, int, const int);
14034 void vec_dstt (const unsigned char *, int, const int);
14035 void vec_dstt (const signed char *, int, const int);
14036 void vec_dstt (const unsigned short *, int, const int);
14037 void vec_dstt (const short *, int, const int);
14038 void vec_dstt (const unsigned int *, int, const int);
14039 void vec_dstt (const int *, int, const int);
14040 void vec_dstt (const unsigned long *, int, const int);
14041 void vec_dstt (const long *, int, const int);
14042 void vec_dstt (const float *, int, const int);
14043
14044 vector float vec_expte (vector float);
14045
14046 vector float vec_floor (vector float);
14047
14048 vector float vec_ld (int, const vector float *);
14049 vector float vec_ld (int, const float *);
14050 vector bool int vec_ld (int, const vector bool int *);
14051 vector signed int vec_ld (int, const vector signed int *);
14052 vector signed int vec_ld (int, const int *);
14053 vector signed int vec_ld (int, const long *);
14054 vector unsigned int vec_ld (int, const vector unsigned int *);
14055 vector unsigned int vec_ld (int, const unsigned int *);
14056 vector unsigned int vec_ld (int, const unsigned long *);
14057 vector bool short vec_ld (int, const vector bool short *);
14058 vector pixel vec_ld (int, const vector pixel *);
14059 vector signed short vec_ld (int, const vector signed short *);
14060 vector signed short vec_ld (int, const short *);
14061 vector unsigned short vec_ld (int, const vector unsigned short *);
14062 vector unsigned short vec_ld (int, const unsigned short *);
14063 vector bool char vec_ld (int, const vector bool char *);
14064 vector signed char vec_ld (int, const vector signed char *);
14065 vector signed char vec_ld (int, const signed char *);
14066 vector unsigned char vec_ld (int, const vector unsigned char *);
14067 vector unsigned char vec_ld (int, const unsigned char *);
14068
14069 vector signed char vec_lde (int, const signed char *);
14070 vector unsigned char vec_lde (int, const unsigned char *);
14071 vector signed short vec_lde (int, const short *);
14072 vector unsigned short vec_lde (int, const unsigned short *);
14073 vector float vec_lde (int, const float *);
14074 vector signed int vec_lde (int, const int *);
14075 vector unsigned int vec_lde (int, const unsigned int *);
14076 vector signed int vec_lde (int, const long *);
14077 vector unsigned int vec_lde (int, const unsigned long *);
14078
14079 vector float vec_lvewx (int, float *);
14080 vector signed int vec_lvewx (int, int *);
14081 vector unsigned int vec_lvewx (int, unsigned int *);
14082 vector signed int vec_lvewx (int, long *);
14083 vector unsigned int vec_lvewx (int, unsigned long *);
14084
14085 vector signed short vec_lvehx (int, short *);
14086 vector unsigned short vec_lvehx (int, unsigned short *);
14087
14088 vector signed char vec_lvebx (int, char *);
14089 vector unsigned char vec_lvebx (int, unsigned char *);
14090
14091 vector float vec_ldl (int, const vector float *);
14092 vector float vec_ldl (int, const float *);
14093 vector bool int vec_ldl (int, const vector bool int *);
14094 vector signed int vec_ldl (int, const vector signed int *);
14095 vector signed int vec_ldl (int, const int *);
14096 vector signed int vec_ldl (int, const long *);
14097 vector unsigned int vec_ldl (int, const vector unsigned int *);
14098 vector unsigned int vec_ldl (int, const unsigned int *);
14099 vector unsigned int vec_ldl (int, const unsigned long *);
14100 vector bool short vec_ldl (int, const vector bool short *);
14101 vector pixel vec_ldl (int, const vector pixel *);
14102 vector signed short vec_ldl (int, const vector signed short *);
14103 vector signed short vec_ldl (int, const short *);
14104 vector unsigned short vec_ldl (int, const vector unsigned short *);
14105 vector unsigned short vec_ldl (int, const unsigned short *);
14106 vector bool char vec_ldl (int, const vector bool char *);
14107 vector signed char vec_ldl (int, const vector signed char *);
14108 vector signed char vec_ldl (int, const signed char *);
14109 vector unsigned char vec_ldl (int, const vector unsigned char *);
14110 vector unsigned char vec_ldl (int, const unsigned char *);
14111
14112 vector float vec_loge (vector float);
14113
14114 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14115 vector unsigned char vec_lvsl (int, const volatile signed char *);
14116 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14117 vector unsigned char vec_lvsl (int, const volatile short *);
14118 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14119 vector unsigned char vec_lvsl (int, const volatile int *);
14120 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14121 vector unsigned char vec_lvsl (int, const volatile long *);
14122 vector unsigned char vec_lvsl (int, const volatile float *);
14123
14124 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14125 vector unsigned char vec_lvsr (int, const volatile signed char *);
14126 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14127 vector unsigned char vec_lvsr (int, const volatile short *);
14128 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14129 vector unsigned char vec_lvsr (int, const volatile int *);
14130 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14131 vector unsigned char vec_lvsr (int, const volatile long *);
14132 vector unsigned char vec_lvsr (int, const volatile float *);
14133
14134 vector float vec_madd (vector float, vector float, vector float);
14135
14136 vector signed short vec_madds (vector signed short,
14137 vector signed short,
14138 vector signed short);
14139
14140 vector unsigned char vec_max (vector bool char, vector unsigned char);
14141 vector unsigned char vec_max (vector unsigned char, vector bool char);
14142 vector unsigned char vec_max (vector unsigned char,
14143 vector unsigned char);
14144 vector signed char vec_max (vector bool char, vector signed char);
14145 vector signed char vec_max (vector signed char, vector bool char);
14146 vector signed char vec_max (vector signed char, vector signed char);
14147 vector unsigned short vec_max (vector bool short,
14148 vector unsigned short);
14149 vector unsigned short vec_max (vector unsigned short,
14150 vector bool short);
14151 vector unsigned short vec_max (vector unsigned short,
14152 vector unsigned short);
14153 vector signed short vec_max (vector bool short, vector signed short);
14154 vector signed short vec_max (vector signed short, vector bool short);
14155 vector signed short vec_max (vector signed short, vector signed short);
14156 vector unsigned int vec_max (vector bool int, vector unsigned int);
14157 vector unsigned int vec_max (vector unsigned int, vector bool int);
14158 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14159 vector signed int vec_max (vector bool int, vector signed int);
14160 vector signed int vec_max (vector signed int, vector bool int);
14161 vector signed int vec_max (vector signed int, vector signed int);
14162 vector float vec_max (vector float, vector float);
14163
14164 vector float vec_vmaxfp (vector float, vector float);
14165
14166 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14167 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14168 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14169
14170 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14171 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14172 vector unsigned int vec_vmaxuw (vector unsigned int,
14173 vector unsigned int);
14174
14175 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14176 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14177 vector signed short vec_vmaxsh (vector signed short,
14178 vector signed short);
14179
14180 vector unsigned short vec_vmaxuh (vector bool short,
14181 vector unsigned short);
14182 vector unsigned short vec_vmaxuh (vector unsigned short,
14183 vector bool short);
14184 vector unsigned short vec_vmaxuh (vector unsigned short,
14185 vector unsigned short);
14186
14187 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14188 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14189 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14190
14191 vector unsigned char vec_vmaxub (vector bool char,
14192 vector unsigned char);
14193 vector unsigned char vec_vmaxub (vector unsigned char,
14194 vector bool char);
14195 vector unsigned char vec_vmaxub (vector unsigned char,
14196 vector unsigned char);
14197
14198 vector bool char vec_mergeh (vector bool char, vector bool char);
14199 vector signed char vec_mergeh (vector signed char, vector signed char);
14200 vector unsigned char vec_mergeh (vector unsigned char,
14201 vector unsigned char);
14202 vector bool short vec_mergeh (vector bool short, vector bool short);
14203 vector pixel vec_mergeh (vector pixel, vector pixel);
14204 vector signed short vec_mergeh (vector signed short,
14205 vector signed short);
14206 vector unsigned short vec_mergeh (vector unsigned short,
14207 vector unsigned short);
14208 vector float vec_mergeh (vector float, vector float);
14209 vector bool int vec_mergeh (vector bool int, vector bool int);
14210 vector signed int vec_mergeh (vector signed int, vector signed int);
14211 vector unsigned int vec_mergeh (vector unsigned int,
14212 vector unsigned int);
14213
14214 vector float vec_vmrghw (vector float, vector float);
14215 vector bool int vec_vmrghw (vector bool int, vector bool int);
14216 vector signed int vec_vmrghw (vector signed int, vector signed int);
14217 vector unsigned int vec_vmrghw (vector unsigned int,
14218 vector unsigned int);
14219
14220 vector bool short vec_vmrghh (vector bool short, vector bool short);
14221 vector signed short vec_vmrghh (vector signed short,
14222 vector signed short);
14223 vector unsigned short vec_vmrghh (vector unsigned short,
14224 vector unsigned short);
14225 vector pixel vec_vmrghh (vector pixel, vector pixel);
14226
14227 vector bool char vec_vmrghb (vector bool char, vector bool char);
14228 vector signed char vec_vmrghb (vector signed char, vector signed char);
14229 vector unsigned char vec_vmrghb (vector unsigned char,
14230 vector unsigned char);
14231
14232 vector bool char vec_mergel (vector bool char, vector bool char);
14233 vector signed char vec_mergel (vector signed char, vector signed char);
14234 vector unsigned char vec_mergel (vector unsigned char,
14235 vector unsigned char);
14236 vector bool short vec_mergel (vector bool short, vector bool short);
14237 vector pixel vec_mergel (vector pixel, vector pixel);
14238 vector signed short vec_mergel (vector signed short,
14239 vector signed short);
14240 vector unsigned short vec_mergel (vector unsigned short,
14241 vector unsigned short);
14242 vector float vec_mergel (vector float, vector float);
14243 vector bool int vec_mergel (vector bool int, vector bool int);
14244 vector signed int vec_mergel (vector signed int, vector signed int);
14245 vector unsigned int vec_mergel (vector unsigned int,
14246 vector unsigned int);
14247
14248 vector float vec_vmrglw (vector float, vector float);
14249 vector signed int vec_vmrglw (vector signed int, vector signed int);
14250 vector unsigned int vec_vmrglw (vector unsigned int,
14251 vector unsigned int);
14252 vector bool int vec_vmrglw (vector bool int, vector bool int);
14253
14254 vector bool short vec_vmrglh (vector bool short, vector bool short);
14255 vector signed short vec_vmrglh (vector signed short,
14256 vector signed short);
14257 vector unsigned short vec_vmrglh (vector unsigned short,
14258 vector unsigned short);
14259 vector pixel vec_vmrglh (vector pixel, vector pixel);
14260
14261 vector bool char vec_vmrglb (vector bool char, vector bool char);
14262 vector signed char vec_vmrglb (vector signed char, vector signed char);
14263 vector unsigned char vec_vmrglb (vector unsigned char,
14264 vector unsigned char);
14265
14266 vector unsigned short vec_mfvscr (void);
14267
14268 vector unsigned char vec_min (vector bool char, vector unsigned char);
14269 vector unsigned char vec_min (vector unsigned char, vector bool char);
14270 vector unsigned char vec_min (vector unsigned char,
14271 vector unsigned char);
14272 vector signed char vec_min (vector bool char, vector signed char);
14273 vector signed char vec_min (vector signed char, vector bool char);
14274 vector signed char vec_min (vector signed char, vector signed char);
14275 vector unsigned short vec_min (vector bool short,
14276 vector unsigned short);
14277 vector unsigned short vec_min (vector unsigned short,
14278 vector bool short);
14279 vector unsigned short vec_min (vector unsigned short,
14280 vector unsigned short);
14281 vector signed short vec_min (vector bool short, vector signed short);
14282 vector signed short vec_min (vector signed short, vector bool short);
14283 vector signed short vec_min (vector signed short, vector signed short);
14284 vector unsigned int vec_min (vector bool int, vector unsigned int);
14285 vector unsigned int vec_min (vector unsigned int, vector bool int);
14286 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14287 vector signed int vec_min (vector bool int, vector signed int);
14288 vector signed int vec_min (vector signed int, vector bool int);
14289 vector signed int vec_min (vector signed int, vector signed int);
14290 vector float vec_min (vector float, vector float);
14291
14292 vector float vec_vminfp (vector float, vector float);
14293
14294 vector signed int vec_vminsw (vector bool int, vector signed int);
14295 vector signed int vec_vminsw (vector signed int, vector bool int);
14296 vector signed int vec_vminsw (vector signed int, vector signed int);
14297
14298 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14299 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14300 vector unsigned int vec_vminuw (vector unsigned int,
14301 vector unsigned int);
14302
14303 vector signed short vec_vminsh (vector bool short, vector signed short);
14304 vector signed short vec_vminsh (vector signed short, vector bool short);
14305 vector signed short vec_vminsh (vector signed short,
14306 vector signed short);
14307
14308 vector unsigned short vec_vminuh (vector bool short,
14309 vector unsigned short);
14310 vector unsigned short vec_vminuh (vector unsigned short,
14311 vector bool short);
14312 vector unsigned short vec_vminuh (vector unsigned short,
14313 vector unsigned short);
14314
14315 vector signed char vec_vminsb (vector bool char, vector signed char);
14316 vector signed char vec_vminsb (vector signed char, vector bool char);
14317 vector signed char vec_vminsb (vector signed char, vector signed char);
14318
14319 vector unsigned char vec_vminub (vector bool char,
14320 vector unsigned char);
14321 vector unsigned char vec_vminub (vector unsigned char,
14322 vector bool char);
14323 vector unsigned char vec_vminub (vector unsigned char,
14324 vector unsigned char);
14325
14326 vector signed short vec_mladd (vector signed short,
14327 vector signed short,
14328 vector signed short);
14329 vector signed short vec_mladd (vector signed short,
14330 vector unsigned short,
14331 vector unsigned short);
14332 vector signed short vec_mladd (vector unsigned short,
14333 vector signed short,
14334 vector signed short);
14335 vector unsigned short vec_mladd (vector unsigned short,
14336 vector unsigned short,
14337 vector unsigned short);
14338
14339 vector signed short vec_mradds (vector signed short,
14340 vector signed short,
14341 vector signed short);
14342
14343 vector unsigned int vec_msum (vector unsigned char,
14344 vector unsigned char,
14345 vector unsigned int);
14346 vector signed int vec_msum (vector signed char,
14347 vector unsigned char,
14348 vector signed int);
14349 vector unsigned int vec_msum (vector unsigned short,
14350 vector unsigned short,
14351 vector unsigned int);
14352 vector signed int vec_msum (vector signed short,
14353 vector signed short,
14354 vector signed int);
14355
14356 vector signed int vec_vmsumshm (vector signed short,
14357 vector signed short,
14358 vector signed int);
14359
14360 vector unsigned int vec_vmsumuhm (vector unsigned short,
14361 vector unsigned short,
14362 vector unsigned int);
14363
14364 vector signed int vec_vmsummbm (vector signed char,
14365 vector unsigned char,
14366 vector signed int);
14367
14368 vector unsigned int vec_vmsumubm (vector unsigned char,
14369 vector unsigned char,
14370 vector unsigned int);
14371
14372 vector unsigned int vec_msums (vector unsigned short,
14373 vector unsigned short,
14374 vector unsigned int);
14375 vector signed int vec_msums (vector signed short,
14376 vector signed short,
14377 vector signed int);
14378
14379 vector signed int vec_vmsumshs (vector signed short,
14380 vector signed short,
14381 vector signed int);
14382
14383 vector unsigned int vec_vmsumuhs (vector unsigned short,
14384 vector unsigned short,
14385 vector unsigned int);
14386
14387 void vec_mtvscr (vector signed int);
14388 void vec_mtvscr (vector unsigned int);
14389 void vec_mtvscr (vector bool int);
14390 void vec_mtvscr (vector signed short);
14391 void vec_mtvscr (vector unsigned short);
14392 void vec_mtvscr (vector bool short);
14393 void vec_mtvscr (vector pixel);
14394 void vec_mtvscr (vector signed char);
14395 void vec_mtvscr (vector unsigned char);
14396 void vec_mtvscr (vector bool char);
14397
14398 vector unsigned short vec_mule (vector unsigned char,
14399 vector unsigned char);
14400 vector signed short vec_mule (vector signed char,
14401 vector signed char);
14402 vector unsigned int vec_mule (vector unsigned short,
14403 vector unsigned short);
14404 vector signed int vec_mule (vector signed short, vector signed short);
14405
14406 vector signed int vec_vmulesh (vector signed short,
14407 vector signed short);
14408
14409 vector unsigned int vec_vmuleuh (vector unsigned short,
14410 vector unsigned short);
14411
14412 vector signed short vec_vmulesb (vector signed char,
14413 vector signed char);
14414
14415 vector unsigned short vec_vmuleub (vector unsigned char,
14416 vector unsigned char);
14417
14418 vector unsigned short vec_mulo (vector unsigned char,
14419 vector unsigned char);
14420 vector signed short vec_mulo (vector signed char, vector signed char);
14421 vector unsigned int vec_mulo (vector unsigned short,
14422 vector unsigned short);
14423 vector signed int vec_mulo (vector signed short, vector signed short);
14424
14425 vector signed int vec_vmulosh (vector signed short,
14426 vector signed short);
14427
14428 vector unsigned int vec_vmulouh (vector unsigned short,
14429 vector unsigned short);
14430
14431 vector signed short vec_vmulosb (vector signed char,
14432 vector signed char);
14433
14434 vector unsigned short vec_vmuloub (vector unsigned char,
14435 vector unsigned char);
14436
14437 vector float vec_nmsub (vector float, vector float, vector float);
14438
14439 vector float vec_nor (vector float, vector float);
14440 vector signed int vec_nor (vector signed int, vector signed int);
14441 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14442 vector bool int vec_nor (vector bool int, vector bool int);
14443 vector signed short vec_nor (vector signed short, vector signed short);
14444 vector unsigned short vec_nor (vector unsigned short,
14445 vector unsigned short);
14446 vector bool short vec_nor (vector bool short, vector bool short);
14447 vector signed char vec_nor (vector signed char, vector signed char);
14448 vector unsigned char vec_nor (vector unsigned char,
14449 vector unsigned char);
14450 vector bool char vec_nor (vector bool char, vector bool char);
14451
14452 vector float vec_or (vector float, vector float);
14453 vector float vec_or (vector float, vector bool int);
14454 vector float vec_or (vector bool int, vector float);
14455 vector bool int vec_or (vector bool int, vector bool int);
14456 vector signed int vec_or (vector bool int, vector signed int);
14457 vector signed int vec_or (vector signed int, vector bool int);
14458 vector signed int vec_or (vector signed int, vector signed int);
14459 vector unsigned int vec_or (vector bool int, vector unsigned int);
14460 vector unsigned int vec_or (vector unsigned int, vector bool int);
14461 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14462 vector bool short vec_or (vector bool short, vector bool short);
14463 vector signed short vec_or (vector bool short, vector signed short);
14464 vector signed short vec_or (vector signed short, vector bool short);
14465 vector signed short vec_or (vector signed short, vector signed short);
14466 vector unsigned short vec_or (vector bool short, vector unsigned short);
14467 vector unsigned short vec_or (vector unsigned short, vector bool short);
14468 vector unsigned short vec_or (vector unsigned short,
14469 vector unsigned short);
14470 vector signed char vec_or (vector bool char, vector signed char);
14471 vector bool char vec_or (vector bool char, vector bool char);
14472 vector signed char vec_or (vector signed char, vector bool char);
14473 vector signed char vec_or (vector signed char, vector signed char);
14474 vector unsigned char vec_or (vector bool char, vector unsigned char);
14475 vector unsigned char vec_or (vector unsigned char, vector bool char);
14476 vector unsigned char vec_or (vector unsigned char,
14477 vector unsigned char);
14478
14479 vector signed char vec_pack (vector signed short, vector signed short);
14480 vector unsigned char vec_pack (vector unsigned short,
14481 vector unsigned short);
14482 vector bool char vec_pack (vector bool short, vector bool short);
14483 vector signed short vec_pack (vector signed int, vector signed int);
14484 vector unsigned short vec_pack (vector unsigned int,
14485 vector unsigned int);
14486 vector bool short vec_pack (vector bool int, vector bool int);
14487
14488 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14489 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14490 vector unsigned short vec_vpkuwum (vector unsigned int,
14491 vector unsigned int);
14492
14493 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14494 vector signed char vec_vpkuhum (vector signed short,
14495 vector signed short);
14496 vector unsigned char vec_vpkuhum (vector unsigned short,
14497 vector unsigned short);
14498
14499 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14500
14501 vector unsigned char vec_packs (vector unsigned short,
14502 vector unsigned short);
14503 vector signed char vec_packs (vector signed short, vector signed short);
14504 vector unsigned short vec_packs (vector unsigned int,
14505 vector unsigned int);
14506 vector signed short vec_packs (vector signed int, vector signed int);
14507
14508 vector signed short vec_vpkswss (vector signed int, vector signed int);
14509
14510 vector unsigned short vec_vpkuwus (vector unsigned int,
14511 vector unsigned int);
14512
14513 vector signed char vec_vpkshss (vector signed short,
14514 vector signed short);
14515
14516 vector unsigned char vec_vpkuhus (vector unsigned short,
14517 vector unsigned short);
14518
14519 vector unsigned char vec_packsu (vector unsigned short,
14520 vector unsigned short);
14521 vector unsigned char vec_packsu (vector signed short,
14522 vector signed short);
14523 vector unsigned short vec_packsu (vector unsigned int,
14524 vector unsigned int);
14525 vector unsigned short vec_packsu (vector signed int, vector signed int);
14526
14527 vector unsigned short vec_vpkswus (vector signed int,
14528 vector signed int);
14529
14530 vector unsigned char vec_vpkshus (vector signed short,
14531 vector signed short);
14532
14533 vector float vec_perm (vector float,
14534 vector float,
14535 vector unsigned char);
14536 vector signed int vec_perm (vector signed int,
14537 vector signed int,
14538 vector unsigned char);
14539 vector unsigned int vec_perm (vector unsigned int,
14540 vector unsigned int,
14541 vector unsigned char);
14542 vector bool int vec_perm (vector bool int,
14543 vector bool int,
14544 vector unsigned char);
14545 vector signed short vec_perm (vector signed short,
14546 vector signed short,
14547 vector unsigned char);
14548 vector unsigned short vec_perm (vector unsigned short,
14549 vector unsigned short,
14550 vector unsigned char);
14551 vector bool short vec_perm (vector bool short,
14552 vector bool short,
14553 vector unsigned char);
14554 vector pixel vec_perm (vector pixel,
14555 vector pixel,
14556 vector unsigned char);
14557 vector signed char vec_perm (vector signed char,
14558 vector signed char,
14559 vector unsigned char);
14560 vector unsigned char vec_perm (vector unsigned char,
14561 vector unsigned char,
14562 vector unsigned char);
14563 vector bool char vec_perm (vector bool char,
14564 vector bool char,
14565 vector unsigned char);
14566
14567 vector float vec_re (vector float);
14568
14569 vector signed char vec_rl (vector signed char,
14570 vector unsigned char);
14571 vector unsigned char vec_rl (vector unsigned char,
14572 vector unsigned char);
14573 vector signed short vec_rl (vector signed short, vector unsigned short);
14574 vector unsigned short vec_rl (vector unsigned short,
14575 vector unsigned short);
14576 vector signed int vec_rl (vector signed int, vector unsigned int);
14577 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14578
14579 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14580 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14581
14582 vector signed short vec_vrlh (vector signed short,
14583 vector unsigned short);
14584 vector unsigned short vec_vrlh (vector unsigned short,
14585 vector unsigned short);
14586
14587 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14588 vector unsigned char vec_vrlb (vector unsigned char,
14589 vector unsigned char);
14590
14591 vector float vec_round (vector float);
14592
14593 vector float vec_recip (vector float, vector float);
14594
14595 vector float vec_rsqrt (vector float);
14596
14597 vector float vec_rsqrte (vector float);
14598
14599 vector float vec_sel (vector float, vector float, vector bool int);
14600 vector float vec_sel (vector float, vector float, vector unsigned int);
14601 vector signed int vec_sel (vector signed int,
14602 vector signed int,
14603 vector bool int);
14604 vector signed int vec_sel (vector signed int,
14605 vector signed int,
14606 vector unsigned int);
14607 vector unsigned int vec_sel (vector unsigned int,
14608 vector unsigned int,
14609 vector bool int);
14610 vector unsigned int vec_sel (vector unsigned int,
14611 vector unsigned int,
14612 vector unsigned int);
14613 vector bool int vec_sel (vector bool int,
14614 vector bool int,
14615 vector bool int);
14616 vector bool int vec_sel (vector bool int,
14617 vector bool int,
14618 vector unsigned int);
14619 vector signed short vec_sel (vector signed short,
14620 vector signed short,
14621 vector bool short);
14622 vector signed short vec_sel (vector signed short,
14623 vector signed short,
14624 vector unsigned short);
14625 vector unsigned short vec_sel (vector unsigned short,
14626 vector unsigned short,
14627 vector bool short);
14628 vector unsigned short vec_sel (vector unsigned short,
14629 vector unsigned short,
14630 vector unsigned short);
14631 vector bool short vec_sel (vector bool short,
14632 vector bool short,
14633 vector bool short);
14634 vector bool short vec_sel (vector bool short,
14635 vector bool short,
14636 vector unsigned short);
14637 vector signed char vec_sel (vector signed char,
14638 vector signed char,
14639 vector bool char);
14640 vector signed char vec_sel (vector signed char,
14641 vector signed char,
14642 vector unsigned char);
14643 vector unsigned char vec_sel (vector unsigned char,
14644 vector unsigned char,
14645 vector bool char);
14646 vector unsigned char vec_sel (vector unsigned char,
14647 vector unsigned char,
14648 vector unsigned char);
14649 vector bool char vec_sel (vector bool char,
14650 vector bool char,
14651 vector bool char);
14652 vector bool char vec_sel (vector bool char,
14653 vector bool char,
14654 vector unsigned char);
14655
14656 vector signed char vec_sl (vector signed char,
14657 vector unsigned char);
14658 vector unsigned char vec_sl (vector unsigned char,
14659 vector unsigned char);
14660 vector signed short vec_sl (vector signed short, vector unsigned short);
14661 vector unsigned short vec_sl (vector unsigned short,
14662 vector unsigned short);
14663 vector signed int vec_sl (vector signed int, vector unsigned int);
14664 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14665
14666 vector signed int vec_vslw (vector signed int, vector unsigned int);
14667 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14668
14669 vector signed short vec_vslh (vector signed short,
14670 vector unsigned short);
14671 vector unsigned short vec_vslh (vector unsigned short,
14672 vector unsigned short);
14673
14674 vector signed char vec_vslb (vector signed char, vector unsigned char);
14675 vector unsigned char vec_vslb (vector unsigned char,
14676 vector unsigned char);
14677
14678 vector float vec_sld (vector float, vector float, const int);
14679 vector signed int vec_sld (vector signed int,
14680 vector signed int,
14681 const int);
14682 vector unsigned int vec_sld (vector unsigned int,
14683 vector unsigned int,
14684 const int);
14685 vector bool int vec_sld (vector bool int,
14686 vector bool int,
14687 const int);
14688 vector signed short vec_sld (vector signed short,
14689 vector signed short,
14690 const int);
14691 vector unsigned short vec_sld (vector unsigned short,
14692 vector unsigned short,
14693 const int);
14694 vector bool short vec_sld (vector bool short,
14695 vector bool short,
14696 const int);
14697 vector pixel vec_sld (vector pixel,
14698 vector pixel,
14699 const int);
14700 vector signed char vec_sld (vector signed char,
14701 vector signed char,
14702 const int);
14703 vector unsigned char vec_sld (vector unsigned char,
14704 vector unsigned char,
14705 const int);
14706 vector bool char vec_sld (vector bool char,
14707 vector bool char,
14708 const int);
14709
14710 vector signed int vec_sll (vector signed int,
14711 vector unsigned int);
14712 vector signed int vec_sll (vector signed int,
14713 vector unsigned short);
14714 vector signed int vec_sll (vector signed int,
14715 vector unsigned char);
14716 vector unsigned int vec_sll (vector unsigned int,
14717 vector unsigned int);
14718 vector unsigned int vec_sll (vector unsigned int,
14719 vector unsigned short);
14720 vector unsigned int vec_sll (vector unsigned int,
14721 vector unsigned char);
14722 vector bool int vec_sll (vector bool int,
14723 vector unsigned int);
14724 vector bool int vec_sll (vector bool int,
14725 vector unsigned short);
14726 vector bool int vec_sll (vector bool int,
14727 vector unsigned char);
14728 vector signed short vec_sll (vector signed short,
14729 vector unsigned int);
14730 vector signed short vec_sll (vector signed short,
14731 vector unsigned short);
14732 vector signed short vec_sll (vector signed short,
14733 vector unsigned char);
14734 vector unsigned short vec_sll (vector unsigned short,
14735 vector unsigned int);
14736 vector unsigned short vec_sll (vector unsigned short,
14737 vector unsigned short);
14738 vector unsigned short vec_sll (vector unsigned short,
14739 vector unsigned char);
14740 vector bool short vec_sll (vector bool short, vector unsigned int);
14741 vector bool short vec_sll (vector bool short, vector unsigned short);
14742 vector bool short vec_sll (vector bool short, vector unsigned char);
14743 vector pixel vec_sll (vector pixel, vector unsigned int);
14744 vector pixel vec_sll (vector pixel, vector unsigned short);
14745 vector pixel vec_sll (vector pixel, vector unsigned char);
14746 vector signed char vec_sll (vector signed char, vector unsigned int);
14747 vector signed char vec_sll (vector signed char, vector unsigned short);
14748 vector signed char vec_sll (vector signed char, vector unsigned char);
14749 vector unsigned char vec_sll (vector unsigned char,
14750 vector unsigned int);
14751 vector unsigned char vec_sll (vector unsigned char,
14752 vector unsigned short);
14753 vector unsigned char vec_sll (vector unsigned char,
14754 vector unsigned char);
14755 vector bool char vec_sll (vector bool char, vector unsigned int);
14756 vector bool char vec_sll (vector bool char, vector unsigned short);
14757 vector bool char vec_sll (vector bool char, vector unsigned char);
14758
14759 vector float vec_slo (vector float, vector signed char);
14760 vector float vec_slo (vector float, vector unsigned char);
14761 vector signed int vec_slo (vector signed int, vector signed char);
14762 vector signed int vec_slo (vector signed int, vector unsigned char);
14763 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14764 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14765 vector signed short vec_slo (vector signed short, vector signed char);
14766 vector signed short vec_slo (vector signed short, vector unsigned char);
14767 vector unsigned short vec_slo (vector unsigned short,
14768 vector signed char);
14769 vector unsigned short vec_slo (vector unsigned short,
14770 vector unsigned char);
14771 vector pixel vec_slo (vector pixel, vector signed char);
14772 vector pixel vec_slo (vector pixel, vector unsigned char);
14773 vector signed char vec_slo (vector signed char, vector signed char);
14774 vector signed char vec_slo (vector signed char, vector unsigned char);
14775 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14776 vector unsigned char vec_slo (vector unsigned char,
14777 vector unsigned char);
14778
14779 vector signed char vec_splat (vector signed char, const int);
14780 vector unsigned char vec_splat (vector unsigned char, const int);
14781 vector bool char vec_splat (vector bool char, const int);
14782 vector signed short vec_splat (vector signed short, const int);
14783 vector unsigned short vec_splat (vector unsigned short, const int);
14784 vector bool short vec_splat (vector bool short, const int);
14785 vector pixel vec_splat (vector pixel, const int);
14786 vector float vec_splat (vector float, const int);
14787 vector signed int vec_splat (vector signed int, const int);
14788 vector unsigned int vec_splat (vector unsigned int, const int);
14789 vector bool int vec_splat (vector bool int, const int);
14790 vector signed long vec_splat (vector signed long, const int);
14791 vector unsigned long vec_splat (vector unsigned long, const int);
14792
14793 vector signed char vec_splats (signed char);
14794 vector unsigned char vec_splats (unsigned char);
14795 vector signed short vec_splats (signed short);
14796 vector unsigned short vec_splats (unsigned short);
14797 vector signed int vec_splats (signed int);
14798 vector unsigned int vec_splats (unsigned int);
14799 vector float vec_splats (float);
14800
14801 vector float vec_vspltw (vector float, const int);
14802 vector signed int vec_vspltw (vector signed int, const int);
14803 vector unsigned int vec_vspltw (vector unsigned int, const int);
14804 vector bool int vec_vspltw (vector bool int, const int);
14805
14806 vector bool short vec_vsplth (vector bool short, const int);
14807 vector signed short vec_vsplth (vector signed short, const int);
14808 vector unsigned short vec_vsplth (vector unsigned short, const int);
14809 vector pixel vec_vsplth (vector pixel, const int);
14810
14811 vector signed char vec_vspltb (vector signed char, const int);
14812 vector unsigned char vec_vspltb (vector unsigned char, const int);
14813 vector bool char vec_vspltb (vector bool char, const int);
14814
14815 vector signed char vec_splat_s8 (const int);
14816
14817 vector signed short vec_splat_s16 (const int);
14818
14819 vector signed int vec_splat_s32 (const int);
14820
14821 vector unsigned char vec_splat_u8 (const int);
14822
14823 vector unsigned short vec_splat_u16 (const int);
14824
14825 vector unsigned int vec_splat_u32 (const int);
14826
14827 vector signed char vec_sr (vector signed char, vector unsigned char);
14828 vector unsigned char vec_sr (vector unsigned char,
14829 vector unsigned char);
14830 vector signed short vec_sr (vector signed short,
14831 vector unsigned short);
14832 vector unsigned short vec_sr (vector unsigned short,
14833 vector unsigned short);
14834 vector signed int vec_sr (vector signed int, vector unsigned int);
14835 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14836
14837 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14838 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14839
14840 vector signed short vec_vsrh (vector signed short,
14841 vector unsigned short);
14842 vector unsigned short vec_vsrh (vector unsigned short,
14843 vector unsigned short);
14844
14845 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14846 vector unsigned char vec_vsrb (vector unsigned char,
14847 vector unsigned char);
14848
14849 vector signed char vec_sra (vector signed char, vector unsigned char);
14850 vector unsigned char vec_sra (vector unsigned char,
14851 vector unsigned char);
14852 vector signed short vec_sra (vector signed short,
14853 vector unsigned short);
14854 vector unsigned short vec_sra (vector unsigned short,
14855 vector unsigned short);
14856 vector signed int vec_sra (vector signed int, vector unsigned int);
14857 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14858
14859 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14860 vector unsigned int vec_vsraw (vector unsigned int,
14861 vector unsigned int);
14862
14863 vector signed short vec_vsrah (vector signed short,
14864 vector unsigned short);
14865 vector unsigned short vec_vsrah (vector unsigned short,
14866 vector unsigned short);
14867
14868 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14869 vector unsigned char vec_vsrab (vector unsigned char,
14870 vector unsigned char);
14871
14872 vector signed int vec_srl (vector signed int, vector unsigned int);
14873 vector signed int vec_srl (vector signed int, vector unsigned short);
14874 vector signed int vec_srl (vector signed int, vector unsigned char);
14875 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14876 vector unsigned int vec_srl (vector unsigned int,
14877 vector unsigned short);
14878 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14879 vector bool int vec_srl (vector bool int, vector unsigned int);
14880 vector bool int vec_srl (vector bool int, vector unsigned short);
14881 vector bool int vec_srl (vector bool int, vector unsigned char);
14882 vector signed short vec_srl (vector signed short, vector unsigned int);
14883 vector signed short vec_srl (vector signed short,
14884 vector unsigned short);
14885 vector signed short vec_srl (vector signed short, vector unsigned char);
14886 vector unsigned short vec_srl (vector unsigned short,
14887 vector unsigned int);
14888 vector unsigned short vec_srl (vector unsigned short,
14889 vector unsigned short);
14890 vector unsigned short vec_srl (vector unsigned short,
14891 vector unsigned char);
14892 vector bool short vec_srl (vector bool short, vector unsigned int);
14893 vector bool short vec_srl (vector bool short, vector unsigned short);
14894 vector bool short vec_srl (vector bool short, vector unsigned char);
14895 vector pixel vec_srl (vector pixel, vector unsigned int);
14896 vector pixel vec_srl (vector pixel, vector unsigned short);
14897 vector pixel vec_srl (vector pixel, vector unsigned char);
14898 vector signed char vec_srl (vector signed char, vector unsigned int);
14899 vector signed char vec_srl (vector signed char, vector unsigned short);
14900 vector signed char vec_srl (vector signed char, vector unsigned char);
14901 vector unsigned char vec_srl (vector unsigned char,
14902 vector unsigned int);
14903 vector unsigned char vec_srl (vector unsigned char,
14904 vector unsigned short);
14905 vector unsigned char vec_srl (vector unsigned char,
14906 vector unsigned char);
14907 vector bool char vec_srl (vector bool char, vector unsigned int);
14908 vector bool char vec_srl (vector bool char, vector unsigned short);
14909 vector bool char vec_srl (vector bool char, vector unsigned char);
14910
14911 vector float vec_sro (vector float, vector signed char);
14912 vector float vec_sro (vector float, vector unsigned char);
14913 vector signed int vec_sro (vector signed int, vector signed char);
14914 vector signed int vec_sro (vector signed int, vector unsigned char);
14915 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14916 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14917 vector signed short vec_sro (vector signed short, vector signed char);
14918 vector signed short vec_sro (vector signed short, vector unsigned char);
14919 vector unsigned short vec_sro (vector unsigned short,
14920 vector signed char);
14921 vector unsigned short vec_sro (vector unsigned short,
14922 vector unsigned char);
14923 vector pixel vec_sro (vector pixel, vector signed char);
14924 vector pixel vec_sro (vector pixel, vector unsigned char);
14925 vector signed char vec_sro (vector signed char, vector signed char);
14926 vector signed char vec_sro (vector signed char, vector unsigned char);
14927 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14928 vector unsigned char vec_sro (vector unsigned char,
14929 vector unsigned char);
14930
14931 void vec_st (vector float, int, vector float *);
14932 void vec_st (vector float, int, float *);
14933 void vec_st (vector signed int, int, vector signed int *);
14934 void vec_st (vector signed int, int, int *);
14935 void vec_st (vector unsigned int, int, vector unsigned int *);
14936 void vec_st (vector unsigned int, int, unsigned int *);
14937 void vec_st (vector bool int, int, vector bool int *);
14938 void vec_st (vector bool int, int, unsigned int *);
14939 void vec_st (vector bool int, int, int *);
14940 void vec_st (vector signed short, int, vector signed short *);
14941 void vec_st (vector signed short, int, short *);
14942 void vec_st (vector unsigned short, int, vector unsigned short *);
14943 void vec_st (vector unsigned short, int, unsigned short *);
14944 void vec_st (vector bool short, int, vector bool short *);
14945 void vec_st (vector bool short, int, unsigned short *);
14946 void vec_st (vector pixel, int, vector pixel *);
14947 void vec_st (vector pixel, int, unsigned short *);
14948 void vec_st (vector pixel, int, short *);
14949 void vec_st (vector bool short, int, short *);
14950 void vec_st (vector signed char, int, vector signed char *);
14951 void vec_st (vector signed char, int, signed char *);
14952 void vec_st (vector unsigned char, int, vector unsigned char *);
14953 void vec_st (vector unsigned char, int, unsigned char *);
14954 void vec_st (vector bool char, int, vector bool char *);
14955 void vec_st (vector bool char, int, unsigned char *);
14956 void vec_st (vector bool char, int, signed char *);
14957
14958 void vec_ste (vector signed char, int, signed char *);
14959 void vec_ste (vector unsigned char, int, unsigned char *);
14960 void vec_ste (vector bool char, int, signed char *);
14961 void vec_ste (vector bool char, int, unsigned char *);
14962 void vec_ste (vector signed short, int, short *);
14963 void vec_ste (vector unsigned short, int, unsigned short *);
14964 void vec_ste (vector bool short, int, short *);
14965 void vec_ste (vector bool short, int, unsigned short *);
14966 void vec_ste (vector pixel, int, short *);
14967 void vec_ste (vector pixel, int, unsigned short *);
14968 void vec_ste (vector float, int, float *);
14969 void vec_ste (vector signed int, int, int *);
14970 void vec_ste (vector unsigned int, int, unsigned int *);
14971 void vec_ste (vector bool int, int, int *);
14972 void vec_ste (vector bool int, int, unsigned int *);
14973
14974 void vec_stvewx (vector float, int, float *);
14975 void vec_stvewx (vector signed int, int, int *);
14976 void vec_stvewx (vector unsigned int, int, unsigned int *);
14977 void vec_stvewx (vector bool int, int, int *);
14978 void vec_stvewx (vector bool int, int, unsigned int *);
14979
14980 void vec_stvehx (vector signed short, int, short *);
14981 void vec_stvehx (vector unsigned short, int, unsigned short *);
14982 void vec_stvehx (vector bool short, int, short *);
14983 void vec_stvehx (vector bool short, int, unsigned short *);
14984 void vec_stvehx (vector pixel, int, short *);
14985 void vec_stvehx (vector pixel, int, unsigned short *);
14986
14987 void vec_stvebx (vector signed char, int, signed char *);
14988 void vec_stvebx (vector unsigned char, int, unsigned char *);
14989 void vec_stvebx (vector bool char, int, signed char *);
14990 void vec_stvebx (vector bool char, int, unsigned char *);
14991
14992 void vec_stl (vector float, int, vector float *);
14993 void vec_stl (vector float, int, float *);
14994 void vec_stl (vector signed int, int, vector signed int *);
14995 void vec_stl (vector signed int, int, int *);
14996 void vec_stl (vector unsigned int, int, vector unsigned int *);
14997 void vec_stl (vector unsigned int, int, unsigned int *);
14998 void vec_stl (vector bool int, int, vector bool int *);
14999 void vec_stl (vector bool int, int, unsigned int *);
15000 void vec_stl (vector bool int, int, int *);
15001 void vec_stl (vector signed short, int, vector signed short *);
15002 void vec_stl (vector signed short, int, short *);
15003 void vec_stl (vector unsigned short, int, vector unsigned short *);
15004 void vec_stl (vector unsigned short, int, unsigned short *);
15005 void vec_stl (vector bool short, int, vector bool short *);
15006 void vec_stl (vector bool short, int, unsigned short *);
15007 void vec_stl (vector bool short, int, short *);
15008 void vec_stl (vector pixel, int, vector pixel *);
15009 void vec_stl (vector pixel, int, unsigned short *);
15010 void vec_stl (vector pixel, int, short *);
15011 void vec_stl (vector signed char, int, vector signed char *);
15012 void vec_stl (vector signed char, int, signed char *);
15013 void vec_stl (vector unsigned char, int, vector unsigned char *);
15014 void vec_stl (vector unsigned char, int, unsigned char *);
15015 void vec_stl (vector bool char, int, vector bool char *);
15016 void vec_stl (vector bool char, int, unsigned char *);
15017 void vec_stl (vector bool char, int, signed char *);
15018
15019 vector signed char vec_sub (vector bool char, vector signed char);
15020 vector signed char vec_sub (vector signed char, vector bool char);
15021 vector signed char vec_sub (vector signed char, vector signed char);
15022 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15023 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15024 vector unsigned char vec_sub (vector unsigned char,
15025 vector unsigned char);
15026 vector signed short vec_sub (vector bool short, vector signed short);
15027 vector signed short vec_sub (vector signed short, vector bool short);
15028 vector signed short vec_sub (vector signed short, vector signed short);
15029 vector unsigned short vec_sub (vector bool short,
15030 vector unsigned short);
15031 vector unsigned short vec_sub (vector unsigned short,
15032 vector bool short);
15033 vector unsigned short vec_sub (vector unsigned short,
15034 vector unsigned short);
15035 vector signed int vec_sub (vector bool int, vector signed int);
15036 vector signed int vec_sub (vector signed int, vector bool int);
15037 vector signed int vec_sub (vector signed int, vector signed int);
15038 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15039 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15040 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15041 vector float vec_sub (vector float, vector float);
15042
15043 vector float vec_vsubfp (vector float, vector float);
15044
15045 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15046 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15047 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15048 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15049 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15050 vector unsigned int vec_vsubuwm (vector unsigned int,
15051 vector unsigned int);
15052
15053 vector signed short vec_vsubuhm (vector bool short,
15054 vector signed short);
15055 vector signed short vec_vsubuhm (vector signed short,
15056 vector bool short);
15057 vector signed short vec_vsubuhm (vector signed short,
15058 vector signed short);
15059 vector unsigned short vec_vsubuhm (vector bool short,
15060 vector unsigned short);
15061 vector unsigned short vec_vsubuhm (vector unsigned short,
15062 vector bool short);
15063 vector unsigned short vec_vsubuhm (vector unsigned short,
15064 vector unsigned short);
15065
15066 vector signed char vec_vsububm (vector bool char, vector signed char);
15067 vector signed char vec_vsububm (vector signed char, vector bool char);
15068 vector signed char vec_vsububm (vector signed char, vector signed char);
15069 vector unsigned char vec_vsububm (vector bool char,
15070 vector unsigned char);
15071 vector unsigned char vec_vsububm (vector unsigned char,
15072 vector bool char);
15073 vector unsigned char vec_vsububm (vector unsigned char,
15074 vector unsigned char);
15075
15076 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15077
15078 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15079 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15080 vector unsigned char vec_subs (vector unsigned char,
15081 vector unsigned char);
15082 vector signed char vec_subs (vector bool char, vector signed char);
15083 vector signed char vec_subs (vector signed char, vector bool char);
15084 vector signed char vec_subs (vector signed char, vector signed char);
15085 vector unsigned short vec_subs (vector bool short,
15086 vector unsigned short);
15087 vector unsigned short vec_subs (vector unsigned short,
15088 vector bool short);
15089 vector unsigned short vec_subs (vector unsigned short,
15090 vector unsigned short);
15091 vector signed short vec_subs (vector bool short, vector signed short);
15092 vector signed short vec_subs (vector signed short, vector bool short);
15093 vector signed short vec_subs (vector signed short, vector signed short);
15094 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15095 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15096 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15097 vector signed int vec_subs (vector bool int, vector signed int);
15098 vector signed int vec_subs (vector signed int, vector bool int);
15099 vector signed int vec_subs (vector signed int, vector signed int);
15100
15101 vector signed int vec_vsubsws (vector bool int, vector signed int);
15102 vector signed int vec_vsubsws (vector signed int, vector bool int);
15103 vector signed int vec_vsubsws (vector signed int, vector signed int);
15104
15105 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15106 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15107 vector unsigned int vec_vsubuws (vector unsigned int,
15108 vector unsigned int);
15109
15110 vector signed short vec_vsubshs (vector bool short,
15111 vector signed short);
15112 vector signed short vec_vsubshs (vector signed short,
15113 vector bool short);
15114 vector signed short vec_vsubshs (vector signed short,
15115 vector signed short);
15116
15117 vector unsigned short vec_vsubuhs (vector bool short,
15118 vector unsigned short);
15119 vector unsigned short vec_vsubuhs (vector unsigned short,
15120 vector bool short);
15121 vector unsigned short vec_vsubuhs (vector unsigned short,
15122 vector unsigned short);
15123
15124 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15125 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15126 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15127
15128 vector unsigned char vec_vsububs (vector bool char,
15129 vector unsigned char);
15130 vector unsigned char vec_vsububs (vector unsigned char,
15131 vector bool char);
15132 vector unsigned char vec_vsububs (vector unsigned char,
15133 vector unsigned char);
15134
15135 vector unsigned int vec_sum4s (vector unsigned char,
15136 vector unsigned int);
15137 vector signed int vec_sum4s (vector signed char, vector signed int);
15138 vector signed int vec_sum4s (vector signed short, vector signed int);
15139
15140 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15141
15142 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15143
15144 vector unsigned int vec_vsum4ubs (vector unsigned char,
15145 vector unsigned int);
15146
15147 vector signed int vec_sum2s (vector signed int, vector signed int);
15148
15149 vector signed int vec_sums (vector signed int, vector signed int);
15150
15151 vector float vec_trunc (vector float);
15152
15153 vector signed short vec_unpackh (vector signed char);
15154 vector bool short vec_unpackh (vector bool char);
15155 vector signed int vec_unpackh (vector signed short);
15156 vector bool int vec_unpackh (vector bool short);
15157 vector unsigned int vec_unpackh (vector pixel);
15158
15159 vector bool int vec_vupkhsh (vector bool short);
15160 vector signed int vec_vupkhsh (vector signed short);
15161
15162 vector unsigned int vec_vupkhpx (vector pixel);
15163
15164 vector bool short vec_vupkhsb (vector bool char);
15165 vector signed short vec_vupkhsb (vector signed char);
15166
15167 vector signed short vec_unpackl (vector signed char);
15168 vector bool short vec_unpackl (vector bool char);
15169 vector unsigned int vec_unpackl (vector pixel);
15170 vector signed int vec_unpackl (vector signed short);
15171 vector bool int vec_unpackl (vector bool short);
15172
15173 vector unsigned int vec_vupklpx (vector pixel);
15174
15175 vector bool int vec_vupklsh (vector bool short);
15176 vector signed int vec_vupklsh (vector signed short);
15177
15178 vector bool short vec_vupklsb (vector bool char);
15179 vector signed short vec_vupklsb (vector signed char);
15180
15181 vector float vec_xor (vector float, vector float);
15182 vector float vec_xor (vector float, vector bool int);
15183 vector float vec_xor (vector bool int, vector float);
15184 vector bool int vec_xor (vector bool int, vector bool int);
15185 vector signed int vec_xor (vector bool int, vector signed int);
15186 vector signed int vec_xor (vector signed int, vector bool int);
15187 vector signed int vec_xor (vector signed int, vector signed int);
15188 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15189 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15190 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15191 vector bool short vec_xor (vector bool short, vector bool short);
15192 vector signed short vec_xor (vector bool short, vector signed short);
15193 vector signed short vec_xor (vector signed short, vector bool short);
15194 vector signed short vec_xor (vector signed short, vector signed short);
15195 vector unsigned short vec_xor (vector bool short,
15196 vector unsigned short);
15197 vector unsigned short vec_xor (vector unsigned short,
15198 vector bool short);
15199 vector unsigned short vec_xor (vector unsigned short,
15200 vector unsigned short);
15201 vector signed char vec_xor (vector bool char, vector signed char);
15202 vector bool char vec_xor (vector bool char, vector bool char);
15203 vector signed char vec_xor (vector signed char, vector bool char);
15204 vector signed char vec_xor (vector signed char, vector signed char);
15205 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15206 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15207 vector unsigned char vec_xor (vector unsigned char,
15208 vector unsigned char);
15209
15210 int vec_all_eq (vector signed char, vector bool char);
15211 int vec_all_eq (vector signed char, vector signed char);
15212 int vec_all_eq (vector unsigned char, vector bool char);
15213 int vec_all_eq (vector unsigned char, vector unsigned char);
15214 int vec_all_eq (vector bool char, vector bool char);
15215 int vec_all_eq (vector bool char, vector unsigned char);
15216 int vec_all_eq (vector bool char, vector signed char);
15217 int vec_all_eq (vector signed short, vector bool short);
15218 int vec_all_eq (vector signed short, vector signed short);
15219 int vec_all_eq (vector unsigned short, vector bool short);
15220 int vec_all_eq (vector unsigned short, vector unsigned short);
15221 int vec_all_eq (vector bool short, vector bool short);
15222 int vec_all_eq (vector bool short, vector unsigned short);
15223 int vec_all_eq (vector bool short, vector signed short);
15224 int vec_all_eq (vector pixel, vector pixel);
15225 int vec_all_eq (vector signed int, vector bool int);
15226 int vec_all_eq (vector signed int, vector signed int);
15227 int vec_all_eq (vector unsigned int, vector bool int);
15228 int vec_all_eq (vector unsigned int, vector unsigned int);
15229 int vec_all_eq (vector bool int, vector bool int);
15230 int vec_all_eq (vector bool int, vector unsigned int);
15231 int vec_all_eq (vector bool int, vector signed int);
15232 int vec_all_eq (vector float, vector float);
15233
15234 int vec_all_ge (vector bool char, vector unsigned char);
15235 int vec_all_ge (vector unsigned char, vector bool char);
15236 int vec_all_ge (vector unsigned char, vector unsigned char);
15237 int vec_all_ge (vector bool char, vector signed char);
15238 int vec_all_ge (vector signed char, vector bool char);
15239 int vec_all_ge (vector signed char, vector signed char);
15240 int vec_all_ge (vector bool short, vector unsigned short);
15241 int vec_all_ge (vector unsigned short, vector bool short);
15242 int vec_all_ge (vector unsigned short, vector unsigned short);
15243 int vec_all_ge (vector signed short, vector signed short);
15244 int vec_all_ge (vector bool short, vector signed short);
15245 int vec_all_ge (vector signed short, vector bool short);
15246 int vec_all_ge (vector bool int, vector unsigned int);
15247 int vec_all_ge (vector unsigned int, vector bool int);
15248 int vec_all_ge (vector unsigned int, vector unsigned int);
15249 int vec_all_ge (vector bool int, vector signed int);
15250 int vec_all_ge (vector signed int, vector bool int);
15251 int vec_all_ge (vector signed int, vector signed int);
15252 int vec_all_ge (vector float, vector float);
15253
15254 int vec_all_gt (vector bool char, vector unsigned char);
15255 int vec_all_gt (vector unsigned char, vector bool char);
15256 int vec_all_gt (vector unsigned char, vector unsigned char);
15257 int vec_all_gt (vector bool char, vector signed char);
15258 int vec_all_gt (vector signed char, vector bool char);
15259 int vec_all_gt (vector signed char, vector signed char);
15260 int vec_all_gt (vector bool short, vector unsigned short);
15261 int vec_all_gt (vector unsigned short, vector bool short);
15262 int vec_all_gt (vector unsigned short, vector unsigned short);
15263 int vec_all_gt (vector bool short, vector signed short);
15264 int vec_all_gt (vector signed short, vector bool short);
15265 int vec_all_gt (vector signed short, vector signed short);
15266 int vec_all_gt (vector bool int, vector unsigned int);
15267 int vec_all_gt (vector unsigned int, vector bool int);
15268 int vec_all_gt (vector unsigned int, vector unsigned int);
15269 int vec_all_gt (vector bool int, vector signed int);
15270 int vec_all_gt (vector signed int, vector bool int);
15271 int vec_all_gt (vector signed int, vector signed int);
15272 int vec_all_gt (vector float, vector float);
15273
15274 int vec_all_in (vector float, vector float);
15275
15276 int vec_all_le (vector bool char, vector unsigned char);
15277 int vec_all_le (vector unsigned char, vector bool char);
15278 int vec_all_le (vector unsigned char, vector unsigned char);
15279 int vec_all_le (vector bool char, vector signed char);
15280 int vec_all_le (vector signed char, vector bool char);
15281 int vec_all_le (vector signed char, vector signed char);
15282 int vec_all_le (vector bool short, vector unsigned short);
15283 int vec_all_le (vector unsigned short, vector bool short);
15284 int vec_all_le (vector unsigned short, vector unsigned short);
15285 int vec_all_le (vector bool short, vector signed short);
15286 int vec_all_le (vector signed short, vector bool short);
15287 int vec_all_le (vector signed short, vector signed short);
15288 int vec_all_le (vector bool int, vector unsigned int);
15289 int vec_all_le (vector unsigned int, vector bool int);
15290 int vec_all_le (vector unsigned int, vector unsigned int);
15291 int vec_all_le (vector bool int, vector signed int);
15292 int vec_all_le (vector signed int, vector bool int);
15293 int vec_all_le (vector signed int, vector signed int);
15294 int vec_all_le (vector float, vector float);
15295
15296 int vec_all_lt (vector bool char, vector unsigned char);
15297 int vec_all_lt (vector unsigned char, vector bool char);
15298 int vec_all_lt (vector unsigned char, vector unsigned char);
15299 int vec_all_lt (vector bool char, vector signed char);
15300 int vec_all_lt (vector signed char, vector bool char);
15301 int vec_all_lt (vector signed char, vector signed char);
15302 int vec_all_lt (vector bool short, vector unsigned short);
15303 int vec_all_lt (vector unsigned short, vector bool short);
15304 int vec_all_lt (vector unsigned short, vector unsigned short);
15305 int vec_all_lt (vector bool short, vector signed short);
15306 int vec_all_lt (vector signed short, vector bool short);
15307 int vec_all_lt (vector signed short, vector signed short);
15308 int vec_all_lt (vector bool int, vector unsigned int);
15309 int vec_all_lt (vector unsigned int, vector bool int);
15310 int vec_all_lt (vector unsigned int, vector unsigned int);
15311 int vec_all_lt (vector bool int, vector signed int);
15312 int vec_all_lt (vector signed int, vector bool int);
15313 int vec_all_lt (vector signed int, vector signed int);
15314 int vec_all_lt (vector float, vector float);
15315
15316 int vec_all_nan (vector float);
15317
15318 int vec_all_ne (vector signed char, vector bool char);
15319 int vec_all_ne (vector signed char, vector signed char);
15320 int vec_all_ne (vector unsigned char, vector bool char);
15321 int vec_all_ne (vector unsigned char, vector unsigned char);
15322 int vec_all_ne (vector bool char, vector bool char);
15323 int vec_all_ne (vector bool char, vector unsigned char);
15324 int vec_all_ne (vector bool char, vector signed char);
15325 int vec_all_ne (vector signed short, vector bool short);
15326 int vec_all_ne (vector signed short, vector signed short);
15327 int vec_all_ne (vector unsigned short, vector bool short);
15328 int vec_all_ne (vector unsigned short, vector unsigned short);
15329 int vec_all_ne (vector bool short, vector bool short);
15330 int vec_all_ne (vector bool short, vector unsigned short);
15331 int vec_all_ne (vector bool short, vector signed short);
15332 int vec_all_ne (vector pixel, vector pixel);
15333 int vec_all_ne (vector signed int, vector bool int);
15334 int vec_all_ne (vector signed int, vector signed int);
15335 int vec_all_ne (vector unsigned int, vector bool int);
15336 int vec_all_ne (vector unsigned int, vector unsigned int);
15337 int vec_all_ne (vector bool int, vector bool int);
15338 int vec_all_ne (vector bool int, vector unsigned int);
15339 int vec_all_ne (vector bool int, vector signed int);
15340 int vec_all_ne (vector float, vector float);
15341
15342 int vec_all_nge (vector float, vector float);
15343
15344 int vec_all_ngt (vector float, vector float);
15345
15346 int vec_all_nle (vector float, vector float);
15347
15348 int vec_all_nlt (vector float, vector float);
15349
15350 int vec_all_numeric (vector float);
15351
15352 int vec_any_eq (vector signed char, vector bool char);
15353 int vec_any_eq (vector signed char, vector signed char);
15354 int vec_any_eq (vector unsigned char, vector bool char);
15355 int vec_any_eq (vector unsigned char, vector unsigned char);
15356 int vec_any_eq (vector bool char, vector bool char);
15357 int vec_any_eq (vector bool char, vector unsigned char);
15358 int vec_any_eq (vector bool char, vector signed char);
15359 int vec_any_eq (vector signed short, vector bool short);
15360 int vec_any_eq (vector signed short, vector signed short);
15361 int vec_any_eq (vector unsigned short, vector bool short);
15362 int vec_any_eq (vector unsigned short, vector unsigned short);
15363 int vec_any_eq (vector bool short, vector bool short);
15364 int vec_any_eq (vector bool short, vector unsigned short);
15365 int vec_any_eq (vector bool short, vector signed short);
15366 int vec_any_eq (vector pixel, vector pixel);
15367 int vec_any_eq (vector signed int, vector bool int);
15368 int vec_any_eq (vector signed int, vector signed int);
15369 int vec_any_eq (vector unsigned int, vector bool int);
15370 int vec_any_eq (vector unsigned int, vector unsigned int);
15371 int vec_any_eq (vector bool int, vector bool int);
15372 int vec_any_eq (vector bool int, vector unsigned int);
15373 int vec_any_eq (vector bool int, vector signed int);
15374 int vec_any_eq (vector float, vector float);
15375
15376 int vec_any_ge (vector signed char, vector bool char);
15377 int vec_any_ge (vector unsigned char, vector bool char);
15378 int vec_any_ge (vector unsigned char, vector unsigned char);
15379 int vec_any_ge (vector signed char, vector signed char);
15380 int vec_any_ge (vector bool char, vector unsigned char);
15381 int vec_any_ge (vector bool char, vector signed char);
15382 int vec_any_ge (vector unsigned short, vector bool short);
15383 int vec_any_ge (vector unsigned short, vector unsigned short);
15384 int vec_any_ge (vector signed short, vector signed short);
15385 int vec_any_ge (vector signed short, vector bool short);
15386 int vec_any_ge (vector bool short, vector unsigned short);
15387 int vec_any_ge (vector bool short, vector signed short);
15388 int vec_any_ge (vector signed int, vector bool int);
15389 int vec_any_ge (vector unsigned int, vector bool int);
15390 int vec_any_ge (vector unsigned int, vector unsigned int);
15391 int vec_any_ge (vector signed int, vector signed int);
15392 int vec_any_ge (vector bool int, vector unsigned int);
15393 int vec_any_ge (vector bool int, vector signed int);
15394 int vec_any_ge (vector float, vector float);
15395
15396 int vec_any_gt (vector bool char, vector unsigned char);
15397 int vec_any_gt (vector unsigned char, vector bool char);
15398 int vec_any_gt (vector unsigned char, vector unsigned char);
15399 int vec_any_gt (vector bool char, vector signed char);
15400 int vec_any_gt (vector signed char, vector bool char);
15401 int vec_any_gt (vector signed char, vector signed char);
15402 int vec_any_gt (vector bool short, vector unsigned short);
15403 int vec_any_gt (vector unsigned short, vector bool short);
15404 int vec_any_gt (vector unsigned short, vector unsigned short);
15405 int vec_any_gt (vector bool short, vector signed short);
15406 int vec_any_gt (vector signed short, vector bool short);
15407 int vec_any_gt (vector signed short, vector signed short);
15408 int vec_any_gt (vector bool int, vector unsigned int);
15409 int vec_any_gt (vector unsigned int, vector bool int);
15410 int vec_any_gt (vector unsigned int, vector unsigned int);
15411 int vec_any_gt (vector bool int, vector signed int);
15412 int vec_any_gt (vector signed int, vector bool int);
15413 int vec_any_gt (vector signed int, vector signed int);
15414 int vec_any_gt (vector float, vector float);
15415
15416 int vec_any_le (vector bool char, vector unsigned char);
15417 int vec_any_le (vector unsigned char, vector bool char);
15418 int vec_any_le (vector unsigned char, vector unsigned char);
15419 int vec_any_le (vector bool char, vector signed char);
15420 int vec_any_le (vector signed char, vector bool char);
15421 int vec_any_le (vector signed char, vector signed char);
15422 int vec_any_le (vector bool short, vector unsigned short);
15423 int vec_any_le (vector unsigned short, vector bool short);
15424 int vec_any_le (vector unsigned short, vector unsigned short);
15425 int vec_any_le (vector bool short, vector signed short);
15426 int vec_any_le (vector signed short, vector bool short);
15427 int vec_any_le (vector signed short, vector signed short);
15428 int vec_any_le (vector bool int, vector unsigned int);
15429 int vec_any_le (vector unsigned int, vector bool int);
15430 int vec_any_le (vector unsigned int, vector unsigned int);
15431 int vec_any_le (vector bool int, vector signed int);
15432 int vec_any_le (vector signed int, vector bool int);
15433 int vec_any_le (vector signed int, vector signed int);
15434 int vec_any_le (vector float, vector float);
15435
15436 int vec_any_lt (vector bool char, vector unsigned char);
15437 int vec_any_lt (vector unsigned char, vector bool char);
15438 int vec_any_lt (vector unsigned char, vector unsigned char);
15439 int vec_any_lt (vector bool char, vector signed char);
15440 int vec_any_lt (vector signed char, vector bool char);
15441 int vec_any_lt (vector signed char, vector signed char);
15442 int vec_any_lt (vector bool short, vector unsigned short);
15443 int vec_any_lt (vector unsigned short, vector bool short);
15444 int vec_any_lt (vector unsigned short, vector unsigned short);
15445 int vec_any_lt (vector bool short, vector signed short);
15446 int vec_any_lt (vector signed short, vector bool short);
15447 int vec_any_lt (vector signed short, vector signed short);
15448 int vec_any_lt (vector bool int, vector unsigned int);
15449 int vec_any_lt (vector unsigned int, vector bool int);
15450 int vec_any_lt (vector unsigned int, vector unsigned int);
15451 int vec_any_lt (vector bool int, vector signed int);
15452 int vec_any_lt (vector signed int, vector bool int);
15453 int vec_any_lt (vector signed int, vector signed int);
15454 int vec_any_lt (vector float, vector float);
15455
15456 int vec_any_nan (vector float);
15457
15458 int vec_any_ne (vector signed char, vector bool char);
15459 int vec_any_ne (vector signed char, vector signed char);
15460 int vec_any_ne (vector unsigned char, vector bool char);
15461 int vec_any_ne (vector unsigned char, vector unsigned char);
15462 int vec_any_ne (vector bool char, vector bool char);
15463 int vec_any_ne (vector bool char, vector unsigned char);
15464 int vec_any_ne (vector bool char, vector signed char);
15465 int vec_any_ne (vector signed short, vector bool short);
15466 int vec_any_ne (vector signed short, vector signed short);
15467 int vec_any_ne (vector unsigned short, vector bool short);
15468 int vec_any_ne (vector unsigned short, vector unsigned short);
15469 int vec_any_ne (vector bool short, vector bool short);
15470 int vec_any_ne (vector bool short, vector unsigned short);
15471 int vec_any_ne (vector bool short, vector signed short);
15472 int vec_any_ne (vector pixel, vector pixel);
15473 int vec_any_ne (vector signed int, vector bool int);
15474 int vec_any_ne (vector signed int, vector signed int);
15475 int vec_any_ne (vector unsigned int, vector bool int);
15476 int vec_any_ne (vector unsigned int, vector unsigned int);
15477 int vec_any_ne (vector bool int, vector bool int);
15478 int vec_any_ne (vector bool int, vector unsigned int);
15479 int vec_any_ne (vector bool int, vector signed int);
15480 int vec_any_ne (vector float, vector float);
15481
15482 int vec_any_nge (vector float, vector float);
15483
15484 int vec_any_ngt (vector float, vector float);
15485
15486 int vec_any_nle (vector float, vector float);
15487
15488 int vec_any_nlt (vector float, vector float);
15489
15490 int vec_any_numeric (vector float);
15491
15492 int vec_any_out (vector float, vector float);
15493 @end smallexample
15494
15495 If the vector/scalar (VSX) instruction set is available, the following
15496 additional functions are available:
15497
15498 @smallexample
15499 vector double vec_abs (vector double);
15500 vector double vec_add (vector double, vector double);
15501 vector double vec_and (vector double, vector double);
15502 vector double vec_and (vector double, vector bool long);
15503 vector double vec_and (vector bool long, vector double);
15504 vector long vec_and (vector long, vector long);
15505 vector long vec_and (vector long, vector bool long);
15506 vector long vec_and (vector bool long, vector long);
15507 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15508 vector unsigned long vec_and (vector unsigned long, vector bool long);
15509 vector unsigned long vec_and (vector bool long, vector unsigned long);
15510 vector double vec_andc (vector double, vector double);
15511 vector double vec_andc (vector double, vector bool long);
15512 vector double vec_andc (vector bool long, vector double);
15513 vector long vec_andc (vector long, vector long);
15514 vector long vec_andc (vector long, vector bool long);
15515 vector long vec_andc (vector bool long, vector long);
15516 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15517 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15518 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15519 vector double vec_ceil (vector double);
15520 vector bool long vec_cmpeq (vector double, vector double);
15521 vector bool long vec_cmpge (vector double, vector double);
15522 vector bool long vec_cmpgt (vector double, vector double);
15523 vector bool long vec_cmple (vector double, vector double);
15524 vector bool long vec_cmplt (vector double, vector double);
15525 vector double vec_cpsgn (vector double, vector double);
15526 vector float vec_div (vector float, vector float);
15527 vector double vec_div (vector double, vector double);
15528 vector long vec_div (vector long, vector long);
15529 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15530 vector double vec_floor (vector double);
15531 vector double vec_ld (int, const vector double *);
15532 vector double vec_ld (int, const double *);
15533 vector double vec_ldl (int, const vector double *);
15534 vector double vec_ldl (int, const double *);
15535 vector unsigned char vec_lvsl (int, const volatile double *);
15536 vector unsigned char vec_lvsr (int, const volatile double *);
15537 vector double vec_madd (vector double, vector double, vector double);
15538 vector double vec_max (vector double, vector double);
15539 vector signed long vec_mergeh (vector signed long, vector signed long);
15540 vector signed long vec_mergeh (vector signed long, vector bool long);
15541 vector signed long vec_mergeh (vector bool long, vector signed long);
15542 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15543 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15544 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15545 vector signed long vec_mergel (vector signed long, vector signed long);
15546 vector signed long vec_mergel (vector signed long, vector bool long);
15547 vector signed long vec_mergel (vector bool long, vector signed long);
15548 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15549 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15550 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15551 vector double vec_min (vector double, vector double);
15552 vector float vec_msub (vector float, vector float, vector float);
15553 vector double vec_msub (vector double, vector double, vector double);
15554 vector float vec_mul (vector float, vector float);
15555 vector double vec_mul (vector double, vector double);
15556 vector long vec_mul (vector long, vector long);
15557 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15558 vector float vec_nearbyint (vector float);
15559 vector double vec_nearbyint (vector double);
15560 vector float vec_nmadd (vector float, vector float, vector float);
15561 vector double vec_nmadd (vector double, vector double, vector double);
15562 vector double vec_nmsub (vector double, vector double, vector double);
15563 vector double vec_nor (vector double, vector double);
15564 vector long vec_nor (vector long, vector long);
15565 vector long vec_nor (vector long, vector bool long);
15566 vector long vec_nor (vector bool long, vector long);
15567 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15568 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15569 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15570 vector double vec_or (vector double, vector double);
15571 vector double vec_or (vector double, vector bool long);
15572 vector double vec_or (vector bool long, vector double);
15573 vector long vec_or (vector long, vector long);
15574 vector long vec_or (vector long, vector bool long);
15575 vector long vec_or (vector bool long, vector long);
15576 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15577 vector unsigned long vec_or (vector unsigned long, vector bool long);
15578 vector unsigned long vec_or (vector bool long, vector unsigned long);
15579 vector double vec_perm (vector double, vector double, vector unsigned char);
15580 vector long vec_perm (vector long, vector long, vector unsigned char);
15581 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15582 vector unsigned char);
15583 vector double vec_rint (vector double);
15584 vector double vec_recip (vector double, vector double);
15585 vector double vec_rsqrt (vector double);
15586 vector double vec_rsqrte (vector double);
15587 vector double vec_sel (vector double, vector double, vector bool long);
15588 vector double vec_sel (vector double, vector double, vector unsigned long);
15589 vector long vec_sel (vector long, vector long, vector long);
15590 vector long vec_sel (vector long, vector long, vector unsigned long);
15591 vector long vec_sel (vector long, vector long, vector bool long);
15592 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15593 vector long);
15594 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15595 vector unsigned long);
15596 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15597 vector bool long);
15598 vector double vec_splats (double);
15599 vector signed long vec_splats (signed long);
15600 vector unsigned long vec_splats (unsigned long);
15601 vector float vec_sqrt (vector float);
15602 vector double vec_sqrt (vector double);
15603 void vec_st (vector double, int, vector double *);
15604 void vec_st (vector double, int, double *);
15605 vector double vec_sub (vector double, vector double);
15606 vector double vec_trunc (vector double);
15607 vector double vec_xor (vector double, vector double);
15608 vector double vec_xor (vector double, vector bool long);
15609 vector double vec_xor (vector bool long, vector double);
15610 vector long vec_xor (vector long, vector long);
15611 vector long vec_xor (vector long, vector bool long);
15612 vector long vec_xor (vector bool long, vector long);
15613 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15614 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15615 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15616 int vec_all_eq (vector double, vector double);
15617 int vec_all_ge (vector double, vector double);
15618 int vec_all_gt (vector double, vector double);
15619 int vec_all_le (vector double, vector double);
15620 int vec_all_lt (vector double, vector double);
15621 int vec_all_nan (vector double);
15622 int vec_all_ne (vector double, vector double);
15623 int vec_all_nge (vector double, vector double);
15624 int vec_all_ngt (vector double, vector double);
15625 int vec_all_nle (vector double, vector double);
15626 int vec_all_nlt (vector double, vector double);
15627 int vec_all_numeric (vector double);
15628 int vec_any_eq (vector double, vector double);
15629 int vec_any_ge (vector double, vector double);
15630 int vec_any_gt (vector double, vector double);
15631 int vec_any_le (vector double, vector double);
15632 int vec_any_lt (vector double, vector double);
15633 int vec_any_nan (vector double);
15634 int vec_any_ne (vector double, vector double);
15635 int vec_any_nge (vector double, vector double);
15636 int vec_any_ngt (vector double, vector double);
15637 int vec_any_nle (vector double, vector double);
15638 int vec_any_nlt (vector double, vector double);
15639 int vec_any_numeric (vector double);
15640
15641 vector double vec_vsx_ld (int, const vector double *);
15642 vector double vec_vsx_ld (int, const double *);
15643 vector float vec_vsx_ld (int, const vector float *);
15644 vector float vec_vsx_ld (int, const float *);
15645 vector bool int vec_vsx_ld (int, const vector bool int *);
15646 vector signed int vec_vsx_ld (int, const vector signed int *);
15647 vector signed int vec_vsx_ld (int, const int *);
15648 vector signed int vec_vsx_ld (int, const long *);
15649 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15650 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15651 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15652 vector bool short vec_vsx_ld (int, const vector bool short *);
15653 vector pixel vec_vsx_ld (int, const vector pixel *);
15654 vector signed short vec_vsx_ld (int, const vector signed short *);
15655 vector signed short vec_vsx_ld (int, const short *);
15656 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15657 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15658 vector bool char vec_vsx_ld (int, const vector bool char *);
15659 vector signed char vec_vsx_ld (int, const vector signed char *);
15660 vector signed char vec_vsx_ld (int, const signed char *);
15661 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15662 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15663
15664 void vec_vsx_st (vector double, int, vector double *);
15665 void vec_vsx_st (vector double, int, double *);
15666 void vec_vsx_st (vector float, int, vector float *);
15667 void vec_vsx_st (vector float, int, float *);
15668 void vec_vsx_st (vector signed int, int, vector signed int *);
15669 void vec_vsx_st (vector signed int, int, int *);
15670 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15671 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15672 void vec_vsx_st (vector bool int, int, vector bool int *);
15673 void vec_vsx_st (vector bool int, int, unsigned int *);
15674 void vec_vsx_st (vector bool int, int, int *);
15675 void vec_vsx_st (vector signed short, int, vector signed short *);
15676 void vec_vsx_st (vector signed short, int, short *);
15677 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15678 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15679 void vec_vsx_st (vector bool short, int, vector bool short *);
15680 void vec_vsx_st (vector bool short, int, unsigned short *);
15681 void vec_vsx_st (vector pixel, int, vector pixel *);
15682 void vec_vsx_st (vector pixel, int, unsigned short *);
15683 void vec_vsx_st (vector pixel, int, short *);
15684 void vec_vsx_st (vector bool short, int, short *);
15685 void vec_vsx_st (vector signed char, int, vector signed char *);
15686 void vec_vsx_st (vector signed char, int, signed char *);
15687 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15688 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15689 void vec_vsx_st (vector bool char, int, vector bool char *);
15690 void vec_vsx_st (vector bool char, int, unsigned char *);
15691 void vec_vsx_st (vector bool char, int, signed char *);
15692
15693 vector double vec_xxpermdi (vector double, vector double, int);
15694 vector float vec_xxpermdi (vector float, vector float, int);
15695 vector long long vec_xxpermdi (vector long long, vector long long, int);
15696 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15697 vector unsigned long long, int);
15698 vector int vec_xxpermdi (vector int, vector int, int);
15699 vector unsigned int vec_xxpermdi (vector unsigned int,
15700 vector unsigned int, int);
15701 vector short vec_xxpermdi (vector short, vector short, int);
15702 vector unsigned short vec_xxpermdi (vector unsigned short,
15703 vector unsigned short, int);
15704 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15705 vector unsigned char vec_xxpermdi (vector unsigned char,
15706 vector unsigned char, int);
15707
15708 vector double vec_xxsldi (vector double, vector double, int);
15709 vector float vec_xxsldi (vector float, vector float, int);
15710 vector long long vec_xxsldi (vector long long, vector long long, int);
15711 vector unsigned long long vec_xxsldi (vector unsigned long long,
15712 vector unsigned long long, int);
15713 vector int vec_xxsldi (vector int, vector int, int);
15714 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15715 vector short vec_xxsldi (vector short, vector short, int);
15716 vector unsigned short vec_xxsldi (vector unsigned short,
15717 vector unsigned short, int);
15718 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15719 vector unsigned char vec_xxsldi (vector unsigned char,
15720 vector unsigned char, int);
15721 @end smallexample
15722
15723 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15724 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15725 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
15726 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15727 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15728
15729 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15730 instruction set is available, the following additional functions are
15731 available for both 32-bit and 64-bit targets. For 64-bit targets, you
15732 can use @var{vector long} instead of @var{vector long long},
15733 @var{vector bool long} instead of @var{vector bool long long}, and
15734 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15735
15736 @smallexample
15737 vector long long vec_abs (vector long long);
15738
15739 vector long long vec_add (vector long long, vector long long);
15740 vector unsigned long long vec_add (vector unsigned long long,
15741 vector unsigned long long);
15742
15743 int vec_all_eq (vector long long, vector long long);
15744 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15745 int vec_all_ge (vector long long, vector long long);
15746 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15747 int vec_all_gt (vector long long, vector long long);
15748 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15749 int vec_all_le (vector long long, vector long long);
15750 int vec_all_le (vector unsigned long long, vector unsigned long long);
15751 int vec_all_lt (vector long long, vector long long);
15752 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15753 int vec_all_ne (vector long long, vector long long);
15754 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15755
15756 int vec_any_eq (vector long long, vector long long);
15757 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15758 int vec_any_ge (vector long long, vector long long);
15759 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15760 int vec_any_gt (vector long long, vector long long);
15761 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15762 int vec_any_le (vector long long, vector long long);
15763 int vec_any_le (vector unsigned long long, vector unsigned long long);
15764 int vec_any_lt (vector long long, vector long long);
15765 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15766 int vec_any_ne (vector long long, vector long long);
15767 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15768
15769 vector long long vec_eqv (vector long long, vector long long);
15770 vector long long vec_eqv (vector bool long long, vector long long);
15771 vector long long vec_eqv (vector long long, vector bool long long);
15772 vector unsigned long long vec_eqv (vector unsigned long long,
15773 vector unsigned long long);
15774 vector unsigned long long vec_eqv (vector bool long long,
15775 vector unsigned long long);
15776 vector unsigned long long vec_eqv (vector unsigned long long,
15777 vector bool long long);
15778 vector int vec_eqv (vector int, vector int);
15779 vector int vec_eqv (vector bool int, vector int);
15780 vector int vec_eqv (vector int, vector bool int);
15781 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15782 vector unsigned int vec_eqv (vector bool unsigned int,
15783 vector unsigned int);
15784 vector unsigned int vec_eqv (vector unsigned int,
15785 vector bool unsigned int);
15786 vector short vec_eqv (vector short, vector short);
15787 vector short vec_eqv (vector bool short, vector short);
15788 vector short vec_eqv (vector short, vector bool short);
15789 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15790 vector unsigned short vec_eqv (vector bool unsigned short,
15791 vector unsigned short);
15792 vector unsigned short vec_eqv (vector unsigned short,
15793 vector bool unsigned short);
15794 vector signed char vec_eqv (vector signed char, vector signed char);
15795 vector signed char vec_eqv (vector bool signed char, vector signed char);
15796 vector signed char vec_eqv (vector signed char, vector bool signed char);
15797 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15798 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15799 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15800
15801 vector long long vec_max (vector long long, vector long long);
15802 vector unsigned long long vec_max (vector unsigned long long,
15803 vector unsigned long long);
15804
15805 vector signed int vec_mergee (vector signed int, vector signed int);
15806 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15807 vector bool int vec_mergee (vector bool int, vector bool int);
15808
15809 vector signed int vec_mergeo (vector signed int, vector signed int);
15810 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15811 vector bool int vec_mergeo (vector bool int, vector bool int);
15812
15813 vector long long vec_min (vector long long, vector long long);
15814 vector unsigned long long vec_min (vector unsigned long long,
15815 vector unsigned long long);
15816
15817 vector long long vec_nand (vector long long, vector long long);
15818 vector long long vec_nand (vector bool long long, vector long long);
15819 vector long long vec_nand (vector long long, vector bool long long);
15820 vector unsigned long long vec_nand (vector unsigned long long,
15821 vector unsigned long long);
15822 vector unsigned long long vec_nand (vector bool long long,
15823 vector unsigned long long);
15824 vector unsigned long long vec_nand (vector unsigned long long,
15825 vector bool long long);
15826 vector int vec_nand (vector int, vector int);
15827 vector int vec_nand (vector bool int, vector int);
15828 vector int vec_nand (vector int, vector bool int);
15829 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15830 vector unsigned int vec_nand (vector bool unsigned int,
15831 vector unsigned int);
15832 vector unsigned int vec_nand (vector unsigned int,
15833 vector bool unsigned int);
15834 vector short vec_nand (vector short, vector short);
15835 vector short vec_nand (vector bool short, vector short);
15836 vector short vec_nand (vector short, vector bool short);
15837 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15838 vector unsigned short vec_nand (vector bool unsigned short,
15839 vector unsigned short);
15840 vector unsigned short vec_nand (vector unsigned short,
15841 vector bool unsigned short);
15842 vector signed char vec_nand (vector signed char, vector signed char);
15843 vector signed char vec_nand (vector bool signed char, vector signed char);
15844 vector signed char vec_nand (vector signed char, vector bool signed char);
15845 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15846 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15847 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15848
15849 vector long long vec_orc (vector long long, vector long long);
15850 vector long long vec_orc (vector bool long long, vector long long);
15851 vector long long vec_orc (vector long long, vector bool long long);
15852 vector unsigned long long vec_orc (vector unsigned long long,
15853 vector unsigned long long);
15854 vector unsigned long long vec_orc (vector bool long long,
15855 vector unsigned long long);
15856 vector unsigned long long vec_orc (vector unsigned long long,
15857 vector bool long long);
15858 vector int vec_orc (vector int, vector int);
15859 vector int vec_orc (vector bool int, vector int);
15860 vector int vec_orc (vector int, vector bool int);
15861 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15862 vector unsigned int vec_orc (vector bool unsigned int,
15863 vector unsigned int);
15864 vector unsigned int vec_orc (vector unsigned int,
15865 vector bool unsigned int);
15866 vector short vec_orc (vector short, vector short);
15867 vector short vec_orc (vector bool short, vector short);
15868 vector short vec_orc (vector short, vector bool short);
15869 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15870 vector unsigned short vec_orc (vector bool unsigned short,
15871 vector unsigned short);
15872 vector unsigned short vec_orc (vector unsigned short,
15873 vector bool unsigned short);
15874 vector signed char vec_orc (vector signed char, vector signed char);
15875 vector signed char vec_orc (vector bool signed char, vector signed char);
15876 vector signed char vec_orc (vector signed char, vector bool signed char);
15877 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15878 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15879 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15880
15881 vector int vec_pack (vector long long, vector long long);
15882 vector unsigned int vec_pack (vector unsigned long long,
15883 vector unsigned long long);
15884 vector bool int vec_pack (vector bool long long, vector bool long long);
15885
15886 vector int vec_packs (vector long long, vector long long);
15887 vector unsigned int vec_packs (vector unsigned long long,
15888 vector unsigned long long);
15889
15890 vector unsigned int vec_packsu (vector long long, vector long long);
15891 vector unsigned int vec_packsu (vector unsigned long long,
15892 vector unsigned long long);
15893
15894 vector long long vec_rl (vector long long,
15895 vector unsigned long long);
15896 vector long long vec_rl (vector unsigned long long,
15897 vector unsigned long long);
15898
15899 vector long long vec_sl (vector long long, vector unsigned long long);
15900 vector long long vec_sl (vector unsigned long long,
15901 vector unsigned long long);
15902
15903 vector long long vec_sr (vector long long, vector unsigned long long);
15904 vector unsigned long long char vec_sr (vector unsigned long long,
15905 vector unsigned long long);
15906
15907 vector long long vec_sra (vector long long, vector unsigned long long);
15908 vector unsigned long long vec_sra (vector unsigned long long,
15909 vector unsigned long long);
15910
15911 vector long long vec_sub (vector long long, vector long long);
15912 vector unsigned long long vec_sub (vector unsigned long long,
15913 vector unsigned long long);
15914
15915 vector long long vec_unpackh (vector int);
15916 vector unsigned long long vec_unpackh (vector unsigned int);
15917
15918 vector long long vec_unpackl (vector int);
15919 vector unsigned long long vec_unpackl (vector unsigned int);
15920
15921 vector long long vec_vaddudm (vector long long, vector long long);
15922 vector long long vec_vaddudm (vector bool long long, vector long long);
15923 vector long long vec_vaddudm (vector long long, vector bool long long);
15924 vector unsigned long long vec_vaddudm (vector unsigned long long,
15925 vector unsigned long long);
15926 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15927 vector unsigned long long);
15928 vector unsigned long long vec_vaddudm (vector unsigned long long,
15929 vector bool unsigned long long);
15930
15931 vector long long vec_vbpermq (vector signed char, vector signed char);
15932 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15933
15934 vector long long vec_cntlz (vector long long);
15935 vector unsigned long long vec_cntlz (vector unsigned long long);
15936 vector int vec_cntlz (vector int);
15937 vector unsigned int vec_cntlz (vector int);
15938 vector short vec_cntlz (vector short);
15939 vector unsigned short vec_cntlz (vector unsigned short);
15940 vector signed char vec_cntlz (vector signed char);
15941 vector unsigned char vec_cntlz (vector unsigned char);
15942
15943 vector long long vec_vclz (vector long long);
15944 vector unsigned long long vec_vclz (vector unsigned long long);
15945 vector int vec_vclz (vector int);
15946 vector unsigned int vec_vclz (vector int);
15947 vector short vec_vclz (vector short);
15948 vector unsigned short vec_vclz (vector unsigned short);
15949 vector signed char vec_vclz (vector signed char);
15950 vector unsigned char vec_vclz (vector unsigned char);
15951
15952 vector signed char vec_vclzb (vector signed char);
15953 vector unsigned char vec_vclzb (vector unsigned char);
15954
15955 vector long long vec_vclzd (vector long long);
15956 vector unsigned long long vec_vclzd (vector unsigned long long);
15957
15958 vector short vec_vclzh (vector short);
15959 vector unsigned short vec_vclzh (vector unsigned short);
15960
15961 vector int vec_vclzw (vector int);
15962 vector unsigned int vec_vclzw (vector int);
15963
15964 vector signed char vec_vgbbd (vector signed char);
15965 vector unsigned char vec_vgbbd (vector unsigned char);
15966
15967 vector long long vec_vmaxsd (vector long long, vector long long);
15968
15969 vector unsigned long long vec_vmaxud (vector unsigned long long,
15970 unsigned vector long long);
15971
15972 vector long long vec_vminsd (vector long long, vector long long);
15973
15974 vector unsigned long long vec_vminud (vector long long,
15975 vector long long);
15976
15977 vector int vec_vpksdss (vector long long, vector long long);
15978 vector unsigned int vec_vpksdss (vector long long, vector long long);
15979
15980 vector unsigned int vec_vpkudus (vector unsigned long long,
15981 vector unsigned long long);
15982
15983 vector int vec_vpkudum (vector long long, vector long long);
15984 vector unsigned int vec_vpkudum (vector unsigned long long,
15985 vector unsigned long long);
15986 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15987
15988 vector long long vec_vpopcnt (vector long long);
15989 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15990 vector int vec_vpopcnt (vector int);
15991 vector unsigned int vec_vpopcnt (vector int);
15992 vector short vec_vpopcnt (vector short);
15993 vector unsigned short vec_vpopcnt (vector unsigned short);
15994 vector signed char vec_vpopcnt (vector signed char);
15995 vector unsigned char vec_vpopcnt (vector unsigned char);
15996
15997 vector signed char vec_vpopcntb (vector signed char);
15998 vector unsigned char vec_vpopcntb (vector unsigned char);
15999
16000 vector long long vec_vpopcntd (vector long long);
16001 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16002
16003 vector short vec_vpopcnth (vector short);
16004 vector unsigned short vec_vpopcnth (vector unsigned short);
16005
16006 vector int vec_vpopcntw (vector int);
16007 vector unsigned int vec_vpopcntw (vector int);
16008
16009 vector long long vec_vrld (vector long long, vector unsigned long long);
16010 vector unsigned long long vec_vrld (vector unsigned long long,
16011 vector unsigned long long);
16012
16013 vector long long vec_vsld (vector long long, vector unsigned long long);
16014 vector long long vec_vsld (vector unsigned long long,
16015 vector unsigned long long);
16016
16017 vector long long vec_vsrad (vector long long, vector unsigned long long);
16018 vector unsigned long long vec_vsrad (vector unsigned long long,
16019 vector unsigned long long);
16020
16021 vector long long vec_vsrd (vector long long, vector unsigned long long);
16022 vector unsigned long long char vec_vsrd (vector unsigned long long,
16023 vector unsigned long long);
16024
16025 vector long long vec_vsubudm (vector long long, vector long long);
16026 vector long long vec_vsubudm (vector bool long long, vector long long);
16027 vector long long vec_vsubudm (vector long long, vector bool long long);
16028 vector unsigned long long vec_vsubudm (vector unsigned long long,
16029 vector unsigned long long);
16030 vector unsigned long long vec_vsubudm (vector bool long long,
16031 vector unsigned long long);
16032 vector unsigned long long vec_vsubudm (vector unsigned long long,
16033 vector bool long long);
16034
16035 vector long long vec_vupkhsw (vector int);
16036 vector unsigned long long vec_vupkhsw (vector unsigned int);
16037
16038 vector long long vec_vupklsw (vector int);
16039 vector unsigned long long vec_vupklsw (vector int);
16040 @end smallexample
16041
16042 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16043 instruction set is available, the following additional functions are
16044 available for 64-bit targets. New vector types
16045 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16046 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16047 builtins.
16048
16049 The normal vector extract, and set operations work on
16050 @var{vector __int128_t} and @var{vector __uint128_t} types,
16051 but the index value must be 0.
16052
16053 @smallexample
16054 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16055 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16056
16057 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16058 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16059
16060 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16061 vector __int128_t);
16062 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16063 vector __uint128_t);
16064
16065 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16066 vector __int128_t);
16067 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16068 vector __uint128_t);
16069
16070 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16071 vector __int128_t);
16072 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16073 vector __uint128_t);
16074
16075 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16076 vector __int128_t);
16077 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16078 vector __uint128_t);
16079
16080 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16081 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16082
16083 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16084 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16085
16086 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16087 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16088 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16089 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16090 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16091 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16092 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16093 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16094 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16095 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16096 @end smallexample
16097
16098 If the cryptographic instructions are enabled (@option{-mcrypto} or
16099 @option{-mcpu=power8}), the following builtins are enabled.
16100
16101 @smallexample
16102 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16103
16104 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16105 vector unsigned long long);
16106
16107 vector unsigned long long __builtin_crypto_vcipherlast
16108 (vector unsigned long long,
16109 vector unsigned long long);
16110
16111 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16112 vector unsigned long long);
16113
16114 vector unsigned long long __builtin_crypto_vncipherlast
16115 (vector unsigned long long,
16116 vector unsigned long long);
16117
16118 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16119 vector unsigned char,
16120 vector unsigned char);
16121
16122 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16123 vector unsigned short,
16124 vector unsigned short);
16125
16126 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16127 vector unsigned int,
16128 vector unsigned int);
16129
16130 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16131 vector unsigned long long,
16132 vector unsigned long long);
16133
16134 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16135 vector unsigned char);
16136
16137 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16138 vector unsigned short);
16139
16140 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16141 vector unsigned int);
16142
16143 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16144 vector unsigned long long);
16145
16146 vector unsigned long long __builtin_crypto_vshasigmad
16147 (vector unsigned long long, int, int);
16148
16149 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16150 int, int);
16151 @end smallexample
16152
16153 The second argument to the @var{__builtin_crypto_vshasigmad} and
16154 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16155 integer that is 0 or 1. The third argument to these builtin functions
16156 must be a constant integer in the range of 0 to 15.
16157
16158 @node PowerPC Hardware Transactional Memory Built-in Functions
16159 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16160 GCC provides two interfaces for accessing the Hardware Transactional
16161 Memory (HTM) instructions available on some of the PowerPC family
16162 of processors (eg, POWER8). The two interfaces come in a low level
16163 interface, consisting of built-in functions specific to PowerPC and a
16164 higher level interface consisting of inline functions that are common
16165 between PowerPC and S/390.
16166
16167 @subsubsection PowerPC HTM Low Level Built-in Functions
16168
16169 The following low level built-in functions are available with
16170 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16171 They all generate the machine instruction that is part of the name.
16172
16173 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16174 the full 4-bit condition register value set by their associated hardware
16175 instruction. The header file @code{htmintrin.h} defines some macros that can
16176 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16177 returns a simple true or false value depending on whether a transaction was
16178 successfully started or not. The arguments of the builtins match exactly the
16179 type and order of the associated hardware instruction's operands, except for
16180 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16181 Refer to the ISA manual for a description of each instruction's operands.
16182
16183 @smallexample
16184 unsigned int __builtin_tbegin (unsigned int)
16185 unsigned int __builtin_tend (unsigned int)
16186
16187 unsigned int __builtin_tabort (unsigned int)
16188 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16189 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16190 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16191 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16192
16193 unsigned int __builtin_tcheck (void)
16194 unsigned int __builtin_treclaim (unsigned int)
16195 unsigned int __builtin_trechkpt (void)
16196 unsigned int __builtin_tsr (unsigned int)
16197 @end smallexample
16198
16199 In addition to the above HTM built-ins, we have added built-ins for
16200 some common extended mnemonics of the HTM instructions:
16201
16202 @smallexample
16203 unsigned int __builtin_tendall (void)
16204 unsigned int __builtin_tresume (void)
16205 unsigned int __builtin_tsuspend (void)
16206 @end smallexample
16207
16208 Note that the semantics of the above HTM builtins are required to mimic
16209 the locking semantics used for critical sections. Builtins that are used
16210 to create a new transaction or restart a suspended transaction must have
16211 lock acquisition like semantics while those builtins that end or suspend a
16212 transaction must have lock release like semantics. Specifically, this must
16213 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16214 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16215 that returns 0, and lock release is as-if an execution of
16216 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16217 implicit implementation-defined lock used for all transactions. The HTM
16218 instructions associated with with the builtins inherently provide the
16219 correct acquisition and release hardware barriers required. However,
16220 the compiler must also be prohibited from moving loads and stores across
16221 the builtins in a way that would violate their semantics. This has been
16222 accomplished by adding memory barriers to the associated HTM instructions
16223 (which is a conservative approach to provide acquire and release semantics).
16224 Earlier versions of the compiler did not treat the HTM instructions as
16225 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16226 be used to determine whether the current compiler treats HTM instructions
16227 as memory barriers or not. This allows the user to explicitly add memory
16228 barriers to their code when using an older version of the compiler.
16229
16230 The following set of built-in functions are available to gain access
16231 to the HTM specific special purpose registers.
16232
16233 @smallexample
16234 unsigned long __builtin_get_texasr (void)
16235 unsigned long __builtin_get_texasru (void)
16236 unsigned long __builtin_get_tfhar (void)
16237 unsigned long __builtin_get_tfiar (void)
16238
16239 void __builtin_set_texasr (unsigned long);
16240 void __builtin_set_texasru (unsigned long);
16241 void __builtin_set_tfhar (unsigned long);
16242 void __builtin_set_tfiar (unsigned long);
16243 @end smallexample
16244
16245 Example usage of these low level built-in functions may look like:
16246
16247 @smallexample
16248 #include <htmintrin.h>
16249
16250 int num_retries = 10;
16251
16252 while (1)
16253 @{
16254 if (__builtin_tbegin (0))
16255 @{
16256 /* Transaction State Initiated. */
16257 if (is_locked (lock))
16258 __builtin_tabort (0);
16259 ... transaction code...
16260 __builtin_tend (0);
16261 break;
16262 @}
16263 else
16264 @{
16265 /* Transaction State Failed. Use locks if the transaction
16266 failure is "persistent" or we've tried too many times. */
16267 if (num_retries-- <= 0
16268 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16269 @{
16270 acquire_lock (lock);
16271 ... non transactional fallback path...
16272 release_lock (lock);
16273 break;
16274 @}
16275 @}
16276 @}
16277 @end smallexample
16278
16279 One final built-in function has been added that returns the value of
16280 the 2-bit Transaction State field of the Machine Status Register (MSR)
16281 as stored in @code{CR0}.
16282
16283 @smallexample
16284 unsigned long __builtin_ttest (void)
16285 @end smallexample
16286
16287 This built-in can be used to determine the current transaction state
16288 using the following code example:
16289
16290 @smallexample
16291 #include <htmintrin.h>
16292
16293 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16294
16295 if (tx_state == _HTM_TRANSACTIONAL)
16296 @{
16297 /* Code to use in transactional state. */
16298 @}
16299 else if (tx_state == _HTM_NONTRANSACTIONAL)
16300 @{
16301 /* Code to use in non-transactional state. */
16302 @}
16303 else if (tx_state == _HTM_SUSPENDED)
16304 @{
16305 /* Code to use in transaction suspended state. */
16306 @}
16307 @end smallexample
16308
16309 @subsubsection PowerPC HTM High Level Inline Functions
16310
16311 The following high level HTM interface is made available by including
16312 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16313 where CPU is `power8' or later. This interface is common between PowerPC
16314 and S/390, allowing users to write one HTM source implementation that
16315 can be compiled and executed on either system.
16316
16317 @smallexample
16318 long __TM_simple_begin (void)
16319 long __TM_begin (void* const TM_buff)
16320 long __TM_end (void)
16321 void __TM_abort (void)
16322 void __TM_named_abort (unsigned char const code)
16323 void __TM_resume (void)
16324 void __TM_suspend (void)
16325
16326 long __TM_is_user_abort (void* const TM_buff)
16327 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16328 long __TM_is_illegal (void* const TM_buff)
16329 long __TM_is_footprint_exceeded (void* const TM_buff)
16330 long __TM_nesting_depth (void* const TM_buff)
16331 long __TM_is_nested_too_deep(void* const TM_buff)
16332 long __TM_is_conflict(void* const TM_buff)
16333 long __TM_is_failure_persistent(void* const TM_buff)
16334 long __TM_failure_address(void* const TM_buff)
16335 long long __TM_failure_code(void* const TM_buff)
16336 @end smallexample
16337
16338 Using these common set of HTM inline functions, we can create
16339 a more portable version of the HTM example in the previous
16340 section that will work on either PowerPC or S/390:
16341
16342 @smallexample
16343 #include <htmxlintrin.h>
16344
16345 int num_retries = 10;
16346 TM_buff_type TM_buff;
16347
16348 while (1)
16349 @{
16350 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16351 @{
16352 /* Transaction State Initiated. */
16353 if (is_locked (lock))
16354 __TM_abort ();
16355 ... transaction code...
16356 __TM_end ();
16357 break;
16358 @}
16359 else
16360 @{
16361 /* Transaction State Failed. Use locks if the transaction
16362 failure is "persistent" or we've tried too many times. */
16363 if (num_retries-- <= 0
16364 || __TM_is_failure_persistent (TM_buff))
16365 @{
16366 acquire_lock (lock);
16367 ... non transactional fallback path...
16368 release_lock (lock);
16369 break;
16370 @}
16371 @}
16372 @}
16373 @end smallexample
16374
16375 @node RX Built-in Functions
16376 @subsection RX Built-in Functions
16377 GCC supports some of the RX instructions which cannot be expressed in
16378 the C programming language via the use of built-in functions. The
16379 following functions are supported:
16380
16381 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16382 Generates the @code{brk} machine instruction.
16383 @end deftypefn
16384
16385 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16386 Generates the @code{clrpsw} machine instruction to clear the specified
16387 bit in the processor status word.
16388 @end deftypefn
16389
16390 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16391 Generates the @code{int} machine instruction to generate an interrupt
16392 with the specified value.
16393 @end deftypefn
16394
16395 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16396 Generates the @code{machi} machine instruction to add the result of
16397 multiplying the top 16 bits of the two arguments into the
16398 accumulator.
16399 @end deftypefn
16400
16401 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16402 Generates the @code{maclo} machine instruction to add the result of
16403 multiplying the bottom 16 bits of the two arguments into the
16404 accumulator.
16405 @end deftypefn
16406
16407 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16408 Generates the @code{mulhi} machine instruction to place the result of
16409 multiplying the top 16 bits of the two arguments into the
16410 accumulator.
16411 @end deftypefn
16412
16413 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16414 Generates the @code{mullo} machine instruction to place the result of
16415 multiplying the bottom 16 bits of the two arguments into the
16416 accumulator.
16417 @end deftypefn
16418
16419 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16420 Generates the @code{mvfachi} machine instruction to read the top
16421 32 bits of the accumulator.
16422 @end deftypefn
16423
16424 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16425 Generates the @code{mvfacmi} machine instruction to read the middle
16426 32 bits of the accumulator.
16427 @end deftypefn
16428
16429 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16430 Generates the @code{mvfc} machine instruction which reads the control
16431 register specified in its argument and returns its value.
16432 @end deftypefn
16433
16434 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16435 Generates the @code{mvtachi} machine instruction to set the top
16436 32 bits of the accumulator.
16437 @end deftypefn
16438
16439 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16440 Generates the @code{mvtaclo} machine instruction to set the bottom
16441 32 bits of the accumulator.
16442 @end deftypefn
16443
16444 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16445 Generates the @code{mvtc} machine instruction which sets control
16446 register number @code{reg} to @code{val}.
16447 @end deftypefn
16448
16449 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16450 Generates the @code{mvtipl} machine instruction set the interrupt
16451 priority level.
16452 @end deftypefn
16453
16454 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16455 Generates the @code{racw} machine instruction to round the accumulator
16456 according to the specified mode.
16457 @end deftypefn
16458
16459 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16460 Generates the @code{revw} machine instruction which swaps the bytes in
16461 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16462 and also bits 16--23 occupy bits 24--31 and vice versa.
16463 @end deftypefn
16464
16465 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16466 Generates the @code{rmpa} machine instruction which initiates a
16467 repeated multiply and accumulate sequence.
16468 @end deftypefn
16469
16470 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16471 Generates the @code{round} machine instruction which returns the
16472 floating-point argument rounded according to the current rounding mode
16473 set in the floating-point status word register.
16474 @end deftypefn
16475
16476 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16477 Generates the @code{sat} machine instruction which returns the
16478 saturated value of the argument.
16479 @end deftypefn
16480
16481 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16482 Generates the @code{setpsw} machine instruction to set the specified
16483 bit in the processor status word.
16484 @end deftypefn
16485
16486 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16487 Generates the @code{wait} machine instruction.
16488 @end deftypefn
16489
16490 @node S/390 System z Built-in Functions
16491 @subsection S/390 System z Built-in Functions
16492 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16493 Generates the @code{tbegin} machine instruction starting a
16494 non-constraint hardware transaction. If the parameter is non-NULL the
16495 memory area is used to store the transaction diagnostic buffer and
16496 will be passed as first operand to @code{tbegin}. This buffer can be
16497 defined using the @code{struct __htm_tdb} C struct defined in
16498 @code{htmintrin.h} and must reside on a double-word boundary. The
16499 second tbegin operand is set to @code{0xff0c}. This enables
16500 save/restore of all GPRs and disables aborts for FPR and AR
16501 manipulations inside the transaction body. The condition code set by
16502 the tbegin instruction is returned as integer value. The tbegin
16503 instruction by definition overwrites the content of all FPRs. The
16504 compiler will generate code which saves and restores the FPRs. For
16505 soft-float code it is recommended to used the @code{*_nofloat}
16506 variant. In order to prevent a TDB from being written it is required
16507 to pass an constant zero value as parameter. Passing the zero value
16508 through a variable is not sufficient. Although modifications of
16509 access registers inside the transaction will not trigger an
16510 transaction abort it is not supported to actually modify them. Access
16511 registers do not get saved when entering a transaction. They will have
16512 undefined state when reaching the abort code.
16513 @end deftypefn
16514
16515 Macros for the possible return codes of tbegin are defined in the
16516 @code{htmintrin.h} header file:
16517
16518 @table @code
16519 @item _HTM_TBEGIN_STARTED
16520 @code{tbegin} has been executed as part of normal processing. The
16521 transaction body is supposed to be executed.
16522 @item _HTM_TBEGIN_INDETERMINATE
16523 The transaction was aborted due to an indeterminate condition which
16524 might be persistent.
16525 @item _HTM_TBEGIN_TRANSIENT
16526 The transaction aborted due to a transient failure. The transaction
16527 should be re-executed in that case.
16528 @item _HTM_TBEGIN_PERSISTENT
16529 The transaction aborted due to a persistent failure. Re-execution
16530 under same circumstances will not be productive.
16531 @end table
16532
16533 @defmac _HTM_FIRST_USER_ABORT_CODE
16534 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16535 specifies the first abort code which can be used for
16536 @code{__builtin_tabort}. Values below this threshold are reserved for
16537 machine use.
16538 @end defmac
16539
16540 @deftp {Data type} {struct __htm_tdb}
16541 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16542 the structure of the transaction diagnostic block as specified in the
16543 Principles of Operation manual chapter 5-91.
16544 @end deftp
16545
16546 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16547 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16548 Using this variant in code making use of FPRs will leave the FPRs in
16549 undefined state when entering the transaction abort handler code.
16550 @end deftypefn
16551
16552 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16553 In addition to @code{__builtin_tbegin} a loop for transient failures
16554 is generated. If tbegin returns a condition code of 2 the transaction
16555 will be retried as often as specified in the second argument. The
16556 perform processor assist instruction is used to tell the CPU about the
16557 number of fails so far.
16558 @end deftypefn
16559
16560 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16561 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16562 restores. Using this variant in code making use of FPRs will leave
16563 the FPRs in undefined state when entering the transaction abort
16564 handler code.
16565 @end deftypefn
16566
16567 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16568 Generates the @code{tbeginc} machine instruction starting a constraint
16569 hardware transaction. The second operand is set to @code{0xff08}.
16570 @end deftypefn
16571
16572 @deftypefn {Built-in Function} int __builtin_tend (void)
16573 Generates the @code{tend} machine instruction finishing a transaction
16574 and making the changes visible to other threads. The condition code
16575 generated by tend is returned as integer value.
16576 @end deftypefn
16577
16578 @deftypefn {Built-in Function} void __builtin_tabort (int)
16579 Generates the @code{tabort} machine instruction with the specified
16580 abort code. Abort codes from 0 through 255 are reserved and will
16581 result in an error message.
16582 @end deftypefn
16583
16584 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16585 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16586 integer parameter is loaded into rX and a value of zero is loaded into
16587 rY. The integer parameter specifies the number of times the
16588 transaction repeatedly aborted.
16589 @end deftypefn
16590
16591 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16592 Generates the @code{etnd} machine instruction. The current nesting
16593 depth is returned as integer value. For a nesting depth of 0 the code
16594 is not executed as part of an transaction.
16595 @end deftypefn
16596
16597 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16598
16599 Generates the @code{ntstg} machine instruction. The second argument
16600 is written to the first arguments location. The store operation will
16601 not be rolled-back in case of an transaction abort.
16602 @end deftypefn
16603
16604 @node SH Built-in Functions
16605 @subsection SH Built-in Functions
16606 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16607 families of processors:
16608
16609 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16610 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16611 used by system code that manages threads and execution contexts. The compiler
16612 normally does not generate code that modifies the contents of @samp{GBR} and
16613 thus the value is preserved across function calls. Changing the @samp{GBR}
16614 value in user code must be done with caution, since the compiler might use
16615 @samp{GBR} in order to access thread local variables.
16616
16617 @end deftypefn
16618
16619 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16620 Returns the value that is currently set in the @samp{GBR} register.
16621 Memory loads and stores that use the thread pointer as a base address are
16622 turned into @samp{GBR} based displacement loads and stores, if possible.
16623 For example:
16624 @smallexample
16625 struct my_tcb
16626 @{
16627 int a, b, c, d, e;
16628 @};
16629
16630 int get_tcb_value (void)
16631 @{
16632 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16633 return ((my_tcb*)__builtin_thread_pointer ())->c;
16634 @}
16635
16636 @end smallexample
16637 @end deftypefn
16638
16639 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16640 Returns the value that is currently set in the @samp{FPSCR} register.
16641 @end deftypefn
16642
16643 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16644 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16645 preserving the current values of the FR, SZ and PR bits.
16646 @end deftypefn
16647
16648 @node SPARC VIS Built-in Functions
16649 @subsection SPARC VIS Built-in Functions
16650
16651 GCC supports SIMD operations on the SPARC using both the generic vector
16652 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16653 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16654 switch, the VIS extension is exposed as the following built-in functions:
16655
16656 @smallexample
16657 typedef int v1si __attribute__ ((vector_size (4)));
16658 typedef int v2si __attribute__ ((vector_size (8)));
16659 typedef short v4hi __attribute__ ((vector_size (8)));
16660 typedef short v2hi __attribute__ ((vector_size (4)));
16661 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16662 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16663
16664 void __builtin_vis_write_gsr (int64_t);
16665 int64_t __builtin_vis_read_gsr (void);
16666
16667 void * __builtin_vis_alignaddr (void *, long);
16668 void * __builtin_vis_alignaddrl (void *, long);
16669 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16670 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16671 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16672 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16673
16674 v4hi __builtin_vis_fexpand (v4qi);
16675
16676 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16677 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16678 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16679 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16680 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16681 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16682 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16683
16684 v4qi __builtin_vis_fpack16 (v4hi);
16685 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16686 v2hi __builtin_vis_fpackfix (v2si);
16687 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16688
16689 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16690
16691 long __builtin_vis_edge8 (void *, void *);
16692 long __builtin_vis_edge8l (void *, void *);
16693 long __builtin_vis_edge16 (void *, void *);
16694 long __builtin_vis_edge16l (void *, void *);
16695 long __builtin_vis_edge32 (void *, void *);
16696 long __builtin_vis_edge32l (void *, void *);
16697
16698 long __builtin_vis_fcmple16 (v4hi, v4hi);
16699 long __builtin_vis_fcmple32 (v2si, v2si);
16700 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16701 long __builtin_vis_fcmpne32 (v2si, v2si);
16702 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16703 long __builtin_vis_fcmpgt32 (v2si, v2si);
16704 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16705 long __builtin_vis_fcmpeq32 (v2si, v2si);
16706
16707 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16708 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16709 v2si __builtin_vis_fpadd32 (v2si, v2si);
16710 v1si __builtin_vis_fpadd32s (v1si, v1si);
16711 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16712 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16713 v2si __builtin_vis_fpsub32 (v2si, v2si);
16714 v1si __builtin_vis_fpsub32s (v1si, v1si);
16715
16716 long __builtin_vis_array8 (long, long);
16717 long __builtin_vis_array16 (long, long);
16718 long __builtin_vis_array32 (long, long);
16719 @end smallexample
16720
16721 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16722 functions also become available:
16723
16724 @smallexample
16725 long __builtin_vis_bmask (long, long);
16726 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16727 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16728 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16729 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16730
16731 long __builtin_vis_edge8n (void *, void *);
16732 long __builtin_vis_edge8ln (void *, void *);
16733 long __builtin_vis_edge16n (void *, void *);
16734 long __builtin_vis_edge16ln (void *, void *);
16735 long __builtin_vis_edge32n (void *, void *);
16736 long __builtin_vis_edge32ln (void *, void *);
16737 @end smallexample
16738
16739 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16740 functions also become available:
16741
16742 @smallexample
16743 void __builtin_vis_cmask8 (long);
16744 void __builtin_vis_cmask16 (long);
16745 void __builtin_vis_cmask32 (long);
16746
16747 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16748
16749 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16750 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16751 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16752 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16753 v2si __builtin_vis_fsll16 (v2si, v2si);
16754 v2si __builtin_vis_fslas16 (v2si, v2si);
16755 v2si __builtin_vis_fsrl16 (v2si, v2si);
16756 v2si __builtin_vis_fsra16 (v2si, v2si);
16757
16758 long __builtin_vis_pdistn (v8qi, v8qi);
16759
16760 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16761
16762 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16763 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16764
16765 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16766 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16767 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16768 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16769 v2si __builtin_vis_fpadds32 (v2si, v2si);
16770 v1si __builtin_vis_fpadds32s (v1si, v1si);
16771 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16772 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16773
16774 long __builtin_vis_fucmple8 (v8qi, v8qi);
16775 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16776 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16777 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16778
16779 float __builtin_vis_fhadds (float, float);
16780 double __builtin_vis_fhaddd (double, double);
16781 float __builtin_vis_fhsubs (float, float);
16782 double __builtin_vis_fhsubd (double, double);
16783 float __builtin_vis_fnhadds (float, float);
16784 double __builtin_vis_fnhaddd (double, double);
16785
16786 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16787 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16788 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16789 @end smallexample
16790
16791 @node SPU Built-in Functions
16792 @subsection SPU Built-in Functions
16793
16794 GCC provides extensions for the SPU processor as described in the
16795 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16796 found at @uref{http://cell.scei.co.jp/} or
16797 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
16798 implementation differs in several ways.
16799
16800 @itemize @bullet
16801
16802 @item
16803 The optional extension of specifying vector constants in parentheses is
16804 not supported.
16805
16806 @item
16807 A vector initializer requires no cast if the vector constant is of the
16808 same type as the variable it is initializing.
16809
16810 @item
16811 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16812 vector type is the default signedness of the base type. The default
16813 varies depending on the operating system, so a portable program should
16814 always specify the signedness.
16815
16816 @item
16817 By default, the keyword @code{__vector} is added. The macro
16818 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16819 undefined.
16820
16821 @item
16822 GCC allows using a @code{typedef} name as the type specifier for a
16823 vector type.
16824
16825 @item
16826 For C, overloaded functions are implemented with macros so the following
16827 does not work:
16828
16829 @smallexample
16830 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16831 @end smallexample
16832
16833 @noindent
16834 Since @code{spu_add} is a macro, the vector constant in the example
16835 is treated as four separate arguments. Wrap the entire argument in
16836 parentheses for this to work.
16837
16838 @item
16839 The extended version of @code{__builtin_expect} is not supported.
16840
16841 @end itemize
16842
16843 @emph{Note:} Only the interface described in the aforementioned
16844 specification is supported. Internally, GCC uses built-in functions to
16845 implement the required functionality, but these are not supported and
16846 are subject to change without notice.
16847
16848 @node TI C6X Built-in Functions
16849 @subsection TI C6X Built-in Functions
16850
16851 GCC provides intrinsics to access certain instructions of the TI C6X
16852 processors. These intrinsics, listed below, are available after
16853 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
16854 to C6X instructions.
16855
16856 @smallexample
16857
16858 int _sadd (int, int)
16859 int _ssub (int, int)
16860 int _sadd2 (int, int)
16861 int _ssub2 (int, int)
16862 long long _mpy2 (int, int)
16863 long long _smpy2 (int, int)
16864 int _add4 (int, int)
16865 int _sub4 (int, int)
16866 int _saddu4 (int, int)
16867
16868 int _smpy (int, int)
16869 int _smpyh (int, int)
16870 int _smpyhl (int, int)
16871 int _smpylh (int, int)
16872
16873 int _sshl (int, int)
16874 int _subc (int, int)
16875
16876 int _avg2 (int, int)
16877 int _avgu4 (int, int)
16878
16879 int _clrr (int, int)
16880 int _extr (int, int)
16881 int _extru (int, int)
16882 int _abs (int)
16883 int _abs2 (int)
16884
16885 @end smallexample
16886
16887 @node TILE-Gx Built-in Functions
16888 @subsection TILE-Gx Built-in Functions
16889
16890 GCC provides intrinsics to access every instruction of the TILE-Gx
16891 processor. The intrinsics are of the form:
16892
16893 @smallexample
16894
16895 unsigned long long __insn_@var{op} (...)
16896
16897 @end smallexample
16898
16899 Where @var{op} is the name of the instruction. Refer to the ISA manual
16900 for the complete list of instructions.
16901
16902 GCC also provides intrinsics to directly access the network registers.
16903 The intrinsics are:
16904
16905 @smallexample
16906
16907 unsigned long long __tile_idn0_receive (void)
16908 unsigned long long __tile_idn1_receive (void)
16909 unsigned long long __tile_udn0_receive (void)
16910 unsigned long long __tile_udn1_receive (void)
16911 unsigned long long __tile_udn2_receive (void)
16912 unsigned long long __tile_udn3_receive (void)
16913 void __tile_idn_send (unsigned long long)
16914 void __tile_udn_send (unsigned long long)
16915
16916 @end smallexample
16917
16918 The intrinsic @code{void __tile_network_barrier (void)} is used to
16919 guarantee that no network operations before it are reordered with
16920 those after it.
16921
16922 @node TILEPro Built-in Functions
16923 @subsection TILEPro Built-in Functions
16924
16925 GCC provides intrinsics to access every instruction of the TILEPro
16926 processor. The intrinsics are of the form:
16927
16928 @smallexample
16929
16930 unsigned __insn_@var{op} (...)
16931
16932 @end smallexample
16933
16934 @noindent
16935 where @var{op} is the name of the instruction. Refer to the ISA manual
16936 for the complete list of instructions.
16937
16938 GCC also provides intrinsics to directly access the network registers.
16939 The intrinsics are:
16940
16941 @smallexample
16942
16943 unsigned __tile_idn0_receive (void)
16944 unsigned __tile_idn1_receive (void)
16945 unsigned __tile_sn_receive (void)
16946 unsigned __tile_udn0_receive (void)
16947 unsigned __tile_udn1_receive (void)
16948 unsigned __tile_udn2_receive (void)
16949 unsigned __tile_udn3_receive (void)
16950 void __tile_idn_send (unsigned)
16951 void __tile_sn_send (unsigned)
16952 void __tile_udn_send (unsigned)
16953
16954 @end smallexample
16955
16956 The intrinsic @code{void __tile_network_barrier (void)} is used to
16957 guarantee that no network operations before it are reordered with
16958 those after it.
16959
16960 @node x86 Built-in Functions
16961 @subsection x86 Built-in Functions
16962
16963 These built-in functions are available for the x86-32 and x86-64 family
16964 of computers, depending on the command-line switches used.
16965
16966 If you specify command-line switches such as @option{-msse},
16967 the compiler could use the extended instruction sets even if the built-ins
16968 are not used explicitly in the program. For this reason, applications
16969 that perform run-time CPU detection must compile separate files for each
16970 supported architecture, using the appropriate flags. In particular,
16971 the file containing the CPU detection code should be compiled without
16972 these options.
16973
16974 The following machine modes are available for use with MMX built-in functions
16975 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
16976 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
16977 vector of eight 8-bit integers. Some of the built-in functions operate on
16978 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
16979
16980 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
16981 of two 32-bit floating-point values.
16982
16983 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
16984 floating-point values. Some instructions use a vector of four 32-bit
16985 integers, these use @code{V4SI}. Finally, some instructions operate on an
16986 entire vector register, interpreting it as a 128-bit integer, these use mode
16987 @code{TI}.
16988
16989 In 64-bit mode, the x86-64 family of processors uses additional built-in
16990 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
16991 floating point and @code{TC} 128-bit complex floating-point values.
16992
16993 The following floating-point built-in functions are available in 64-bit
16994 mode. All of them implement the function that is part of the name.
16995
16996 @smallexample
16997 __float128 __builtin_fabsq (__float128)
16998 __float128 __builtin_copysignq (__float128, __float128)
16999 @end smallexample
17000
17001 The following built-in function is always available.
17002
17003 @table @code
17004 @item void __builtin_ia32_pause (void)
17005 Generates the @code{pause} machine instruction with a compiler memory
17006 barrier.
17007 @end table
17008
17009 The following floating-point built-in functions are made available in the
17010 64-bit mode.
17011
17012 @table @code
17013 @item __float128 __builtin_infq (void)
17014 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
17015 @findex __builtin_infq
17016
17017 @item __float128 __builtin_huge_valq (void)
17018 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
17019 @findex __builtin_huge_valq
17020 @end table
17021
17022 The following built-in functions are always available and can be used to
17023 check the target platform type.
17024
17025 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
17026 This function runs the CPU detection code to check the type of CPU and the
17027 features supported. This built-in function needs to be invoked along with the built-in functions
17028 to check CPU type and features, @code{__builtin_cpu_is} and
17029 @code{__builtin_cpu_supports}, only when used in a function that is
17030 executed before any constructors are called. The CPU detection code is
17031 automatically executed in a very high priority constructor.
17032
17033 For example, this function has to be used in @code{ifunc} resolvers that
17034 check for CPU type using the built-in functions @code{__builtin_cpu_is}
17035 and @code{__builtin_cpu_supports}, or in constructors on targets that
17036 don't support constructor priority.
17037 @smallexample
17038
17039 static void (*resolve_memcpy (void)) (void)
17040 @{
17041 // ifunc resolvers fire before constructors, explicitly call the init
17042 // function.
17043 __builtin_cpu_init ();
17044 if (__builtin_cpu_supports ("ssse3"))
17045 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
17046 else
17047 return default_memcpy;
17048 @}
17049
17050 void *memcpy (void *, const void *, size_t)
17051 __attribute__ ((ifunc ("resolve_memcpy")));
17052 @end smallexample
17053
17054 @end deftypefn
17055
17056 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
17057 This function returns a positive integer if the run-time CPU
17058 is of type @var{cpuname}
17059 and returns @code{0} otherwise. The following CPU names can be detected:
17060
17061 @table @samp
17062 @item intel
17063 Intel CPU.
17064
17065 @item atom
17066 Intel Atom CPU.
17067
17068 @item core2
17069 Intel Core 2 CPU.
17070
17071 @item corei7
17072 Intel Core i7 CPU.
17073
17074 @item nehalem
17075 Intel Core i7 Nehalem CPU.
17076
17077 @item westmere
17078 Intel Core i7 Westmere CPU.
17079
17080 @item sandybridge
17081 Intel Core i7 Sandy Bridge CPU.
17082
17083 @item amd
17084 AMD CPU.
17085
17086 @item amdfam10h
17087 AMD Family 10h CPU.
17088
17089 @item barcelona
17090 AMD Family 10h Barcelona CPU.
17091
17092 @item shanghai
17093 AMD Family 10h Shanghai CPU.
17094
17095 @item istanbul
17096 AMD Family 10h Istanbul CPU.
17097
17098 @item btver1
17099 AMD Family 14h CPU.
17100
17101 @item amdfam15h
17102 AMD Family 15h CPU.
17103
17104 @item bdver1
17105 AMD Family 15h Bulldozer version 1.
17106
17107 @item bdver2
17108 AMD Family 15h Bulldozer version 2.
17109
17110 @item bdver3
17111 AMD Family 15h Bulldozer version 3.
17112
17113 @item bdver4
17114 AMD Family 15h Bulldozer version 4.
17115
17116 @item btver2
17117 AMD Family 16h CPU.
17118
17119 @item znver1
17120 AMD Family 17h CPU.
17121 @end table
17122
17123 Here is an example:
17124 @smallexample
17125 if (__builtin_cpu_is ("corei7"))
17126 @{
17127 do_corei7 (); // Core i7 specific implementation.
17128 @}
17129 else
17130 @{
17131 do_generic (); // Generic implementation.
17132 @}
17133 @end smallexample
17134 @end deftypefn
17135
17136 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17137 This function returns a positive integer if the run-time CPU
17138 supports @var{feature}
17139 and returns @code{0} otherwise. The following features can be detected:
17140
17141 @table @samp
17142 @item cmov
17143 CMOV instruction.
17144 @item mmx
17145 MMX instructions.
17146 @item popcnt
17147 POPCNT instruction.
17148 @item sse
17149 SSE instructions.
17150 @item sse2
17151 SSE2 instructions.
17152 @item sse3
17153 SSE3 instructions.
17154 @item ssse3
17155 SSSE3 instructions.
17156 @item sse4.1
17157 SSE4.1 instructions.
17158 @item sse4.2
17159 SSE4.2 instructions.
17160 @item avx
17161 AVX instructions.
17162 @item avx2
17163 AVX2 instructions.
17164 @item avx512f
17165 AVX512F instructions.
17166 @end table
17167
17168 Here is an example:
17169 @smallexample
17170 if (__builtin_cpu_supports ("popcnt"))
17171 @{
17172 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17173 @}
17174 else
17175 @{
17176 count = generic_countbits (n); //generic implementation.
17177 @}
17178 @end smallexample
17179 @end deftypefn
17180
17181
17182 The following built-in functions are made available by @option{-mmmx}.
17183 All of them generate the machine instruction that is part of the name.
17184
17185 @smallexample
17186 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17187 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17188 v2si __builtin_ia32_paddd (v2si, v2si)
17189 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17190 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17191 v2si __builtin_ia32_psubd (v2si, v2si)
17192 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17193 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17194 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17195 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17196 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17197 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17198 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17199 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17200 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17201 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17202 di __builtin_ia32_pand (di, di)
17203 di __builtin_ia32_pandn (di,di)
17204 di __builtin_ia32_por (di, di)
17205 di __builtin_ia32_pxor (di, di)
17206 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17207 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17208 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17209 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17210 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17211 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17212 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17213 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17214 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17215 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17216 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17217 v2si __builtin_ia32_punpckldq (v2si, v2si)
17218 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17219 v4hi __builtin_ia32_packssdw (v2si, v2si)
17220 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17221
17222 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17223 v2si __builtin_ia32_pslld (v2si, v2si)
17224 v1di __builtin_ia32_psllq (v1di, v1di)
17225 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17226 v2si __builtin_ia32_psrld (v2si, v2si)
17227 v1di __builtin_ia32_psrlq (v1di, v1di)
17228 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17229 v2si __builtin_ia32_psrad (v2si, v2si)
17230 v4hi __builtin_ia32_psllwi (v4hi, int)
17231 v2si __builtin_ia32_pslldi (v2si, int)
17232 v1di __builtin_ia32_psllqi (v1di, int)
17233 v4hi __builtin_ia32_psrlwi (v4hi, int)
17234 v2si __builtin_ia32_psrldi (v2si, int)
17235 v1di __builtin_ia32_psrlqi (v1di, int)
17236 v4hi __builtin_ia32_psrawi (v4hi, int)
17237 v2si __builtin_ia32_psradi (v2si, int)
17238
17239 @end smallexample
17240
17241 The following built-in functions are made available either with
17242 @option{-msse}, or with a combination of @option{-m3dnow} and
17243 @option{-march=athlon}. All of them generate the machine
17244 instruction that is part of the name.
17245
17246 @smallexample
17247 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17248 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17249 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17250 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17251 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17252 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17253 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17254 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17255 int __builtin_ia32_pmovmskb (v8qi)
17256 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17257 void __builtin_ia32_movntq (di *, di)
17258 void __builtin_ia32_sfence (void)
17259 @end smallexample
17260
17261 The following built-in functions are available when @option{-msse} is used.
17262 All of them generate the machine instruction that is part of the name.
17263
17264 @smallexample
17265 int __builtin_ia32_comieq (v4sf, v4sf)
17266 int __builtin_ia32_comineq (v4sf, v4sf)
17267 int __builtin_ia32_comilt (v4sf, v4sf)
17268 int __builtin_ia32_comile (v4sf, v4sf)
17269 int __builtin_ia32_comigt (v4sf, v4sf)
17270 int __builtin_ia32_comige (v4sf, v4sf)
17271 int __builtin_ia32_ucomieq (v4sf, v4sf)
17272 int __builtin_ia32_ucomineq (v4sf, v4sf)
17273 int __builtin_ia32_ucomilt (v4sf, v4sf)
17274 int __builtin_ia32_ucomile (v4sf, v4sf)
17275 int __builtin_ia32_ucomigt (v4sf, v4sf)
17276 int __builtin_ia32_ucomige (v4sf, v4sf)
17277 v4sf __builtin_ia32_addps (v4sf, v4sf)
17278 v4sf __builtin_ia32_subps (v4sf, v4sf)
17279 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17280 v4sf __builtin_ia32_divps (v4sf, v4sf)
17281 v4sf __builtin_ia32_addss (v4sf, v4sf)
17282 v4sf __builtin_ia32_subss (v4sf, v4sf)
17283 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17284 v4sf __builtin_ia32_divss (v4sf, v4sf)
17285 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17286 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17287 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17288 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17289 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17290 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17291 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17292 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17293 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17294 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17295 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17296 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17297 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17298 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17299 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17300 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17301 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17302 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17303 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17304 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17305 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17306 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17307 v4sf __builtin_ia32_minps (v4sf, v4sf)
17308 v4sf __builtin_ia32_minss (v4sf, v4sf)
17309 v4sf __builtin_ia32_andps (v4sf, v4sf)
17310 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17311 v4sf __builtin_ia32_orps (v4sf, v4sf)
17312 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17313 v4sf __builtin_ia32_movss (v4sf, v4sf)
17314 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17315 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17316 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17317 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17318 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17319 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17320 v2si __builtin_ia32_cvtps2pi (v4sf)
17321 int __builtin_ia32_cvtss2si (v4sf)
17322 v2si __builtin_ia32_cvttps2pi (v4sf)
17323 int __builtin_ia32_cvttss2si (v4sf)
17324 v4sf __builtin_ia32_rcpps (v4sf)
17325 v4sf __builtin_ia32_rsqrtps (v4sf)
17326 v4sf __builtin_ia32_sqrtps (v4sf)
17327 v4sf __builtin_ia32_rcpss (v4sf)
17328 v4sf __builtin_ia32_rsqrtss (v4sf)
17329 v4sf __builtin_ia32_sqrtss (v4sf)
17330 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17331 void __builtin_ia32_movntps (float *, v4sf)
17332 int __builtin_ia32_movmskps (v4sf)
17333 @end smallexample
17334
17335 The following built-in functions are available when @option{-msse} is used.
17336
17337 @table @code
17338 @item v4sf __builtin_ia32_loadups (float *)
17339 Generates the @code{movups} machine instruction as a load from memory.
17340 @item void __builtin_ia32_storeups (float *, v4sf)
17341 Generates the @code{movups} machine instruction as a store to memory.
17342 @item v4sf __builtin_ia32_loadss (float *)
17343 Generates the @code{movss} machine instruction as a load from memory.
17344 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17345 Generates the @code{movhps} machine instruction as a load from memory.
17346 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17347 Generates the @code{movlps} machine instruction as a load from memory
17348 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17349 Generates the @code{movhps} machine instruction as a store to memory.
17350 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17351 Generates the @code{movlps} machine instruction as a store to memory.
17352 @end table
17353
17354 The following built-in functions are available when @option{-msse2} is used.
17355 All of them generate the machine instruction that is part of the name.
17356
17357 @smallexample
17358 int __builtin_ia32_comisdeq (v2df, v2df)
17359 int __builtin_ia32_comisdlt (v2df, v2df)
17360 int __builtin_ia32_comisdle (v2df, v2df)
17361 int __builtin_ia32_comisdgt (v2df, v2df)
17362 int __builtin_ia32_comisdge (v2df, v2df)
17363 int __builtin_ia32_comisdneq (v2df, v2df)
17364 int __builtin_ia32_ucomisdeq (v2df, v2df)
17365 int __builtin_ia32_ucomisdlt (v2df, v2df)
17366 int __builtin_ia32_ucomisdle (v2df, v2df)
17367 int __builtin_ia32_ucomisdgt (v2df, v2df)
17368 int __builtin_ia32_ucomisdge (v2df, v2df)
17369 int __builtin_ia32_ucomisdneq (v2df, v2df)
17370 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17371 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17372 v2df __builtin_ia32_cmplepd (v2df, v2df)
17373 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17374 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17375 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17376 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17377 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17378 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17379 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17380 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17381 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17382 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17383 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17384 v2df __builtin_ia32_cmplesd (v2df, v2df)
17385 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17386 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17387 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17388 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17389 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17390 v2di __builtin_ia32_paddq (v2di, v2di)
17391 v2di __builtin_ia32_psubq (v2di, v2di)
17392 v2df __builtin_ia32_addpd (v2df, v2df)
17393 v2df __builtin_ia32_subpd (v2df, v2df)
17394 v2df __builtin_ia32_mulpd (v2df, v2df)
17395 v2df __builtin_ia32_divpd (v2df, v2df)
17396 v2df __builtin_ia32_addsd (v2df, v2df)
17397 v2df __builtin_ia32_subsd (v2df, v2df)
17398 v2df __builtin_ia32_mulsd (v2df, v2df)
17399 v2df __builtin_ia32_divsd (v2df, v2df)
17400 v2df __builtin_ia32_minpd (v2df, v2df)
17401 v2df __builtin_ia32_maxpd (v2df, v2df)
17402 v2df __builtin_ia32_minsd (v2df, v2df)
17403 v2df __builtin_ia32_maxsd (v2df, v2df)
17404 v2df __builtin_ia32_andpd (v2df, v2df)
17405 v2df __builtin_ia32_andnpd (v2df, v2df)
17406 v2df __builtin_ia32_orpd (v2df, v2df)
17407 v2df __builtin_ia32_xorpd (v2df, v2df)
17408 v2df __builtin_ia32_movsd (v2df, v2df)
17409 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17410 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17411 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17412 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17413 v4si __builtin_ia32_paddd128 (v4si, v4si)
17414 v2di __builtin_ia32_paddq128 (v2di, v2di)
17415 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17416 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17417 v4si __builtin_ia32_psubd128 (v4si, v4si)
17418 v2di __builtin_ia32_psubq128 (v2di, v2di)
17419 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17420 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17421 v2di __builtin_ia32_pand128 (v2di, v2di)
17422 v2di __builtin_ia32_pandn128 (v2di, v2di)
17423 v2di __builtin_ia32_por128 (v2di, v2di)
17424 v2di __builtin_ia32_pxor128 (v2di, v2di)
17425 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17426 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17427 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17428 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17429 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17430 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17431 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17432 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17433 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17434 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17435 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17436 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17437 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17438 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17439 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17440 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17441 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17442 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17443 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17444 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17445 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17446 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17447 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17448 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17449 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17450 v2df __builtin_ia32_loadupd (double *)
17451 void __builtin_ia32_storeupd (double *, v2df)
17452 v2df __builtin_ia32_loadhpd (v2df, double const *)
17453 v2df __builtin_ia32_loadlpd (v2df, double const *)
17454 int __builtin_ia32_movmskpd (v2df)
17455 int __builtin_ia32_pmovmskb128 (v16qi)
17456 void __builtin_ia32_movnti (int *, int)
17457 void __builtin_ia32_movnti64 (long long int *, long long int)
17458 void __builtin_ia32_movntpd (double *, v2df)
17459 void __builtin_ia32_movntdq (v2df *, v2df)
17460 v4si __builtin_ia32_pshufd (v4si, int)
17461 v8hi __builtin_ia32_pshuflw (v8hi, int)
17462 v8hi __builtin_ia32_pshufhw (v8hi, int)
17463 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17464 v2df __builtin_ia32_sqrtpd (v2df)
17465 v2df __builtin_ia32_sqrtsd (v2df)
17466 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17467 v2df __builtin_ia32_cvtdq2pd (v4si)
17468 v4sf __builtin_ia32_cvtdq2ps (v4si)
17469 v4si __builtin_ia32_cvtpd2dq (v2df)
17470 v2si __builtin_ia32_cvtpd2pi (v2df)
17471 v4sf __builtin_ia32_cvtpd2ps (v2df)
17472 v4si __builtin_ia32_cvttpd2dq (v2df)
17473 v2si __builtin_ia32_cvttpd2pi (v2df)
17474 v2df __builtin_ia32_cvtpi2pd (v2si)
17475 int __builtin_ia32_cvtsd2si (v2df)
17476 int __builtin_ia32_cvttsd2si (v2df)
17477 long long __builtin_ia32_cvtsd2si64 (v2df)
17478 long long __builtin_ia32_cvttsd2si64 (v2df)
17479 v4si __builtin_ia32_cvtps2dq (v4sf)
17480 v2df __builtin_ia32_cvtps2pd (v4sf)
17481 v4si __builtin_ia32_cvttps2dq (v4sf)
17482 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17483 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17484 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17485 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17486 void __builtin_ia32_clflush (const void *)
17487 void __builtin_ia32_lfence (void)
17488 void __builtin_ia32_mfence (void)
17489 v16qi __builtin_ia32_loaddqu (const char *)
17490 void __builtin_ia32_storedqu (char *, v16qi)
17491 v1di __builtin_ia32_pmuludq (v2si, v2si)
17492 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17493 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17494 v4si __builtin_ia32_pslld128 (v4si, v4si)
17495 v2di __builtin_ia32_psllq128 (v2di, v2di)
17496 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17497 v4si __builtin_ia32_psrld128 (v4si, v4si)
17498 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17499 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17500 v4si __builtin_ia32_psrad128 (v4si, v4si)
17501 v2di __builtin_ia32_pslldqi128 (v2di, int)
17502 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17503 v4si __builtin_ia32_pslldi128 (v4si, int)
17504 v2di __builtin_ia32_psllqi128 (v2di, int)
17505 v2di __builtin_ia32_psrldqi128 (v2di, int)
17506 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17507 v4si __builtin_ia32_psrldi128 (v4si, int)
17508 v2di __builtin_ia32_psrlqi128 (v2di, int)
17509 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17510 v4si __builtin_ia32_psradi128 (v4si, int)
17511 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17512 v2di __builtin_ia32_movq128 (v2di)
17513 @end smallexample
17514
17515 The following built-in functions are available when @option{-msse3} is used.
17516 All of them generate the machine instruction that is part of the name.
17517
17518 @smallexample
17519 v2df __builtin_ia32_addsubpd (v2df, v2df)
17520 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17521 v2df __builtin_ia32_haddpd (v2df, v2df)
17522 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17523 v2df __builtin_ia32_hsubpd (v2df, v2df)
17524 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17525 v16qi __builtin_ia32_lddqu (char const *)
17526 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17527 v4sf __builtin_ia32_movshdup (v4sf)
17528 v4sf __builtin_ia32_movsldup (v4sf)
17529 void __builtin_ia32_mwait (unsigned int, unsigned int)
17530 @end smallexample
17531
17532 The following built-in functions are available when @option{-mssse3} is used.
17533 All of them generate the machine instruction that is part of the name.
17534
17535 @smallexample
17536 v2si __builtin_ia32_phaddd (v2si, v2si)
17537 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17538 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17539 v2si __builtin_ia32_phsubd (v2si, v2si)
17540 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17541 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17542 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17543 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17544 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17545 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17546 v2si __builtin_ia32_psignd (v2si, v2si)
17547 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17548 v1di __builtin_ia32_palignr (v1di, v1di, int)
17549 v8qi __builtin_ia32_pabsb (v8qi)
17550 v2si __builtin_ia32_pabsd (v2si)
17551 v4hi __builtin_ia32_pabsw (v4hi)
17552 @end smallexample
17553
17554 The following built-in functions are available when @option{-mssse3} is used.
17555 All of them generate the machine instruction that is part of the name.
17556
17557 @smallexample
17558 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17559 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17560 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17561 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17562 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17563 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17564 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17565 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17566 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17567 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17568 v4si __builtin_ia32_psignd128 (v4si, v4si)
17569 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17570 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17571 v16qi __builtin_ia32_pabsb128 (v16qi)
17572 v4si __builtin_ia32_pabsd128 (v4si)
17573 v8hi __builtin_ia32_pabsw128 (v8hi)
17574 @end smallexample
17575
17576 The following built-in functions are available when @option{-msse4.1} is
17577 used. All of them generate the machine instruction that is part of the
17578 name.
17579
17580 @smallexample
17581 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17582 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17583 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17584 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17585 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17586 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17587 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17588 v2di __builtin_ia32_movntdqa (v2di *);
17589 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17590 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17591 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17592 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17593 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17594 v8hi __builtin_ia32_phminposuw128 (v8hi)
17595 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17596 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17597 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17598 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17599 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17600 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17601 v4si __builtin_ia32_pminud128 (v4si, v4si)
17602 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17603 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17604 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17605 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17606 v2di __builtin_ia32_pmovsxdq128 (v4si)
17607 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17608 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17609 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17610 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17611 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17612 v2di __builtin_ia32_pmovzxdq128 (v4si)
17613 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17614 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17615 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17616 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17617 int __builtin_ia32_ptestc128 (v2di, v2di)
17618 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17619 int __builtin_ia32_ptestz128 (v2di, v2di)
17620 v2df __builtin_ia32_roundpd (v2df, const int)
17621 v4sf __builtin_ia32_roundps (v4sf, const int)
17622 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17623 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17624 @end smallexample
17625
17626 The following built-in functions are available when @option{-msse4.1} is
17627 used.
17628
17629 @table @code
17630 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17631 Generates the @code{insertps} machine instruction.
17632 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17633 Generates the @code{pextrb} machine instruction.
17634 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17635 Generates the @code{pinsrb} machine instruction.
17636 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17637 Generates the @code{pinsrd} machine instruction.
17638 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17639 Generates the @code{pinsrq} machine instruction in 64bit mode.
17640 @end table
17641
17642 The following built-in functions are changed to generate new SSE4.1
17643 instructions when @option{-msse4.1} is used.
17644
17645 @table @code
17646 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17647 Generates the @code{extractps} machine instruction.
17648 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17649 Generates the @code{pextrd} machine instruction.
17650 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17651 Generates the @code{pextrq} machine instruction in 64bit mode.
17652 @end table
17653
17654 The following built-in functions are available when @option{-msse4.2} is
17655 used. All of them generate the machine instruction that is part of the
17656 name.
17657
17658 @smallexample
17659 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17660 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17661 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17662 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17663 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17664 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17665 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17666 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17667 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17668 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17669 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17670 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17671 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17672 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17673 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17674 @end smallexample
17675
17676 The following built-in functions are available when @option{-msse4.2} is
17677 used.
17678
17679 @table @code
17680 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17681 Generates the @code{crc32b} machine instruction.
17682 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17683 Generates the @code{crc32w} machine instruction.
17684 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17685 Generates the @code{crc32l} machine instruction.
17686 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17687 Generates the @code{crc32q} machine instruction.
17688 @end table
17689
17690 The following built-in functions are changed to generate new SSE4.2
17691 instructions when @option{-msse4.2} is used.
17692
17693 @table @code
17694 @item int __builtin_popcount (unsigned int)
17695 Generates the @code{popcntl} machine instruction.
17696 @item int __builtin_popcountl (unsigned long)
17697 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17698 depending on the size of @code{unsigned long}.
17699 @item int __builtin_popcountll (unsigned long long)
17700 Generates the @code{popcntq} machine instruction.
17701 @end table
17702
17703 The following built-in functions are available when @option{-mavx} is
17704 used. All of them generate the machine instruction that is part of the
17705 name.
17706
17707 @smallexample
17708 v4df __builtin_ia32_addpd256 (v4df,v4df)
17709 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17710 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17711 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17712 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17713 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17714 v4df __builtin_ia32_andpd256 (v4df,v4df)
17715 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17716 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17717 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17718 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17719 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17720 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17721 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17722 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17723 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17724 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17725 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17726 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17727 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17728 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17729 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17730 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17731 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17732 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17733 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17734 v4df __builtin_ia32_divpd256 (v4df,v4df)
17735 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17736 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17737 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17738 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17739 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17740 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17741 v32qi __builtin_ia32_lddqu256 (pcchar)
17742 v32qi __builtin_ia32_loaddqu256 (pcchar)
17743 v4df __builtin_ia32_loadupd256 (pcdouble)
17744 v8sf __builtin_ia32_loadups256 (pcfloat)
17745 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17746 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17747 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17748 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17749 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17750 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17751 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17752 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17753 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17754 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17755 v4df __builtin_ia32_minpd256 (v4df,v4df)
17756 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17757 v4df __builtin_ia32_movddup256 (v4df)
17758 int __builtin_ia32_movmskpd256 (v4df)
17759 int __builtin_ia32_movmskps256 (v8sf)
17760 v8sf __builtin_ia32_movshdup256 (v8sf)
17761 v8sf __builtin_ia32_movsldup256 (v8sf)
17762 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17763 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17764 v4df __builtin_ia32_orpd256 (v4df,v4df)
17765 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17766 v2df __builtin_ia32_pd_pd256 (v4df)
17767 v4df __builtin_ia32_pd256_pd (v2df)
17768 v4sf __builtin_ia32_ps_ps256 (v8sf)
17769 v8sf __builtin_ia32_ps256_ps (v4sf)
17770 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17771 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17772 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17773 v8sf __builtin_ia32_rcpps256 (v8sf)
17774 v4df __builtin_ia32_roundpd256 (v4df,int)
17775 v8sf __builtin_ia32_roundps256 (v8sf,int)
17776 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17777 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17778 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17779 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17780 v4si __builtin_ia32_si_si256 (v8si)
17781 v8si __builtin_ia32_si256_si (v4si)
17782 v4df __builtin_ia32_sqrtpd256 (v4df)
17783 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17784 v8sf __builtin_ia32_sqrtps256 (v8sf)
17785 void __builtin_ia32_storedqu256 (pchar,v32qi)
17786 void __builtin_ia32_storeupd256 (pdouble,v4df)
17787 void __builtin_ia32_storeups256 (pfloat,v8sf)
17788 v4df __builtin_ia32_subpd256 (v4df,v4df)
17789 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17790 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17791 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17792 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17793 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17794 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17795 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17796 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17797 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17798 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17799 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17800 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17801 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17802 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17803 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17804 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17805 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17806 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17807 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17808 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17809 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17810 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17811 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17812 v2df __builtin_ia32_vpermilpd (v2df,int)
17813 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17814 v4sf __builtin_ia32_vpermilps (v4sf,int)
17815 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17816 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17817 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17818 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17819 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17820 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17821 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17822 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17823 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17824 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17825 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17826 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17827 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17828 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17829 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17830 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17831 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17832 void __builtin_ia32_vzeroall (void)
17833 void __builtin_ia32_vzeroupper (void)
17834 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17835 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17836 @end smallexample
17837
17838 The following built-in functions are available when @option{-mavx2} is
17839 used. All of them generate the machine instruction that is part of the
17840 name.
17841
17842 @smallexample
17843 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17844 v32qi __builtin_ia32_pabsb256 (v32qi)
17845 v16hi __builtin_ia32_pabsw256 (v16hi)
17846 v8si __builtin_ia32_pabsd256 (v8si)
17847 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17848 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17849 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17850 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17851 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17852 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17853 v8si __builtin_ia32_paddd256 (v8si,v8si)
17854 v4di __builtin_ia32_paddq256 (v4di,v4di)
17855 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17856 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17857 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17858 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17859 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17860 v4di __builtin_ia32_andsi256 (v4di,v4di)
17861 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17862 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17863 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17864 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17865 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17866 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17867 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17868 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17869 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17870 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17871 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17872 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17873 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17874 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17875 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17876 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17877 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17878 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17879 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17880 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17881 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17882 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17883 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17884 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17885 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17886 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17887 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17888 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17889 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17890 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17891 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17892 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17893 v8si __builtin_ia32_pminud256 (v8si,v8si)
17894 int __builtin_ia32_pmovmskb256 (v32qi)
17895 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17896 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17897 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17898 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17899 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17900 v4di __builtin_ia32_pmovsxdq256 (v4si)
17901 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17902 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17903 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17904 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17905 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17906 v4di __builtin_ia32_pmovzxdq256 (v4si)
17907 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17908 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17909 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17910 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17911 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17912 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17913 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17914 v4di __builtin_ia32_por256 (v4di,v4di)
17915 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17916 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17917 v8si __builtin_ia32_pshufd256 (v8si,int)
17918 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17919 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17920 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17921 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17922 v8si __builtin_ia32_psignd256 (v8si,v8si)
17923 v4di __builtin_ia32_pslldqi256 (v4di,int)
17924 v16hi __builtin_ia32_psllwi256 (16hi,int)
17925 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17926 v8si __builtin_ia32_pslldi256 (v8si,int)
17927 v8si __builtin_ia32_pslld256(v8si,v4si)
17928 v4di __builtin_ia32_psllqi256 (v4di,int)
17929 v4di __builtin_ia32_psllq256(v4di,v2di)
17930 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17931 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17932 v8si __builtin_ia32_psradi256 (v8si,int)
17933 v8si __builtin_ia32_psrad256 (v8si,v4si)
17934 v4di __builtin_ia32_psrldqi256 (v4di, int)
17935 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17936 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17937 v8si __builtin_ia32_psrldi256 (v8si,int)
17938 v8si __builtin_ia32_psrld256 (v8si,v4si)
17939 v4di __builtin_ia32_psrlqi256 (v4di,int)
17940 v4di __builtin_ia32_psrlq256(v4di,v2di)
17941 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17942 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17943 v8si __builtin_ia32_psubd256 (v8si,v8si)
17944 v4di __builtin_ia32_psubq256 (v4di,v4di)
17945 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17946 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17947 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17948 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17949 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17950 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17951 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17952 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
17953 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
17954 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
17955 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
17956 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
17957 v4di __builtin_ia32_pxor256 (v4di,v4di)
17958 v4di __builtin_ia32_movntdqa256 (pv4di)
17959 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
17960 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
17961 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
17962 v4di __builtin_ia32_vbroadcastsi256 (v2di)
17963 v4si __builtin_ia32_pblendd128 (v4si,v4si)
17964 v8si __builtin_ia32_pblendd256 (v8si,v8si)
17965 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
17966 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
17967 v8si __builtin_ia32_pbroadcastd256 (v4si)
17968 v4di __builtin_ia32_pbroadcastq256 (v2di)
17969 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
17970 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
17971 v4si __builtin_ia32_pbroadcastd128 (v4si)
17972 v2di __builtin_ia32_pbroadcastq128 (v2di)
17973 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
17974 v4df __builtin_ia32_permdf256 (v4df,int)
17975 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
17976 v4di __builtin_ia32_permdi256 (v4di,int)
17977 v4di __builtin_ia32_permti256 (v4di,v4di,int)
17978 v4di __builtin_ia32_extract128i256 (v4di,int)
17979 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
17980 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
17981 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
17982 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
17983 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
17984 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
17985 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
17986 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
17987 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
17988 v8si __builtin_ia32_psllv8si (v8si,v8si)
17989 v4si __builtin_ia32_psllv4si (v4si,v4si)
17990 v4di __builtin_ia32_psllv4di (v4di,v4di)
17991 v2di __builtin_ia32_psllv2di (v2di,v2di)
17992 v8si __builtin_ia32_psrav8si (v8si,v8si)
17993 v4si __builtin_ia32_psrav4si (v4si,v4si)
17994 v8si __builtin_ia32_psrlv8si (v8si,v8si)
17995 v4si __builtin_ia32_psrlv4si (v4si,v4si)
17996 v4di __builtin_ia32_psrlv4di (v4di,v4di)
17997 v2di __builtin_ia32_psrlv2di (v2di,v2di)
17998 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
17999 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
18000 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
18001 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
18002 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
18003 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
18004 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
18005 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
18006 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
18007 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
18008 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
18009 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
18010 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
18011 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
18012 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
18013 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
18014 @end smallexample
18015
18016 The following built-in functions are available when @option{-maes} is
18017 used. All of them generate the machine instruction that is part of the
18018 name.
18019
18020 @smallexample
18021 v2di __builtin_ia32_aesenc128 (v2di, v2di)
18022 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
18023 v2di __builtin_ia32_aesdec128 (v2di, v2di)
18024 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
18025 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
18026 v2di __builtin_ia32_aesimc128 (v2di)
18027 @end smallexample
18028
18029 The following built-in function is available when @option{-mpclmul} is
18030 used.
18031
18032 @table @code
18033 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
18034 Generates the @code{pclmulqdq} machine instruction.
18035 @end table
18036
18037 The following built-in function is available when @option{-mfsgsbase} is
18038 used. All of them generate the machine instruction that is part of the
18039 name.
18040
18041 @smallexample
18042 unsigned int __builtin_ia32_rdfsbase32 (void)
18043 unsigned long long __builtin_ia32_rdfsbase64 (void)
18044 unsigned int __builtin_ia32_rdgsbase32 (void)
18045 unsigned long long __builtin_ia32_rdgsbase64 (void)
18046 void _writefsbase_u32 (unsigned int)
18047 void _writefsbase_u64 (unsigned long long)
18048 void _writegsbase_u32 (unsigned int)
18049 void _writegsbase_u64 (unsigned long long)
18050 @end smallexample
18051
18052 The following built-in function is available when @option{-mrdrnd} is
18053 used. All of them generate the machine instruction that is part of the
18054 name.
18055
18056 @smallexample
18057 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
18058 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
18059 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
18060 @end smallexample
18061
18062 The following built-in functions are available when @option{-msse4a} is used.
18063 All of them generate the machine instruction that is part of the name.
18064
18065 @smallexample
18066 void __builtin_ia32_movntsd (double *, v2df)
18067 void __builtin_ia32_movntss (float *, v4sf)
18068 v2di __builtin_ia32_extrq (v2di, v16qi)
18069 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
18070 v2di __builtin_ia32_insertq (v2di, v2di)
18071 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
18072 @end smallexample
18073
18074 The following built-in functions are available when @option{-mxop} is used.
18075 @smallexample
18076 v2df __builtin_ia32_vfrczpd (v2df)
18077 v4sf __builtin_ia32_vfrczps (v4sf)
18078 v2df __builtin_ia32_vfrczsd (v2df)
18079 v4sf __builtin_ia32_vfrczss (v4sf)
18080 v4df __builtin_ia32_vfrczpd256 (v4df)
18081 v8sf __builtin_ia32_vfrczps256 (v8sf)
18082 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18083 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18084 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18085 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18086 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18087 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18088 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18089 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18090 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18091 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18092 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18093 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18094 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18095 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18096 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18097 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18098 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18099 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18100 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18101 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18102 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18103 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18104 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18105 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18106 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18107 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18108 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18109 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18110 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18111 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18112 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18113 v4si __builtin_ia32_vpcomged (v4si, v4si)
18114 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18115 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18116 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18117 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18118 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18119 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18120 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18121 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18122 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18123 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18124 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18125 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18126 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18127 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18128 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18129 v4si __builtin_ia32_vpcomled (v4si, v4si)
18130 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18131 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18132 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18133 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18134 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18135 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18136 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18137 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18138 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18139 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18140 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18141 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18142 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18143 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18144 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18145 v4si __builtin_ia32_vpcomned (v4si, v4si)
18146 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18147 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18148 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18149 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18150 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18151 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18152 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18153 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18154 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18155 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18156 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18157 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18158 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18159 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18160 v4si __builtin_ia32_vphaddbd (v16qi)
18161 v2di __builtin_ia32_vphaddbq (v16qi)
18162 v8hi __builtin_ia32_vphaddbw (v16qi)
18163 v2di __builtin_ia32_vphadddq (v4si)
18164 v4si __builtin_ia32_vphaddubd (v16qi)
18165 v2di __builtin_ia32_vphaddubq (v16qi)
18166 v8hi __builtin_ia32_vphaddubw (v16qi)
18167 v2di __builtin_ia32_vphaddudq (v4si)
18168 v4si __builtin_ia32_vphadduwd (v8hi)
18169 v2di __builtin_ia32_vphadduwq (v8hi)
18170 v4si __builtin_ia32_vphaddwd (v8hi)
18171 v2di __builtin_ia32_vphaddwq (v8hi)
18172 v8hi __builtin_ia32_vphsubbw (v16qi)
18173 v2di __builtin_ia32_vphsubdq (v4si)
18174 v4si __builtin_ia32_vphsubwd (v8hi)
18175 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18176 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18177 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18178 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18179 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18180 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18181 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18182 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18183 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18184 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18185 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18186 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18187 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18188 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18189 v4si __builtin_ia32_vprotd (v4si, v4si)
18190 v2di __builtin_ia32_vprotq (v2di, v2di)
18191 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18192 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18193 v4si __builtin_ia32_vpshad (v4si, v4si)
18194 v2di __builtin_ia32_vpshaq (v2di, v2di)
18195 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18196 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18197 v4si __builtin_ia32_vpshld (v4si, v4si)
18198 v2di __builtin_ia32_vpshlq (v2di, v2di)
18199 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18200 @end smallexample
18201
18202 The following built-in functions are available when @option{-mfma4} is used.
18203 All of them generate the machine instruction that is part of the name.
18204
18205 @smallexample
18206 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18207 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18208 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18209 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18210 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18211 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18212 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18213 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18214 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18215 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18216 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18217 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18218 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18219 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18220 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18221 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18222 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18223 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18224 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18225 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18226 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18227 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18228 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18229 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18230 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18231 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18232 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18233 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18234 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18235 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18236 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18237 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18238
18239 @end smallexample
18240
18241 The following built-in functions are available when @option{-mlwp} is used.
18242
18243 @smallexample
18244 void __builtin_ia32_llwpcb16 (void *);
18245 void __builtin_ia32_llwpcb32 (void *);
18246 void __builtin_ia32_llwpcb64 (void *);
18247 void * __builtin_ia32_llwpcb16 (void);
18248 void * __builtin_ia32_llwpcb32 (void);
18249 void * __builtin_ia32_llwpcb64 (void);
18250 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18251 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18252 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18253 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18254 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18255 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18256 @end smallexample
18257
18258 The following built-in functions are available when @option{-mbmi} is used.
18259 All of them generate the machine instruction that is part of the name.
18260 @smallexample
18261 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18262 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18263 @end smallexample
18264
18265 The following built-in functions are available when @option{-mbmi2} is used.
18266 All of them generate the machine instruction that is part of the name.
18267 @smallexample
18268 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18269 unsigned int _pdep_u32 (unsigned int, unsigned int)
18270 unsigned int _pext_u32 (unsigned int, unsigned int)
18271 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18272 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18273 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18274 @end smallexample
18275
18276 The following built-in functions are available when @option{-mlzcnt} is used.
18277 All of them generate the machine instruction that is part of the name.
18278 @smallexample
18279 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18280 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18281 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18282 @end smallexample
18283
18284 The following built-in functions are available when @option{-mfxsr} is used.
18285 All of them generate the machine instruction that is part of the name.
18286 @smallexample
18287 void __builtin_ia32_fxsave (void *)
18288 void __builtin_ia32_fxrstor (void *)
18289 void __builtin_ia32_fxsave64 (void *)
18290 void __builtin_ia32_fxrstor64 (void *)
18291 @end smallexample
18292
18293 The following built-in functions are available when @option{-mxsave} is used.
18294 All of them generate the machine instruction that is part of the name.
18295 @smallexample
18296 void __builtin_ia32_xsave (void *, long long)
18297 void __builtin_ia32_xrstor (void *, long long)
18298 void __builtin_ia32_xsave64 (void *, long long)
18299 void __builtin_ia32_xrstor64 (void *, long long)
18300 @end smallexample
18301
18302 The following built-in functions are available when @option{-mxsaveopt} is used.
18303 All of them generate the machine instruction that is part of the name.
18304 @smallexample
18305 void __builtin_ia32_xsaveopt (void *, long long)
18306 void __builtin_ia32_xsaveopt64 (void *, long long)
18307 @end smallexample
18308
18309 The following built-in functions are available when @option{-mtbm} is used.
18310 Both of them generate the immediate form of the bextr machine instruction.
18311 @smallexample
18312 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18313 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18314 @end smallexample
18315
18316
18317 The following built-in functions are available when @option{-m3dnow} is used.
18318 All of them generate the machine instruction that is part of the name.
18319
18320 @smallexample
18321 void __builtin_ia32_femms (void)
18322 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18323 v2si __builtin_ia32_pf2id (v2sf)
18324 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18325 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18326 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18327 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18328 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18329 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18330 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18331 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18332 v2sf __builtin_ia32_pfrcp (v2sf)
18333 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18334 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18335 v2sf __builtin_ia32_pfrsqrt (v2sf)
18336 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18337 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18338 v2sf __builtin_ia32_pi2fd (v2si)
18339 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18340 @end smallexample
18341
18342 The following built-in functions are available when both @option{-m3dnow}
18343 and @option{-march=athlon} are used. All of them generate the machine
18344 instruction that is part of the name.
18345
18346 @smallexample
18347 v2si __builtin_ia32_pf2iw (v2sf)
18348 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18349 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18350 v2sf __builtin_ia32_pi2fw (v2si)
18351 v2sf __builtin_ia32_pswapdsf (v2sf)
18352 v2si __builtin_ia32_pswapdsi (v2si)
18353 @end smallexample
18354
18355 The following built-in functions are available when @option{-mrtm} is used
18356 They are used for restricted transactional memory. These are the internal
18357 low level functions. Normally the functions in
18358 @ref{x86 transactional memory intrinsics} should be used instead.
18359
18360 @smallexample
18361 int __builtin_ia32_xbegin ()
18362 void __builtin_ia32_xend ()
18363 void __builtin_ia32_xabort (status)
18364 int __builtin_ia32_xtest ()
18365 @end smallexample
18366
18367 The following built-in functions are available when @option{-mmwaitx} is used.
18368 All of them generate the machine instruction that is part of the name.
18369 @smallexample
18370 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18371 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18372 @end smallexample
18373
18374 @node x86 transactional memory intrinsics
18375 @subsection x86 Transactional Memory Intrinsics
18376
18377 These hardware transactional memory intrinsics for x86 allow you to use
18378 memory transactions with RTM (Restricted Transactional Memory).
18379 This support is enabled with the @option{-mrtm} option.
18380 For using HLE (Hardware Lock Elision) see
18381 @ref{x86 specific memory model extensions for transactional memory} instead.
18382
18383 A memory transaction commits all changes to memory in an atomic way,
18384 as visible to other threads. If the transaction fails it is rolled back
18385 and all side effects discarded.
18386
18387 Generally there is no guarantee that a memory transaction ever succeeds
18388 and suitable fallback code always needs to be supplied.
18389
18390 @deftypefn {RTM Function} {unsigned} _xbegin ()
18391 Start a RTM (Restricted Transactional Memory) transaction.
18392 Returns @code{_XBEGIN_STARTED} when the transaction
18393 started successfully (note this is not 0, so the constant has to be
18394 explicitly tested).
18395
18396 If the transaction aborts, all side-effects
18397 are undone and an abort code encoded as a bit mask is returned.
18398 The following macros are defined:
18399
18400 @table @code
18401 @item _XABORT_EXPLICIT
18402 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18403 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18404 @item _XABORT_RETRY
18405 Transaction retry is possible.
18406 @item _XABORT_CONFLICT
18407 Transaction abort due to a memory conflict with another thread.
18408 @item _XABORT_CAPACITY
18409 Transaction abort due to the transaction using too much memory.
18410 @item _XABORT_DEBUG
18411 Transaction abort due to a debug trap.
18412 @item _XABORT_NESTED
18413 Transaction abort in an inner nested transaction.
18414 @end table
18415
18416 There is no guarantee
18417 any transaction ever succeeds, so there always needs to be a valid
18418 fallback path.
18419 @end deftypefn
18420
18421 @deftypefn {RTM Function} {void} _xend ()
18422 Commit the current transaction. When no transaction is active this faults.
18423 All memory side-effects of the transaction become visible
18424 to other threads in an atomic manner.
18425 @end deftypefn
18426
18427 @deftypefn {RTM Function} {int} _xtest ()
18428 Return a nonzero value if a transaction is currently active, otherwise 0.
18429 @end deftypefn
18430
18431 @deftypefn {RTM Function} {void} _xabort (status)
18432 Abort the current transaction. When no transaction is active this is a no-op.
18433 The @var{status} is an 8-bit constant; its value is encoded in the return
18434 value from @code{_xbegin}.
18435 @end deftypefn
18436
18437 Here is an example showing handling for @code{_XABORT_RETRY}
18438 and a fallback path for other failures:
18439
18440 @smallexample
18441 #include <immintrin.h>
18442
18443 int n_tries, max_tries;
18444 unsigned status = _XABORT_EXPLICIT;
18445 ...
18446
18447 for (n_tries = 0; n_tries < max_tries; n_tries++)
18448 @{
18449 status = _xbegin ();
18450 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18451 break;
18452 @}
18453 if (status == _XBEGIN_STARTED)
18454 @{
18455 ... transaction code...
18456 _xend ();
18457 @}
18458 else
18459 @{
18460 ... non-transactional fallback path...
18461 @}
18462 @end smallexample
18463
18464 @noindent
18465 Note that, in most cases, the transactional and non-transactional code
18466 must synchronize together to ensure consistency.
18467
18468 @node Target Format Checks
18469 @section Format Checks Specific to Particular Target Machines
18470
18471 For some target machines, GCC supports additional options to the
18472 format attribute
18473 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18474
18475 @menu
18476 * Solaris Format Checks::
18477 * Darwin Format Checks::
18478 @end menu
18479
18480 @node Solaris Format Checks
18481 @subsection Solaris Format Checks
18482
18483 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18484 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18485 conversions, and the two-argument @code{%b} conversion for displaying
18486 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18487
18488 @node Darwin Format Checks
18489 @subsection Darwin Format Checks
18490
18491 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18492 attribute context. Declarations made with such attribution are parsed for correct syntax
18493 and format argument types. However, parsing of the format string itself is currently undefined
18494 and is not carried out by this version of the compiler.
18495
18496 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18497 also be used as format arguments. Note that the relevant headers are only likely to be
18498 available on Darwin (OSX) installations. On such installations, the XCode and system
18499 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18500 associated functions.
18501
18502 @node Pragmas
18503 @section Pragmas Accepted by GCC
18504 @cindex pragmas
18505 @cindex @code{#pragma}
18506
18507 GCC supports several types of pragmas, primarily in order to compile
18508 code originally written for other compilers. Note that in general
18509 we do not recommend the use of pragmas; @xref{Function Attributes},
18510 for further explanation.
18511
18512 @menu
18513 * AArch64 Pragmas::
18514 * ARM Pragmas::
18515 * M32C Pragmas::
18516 * MeP Pragmas::
18517 * RS/6000 and PowerPC Pragmas::
18518 * Darwin Pragmas::
18519 * Solaris Pragmas::
18520 * Symbol-Renaming Pragmas::
18521 * Structure-Layout Pragmas::
18522 * Weak Pragmas::
18523 * Diagnostic Pragmas::
18524 * Visibility Pragmas::
18525 * Push/Pop Macro Pragmas::
18526 * Function Specific Option Pragmas::
18527 * Loop-Specific Pragmas::
18528 @end menu
18529
18530 @node AArch64 Pragmas
18531 @subsection AArch64 Pragmas
18532
18533 The pragmas defined by the AArch64 target correspond to the AArch64
18534 target function attributes. They can be specified as below:
18535 @smallexample
18536 #pragma GCC target("string")
18537 @end smallexample
18538
18539 where @code{@var{string}} can be any string accepted as an AArch64 target
18540 attribute. @xref{AArch64 Function Attributes}, for more details
18541 on the permissible values of @code{string}.
18542
18543 @node ARM Pragmas
18544 @subsection ARM Pragmas
18545
18546 The ARM target defines pragmas for controlling the default addition of
18547 @code{long_call} and @code{short_call} attributes to functions.
18548 @xref{Function Attributes}, for information about the effects of these
18549 attributes.
18550
18551 @table @code
18552 @item long_calls
18553 @cindex pragma, long_calls
18554 Set all subsequent functions to have the @code{long_call} attribute.
18555
18556 @item no_long_calls
18557 @cindex pragma, no_long_calls
18558 Set all subsequent functions to have the @code{short_call} attribute.
18559
18560 @item long_calls_off
18561 @cindex pragma, long_calls_off
18562 Do not affect the @code{long_call} or @code{short_call} attributes of
18563 subsequent functions.
18564 @end table
18565
18566 @node M32C Pragmas
18567 @subsection M32C Pragmas
18568
18569 @table @code
18570 @item GCC memregs @var{number}
18571 @cindex pragma, memregs
18572 Overrides the command-line option @code{-memregs=} for the current
18573 file. Use with care! This pragma must be before any function in the
18574 file, and mixing different memregs values in different objects may
18575 make them incompatible. This pragma is useful when a
18576 performance-critical function uses a memreg for temporary values,
18577 as it may allow you to reduce the number of memregs used.
18578
18579 @item ADDRESS @var{name} @var{address}
18580 @cindex pragma, address
18581 For any declared symbols matching @var{name}, this does three things
18582 to that symbol: it forces the symbol to be located at the given
18583 address (a number), it forces the symbol to be volatile, and it
18584 changes the symbol's scope to be static. This pragma exists for
18585 compatibility with other compilers, but note that the common
18586 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18587 instead). Example:
18588
18589 @smallexample
18590 #pragma ADDRESS port3 0x103
18591 char port3;
18592 @end smallexample
18593
18594 @end table
18595
18596 @node MeP Pragmas
18597 @subsection MeP Pragmas
18598
18599 @table @code
18600
18601 @item custom io_volatile (on|off)
18602 @cindex pragma, custom io_volatile
18603 Overrides the command-line option @code{-mio-volatile} for the current
18604 file. Note that for compatibility with future GCC releases, this
18605 option should only be used once before any @code{io} variables in each
18606 file.
18607
18608 @item GCC coprocessor available @var{registers}
18609 @cindex pragma, coprocessor available
18610 Specifies which coprocessor registers are available to the register
18611 allocator. @var{registers} may be a single register, register range
18612 separated by ellipses, or comma-separated list of those. Example:
18613
18614 @smallexample
18615 #pragma GCC coprocessor available $c0...$c10, $c28
18616 @end smallexample
18617
18618 @item GCC coprocessor call_saved @var{registers}
18619 @cindex pragma, coprocessor call_saved
18620 Specifies which coprocessor registers are to be saved and restored by
18621 any function using them. @var{registers} may be a single register,
18622 register range separated by ellipses, or comma-separated list of
18623 those. Example:
18624
18625 @smallexample
18626 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18627 @end smallexample
18628
18629 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18630 @cindex pragma, coprocessor subclass
18631 Creates and defines a register class. These register classes can be
18632 used by inline @code{asm} constructs. @var{registers} may be a single
18633 register, register range separated by ellipses, or comma-separated
18634 list of those. Example:
18635
18636 @smallexample
18637 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18638
18639 asm ("cpfoo %0" : "=B" (x));
18640 @end smallexample
18641
18642 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18643 @cindex pragma, disinterrupt
18644 For the named functions, the compiler adds code to disable interrupts
18645 for the duration of those functions. If any functions so named
18646 are not encountered in the source, a warning is emitted that the pragma is
18647 not used. Examples:
18648
18649 @smallexample
18650 #pragma disinterrupt foo
18651 #pragma disinterrupt bar, grill
18652 int foo () @{ @dots{} @}
18653 @end smallexample
18654
18655 @item GCC call @var{name} , @var{name} @dots{}
18656 @cindex pragma, call
18657 For the named functions, the compiler always uses a register-indirect
18658 call model when calling the named functions. Examples:
18659
18660 @smallexample
18661 extern int foo ();
18662 #pragma call foo
18663 @end smallexample
18664
18665 @end table
18666
18667 @node RS/6000 and PowerPC Pragmas
18668 @subsection RS/6000 and PowerPC Pragmas
18669
18670 The RS/6000 and PowerPC targets define one pragma for controlling
18671 whether or not the @code{longcall} attribute is added to function
18672 declarations by default. This pragma overrides the @option{-mlongcall}
18673 option, but not the @code{longcall} and @code{shortcall} attributes.
18674 @xref{RS/6000 and PowerPC Options}, for more information about when long
18675 calls are and are not necessary.
18676
18677 @table @code
18678 @item longcall (1)
18679 @cindex pragma, longcall
18680 Apply the @code{longcall} attribute to all subsequent function
18681 declarations.
18682
18683 @item longcall (0)
18684 Do not apply the @code{longcall} attribute to subsequent function
18685 declarations.
18686 @end table
18687
18688 @c Describe h8300 pragmas here.
18689 @c Describe sh pragmas here.
18690 @c Describe v850 pragmas here.
18691
18692 @node Darwin Pragmas
18693 @subsection Darwin Pragmas
18694
18695 The following pragmas are available for all architectures running the
18696 Darwin operating system. These are useful for compatibility with other
18697 Mac OS compilers.
18698
18699 @table @code
18700 @item mark @var{tokens}@dots{}
18701 @cindex pragma, mark
18702 This pragma is accepted, but has no effect.
18703
18704 @item options align=@var{alignment}
18705 @cindex pragma, options align
18706 This pragma sets the alignment of fields in structures. The values of
18707 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18708 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
18709 properly; to restore the previous setting, use @code{reset} for the
18710 @var{alignment}.
18711
18712 @item segment @var{tokens}@dots{}
18713 @cindex pragma, segment
18714 This pragma is accepted, but has no effect.
18715
18716 @item unused (@var{var} [, @var{var}]@dots{})
18717 @cindex pragma, unused
18718 This pragma declares variables to be possibly unused. GCC does not
18719 produce warnings for the listed variables. The effect is similar to
18720 that of the @code{unused} attribute, except that this pragma may appear
18721 anywhere within the variables' scopes.
18722 @end table
18723
18724 @node Solaris Pragmas
18725 @subsection Solaris Pragmas
18726
18727 The Solaris target supports @code{#pragma redefine_extname}
18728 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
18729 @code{#pragma} directives for compatibility with the system compiler.
18730
18731 @table @code
18732 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18733 @cindex pragma, align
18734
18735 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18736 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18737 Attributes}). Macro expansion occurs on the arguments to this pragma
18738 when compiling C and Objective-C@. It does not currently occur when
18739 compiling C++, but this is a bug which may be fixed in a future
18740 release.
18741
18742 @item fini (@var{function} [, @var{function}]...)
18743 @cindex pragma, fini
18744
18745 This pragma causes each listed @var{function} to be called after
18746 main, or during shared module unloading, by adding a call to the
18747 @code{.fini} section.
18748
18749 @item init (@var{function} [, @var{function}]...)
18750 @cindex pragma, init
18751
18752 This pragma causes each listed @var{function} to be called during
18753 initialization (before @code{main}) or during shared module loading, by
18754 adding a call to the @code{.init} section.
18755
18756 @end table
18757
18758 @node Symbol-Renaming Pragmas
18759 @subsection Symbol-Renaming Pragmas
18760
18761 GCC supports a @code{#pragma} directive that changes the name used in
18762 assembly for a given declaration. While this pragma is supported on all
18763 platforms, it is intended primarily to provide compatibility with the
18764 Solaris system headers. This effect can also be achieved using the asm
18765 labels extension (@pxref{Asm Labels}).
18766
18767 @table @code
18768 @item redefine_extname @var{oldname} @var{newname}
18769 @cindex pragma, redefine_extname
18770
18771 This pragma gives the C function @var{oldname} the assembly symbol
18772 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18773 is defined if this pragma is available (currently on all platforms).
18774 @end table
18775
18776 This pragma and the asm labels extension interact in a complicated
18777 manner. Here are some corner cases you may want to be aware of:
18778
18779 @enumerate
18780 @item This pragma silently applies only to declarations with external
18781 linkage. Asm labels do not have this restriction.
18782
18783 @item In C++, this pragma silently applies only to declarations with
18784 ``C'' linkage. Again, asm labels do not have this restriction.
18785
18786 @item If either of the ways of changing the assembly name of a
18787 declaration are applied to a declaration whose assembly name has
18788 already been determined (either by a previous use of one of these
18789 features, or because the compiler needed the assembly name in order to
18790 generate code), and the new name is different, a warning issues and
18791 the name does not change.
18792
18793 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18794 always the C-language name.
18795 @end enumerate
18796
18797 @node Structure-Layout Pragmas
18798 @subsection Structure-Layout Pragmas
18799
18800 For compatibility with Microsoft Windows compilers, GCC supports a
18801 set of @code{#pragma} directives that change the maximum alignment of
18802 members of structures (other than zero-width bit-fields), unions, and
18803 classes subsequently defined. The @var{n} value below always is required
18804 to be a small power of two and specifies the new alignment in bytes.
18805
18806 @enumerate
18807 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18808 @item @code{#pragma pack()} sets the alignment to the one that was in
18809 effect when compilation started (see also command-line option
18810 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18811 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18812 setting on an internal stack and then optionally sets the new alignment.
18813 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18814 saved at the top of the internal stack (and removes that stack entry).
18815 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18816 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18817 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18818 @code{#pragma pack(pop)}.
18819 @end enumerate
18820
18821 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
18822 directive which lays out structures and unions subsequently defined as the
18823 documented @code{__attribute__ ((ms_struct))}.
18824
18825 @enumerate
18826 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
18827 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
18828 @item @code{#pragma ms_struct reset} goes back to the default layout.
18829 @end enumerate
18830
18831 Most targets also support the @code{#pragma scalar_storage_order} directive
18832 which lays out structures and unions subsequently defined as the documented
18833 @code{__attribute__ ((scalar_storage_order))}.
18834
18835 @enumerate
18836 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
18837 of the scalar fields to big-endian.
18838 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
18839 of the scalar fields to little-endian.
18840 @item @code{#pragma scalar_storage_order default} goes back to the endianness
18841 that was in effect when compilation started (see also command-line option
18842 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
18843 @end enumerate
18844
18845 @node Weak Pragmas
18846 @subsection Weak Pragmas
18847
18848 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18849 directives for declaring symbols to be weak, and defining weak
18850 aliases.
18851
18852 @table @code
18853 @item #pragma weak @var{symbol}
18854 @cindex pragma, weak
18855 This pragma declares @var{symbol} to be weak, as if the declaration
18856 had the attribute of the same name. The pragma may appear before
18857 or after the declaration of @var{symbol}. It is not an error for
18858 @var{symbol} to never be defined at all.
18859
18860 @item #pragma weak @var{symbol1} = @var{symbol2}
18861 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18862 It is an error if @var{symbol2} is not defined in the current
18863 translation unit.
18864 @end table
18865
18866 @node Diagnostic Pragmas
18867 @subsection Diagnostic Pragmas
18868
18869 GCC allows the user to selectively enable or disable certain types of
18870 diagnostics, and change the kind of the diagnostic. For example, a
18871 project's policy might require that all sources compile with
18872 @option{-Werror} but certain files might have exceptions allowing
18873 specific types of warnings. Or, a project might selectively enable
18874 diagnostics and treat them as errors depending on which preprocessor
18875 macros are defined.
18876
18877 @table @code
18878 @item #pragma GCC diagnostic @var{kind} @var{option}
18879 @cindex pragma, diagnostic
18880
18881 Modifies the disposition of a diagnostic. Note that not all
18882 diagnostics are modifiable; at the moment only warnings (normally
18883 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18884 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18885 are controllable and which option controls them.
18886
18887 @var{kind} is @samp{error} to treat this diagnostic as an error,
18888 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18889 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18890 @var{option} is a double quoted string that matches the command-line
18891 option.
18892
18893 @smallexample
18894 #pragma GCC diagnostic warning "-Wformat"
18895 #pragma GCC diagnostic error "-Wformat"
18896 #pragma GCC diagnostic ignored "-Wformat"
18897 @end smallexample
18898
18899 Note that these pragmas override any command-line options. GCC keeps
18900 track of the location of each pragma, and issues diagnostics according
18901 to the state as of that point in the source file. Thus, pragmas occurring
18902 after a line do not affect diagnostics caused by that line.
18903
18904 @item #pragma GCC diagnostic push
18905 @itemx #pragma GCC diagnostic pop
18906
18907 Causes GCC to remember the state of the diagnostics as of each
18908 @code{push}, and restore to that point at each @code{pop}. If a
18909 @code{pop} has no matching @code{push}, the command-line options are
18910 restored.
18911
18912 @smallexample
18913 #pragma GCC diagnostic error "-Wuninitialized"
18914 foo(a); /* error is given for this one */
18915 #pragma GCC diagnostic push
18916 #pragma GCC diagnostic ignored "-Wuninitialized"
18917 foo(b); /* no diagnostic for this one */
18918 #pragma GCC diagnostic pop
18919 foo(c); /* error is given for this one */
18920 #pragma GCC diagnostic pop
18921 foo(d); /* depends on command-line options */
18922 @end smallexample
18923
18924 @end table
18925
18926 GCC also offers a simple mechanism for printing messages during
18927 compilation.
18928
18929 @table @code
18930 @item #pragma message @var{string}
18931 @cindex pragma, diagnostic
18932
18933 Prints @var{string} as a compiler message on compilation. The message
18934 is informational only, and is neither a compilation warning nor an error.
18935
18936 @smallexample
18937 #pragma message "Compiling " __FILE__ "..."
18938 @end smallexample
18939
18940 @var{string} may be parenthesized, and is printed with location
18941 information. For example,
18942
18943 @smallexample
18944 #define DO_PRAGMA(x) _Pragma (#x)
18945 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
18946
18947 TODO(Remember to fix this)
18948 @end smallexample
18949
18950 @noindent
18951 prints @samp{/tmp/file.c:4: note: #pragma message:
18952 TODO - Remember to fix this}.
18953
18954 @end table
18955
18956 @node Visibility Pragmas
18957 @subsection Visibility Pragmas
18958
18959 @table @code
18960 @item #pragma GCC visibility push(@var{visibility})
18961 @itemx #pragma GCC visibility pop
18962 @cindex pragma, visibility
18963
18964 This pragma allows the user to set the visibility for multiple
18965 declarations without having to give each a visibility attribute
18966 (@pxref{Function Attributes}).
18967
18968 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
18969 declarations. Class members and template specializations are not
18970 affected; if you want to override the visibility for a particular
18971 member or instantiation, you must use an attribute.
18972
18973 @end table
18974
18975
18976 @node Push/Pop Macro Pragmas
18977 @subsection Push/Pop Macro Pragmas
18978
18979 For compatibility with Microsoft Windows compilers, GCC supports
18980 @samp{#pragma push_macro(@var{"macro_name"})}
18981 and @samp{#pragma pop_macro(@var{"macro_name"})}.
18982
18983 @table @code
18984 @item #pragma push_macro(@var{"macro_name"})
18985 @cindex pragma, push_macro
18986 This pragma saves the value of the macro named as @var{macro_name} to
18987 the top of the stack for this macro.
18988
18989 @item #pragma pop_macro(@var{"macro_name"})
18990 @cindex pragma, pop_macro
18991 This pragma sets the value of the macro named as @var{macro_name} to
18992 the value on top of the stack for this macro. If the stack for
18993 @var{macro_name} is empty, the value of the macro remains unchanged.
18994 @end table
18995
18996 For example:
18997
18998 @smallexample
18999 #define X 1
19000 #pragma push_macro("X")
19001 #undef X
19002 #define X -1
19003 #pragma pop_macro("X")
19004 int x [X];
19005 @end smallexample
19006
19007 @noindent
19008 In this example, the definition of X as 1 is saved by @code{#pragma
19009 push_macro} and restored by @code{#pragma pop_macro}.
19010
19011 @node Function Specific Option Pragmas
19012 @subsection Function Specific Option Pragmas
19013
19014 @table @code
19015 @item #pragma GCC target (@var{"string"}...)
19016 @cindex pragma GCC target
19017
19018 This pragma allows you to set target specific options for functions
19019 defined later in the source file. One or more strings can be
19020 specified. Each function that is defined after this point is as
19021 if @code{attribute((target("STRING")))} was specified for that
19022 function. The parenthesis around the options is optional.
19023 @xref{Function Attributes}, for more information about the
19024 @code{target} attribute and the attribute syntax.
19025
19026 The @code{#pragma GCC target} pragma is presently implemented for
19027 x86, PowerPC, and Nios II targets only.
19028 @end table
19029
19030 @table @code
19031 @item #pragma GCC optimize (@var{"string"}...)
19032 @cindex pragma GCC optimize
19033
19034 This pragma allows you to set global optimization options for functions
19035 defined later in the source file. One or more strings can be
19036 specified. Each function that is defined after this point is as
19037 if @code{attribute((optimize("STRING")))} was specified for that
19038 function. The parenthesis around the options is optional.
19039 @xref{Function Attributes}, for more information about the
19040 @code{optimize} attribute and the attribute syntax.
19041 @end table
19042
19043 @table @code
19044 @item #pragma GCC push_options
19045 @itemx #pragma GCC pop_options
19046 @cindex pragma GCC push_options
19047 @cindex pragma GCC pop_options
19048
19049 These pragmas maintain a stack of the current target and optimization
19050 options. It is intended for include files where you temporarily want
19051 to switch to using a different @samp{#pragma GCC target} or
19052 @samp{#pragma GCC optimize} and then to pop back to the previous
19053 options.
19054 @end table
19055
19056 @table @code
19057 @item #pragma GCC reset_options
19058 @cindex pragma GCC reset_options
19059
19060 This pragma clears the current @code{#pragma GCC target} and
19061 @code{#pragma GCC optimize} to use the default switches as specified
19062 on the command line.
19063 @end table
19064
19065 @node Loop-Specific Pragmas
19066 @subsection Loop-Specific Pragmas
19067
19068 @table @code
19069 @item #pragma GCC ivdep
19070 @cindex pragma GCC ivdep
19071 @end table
19072
19073 With this pragma, the programmer asserts that there are no loop-carried
19074 dependencies which would prevent consecutive iterations of
19075 the following loop from executing concurrently with SIMD
19076 (single instruction multiple data) instructions.
19077
19078 For example, the compiler can only unconditionally vectorize the following
19079 loop with the pragma:
19080
19081 @smallexample
19082 void foo (int n, int *a, int *b, int *c)
19083 @{
19084 int i, j;
19085 #pragma GCC ivdep
19086 for (i = 0; i < n; ++i)
19087 a[i] = b[i] + c[i];
19088 @}
19089 @end smallexample
19090
19091 @noindent
19092 In this example, using the @code{restrict} qualifier had the same
19093 effect. In the following example, that would not be possible. Assume
19094 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19095 that it can unconditionally vectorize the following loop:
19096
19097 @smallexample
19098 void ignore_vec_dep (int *a, int k, int c, int m)
19099 @{
19100 #pragma GCC ivdep
19101 for (int i = 0; i < m; i++)
19102 a[i] = a[i + k] * c;
19103 @}
19104 @end smallexample
19105
19106
19107 @node Unnamed Fields
19108 @section Unnamed Structure and Union Fields
19109 @cindex @code{struct}
19110 @cindex @code{union}
19111
19112 As permitted by ISO C11 and for compatibility with other compilers,
19113 GCC allows you to define
19114 a structure or union that contains, as fields, structures and unions
19115 without names. For example:
19116
19117 @smallexample
19118 struct @{
19119 int a;
19120 union @{
19121 int b;
19122 float c;
19123 @};
19124 int d;
19125 @} foo;
19126 @end smallexample
19127
19128 @noindent
19129 In this example, you are able to access members of the unnamed
19130 union with code like @samp{foo.b}. Note that only unnamed structs and
19131 unions are allowed, you may not have, for example, an unnamed
19132 @code{int}.
19133
19134 You must never create such structures that cause ambiguous field definitions.
19135 For example, in this structure:
19136
19137 @smallexample
19138 struct @{
19139 int a;
19140 struct @{
19141 int a;
19142 @};
19143 @} foo;
19144 @end smallexample
19145
19146 @noindent
19147 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19148 The compiler gives errors for such constructs.
19149
19150 @opindex fms-extensions
19151 Unless @option{-fms-extensions} is used, the unnamed field must be a
19152 structure or union definition without a tag (for example, @samp{struct
19153 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19154 also be a definition with a tag such as @samp{struct foo @{ int a;
19155 @};}, a reference to a previously defined structure or union such as
19156 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19157 previously defined structure or union type.
19158
19159 @opindex fplan9-extensions
19160 The option @option{-fplan9-extensions} enables
19161 @option{-fms-extensions} as well as two other extensions. First, a
19162 pointer to a structure is automatically converted to a pointer to an
19163 anonymous field for assignments and function calls. For example:
19164
19165 @smallexample
19166 struct s1 @{ int a; @};
19167 struct s2 @{ struct s1; @};
19168 extern void f1 (struct s1 *);
19169 void f2 (struct s2 *p) @{ f1 (p); @}
19170 @end smallexample
19171
19172 @noindent
19173 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19174 converted into a pointer to the anonymous field.
19175
19176 Second, when the type of an anonymous field is a @code{typedef} for a
19177 @code{struct} or @code{union}, code may refer to the field using the
19178 name of the @code{typedef}.
19179
19180 @smallexample
19181 typedef struct @{ int a; @} s1;
19182 struct s2 @{ s1; @};
19183 s1 f1 (struct s2 *p) @{ return p->s1; @}
19184 @end smallexample
19185
19186 These usages are only permitted when they are not ambiguous.
19187
19188 @node Thread-Local
19189 @section Thread-Local Storage
19190 @cindex Thread-Local Storage
19191 @cindex @acronym{TLS}
19192 @cindex @code{__thread}
19193
19194 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19195 are allocated such that there is one instance of the variable per extant
19196 thread. The runtime model GCC uses to implement this originates
19197 in the IA-64 processor-specific ABI, but has since been migrated
19198 to other processors as well. It requires significant support from
19199 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19200 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19201 is not available everywhere.
19202
19203 At the user level, the extension is visible with a new storage
19204 class keyword: @code{__thread}. For example:
19205
19206 @smallexample
19207 __thread int i;
19208 extern __thread struct state s;
19209 static __thread char *p;
19210 @end smallexample
19211
19212 The @code{__thread} specifier may be used alone, with the @code{extern}
19213 or @code{static} specifiers, but with no other storage class specifier.
19214 When used with @code{extern} or @code{static}, @code{__thread} must appear
19215 immediately after the other storage class specifier.
19216
19217 The @code{__thread} specifier may be applied to any global, file-scoped
19218 static, function-scoped static, or static data member of a class. It may
19219 not be applied to block-scoped automatic or non-static data member.
19220
19221 When the address-of operator is applied to a thread-local variable, it is
19222 evaluated at run time and returns the address of the current thread's
19223 instance of that variable. An address so obtained may be used by any
19224 thread. When a thread terminates, any pointers to thread-local variables
19225 in that thread become invalid.
19226
19227 No static initialization may refer to the address of a thread-local variable.
19228
19229 In C++, if an initializer is present for a thread-local variable, it must
19230 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19231 standard.
19232
19233 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19234 ELF Handling For Thread-Local Storage} for a detailed explanation of
19235 the four thread-local storage addressing models, and how the runtime
19236 is expected to function.
19237
19238 @menu
19239 * C99 Thread-Local Edits::
19240 * C++98 Thread-Local Edits::
19241 @end menu
19242
19243 @node C99 Thread-Local Edits
19244 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19245
19246 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19247 that document the exact semantics of the language extension.
19248
19249 @itemize @bullet
19250 @item
19251 @cite{5.1.2 Execution environments}
19252
19253 Add new text after paragraph 1
19254
19255 @quotation
19256 Within either execution environment, a @dfn{thread} is a flow of
19257 control within a program. It is implementation defined whether
19258 or not there may be more than one thread associated with a program.
19259 It is implementation defined how threads beyond the first are
19260 created, the name and type of the function called at thread
19261 startup, and how threads may be terminated. However, objects
19262 with thread storage duration shall be initialized before thread
19263 startup.
19264 @end quotation
19265
19266 @item
19267 @cite{6.2.4 Storage durations of objects}
19268
19269 Add new text before paragraph 3
19270
19271 @quotation
19272 An object whose identifier is declared with the storage-class
19273 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19274 Its lifetime is the entire execution of the thread, and its
19275 stored value is initialized only once, prior to thread startup.
19276 @end quotation
19277
19278 @item
19279 @cite{6.4.1 Keywords}
19280
19281 Add @code{__thread}.
19282
19283 @item
19284 @cite{6.7.1 Storage-class specifiers}
19285
19286 Add @code{__thread} to the list of storage class specifiers in
19287 paragraph 1.
19288
19289 Change paragraph 2 to
19290
19291 @quotation
19292 With the exception of @code{__thread}, at most one storage-class
19293 specifier may be given [@dots{}]. The @code{__thread} specifier may
19294 be used alone, or immediately following @code{extern} or
19295 @code{static}.
19296 @end quotation
19297
19298 Add new text after paragraph 6
19299
19300 @quotation
19301 The declaration of an identifier for a variable that has
19302 block scope that specifies @code{__thread} shall also
19303 specify either @code{extern} or @code{static}.
19304
19305 The @code{__thread} specifier shall be used only with
19306 variables.
19307 @end quotation
19308 @end itemize
19309
19310 @node C++98 Thread-Local Edits
19311 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19312
19313 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19314 that document the exact semantics of the language extension.
19315
19316 @itemize @bullet
19317 @item
19318 @b{[intro.execution]}
19319
19320 New text after paragraph 4
19321
19322 @quotation
19323 A @dfn{thread} is a flow of control within the abstract machine.
19324 It is implementation defined whether or not there may be more than
19325 one thread.
19326 @end quotation
19327
19328 New text after paragraph 7
19329
19330 @quotation
19331 It is unspecified whether additional action must be taken to
19332 ensure when and whether side effects are visible to other threads.
19333 @end quotation
19334
19335 @item
19336 @b{[lex.key]}
19337
19338 Add @code{__thread}.
19339
19340 @item
19341 @b{[basic.start.main]}
19342
19343 Add after paragraph 5
19344
19345 @quotation
19346 The thread that begins execution at the @code{main} function is called
19347 the @dfn{main thread}. It is implementation defined how functions
19348 beginning threads other than the main thread are designated or typed.
19349 A function so designated, as well as the @code{main} function, is called
19350 a @dfn{thread startup function}. It is implementation defined what
19351 happens if a thread startup function returns. It is implementation
19352 defined what happens to other threads when any thread calls @code{exit}.
19353 @end quotation
19354
19355 @item
19356 @b{[basic.start.init]}
19357
19358 Add after paragraph 4
19359
19360 @quotation
19361 The storage for an object of thread storage duration shall be
19362 statically initialized before the first statement of the thread startup
19363 function. An object of thread storage duration shall not require
19364 dynamic initialization.
19365 @end quotation
19366
19367 @item
19368 @b{[basic.start.term]}
19369
19370 Add after paragraph 3
19371
19372 @quotation
19373 The type of an object with thread storage duration shall not have a
19374 non-trivial destructor, nor shall it be an array type whose elements
19375 (directly or indirectly) have non-trivial destructors.
19376 @end quotation
19377
19378 @item
19379 @b{[basic.stc]}
19380
19381 Add ``thread storage duration'' to the list in paragraph 1.
19382
19383 Change paragraph 2
19384
19385 @quotation
19386 Thread, static, and automatic storage durations are associated with
19387 objects introduced by declarations [@dots{}].
19388 @end quotation
19389
19390 Add @code{__thread} to the list of specifiers in paragraph 3.
19391
19392 @item
19393 @b{[basic.stc.thread]}
19394
19395 New section before @b{[basic.stc.static]}
19396
19397 @quotation
19398 The keyword @code{__thread} applied to a non-local object gives the
19399 object thread storage duration.
19400
19401 A local variable or class data member declared both @code{static}
19402 and @code{__thread} gives the variable or member thread storage
19403 duration.
19404 @end quotation
19405
19406 @item
19407 @b{[basic.stc.static]}
19408
19409 Change paragraph 1
19410
19411 @quotation
19412 All objects that have neither thread storage duration, dynamic
19413 storage duration nor are local [@dots{}].
19414 @end quotation
19415
19416 @item
19417 @b{[dcl.stc]}
19418
19419 Add @code{__thread} to the list in paragraph 1.
19420
19421 Change paragraph 1
19422
19423 @quotation
19424 With the exception of @code{__thread}, at most one
19425 @var{storage-class-specifier} shall appear in a given
19426 @var{decl-specifier-seq}. The @code{__thread} specifier may
19427 be used alone, or immediately following the @code{extern} or
19428 @code{static} specifiers. [@dots{}]
19429 @end quotation
19430
19431 Add after paragraph 5
19432
19433 @quotation
19434 The @code{__thread} specifier can be applied only to the names of objects
19435 and to anonymous unions.
19436 @end quotation
19437
19438 @item
19439 @b{[class.mem]}
19440
19441 Add after paragraph 6
19442
19443 @quotation
19444 Non-@code{static} members shall not be @code{__thread}.
19445 @end quotation
19446 @end itemize
19447
19448 @node Binary constants
19449 @section Binary Constants using the @samp{0b} Prefix
19450 @cindex Binary constants using the @samp{0b} prefix
19451
19452 Integer constants can be written as binary constants, consisting of a
19453 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19454 @samp{0B}. This is particularly useful in environments that operate a
19455 lot on the bit level (like microcontrollers).
19456
19457 The following statements are identical:
19458
19459 @smallexample
19460 i = 42;
19461 i = 0x2a;
19462 i = 052;
19463 i = 0b101010;
19464 @end smallexample
19465
19466 The type of these constants follows the same rules as for octal or
19467 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19468 can be applied.
19469
19470 @node C++ Extensions
19471 @chapter Extensions to the C++ Language
19472 @cindex extensions, C++ language
19473 @cindex C++ language extensions
19474
19475 The GNU compiler provides these extensions to the C++ language (and you
19476 can also use most of the C language extensions in your C++ programs). If you
19477 want to write code that checks whether these features are available, you can
19478 test for the GNU compiler the same way as for C programs: check for a
19479 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19480 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19481 Predefined Macros,cpp,The GNU C Preprocessor}).
19482
19483 @menu
19484 * C++ Volatiles:: What constitutes an access to a volatile object.
19485 * Restricted Pointers:: C99 restricted pointers and references.
19486 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19487 * C++ Interface:: You can use a single C++ header file for both
19488 declarations and definitions.
19489 * Template Instantiation:: Methods for ensuring that exactly one copy of
19490 each needed template instantiation is emitted.
19491 * Bound member functions:: You can extract a function pointer to the
19492 method denoted by a @samp{->*} or @samp{.*} expression.
19493 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19494 * Function Multiversioning:: Declaring multiple function versions.
19495 * Namespace Association:: Strong using-directives for namespace association.
19496 * Type Traits:: Compiler support for type traits.
19497 * C++ Concepts:: Improved support for generic programming.
19498 * Java Exceptions:: Tweaking exception handling to work with Java.
19499 * Deprecated Features:: Things will disappear from G++.
19500 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19501 @end menu
19502
19503 @node C++ Volatiles
19504 @section When is a Volatile C++ Object Accessed?
19505 @cindex accessing volatiles
19506 @cindex volatile read
19507 @cindex volatile write
19508 @cindex volatile access
19509
19510 The C++ standard differs from the C standard in its treatment of
19511 volatile objects. It fails to specify what constitutes a volatile
19512 access, except to say that C++ should behave in a similar manner to C
19513 with respect to volatiles, where possible. However, the different
19514 lvalueness of expressions between C and C++ complicate the behavior.
19515 G++ behaves the same as GCC for volatile access, @xref{C
19516 Extensions,,Volatiles}, for a description of GCC's behavior.
19517
19518 The C and C++ language specifications differ when an object is
19519 accessed in a void context:
19520
19521 @smallexample
19522 volatile int *src = @var{somevalue};
19523 *src;
19524 @end smallexample
19525
19526 The C++ standard specifies that such expressions do not undergo lvalue
19527 to rvalue conversion, and that the type of the dereferenced object may
19528 be incomplete. The C++ standard does not specify explicitly that it
19529 is lvalue to rvalue conversion that is responsible for causing an
19530 access. There is reason to believe that it is, because otherwise
19531 certain simple expressions become undefined. However, because it
19532 would surprise most programmers, G++ treats dereferencing a pointer to
19533 volatile object of complete type as GCC would do for an equivalent
19534 type in C@. When the object has incomplete type, G++ issues a
19535 warning; if you wish to force an error, you must force a conversion to
19536 rvalue with, for instance, a static cast.
19537
19538 When using a reference to volatile, G++ does not treat equivalent
19539 expressions as accesses to volatiles, but instead issues a warning that
19540 no volatile is accessed. The rationale for this is that otherwise it
19541 becomes difficult to determine where volatile access occur, and not
19542 possible to ignore the return value from functions returning volatile
19543 references. Again, if you wish to force a read, cast the reference to
19544 an rvalue.
19545
19546 G++ implements the same behavior as GCC does when assigning to a
19547 volatile object---there is no reread of the assigned-to object, the
19548 assigned rvalue is reused. Note that in C++ assignment expressions
19549 are lvalues, and if used as an lvalue, the volatile object is
19550 referred to. For instance, @var{vref} refers to @var{vobj}, as
19551 expected, in the following example:
19552
19553 @smallexample
19554 volatile int vobj;
19555 volatile int &vref = vobj = @var{something};
19556 @end smallexample
19557
19558 @node Restricted Pointers
19559 @section Restricting Pointer Aliasing
19560 @cindex restricted pointers
19561 @cindex restricted references
19562 @cindex restricted this pointer
19563
19564 As with the C front end, G++ understands the C99 feature of restricted pointers,
19565 specified with the @code{__restrict__}, or @code{__restrict} type
19566 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19567 language flag, @code{restrict} is not a keyword in C++.
19568
19569 In addition to allowing restricted pointers, you can specify restricted
19570 references, which indicate that the reference is not aliased in the local
19571 context.
19572
19573 @smallexample
19574 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19575 @{
19576 /* @r{@dots{}} */
19577 @}
19578 @end smallexample
19579
19580 @noindent
19581 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19582 @var{rref} refers to a (different) unaliased integer.
19583
19584 You may also specify whether a member function's @var{this} pointer is
19585 unaliased by using @code{__restrict__} as a member function qualifier.
19586
19587 @smallexample
19588 void T::fn () __restrict__
19589 @{
19590 /* @r{@dots{}} */
19591 @}
19592 @end smallexample
19593
19594 @noindent
19595 Within the body of @code{T::fn}, @var{this} has the effective
19596 definition @code{T *__restrict__ const this}. Notice that the
19597 interpretation of a @code{__restrict__} member function qualifier is
19598 different to that of @code{const} or @code{volatile} qualifier, in that it
19599 is applied to the pointer rather than the object. This is consistent with
19600 other compilers that implement restricted pointers.
19601
19602 As with all outermost parameter qualifiers, @code{__restrict__} is
19603 ignored in function definition matching. This means you only need to
19604 specify @code{__restrict__} in a function definition, rather than
19605 in a function prototype as well.
19606
19607 @node Vague Linkage
19608 @section Vague Linkage
19609 @cindex vague linkage
19610
19611 There are several constructs in C++ that require space in the object
19612 file but are not clearly tied to a single translation unit. We say that
19613 these constructs have ``vague linkage''. Typically such constructs are
19614 emitted wherever they are needed, though sometimes we can be more
19615 clever.
19616
19617 @table @asis
19618 @item Inline Functions
19619 Inline functions are typically defined in a header file which can be
19620 included in many different compilations. Hopefully they can usually be
19621 inlined, but sometimes an out-of-line copy is necessary, if the address
19622 of the function is taken or if inlining fails. In general, we emit an
19623 out-of-line copy in all translation units where one is needed. As an
19624 exception, we only emit inline virtual functions with the vtable, since
19625 it always requires a copy.
19626
19627 Local static variables and string constants used in an inline function
19628 are also considered to have vague linkage, since they must be shared
19629 between all inlined and out-of-line instances of the function.
19630
19631 @item VTables
19632 @cindex vtable
19633 C++ virtual functions are implemented in most compilers using a lookup
19634 table, known as a vtable. The vtable contains pointers to the virtual
19635 functions provided by a class, and each object of the class contains a
19636 pointer to its vtable (or vtables, in some multiple-inheritance
19637 situations). If the class declares any non-inline, non-pure virtual
19638 functions, the first one is chosen as the ``key method'' for the class,
19639 and the vtable is only emitted in the translation unit where the key
19640 method is defined.
19641
19642 @emph{Note:} If the chosen key method is later defined as inline, the
19643 vtable is still emitted in every translation unit that defines it.
19644 Make sure that any inline virtuals are declared inline in the class
19645 body, even if they are not defined there.
19646
19647 @item @code{type_info} objects
19648 @cindex @code{type_info}
19649 @cindex RTTI
19650 C++ requires information about types to be written out in order to
19651 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19652 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19653 object is written out along with the vtable so that @samp{dynamic_cast}
19654 can determine the dynamic type of a class object at run time. For all
19655 other types, we write out the @samp{type_info} object when it is used: when
19656 applying @samp{typeid} to an expression, throwing an object, or
19657 referring to a type in a catch clause or exception specification.
19658
19659 @item Template Instantiations
19660 Most everything in this section also applies to template instantiations,
19661 but there are other options as well.
19662 @xref{Template Instantiation,,Where's the Template?}.
19663
19664 @end table
19665
19666 When used with GNU ld version 2.8 or later on an ELF system such as
19667 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19668 these constructs will be discarded at link time. This is known as
19669 COMDAT support.
19670
19671 On targets that don't support COMDAT, but do support weak symbols, GCC
19672 uses them. This way one copy overrides all the others, but
19673 the unused copies still take up space in the executable.
19674
19675 For targets that do not support either COMDAT or weak symbols,
19676 most entities with vague linkage are emitted as local symbols to
19677 avoid duplicate definition errors from the linker. This does not happen
19678 for local statics in inlines, however, as having multiple copies
19679 almost certainly breaks things.
19680
19681 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19682 another way to control placement of these constructs.
19683
19684 @node C++ Interface
19685 @section C++ Interface and Implementation Pragmas
19686
19687 @cindex interface and implementation headers, C++
19688 @cindex C++ interface and implementation headers
19689 @cindex pragmas, interface and implementation
19690
19691 @code{#pragma interface} and @code{#pragma implementation} provide the
19692 user with a way of explicitly directing the compiler to emit entities
19693 with vague linkage (and debugging information) in a particular
19694 translation unit.
19695
19696 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19697 by COMDAT support and the ``key method'' heuristic
19698 mentioned in @ref{Vague Linkage}. Using them can actually cause your
19699 program to grow due to unnecessary out-of-line copies of inline
19700 functions.
19701
19702 @table @code
19703 @item #pragma interface
19704 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19705 @kindex #pragma interface
19706 Use this directive in @emph{header files} that define object classes, to save
19707 space in most of the object files that use those classes. Normally,
19708 local copies of certain information (backup copies of inline member
19709 functions, debugging information, and the internal tables that implement
19710 virtual functions) must be kept in each object file that includes class
19711 definitions. You can use this pragma to avoid such duplication. When a
19712 header file containing @samp{#pragma interface} is included in a
19713 compilation, this auxiliary information is not generated (unless
19714 the main input source file itself uses @samp{#pragma implementation}).
19715 Instead, the object files contain references to be resolved at link
19716 time.
19717
19718 The second form of this directive is useful for the case where you have
19719 multiple headers with the same name in different directories. If you
19720 use this form, you must specify the same string to @samp{#pragma
19721 implementation}.
19722
19723 @item #pragma implementation
19724 @itemx #pragma implementation "@var{objects}.h"
19725 @kindex #pragma implementation
19726 Use this pragma in a @emph{main input file}, when you want full output from
19727 included header files to be generated (and made globally visible). The
19728 included header file, in turn, should use @samp{#pragma interface}.
19729 Backup copies of inline member functions, debugging information, and the
19730 internal tables used to implement virtual functions are all generated in
19731 implementation files.
19732
19733 @cindex implied @code{#pragma implementation}
19734 @cindex @code{#pragma implementation}, implied
19735 @cindex naming convention, implementation headers
19736 If you use @samp{#pragma implementation} with no argument, it applies to
19737 an include file with the same basename@footnote{A file's @dfn{basename}
19738 is the name stripped of all leading path information and of trailing
19739 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19740 file. For example, in @file{allclass.cc}, giving just
19741 @samp{#pragma implementation}
19742 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19743
19744 Use the string argument if you want a single implementation file to
19745 include code from multiple header files. (You must also use
19746 @samp{#include} to include the header file; @samp{#pragma
19747 implementation} only specifies how to use the file---it doesn't actually
19748 include it.)
19749
19750 There is no way to split up the contents of a single header file into
19751 multiple implementation files.
19752 @end table
19753
19754 @cindex inlining and C++ pragmas
19755 @cindex C++ pragmas, effect on inlining
19756 @cindex pragmas in C++, effect on inlining
19757 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19758 effect on function inlining.
19759
19760 If you define a class in a header file marked with @samp{#pragma
19761 interface}, the effect on an inline function defined in that class is
19762 similar to an explicit @code{extern} declaration---the compiler emits
19763 no code at all to define an independent version of the function. Its
19764 definition is used only for inlining with its callers.
19765
19766 @opindex fno-implement-inlines
19767 Conversely, when you include the same header file in a main source file
19768 that declares it as @samp{#pragma implementation}, the compiler emits
19769 code for the function itself; this defines a version of the function
19770 that can be found via pointers (or by callers compiled without
19771 inlining). If all calls to the function can be inlined, you can avoid
19772 emitting the function by compiling with @option{-fno-implement-inlines}.
19773 If any calls are not inlined, you will get linker errors.
19774
19775 @node Template Instantiation
19776 @section Where's the Template?
19777 @cindex template instantiation
19778
19779 C++ templates were the first language feature to require more
19780 intelligence from the environment than was traditionally found on a UNIX
19781 system. Somehow the compiler and linker have to make sure that each
19782 template instance occurs exactly once in the executable if it is needed,
19783 and not at all otherwise. There are two basic approaches to this
19784 problem, which are referred to as the Borland model and the Cfront model.
19785
19786 @table @asis
19787 @item Borland model
19788 Borland C++ solved the template instantiation problem by adding the code
19789 equivalent of common blocks to their linker; the compiler emits template
19790 instances in each translation unit that uses them, and the linker
19791 collapses them together. The advantage of this model is that the linker
19792 only has to consider the object files themselves; there is no external
19793 complexity to worry about. The disadvantage is that compilation time
19794 is increased because the template code is being compiled repeatedly.
19795 Code written for this model tends to include definitions of all
19796 templates in the header file, since they must be seen to be
19797 instantiated.
19798
19799 @item Cfront model
19800 The AT&T C++ translator, Cfront, solved the template instantiation
19801 problem by creating the notion of a template repository, an
19802 automatically maintained place where template instances are stored. A
19803 more modern version of the repository works as follows: As individual
19804 object files are built, the compiler places any template definitions and
19805 instantiations encountered in the repository. At link time, the link
19806 wrapper adds in the objects in the repository and compiles any needed
19807 instances that were not previously emitted. The advantages of this
19808 model are more optimal compilation speed and the ability to use the
19809 system linker; to implement the Borland model a compiler vendor also
19810 needs to replace the linker. The disadvantages are vastly increased
19811 complexity, and thus potential for error; for some code this can be
19812 just as transparent, but in practice it can been very difficult to build
19813 multiple programs in one directory and one program in multiple
19814 directories. Code written for this model tends to separate definitions
19815 of non-inline member templates into a separate file, which should be
19816 compiled separately.
19817 @end table
19818
19819 G++ implements the Borland model on targets where the linker supports it,
19820 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
19821 Otherwise G++ implements neither automatic model.
19822
19823 You have the following options for dealing with template instantiations:
19824
19825 @enumerate
19826 @item
19827 Do nothing. Code written for the Borland model works fine, but
19828 each translation unit contains instances of each of the templates it
19829 uses. The duplicate instances will be discarded by the linker, but in
19830 a large program, this can lead to an unacceptable amount of code
19831 duplication in object files or shared libraries.
19832
19833 Duplicate instances of a template can be avoided by defining an explicit
19834 instantiation in one object file, and preventing the compiler from doing
19835 implicit instantiations in any other object files by using an explicit
19836 instantiation declaration, using the @code{extern template} syntax:
19837
19838 @smallexample
19839 extern template int max (int, int);
19840 @end smallexample
19841
19842 This syntax is defined in the C++ 2011 standard, but has been supported by
19843 G++ and other compilers since well before 2011.
19844
19845 Explicit instantiations can be used for the largest or most frequently
19846 duplicated instances, without having to know exactly which other instances
19847 are used in the rest of the program. You can scatter the explicit
19848 instantiations throughout your program, perhaps putting them in the
19849 translation units where the instances are used or the translation units
19850 that define the templates themselves; you can put all of the explicit
19851 instantiations you need into one big file; or you can create small files
19852 like
19853
19854 @smallexample
19855 #include "Foo.h"
19856 #include "Foo.cc"
19857
19858 template class Foo<int>;
19859 template ostream& operator <<
19860 (ostream&, const Foo<int>&);
19861 @end smallexample
19862
19863 @noindent
19864 for each of the instances you need, and create a template instantiation
19865 library from those.
19866
19867 This is the simplest option, but also offers flexibility and
19868 fine-grained control when necessary. It is also the most portable
19869 alternative and programs using this approach will work with most modern
19870 compilers.
19871
19872 @item
19873 @opindex frepo
19874 Compile your template-using code with @option{-frepo}. The compiler
19875 generates files with the extension @samp{.rpo} listing all of the
19876 template instantiations used in the corresponding object files that
19877 could be instantiated there; the link wrapper, @samp{collect2},
19878 then updates the @samp{.rpo} files to tell the compiler where to place
19879 those instantiations and rebuild any affected object files. The
19880 link-time overhead is negligible after the first pass, as the compiler
19881 continues to place the instantiations in the same files.
19882
19883 This can be a suitable option for application code written for the Borland
19884 model, as it usually just works. Code written for the Cfront model
19885 needs to be modified so that the template definitions are available at
19886 one or more points of instantiation; usually this is as simple as adding
19887 @code{#include <tmethods.cc>} to the end of each template header.
19888
19889 For library code, if you want the library to provide all of the template
19890 instantiations it needs, just try to link all of its object files
19891 together; the link will fail, but cause the instantiations to be
19892 generated as a side effect. Be warned, however, that this may cause
19893 conflicts if multiple libraries try to provide the same instantiations.
19894 For greater control, use explicit instantiation as described in the next
19895 option.
19896
19897 @item
19898 @opindex fno-implicit-templates
19899 Compile your code with @option{-fno-implicit-templates} to disable the
19900 implicit generation of template instances, and explicitly instantiate
19901 all the ones you use. This approach requires more knowledge of exactly
19902 which instances you need than do the others, but it's less
19903 mysterious and allows greater control if you want to ensure that only
19904 the intended instances are used.
19905
19906 If you are using Cfront-model code, you can probably get away with not
19907 using @option{-fno-implicit-templates} when compiling files that don't
19908 @samp{#include} the member template definitions.
19909
19910 If you use one big file to do the instantiations, you may want to
19911 compile it without @option{-fno-implicit-templates} so you get all of the
19912 instances required by your explicit instantiations (but not by any
19913 other files) without having to specify them as well.
19914
19915 In addition to forward declaration of explicit instantiations
19916 (with @code{extern}), G++ has extended the template instantiation
19917 syntax to support instantiation of the compiler support data for a
19918 template class (i.e.@: the vtable) without instantiating any of its
19919 members (with @code{inline}), and instantiation of only the static data
19920 members of a template class, without the support data or member
19921 functions (with @code{static}):
19922
19923 @smallexample
19924 inline template class Foo<int>;
19925 static template class Foo<int>;
19926 @end smallexample
19927 @end enumerate
19928
19929 @node Bound member functions
19930 @section Extracting the Function Pointer from a Bound Pointer to Member Function
19931 @cindex pmf
19932 @cindex pointer to member function
19933 @cindex bound pointer to member function
19934
19935 In C++, pointer to member functions (PMFs) are implemented using a wide
19936 pointer of sorts to handle all the possible call mechanisms; the PMF
19937 needs to store information about how to adjust the @samp{this} pointer,
19938 and if the function pointed to is virtual, where to find the vtable, and
19939 where in the vtable to look for the member function. If you are using
19940 PMFs in an inner loop, you should really reconsider that decision. If
19941 that is not an option, you can extract the pointer to the function that
19942 would be called for a given object/PMF pair and call it directly inside
19943 the inner loop, to save a bit of time.
19944
19945 Note that you still pay the penalty for the call through a
19946 function pointer; on most modern architectures, such a call defeats the
19947 branch prediction features of the CPU@. This is also true of normal
19948 virtual function calls.
19949
19950 The syntax for this extension is
19951
19952 @smallexample
19953 extern A a;
19954 extern int (A::*fp)();
19955 typedef int (*fptr)(A *);
19956
19957 fptr p = (fptr)(a.*fp);
19958 @end smallexample
19959
19960 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
19961 no object is needed to obtain the address of the function. They can be
19962 converted to function pointers directly:
19963
19964 @smallexample
19965 fptr p1 = (fptr)(&A::foo);
19966 @end smallexample
19967
19968 @opindex Wno-pmf-conversions
19969 You must specify @option{-Wno-pmf-conversions} to use this extension.
19970
19971 @node C++ Attributes
19972 @section C++-Specific Variable, Function, and Type Attributes
19973
19974 Some attributes only make sense for C++ programs.
19975
19976 @table @code
19977 @item abi_tag ("@var{tag}", ...)
19978 @cindex @code{abi_tag} function attribute
19979 @cindex @code{abi_tag} variable attribute
19980 @cindex @code{abi_tag} type attribute
19981 The @code{abi_tag} attribute can be applied to a function, variable, or class
19982 declaration. It modifies the mangled name of the entity to
19983 incorporate the tag name, in order to distinguish the function or
19984 class from an earlier version with a different ABI; perhaps the class
19985 has changed size, or the function has a different return type that is
19986 not encoded in the mangled name.
19987
19988 The attribute can also be applied to an inline namespace, but does not
19989 affect the mangled name of the namespace; in this case it is only used
19990 for @option{-Wabi-tag} warnings and automatic tagging of functions and
19991 variables. Tagging inline namespaces is generally preferable to
19992 tagging individual declarations, but the latter is sometimes
19993 necessary, such as when only certain members of a class need to be
19994 tagged.
19995
19996 The argument can be a list of strings of arbitrary length. The
19997 strings are sorted on output, so the order of the list is
19998 unimportant.
19999
20000 A redeclaration of an entity must not add new ABI tags,
20001 since doing so would change the mangled name.
20002
20003 The ABI tags apply to a name, so all instantiations and
20004 specializations of a template have the same tags. The attribute will
20005 be ignored if applied to an explicit specialization or instantiation.
20006
20007 The @option{-Wabi-tag} flag enables a warning about a class which does
20008 not have all the ABI tags used by its subobjects and virtual functions; for users with code
20009 that needs to coexist with an earlier ABI, using this option can help
20010 to find all affected types that need to be tagged.
20011
20012 When a type involving an ABI tag is used as the type of a variable or
20013 return type of a function where that tag is not already present in the
20014 signature of the function, the tag is automatically applied to the
20015 variable or function. @option{-Wabi-tag} also warns about this
20016 situation; this warning can be avoided by explicitly tagging the
20017 variable or function or moving it into a tagged inline namespace.
20018
20019 @item init_priority (@var{priority})
20020 @cindex @code{init_priority} variable attribute
20021
20022 In Standard C++, objects defined at namespace scope are guaranteed to be
20023 initialized in an order in strict accordance with that of their definitions
20024 @emph{in a given translation unit}. No guarantee is made for initializations
20025 across translation units. However, GNU C++ allows users to control the
20026 order of initialization of objects defined at namespace scope with the
20027 @code{init_priority} attribute by specifying a relative @var{priority},
20028 a constant integral expression currently bounded between 101 and 65535
20029 inclusive. Lower numbers indicate a higher priority.
20030
20031 In the following example, @code{A} would normally be created before
20032 @code{B}, but the @code{init_priority} attribute reverses that order:
20033
20034 @smallexample
20035 Some_Class A __attribute__ ((init_priority (2000)));
20036 Some_Class B __attribute__ ((init_priority (543)));
20037 @end smallexample
20038
20039 @noindent
20040 Note that the particular values of @var{priority} do not matter; only their
20041 relative ordering.
20042
20043 @item java_interface
20044 @cindex @code{java_interface} type attribute
20045
20046 This type attribute informs C++ that the class is a Java interface. It may
20047 only be applied to classes declared within an @code{extern "Java"} block.
20048 Calls to methods declared in this interface are dispatched using GCJ's
20049 interface table mechanism, instead of regular virtual table dispatch.
20050
20051 @item warn_unused
20052 @cindex @code{warn_unused} type attribute
20053
20054 For C++ types with non-trivial constructors and/or destructors it is
20055 impossible for the compiler to determine whether a variable of this
20056 type is truly unused if it is not referenced. This type attribute
20057 informs the compiler that variables of this type should be warned
20058 about if they appear to be unused, just like variables of fundamental
20059 types.
20060
20061 This attribute is appropriate for types which just represent a value,
20062 such as @code{std::string}; it is not appropriate for types which
20063 control a resource, such as @code{std::mutex}.
20064
20065 This attribute is also accepted in C, but it is unnecessary because C
20066 does not have constructors or destructors.
20067
20068 @end table
20069
20070 See also @ref{Namespace Association}.
20071
20072 @node Function Multiversioning
20073 @section Function Multiversioning
20074 @cindex function versions
20075
20076 With the GNU C++ front end, for x86 targets, you may specify multiple
20077 versions of a function, where each function is specialized for a
20078 specific target feature. At runtime, the appropriate version of the
20079 function is automatically executed depending on the characteristics of
20080 the execution platform. Here is an example.
20081
20082 @smallexample
20083 __attribute__ ((target ("default")))
20084 int foo ()
20085 @{
20086 // The default version of foo.
20087 return 0;
20088 @}
20089
20090 __attribute__ ((target ("sse4.2")))
20091 int foo ()
20092 @{
20093 // foo version for SSE4.2
20094 return 1;
20095 @}
20096
20097 __attribute__ ((target ("arch=atom")))
20098 int foo ()
20099 @{
20100 // foo version for the Intel ATOM processor
20101 return 2;
20102 @}
20103
20104 __attribute__ ((target ("arch=amdfam10")))
20105 int foo ()
20106 @{
20107 // foo version for the AMD Family 0x10 processors.
20108 return 3;
20109 @}
20110
20111 int main ()
20112 @{
20113 int (*p)() = &foo;
20114 assert ((*p) () == foo ());
20115 return 0;
20116 @}
20117 @end smallexample
20118
20119 In the above example, four versions of function foo are created. The
20120 first version of foo with the target attribute "default" is the default
20121 version. This version gets executed when no other target specific
20122 version qualifies for execution on a particular platform. A new version
20123 of foo is created by using the same function signature but with a
20124 different target string. Function foo is called or a pointer to it is
20125 taken just like a regular function. GCC takes care of doing the
20126 dispatching to call the right version at runtime. Refer to the
20127 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20128 Function Multiversioning} for more details.
20129
20130 @node Namespace Association
20131 @section Namespace Association
20132
20133 @strong{Caution:} The semantics of this extension are equivalent
20134 to C++ 2011 inline namespaces. Users should use inline namespaces
20135 instead as this extension will be removed in future versions of G++.
20136
20137 A using-directive with @code{__attribute ((strong))} is stronger
20138 than a normal using-directive in two ways:
20139
20140 @itemize @bullet
20141 @item
20142 Templates from the used namespace can be specialized and explicitly
20143 instantiated as though they were members of the using namespace.
20144
20145 @item
20146 The using namespace is considered an associated namespace of all
20147 templates in the used namespace for purposes of argument-dependent
20148 name lookup.
20149 @end itemize
20150
20151 The used namespace must be nested within the using namespace so that
20152 normal unqualified lookup works properly.
20153
20154 This is useful for composing a namespace transparently from
20155 implementation namespaces. For example:
20156
20157 @smallexample
20158 namespace std @{
20159 namespace debug @{
20160 template <class T> struct A @{ @};
20161 @}
20162 using namespace debug __attribute ((__strong__));
20163 template <> struct A<int> @{ @}; // @r{OK to specialize}
20164
20165 template <class T> void f (A<T>);
20166 @}
20167
20168 int main()
20169 @{
20170 f (std::A<float>()); // @r{lookup finds} std::f
20171 f (std::A<int>());
20172 @}
20173 @end smallexample
20174
20175 @node Type Traits
20176 @section Type Traits
20177
20178 The C++ front end implements syntactic extensions that allow
20179 compile-time determination of
20180 various characteristics of a type (or of a
20181 pair of types).
20182
20183 @table @code
20184 @item __has_nothrow_assign (type)
20185 If @code{type} is const qualified or is a reference type then the trait is
20186 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20187 is true, else if @code{type} is a cv class or union type with copy assignment
20188 operators that are known not to throw an exception then the trait is true,
20189 else it is false. Requires: @code{type} shall be a complete type,
20190 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20191
20192 @item __has_nothrow_copy (type)
20193 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20194 @code{type} is a cv class or union type with copy constructors that
20195 are known not to throw an exception then the trait is true, else it is false.
20196 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20197 @code{void}, or an array of unknown bound.
20198
20199 @item __has_nothrow_constructor (type)
20200 If @code{__has_trivial_constructor (type)} is true then the trait is
20201 true, else if @code{type} is a cv class or union type (or array
20202 thereof) with a default constructor that is known not to throw an
20203 exception then the trait is true, else it is false. Requires:
20204 @code{type} shall be a complete type, (possibly cv-qualified)
20205 @code{void}, or an array of unknown bound.
20206
20207 @item __has_trivial_assign (type)
20208 If @code{type} is const qualified or is a reference type then the trait is
20209 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20210 true, else if @code{type} is a cv class or union type with a trivial
20211 copy assignment ([class.copy]) then the trait is true, else it is
20212 false. Requires: @code{type} shall be a complete type, (possibly
20213 cv-qualified) @code{void}, or an array of unknown bound.
20214
20215 @item __has_trivial_copy (type)
20216 If @code{__is_pod (type)} is true or @code{type} is a reference type
20217 then the trait is true, else if @code{type} is a cv class or union type
20218 with a trivial copy constructor ([class.copy]) then the trait
20219 is true, else it is false. Requires: @code{type} shall be a complete
20220 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20221
20222 @item __has_trivial_constructor (type)
20223 If @code{__is_pod (type)} is true then the trait is true, else if
20224 @code{type} is a cv class or union type (or array thereof) with a
20225 trivial default constructor ([class.ctor]) then the trait is true,
20226 else it is false. Requires: @code{type} shall be a complete
20227 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20228
20229 @item __has_trivial_destructor (type)
20230 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20231 the trait is true, else if @code{type} is a cv class or union type (or
20232 array thereof) with a trivial destructor ([class.dtor]) then the trait
20233 is true, else it is false. Requires: @code{type} shall be a complete
20234 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20235
20236 @item __has_virtual_destructor (type)
20237 If @code{type} is a class type with a virtual destructor
20238 ([class.dtor]) then the trait is true, else it is false. Requires:
20239 @code{type} shall be a complete type, (possibly cv-qualified)
20240 @code{void}, or an array of unknown bound.
20241
20242 @item __is_abstract (type)
20243 If @code{type} is an abstract class ([class.abstract]) then the trait
20244 is true, else it is false. Requires: @code{type} shall be a complete
20245 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20246
20247 @item __is_base_of (base_type, derived_type)
20248 If @code{base_type} is a base class of @code{derived_type}
20249 ([class.derived]) then the trait is true, otherwise it is false.
20250 Top-level cv qualifications of @code{base_type} and
20251 @code{derived_type} are ignored. For the purposes of this trait, a
20252 class type is considered is own base. Requires: if @code{__is_class
20253 (base_type)} and @code{__is_class (derived_type)} are true and
20254 @code{base_type} and @code{derived_type} are not the same type
20255 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20256 type. Diagnostic is produced if this requirement is not met.
20257
20258 @item __is_class (type)
20259 If @code{type} is a cv class type, and not a union type
20260 ([basic.compound]) the trait is true, else it is false.
20261
20262 @item __is_empty (type)
20263 If @code{__is_class (type)} is false then the trait is false.
20264 Otherwise @code{type} is considered empty if and only if: @code{type}
20265 has no non-static data members, or all non-static data members, if
20266 any, are bit-fields of length 0, and @code{type} has no virtual
20267 members, and @code{type} has no virtual base classes, and @code{type}
20268 has no base classes @code{base_type} for which
20269 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20270 be a complete type, (possibly cv-qualified) @code{void}, or an array
20271 of unknown bound.
20272
20273 @item __is_enum (type)
20274 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20275 true, else it is false.
20276
20277 @item __is_literal_type (type)
20278 If @code{type} is a literal type ([basic.types]) the trait is
20279 true, else it is false. Requires: @code{type} shall be a complete type,
20280 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20281
20282 @item __is_pod (type)
20283 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20284 else it is false. Requires: @code{type} shall be a complete type,
20285 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20286
20287 @item __is_polymorphic (type)
20288 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20289 is true, else it is false. Requires: @code{type} shall be a complete
20290 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20291
20292 @item __is_standard_layout (type)
20293 If @code{type} is a standard-layout type ([basic.types]) the trait is
20294 true, else it is false. Requires: @code{type} shall be a complete
20295 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20296
20297 @item __is_trivial (type)
20298 If @code{type} is a trivial type ([basic.types]) the trait is
20299 true, else it is false. Requires: @code{type} shall be a complete
20300 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20301
20302 @item __is_union (type)
20303 If @code{type} is a cv union type ([basic.compound]) the trait is
20304 true, else it is false.
20305
20306 @item __underlying_type (type)
20307 The underlying type of @code{type}. Requires: @code{type} shall be
20308 an enumeration type ([dcl.enum]).
20309
20310 @end table
20311
20312
20313 @node C++ Concepts
20314 @section C++ Concepts
20315
20316 C++ concepts provide much-improved support for generic programming. In
20317 particular, they allow the specification of constraints on template arguments.
20318 The constraints are used to extend the usual overloading and partial
20319 specialization capabilities of the language, allowing generic data structures
20320 and algorithms to be ``refined'' based on their properties rather than their
20321 type names.
20322
20323 The following keywords are reserved for concepts.
20324
20325 @table @code
20326 @item assumes
20327 States an expression as an assumption, and if possible, verifies that the
20328 assumption is valid. For example, @code{assume(n > 0)}.
20329
20330 @item axiom
20331 Introduces an axiom definition. Axioms introduce requirements on values.
20332
20333 @item forall
20334 Introduces a universally quantified object in an axiom. For example,
20335 @code{forall (int n) n + 0 == n}).
20336
20337 @item concept
20338 Introduces a concept definition. Concepts are sets of syntactic and semantic
20339 requirements on types and their values.
20340
20341 @item requires
20342 Introduces constraints on template arguments or requirements for a member
20343 function of a class template.
20344
20345 @end table
20346
20347 The front end also exposes a number of internal mechanism that can be used
20348 to simplify the writing of type traits. Note that some of these traits are
20349 likely to be removed in the future.
20350
20351 @table @code
20352 @item __is_same (type1, type2)
20353 A binary type trait: true whenever the type arguments are the same.
20354
20355 @end table
20356
20357
20358 @node Java Exceptions
20359 @section Java Exceptions
20360
20361 The Java language uses a slightly different exception handling model
20362 from C++. Normally, GNU C++ automatically detects when you are
20363 writing C++ code that uses Java exceptions, and handle them
20364 appropriately. However, if C++ code only needs to execute destructors
20365 when Java exceptions are thrown through it, GCC guesses incorrectly.
20366 Sample problematic code is:
20367
20368 @smallexample
20369 struct S @{ ~S(); @};
20370 extern void bar(); // @r{is written in Java, and may throw exceptions}
20371 void foo()
20372 @{
20373 S s;
20374 bar();
20375 @}
20376 @end smallexample
20377
20378 @noindent
20379 The usual effect of an incorrect guess is a link failure, complaining of
20380 a missing routine called @samp{__gxx_personality_v0}.
20381
20382 You can inform the compiler that Java exceptions are to be used in a
20383 translation unit, irrespective of what it might think, by writing
20384 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20385 @samp{#pragma} must appear before any functions that throw or catch
20386 exceptions, or run destructors when exceptions are thrown through them.
20387
20388 You cannot mix Java and C++ exceptions in the same translation unit. It
20389 is believed to be safe to throw a C++ exception from one file through
20390 another file compiled for the Java exception model, or vice versa, but
20391 there may be bugs in this area.
20392
20393 @node Deprecated Features
20394 @section Deprecated Features
20395
20396 In the past, the GNU C++ compiler was extended to experiment with new
20397 features, at a time when the C++ language was still evolving. Now that
20398 the C++ standard is complete, some of those features are superseded by
20399 superior alternatives. Using the old features might cause a warning in
20400 some cases that the feature will be dropped in the future. In other
20401 cases, the feature might be gone already.
20402
20403 While the list below is not exhaustive, it documents some of the options
20404 that are now deprecated:
20405
20406 @table @code
20407 @item -fexternal-templates
20408 @itemx -falt-external-templates
20409 These are two of the many ways for G++ to implement template
20410 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20411 defines how template definitions have to be organized across
20412 implementation units. G++ has an implicit instantiation mechanism that
20413 should work just fine for standard-conforming code.
20414
20415 @item -fstrict-prototype
20416 @itemx -fno-strict-prototype
20417 Previously it was possible to use an empty prototype parameter list to
20418 indicate an unspecified number of parameters (like C), rather than no
20419 parameters, as C++ demands. This feature has been removed, except where
20420 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20421 @end table
20422
20423 G++ allows a virtual function returning @samp{void *} to be overridden
20424 by one returning a different pointer type. This extension to the
20425 covariant return type rules is now deprecated and will be removed from a
20426 future version.
20427
20428 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20429 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20430 and are now removed from G++. Code using these operators should be
20431 modified to use @code{std::min} and @code{std::max} instead.
20432
20433 The named return value extension has been deprecated, and is now
20434 removed from G++.
20435
20436 The use of initializer lists with new expressions has been deprecated,
20437 and is now removed from G++.
20438
20439 Floating and complex non-type template parameters have been deprecated,
20440 and are now removed from G++.
20441
20442 The implicit typename extension has been deprecated and is now
20443 removed from G++.
20444
20445 The use of default arguments in function pointers, function typedefs
20446 and other places where they are not permitted by the standard is
20447 deprecated and will be removed from a future version of G++.
20448
20449 G++ allows floating-point literals to appear in integral constant expressions,
20450 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20451 This extension is deprecated and will be removed from a future version.
20452
20453 G++ allows static data members of const floating-point type to be declared
20454 with an initializer in a class definition. The standard only allows
20455 initializers for static members of const integral types and const
20456 enumeration types so this extension has been deprecated and will be removed
20457 from a future version.
20458
20459 @node Backwards Compatibility
20460 @section Backwards Compatibility
20461 @cindex Backwards Compatibility
20462 @cindex ARM [Annotated C++ Reference Manual]
20463
20464 Now that there is a definitive ISO standard C++, G++ has a specification
20465 to adhere to. The C++ language evolved over time, and features that
20466 used to be acceptable in previous drafts of the standard, such as the ARM
20467 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20468 compilation of C++ written to such drafts, G++ contains some backwards
20469 compatibilities. @emph{All such backwards compatibility features are
20470 liable to disappear in future versions of G++.} They should be considered
20471 deprecated. @xref{Deprecated Features}.
20472
20473 @table @code
20474 @item For scope
20475 If a variable is declared at for scope, it used to remain in scope until
20476 the end of the scope that contained the for statement (rather than just
20477 within the for scope). G++ retains this, but issues a warning, if such a
20478 variable is accessed outside the for scope.
20479
20480 @item Implicit C language
20481 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20482 scope to set the language. On such systems, all header files are
20483 implicitly scoped inside a C language scope. Also, an empty prototype
20484 @code{()} is treated as an unspecified number of arguments, rather
20485 than no arguments, as C++ demands.
20486 @end table
20487
20488 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20489 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr