PR c++/70652 - [6 Regression] r234966 causes bootstrap to fail
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2016 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
17
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
21
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
52 or arrays as values.
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
75 function.
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
219
220 @smallexample
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
223
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
228
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
233
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
238
239 A local label declaration looks like this:
240
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
244
245 @noindent
246 or
247
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
251
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
254
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
258
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
265
266 @smallexample
267 #define SEARCH(value, array, target) \
268 do @{ \
269 __label__ found; \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
272 int i, j; \
273 int value; \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
278 (value) = -1; \
279 found:; \
280 @} while (0)
281 @end smallexample
282
283 This could also be written using a statement expression:
284
285 @smallexample
286 #define SEARCH(array, target) \
287 (@{ \
288 __label__ found; \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
291 int i, j; \
292 int value; \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
297 value = -1; \
298 found: \
299 value; \
300 @})
301 @end smallexample
302
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
305
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
312
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
317
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
323
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
329
330 @smallexample
331 goto *ptr;
332 @end smallexample
333
334 @noindent
335 Any expression of type @code{void *} is allowed.
336
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
339
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
343
344 @noindent
345 Then you can select a label with indexing, like this:
346
347 @smallexample
348 goto *array[i];
349 @end smallexample
350
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
354
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
359
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
363
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
368
369 An alternate way to write the above example is
370
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
376
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
383
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
390
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
396
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
400
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
404
405 @smallexample
406 @group
407 foo (double a, double b)
408 @{
409 double square (double z) @{ return z * z; @}
410
411 return square (a) + square (b);
412 @}
413 @end group
414 @end smallexample
415
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
420
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
424 @{
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
427 int i;
428 /* @r{@dots{}} */
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @}
432 @end group
433 @end smallexample
434
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
438
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
441
442 @smallexample
443 hack (int *array, int size)
444 @{
445 void store (int index, int value)
446 @{ array[index] = value; @}
447
448 intermediate (store, size);
449 @}
450 @end smallexample
451
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
457
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
465
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
470
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
476
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
480 @{
481 __label__ failure;
482 int access (int *array, int index)
483 @{
484 if (index > size)
485 goto failure;
486 return array[index + offset];
487 @}
488 int i;
489 /* @r{@dots{}} */
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492 /* @r{@dots{}} */
493 return 0;
494
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
497 failure:
498 return -1;
499 @}
500 @end group
501 @end smallexample
502
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
507
508 @smallexample
509 bar (int *array, int offset, int size)
510 @{
511 __label__ failure;
512 auto int access (int *, int);
513 /* @r{@dots{}} */
514 int access (int *array, int index)
515 @{
516 if (index > size)
517 goto failure;
518 return array[index + offset];
519 @}
520 /* @r{@dots{}} */
521 @}
522 @end smallexample
523
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
528
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
533
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
538
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
543
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
548
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
553 @end deftypefn
554
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
559
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
563
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
567
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
573
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
579
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
594 @{
595 int r = fprintf (f, "myprintf: ");
596 if (r < 0)
597 return r;
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
599 if (s < 0)
600 return s;
601 return r + s;
602 @}
603 @end smallexample
604 @end deftypefn
605
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
618 @{
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
621
622 if (__builtin_constant_p (oflag))
623 @{
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 @{
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
628 @}
629 return open (path, oflag, __builtin_va_arg_pack ());
630 @}
631
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
634
635 return open (path, oflag, __builtin_va_arg_pack ());
636 @}
637 #endif
638 @end smallexample
639 @end deftypefn
640
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
646
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
650
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
653
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
657
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
661
662 Here is an example with a typename as the argument:
663
664 @smallexample
665 typeof (int *)
666 @end smallexample
667
668 @noindent
669 Here the type described is that of pointers to @code{int}.
670
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
674
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
678
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
682
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
688
689 @smallexample
690 #define max(a,b) \
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
694 @end smallexample
695
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
701
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
708
709 @noindent
710 Some more examples of the use of @code{typeof}:
711
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
715
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of such values.
722
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
726
727 @item
728 This declares @code{y} as an array of pointers to characters:
729
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
733
734 @noindent
735 It is equivalent to the following traditional C declaration:
736
737 @smallexample
738 char *y[4];
739 @end smallexample
740
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
743
744 @smallexample
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
748
749 @noindent
750 Now the declaration can be rewritten this way:
751
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
755
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
760
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
769
770 @smallexample
771 #define max(a,b) \
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
775 @end smallexample
776
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
784
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
789
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
797
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
801
802 Therefore, the expression
803
804 @smallexample
805 x ? : y
806 @end smallexample
807
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
811
812 This example is perfectly equivalent to
813
814 @smallexample
815 x ? x : y
816 @end smallexample
817
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
827
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
831
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
838
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
846
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
854
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
862
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
870
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
876
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
882
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
889
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
899
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
909
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
916
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF
920 debug info format can represent this, so use of DWARF is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}. You can
925 examine and set these two fictitious variables with your debugger.
926
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{__ibm128} data type
933 @cindex @code{w} floating point suffix
934 @cindex @code{q} floating point suffix
935 @cindex @code{W} floating point suffix
936 @cindex @code{Q} floating point suffix
937
938 As an extension, GNU C supports additional floating
939 types, @code{__float80} and @code{__float128} to support 80-bit
940 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
941 Support for additional types includes the arithmetic operators:
942 add, subtract, multiply, divide; unary arithmetic operators;
943 relational operators; equality operators; and conversions to and from
944 integer and other floating types. Use a suffix @samp{w} or @samp{W}
945 in a literal constant of type @code{__float80} or type
946 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
947
948 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
949 types using the corresponding internal complex type, @code{XCmode} for
950 @code{__float80} type and @code{TCmode} for @code{__float128} type:
951
952 @smallexample
953 typedef _Complex float __attribute__((mode(TC))) _Complex128;
954 typedef _Complex float __attribute__((mode(XC))) _Complex80;
955 @end smallexample
956
957 In order to use @code{__float128} and @code{__ibm128} on PowerPC Linux
958 systems, you must use the @option{-mfloat128}. It is expected in
959 future versions of GCC that @code{__float128} will be enabled
960 automatically. In addition, there are currently problems in using the
961 complex @code{__float128} type. When these problems are fixed, you
962 would use the following syntax to declare @code{_Complex128} to be a
963 complex @code{__float128} type:
964
965 @smallexample
966 typedef _Complex float __attribute__((mode(KC))) _Complex128;
967 @end smallexample
968
969 Not all targets support additional floating-point types.
970 @code{__float80} and @code{__float128} types are supported on x86 and
971 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
972 The @code{__float128} type is supported on PowerPC 64-bit Linux
973 systems by default if the vector scalar instruction set (VSX) is
974 enabled.
975
976 On the PowerPC, @code{__ibm128} provides access to the IBM extended
977 double format, and it is intended to be used by the library functions
978 that handle conversions if/when long double is changed to be IEEE
979 128-bit floating point.
980
981 @node Half-Precision
982 @section Half-Precision Floating Point
983 @cindex half-precision floating point
984 @cindex @code{__fp16} data type
985
986 On ARM targets, GCC supports half-precision (16-bit) floating point via
987 the @code{__fp16} type. You must enable this type explicitly
988 with the @option{-mfp16-format} command-line option in order to use it.
989
990 ARM supports two incompatible representations for half-precision
991 floating-point values. You must choose one of the representations and
992 use it consistently in your program.
993
994 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
995 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
996 There are 11 bits of significand precision, approximately 3
997 decimal digits.
998
999 Specifying @option{-mfp16-format=alternative} selects the ARM
1000 alternative format. This representation is similar to the IEEE
1001 format, but does not support infinities or NaNs. Instead, the range
1002 of exponents is extended, so that this format can represent normalized
1003 values in the range of @math{2^{-14}} to 131008.
1004
1005 The @code{__fp16} type is a storage format only. For purposes
1006 of arithmetic and other operations, @code{__fp16} values in C or C++
1007 expressions are automatically promoted to @code{float}. In addition,
1008 you cannot declare a function with a return value or parameters
1009 of type @code{__fp16}.
1010
1011 Note that conversions from @code{double} to @code{__fp16}
1012 involve an intermediate conversion to @code{float}. Because
1013 of rounding, this can sometimes produce a different result than a
1014 direct conversion.
1015
1016 ARM provides hardware support for conversions between
1017 @code{__fp16} and @code{float} values
1018 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1019 code using these hardware instructions if you compile with
1020 options to select an FPU that provides them;
1021 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1022 in addition to the @option{-mfp16-format} option to select
1023 a half-precision format.
1024
1025 Language-level support for the @code{__fp16} data type is
1026 independent of whether GCC generates code using hardware floating-point
1027 instructions. In cases where hardware support is not specified, GCC
1028 implements conversions between @code{__fp16} and @code{float} values
1029 as library calls.
1030
1031 @node Decimal Float
1032 @section Decimal Floating Types
1033 @cindex decimal floating types
1034 @cindex @code{_Decimal32} data type
1035 @cindex @code{_Decimal64} data type
1036 @cindex @code{_Decimal128} data type
1037 @cindex @code{df} integer suffix
1038 @cindex @code{dd} integer suffix
1039 @cindex @code{dl} integer suffix
1040 @cindex @code{DF} integer suffix
1041 @cindex @code{DD} integer suffix
1042 @cindex @code{DL} integer suffix
1043
1044 As an extension, GNU C supports decimal floating types as
1045 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1046 floating types in GCC will evolve as the draft technical report changes.
1047 Calling conventions for any target might also change. Not all targets
1048 support decimal floating types.
1049
1050 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1051 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1052 @code{float}, @code{double}, and @code{long double} whose radix is not
1053 specified by the C standard but is usually two.
1054
1055 Support for decimal floating types includes the arithmetic operators
1056 add, subtract, multiply, divide; unary arithmetic operators;
1057 relational operators; equality operators; and conversions to and from
1058 integer and other floating types. Use a suffix @samp{df} or
1059 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1060 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1061 @code{_Decimal128}.
1062
1063 GCC support of decimal float as specified by the draft technical report
1064 is incomplete:
1065
1066 @itemize @bullet
1067 @item
1068 When the value of a decimal floating type cannot be represented in the
1069 integer type to which it is being converted, the result is undefined
1070 rather than the result value specified by the draft technical report.
1071
1072 @item
1073 GCC does not provide the C library functionality associated with
1074 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1075 @file{wchar.h}, which must come from a separate C library implementation.
1076 Because of this the GNU C compiler does not define macro
1077 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1078 the technical report.
1079 @end itemize
1080
1081 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1082 are supported by the DWARF debug information format.
1083
1084 @node Hex Floats
1085 @section Hex Floats
1086 @cindex hex floats
1087
1088 ISO C99 supports floating-point numbers written not only in the usual
1089 decimal notation, such as @code{1.55e1}, but also numbers such as
1090 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1091 supports this in C90 mode (except in some cases when strictly
1092 conforming) and in C++. In that format the
1093 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1094 mandatory. The exponent is a decimal number that indicates the power of
1095 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1096 @tex
1097 $1 {15\over16}$,
1098 @end tex
1099 @ifnottex
1100 1 15/16,
1101 @end ifnottex
1102 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1103 is the same as @code{1.55e1}.
1104
1105 Unlike for floating-point numbers in the decimal notation the exponent
1106 is always required in the hexadecimal notation. Otherwise the compiler
1107 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1108 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1109 extension for floating-point constants of type @code{float}.
1110
1111 @node Fixed-Point
1112 @section Fixed-Point Types
1113 @cindex fixed-point types
1114 @cindex @code{_Fract} data type
1115 @cindex @code{_Accum} data type
1116 @cindex @code{_Sat} data type
1117 @cindex @code{hr} fixed-suffix
1118 @cindex @code{r} fixed-suffix
1119 @cindex @code{lr} fixed-suffix
1120 @cindex @code{llr} fixed-suffix
1121 @cindex @code{uhr} fixed-suffix
1122 @cindex @code{ur} fixed-suffix
1123 @cindex @code{ulr} fixed-suffix
1124 @cindex @code{ullr} fixed-suffix
1125 @cindex @code{hk} fixed-suffix
1126 @cindex @code{k} fixed-suffix
1127 @cindex @code{lk} fixed-suffix
1128 @cindex @code{llk} fixed-suffix
1129 @cindex @code{uhk} fixed-suffix
1130 @cindex @code{uk} fixed-suffix
1131 @cindex @code{ulk} fixed-suffix
1132 @cindex @code{ullk} fixed-suffix
1133 @cindex @code{HR} fixed-suffix
1134 @cindex @code{R} fixed-suffix
1135 @cindex @code{LR} fixed-suffix
1136 @cindex @code{LLR} fixed-suffix
1137 @cindex @code{UHR} fixed-suffix
1138 @cindex @code{UR} fixed-suffix
1139 @cindex @code{ULR} fixed-suffix
1140 @cindex @code{ULLR} fixed-suffix
1141 @cindex @code{HK} fixed-suffix
1142 @cindex @code{K} fixed-suffix
1143 @cindex @code{LK} fixed-suffix
1144 @cindex @code{LLK} fixed-suffix
1145 @cindex @code{UHK} fixed-suffix
1146 @cindex @code{UK} fixed-suffix
1147 @cindex @code{ULK} fixed-suffix
1148 @cindex @code{ULLK} fixed-suffix
1149
1150 As an extension, GNU C supports fixed-point types as
1151 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1152 types in GCC will evolve as the draft technical report changes.
1153 Calling conventions for any target might also change. Not all targets
1154 support fixed-point types.
1155
1156 The fixed-point types are
1157 @code{short _Fract},
1158 @code{_Fract},
1159 @code{long _Fract},
1160 @code{long long _Fract},
1161 @code{unsigned short _Fract},
1162 @code{unsigned _Fract},
1163 @code{unsigned long _Fract},
1164 @code{unsigned long long _Fract},
1165 @code{_Sat short _Fract},
1166 @code{_Sat _Fract},
1167 @code{_Sat long _Fract},
1168 @code{_Sat long long _Fract},
1169 @code{_Sat unsigned short _Fract},
1170 @code{_Sat unsigned _Fract},
1171 @code{_Sat unsigned long _Fract},
1172 @code{_Sat unsigned long long _Fract},
1173 @code{short _Accum},
1174 @code{_Accum},
1175 @code{long _Accum},
1176 @code{long long _Accum},
1177 @code{unsigned short _Accum},
1178 @code{unsigned _Accum},
1179 @code{unsigned long _Accum},
1180 @code{unsigned long long _Accum},
1181 @code{_Sat short _Accum},
1182 @code{_Sat _Accum},
1183 @code{_Sat long _Accum},
1184 @code{_Sat long long _Accum},
1185 @code{_Sat unsigned short _Accum},
1186 @code{_Sat unsigned _Accum},
1187 @code{_Sat unsigned long _Accum},
1188 @code{_Sat unsigned long long _Accum}.
1189
1190 Fixed-point data values contain fractional and optional integral parts.
1191 The format of fixed-point data varies and depends on the target machine.
1192
1193 Support for fixed-point types includes:
1194 @itemize @bullet
1195 @item
1196 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1197 @item
1198 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1199 @item
1200 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1201 @item
1202 binary shift operators (@code{<<}, @code{>>})
1203 @item
1204 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1205 @item
1206 equality operators (@code{==}, @code{!=})
1207 @item
1208 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1209 @code{<<=}, @code{>>=})
1210 @item
1211 conversions to and from integer, floating-point, or fixed-point types
1212 @end itemize
1213
1214 Use a suffix in a fixed-point literal constant:
1215 @itemize
1216 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1217 @code{_Sat short _Fract}
1218 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1219 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1220 @code{_Sat long _Fract}
1221 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1222 @code{_Sat long long _Fract}
1223 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1224 @code{_Sat unsigned short _Fract}
1225 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1226 @code{_Sat unsigned _Fract}
1227 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1228 @code{_Sat unsigned long _Fract}
1229 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1230 and @code{_Sat unsigned long long _Fract}
1231 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1232 @code{_Sat short _Accum}
1233 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1234 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1235 @code{_Sat long _Accum}
1236 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1237 @code{_Sat long long _Accum}
1238 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1239 @code{_Sat unsigned short _Accum}
1240 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1241 @code{_Sat unsigned _Accum}
1242 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1243 @code{_Sat unsigned long _Accum}
1244 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1245 and @code{_Sat unsigned long long _Accum}
1246 @end itemize
1247
1248 GCC support of fixed-point types as specified by the draft technical report
1249 is incomplete:
1250
1251 @itemize @bullet
1252 @item
1253 Pragmas to control overflow and rounding behaviors are not implemented.
1254 @end itemize
1255
1256 Fixed-point types are supported by the DWARF debug information format.
1257
1258 @node Named Address Spaces
1259 @section Named Address Spaces
1260 @cindex Named Address Spaces
1261
1262 As an extension, GNU C supports named address spaces as
1263 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1264 address spaces in GCC will evolve as the draft technical report
1265 changes. Calling conventions for any target might also change. At
1266 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1267 address spaces other than the generic address space.
1268
1269 Address space identifiers may be used exactly like any other C type
1270 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1271 document for more details.
1272
1273 @anchor{AVR Named Address Spaces}
1274 @subsection AVR Named Address Spaces
1275
1276 On the AVR target, there are several address spaces that can be used
1277 in order to put read-only data into the flash memory and access that
1278 data by means of the special instructions @code{LPM} or @code{ELPM}
1279 needed to read from flash.
1280
1281 Per default, any data including read-only data is located in RAM
1282 (the generic address space) so that non-generic address spaces are
1283 needed to locate read-only data in flash memory
1284 @emph{and} to generate the right instructions to access this data
1285 without using (inline) assembler code.
1286
1287 @table @code
1288 @item __flash
1289 @cindex @code{__flash} AVR Named Address Spaces
1290 The @code{__flash} qualifier locates data in the
1291 @code{.progmem.data} section. Data is read using the @code{LPM}
1292 instruction. Pointers to this address space are 16 bits wide.
1293
1294 @item __flash1
1295 @itemx __flash2
1296 @itemx __flash3
1297 @itemx __flash4
1298 @itemx __flash5
1299 @cindex @code{__flash1} AVR Named Address Spaces
1300 @cindex @code{__flash2} AVR Named Address Spaces
1301 @cindex @code{__flash3} AVR Named Address Spaces
1302 @cindex @code{__flash4} AVR Named Address Spaces
1303 @cindex @code{__flash5} AVR Named Address Spaces
1304 These are 16-bit address spaces locating data in section
1305 @code{.progmem@var{N}.data} where @var{N} refers to
1306 address space @code{__flash@var{N}}.
1307 The compiler sets the @code{RAMPZ} segment register appropriately
1308 before reading data by means of the @code{ELPM} instruction.
1309
1310 @item __memx
1311 @cindex @code{__memx} AVR Named Address Spaces
1312 This is a 24-bit address space that linearizes flash and RAM:
1313 If the high bit of the address is set, data is read from
1314 RAM using the lower two bytes as RAM address.
1315 If the high bit of the address is clear, data is read from flash
1316 with @code{RAMPZ} set according to the high byte of the address.
1317 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1318
1319 Objects in this address space are located in @code{.progmemx.data}.
1320 @end table
1321
1322 @b{Example}
1323
1324 @smallexample
1325 char my_read (const __flash char ** p)
1326 @{
1327 /* p is a pointer to RAM that points to a pointer to flash.
1328 The first indirection of p reads that flash pointer
1329 from RAM and the second indirection reads a char from this
1330 flash address. */
1331
1332 return **p;
1333 @}
1334
1335 /* Locate array[] in flash memory */
1336 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1337
1338 int i = 1;
1339
1340 int main (void)
1341 @{
1342 /* Return 17 by reading from flash memory */
1343 return array[array[i]];
1344 @}
1345 @end smallexample
1346
1347 @noindent
1348 For each named address space supported by avr-gcc there is an equally
1349 named but uppercase built-in macro defined.
1350 The purpose is to facilitate testing if respective address space
1351 support is available or not:
1352
1353 @smallexample
1354 #ifdef __FLASH
1355 const __flash int var = 1;
1356
1357 int read_var (void)
1358 @{
1359 return var;
1360 @}
1361 #else
1362 #include <avr/pgmspace.h> /* From AVR-LibC */
1363
1364 const int var PROGMEM = 1;
1365
1366 int read_var (void)
1367 @{
1368 return (int) pgm_read_word (&var);
1369 @}
1370 #endif /* __FLASH */
1371 @end smallexample
1372
1373 @noindent
1374 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1375 locates data in flash but
1376 accesses to these data read from generic address space, i.e.@:
1377 from RAM,
1378 so that you need special accessors like @code{pgm_read_byte}
1379 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1380 together with attribute @code{progmem}.
1381
1382 @noindent
1383 @b{Limitations and caveats}
1384
1385 @itemize
1386 @item
1387 Reading across the 64@tie{}KiB section boundary of
1388 the @code{__flash} or @code{__flash@var{N}} address spaces
1389 shows undefined behavior. The only address space that
1390 supports reading across the 64@tie{}KiB flash segment boundaries is
1391 @code{__memx}.
1392
1393 @item
1394 If you use one of the @code{__flash@var{N}} address spaces
1395 you must arrange your linker script to locate the
1396 @code{.progmem@var{N}.data} sections according to your needs.
1397
1398 @item
1399 Any data or pointers to the non-generic address spaces must
1400 be qualified as @code{const}, i.e.@: as read-only data.
1401 This still applies if the data in one of these address
1402 spaces like software version number or calibration lookup table are intended to
1403 be changed after load time by, say, a boot loader. In this case
1404 the right qualification is @code{const} @code{volatile} so that the compiler
1405 must not optimize away known values or insert them
1406 as immediates into operands of instructions.
1407
1408 @item
1409 The following code initializes a variable @code{pfoo}
1410 located in static storage with a 24-bit address:
1411 @smallexample
1412 extern const __memx char foo;
1413 const __memx void *pfoo = &foo;
1414 @end smallexample
1415
1416 @noindent
1417 Such code requires at least binutils 2.23, see
1418 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1419
1420 @end itemize
1421
1422 @subsection M32C Named Address Spaces
1423 @cindex @code{__far} M32C Named Address Spaces
1424
1425 On the M32C target, with the R8C and M16C CPU variants, variables
1426 qualified with @code{__far} are accessed using 32-bit addresses in
1427 order to access memory beyond the first 64@tie{}Ki bytes. If
1428 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1429 effect.
1430
1431 @subsection RL78 Named Address Spaces
1432 @cindex @code{__far} RL78 Named Address Spaces
1433
1434 On the RL78 target, variables qualified with @code{__far} are accessed
1435 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1436 addresses. Non-far variables are assumed to appear in the topmost
1437 64@tie{}KiB of the address space.
1438
1439 @subsection SPU Named Address Spaces
1440 @cindex @code{__ea} SPU Named Address Spaces
1441
1442 On the SPU target variables may be declared as
1443 belonging to another address space by qualifying the type with the
1444 @code{__ea} address space identifier:
1445
1446 @smallexample
1447 extern int __ea i;
1448 @end smallexample
1449
1450 @noindent
1451 The compiler generates special code to access the variable @code{i}.
1452 It may use runtime library
1453 support, or generate special machine instructions to access that address
1454 space.
1455
1456 @subsection x86 Named Address Spaces
1457 @cindex x86 named address spaces
1458
1459 On the x86 target, variables may be declared as being relative
1460 to the @code{%fs} or @code{%gs} segments.
1461
1462 @table @code
1463 @item __seg_fs
1464 @itemx __seg_gs
1465 @cindex @code{__seg_fs} x86 named address space
1466 @cindex @code{__seg_gs} x86 named address space
1467 The object is accessed with the respective segment override prefix.
1468
1469 The respective segment base must be set via some method specific to
1470 the operating system. Rather than require an expensive system call
1471 to retrieve the segment base, these address spaces are not considered
1472 to be subspaces of the generic (flat) address space. This means that
1473 explicit casts are required to convert pointers between these address
1474 spaces and the generic address space. In practice the application
1475 should cast to @code{uintptr_t} and apply the segment base offset
1476 that it installed previously.
1477
1478 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1479 defined when these address spaces are supported.
1480 @end table
1481
1482 @node Zero Length
1483 @section Arrays of Length Zero
1484 @cindex arrays of length zero
1485 @cindex zero-length arrays
1486 @cindex length-zero arrays
1487 @cindex flexible array members
1488
1489 Zero-length arrays are allowed in GNU C@. They are very useful as the
1490 last element of a structure that is really a header for a variable-length
1491 object:
1492
1493 @smallexample
1494 struct line @{
1495 int length;
1496 char contents[0];
1497 @};
1498
1499 struct line *thisline = (struct line *)
1500 malloc (sizeof (struct line) + this_length);
1501 thisline->length = this_length;
1502 @end smallexample
1503
1504 In ISO C90, you would have to give @code{contents} a length of 1, which
1505 means either you waste space or complicate the argument to @code{malloc}.
1506
1507 In ISO C99, you would use a @dfn{flexible array member}, which is
1508 slightly different in syntax and semantics:
1509
1510 @itemize @bullet
1511 @item
1512 Flexible array members are written as @code{contents[]} without
1513 the @code{0}.
1514
1515 @item
1516 Flexible array members have incomplete type, and so the @code{sizeof}
1517 operator may not be applied. As a quirk of the original implementation
1518 of zero-length arrays, @code{sizeof} evaluates to zero.
1519
1520 @item
1521 Flexible array members may only appear as the last member of a
1522 @code{struct} that is otherwise non-empty.
1523
1524 @item
1525 A structure containing a flexible array member, or a union containing
1526 such a structure (possibly recursively), may not be a member of a
1527 structure or an element of an array. (However, these uses are
1528 permitted by GCC as extensions.)
1529 @end itemize
1530
1531 Non-empty initialization of zero-length
1532 arrays is treated like any case where there are more initializer
1533 elements than the array holds, in that a suitable warning about ``excess
1534 elements in array'' is given, and the excess elements (all of them, in
1535 this case) are ignored.
1536
1537 GCC allows static initialization of flexible array members.
1538 This is equivalent to defining a new structure containing the original
1539 structure followed by an array of sufficient size to contain the data.
1540 E.g.@: in the following, @code{f1} is constructed as if it were declared
1541 like @code{f2}.
1542
1543 @smallexample
1544 struct f1 @{
1545 int x; int y[];
1546 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1547
1548 struct f2 @{
1549 struct f1 f1; int data[3];
1550 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1551 @end smallexample
1552
1553 @noindent
1554 The convenience of this extension is that @code{f1} has the desired
1555 type, eliminating the need to consistently refer to @code{f2.f1}.
1556
1557 This has symmetry with normal static arrays, in that an array of
1558 unknown size is also written with @code{[]}.
1559
1560 Of course, this extension only makes sense if the extra data comes at
1561 the end of a top-level object, as otherwise we would be overwriting
1562 data at subsequent offsets. To avoid undue complication and confusion
1563 with initialization of deeply nested arrays, we simply disallow any
1564 non-empty initialization except when the structure is the top-level
1565 object. For example:
1566
1567 @smallexample
1568 struct foo @{ int x; int y[]; @};
1569 struct bar @{ struct foo z; @};
1570
1571 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1572 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1573 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1574 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1575 @end smallexample
1576
1577 @node Empty Structures
1578 @section Structures with No Members
1579 @cindex empty structures
1580 @cindex zero-size structures
1581
1582 GCC permits a C structure to have no members:
1583
1584 @smallexample
1585 struct empty @{
1586 @};
1587 @end smallexample
1588
1589 The structure has size zero. In C++, empty structures are part
1590 of the language. G++ treats empty structures as if they had a single
1591 member of type @code{char}.
1592
1593 @node Variable Length
1594 @section Arrays of Variable Length
1595 @cindex variable-length arrays
1596 @cindex arrays of variable length
1597 @cindex VLAs
1598
1599 Variable-length automatic arrays are allowed in ISO C99, and as an
1600 extension GCC accepts them in C90 mode and in C++. These arrays are
1601 declared like any other automatic arrays, but with a length that is not
1602 a constant expression. The storage is allocated at the point of
1603 declaration and deallocated when the block scope containing the declaration
1604 exits. For
1605 example:
1606
1607 @smallexample
1608 FILE *
1609 concat_fopen (char *s1, char *s2, char *mode)
1610 @{
1611 char str[strlen (s1) + strlen (s2) + 1];
1612 strcpy (str, s1);
1613 strcat (str, s2);
1614 return fopen (str, mode);
1615 @}
1616 @end smallexample
1617
1618 @cindex scope of a variable length array
1619 @cindex variable-length array scope
1620 @cindex deallocating variable length arrays
1621 Jumping or breaking out of the scope of the array name deallocates the
1622 storage. Jumping into the scope is not allowed; you get an error
1623 message for it.
1624
1625 @cindex variable-length array in a structure
1626 As an extension, GCC accepts variable-length arrays as a member of
1627 a structure or a union. For example:
1628
1629 @smallexample
1630 void
1631 foo (int n)
1632 @{
1633 struct S @{ int x[n]; @};
1634 @}
1635 @end smallexample
1636
1637 @cindex @code{alloca} vs variable-length arrays
1638 You can use the function @code{alloca} to get an effect much like
1639 variable-length arrays. The function @code{alloca} is available in
1640 many other C implementations (but not in all). On the other hand,
1641 variable-length arrays are more elegant.
1642
1643 There are other differences between these two methods. Space allocated
1644 with @code{alloca} exists until the containing @emph{function} returns.
1645 The space for a variable-length array is deallocated as soon as the array
1646 name's scope ends, unless you also use @code{alloca} in this scope.
1647
1648 You can also use variable-length arrays as arguments to functions:
1649
1650 @smallexample
1651 struct entry
1652 tester (int len, char data[len][len])
1653 @{
1654 /* @r{@dots{}} */
1655 @}
1656 @end smallexample
1657
1658 The length of an array is computed once when the storage is allocated
1659 and is remembered for the scope of the array in case you access it with
1660 @code{sizeof}.
1661
1662 If you want to pass the array first and the length afterward, you can
1663 use a forward declaration in the parameter list---another GNU extension.
1664
1665 @smallexample
1666 struct entry
1667 tester (int len; char data[len][len], int len)
1668 @{
1669 /* @r{@dots{}} */
1670 @}
1671 @end smallexample
1672
1673 @cindex parameter forward declaration
1674 The @samp{int len} before the semicolon is a @dfn{parameter forward
1675 declaration}, and it serves the purpose of making the name @code{len}
1676 known when the declaration of @code{data} is parsed.
1677
1678 You can write any number of such parameter forward declarations in the
1679 parameter list. They can be separated by commas or semicolons, but the
1680 last one must end with a semicolon, which is followed by the ``real''
1681 parameter declarations. Each forward declaration must match a ``real''
1682 declaration in parameter name and data type. ISO C99 does not support
1683 parameter forward declarations.
1684
1685 @node Variadic Macros
1686 @section Macros with a Variable Number of Arguments.
1687 @cindex variable number of arguments
1688 @cindex macro with variable arguments
1689 @cindex rest argument (in macro)
1690 @cindex variadic macros
1691
1692 In the ISO C standard of 1999, a macro can be declared to accept a
1693 variable number of arguments much as a function can. The syntax for
1694 defining the macro is similar to that of a function. Here is an
1695 example:
1696
1697 @smallexample
1698 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1699 @end smallexample
1700
1701 @noindent
1702 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1703 such a macro, it represents the zero or more tokens until the closing
1704 parenthesis that ends the invocation, including any commas. This set of
1705 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1706 wherever it appears. See the CPP manual for more information.
1707
1708 GCC has long supported variadic macros, and used a different syntax that
1709 allowed you to give a name to the variable arguments just like any other
1710 argument. Here is an example:
1711
1712 @smallexample
1713 #define debug(format, args...) fprintf (stderr, format, args)
1714 @end smallexample
1715
1716 @noindent
1717 This is in all ways equivalent to the ISO C example above, but arguably
1718 more readable and descriptive.
1719
1720 GNU CPP has two further variadic macro extensions, and permits them to
1721 be used with either of the above forms of macro definition.
1722
1723 In standard C, you are not allowed to leave the variable argument out
1724 entirely; but you are allowed to pass an empty argument. For example,
1725 this invocation is invalid in ISO C, because there is no comma after
1726 the string:
1727
1728 @smallexample
1729 debug ("A message")
1730 @end smallexample
1731
1732 GNU CPP permits you to completely omit the variable arguments in this
1733 way. In the above examples, the compiler would complain, though since
1734 the expansion of the macro still has the extra comma after the format
1735 string.
1736
1737 To help solve this problem, CPP behaves specially for variable arguments
1738 used with the token paste operator, @samp{##}. If instead you write
1739
1740 @smallexample
1741 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1742 @end smallexample
1743
1744 @noindent
1745 and if the variable arguments are omitted or empty, the @samp{##}
1746 operator causes the preprocessor to remove the comma before it. If you
1747 do provide some variable arguments in your macro invocation, GNU CPP
1748 does not complain about the paste operation and instead places the
1749 variable arguments after the comma. Just like any other pasted macro
1750 argument, these arguments are not macro expanded.
1751
1752 @node Escaped Newlines
1753 @section Slightly Looser Rules for Escaped Newlines
1754 @cindex escaped newlines
1755 @cindex newlines (escaped)
1756
1757 The preprocessor treatment of escaped newlines is more relaxed
1758 than that specified by the C90 standard, which requires the newline
1759 to immediately follow a backslash.
1760 GCC's implementation allows whitespace in the form
1761 of spaces, horizontal and vertical tabs, and form feeds between the
1762 backslash and the subsequent newline. The preprocessor issues a
1763 warning, but treats it as a valid escaped newline and combines the two
1764 lines to form a single logical line. This works within comments and
1765 tokens, as well as between tokens. Comments are @emph{not} treated as
1766 whitespace for the purposes of this relaxation, since they have not
1767 yet been replaced with spaces.
1768
1769 @node Subscripting
1770 @section Non-Lvalue Arrays May Have Subscripts
1771 @cindex subscripting
1772 @cindex arrays, non-lvalue
1773
1774 @cindex subscripting and function values
1775 In ISO C99, arrays that are not lvalues still decay to pointers, and
1776 may be subscripted, although they may not be modified or used after
1777 the next sequence point and the unary @samp{&} operator may not be
1778 applied to them. As an extension, GNU C allows such arrays to be
1779 subscripted in C90 mode, though otherwise they do not decay to
1780 pointers outside C99 mode. For example,
1781 this is valid in GNU C though not valid in C90:
1782
1783 @smallexample
1784 @group
1785 struct foo @{int a[4];@};
1786
1787 struct foo f();
1788
1789 bar (int index)
1790 @{
1791 return f().a[index];
1792 @}
1793 @end group
1794 @end smallexample
1795
1796 @node Pointer Arith
1797 @section Arithmetic on @code{void}- and Function-Pointers
1798 @cindex void pointers, arithmetic
1799 @cindex void, size of pointer to
1800 @cindex function pointers, arithmetic
1801 @cindex function, size of pointer to
1802
1803 In GNU C, addition and subtraction operations are supported on pointers to
1804 @code{void} and on pointers to functions. This is done by treating the
1805 size of a @code{void} or of a function as 1.
1806
1807 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1808 and on function types, and returns 1.
1809
1810 @opindex Wpointer-arith
1811 The option @option{-Wpointer-arith} requests a warning if these extensions
1812 are used.
1813
1814 @node Pointers to Arrays
1815 @section Pointers to Arrays with Qualifiers Work as Expected
1816 @cindex pointers to arrays
1817 @cindex const qualifier
1818
1819 In GNU C, pointers to arrays with qualifiers work similar to pointers
1820 to other qualified types. For example, a value of type @code{int (*)[5]}
1821 can be used to initialize a variable of type @code{const int (*)[5]}.
1822 These types are incompatible in ISO C because the @code{const} qualifier
1823 is formally attached to the element type of the array and not the
1824 array itself.
1825
1826 @smallexample
1827 extern void
1828 transpose (int N, int M, double out[M][N], const double in[N][M]);
1829 double x[3][2];
1830 double y[2][3];
1831 @r{@dots{}}
1832 transpose(3, 2, y, x);
1833 @end smallexample
1834
1835 @node Initializers
1836 @section Non-Constant Initializers
1837 @cindex initializers, non-constant
1838 @cindex non-constant initializers
1839
1840 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1841 automatic variable are not required to be constant expressions in GNU C@.
1842 Here is an example of an initializer with run-time varying elements:
1843
1844 @smallexample
1845 foo (float f, float g)
1846 @{
1847 float beat_freqs[2] = @{ f-g, f+g @};
1848 /* @r{@dots{}} */
1849 @}
1850 @end smallexample
1851
1852 @node Compound Literals
1853 @section Compound Literals
1854 @cindex constructor expressions
1855 @cindex initializations in expressions
1856 @cindex structures, constructor expression
1857 @cindex expressions, constructor
1858 @cindex compound literals
1859 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1860
1861 ISO C99 supports compound literals. A compound literal looks like
1862 a cast containing an initializer. Its value is an object of the
1863 type specified in the cast, containing the elements specified in
1864 the initializer; it is an lvalue. As an extension, GCC supports
1865 compound literals in C90 mode and in C++, though the semantics are
1866 somewhat different in C++.
1867
1868 Usually, the specified type is a structure. Assume that
1869 @code{struct foo} and @code{structure} are declared as shown:
1870
1871 @smallexample
1872 struct foo @{int a; char b[2];@} structure;
1873 @end smallexample
1874
1875 @noindent
1876 Here is an example of constructing a @code{struct foo} with a compound literal:
1877
1878 @smallexample
1879 structure = ((struct foo) @{x + y, 'a', 0@});
1880 @end smallexample
1881
1882 @noindent
1883 This is equivalent to writing the following:
1884
1885 @smallexample
1886 @{
1887 struct foo temp = @{x + y, 'a', 0@};
1888 structure = temp;
1889 @}
1890 @end smallexample
1891
1892 You can also construct an array, though this is dangerous in C++, as
1893 explained below. If all the elements of the compound literal are
1894 (made up of) simple constant expressions, suitable for use in
1895 initializers of objects of static storage duration, then the compound
1896 literal can be coerced to a pointer to its first element and used in
1897 such an initializer, as shown here:
1898
1899 @smallexample
1900 char **foo = (char *[]) @{ "x", "y", "z" @};
1901 @end smallexample
1902
1903 Compound literals for scalar types and union types are
1904 also allowed, but then the compound literal is equivalent
1905 to a cast.
1906
1907 As a GNU extension, GCC allows initialization of objects with static storage
1908 duration by compound literals (which is not possible in ISO C99, because
1909 the initializer is not a constant).
1910 It is handled as if the object is initialized only with the bracket
1911 enclosed list if the types of the compound literal and the object match.
1912 The initializer list of the compound literal must be constant.
1913 If the object being initialized has array type of unknown size, the size is
1914 determined by compound literal size.
1915
1916 @smallexample
1917 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1918 static int y[] = (int []) @{1, 2, 3@};
1919 static int z[] = (int [3]) @{1@};
1920 @end smallexample
1921
1922 @noindent
1923 The above lines are equivalent to the following:
1924 @smallexample
1925 static struct foo x = @{1, 'a', 'b'@};
1926 static int y[] = @{1, 2, 3@};
1927 static int z[] = @{1, 0, 0@};
1928 @end smallexample
1929
1930 In C, a compound literal designates an unnamed object with static or
1931 automatic storage duration. In C++, a compound literal designates a
1932 temporary object, which only lives until the end of its
1933 full-expression. As a result, well-defined C code that takes the
1934 address of a subobject of a compound literal can be undefined in C++,
1935 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1936 For instance, if the array compound literal example above appeared
1937 inside a function, any subsequent use of @samp{foo} in C++ has
1938 undefined behavior because the lifetime of the array ends after the
1939 declaration of @samp{foo}.
1940
1941 As an optimization, the C++ compiler sometimes gives array compound
1942 literals longer lifetimes: when the array either appears outside a
1943 function or has const-qualified type. If @samp{foo} and its
1944 initializer had elements of @samp{char *const} type rather than
1945 @samp{char *}, or if @samp{foo} were a global variable, the array
1946 would have static storage duration. But it is probably safest just to
1947 avoid the use of array compound literals in code compiled as C++.
1948
1949 @node Designated Inits
1950 @section Designated Initializers
1951 @cindex initializers with labeled elements
1952 @cindex labeled elements in initializers
1953 @cindex case labels in initializers
1954 @cindex designated initializers
1955
1956 Standard C90 requires the elements of an initializer to appear in a fixed
1957 order, the same as the order of the elements in the array or structure
1958 being initialized.
1959
1960 In ISO C99 you can give the elements in any order, specifying the array
1961 indices or structure field names they apply to, and GNU C allows this as
1962 an extension in C90 mode as well. This extension is not
1963 implemented in GNU C++.
1964
1965 To specify an array index, write
1966 @samp{[@var{index}] =} before the element value. For example,
1967
1968 @smallexample
1969 int a[6] = @{ [4] = 29, [2] = 15 @};
1970 @end smallexample
1971
1972 @noindent
1973 is equivalent to
1974
1975 @smallexample
1976 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1977 @end smallexample
1978
1979 @noindent
1980 The index values must be constant expressions, even if the array being
1981 initialized is automatic.
1982
1983 An alternative syntax for this that has been obsolete since GCC 2.5 but
1984 GCC still accepts is to write @samp{[@var{index}]} before the element
1985 value, with no @samp{=}.
1986
1987 To initialize a range of elements to the same value, write
1988 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1989 extension. For example,
1990
1991 @smallexample
1992 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1993 @end smallexample
1994
1995 @noindent
1996 If the value in it has side-effects, the side-effects happen only once,
1997 not for each initialized field by the range initializer.
1998
1999 @noindent
2000 Note that the length of the array is the highest value specified
2001 plus one.
2002
2003 In a structure initializer, specify the name of a field to initialize
2004 with @samp{.@var{fieldname} =} before the element value. For example,
2005 given the following structure,
2006
2007 @smallexample
2008 struct point @{ int x, y; @};
2009 @end smallexample
2010
2011 @noindent
2012 the following initialization
2013
2014 @smallexample
2015 struct point p = @{ .y = yvalue, .x = xvalue @};
2016 @end smallexample
2017
2018 @noindent
2019 is equivalent to
2020
2021 @smallexample
2022 struct point p = @{ xvalue, yvalue @};
2023 @end smallexample
2024
2025 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2026 @samp{@var{fieldname}:}, as shown here:
2027
2028 @smallexample
2029 struct point p = @{ y: yvalue, x: xvalue @};
2030 @end smallexample
2031
2032 Omitted field members are implicitly initialized the same as objects
2033 that have static storage duration.
2034
2035 @cindex designators
2036 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2037 @dfn{designator}. You can also use a designator (or the obsolete colon
2038 syntax) when initializing a union, to specify which element of the union
2039 should be used. For example,
2040
2041 @smallexample
2042 union foo @{ int i; double d; @};
2043
2044 union foo f = @{ .d = 4 @};
2045 @end smallexample
2046
2047 @noindent
2048 converts 4 to a @code{double} to store it in the union using
2049 the second element. By contrast, casting 4 to type @code{union foo}
2050 stores it into the union as the integer @code{i}, since it is
2051 an integer. (@xref{Cast to Union}.)
2052
2053 You can combine this technique of naming elements with ordinary C
2054 initialization of successive elements. Each initializer element that
2055 does not have a designator applies to the next consecutive element of the
2056 array or structure. For example,
2057
2058 @smallexample
2059 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2060 @end smallexample
2061
2062 @noindent
2063 is equivalent to
2064
2065 @smallexample
2066 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2067 @end smallexample
2068
2069 Labeling the elements of an array initializer is especially useful
2070 when the indices are characters or belong to an @code{enum} type.
2071 For example:
2072
2073 @smallexample
2074 int whitespace[256]
2075 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2076 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2077 @end smallexample
2078
2079 @cindex designator lists
2080 You can also write a series of @samp{.@var{fieldname}} and
2081 @samp{[@var{index}]} designators before an @samp{=} to specify a
2082 nested subobject to initialize; the list is taken relative to the
2083 subobject corresponding to the closest surrounding brace pair. For
2084 example, with the @samp{struct point} declaration above:
2085
2086 @smallexample
2087 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2088 @end smallexample
2089
2090 @noindent
2091 If the same field is initialized multiple times, it has the value from
2092 the last initialization. If any such overridden initialization has
2093 side-effect, it is unspecified whether the side-effect happens or not.
2094 Currently, GCC discards them and issues a warning.
2095
2096 @node Case Ranges
2097 @section Case Ranges
2098 @cindex case ranges
2099 @cindex ranges in case statements
2100
2101 You can specify a range of consecutive values in a single @code{case} label,
2102 like this:
2103
2104 @smallexample
2105 case @var{low} ... @var{high}:
2106 @end smallexample
2107
2108 @noindent
2109 This has the same effect as the proper number of individual @code{case}
2110 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2111
2112 This feature is especially useful for ranges of ASCII character codes:
2113
2114 @smallexample
2115 case 'A' ... 'Z':
2116 @end smallexample
2117
2118 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2119 it may be parsed wrong when you use it with integer values. For example,
2120 write this:
2121
2122 @smallexample
2123 case 1 ... 5:
2124 @end smallexample
2125
2126 @noindent
2127 rather than this:
2128
2129 @smallexample
2130 case 1...5:
2131 @end smallexample
2132
2133 @node Cast to Union
2134 @section Cast to a Union Type
2135 @cindex cast to a union
2136 @cindex union, casting to a
2137
2138 A cast to union type is similar to other casts, except that the type
2139 specified is a union type. You can specify the type either with
2140 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2141 a constructor, not a cast, and hence does not yield an lvalue like
2142 normal casts. (@xref{Compound Literals}.)
2143
2144 The types that may be cast to the union type are those of the members
2145 of the union. Thus, given the following union and variables:
2146
2147 @smallexample
2148 union foo @{ int i; double d; @};
2149 int x;
2150 double y;
2151 @end smallexample
2152
2153 @noindent
2154 both @code{x} and @code{y} can be cast to type @code{union foo}.
2155
2156 Using the cast as the right-hand side of an assignment to a variable of
2157 union type is equivalent to storing in a member of the union:
2158
2159 @smallexample
2160 union foo u;
2161 /* @r{@dots{}} */
2162 u = (union foo) x @equiv{} u.i = x
2163 u = (union foo) y @equiv{} u.d = y
2164 @end smallexample
2165
2166 You can also use the union cast as a function argument:
2167
2168 @smallexample
2169 void hack (union foo);
2170 /* @r{@dots{}} */
2171 hack ((union foo) x);
2172 @end smallexample
2173
2174 @node Mixed Declarations
2175 @section Mixed Declarations and Code
2176 @cindex mixed declarations and code
2177 @cindex declarations, mixed with code
2178 @cindex code, mixed with declarations
2179
2180 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2181 within compound statements. As an extension, GNU C also allows this in
2182 C90 mode. For example, you could do:
2183
2184 @smallexample
2185 int i;
2186 /* @r{@dots{}} */
2187 i++;
2188 int j = i + 2;
2189 @end smallexample
2190
2191 Each identifier is visible from where it is declared until the end of
2192 the enclosing block.
2193
2194 @node Function Attributes
2195 @section Declaring Attributes of Functions
2196 @cindex function attributes
2197 @cindex declaring attributes of functions
2198 @cindex @code{volatile} applied to function
2199 @cindex @code{const} applied to function
2200
2201 In GNU C, you can use function attributes to declare certain things
2202 about functions called in your program which help the compiler
2203 optimize calls and check your code more carefully. For example, you
2204 can use attributes to declare that a function never returns
2205 (@code{noreturn}), returns a value depending only on its arguments
2206 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2207
2208 You can also use attributes to control memory placement, code
2209 generation options or call/return conventions within the function
2210 being annotated. Many of these attributes are target-specific. For
2211 example, many targets support attributes for defining interrupt
2212 handler functions, which typically must follow special register usage
2213 and return conventions.
2214
2215 Function attributes are introduced by the @code{__attribute__} keyword
2216 on a declaration, followed by an attribute specification inside double
2217 parentheses. You can specify multiple attributes in a declaration by
2218 separating them by commas within the double parentheses or by
2219 immediately following an attribute declaration with another attribute
2220 declaration. @xref{Attribute Syntax}, for the exact rules on
2221 attribute syntax and placement.
2222
2223 GCC also supports attributes on
2224 variable declarations (@pxref{Variable Attributes}),
2225 labels (@pxref{Label Attributes}),
2226 enumerators (@pxref{Enumerator Attributes}),
2227 and types (@pxref{Type Attributes}).
2228
2229 There is some overlap between the purposes of attributes and pragmas
2230 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2231 found convenient to use @code{__attribute__} to achieve a natural
2232 attachment of attributes to their corresponding declarations, whereas
2233 @code{#pragma} is of use for compatibility with other compilers
2234 or constructs that do not naturally form part of the grammar.
2235
2236 In addition to the attributes documented here,
2237 GCC plugins may provide their own attributes.
2238
2239 @menu
2240 * Common Function Attributes::
2241 * AArch64 Function Attributes::
2242 * ARC Function Attributes::
2243 * ARM Function Attributes::
2244 * AVR Function Attributes::
2245 * Blackfin Function Attributes::
2246 * CR16 Function Attributes::
2247 * Epiphany Function Attributes::
2248 * H8/300 Function Attributes::
2249 * IA-64 Function Attributes::
2250 * M32C Function Attributes::
2251 * M32R/D Function Attributes::
2252 * m68k Function Attributes::
2253 * MCORE Function Attributes::
2254 * MeP Function Attributes::
2255 * MicroBlaze Function Attributes::
2256 * Microsoft Windows Function Attributes::
2257 * MIPS Function Attributes::
2258 * MSP430 Function Attributes::
2259 * NDS32 Function Attributes::
2260 * Nios II Function Attributes::
2261 * Nvidia PTX Function Attributes::
2262 * PowerPC Function Attributes::
2263 * RL78 Function Attributes::
2264 * RX Function Attributes::
2265 * S/390 Function Attributes::
2266 * SH Function Attributes::
2267 * SPU Function Attributes::
2268 * Symbian OS Function Attributes::
2269 * V850 Function Attributes::
2270 * Visium Function Attributes::
2271 * x86 Function Attributes::
2272 * Xstormy16 Function Attributes::
2273 @end menu
2274
2275 @node Common Function Attributes
2276 @subsection Common Function Attributes
2277
2278 The following attributes are supported on most targets.
2279
2280 @table @code
2281 @c Keep this table alphabetized by attribute name. Treat _ as space.
2282
2283 @item alias ("@var{target}")
2284 @cindex @code{alias} function attribute
2285 The @code{alias} attribute causes the declaration to be emitted as an
2286 alias for another symbol, which must be specified. For instance,
2287
2288 @smallexample
2289 void __f () @{ /* @r{Do something.} */; @}
2290 void f () __attribute__ ((weak, alias ("__f")));
2291 @end smallexample
2292
2293 @noindent
2294 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2295 mangled name for the target must be used. It is an error if @samp{__f}
2296 is not defined in the same translation unit.
2297
2298 This attribute requires assembler and object file support,
2299 and may not be available on all targets.
2300
2301 @item aligned (@var{alignment})
2302 @cindex @code{aligned} function attribute
2303 This attribute specifies a minimum alignment for the function,
2304 measured in bytes.
2305
2306 You cannot use this attribute to decrease the alignment of a function,
2307 only to increase it. However, when you explicitly specify a function
2308 alignment this overrides the effect of the
2309 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2310 function.
2311
2312 Note that the effectiveness of @code{aligned} attributes may be
2313 limited by inherent limitations in your linker. On many systems, the
2314 linker is only able to arrange for functions to be aligned up to a
2315 certain maximum alignment. (For some linkers, the maximum supported
2316 alignment may be very very small.) See your linker documentation for
2317 further information.
2318
2319 The @code{aligned} attribute can also be used for variables and fields
2320 (@pxref{Variable Attributes}.)
2321
2322 @item alloc_align
2323 @cindex @code{alloc_align} function attribute
2324 The @code{alloc_align} attribute is used to tell the compiler that the
2325 function return value points to memory, where the returned pointer minimum
2326 alignment is given by one of the functions parameters. GCC uses this
2327 information to improve pointer alignment analysis.
2328
2329 The function parameter denoting the allocated alignment is specified by
2330 one integer argument, whose number is the argument of the attribute.
2331 Argument numbering starts at one.
2332
2333 For instance,
2334
2335 @smallexample
2336 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2337 @end smallexample
2338
2339 @noindent
2340 declares that @code{my_memalign} returns memory with minimum alignment
2341 given by parameter 1.
2342
2343 @item alloc_size
2344 @cindex @code{alloc_size} function attribute
2345 The @code{alloc_size} attribute is used to tell the compiler that the
2346 function return value points to memory, where the size is given by
2347 one or two of the functions parameters. GCC uses this
2348 information to improve the correctness of @code{__builtin_object_size}.
2349
2350 The function parameter(s) denoting the allocated size are specified by
2351 one or two integer arguments supplied to the attribute. The allocated size
2352 is either the value of the single function argument specified or the product
2353 of the two function arguments specified. Argument numbering starts at
2354 one.
2355
2356 For instance,
2357
2358 @smallexample
2359 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2360 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2361 @end smallexample
2362
2363 @noindent
2364 declares that @code{my_calloc} returns memory of the size given by
2365 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2366 of the size given by parameter 2.
2367
2368 @item always_inline
2369 @cindex @code{always_inline} function attribute
2370 Generally, functions are not inlined unless optimization is specified.
2371 For functions declared inline, this attribute inlines the function
2372 independent of any restrictions that otherwise apply to inlining.
2373 Failure to inline such a function is diagnosed as an error.
2374 Note that if such a function is called indirectly the compiler may
2375 or may not inline it depending on optimization level and a failure
2376 to inline an indirect call may or may not be diagnosed.
2377
2378 @item artificial
2379 @cindex @code{artificial} function attribute
2380 This attribute is useful for small inline wrappers that if possible
2381 should appear during debugging as a unit. Depending on the debug
2382 info format it either means marking the function as artificial
2383 or using the caller location for all instructions within the inlined
2384 body.
2385
2386 @item assume_aligned
2387 @cindex @code{assume_aligned} function attribute
2388 The @code{assume_aligned} attribute is used to tell the compiler that the
2389 function return value points to memory, where the returned pointer minimum
2390 alignment is given by the first argument.
2391 If the attribute has two arguments, the second argument is misalignment offset.
2392
2393 For instance
2394
2395 @smallexample
2396 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2397 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2398 @end smallexample
2399
2400 @noindent
2401 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2402 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2403 to 8.
2404
2405 @item bnd_instrument
2406 @cindex @code{bnd_instrument} function attribute
2407 The @code{bnd_instrument} attribute on functions is used to inform the
2408 compiler that the function should be instrumented when compiled
2409 with the @option{-fchkp-instrument-marked-only} option.
2410
2411 @item bnd_legacy
2412 @cindex @code{bnd_legacy} function attribute
2413 @cindex Pointer Bounds Checker attributes
2414 The @code{bnd_legacy} attribute on functions is used to inform the
2415 compiler that the function should not be instrumented when compiled
2416 with the @option{-fcheck-pointer-bounds} option.
2417
2418 @item cold
2419 @cindex @code{cold} function attribute
2420 The @code{cold} attribute on functions is used to inform the compiler that
2421 the function is unlikely to be executed. The function is optimized for
2422 size rather than speed and on many targets it is placed into a special
2423 subsection of the text section so all cold functions appear close together,
2424 improving code locality of non-cold parts of program. The paths leading
2425 to calls of cold functions within code are marked as unlikely by the branch
2426 prediction mechanism. It is thus useful to mark functions used to handle
2427 unlikely conditions, such as @code{perror}, as cold to improve optimization
2428 of hot functions that do call marked functions in rare occasions.
2429
2430 When profile feedback is available, via @option{-fprofile-use}, cold functions
2431 are automatically detected and this attribute is ignored.
2432
2433 @item const
2434 @cindex @code{const} function attribute
2435 @cindex functions that have no side effects
2436 Many functions do not examine any values except their arguments, and
2437 have no effects except the return value. Basically this is just slightly
2438 more strict class than the @code{pure} attribute below, since function is not
2439 allowed to read global memory.
2440
2441 @cindex pointer arguments
2442 Note that a function that has pointer arguments and examines the data
2443 pointed to must @emph{not} be declared @code{const}. Likewise, a
2444 function that calls a non-@code{const} function usually must not be
2445 @code{const}. It does not make sense for a @code{const} function to
2446 return @code{void}.
2447
2448 @item constructor
2449 @itemx destructor
2450 @itemx constructor (@var{priority})
2451 @itemx destructor (@var{priority})
2452 @cindex @code{constructor} function attribute
2453 @cindex @code{destructor} function attribute
2454 The @code{constructor} attribute causes the function to be called
2455 automatically before execution enters @code{main ()}. Similarly, the
2456 @code{destructor} attribute causes the function to be called
2457 automatically after @code{main ()} completes or @code{exit ()} is
2458 called. Functions with these attributes are useful for
2459 initializing data that is used implicitly during the execution of
2460 the program.
2461
2462 You may provide an optional integer priority to control the order in
2463 which constructor and destructor functions are run. A constructor
2464 with a smaller priority number runs before a constructor with a larger
2465 priority number; the opposite relationship holds for destructors. So,
2466 if you have a constructor that allocates a resource and a destructor
2467 that deallocates the same resource, both functions typically have the
2468 same priority. The priorities for constructor and destructor
2469 functions are the same as those specified for namespace-scope C++
2470 objects (@pxref{C++ Attributes}).
2471
2472 These attributes are not currently implemented for Objective-C@.
2473
2474 @item deprecated
2475 @itemx deprecated (@var{msg})
2476 @cindex @code{deprecated} function attribute
2477 The @code{deprecated} attribute results in a warning if the function
2478 is used anywhere in the source file. This is useful when identifying
2479 functions that are expected to be removed in a future version of a
2480 program. The warning also includes the location of the declaration
2481 of the deprecated function, to enable users to easily find further
2482 information about why the function is deprecated, or what they should
2483 do instead. Note that the warnings only occurs for uses:
2484
2485 @smallexample
2486 int old_fn () __attribute__ ((deprecated));
2487 int old_fn ();
2488 int (*fn_ptr)() = old_fn;
2489 @end smallexample
2490
2491 @noindent
2492 results in a warning on line 3 but not line 2. The optional @var{msg}
2493 argument, which must be a string, is printed in the warning if
2494 present.
2495
2496 The @code{deprecated} attribute can also be used for variables and
2497 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2498
2499 @item error ("@var{message}")
2500 @itemx warning ("@var{message}")
2501 @cindex @code{error} function attribute
2502 @cindex @code{warning} function attribute
2503 If the @code{error} or @code{warning} attribute
2504 is used on a function declaration and a call to such a function
2505 is not eliminated through dead code elimination or other optimizations,
2506 an error or warning (respectively) that includes @var{message} is diagnosed.
2507 This is useful
2508 for compile-time checking, especially together with @code{__builtin_constant_p}
2509 and inline functions where checking the inline function arguments is not
2510 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2511
2512 While it is possible to leave the function undefined and thus invoke
2513 a link failure (to define the function with
2514 a message in @code{.gnu.warning*} section),
2515 when using these attributes the problem is diagnosed
2516 earlier and with exact location of the call even in presence of inline
2517 functions or when not emitting debugging information.
2518
2519 @item externally_visible
2520 @cindex @code{externally_visible} function attribute
2521 This attribute, attached to a global variable or function, nullifies
2522 the effect of the @option{-fwhole-program} command-line option, so the
2523 object remains visible outside the current compilation unit.
2524
2525 If @option{-fwhole-program} is used together with @option{-flto} and
2526 @command{gold} is used as the linker plugin,
2527 @code{externally_visible} attributes are automatically added to functions
2528 (not variable yet due to a current @command{gold} issue)
2529 that are accessed outside of LTO objects according to resolution file
2530 produced by @command{gold}.
2531 For other linkers that cannot generate resolution file,
2532 explicit @code{externally_visible} attributes are still necessary.
2533
2534 @item flatten
2535 @cindex @code{flatten} function attribute
2536 Generally, inlining into a function is limited. For a function marked with
2537 this attribute, every call inside this function is inlined, if possible.
2538 Whether the function itself is considered for inlining depends on its size and
2539 the current inlining parameters.
2540
2541 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2542 @cindex @code{format} function attribute
2543 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2544 @opindex Wformat
2545 The @code{format} attribute specifies that a function takes @code{printf},
2546 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2547 should be type-checked against a format string. For example, the
2548 declaration:
2549
2550 @smallexample
2551 extern int
2552 my_printf (void *my_object, const char *my_format, ...)
2553 __attribute__ ((format (printf, 2, 3)));
2554 @end smallexample
2555
2556 @noindent
2557 causes the compiler to check the arguments in calls to @code{my_printf}
2558 for consistency with the @code{printf} style format string argument
2559 @code{my_format}.
2560
2561 The parameter @var{archetype} determines how the format string is
2562 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2563 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2564 @code{strfmon}. (You can also use @code{__printf__},
2565 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2566 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2567 @code{ms_strftime} are also present.
2568 @var{archetype} values such as @code{printf} refer to the formats accepted
2569 by the system's C runtime library,
2570 while values prefixed with @samp{gnu_} always refer
2571 to the formats accepted by the GNU C Library. On Microsoft Windows
2572 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2573 @file{msvcrt.dll} library.
2574 The parameter @var{string-index}
2575 specifies which argument is the format string argument (starting
2576 from 1), while @var{first-to-check} is the number of the first
2577 argument to check against the format string. For functions
2578 where the arguments are not available to be checked (such as
2579 @code{vprintf}), specify the third parameter as zero. In this case the
2580 compiler only checks the format string for consistency. For
2581 @code{strftime} formats, the third parameter is required to be zero.
2582 Since non-static C++ methods have an implicit @code{this} argument, the
2583 arguments of such methods should be counted from two, not one, when
2584 giving values for @var{string-index} and @var{first-to-check}.
2585
2586 In the example above, the format string (@code{my_format}) is the second
2587 argument of the function @code{my_print}, and the arguments to check
2588 start with the third argument, so the correct parameters for the format
2589 attribute are 2 and 3.
2590
2591 @opindex ffreestanding
2592 @opindex fno-builtin
2593 The @code{format} attribute allows you to identify your own functions
2594 that take format strings as arguments, so that GCC can check the
2595 calls to these functions for errors. The compiler always (unless
2596 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2597 for the standard library functions @code{printf}, @code{fprintf},
2598 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2599 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2600 warnings are requested (using @option{-Wformat}), so there is no need to
2601 modify the header file @file{stdio.h}. In C99 mode, the functions
2602 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2603 @code{vsscanf} are also checked. Except in strictly conforming C
2604 standard modes, the X/Open function @code{strfmon} is also checked as
2605 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2606 @xref{C Dialect Options,,Options Controlling C Dialect}.
2607
2608 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2609 recognized in the same context. Declarations including these format attributes
2610 are parsed for correct syntax, however the result of checking of such format
2611 strings is not yet defined, and is not carried out by this version of the
2612 compiler.
2613
2614 The target may also provide additional types of format checks.
2615 @xref{Target Format Checks,,Format Checks Specific to Particular
2616 Target Machines}.
2617
2618 @item format_arg (@var{string-index})
2619 @cindex @code{format_arg} function attribute
2620 @opindex Wformat-nonliteral
2621 The @code{format_arg} attribute specifies that a function takes a format
2622 string for a @code{printf}, @code{scanf}, @code{strftime} or
2623 @code{strfmon} style function and modifies it (for example, to translate
2624 it into another language), so the result can be passed to a
2625 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2626 function (with the remaining arguments to the format function the same
2627 as they would have been for the unmodified string). For example, the
2628 declaration:
2629
2630 @smallexample
2631 extern char *
2632 my_dgettext (char *my_domain, const char *my_format)
2633 __attribute__ ((format_arg (2)));
2634 @end smallexample
2635
2636 @noindent
2637 causes the compiler to check the arguments in calls to a @code{printf},
2638 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2639 format string argument is a call to the @code{my_dgettext} function, for
2640 consistency with the format string argument @code{my_format}. If the
2641 @code{format_arg} attribute had not been specified, all the compiler
2642 could tell in such calls to format functions would be that the format
2643 string argument is not constant; this would generate a warning when
2644 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2645 without the attribute.
2646
2647 The parameter @var{string-index} specifies which argument is the format
2648 string argument (starting from one). Since non-static C++ methods have
2649 an implicit @code{this} argument, the arguments of such methods should
2650 be counted from two.
2651
2652 The @code{format_arg} attribute allows you to identify your own
2653 functions that modify format strings, so that GCC can check the
2654 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2655 type function whose operands are a call to one of your own function.
2656 The compiler always treats @code{gettext}, @code{dgettext}, and
2657 @code{dcgettext} in this manner except when strict ISO C support is
2658 requested by @option{-ansi} or an appropriate @option{-std} option, or
2659 @option{-ffreestanding} or @option{-fno-builtin}
2660 is used. @xref{C Dialect Options,,Options
2661 Controlling C Dialect}.
2662
2663 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2664 @code{NSString} reference for compatibility with the @code{format} attribute
2665 above.
2666
2667 The target may also allow additional types in @code{format-arg} attributes.
2668 @xref{Target Format Checks,,Format Checks Specific to Particular
2669 Target Machines}.
2670
2671 @item gnu_inline
2672 @cindex @code{gnu_inline} function attribute
2673 This attribute should be used with a function that is also declared
2674 with the @code{inline} keyword. It directs GCC to treat the function
2675 as if it were defined in gnu90 mode even when compiling in C99 or
2676 gnu99 mode.
2677
2678 If the function is declared @code{extern}, then this definition of the
2679 function is used only for inlining. In no case is the function
2680 compiled as a standalone function, not even if you take its address
2681 explicitly. Such an address becomes an external reference, as if you
2682 had only declared the function, and had not defined it. This has
2683 almost the effect of a macro. The way to use this is to put a
2684 function definition in a header file with this attribute, and put
2685 another copy of the function, without @code{extern}, in a library
2686 file. The definition in the header file causes most calls to the
2687 function to be inlined. If any uses of the function remain, they
2688 refer to the single copy in the library. Note that the two
2689 definitions of the functions need not be precisely the same, although
2690 if they do not have the same effect your program may behave oddly.
2691
2692 In C, if the function is neither @code{extern} nor @code{static}, then
2693 the function is compiled as a standalone function, as well as being
2694 inlined where possible.
2695
2696 This is how GCC traditionally handled functions declared
2697 @code{inline}. Since ISO C99 specifies a different semantics for
2698 @code{inline}, this function attribute is provided as a transition
2699 measure and as a useful feature in its own right. This attribute is
2700 available in GCC 4.1.3 and later. It is available if either of the
2701 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2702 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2703 Function is As Fast As a Macro}.
2704
2705 In C++, this attribute does not depend on @code{extern} in any way,
2706 but it still requires the @code{inline} keyword to enable its special
2707 behavior.
2708
2709 @item hot
2710 @cindex @code{hot} function attribute
2711 The @code{hot} attribute on a function is used to inform the compiler that
2712 the function is a hot spot of the compiled program. The function is
2713 optimized more aggressively and on many targets it is placed into a special
2714 subsection of the text section so all hot functions appear close together,
2715 improving locality.
2716
2717 When profile feedback is available, via @option{-fprofile-use}, hot functions
2718 are automatically detected and this attribute is ignored.
2719
2720 @item ifunc ("@var{resolver}")
2721 @cindex @code{ifunc} function attribute
2722 @cindex indirect functions
2723 @cindex functions that are dynamically resolved
2724 The @code{ifunc} attribute is used to mark a function as an indirect
2725 function using the STT_GNU_IFUNC symbol type extension to the ELF
2726 standard. This allows the resolution of the symbol value to be
2727 determined dynamically at load time, and an optimized version of the
2728 routine can be selected for the particular processor or other system
2729 characteristics determined then. To use this attribute, first define
2730 the implementation functions available, and a resolver function that
2731 returns a pointer to the selected implementation function. The
2732 implementation functions' declarations must match the API of the
2733 function being implemented, the resolver's declaration is be a
2734 function returning pointer to void function returning void:
2735
2736 @smallexample
2737 void *my_memcpy (void *dst, const void *src, size_t len)
2738 @{
2739 @dots{}
2740 @}
2741
2742 static void (*resolve_memcpy (void)) (void)
2743 @{
2744 return my_memcpy; // we'll just always select this routine
2745 @}
2746 @end smallexample
2747
2748 @noindent
2749 The exported header file declaring the function the user calls would
2750 contain:
2751
2752 @smallexample
2753 extern void *memcpy (void *, const void *, size_t);
2754 @end smallexample
2755
2756 @noindent
2757 allowing the user to call this as a regular function, unaware of the
2758 implementation. Finally, the indirect function needs to be defined in
2759 the same translation unit as the resolver function:
2760
2761 @smallexample
2762 void *memcpy (void *, const void *, size_t)
2763 __attribute__ ((ifunc ("resolve_memcpy")));
2764 @end smallexample
2765
2766 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2767 and GNU C Library version 2.11.1 are required to use this feature.
2768
2769 @item interrupt
2770 @itemx interrupt_handler
2771 Many GCC back ends support attributes to indicate that a function is
2772 an interrupt handler, which tells the compiler to generate function
2773 entry and exit sequences that differ from those from regular
2774 functions. The exact syntax and behavior are target-specific;
2775 refer to the following subsections for details.
2776
2777 @item leaf
2778 @cindex @code{leaf} function attribute
2779 Calls to external functions with this attribute must return to the
2780 current compilation unit only by return or by exception handling. In
2781 particular, a leaf function is not allowed to invoke callback functions
2782 passed to it from the current compilation unit, directly call functions
2783 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2784 might still call functions from other compilation units and thus they
2785 are not necessarily leaf in the sense that they contain no function
2786 calls at all.
2787
2788 The attribute is intended for library functions to improve dataflow
2789 analysis. The compiler takes the hint that any data not escaping the
2790 current compilation unit cannot be used or modified by the leaf
2791 function. For example, the @code{sin} function is a leaf function, but
2792 @code{qsort} is not.
2793
2794 Note that leaf functions might indirectly run a signal handler defined
2795 in the current compilation unit that uses static variables. Similarly,
2796 when lazy symbol resolution is in effect, leaf functions might invoke
2797 indirect functions whose resolver function or implementation function is
2798 defined in the current compilation unit and uses static variables. There
2799 is no standard-compliant way to write such a signal handler, resolver
2800 function, or implementation function, and the best that you can do is to
2801 remove the @code{leaf} attribute or mark all such static variables
2802 @code{volatile}. Lastly, for ELF-based systems that support symbol
2803 interposition, care should be taken that functions defined in the
2804 current compilation unit do not unexpectedly interpose other symbols
2805 based on the defined standards mode and defined feature test macros;
2806 otherwise an inadvertent callback would be added.
2807
2808 The attribute has no effect on functions defined within the current
2809 compilation unit. This is to allow easy merging of multiple compilation
2810 units into one, for example, by using the link-time optimization. For
2811 this reason the attribute is not allowed on types to annotate indirect
2812 calls.
2813
2814 @item malloc
2815 @cindex @code{malloc} function attribute
2816 @cindex functions that behave like malloc
2817 This tells the compiler that a function is @code{malloc}-like, i.e.,
2818 that the pointer @var{P} returned by the function cannot alias any
2819 other pointer valid when the function returns, and moreover no
2820 pointers to valid objects occur in any storage addressed by @var{P}.
2821
2822 Using this attribute can improve optimization. Functions like
2823 @code{malloc} and @code{calloc} have this property because they return
2824 a pointer to uninitialized or zeroed-out storage. However, functions
2825 like @code{realloc} do not have this property, as they can return a
2826 pointer to storage containing pointers.
2827
2828 @item no_icf
2829 @cindex @code{no_icf} function attribute
2830 This function attribute prevents a functions from being merged with another
2831 semantically equivalent function.
2832
2833 @item no_instrument_function
2834 @cindex @code{no_instrument_function} function attribute
2835 @opindex finstrument-functions
2836 If @option{-finstrument-functions} is given, profiling function calls are
2837 generated at entry and exit of most user-compiled functions.
2838 Functions with this attribute are not so instrumented.
2839
2840 @item no_reorder
2841 @cindex @code{no_reorder} function attribute
2842 Do not reorder functions or variables marked @code{no_reorder}
2843 against each other or top level assembler statements the executable.
2844 The actual order in the program will depend on the linker command
2845 line. Static variables marked like this are also not removed.
2846 This has a similar effect
2847 as the @option{-fno-toplevel-reorder} option, but only applies to the
2848 marked symbols.
2849
2850 @item no_sanitize_address
2851 @itemx no_address_safety_analysis
2852 @cindex @code{no_sanitize_address} function attribute
2853 The @code{no_sanitize_address} attribute on functions is used
2854 to inform the compiler that it should not instrument memory accesses
2855 in the function when compiling with the @option{-fsanitize=address} option.
2856 The @code{no_address_safety_analysis} is a deprecated alias of the
2857 @code{no_sanitize_address} attribute, new code should use
2858 @code{no_sanitize_address}.
2859
2860 @item no_sanitize_thread
2861 @cindex @code{no_sanitize_thread} function attribute
2862 The @code{no_sanitize_thread} attribute on functions is used
2863 to inform the compiler that it should not instrument memory accesses
2864 in the function when compiling with the @option{-fsanitize=thread} option.
2865
2866 @item no_sanitize_undefined
2867 @cindex @code{no_sanitize_undefined} function attribute
2868 The @code{no_sanitize_undefined} attribute on functions is used
2869 to inform the compiler that it should not check for undefined behavior
2870 in the function when compiling with the @option{-fsanitize=undefined} option.
2871
2872 @item no_split_stack
2873 @cindex @code{no_split_stack} function attribute
2874 @opindex fsplit-stack
2875 If @option{-fsplit-stack} is given, functions have a small
2876 prologue which decides whether to split the stack. Functions with the
2877 @code{no_split_stack} attribute do not have that prologue, and thus
2878 may run with only a small amount of stack space available.
2879
2880 @item no_stack_limit
2881 @cindex @code{no_stack_limit} function attribute
2882 This attribute locally overrides the @option{-fstack-limit-register}
2883 and @option{-fstack-limit-symbol} command-line options; it has the effect
2884 of disabling stack limit checking in the function it applies to.
2885
2886 @item noclone
2887 @cindex @code{noclone} function attribute
2888 This function attribute prevents a function from being considered for
2889 cloning---a mechanism that produces specialized copies of functions
2890 and which is (currently) performed by interprocedural constant
2891 propagation.
2892
2893 @item noinline
2894 @cindex @code{noinline} function attribute
2895 This function attribute prevents a function from being considered for
2896 inlining.
2897 @c Don't enumerate the optimizations by name here; we try to be
2898 @c future-compatible with this mechanism.
2899 If the function does not have side-effects, there are optimizations
2900 other than inlining that cause function calls to be optimized away,
2901 although the function call is live. To keep such calls from being
2902 optimized away, put
2903 @smallexample
2904 asm ("");
2905 @end smallexample
2906
2907 @noindent
2908 (@pxref{Extended Asm}) in the called function, to serve as a special
2909 side-effect.
2910
2911 @item nonnull (@var{arg-index}, @dots{})
2912 @cindex @code{nonnull} function attribute
2913 @cindex functions with non-null pointer arguments
2914 The @code{nonnull} attribute specifies that some function parameters should
2915 be non-null pointers. For instance, the declaration:
2916
2917 @smallexample
2918 extern void *
2919 my_memcpy (void *dest, const void *src, size_t len)
2920 __attribute__((nonnull (1, 2)));
2921 @end smallexample
2922
2923 @noindent
2924 causes the compiler to check that, in calls to @code{my_memcpy},
2925 arguments @var{dest} and @var{src} are non-null. If the compiler
2926 determines that a null pointer is passed in an argument slot marked
2927 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2928 is issued. The compiler may also choose to make optimizations based
2929 on the knowledge that certain function arguments will never be null.
2930
2931 If no argument index list is given to the @code{nonnull} attribute,
2932 all pointer arguments are marked as non-null. To illustrate, the
2933 following declaration is equivalent to the previous example:
2934
2935 @smallexample
2936 extern void *
2937 my_memcpy (void *dest, const void *src, size_t len)
2938 __attribute__((nonnull));
2939 @end smallexample
2940
2941 @item noplt
2942 @cindex @code{noplt} function attribute
2943 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2944 Calls to functions marked with this attribute in position-independent code
2945 do not use the PLT.
2946
2947 @smallexample
2948 @group
2949 /* Externally defined function foo. */
2950 int foo () __attribute__ ((noplt));
2951
2952 int
2953 main (/* @r{@dots{}} */)
2954 @{
2955 /* @r{@dots{}} */
2956 foo ();
2957 /* @r{@dots{}} */
2958 @}
2959 @end group
2960 @end smallexample
2961
2962 The @code{noplt} attribute on function @code{foo}
2963 tells the compiler to assume that
2964 the function @code{foo} is externally defined and that the call to
2965 @code{foo} must avoid the PLT
2966 in position-independent code.
2967
2968 In position-dependent code, a few targets also convert calls to
2969 functions that are marked to not use the PLT to use the GOT instead.
2970
2971 @item noreturn
2972 @cindex @code{noreturn} function attribute
2973 @cindex functions that never return
2974 A few standard library functions, such as @code{abort} and @code{exit},
2975 cannot return. GCC knows this automatically. Some programs define
2976 their own functions that never return. You can declare them
2977 @code{noreturn} to tell the compiler this fact. For example,
2978
2979 @smallexample
2980 @group
2981 void fatal () __attribute__ ((noreturn));
2982
2983 void
2984 fatal (/* @r{@dots{}} */)
2985 @{
2986 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2987 exit (1);
2988 @}
2989 @end group
2990 @end smallexample
2991
2992 The @code{noreturn} keyword tells the compiler to assume that
2993 @code{fatal} cannot return. It can then optimize without regard to what
2994 would happen if @code{fatal} ever did return. This makes slightly
2995 better code. More importantly, it helps avoid spurious warnings of
2996 uninitialized variables.
2997
2998 The @code{noreturn} keyword does not affect the exceptional path when that
2999 applies: a @code{noreturn}-marked function may still return to the caller
3000 by throwing an exception or calling @code{longjmp}.
3001
3002 Do not assume that registers saved by the calling function are
3003 restored before calling the @code{noreturn} function.
3004
3005 It does not make sense for a @code{noreturn} function to have a return
3006 type other than @code{void}.
3007
3008 @item nothrow
3009 @cindex @code{nothrow} function attribute
3010 The @code{nothrow} attribute is used to inform the compiler that a
3011 function cannot throw an exception. For example, most functions in
3012 the standard C library can be guaranteed not to throw an exception
3013 with the notable exceptions of @code{qsort} and @code{bsearch} that
3014 take function pointer arguments.
3015
3016 @item optimize
3017 @cindex @code{optimize} function attribute
3018 The @code{optimize} attribute is used to specify that a function is to
3019 be compiled with different optimization options than specified on the
3020 command line. Arguments can either be numbers or strings. Numbers
3021 are assumed to be an optimization level. Strings that begin with
3022 @code{O} are assumed to be an optimization option, while other options
3023 are assumed to be used with a @code{-f} prefix. You can also use the
3024 @samp{#pragma GCC optimize} pragma to set the optimization options
3025 that affect more than one function.
3026 @xref{Function Specific Option Pragmas}, for details about the
3027 @samp{#pragma GCC optimize} pragma.
3028
3029 This can be used for instance to have frequently-executed functions
3030 compiled with more aggressive optimization options that produce faster
3031 and larger code, while other functions can be compiled with less
3032 aggressive options.
3033
3034 @item pure
3035 @cindex @code{pure} function attribute
3036 @cindex functions that have no side effects
3037 Many functions have no effects except the return value and their
3038 return value depends only on the parameters and/or global variables.
3039 Such a function can be subject
3040 to common subexpression elimination and loop optimization just as an
3041 arithmetic operator would be. These functions should be declared
3042 with the attribute @code{pure}. For example,
3043
3044 @smallexample
3045 int square (int) __attribute__ ((pure));
3046 @end smallexample
3047
3048 @noindent
3049 says that the hypothetical function @code{square} is safe to call
3050 fewer times than the program says.
3051
3052 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3053 Interesting non-pure functions are functions with infinite loops or those
3054 depending on volatile memory or other system resource, that may change between
3055 two consecutive calls (such as @code{feof} in a multithreading environment).
3056
3057 @item returns_nonnull
3058 @cindex @code{returns_nonnull} function attribute
3059 The @code{returns_nonnull} attribute specifies that the function
3060 return value should be a non-null pointer. For instance, the declaration:
3061
3062 @smallexample
3063 extern void *
3064 mymalloc (size_t len) __attribute__((returns_nonnull));
3065 @end smallexample
3066
3067 @noindent
3068 lets the compiler optimize callers based on the knowledge
3069 that the return value will never be null.
3070
3071 @item returns_twice
3072 @cindex @code{returns_twice} function attribute
3073 @cindex functions that return more than once
3074 The @code{returns_twice} attribute tells the compiler that a function may
3075 return more than one time. The compiler ensures that all registers
3076 are dead before calling such a function and emits a warning about
3077 the variables that may be clobbered after the second return from the
3078 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3079 The @code{longjmp}-like counterpart of such function, if any, might need
3080 to be marked with the @code{noreturn} attribute.
3081
3082 @item section ("@var{section-name}")
3083 @cindex @code{section} function attribute
3084 @cindex functions in arbitrary sections
3085 Normally, the compiler places the code it generates in the @code{text} section.
3086 Sometimes, however, you need additional sections, or you need certain
3087 particular functions to appear in special sections. The @code{section}
3088 attribute specifies that a function lives in a particular section.
3089 For example, the declaration:
3090
3091 @smallexample
3092 extern void foobar (void) __attribute__ ((section ("bar")));
3093 @end smallexample
3094
3095 @noindent
3096 puts the function @code{foobar} in the @code{bar} section.
3097
3098 Some file formats do not support arbitrary sections so the @code{section}
3099 attribute is not available on all platforms.
3100 If you need to map the entire contents of a module to a particular
3101 section, consider using the facilities of the linker instead.
3102
3103 @item sentinel
3104 @cindex @code{sentinel} function attribute
3105 This function attribute ensures that a parameter in a function call is
3106 an explicit @code{NULL}. The attribute is only valid on variadic
3107 functions. By default, the sentinel is located at position zero, the
3108 last parameter of the function call. If an optional integer position
3109 argument P is supplied to the attribute, the sentinel must be located at
3110 position P counting backwards from the end of the argument list.
3111
3112 @smallexample
3113 __attribute__ ((sentinel))
3114 is equivalent to
3115 __attribute__ ((sentinel(0)))
3116 @end smallexample
3117
3118 The attribute is automatically set with a position of 0 for the built-in
3119 functions @code{execl} and @code{execlp}. The built-in function
3120 @code{execle} has the attribute set with a position of 1.
3121
3122 A valid @code{NULL} in this context is defined as zero with any pointer
3123 type. If your system defines the @code{NULL} macro with an integer type
3124 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3125 with a copy that redefines NULL appropriately.
3126
3127 The warnings for missing or incorrect sentinels are enabled with
3128 @option{-Wformat}.
3129
3130 @item simd
3131 @itemx simd("@var{mask}")
3132 @cindex @code{simd} function attribute
3133 This attribute enables creation of one or more function versions that
3134 can process multiple arguments using SIMD instructions from a
3135 single invocation. Specifying this attribute allows compiler to
3136 assume that such versions are available at link time (provided
3137 in the same or another translation unit). Generated versions are
3138 target-dependent and described in the corresponding Vector ABI document. For
3139 x86_64 target this document can be found
3140 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3141
3142 The optional argument @var{mask} may have the value
3143 @code{notinbranch} or @code{inbranch},
3144 and instructs the compiler to generate non-masked or masked
3145 clones correspondingly. By default, all clones are generated.
3146
3147 The attribute should not be used together with Cilk Plus @code{vector}
3148 attribute on the same function.
3149
3150 If the attribute is specified and @code{#pragma omp declare simd} is
3151 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3152 switch is specified, then the attribute is ignored.
3153
3154 @item stack_protect
3155 @cindex @code{stack_protect} function attribute
3156 This attribute adds stack protection code to the function if
3157 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3158 or @option{-fstack-protector-explicit} are set.
3159
3160 @item target (@var{options})
3161 @cindex @code{target} function attribute
3162 Multiple target back ends implement the @code{target} attribute
3163 to specify that a function is to
3164 be compiled with different target options than specified on the
3165 command line. This can be used for instance to have functions
3166 compiled with a different ISA (instruction set architecture) than the
3167 default. You can also use the @samp{#pragma GCC target} pragma to set
3168 more than one function to be compiled with specific target options.
3169 @xref{Function Specific Option Pragmas}, for details about the
3170 @samp{#pragma GCC target} pragma.
3171
3172 For instance, on an x86, you could declare one function with the
3173 @code{target("sse4.1,arch=core2")} attribute and another with
3174 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3175 compiling the first function with @option{-msse4.1} and
3176 @option{-march=core2} options, and the second function with
3177 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3178 to make sure that a function is only invoked on a machine that
3179 supports the particular ISA it is compiled for (for example by using
3180 @code{cpuid} on x86 to determine what feature bits and architecture
3181 family are used).
3182
3183 @smallexample
3184 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3185 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3186 @end smallexample
3187
3188 You can either use multiple
3189 strings separated by commas to specify multiple options,
3190 or separate the options with a comma (@samp{,}) within a single string.
3191
3192 The options supported are specific to each target; refer to @ref{x86
3193 Function Attributes}, @ref{PowerPC Function Attributes},
3194 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3195 for details.
3196
3197 @item target_clones (@var{options})
3198 @cindex @code{target_clones} function attribute
3199 The @code{target_clones} attribute is used to specify that a function
3200 be cloned into multiple versions compiled with different target options
3201 than specified on the command line. The supported options and restrictions
3202 are the same as for @code{target} attribute.
3203
3204 For instance, on an x86, you could compile a function with
3205 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3206 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3207 It also creates a resolver function (see the @code{ifunc} attribute
3208 above) that dynamically selects a clone suitable for current architecture.
3209
3210 @item unused
3211 @cindex @code{unused} function attribute
3212 This attribute, attached to a function, means that the function is meant
3213 to be possibly unused. GCC does not produce a warning for this
3214 function.
3215
3216 @item used
3217 @cindex @code{used} function attribute
3218 This attribute, attached to a function, means that code must be emitted
3219 for the function even if it appears that the function is not referenced.
3220 This is useful, for example, when the function is referenced only in
3221 inline assembly.
3222
3223 When applied to a member function of a C++ class template, the
3224 attribute also means that the function is instantiated if the
3225 class itself is instantiated.
3226
3227 @item visibility ("@var{visibility_type}")
3228 @cindex @code{visibility} function attribute
3229 This attribute affects the linkage of the declaration to which it is attached.
3230 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3231 (@pxref{Common Type Attributes}) as well as functions.
3232
3233 There are four supported @var{visibility_type} values: default,
3234 hidden, protected or internal visibility.
3235
3236 @smallexample
3237 void __attribute__ ((visibility ("protected")))
3238 f () @{ /* @r{Do something.} */; @}
3239 int i __attribute__ ((visibility ("hidden")));
3240 @end smallexample
3241
3242 The possible values of @var{visibility_type} correspond to the
3243 visibility settings in the ELF gABI.
3244
3245 @table @code
3246 @c keep this list of visibilities in alphabetical order.
3247
3248 @item default
3249 Default visibility is the normal case for the object file format.
3250 This value is available for the visibility attribute to override other
3251 options that may change the assumed visibility of entities.
3252
3253 On ELF, default visibility means that the declaration is visible to other
3254 modules and, in shared libraries, means that the declared entity may be
3255 overridden.
3256
3257 On Darwin, default visibility means that the declaration is visible to
3258 other modules.
3259
3260 Default visibility corresponds to ``external linkage'' in the language.
3261
3262 @item hidden
3263 Hidden visibility indicates that the entity declared has a new
3264 form of linkage, which we call ``hidden linkage''. Two
3265 declarations of an object with hidden linkage refer to the same object
3266 if they are in the same shared object.
3267
3268 @item internal
3269 Internal visibility is like hidden visibility, but with additional
3270 processor specific semantics. Unless otherwise specified by the
3271 psABI, GCC defines internal visibility to mean that a function is
3272 @emph{never} called from another module. Compare this with hidden
3273 functions which, while they cannot be referenced directly by other
3274 modules, can be referenced indirectly via function pointers. By
3275 indicating that a function cannot be called from outside the module,
3276 GCC may for instance omit the load of a PIC register since it is known
3277 that the calling function loaded the correct value.
3278
3279 @item protected
3280 Protected visibility is like default visibility except that it
3281 indicates that references within the defining module bind to the
3282 definition in that module. That is, the declared entity cannot be
3283 overridden by another module.
3284
3285 @end table
3286
3287 All visibilities are supported on many, but not all, ELF targets
3288 (supported when the assembler supports the @samp{.visibility}
3289 pseudo-op). Default visibility is supported everywhere. Hidden
3290 visibility is supported on Darwin targets.
3291
3292 The visibility attribute should be applied only to declarations that
3293 would otherwise have external linkage. The attribute should be applied
3294 consistently, so that the same entity should not be declared with
3295 different settings of the attribute.
3296
3297 In C++, the visibility attribute applies to types as well as functions
3298 and objects, because in C++ types have linkage. A class must not have
3299 greater visibility than its non-static data member types and bases,
3300 and class members default to the visibility of their class. Also, a
3301 declaration without explicit visibility is limited to the visibility
3302 of its type.
3303
3304 In C++, you can mark member functions and static member variables of a
3305 class with the visibility attribute. This is useful if you know a
3306 particular method or static member variable should only be used from
3307 one shared object; then you can mark it hidden while the rest of the
3308 class has default visibility. Care must be taken to avoid breaking
3309 the One Definition Rule; for example, it is usually not useful to mark
3310 an inline method as hidden without marking the whole class as hidden.
3311
3312 A C++ namespace declaration can also have the visibility attribute.
3313
3314 @smallexample
3315 namespace nspace1 __attribute__ ((visibility ("protected")))
3316 @{ /* @r{Do something.} */; @}
3317 @end smallexample
3318
3319 This attribute applies only to the particular namespace body, not to
3320 other definitions of the same namespace; it is equivalent to using
3321 @samp{#pragma GCC visibility} before and after the namespace
3322 definition (@pxref{Visibility Pragmas}).
3323
3324 In C++, if a template argument has limited visibility, this
3325 restriction is implicitly propagated to the template instantiation.
3326 Otherwise, template instantiations and specializations default to the
3327 visibility of their template.
3328
3329 If both the template and enclosing class have explicit visibility, the
3330 visibility from the template is used.
3331
3332 @item warn_unused_result
3333 @cindex @code{warn_unused_result} function attribute
3334 The @code{warn_unused_result} attribute causes a warning to be emitted
3335 if a caller of the function with this attribute does not use its
3336 return value. This is useful for functions where not checking
3337 the result is either a security problem or always a bug, such as
3338 @code{realloc}.
3339
3340 @smallexample
3341 int fn () __attribute__ ((warn_unused_result));
3342 int foo ()
3343 @{
3344 if (fn () < 0) return -1;
3345 fn ();
3346 return 0;
3347 @}
3348 @end smallexample
3349
3350 @noindent
3351 results in warning on line 5.
3352
3353 @item weak
3354 @cindex @code{weak} function attribute
3355 The @code{weak} attribute causes the declaration to be emitted as a weak
3356 symbol rather than a global. This is primarily useful in defining
3357 library functions that can be overridden in user code, though it can
3358 also be used with non-function declarations. Weak symbols are supported
3359 for ELF targets, and also for a.out targets when using the GNU assembler
3360 and linker.
3361
3362 @item weakref
3363 @itemx weakref ("@var{target}")
3364 @cindex @code{weakref} function attribute
3365 The @code{weakref} attribute marks a declaration as a weak reference.
3366 Without arguments, it should be accompanied by an @code{alias} attribute
3367 naming the target symbol. Optionally, the @var{target} may be given as
3368 an argument to @code{weakref} itself. In either case, @code{weakref}
3369 implicitly marks the declaration as @code{weak}. Without a
3370 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3371 @code{weakref} is equivalent to @code{weak}.
3372
3373 @smallexample
3374 static int x() __attribute__ ((weakref ("y")));
3375 /* is equivalent to... */
3376 static int x() __attribute__ ((weak, weakref, alias ("y")));
3377 /* and to... */
3378 static int x() __attribute__ ((weakref));
3379 static int x() __attribute__ ((alias ("y")));
3380 @end smallexample
3381
3382 A weak reference is an alias that does not by itself require a
3383 definition to be given for the target symbol. If the target symbol is
3384 only referenced through weak references, then it becomes a @code{weak}
3385 undefined symbol. If it is directly referenced, however, then such
3386 strong references prevail, and a definition is required for the
3387 symbol, not necessarily in the same translation unit.
3388
3389 The effect is equivalent to moving all references to the alias to a
3390 separate translation unit, renaming the alias to the aliased symbol,
3391 declaring it as weak, compiling the two separate translation units and
3392 performing a reloadable link on them.
3393
3394 At present, a declaration to which @code{weakref} is attached can
3395 only be @code{static}.
3396
3397
3398 @end table
3399
3400 @c This is the end of the target-independent attribute table
3401
3402 @node AArch64 Function Attributes
3403 @subsection AArch64 Function Attributes
3404
3405 The following target-specific function attributes are available for the
3406 AArch64 target. For the most part, these options mirror the behavior of
3407 similar command-line options (@pxref{AArch64 Options}), but on a
3408 per-function basis.
3409
3410 @table @code
3411 @item general-regs-only
3412 @cindex @code{general-regs-only} function attribute, AArch64
3413 Indicates that no floating-point or Advanced SIMD registers should be
3414 used when generating code for this function. If the function explicitly
3415 uses floating-point code, then the compiler gives an error. This is
3416 the same behavior as that of the command-line option
3417 @option{-mgeneral-regs-only}.
3418
3419 @item fix-cortex-a53-835769
3420 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3421 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3422 applied to this function. To explicitly disable the workaround for this
3423 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3424 This corresponds to the behavior of the command line options
3425 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3426
3427 @item cmodel=
3428 @cindex @code{cmodel=} function attribute, AArch64
3429 Indicates that code should be generated for a particular code model for
3430 this function. The behavior and permissible arguments are the same as
3431 for the command line option @option{-mcmodel=}.
3432
3433 @item strict-align
3434 @cindex @code{strict-align} function attribute, AArch64
3435 Indicates that the compiler should not assume that unaligned memory references
3436 are handled by the system. The behavior is the same as for the command-line
3437 option @option{-mstrict-align}.
3438
3439 @item omit-leaf-frame-pointer
3440 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3441 Indicates that the frame pointer should be omitted for a leaf function call.
3442 To keep the frame pointer, the inverse attribute
3443 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3444 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3445 and @option{-mno-omit-leaf-frame-pointer}.
3446
3447 @item tls-dialect=
3448 @cindex @code{tls-dialect=} function attribute, AArch64
3449 Specifies the TLS dialect to use for this function. The behavior and
3450 permissible arguments are the same as for the command-line option
3451 @option{-mtls-dialect=}.
3452
3453 @item arch=
3454 @cindex @code{arch=} function attribute, AArch64
3455 Specifies the architecture version and architectural extensions to use
3456 for this function. The behavior and permissible arguments are the same as
3457 for the @option{-march=} command-line option.
3458
3459 @item tune=
3460 @cindex @code{tune=} function attribute, AArch64
3461 Specifies the core for which to tune the performance of this function.
3462 The behavior and permissible arguments are the same as for the @option{-mtune=}
3463 command-line option.
3464
3465 @item cpu=
3466 @cindex @code{cpu=} function attribute, AArch64
3467 Specifies the core for which to tune the performance of this function and also
3468 whose architectural features to use. The behavior and valid arguments are the
3469 same as for the @option{-mcpu=} command-line option.
3470
3471 @end table
3472
3473 The above target attributes can be specified as follows:
3474
3475 @smallexample
3476 __attribute__((target("@var{attr-string}")))
3477 int
3478 f (int a)
3479 @{
3480 return a + 5;
3481 @}
3482 @end smallexample
3483
3484 where @code{@var{attr-string}} is one of the attribute strings specified above.
3485
3486 Additionally, the architectural extension string may be specified on its
3487 own. This can be used to turn on and off particular architectural extensions
3488 without having to specify a particular architecture version or core. Example:
3489
3490 @smallexample
3491 __attribute__((target("+crc+nocrypto")))
3492 int
3493 foo (int a)
3494 @{
3495 return a + 5;
3496 @}
3497 @end smallexample
3498
3499 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3500 extension and disables the @code{crypto} extension for the function @code{foo}
3501 without modifying an existing @option{-march=} or @option{-mcpu} option.
3502
3503 Multiple target function attributes can be specified by separating them with
3504 a comma. For example:
3505 @smallexample
3506 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3507 int
3508 foo (int a)
3509 @{
3510 return a + 5;
3511 @}
3512 @end smallexample
3513
3514 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3515 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3516
3517 @subsubsection Inlining rules
3518 Specifying target attributes on individual functions or performing link-time
3519 optimization across translation units compiled with different target options
3520 can affect function inlining rules:
3521
3522 In particular, a caller function can inline a callee function only if the
3523 architectural features available to the callee are a subset of the features
3524 available to the caller.
3525 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3526 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3527 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3528 because the all the architectural features that function @code{bar} requires
3529 are available to function @code{foo}. Conversely, function @code{bar} cannot
3530 inline function @code{foo}.
3531
3532 Additionally inlining a function compiled with @option{-mstrict-align} into a
3533 function compiled without @code{-mstrict-align} is not allowed.
3534 However, inlining a function compiled without @option{-mstrict-align} into a
3535 function compiled with @option{-mstrict-align} is allowed.
3536
3537 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3538 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3539 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3540 architectural feature rules specified above.
3541
3542 @node ARC Function Attributes
3543 @subsection ARC Function Attributes
3544
3545 These function attributes are supported by the ARC back end:
3546
3547 @table @code
3548 @item interrupt
3549 @cindex @code{interrupt} function attribute, ARC
3550 Use this attribute to indicate
3551 that the specified function is an interrupt handler. The compiler generates
3552 function entry and exit sequences suitable for use in an interrupt handler
3553 when this attribute is present.
3554
3555 On the ARC, you must specify the kind of interrupt to be handled
3556 in a parameter to the interrupt attribute like this:
3557
3558 @smallexample
3559 void f () __attribute__ ((interrupt ("ilink1")));
3560 @end smallexample
3561
3562 Permissible values for this parameter are: @w{@code{ilink1}} and
3563 @w{@code{ilink2}}.
3564
3565 @item long_call
3566 @itemx medium_call
3567 @itemx short_call
3568 @cindex @code{long_call} function attribute, ARC
3569 @cindex @code{medium_call} function attribute, ARC
3570 @cindex @code{short_call} function attribute, ARC
3571 @cindex indirect calls, ARC
3572 These attributes specify how a particular function is called.
3573 These attributes override the
3574 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3575 command-line switches and @code{#pragma long_calls} settings.
3576
3577 For ARC, a function marked with the @code{long_call} attribute is
3578 always called using register-indirect jump-and-link instructions,
3579 thereby enabling the called function to be placed anywhere within the
3580 32-bit address space. A function marked with the @code{medium_call}
3581 attribute will always be close enough to be called with an unconditional
3582 branch-and-link instruction, which has a 25-bit offset from
3583 the call site. A function marked with the @code{short_call}
3584 attribute will always be close enough to be called with a conditional
3585 branch-and-link instruction, which has a 21-bit offset from
3586 the call site.
3587 @end table
3588
3589 @node ARM Function Attributes
3590 @subsection ARM Function Attributes
3591
3592 These function attributes are supported for ARM targets:
3593
3594 @table @code
3595 @item interrupt
3596 @cindex @code{interrupt} function attribute, ARM
3597 Use this attribute to indicate
3598 that the specified function is an interrupt handler. The compiler generates
3599 function entry and exit sequences suitable for use in an interrupt handler
3600 when this attribute is present.
3601
3602 You can specify the kind of interrupt to be handled by
3603 adding an optional parameter to the interrupt attribute like this:
3604
3605 @smallexample
3606 void f () __attribute__ ((interrupt ("IRQ")));
3607 @end smallexample
3608
3609 @noindent
3610 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3611 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3612
3613 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3614 may be called with a word-aligned stack pointer.
3615
3616 @item isr
3617 @cindex @code{isr} function attribute, ARM
3618 Use this attribute on ARM to write Interrupt Service Routines. This is an
3619 alias to the @code{interrupt} attribute above.
3620
3621 @item long_call
3622 @itemx short_call
3623 @cindex @code{long_call} function attribute, ARM
3624 @cindex @code{short_call} function attribute, ARM
3625 @cindex indirect calls, ARM
3626 These attributes specify how a particular function is called.
3627 These attributes override the
3628 @option{-mlong-calls} (@pxref{ARM Options})
3629 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3630 @code{long_call} attribute indicates that the function might be far
3631 away from the call site and require a different (more expensive)
3632 calling sequence. The @code{short_call} attribute always places
3633 the offset to the function from the call site into the @samp{BL}
3634 instruction directly.
3635
3636 @item naked
3637 @cindex @code{naked} function attribute, ARM
3638 This attribute allows the compiler to construct the
3639 requisite function declaration, while allowing the body of the
3640 function to be assembly code. The specified function will not have
3641 prologue/epilogue sequences generated by the compiler. Only basic
3642 @code{asm} statements can safely be included in naked functions
3643 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3644 basic @code{asm} and C code may appear to work, they cannot be
3645 depended upon to work reliably and are not supported.
3646
3647 @item pcs
3648 @cindex @code{pcs} function attribute, ARM
3649
3650 The @code{pcs} attribute can be used to control the calling convention
3651 used for a function on ARM. The attribute takes an argument that specifies
3652 the calling convention to use.
3653
3654 When compiling using the AAPCS ABI (or a variant of it) then valid
3655 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3656 order to use a variant other than @code{"aapcs"} then the compiler must
3657 be permitted to use the appropriate co-processor registers (i.e., the
3658 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3659 For example,
3660
3661 @smallexample
3662 /* Argument passed in r0, and result returned in r0+r1. */
3663 double f2d (float) __attribute__((pcs("aapcs")));
3664 @end smallexample
3665
3666 Variadic functions always use the @code{"aapcs"} calling convention and
3667 the compiler rejects attempts to specify an alternative.
3668
3669 @item target (@var{options})
3670 @cindex @code{target} function attribute
3671 As discussed in @ref{Common Function Attributes}, this attribute
3672 allows specification of target-specific compilation options.
3673
3674 On ARM, the following options are allowed:
3675
3676 @table @samp
3677 @item thumb
3678 @cindex @code{target("thumb")} function attribute, ARM
3679 Force code generation in the Thumb (T16/T32) ISA, depending on the
3680 architecture level.
3681
3682 @item arm
3683 @cindex @code{target("arm")} function attribute, ARM
3684 Force code generation in the ARM (A32) ISA.
3685
3686 Functions from different modes can be inlined in the caller's mode.
3687
3688 @item fpu=
3689 @cindex @code{target("fpu=")} function attribute, ARM
3690 Specifies the fpu for which to tune the performance of this function.
3691 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3692 command-line option.
3693
3694 @end table
3695
3696 @end table
3697
3698 @node AVR Function Attributes
3699 @subsection AVR Function Attributes
3700
3701 These function attributes are supported by the AVR back end:
3702
3703 @table @code
3704 @item interrupt
3705 @cindex @code{interrupt} function attribute, AVR
3706 Use this attribute to indicate
3707 that the specified function is an interrupt handler. The compiler generates
3708 function entry and exit sequences suitable for use in an interrupt handler
3709 when this attribute is present.
3710
3711 On the AVR, the hardware globally disables interrupts when an
3712 interrupt is executed. The first instruction of an interrupt handler
3713 declared with this attribute is a @code{SEI} instruction to
3714 re-enable interrupts. See also the @code{signal} function attribute
3715 that does not insert a @code{SEI} instruction. If both @code{signal} and
3716 @code{interrupt} are specified for the same function, @code{signal}
3717 is silently ignored.
3718
3719 @item naked
3720 @cindex @code{naked} function attribute, AVR
3721 This attribute allows the compiler to construct the
3722 requisite function declaration, while allowing the body of the
3723 function to be assembly code. The specified function will not have
3724 prologue/epilogue sequences generated by the compiler. Only basic
3725 @code{asm} statements can safely be included in naked functions
3726 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3727 basic @code{asm} and C code may appear to work, they cannot be
3728 depended upon to work reliably and are not supported.
3729
3730 @item OS_main
3731 @itemx OS_task
3732 @cindex @code{OS_main} function attribute, AVR
3733 @cindex @code{OS_task} function attribute, AVR
3734 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3735 do not save/restore any call-saved register in their prologue/epilogue.
3736
3737 The @code{OS_main} attribute can be used when there @emph{is
3738 guarantee} that interrupts are disabled at the time when the function
3739 is entered. This saves resources when the stack pointer has to be
3740 changed to set up a frame for local variables.
3741
3742 The @code{OS_task} attribute can be used when there is @emph{no
3743 guarantee} that interrupts are disabled at that time when the function
3744 is entered like for, e@.g@. task functions in a multi-threading operating
3745 system. In that case, changing the stack pointer register is
3746 guarded by save/clear/restore of the global interrupt enable flag.
3747
3748 The differences to the @code{naked} function attribute are:
3749 @itemize @bullet
3750 @item @code{naked} functions do not have a return instruction whereas
3751 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3752 @code{RETI} return instruction.
3753 @item @code{naked} functions do not set up a frame for local variables
3754 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3755 as needed.
3756 @end itemize
3757
3758 @item signal
3759 @cindex @code{signal} function attribute, AVR
3760 Use this attribute on the AVR to indicate that the specified
3761 function is an interrupt handler. The compiler generates function
3762 entry and exit sequences suitable for use in an interrupt handler when this
3763 attribute is present.
3764
3765 See also the @code{interrupt} function attribute.
3766
3767 The AVR hardware globally disables interrupts when an interrupt is executed.
3768 Interrupt handler functions defined with the @code{signal} attribute
3769 do not re-enable interrupts. It is save to enable interrupts in a
3770 @code{signal} handler. This ``save'' only applies to the code
3771 generated by the compiler and not to the IRQ layout of the
3772 application which is responsibility of the application.
3773
3774 If both @code{signal} and @code{interrupt} are specified for the same
3775 function, @code{signal} is silently ignored.
3776 @end table
3777
3778 @node Blackfin Function Attributes
3779 @subsection Blackfin Function Attributes
3780
3781 These function attributes are supported by the Blackfin back end:
3782
3783 @table @code
3784
3785 @item exception_handler
3786 @cindex @code{exception_handler} function attribute
3787 @cindex exception handler functions, Blackfin
3788 Use this attribute on the Blackfin to indicate that the specified function
3789 is an exception handler. The compiler generates function entry and
3790 exit sequences suitable for use in an exception handler when this
3791 attribute is present.
3792
3793 @item interrupt_handler
3794 @cindex @code{interrupt_handler} function attribute, Blackfin
3795 Use this attribute to
3796 indicate that the specified function is an interrupt handler. The compiler
3797 generates function entry and exit sequences suitable for use in an
3798 interrupt handler when this attribute is present.
3799
3800 @item kspisusp
3801 @cindex @code{kspisusp} function attribute, Blackfin
3802 @cindex User stack pointer in interrupts on the Blackfin
3803 When used together with @code{interrupt_handler}, @code{exception_handler}
3804 or @code{nmi_handler}, code is generated to load the stack pointer
3805 from the USP register in the function prologue.
3806
3807 @item l1_text
3808 @cindex @code{l1_text} function attribute, Blackfin
3809 This attribute specifies a function to be placed into L1 Instruction
3810 SRAM@. The function is put into a specific section named @code{.l1.text}.
3811 With @option{-mfdpic}, function calls with a such function as the callee
3812 or caller uses inlined PLT.
3813
3814 @item l2
3815 @cindex @code{l2} function attribute, Blackfin
3816 This attribute specifies a function to be placed into L2
3817 SRAM. The function is put into a specific section named
3818 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3819 an inlined PLT.
3820
3821 @item longcall
3822 @itemx shortcall
3823 @cindex indirect calls, Blackfin
3824 @cindex @code{longcall} function attribute, Blackfin
3825 @cindex @code{shortcall} function attribute, Blackfin
3826 The @code{longcall} attribute
3827 indicates that the function might be far away from the call site and
3828 require a different (more expensive) calling sequence. The
3829 @code{shortcall} attribute indicates that the function is always close
3830 enough for the shorter calling sequence to be used. These attributes
3831 override the @option{-mlongcall} switch.
3832
3833 @item nesting
3834 @cindex @code{nesting} function attribute, Blackfin
3835 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3836 Use this attribute together with @code{interrupt_handler},
3837 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3838 entry code should enable nested interrupts or exceptions.
3839
3840 @item nmi_handler
3841 @cindex @code{nmi_handler} function attribute, Blackfin
3842 @cindex NMI handler functions on the Blackfin processor
3843 Use this attribute on the Blackfin to indicate that the specified function
3844 is an NMI handler. The compiler generates function entry and
3845 exit sequences suitable for use in an NMI handler when this
3846 attribute is present.
3847
3848 @item saveall
3849 @cindex @code{saveall} function attribute, Blackfin
3850 @cindex save all registers on the Blackfin
3851 Use this attribute to indicate that
3852 all registers except the stack pointer should be saved in the prologue
3853 regardless of whether they are used or not.
3854 @end table
3855
3856 @node CR16 Function Attributes
3857 @subsection CR16 Function Attributes
3858
3859 These function attributes are supported by the CR16 back end:
3860
3861 @table @code
3862 @item interrupt
3863 @cindex @code{interrupt} function attribute, CR16
3864 Use this attribute to indicate
3865 that the specified function is an interrupt handler. The compiler generates
3866 function entry and exit sequences suitable for use in an interrupt handler
3867 when this attribute is present.
3868 @end table
3869
3870 @node Epiphany Function Attributes
3871 @subsection Epiphany Function Attributes
3872
3873 These function attributes are supported by the Epiphany back end:
3874
3875 @table @code
3876 @item disinterrupt
3877 @cindex @code{disinterrupt} function attribute, Epiphany
3878 This attribute causes the compiler to emit
3879 instructions to disable interrupts for the duration of the given
3880 function.
3881
3882 @item forwarder_section
3883 @cindex @code{forwarder_section} function attribute, Epiphany
3884 This attribute modifies the behavior of an interrupt handler.
3885 The interrupt handler may be in external memory which cannot be
3886 reached by a branch instruction, so generate a local memory trampoline
3887 to transfer control. The single parameter identifies the section where
3888 the trampoline is placed.
3889
3890 @item interrupt
3891 @cindex @code{interrupt} function attribute, Epiphany
3892 Use this attribute to indicate
3893 that the specified function is an interrupt handler. The compiler generates
3894 function entry and exit sequences suitable for use in an interrupt handler
3895 when this attribute is present. It may also generate
3896 a special section with code to initialize the interrupt vector table.
3897
3898 On Epiphany targets one or more optional parameters can be added like this:
3899
3900 @smallexample
3901 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3902 @end smallexample
3903
3904 Permissible values for these parameters are: @w{@code{reset}},
3905 @w{@code{software_exception}}, @w{@code{page_miss}},
3906 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3907 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3908 Multiple parameters indicate that multiple entries in the interrupt
3909 vector table should be initialized for this function, i.e.@: for each
3910 parameter @w{@var{name}}, a jump to the function is emitted in
3911 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3912 entirely, in which case no interrupt vector table entry is provided.
3913
3914 Note that interrupts are enabled inside the function
3915 unless the @code{disinterrupt} attribute is also specified.
3916
3917 The following examples are all valid uses of these attributes on
3918 Epiphany targets:
3919 @smallexample
3920 void __attribute__ ((interrupt)) universal_handler ();
3921 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3922 void __attribute__ ((interrupt ("dma0, dma1")))
3923 universal_dma_handler ();
3924 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3925 fast_timer_handler ();
3926 void __attribute__ ((interrupt ("dma0, dma1"),
3927 forwarder_section ("tramp")))
3928 external_dma_handler ();
3929 @end smallexample
3930
3931 @item long_call
3932 @itemx short_call
3933 @cindex @code{long_call} function attribute, Epiphany
3934 @cindex @code{short_call} function attribute, Epiphany
3935 @cindex indirect calls, Epiphany
3936 These attributes specify how a particular function is called.
3937 These attributes override the
3938 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3939 command-line switch and @code{#pragma long_calls} settings.
3940 @end table
3941
3942
3943 @node H8/300 Function Attributes
3944 @subsection H8/300 Function Attributes
3945
3946 These function attributes are available for H8/300 targets:
3947
3948 @table @code
3949 @item function_vector
3950 @cindex @code{function_vector} function attribute, H8/300
3951 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3952 that the specified function should be called through the function vector.
3953 Calling a function through the function vector reduces code size; however,
3954 the function vector has a limited size (maximum 128 entries on the H8/300
3955 and 64 entries on the H8/300H and H8S)
3956 and shares space with the interrupt vector.
3957
3958 @item interrupt_handler
3959 @cindex @code{interrupt_handler} function attribute, H8/300
3960 Use this attribute on the H8/300, H8/300H, and H8S to
3961 indicate that the specified function is an interrupt handler. The compiler
3962 generates function entry and exit sequences suitable for use in an
3963 interrupt handler when this attribute is present.
3964
3965 @item saveall
3966 @cindex @code{saveall} function attribute, H8/300
3967 @cindex save all registers on the H8/300, H8/300H, and H8S
3968 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3969 all registers except the stack pointer should be saved in the prologue
3970 regardless of whether they are used or not.
3971 @end table
3972
3973 @node IA-64 Function Attributes
3974 @subsection IA-64 Function Attributes
3975
3976 These function attributes are supported on IA-64 targets:
3977
3978 @table @code
3979 @item syscall_linkage
3980 @cindex @code{syscall_linkage} function attribute, IA-64
3981 This attribute is used to modify the IA-64 calling convention by marking
3982 all input registers as live at all function exits. This makes it possible
3983 to restart a system call after an interrupt without having to save/restore
3984 the input registers. This also prevents kernel data from leaking into
3985 application code.
3986
3987 @item version_id
3988 @cindex @code{version_id} function attribute, IA-64
3989 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3990 symbol to contain a version string, thus allowing for function level
3991 versioning. HP-UX system header files may use function level versioning
3992 for some system calls.
3993
3994 @smallexample
3995 extern int foo () __attribute__((version_id ("20040821")));
3996 @end smallexample
3997
3998 @noindent
3999 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4000 @end table
4001
4002 @node M32C Function Attributes
4003 @subsection M32C Function Attributes
4004
4005 These function attributes are supported by the M32C back end:
4006
4007 @table @code
4008 @item bank_switch
4009 @cindex @code{bank_switch} function attribute, M32C
4010 When added to an interrupt handler with the M32C port, causes the
4011 prologue and epilogue to use bank switching to preserve the registers
4012 rather than saving them on the stack.
4013
4014 @item fast_interrupt
4015 @cindex @code{fast_interrupt} function attribute, M32C
4016 Use this attribute on the M32C port to indicate that the specified
4017 function is a fast interrupt handler. This is just like the
4018 @code{interrupt} attribute, except that @code{freit} is used to return
4019 instead of @code{reit}.
4020
4021 @item function_vector
4022 @cindex @code{function_vector} function attribute, M16C/M32C
4023 On M16C/M32C targets, the @code{function_vector} attribute declares a
4024 special page subroutine call function. Use of this attribute reduces
4025 the code size by 2 bytes for each call generated to the
4026 subroutine. The argument to the attribute is the vector number entry
4027 from the special page vector table which contains the 16 low-order
4028 bits of the subroutine's entry address. Each vector table has special
4029 page number (18 to 255) that is used in @code{jsrs} instructions.
4030 Jump addresses of the routines are generated by adding 0x0F0000 (in
4031 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4032 2-byte addresses set in the vector table. Therefore you need to ensure
4033 that all the special page vector routines should get mapped within the
4034 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4035 (for M32C).
4036
4037 In the following example 2 bytes are saved for each call to
4038 function @code{foo}.
4039
4040 @smallexample
4041 void foo (void) __attribute__((function_vector(0x18)));
4042 void foo (void)
4043 @{
4044 @}
4045
4046 void bar (void)
4047 @{
4048 foo();
4049 @}
4050 @end smallexample
4051
4052 If functions are defined in one file and are called in another file,
4053 then be sure to write this declaration in both files.
4054
4055 This attribute is ignored for R8C target.
4056
4057 @item interrupt
4058 @cindex @code{interrupt} function attribute, M32C
4059 Use this attribute to indicate
4060 that the specified function is an interrupt handler. The compiler generates
4061 function entry and exit sequences suitable for use in an interrupt handler
4062 when this attribute is present.
4063 @end table
4064
4065 @node M32R/D Function Attributes
4066 @subsection M32R/D Function Attributes
4067
4068 These function attributes are supported by the M32R/D back end:
4069
4070 @table @code
4071 @item interrupt
4072 @cindex @code{interrupt} function attribute, M32R/D
4073 Use this attribute to indicate
4074 that the specified function is an interrupt handler. The compiler generates
4075 function entry and exit sequences suitable for use in an interrupt handler
4076 when this attribute is present.
4077
4078 @item model (@var{model-name})
4079 @cindex @code{model} function attribute, M32R/D
4080 @cindex function addressability on the M32R/D
4081
4082 On the M32R/D, use this attribute to set the addressability of an
4083 object, and of the code generated for a function. The identifier
4084 @var{model-name} is one of @code{small}, @code{medium}, or
4085 @code{large}, representing each of the code models.
4086
4087 Small model objects live in the lower 16MB of memory (so that their
4088 addresses can be loaded with the @code{ld24} instruction), and are
4089 callable with the @code{bl} instruction.
4090
4091 Medium model objects may live anywhere in the 32-bit address space (the
4092 compiler generates @code{seth/add3} instructions to load their addresses),
4093 and are callable with the @code{bl} instruction.
4094
4095 Large model objects may live anywhere in the 32-bit address space (the
4096 compiler generates @code{seth/add3} instructions to load their addresses),
4097 and may not be reachable with the @code{bl} instruction (the compiler
4098 generates the much slower @code{seth/add3/jl} instruction sequence).
4099 @end table
4100
4101 @node m68k Function Attributes
4102 @subsection m68k Function Attributes
4103
4104 These function attributes are supported by the m68k back end:
4105
4106 @table @code
4107 @item interrupt
4108 @itemx interrupt_handler
4109 @cindex @code{interrupt} function attribute, m68k
4110 @cindex @code{interrupt_handler} function attribute, m68k
4111 Use this attribute to
4112 indicate that the specified function is an interrupt handler. The compiler
4113 generates function entry and exit sequences suitable for use in an
4114 interrupt handler when this attribute is present. Either name may be used.
4115
4116 @item interrupt_thread
4117 @cindex @code{interrupt_thread} function attribute, fido
4118 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4119 that the specified function is an interrupt handler that is designed
4120 to run as a thread. The compiler omits generate prologue/epilogue
4121 sequences and replaces the return instruction with a @code{sleep}
4122 instruction. This attribute is available only on fido.
4123 @end table
4124
4125 @node MCORE Function Attributes
4126 @subsection MCORE Function Attributes
4127
4128 These function attributes are supported by the MCORE back end:
4129
4130 @table @code
4131 @item naked
4132 @cindex @code{naked} function attribute, MCORE
4133 This attribute allows the compiler to construct the
4134 requisite function declaration, while allowing the body of the
4135 function to be assembly code. The specified function will not have
4136 prologue/epilogue sequences generated by the compiler. Only basic
4137 @code{asm} statements can safely be included in naked functions
4138 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4139 basic @code{asm} and C code may appear to work, they cannot be
4140 depended upon to work reliably and are not supported.
4141 @end table
4142
4143 @node MeP Function Attributes
4144 @subsection MeP Function Attributes
4145
4146 These function attributes are supported by the MeP back end:
4147
4148 @table @code
4149 @item disinterrupt
4150 @cindex @code{disinterrupt} function attribute, MeP
4151 On MeP targets, this attribute causes the compiler to emit
4152 instructions to disable interrupts for the duration of the given
4153 function.
4154
4155 @item interrupt
4156 @cindex @code{interrupt} function attribute, MeP
4157 Use this attribute to indicate
4158 that the specified function is an interrupt handler. The compiler generates
4159 function entry and exit sequences suitable for use in an interrupt handler
4160 when this attribute is present.
4161
4162 @item near
4163 @cindex @code{near} function attribute, MeP
4164 This attribute causes the compiler to assume the called
4165 function is close enough to use the normal calling convention,
4166 overriding the @option{-mtf} command-line option.
4167
4168 @item far
4169 @cindex @code{far} function attribute, MeP
4170 On MeP targets this causes the compiler to use a calling convention
4171 that assumes the called function is too far away for the built-in
4172 addressing modes.
4173
4174 @item vliw
4175 @cindex @code{vliw} function attribute, MeP
4176 The @code{vliw} attribute tells the compiler to emit
4177 instructions in VLIW mode instead of core mode. Note that this
4178 attribute is not allowed unless a VLIW coprocessor has been configured
4179 and enabled through command-line options.
4180 @end table
4181
4182 @node MicroBlaze Function Attributes
4183 @subsection MicroBlaze Function Attributes
4184
4185 These function attributes are supported on MicroBlaze targets:
4186
4187 @table @code
4188 @item save_volatiles
4189 @cindex @code{save_volatiles} function attribute, MicroBlaze
4190 Use this attribute to indicate that the function is
4191 an interrupt handler. All volatile registers (in addition to non-volatile
4192 registers) are saved in the function prologue. If the function is a leaf
4193 function, only volatiles used by the function are saved. A normal function
4194 return is generated instead of a return from interrupt.
4195
4196 @item break_handler
4197 @cindex @code{break_handler} function attribute, MicroBlaze
4198 @cindex break handler functions
4199 Use this attribute to indicate that
4200 the specified function is a break handler. The compiler generates function
4201 entry and exit sequences suitable for use in an break handler when this
4202 attribute is present. The return from @code{break_handler} is done through
4203 the @code{rtbd} instead of @code{rtsd}.
4204
4205 @smallexample
4206 void f () __attribute__ ((break_handler));
4207 @end smallexample
4208
4209 @item interrupt_handler
4210 @itemx fast_interrupt
4211 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4212 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4213 These attributes indicate that the specified function is an interrupt
4214 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4215 used in low-latency interrupt mode, and @code{interrupt_handler} for
4216 interrupts that do not use low-latency handlers. In both cases, GCC
4217 emits appropriate prologue code and generates a return from the handler
4218 using @code{rtid} instead of @code{rtsd}.
4219 @end table
4220
4221 @node Microsoft Windows Function Attributes
4222 @subsection Microsoft Windows Function Attributes
4223
4224 The following attributes are available on Microsoft Windows and Symbian OS
4225 targets.
4226
4227 @table @code
4228 @item dllexport
4229 @cindex @code{dllexport} function attribute
4230 @cindex @code{__declspec(dllexport)}
4231 On Microsoft Windows targets and Symbian OS targets the
4232 @code{dllexport} attribute causes the compiler to provide a global
4233 pointer to a pointer in a DLL, so that it can be referenced with the
4234 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4235 name is formed by combining @code{_imp__} and the function or variable
4236 name.
4237
4238 You can use @code{__declspec(dllexport)} as a synonym for
4239 @code{__attribute__ ((dllexport))} for compatibility with other
4240 compilers.
4241
4242 On systems that support the @code{visibility} attribute, this
4243 attribute also implies ``default'' visibility. It is an error to
4244 explicitly specify any other visibility.
4245
4246 GCC's default behavior is to emit all inline functions with the
4247 @code{dllexport} attribute. Since this can cause object file-size bloat,
4248 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4249 ignore the attribute for inlined functions unless the
4250 @option{-fkeep-inline-functions} flag is used instead.
4251
4252 The attribute is ignored for undefined symbols.
4253
4254 When applied to C++ classes, the attribute marks defined non-inlined
4255 member functions and static data members as exports. Static consts
4256 initialized in-class are not marked unless they are also defined
4257 out-of-class.
4258
4259 For Microsoft Windows targets there are alternative methods for
4260 including the symbol in the DLL's export table such as using a
4261 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4262 the @option{--export-all} linker flag.
4263
4264 @item dllimport
4265 @cindex @code{dllimport} function attribute
4266 @cindex @code{__declspec(dllimport)}
4267 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4268 attribute causes the compiler to reference a function or variable via
4269 a global pointer to a pointer that is set up by the DLL exporting the
4270 symbol. The attribute implies @code{extern}. On Microsoft Windows
4271 targets, the pointer name is formed by combining @code{_imp__} and the
4272 function or variable name.
4273
4274 You can use @code{__declspec(dllimport)} as a synonym for
4275 @code{__attribute__ ((dllimport))} for compatibility with other
4276 compilers.
4277
4278 On systems that support the @code{visibility} attribute, this
4279 attribute also implies ``default'' visibility. It is an error to
4280 explicitly specify any other visibility.
4281
4282 Currently, the attribute is ignored for inlined functions. If the
4283 attribute is applied to a symbol @emph{definition}, an error is reported.
4284 If a symbol previously declared @code{dllimport} is later defined, the
4285 attribute is ignored in subsequent references, and a warning is emitted.
4286 The attribute is also overridden by a subsequent declaration as
4287 @code{dllexport}.
4288
4289 When applied to C++ classes, the attribute marks non-inlined
4290 member functions and static data members as imports. However, the
4291 attribute is ignored for virtual methods to allow creation of vtables
4292 using thunks.
4293
4294 On the SH Symbian OS target the @code{dllimport} attribute also has
4295 another affect---it can cause the vtable and run-time type information
4296 for a class to be exported. This happens when the class has a
4297 dllimported constructor or a non-inline, non-pure virtual function
4298 and, for either of those two conditions, the class also has an inline
4299 constructor or destructor and has a key function that is defined in
4300 the current translation unit.
4301
4302 For Microsoft Windows targets the use of the @code{dllimport}
4303 attribute on functions is not necessary, but provides a small
4304 performance benefit by eliminating a thunk in the DLL@. The use of the
4305 @code{dllimport} attribute on imported variables can be avoided by passing the
4306 @option{--enable-auto-import} switch to the GNU linker. As with
4307 functions, using the attribute for a variable eliminates a thunk in
4308 the DLL@.
4309
4310 One drawback to using this attribute is that a pointer to a
4311 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4312 address. However, a pointer to a @emph{function} with the
4313 @code{dllimport} attribute can be used as a constant initializer; in
4314 this case, the address of a stub function in the import lib is
4315 referenced. On Microsoft Windows targets, the attribute can be disabled
4316 for functions by setting the @option{-mnop-fun-dllimport} flag.
4317 @end table
4318
4319 @node MIPS Function Attributes
4320 @subsection MIPS Function Attributes
4321
4322 These function attributes are supported by the MIPS back end:
4323
4324 @table @code
4325 @item interrupt
4326 @cindex @code{interrupt} function attribute, MIPS
4327 Use this attribute to indicate that the specified function is an interrupt
4328 handler. The compiler generates function entry and exit sequences suitable
4329 for use in an interrupt handler when this attribute is present.
4330 An optional argument is supported for the interrupt attribute which allows
4331 the interrupt mode to be described. By default GCC assumes the external
4332 interrupt controller (EIC) mode is in use, this can be explicitly set using
4333 @code{eic}. When interrupts are non-masked then the requested Interrupt
4334 Priority Level (IPL) is copied to the current IPL which has the effect of only
4335 enabling higher priority interrupts. To use vectored interrupt mode use
4336 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4337 the behavior of the non-masked interrupt support and GCC will arrange to mask
4338 all interrupts from sw0 up to and including the specified interrupt vector.
4339
4340 You can use the following attributes to modify the behavior
4341 of an interrupt handler:
4342 @table @code
4343 @item use_shadow_register_set
4344 @cindex @code{use_shadow_register_set} function attribute, MIPS
4345 Assume that the handler uses a shadow register set, instead of
4346 the main general-purpose registers. An optional argument @code{intstack} is
4347 supported to indicate that the shadow register set contains a valid stack
4348 pointer.
4349
4350 @item keep_interrupts_masked
4351 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4352 Keep interrupts masked for the whole function. Without this attribute,
4353 GCC tries to reenable interrupts for as much of the function as it can.
4354
4355 @item use_debug_exception_return
4356 @cindex @code{use_debug_exception_return} function attribute, MIPS
4357 Return using the @code{deret} instruction. Interrupt handlers that don't
4358 have this attribute return using @code{eret} instead.
4359 @end table
4360
4361 You can use any combination of these attributes, as shown below:
4362 @smallexample
4363 void __attribute__ ((interrupt)) v0 ();
4364 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4365 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4366 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4367 void __attribute__ ((interrupt, use_shadow_register_set,
4368 keep_interrupts_masked)) v4 ();
4369 void __attribute__ ((interrupt, use_shadow_register_set,
4370 use_debug_exception_return)) v5 ();
4371 void __attribute__ ((interrupt, keep_interrupts_masked,
4372 use_debug_exception_return)) v6 ();
4373 void __attribute__ ((interrupt, use_shadow_register_set,
4374 keep_interrupts_masked,
4375 use_debug_exception_return)) v7 ();
4376 void __attribute__ ((interrupt("eic"))) v8 ();
4377 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4378 @end smallexample
4379
4380 @item long_call
4381 @itemx near
4382 @itemx far
4383 @cindex indirect calls, MIPS
4384 @cindex @code{long_call} function attribute, MIPS
4385 @cindex @code{near} function attribute, MIPS
4386 @cindex @code{far} function attribute, MIPS
4387 These attributes specify how a particular function is called on MIPS@.
4388 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4389 command-line switch. The @code{long_call} and @code{far} attributes are
4390 synonyms, and cause the compiler to always call
4391 the function by first loading its address into a register, and then using
4392 the contents of that register. The @code{near} attribute has the opposite
4393 effect; it specifies that non-PIC calls should be made using the more
4394 efficient @code{jal} instruction.
4395
4396 @item mips16
4397 @itemx nomips16
4398 @cindex @code{mips16} function attribute, MIPS
4399 @cindex @code{nomips16} function attribute, MIPS
4400
4401 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4402 function attributes to locally select or turn off MIPS16 code generation.
4403 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4404 while MIPS16 code generation is disabled for functions with the
4405 @code{nomips16} attribute. These attributes override the
4406 @option{-mips16} and @option{-mno-mips16} options on the command line
4407 (@pxref{MIPS Options}).
4408
4409 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4410 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4411 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4412 may interact badly with some GCC extensions such as @code{__builtin_apply}
4413 (@pxref{Constructing Calls}).
4414
4415 @item micromips, MIPS
4416 @itemx nomicromips, MIPS
4417 @cindex @code{micromips} function attribute
4418 @cindex @code{nomicromips} function attribute
4419
4420 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4421 function attributes to locally select or turn off microMIPS code generation.
4422 A function with the @code{micromips} attribute is emitted as microMIPS code,
4423 while microMIPS code generation is disabled for functions with the
4424 @code{nomicromips} attribute. These attributes override the
4425 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4426 (@pxref{MIPS Options}).
4427
4428 When compiling files containing mixed microMIPS and non-microMIPS code, the
4429 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4430 command line,
4431 not that within individual functions. Mixed microMIPS and non-microMIPS code
4432 may interact badly with some GCC extensions such as @code{__builtin_apply}
4433 (@pxref{Constructing Calls}).
4434
4435 @item nocompression
4436 @cindex @code{nocompression} function attribute, MIPS
4437 On MIPS targets, you can use the @code{nocompression} function attribute
4438 to locally turn off MIPS16 and microMIPS code generation. This attribute
4439 overrides the @option{-mips16} and @option{-mmicromips} options on the
4440 command line (@pxref{MIPS Options}).
4441 @end table
4442
4443 @node MSP430 Function Attributes
4444 @subsection MSP430 Function Attributes
4445
4446 These function attributes are supported by the MSP430 back end:
4447
4448 @table @code
4449 @item critical
4450 @cindex @code{critical} function attribute, MSP430
4451 Critical functions disable interrupts upon entry and restore the
4452 previous interrupt state upon exit. Critical functions cannot also
4453 have the @code{naked} or @code{reentrant} attributes. They can have
4454 the @code{interrupt} attribute.
4455
4456 @item interrupt
4457 @cindex @code{interrupt} function attribute, MSP430
4458 Use this attribute to indicate
4459 that the specified function is an interrupt handler. The compiler generates
4460 function entry and exit sequences suitable for use in an interrupt handler
4461 when this attribute is present.
4462
4463 You can provide an argument to the interrupt
4464 attribute which specifies a name or number. If the argument is a
4465 number it indicates the slot in the interrupt vector table (0 - 31) to
4466 which this handler should be assigned. If the argument is a name it
4467 is treated as a symbolic name for the vector slot. These names should
4468 match up with appropriate entries in the linker script. By default
4469 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4470 @code{reset} for vector 31 are recognized.
4471
4472 @item naked
4473 @cindex @code{naked} function attribute, MSP430
4474 This attribute allows the compiler to construct the
4475 requisite function declaration, while allowing the body of the
4476 function to be assembly code. The specified function will not have
4477 prologue/epilogue sequences generated by the compiler. Only basic
4478 @code{asm} statements can safely be included in naked functions
4479 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4480 basic @code{asm} and C code may appear to work, they cannot be
4481 depended upon to work reliably and are not supported.
4482
4483 @item reentrant
4484 @cindex @code{reentrant} function attribute, MSP430
4485 Reentrant functions disable interrupts upon entry and enable them
4486 upon exit. Reentrant functions cannot also have the @code{naked}
4487 or @code{critical} attributes. They can have the @code{interrupt}
4488 attribute.
4489
4490 @item wakeup
4491 @cindex @code{wakeup} function attribute, MSP430
4492 This attribute only applies to interrupt functions. It is silently
4493 ignored if applied to a non-interrupt function. A wakeup interrupt
4494 function will rouse the processor from any low-power state that it
4495 might be in when the function exits.
4496
4497 @item lower
4498 @itemx upper
4499 @itemx either
4500 @cindex @code{lower} function attribute, MSP430
4501 @cindex @code{upper} function attribute, MSP430
4502 @cindex @code{either} function attribute, MSP430
4503 On the MSP430 target these attributes can be used to specify whether
4504 the function or variable should be placed into low memory, high
4505 memory, or the placement should be left to the linker to decide. The
4506 attributes are only significant if compiling for the MSP430X
4507 architecture.
4508
4509 The attributes work in conjunction with a linker script that has been
4510 augmented to specify where to place sections with a @code{.lower} and
4511 a @code{.upper} prefix. So, for example, as well as placing the
4512 @code{.data} section, the script also specifies the placement of a
4513 @code{.lower.data} and a @code{.upper.data} section. The intention
4514 is that @code{lower} sections are placed into a small but easier to
4515 access memory region and the upper sections are placed into a larger, but
4516 slower to access, region.
4517
4518 The @code{either} attribute is special. It tells the linker to place
4519 the object into the corresponding @code{lower} section if there is
4520 room for it. If there is insufficient room then the object is placed
4521 into the corresponding @code{upper} section instead. Note that the
4522 placement algorithm is not very sophisticated. It does not attempt to
4523 find an optimal packing of the @code{lower} sections. It just makes
4524 one pass over the objects and does the best that it can. Using the
4525 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4526 options can help the packing, however, since they produce smaller,
4527 easier to pack regions.
4528 @end table
4529
4530 @node NDS32 Function Attributes
4531 @subsection NDS32 Function Attributes
4532
4533 These function attributes are supported by the NDS32 back end:
4534
4535 @table @code
4536 @item exception
4537 @cindex @code{exception} function attribute
4538 @cindex exception handler functions, NDS32
4539 Use this attribute on the NDS32 target to indicate that the specified function
4540 is an exception handler. The compiler will generate corresponding sections
4541 for use in an exception handler.
4542
4543 @item interrupt
4544 @cindex @code{interrupt} function attribute, NDS32
4545 On NDS32 target, this attribute indicates that the specified function
4546 is an interrupt handler. The compiler generates corresponding sections
4547 for use in an interrupt handler. You can use the following attributes
4548 to modify the behavior:
4549 @table @code
4550 @item nested
4551 @cindex @code{nested} function attribute, NDS32
4552 This interrupt service routine is interruptible.
4553 @item not_nested
4554 @cindex @code{not_nested} function attribute, NDS32
4555 This interrupt service routine is not interruptible.
4556 @item nested_ready
4557 @cindex @code{nested_ready} function attribute, NDS32
4558 This interrupt service routine is interruptible after @code{PSW.GIE}
4559 (global interrupt enable) is set. This allows interrupt service routine to
4560 finish some short critical code before enabling interrupts.
4561 @item save_all
4562 @cindex @code{save_all} function attribute, NDS32
4563 The system will help save all registers into stack before entering
4564 interrupt handler.
4565 @item partial_save
4566 @cindex @code{partial_save} function attribute, NDS32
4567 The system will help save caller registers into stack before entering
4568 interrupt handler.
4569 @end table
4570
4571 @item naked
4572 @cindex @code{naked} function attribute, NDS32
4573 This attribute allows the compiler to construct the
4574 requisite function declaration, while allowing the body of the
4575 function to be assembly code. The specified function will not have
4576 prologue/epilogue sequences generated by the compiler. Only basic
4577 @code{asm} statements can safely be included in naked functions
4578 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4579 basic @code{asm} and C code may appear to work, they cannot be
4580 depended upon to work reliably and are not supported.
4581
4582 @item reset
4583 @cindex @code{reset} function attribute, NDS32
4584 @cindex reset handler functions
4585 Use this attribute on the NDS32 target to indicate that the specified function
4586 is a reset handler. The compiler will generate corresponding sections
4587 for use in a reset handler. You can use the following attributes
4588 to provide extra exception handling:
4589 @table @code
4590 @item nmi
4591 @cindex @code{nmi} function attribute, NDS32
4592 Provide a user-defined function to handle NMI exception.
4593 @item warm
4594 @cindex @code{warm} function attribute, NDS32
4595 Provide a user-defined function to handle warm reset exception.
4596 @end table
4597 @end table
4598
4599 @node Nios II Function Attributes
4600 @subsection Nios II Function Attributes
4601
4602 These function attributes are supported by the Nios II back end:
4603
4604 @table @code
4605 @item target (@var{options})
4606 @cindex @code{target} function attribute
4607 As discussed in @ref{Common Function Attributes}, this attribute
4608 allows specification of target-specific compilation options.
4609
4610 When compiling for Nios II, the following options are allowed:
4611
4612 @table @samp
4613 @item custom-@var{insn}=@var{N}
4614 @itemx no-custom-@var{insn}
4615 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4616 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4617 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4618 custom instruction with encoding @var{N} when generating code that uses
4619 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4620 the custom instruction @var{insn}.
4621 These target attributes correspond to the
4622 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4623 command-line options, and support the same set of @var{insn} keywords.
4624 @xref{Nios II Options}, for more information.
4625
4626 @item custom-fpu-cfg=@var{name}
4627 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4628 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4629 command-line option, to select a predefined set of custom instructions
4630 named @var{name}.
4631 @xref{Nios II Options}, for more information.
4632 @end table
4633 @end table
4634
4635 @node Nvidia PTX Function Attributes
4636 @subsection Nvidia PTX Function Attributes
4637
4638 These function attributes are supported by the Nvidia PTX back end:
4639
4640 @table @code
4641 @item kernel
4642 @cindex @code{kernel} attribute, Nvidia PTX
4643 This attribute indicates that the corresponding function should be compiled
4644 as a kernel function, which can be invoked from the host via the CUDA RT
4645 library.
4646 By default functions are only callable only from other PTX functions.
4647
4648 Kernel functions must have @code{void} return type.
4649 @end table
4650
4651 @node PowerPC Function Attributes
4652 @subsection PowerPC Function Attributes
4653
4654 These function attributes are supported by the PowerPC back end:
4655
4656 @table @code
4657 @item longcall
4658 @itemx shortcall
4659 @cindex indirect calls, PowerPC
4660 @cindex @code{longcall} function attribute, PowerPC
4661 @cindex @code{shortcall} function attribute, PowerPC
4662 The @code{longcall} attribute
4663 indicates that the function might be far away from the call site and
4664 require a different (more expensive) calling sequence. The
4665 @code{shortcall} attribute indicates that the function is always close
4666 enough for the shorter calling sequence to be used. These attributes
4667 override both the @option{-mlongcall} switch and
4668 the @code{#pragma longcall} setting.
4669
4670 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4671 calls are necessary.
4672
4673 @item target (@var{options})
4674 @cindex @code{target} function attribute
4675 As discussed in @ref{Common Function Attributes}, this attribute
4676 allows specification of target-specific compilation options.
4677
4678 On the PowerPC, the following options are allowed:
4679
4680 @table @samp
4681 @item altivec
4682 @itemx no-altivec
4683 @cindex @code{target("altivec")} function attribute, PowerPC
4684 Generate code that uses (does not use) AltiVec instructions. In
4685 32-bit code, you cannot enable AltiVec instructions unless
4686 @option{-mabi=altivec} is used on the command line.
4687
4688 @item cmpb
4689 @itemx no-cmpb
4690 @cindex @code{target("cmpb")} function attribute, PowerPC
4691 Generate code that uses (does not use) the compare bytes instruction
4692 implemented on the POWER6 processor and other processors that support
4693 the PowerPC V2.05 architecture.
4694
4695 @item dlmzb
4696 @itemx no-dlmzb
4697 @cindex @code{target("dlmzb")} function attribute, PowerPC
4698 Generate code that uses (does not use) the string-search @samp{dlmzb}
4699 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4700 generated by default when targeting those processors.
4701
4702 @item fprnd
4703 @itemx no-fprnd
4704 @cindex @code{target("fprnd")} function attribute, PowerPC
4705 Generate code that uses (does not use) the FP round to integer
4706 instructions implemented on the POWER5+ processor and other processors
4707 that support the PowerPC V2.03 architecture.
4708
4709 @item hard-dfp
4710 @itemx no-hard-dfp
4711 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4712 Generate code that uses (does not use) the decimal floating-point
4713 instructions implemented on some POWER processors.
4714
4715 @item isel
4716 @itemx no-isel
4717 @cindex @code{target("isel")} function attribute, PowerPC
4718 Generate code that uses (does not use) ISEL instruction.
4719
4720 @item mfcrf
4721 @itemx no-mfcrf
4722 @cindex @code{target("mfcrf")} function attribute, PowerPC
4723 Generate code that uses (does not use) the move from condition
4724 register field instruction implemented on the POWER4 processor and
4725 other processors that support the PowerPC V2.01 architecture.
4726
4727 @item mfpgpr
4728 @itemx no-mfpgpr
4729 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4730 Generate code that uses (does not use) the FP move to/from general
4731 purpose register instructions implemented on the POWER6X processor and
4732 other processors that support the extended PowerPC V2.05 architecture.
4733
4734 @item mulhw
4735 @itemx no-mulhw
4736 @cindex @code{target("mulhw")} function attribute, PowerPC
4737 Generate code that uses (does not use) the half-word multiply and
4738 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4739 These instructions are generated by default when targeting those
4740 processors.
4741
4742 @item multiple
4743 @itemx no-multiple
4744 @cindex @code{target("multiple")} function attribute, PowerPC
4745 Generate code that uses (does not use) the load multiple word
4746 instructions and the store multiple word instructions.
4747
4748 @item update
4749 @itemx no-update
4750 @cindex @code{target("update")} function attribute, PowerPC
4751 Generate code that uses (does not use) the load or store instructions
4752 that update the base register to the address of the calculated memory
4753 location.
4754
4755 @item popcntb
4756 @itemx no-popcntb
4757 @cindex @code{target("popcntb")} function attribute, PowerPC
4758 Generate code that uses (does not use) the popcount and double-precision
4759 FP reciprocal estimate instruction implemented on the POWER5
4760 processor and other processors that support the PowerPC V2.02
4761 architecture.
4762
4763 @item popcntd
4764 @itemx no-popcntd
4765 @cindex @code{target("popcntd")} function attribute, PowerPC
4766 Generate code that uses (does not use) the popcount instruction
4767 implemented on the POWER7 processor and other processors that support
4768 the PowerPC V2.06 architecture.
4769
4770 @item powerpc-gfxopt
4771 @itemx no-powerpc-gfxopt
4772 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4773 Generate code that uses (does not use) the optional PowerPC
4774 architecture instructions in the Graphics group, including
4775 floating-point select.
4776
4777 @item powerpc-gpopt
4778 @itemx no-powerpc-gpopt
4779 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4780 Generate code that uses (does not use) the optional PowerPC
4781 architecture instructions in the General Purpose group, including
4782 floating-point square root.
4783
4784 @item recip-precision
4785 @itemx no-recip-precision
4786 @cindex @code{target("recip-precision")} function attribute, PowerPC
4787 Assume (do not assume) that the reciprocal estimate instructions
4788 provide higher-precision estimates than is mandated by the PowerPC
4789 ABI.
4790
4791 @item string
4792 @itemx no-string
4793 @cindex @code{target("string")} function attribute, PowerPC
4794 Generate code that uses (does not use) the load string instructions
4795 and the store string word instructions to save multiple registers and
4796 do small block moves.
4797
4798 @item vsx
4799 @itemx no-vsx
4800 @cindex @code{target("vsx")} function attribute, PowerPC
4801 Generate code that uses (does not use) vector/scalar (VSX)
4802 instructions, and also enable the use of built-in functions that allow
4803 more direct access to the VSX instruction set. In 32-bit code, you
4804 cannot enable VSX or AltiVec instructions unless
4805 @option{-mabi=altivec} is used on the command line.
4806
4807 @item friz
4808 @itemx no-friz
4809 @cindex @code{target("friz")} function attribute, PowerPC
4810 Generate (do not generate) the @code{friz} instruction when the
4811 @option{-funsafe-math-optimizations} option is used to optimize
4812 rounding a floating-point value to 64-bit integer and back to floating
4813 point. The @code{friz} instruction does not return the same value if
4814 the floating-point number is too large to fit in an integer.
4815
4816 @item avoid-indexed-addresses
4817 @itemx no-avoid-indexed-addresses
4818 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4819 Generate code that tries to avoid (not avoid) the use of indexed load
4820 or store instructions.
4821
4822 @item paired
4823 @itemx no-paired
4824 @cindex @code{target("paired")} function attribute, PowerPC
4825 Generate code that uses (does not use) the generation of PAIRED simd
4826 instructions.
4827
4828 @item longcall
4829 @itemx no-longcall
4830 @cindex @code{target("longcall")} function attribute, PowerPC
4831 Generate code that assumes (does not assume) that all calls are far
4832 away so that a longer more expensive calling sequence is required.
4833
4834 @item cpu=@var{CPU}
4835 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4836 Specify the architecture to generate code for when compiling the
4837 function. If you select the @code{target("cpu=power7")} attribute when
4838 generating 32-bit code, VSX and AltiVec instructions are not generated
4839 unless you use the @option{-mabi=altivec} option on the command line.
4840
4841 @item tune=@var{TUNE}
4842 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4843 Specify the architecture to tune for when compiling the function. If
4844 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4845 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4846 compilation tunes for the @var{CPU} architecture, and not the
4847 default tuning specified on the command line.
4848 @end table
4849
4850 On the PowerPC, the inliner does not inline a
4851 function that has different target options than the caller, unless the
4852 callee has a subset of the target options of the caller.
4853 @end table
4854
4855 @node RL78 Function Attributes
4856 @subsection RL78 Function Attributes
4857
4858 These function attributes are supported by the RL78 back end:
4859
4860 @table @code
4861 @item interrupt
4862 @itemx brk_interrupt
4863 @cindex @code{interrupt} function attribute, RL78
4864 @cindex @code{brk_interrupt} function attribute, RL78
4865 These attributes indicate
4866 that the specified function is an interrupt handler. The compiler generates
4867 function entry and exit sequences suitable for use in an interrupt handler
4868 when this attribute is present.
4869
4870 Use @code{brk_interrupt} instead of @code{interrupt} for
4871 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4872 that must end with @code{RETB} instead of @code{RETI}).
4873
4874 @item naked
4875 @cindex @code{naked} function attribute, RL78
4876 This attribute allows the compiler to construct the
4877 requisite function declaration, while allowing the body of the
4878 function to be assembly code. The specified function will not have
4879 prologue/epilogue sequences generated by the compiler. Only basic
4880 @code{asm} statements can safely be included in naked functions
4881 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4882 basic @code{asm} and C code may appear to work, they cannot be
4883 depended upon to work reliably and are not supported.
4884 @end table
4885
4886 @node RX Function Attributes
4887 @subsection RX Function Attributes
4888
4889 These function attributes are supported by the RX back end:
4890
4891 @table @code
4892 @item fast_interrupt
4893 @cindex @code{fast_interrupt} function attribute, RX
4894 Use this attribute on the RX port to indicate that the specified
4895 function is a fast interrupt handler. This is just like the
4896 @code{interrupt} attribute, except that @code{freit} is used to return
4897 instead of @code{reit}.
4898
4899 @item interrupt
4900 @cindex @code{interrupt} function attribute, RX
4901 Use this attribute to indicate
4902 that the specified function is an interrupt handler. The compiler generates
4903 function entry and exit sequences suitable for use in an interrupt handler
4904 when this attribute is present.
4905
4906 On RX targets, you may specify one or more vector numbers as arguments
4907 to the attribute, as well as naming an alternate table name.
4908 Parameters are handled sequentially, so one handler can be assigned to
4909 multiple entries in multiple tables. One may also pass the magic
4910 string @code{"$default"} which causes the function to be used for any
4911 unfilled slots in the current table.
4912
4913 This example shows a simple assignment of a function to one vector in
4914 the default table (note that preprocessor macros may be used for
4915 chip-specific symbolic vector names):
4916 @smallexample
4917 void __attribute__ ((interrupt (5))) txd1_handler ();
4918 @end smallexample
4919
4920 This example assigns a function to two slots in the default table
4921 (using preprocessor macros defined elsewhere) and makes it the default
4922 for the @code{dct} table:
4923 @smallexample
4924 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4925 txd1_handler ();
4926 @end smallexample
4927
4928 @item naked
4929 @cindex @code{naked} function attribute, RX
4930 This attribute allows the compiler to construct the
4931 requisite function declaration, while allowing the body of the
4932 function to be assembly code. The specified function will not have
4933 prologue/epilogue sequences generated by the compiler. Only basic
4934 @code{asm} statements can safely be included in naked functions
4935 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4936 basic @code{asm} and C code may appear to work, they cannot be
4937 depended upon to work reliably and are not supported.
4938
4939 @item vector
4940 @cindex @code{vector} function attribute, RX
4941 This RX attribute is similar to the @code{interrupt} attribute, including its
4942 parameters, but does not make the function an interrupt-handler type
4943 function (i.e. it retains the normal C function calling ABI). See the
4944 @code{interrupt} attribute for a description of its arguments.
4945 @end table
4946
4947 @node S/390 Function Attributes
4948 @subsection S/390 Function Attributes
4949
4950 These function attributes are supported on the S/390:
4951
4952 @table @code
4953 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4954 @cindex @code{hotpatch} function attribute, S/390
4955
4956 On S/390 System z targets, you can use this function attribute to
4957 make GCC generate a ``hot-patching'' function prologue. If the
4958 @option{-mhotpatch=} command-line option is used at the same time,
4959 the @code{hotpatch} attribute takes precedence. The first of the
4960 two arguments specifies the number of halfwords to be added before
4961 the function label. A second argument can be used to specify the
4962 number of halfwords to be added after the function label. For
4963 both arguments the maximum allowed value is 1000000.
4964
4965 If both arguments are zero, hotpatching is disabled.
4966
4967 @item target (@var{options})
4968 @cindex @code{target} function attribute
4969 As discussed in @ref{Common Function Attributes}, this attribute
4970 allows specification of target-specific compilation options.
4971
4972 On S/390, the following options are supported:
4973
4974 @table @samp
4975 @item arch=
4976 @item tune=
4977 @item stack-guard=
4978 @item stack-size=
4979 @item branch-cost=
4980 @item warn-framesize=
4981 @item backchain
4982 @itemx no-backchain
4983 @item hard-dfp
4984 @itemx no-hard-dfp
4985 @item hard-float
4986 @itemx soft-float
4987 @item htm
4988 @itemx no-htm
4989 @item vx
4990 @itemx no-vx
4991 @item packed-stack
4992 @itemx no-packed-stack
4993 @item small-exec
4994 @itemx no-small-exec
4995 @item mvcle
4996 @itemx no-mvcle
4997 @item warn-dynamicstack
4998 @itemx no-warn-dynamicstack
4999 @end table
5000
5001 The options work exactly like the S/390 specific command line
5002 options (without the prefix @option{-m}) except that they do not
5003 change any feature macros. For example,
5004
5005 @smallexample
5006 @code{target("no-vx")}
5007 @end smallexample
5008
5009 does not undefine the @code{__VEC__} macro.
5010 @end table
5011
5012 @node SH Function Attributes
5013 @subsection SH Function Attributes
5014
5015 These function attributes are supported on the SH family of processors:
5016
5017 @table @code
5018 @item function_vector
5019 @cindex @code{function_vector} function attribute, SH
5020 @cindex calling functions through the function vector on SH2A
5021 On SH2A targets, this attribute declares a function to be called using the
5022 TBR relative addressing mode. The argument to this attribute is the entry
5023 number of the same function in a vector table containing all the TBR
5024 relative addressable functions. For correct operation the TBR must be setup
5025 accordingly to point to the start of the vector table before any functions with
5026 this attribute are invoked. Usually a good place to do the initialization is
5027 the startup routine. The TBR relative vector table can have at max 256 function
5028 entries. The jumps to these functions are generated using a SH2A specific,
5029 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5030 from GNU binutils version 2.7 or later for this attribute to work correctly.
5031
5032 In an application, for a function being called once, this attribute
5033 saves at least 8 bytes of code; and if other successive calls are being
5034 made to the same function, it saves 2 bytes of code per each of these
5035 calls.
5036
5037 @item interrupt_handler
5038 @cindex @code{interrupt_handler} function attribute, SH
5039 Use this attribute to
5040 indicate that the specified function is an interrupt handler. The compiler
5041 generates function entry and exit sequences suitable for use in an
5042 interrupt handler when this attribute is present.
5043
5044 @item nosave_low_regs
5045 @cindex @code{nosave_low_regs} function attribute, SH
5046 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5047 function should not save and restore registers R0..R7. This can be used on SH3*
5048 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5049 interrupt handlers.
5050
5051 @item renesas
5052 @cindex @code{renesas} function attribute, SH
5053 On SH targets this attribute specifies that the function or struct follows the
5054 Renesas ABI.
5055
5056 @item resbank
5057 @cindex @code{resbank} function attribute, SH
5058 On the SH2A target, this attribute enables the high-speed register
5059 saving and restoration using a register bank for @code{interrupt_handler}
5060 routines. Saving to the bank is performed automatically after the CPU
5061 accepts an interrupt that uses a register bank.
5062
5063 The nineteen 32-bit registers comprising general register R0 to R14,
5064 control register GBR, and system registers MACH, MACL, and PR and the
5065 vector table address offset are saved into a register bank. Register
5066 banks are stacked in first-in last-out (FILO) sequence. Restoration
5067 from the bank is executed by issuing a RESBANK instruction.
5068
5069 @item sp_switch
5070 @cindex @code{sp_switch} function attribute, SH
5071 Use this attribute on the SH to indicate an @code{interrupt_handler}
5072 function should switch to an alternate stack. It expects a string
5073 argument that names a global variable holding the address of the
5074 alternate stack.
5075
5076 @smallexample
5077 void *alt_stack;
5078 void f () __attribute__ ((interrupt_handler,
5079 sp_switch ("alt_stack")));
5080 @end smallexample
5081
5082 @item trap_exit
5083 @cindex @code{trap_exit} function attribute, SH
5084 Use this attribute on the SH for an @code{interrupt_handler} to return using
5085 @code{trapa} instead of @code{rte}. This attribute expects an integer
5086 argument specifying the trap number to be used.
5087
5088 @item trapa_handler
5089 @cindex @code{trapa_handler} function attribute, SH
5090 On SH targets this function attribute is similar to @code{interrupt_handler}
5091 but it does not save and restore all registers.
5092 @end table
5093
5094 @node SPU Function Attributes
5095 @subsection SPU Function Attributes
5096
5097 These function attributes are supported by the SPU back end:
5098
5099 @table @code
5100 @item naked
5101 @cindex @code{naked} function attribute, SPU
5102 This attribute allows the compiler to construct the
5103 requisite function declaration, while allowing the body of the
5104 function to be assembly code. The specified function will not have
5105 prologue/epilogue sequences generated by the compiler. Only basic
5106 @code{asm} statements can safely be included in naked functions
5107 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5108 basic @code{asm} and C code may appear to work, they cannot be
5109 depended upon to work reliably and are not supported.
5110 @end table
5111
5112 @node Symbian OS Function Attributes
5113 @subsection Symbian OS Function Attributes
5114
5115 @xref{Microsoft Windows Function Attributes}, for discussion of the
5116 @code{dllexport} and @code{dllimport} attributes.
5117
5118 @node V850 Function Attributes
5119 @subsection V850 Function Attributes
5120
5121 The V850 back end supports these function attributes:
5122
5123 @table @code
5124 @item interrupt
5125 @itemx interrupt_handler
5126 @cindex @code{interrupt} function attribute, V850
5127 @cindex @code{interrupt_handler} function attribute, V850
5128 Use these attributes to indicate
5129 that the specified function is an interrupt handler. The compiler generates
5130 function entry and exit sequences suitable for use in an interrupt handler
5131 when either attribute is present.
5132 @end table
5133
5134 @node Visium Function Attributes
5135 @subsection Visium Function Attributes
5136
5137 These function attributes are supported by the Visium back end:
5138
5139 @table @code
5140 @item interrupt
5141 @cindex @code{interrupt} function attribute, Visium
5142 Use this attribute to indicate
5143 that the specified function is an interrupt handler. The compiler generates
5144 function entry and exit sequences suitable for use in an interrupt handler
5145 when this attribute is present.
5146 @end table
5147
5148 @node x86 Function Attributes
5149 @subsection x86 Function Attributes
5150
5151 These function attributes are supported by the x86 back end:
5152
5153 @table @code
5154 @item cdecl
5155 @cindex @code{cdecl} function attribute, x86-32
5156 @cindex functions that pop the argument stack on x86-32
5157 @opindex mrtd
5158 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5159 assume that the calling function pops off the stack space used to
5160 pass arguments. This is
5161 useful to override the effects of the @option{-mrtd} switch.
5162
5163 @item fastcall
5164 @cindex @code{fastcall} function attribute, x86-32
5165 @cindex functions that pop the argument stack on x86-32
5166 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5167 pass the first argument (if of integral type) in the register ECX and
5168 the second argument (if of integral type) in the register EDX@. Subsequent
5169 and other typed arguments are passed on the stack. The called function
5170 pops the arguments off the stack. If the number of arguments is variable all
5171 arguments are pushed on the stack.
5172
5173 @item thiscall
5174 @cindex @code{thiscall} function attribute, x86-32
5175 @cindex functions that pop the argument stack on x86-32
5176 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5177 pass the first argument (if of integral type) in the register ECX.
5178 Subsequent and other typed arguments are passed on the stack. The called
5179 function pops the arguments off the stack.
5180 If the number of arguments is variable all arguments are pushed on the
5181 stack.
5182 The @code{thiscall} attribute is intended for C++ non-static member functions.
5183 As a GCC extension, this calling convention can be used for C functions
5184 and for static member methods.
5185
5186 @item ms_abi
5187 @itemx sysv_abi
5188 @cindex @code{ms_abi} function attribute, x86
5189 @cindex @code{sysv_abi} function attribute, x86
5190
5191 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5192 to indicate which calling convention should be used for a function. The
5193 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5194 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5195 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5196 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5197
5198 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5199 requires the @option{-maccumulate-outgoing-args} option.
5200
5201 @item callee_pop_aggregate_return (@var{number})
5202 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5203
5204 On x86-32 targets, you can use this attribute to control how
5205 aggregates are returned in memory. If the caller is responsible for
5206 popping the hidden pointer together with the rest of the arguments, specify
5207 @var{number} equal to zero. If callee is responsible for popping the
5208 hidden pointer, specify @var{number} equal to one.
5209
5210 The default x86-32 ABI assumes that the callee pops the
5211 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5212 the compiler assumes that the
5213 caller pops the stack for hidden pointer.
5214
5215 @item ms_hook_prologue
5216 @cindex @code{ms_hook_prologue} function attribute, x86
5217
5218 On 32-bit and 64-bit x86 targets, you can use
5219 this function attribute to make GCC generate the ``hot-patching'' function
5220 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5221 and newer.
5222
5223 @item regparm (@var{number})
5224 @cindex @code{regparm} function attribute, x86
5225 @cindex functions that are passed arguments in registers on x86-32
5226 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5227 pass arguments number one to @var{number} if they are of integral type
5228 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5229 take a variable number of arguments continue to be passed all of their
5230 arguments on the stack.
5231
5232 Beware that on some ELF systems this attribute is unsuitable for
5233 global functions in shared libraries with lazy binding (which is the
5234 default). Lazy binding sends the first call via resolving code in
5235 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5236 per the standard calling conventions. Solaris 8 is affected by this.
5237 Systems with the GNU C Library version 2.1 or higher
5238 and FreeBSD are believed to be
5239 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5240 disabled with the linker or the loader if desired, to avoid the
5241 problem.)
5242
5243 @item sseregparm
5244 @cindex @code{sseregparm} function attribute, x86
5245 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5246 causes the compiler to pass up to 3 floating-point arguments in
5247 SSE registers instead of on the stack. Functions that take a
5248 variable number of arguments continue to pass all of their
5249 floating-point arguments on the stack.
5250
5251 @item force_align_arg_pointer
5252 @cindex @code{force_align_arg_pointer} function attribute, x86
5253 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5254 applied to individual function definitions, generating an alternate
5255 prologue and epilogue that realigns the run-time stack if necessary.
5256 This supports mixing legacy codes that run with a 4-byte aligned stack
5257 with modern codes that keep a 16-byte stack for SSE compatibility.
5258
5259 @item stdcall
5260 @cindex @code{stdcall} function attribute, x86-32
5261 @cindex functions that pop the argument stack on x86-32
5262 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5263 assume that the called function pops off the stack space used to
5264 pass arguments, unless it takes a variable number of arguments.
5265
5266 @item target (@var{options})
5267 @cindex @code{target} function attribute
5268 As discussed in @ref{Common Function Attributes}, this attribute
5269 allows specification of target-specific compilation options.
5270
5271 On the x86, the following options are allowed:
5272 @table @samp
5273 @item abm
5274 @itemx no-abm
5275 @cindex @code{target("abm")} function attribute, x86
5276 Enable/disable the generation of the advanced bit instructions.
5277
5278 @item aes
5279 @itemx no-aes
5280 @cindex @code{target("aes")} function attribute, x86
5281 Enable/disable the generation of the AES instructions.
5282
5283 @item default
5284 @cindex @code{target("default")} function attribute, x86
5285 @xref{Function Multiversioning}, where it is used to specify the
5286 default function version.
5287
5288 @item mmx
5289 @itemx no-mmx
5290 @cindex @code{target("mmx")} function attribute, x86
5291 Enable/disable the generation of the MMX instructions.
5292
5293 @item pclmul
5294 @itemx no-pclmul
5295 @cindex @code{target("pclmul")} function attribute, x86
5296 Enable/disable the generation of the PCLMUL instructions.
5297
5298 @item popcnt
5299 @itemx no-popcnt
5300 @cindex @code{target("popcnt")} function attribute, x86
5301 Enable/disable the generation of the POPCNT instruction.
5302
5303 @item sse
5304 @itemx no-sse
5305 @cindex @code{target("sse")} function attribute, x86
5306 Enable/disable the generation of the SSE instructions.
5307
5308 @item sse2
5309 @itemx no-sse2
5310 @cindex @code{target("sse2")} function attribute, x86
5311 Enable/disable the generation of the SSE2 instructions.
5312
5313 @item sse3
5314 @itemx no-sse3
5315 @cindex @code{target("sse3")} function attribute, x86
5316 Enable/disable the generation of the SSE3 instructions.
5317
5318 @item sse4
5319 @itemx no-sse4
5320 @cindex @code{target("sse4")} function attribute, x86
5321 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5322 and SSE4.2).
5323
5324 @item sse4.1
5325 @itemx no-sse4.1
5326 @cindex @code{target("sse4.1")} function attribute, x86
5327 Enable/disable the generation of the sse4.1 instructions.
5328
5329 @item sse4.2
5330 @itemx no-sse4.2
5331 @cindex @code{target("sse4.2")} function attribute, x86
5332 Enable/disable the generation of the sse4.2 instructions.
5333
5334 @item sse4a
5335 @itemx no-sse4a
5336 @cindex @code{target("sse4a")} function attribute, x86
5337 Enable/disable the generation of the SSE4A instructions.
5338
5339 @item fma4
5340 @itemx no-fma4
5341 @cindex @code{target("fma4")} function attribute, x86
5342 Enable/disable the generation of the FMA4 instructions.
5343
5344 @item xop
5345 @itemx no-xop
5346 @cindex @code{target("xop")} function attribute, x86
5347 Enable/disable the generation of the XOP instructions.
5348
5349 @item lwp
5350 @itemx no-lwp
5351 @cindex @code{target("lwp")} function attribute, x86
5352 Enable/disable the generation of the LWP instructions.
5353
5354 @item ssse3
5355 @itemx no-ssse3
5356 @cindex @code{target("ssse3")} function attribute, x86
5357 Enable/disable the generation of the SSSE3 instructions.
5358
5359 @item cld
5360 @itemx no-cld
5361 @cindex @code{target("cld")} function attribute, x86
5362 Enable/disable the generation of the CLD before string moves.
5363
5364 @item fancy-math-387
5365 @itemx no-fancy-math-387
5366 @cindex @code{target("fancy-math-387")} function attribute, x86
5367 Enable/disable the generation of the @code{sin}, @code{cos}, and
5368 @code{sqrt} instructions on the 387 floating-point unit.
5369
5370 @item fused-madd
5371 @itemx no-fused-madd
5372 @cindex @code{target("fused-madd")} function attribute, x86
5373 Enable/disable the generation of the fused multiply/add instructions.
5374
5375 @item ieee-fp
5376 @itemx no-ieee-fp
5377 @cindex @code{target("ieee-fp")} function attribute, x86
5378 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5379
5380 @item inline-all-stringops
5381 @itemx no-inline-all-stringops
5382 @cindex @code{target("inline-all-stringops")} function attribute, x86
5383 Enable/disable inlining of string operations.
5384
5385 @item inline-stringops-dynamically
5386 @itemx no-inline-stringops-dynamically
5387 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5388 Enable/disable the generation of the inline code to do small string
5389 operations and calling the library routines for large operations.
5390
5391 @item align-stringops
5392 @itemx no-align-stringops
5393 @cindex @code{target("align-stringops")} function attribute, x86
5394 Do/do not align destination of inlined string operations.
5395
5396 @item recip
5397 @itemx no-recip
5398 @cindex @code{target("recip")} function attribute, x86
5399 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5400 instructions followed an additional Newton-Raphson step instead of
5401 doing a floating-point division.
5402
5403 @item arch=@var{ARCH}
5404 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5405 Specify the architecture to generate code for in compiling the function.
5406
5407 @item tune=@var{TUNE}
5408 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5409 Specify the architecture to tune for in compiling the function.
5410
5411 @item fpmath=@var{FPMATH}
5412 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5413 Specify which floating-point unit to use. You must specify the
5414 @code{target("fpmath=sse,387")} option as
5415 @code{target("fpmath=sse+387")} because the comma would separate
5416 different options.
5417 @end table
5418
5419 On the x86, the inliner does not inline a
5420 function that has different target options than the caller, unless the
5421 callee has a subset of the target options of the caller. For example
5422 a function declared with @code{target("sse3")} can inline a function
5423 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5424 @end table
5425
5426 @node Xstormy16 Function Attributes
5427 @subsection Xstormy16 Function Attributes
5428
5429 These function attributes are supported by the Xstormy16 back end:
5430
5431 @table @code
5432 @item interrupt
5433 @cindex @code{interrupt} function attribute, Xstormy16
5434 Use this attribute to indicate
5435 that the specified function is an interrupt handler. The compiler generates
5436 function entry and exit sequences suitable for use in an interrupt handler
5437 when this attribute is present.
5438 @end table
5439
5440 @node Variable Attributes
5441 @section Specifying Attributes of Variables
5442 @cindex attribute of variables
5443 @cindex variable attributes
5444
5445 The keyword @code{__attribute__} allows you to specify special
5446 attributes of variables or structure fields. This keyword is followed
5447 by an attribute specification inside double parentheses. Some
5448 attributes are currently defined generically for variables.
5449 Other attributes are defined for variables on particular target
5450 systems. Other attributes are available for functions
5451 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5452 enumerators (@pxref{Enumerator Attributes}), and for types
5453 (@pxref{Type Attributes}).
5454 Other front ends might define more attributes
5455 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5456
5457 @xref{Attribute Syntax}, for details of the exact syntax for using
5458 attributes.
5459
5460 @menu
5461 * Common Variable Attributes::
5462 * AVR Variable Attributes::
5463 * Blackfin Variable Attributes::
5464 * H8/300 Variable Attributes::
5465 * IA-64 Variable Attributes::
5466 * M32R/D Variable Attributes::
5467 * MeP Variable Attributes::
5468 * Microsoft Windows Variable Attributes::
5469 * MSP430 Variable Attributes::
5470 * PowerPC Variable Attributes::
5471 * RL78 Variable Attributes::
5472 * SPU Variable Attributes::
5473 * V850 Variable Attributes::
5474 * x86 Variable Attributes::
5475 * Xstormy16 Variable Attributes::
5476 @end menu
5477
5478 @node Common Variable Attributes
5479 @subsection Common Variable Attributes
5480
5481 The following attributes are supported on most targets.
5482
5483 @table @code
5484 @cindex @code{aligned} variable attribute
5485 @item aligned (@var{alignment})
5486 This attribute specifies a minimum alignment for the variable or
5487 structure field, measured in bytes. For example, the declaration:
5488
5489 @smallexample
5490 int x __attribute__ ((aligned (16))) = 0;
5491 @end smallexample
5492
5493 @noindent
5494 causes the compiler to allocate the global variable @code{x} on a
5495 16-byte boundary. On a 68040, this could be used in conjunction with
5496 an @code{asm} expression to access the @code{move16} instruction which
5497 requires 16-byte aligned operands.
5498
5499 You can also specify the alignment of structure fields. For example, to
5500 create a double-word aligned @code{int} pair, you could write:
5501
5502 @smallexample
5503 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5504 @end smallexample
5505
5506 @noindent
5507 This is an alternative to creating a union with a @code{double} member,
5508 which forces the union to be double-word aligned.
5509
5510 As in the preceding examples, you can explicitly specify the alignment
5511 (in bytes) that you wish the compiler to use for a given variable or
5512 structure field. Alternatively, you can leave out the alignment factor
5513 and just ask the compiler to align a variable or field to the
5514 default alignment for the target architecture you are compiling for.
5515 The default alignment is sufficient for all scalar types, but may not be
5516 enough for all vector types on a target that supports vector operations.
5517 The default alignment is fixed for a particular target ABI.
5518
5519 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5520 which is the largest alignment ever used for any data type on the
5521 target machine you are compiling for. For example, you could write:
5522
5523 @smallexample
5524 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5525 @end smallexample
5526
5527 The compiler automatically sets the alignment for the declared
5528 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5529 often make copy operations more efficient, because the compiler can
5530 use whatever instructions copy the biggest chunks of memory when
5531 performing copies to or from the variables or fields that you have
5532 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5533 may change depending on command-line options.
5534
5535 When used on a struct, or struct member, the @code{aligned} attribute can
5536 only increase the alignment; in order to decrease it, the @code{packed}
5537 attribute must be specified as well. When used as part of a typedef, the
5538 @code{aligned} attribute can both increase and decrease alignment, and
5539 specifying the @code{packed} attribute generates a warning.
5540
5541 Note that the effectiveness of @code{aligned} attributes may be limited
5542 by inherent limitations in your linker. On many systems, the linker is
5543 only able to arrange for variables to be aligned up to a certain maximum
5544 alignment. (For some linkers, the maximum supported alignment may
5545 be very very small.) If your linker is only able to align variables
5546 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5547 in an @code{__attribute__} still only provides you with 8-byte
5548 alignment. See your linker documentation for further information.
5549
5550 The @code{aligned} attribute can also be used for functions
5551 (@pxref{Common Function Attributes}.)
5552
5553 @item cleanup (@var{cleanup_function})
5554 @cindex @code{cleanup} variable attribute
5555 The @code{cleanup} attribute runs a function when the variable goes
5556 out of scope. This attribute can only be applied to auto function
5557 scope variables; it may not be applied to parameters or variables
5558 with static storage duration. The function must take one parameter,
5559 a pointer to a type compatible with the variable. The return value
5560 of the function (if any) is ignored.
5561
5562 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5563 is run during the stack unwinding that happens during the
5564 processing of the exception. Note that the @code{cleanup} attribute
5565 does not allow the exception to be caught, only to perform an action.
5566 It is undefined what happens if @var{cleanup_function} does not
5567 return normally.
5568
5569 @item common
5570 @itemx nocommon
5571 @cindex @code{common} variable attribute
5572 @cindex @code{nocommon} variable attribute
5573 @opindex fcommon
5574 @opindex fno-common
5575 The @code{common} attribute requests GCC to place a variable in
5576 ``common'' storage. The @code{nocommon} attribute requests the
5577 opposite---to allocate space for it directly.
5578
5579 These attributes override the default chosen by the
5580 @option{-fno-common} and @option{-fcommon} flags respectively.
5581
5582 @item deprecated
5583 @itemx deprecated (@var{msg})
5584 @cindex @code{deprecated} variable attribute
5585 The @code{deprecated} attribute results in a warning if the variable
5586 is used anywhere in the source file. This is useful when identifying
5587 variables that are expected to be removed in a future version of a
5588 program. The warning also includes the location of the declaration
5589 of the deprecated variable, to enable users to easily find further
5590 information about why the variable is deprecated, or what they should
5591 do instead. Note that the warning only occurs for uses:
5592
5593 @smallexample
5594 extern int old_var __attribute__ ((deprecated));
5595 extern int old_var;
5596 int new_fn () @{ return old_var; @}
5597 @end smallexample
5598
5599 @noindent
5600 results in a warning on line 3 but not line 2. The optional @var{msg}
5601 argument, which must be a string, is printed in the warning if
5602 present.
5603
5604 The @code{deprecated} attribute can also be used for functions and
5605 types (@pxref{Common Function Attributes},
5606 @pxref{Common Type Attributes}).
5607
5608 @item mode (@var{mode})
5609 @cindex @code{mode} variable attribute
5610 This attribute specifies the data type for the declaration---whichever
5611 type corresponds to the mode @var{mode}. This in effect lets you
5612 request an integer or floating-point type according to its width.
5613
5614 You may also specify a mode of @code{byte} or @code{__byte__} to
5615 indicate the mode corresponding to a one-byte integer, @code{word} or
5616 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5617 or @code{__pointer__} for the mode used to represent pointers.
5618
5619 @item packed
5620 @cindex @code{packed} variable attribute
5621 The @code{packed} attribute specifies that a variable or structure field
5622 should have the smallest possible alignment---one byte for a variable,
5623 and one bit for a field, unless you specify a larger value with the
5624 @code{aligned} attribute.
5625
5626 Here is a structure in which the field @code{x} is packed, so that it
5627 immediately follows @code{a}:
5628
5629 @smallexample
5630 struct foo
5631 @{
5632 char a;
5633 int x[2] __attribute__ ((packed));
5634 @};
5635 @end smallexample
5636
5637 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5638 @code{packed} attribute on bit-fields of type @code{char}. This has
5639 been fixed in GCC 4.4 but the change can lead to differences in the
5640 structure layout. See the documentation of
5641 @option{-Wpacked-bitfield-compat} for more information.
5642
5643 @item section ("@var{section-name}")
5644 @cindex @code{section} variable attribute
5645 Normally, the compiler places the objects it generates in sections like
5646 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5647 or you need certain particular variables to appear in special sections,
5648 for example to map to special hardware. The @code{section}
5649 attribute specifies that a variable (or function) lives in a particular
5650 section. For example, this small program uses several specific section names:
5651
5652 @smallexample
5653 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5654 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5655 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5656 int init_data __attribute__ ((section ("INITDATA")));
5657
5658 main()
5659 @{
5660 /* @r{Initialize stack pointer} */
5661 init_sp (stack + sizeof (stack));
5662
5663 /* @r{Initialize initialized data} */
5664 memcpy (&init_data, &data, &edata - &data);
5665
5666 /* @r{Turn on the serial ports} */
5667 init_duart (&a);
5668 init_duart (&b);
5669 @}
5670 @end smallexample
5671
5672 @noindent
5673 Use the @code{section} attribute with
5674 @emph{global} variables and not @emph{local} variables,
5675 as shown in the example.
5676
5677 You may use the @code{section} attribute with initialized or
5678 uninitialized global variables but the linker requires
5679 each object be defined once, with the exception that uninitialized
5680 variables tentatively go in the @code{common} (or @code{bss}) section
5681 and can be multiply ``defined''. Using the @code{section} attribute
5682 changes what section the variable goes into and may cause the
5683 linker to issue an error if an uninitialized variable has multiple
5684 definitions. You can force a variable to be initialized with the
5685 @option{-fno-common} flag or the @code{nocommon} attribute.
5686
5687 Some file formats do not support arbitrary sections so the @code{section}
5688 attribute is not available on all platforms.
5689 If you need to map the entire contents of a module to a particular
5690 section, consider using the facilities of the linker instead.
5691
5692 @item tls_model ("@var{tls_model}")
5693 @cindex @code{tls_model} variable attribute
5694 The @code{tls_model} attribute sets thread-local storage model
5695 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5696 overriding @option{-ftls-model=} command-line switch on a per-variable
5697 basis.
5698 The @var{tls_model} argument should be one of @code{global-dynamic},
5699 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5700
5701 Not all targets support this attribute.
5702
5703 @item unused
5704 @cindex @code{unused} variable attribute
5705 This attribute, attached to a variable, means that the variable is meant
5706 to be possibly unused. GCC does not produce a warning for this
5707 variable.
5708
5709 @item used
5710 @cindex @code{used} variable attribute
5711 This attribute, attached to a variable with static storage, means that
5712 the variable must be emitted even if it appears that the variable is not
5713 referenced.
5714
5715 When applied to a static data member of a C++ class template, the
5716 attribute also means that the member is instantiated if the
5717 class itself is instantiated.
5718
5719 @item vector_size (@var{bytes})
5720 @cindex @code{vector_size} variable attribute
5721 This attribute specifies the vector size for the variable, measured in
5722 bytes. For example, the declaration:
5723
5724 @smallexample
5725 int foo __attribute__ ((vector_size (16)));
5726 @end smallexample
5727
5728 @noindent
5729 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5730 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5731 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5732
5733 This attribute is only applicable to integral and float scalars,
5734 although arrays, pointers, and function return values are allowed in
5735 conjunction with this construct.
5736
5737 Aggregates with this attribute are invalid, even if they are of the same
5738 size as a corresponding scalar. For example, the declaration:
5739
5740 @smallexample
5741 struct S @{ int a; @};
5742 struct S __attribute__ ((vector_size (16))) foo;
5743 @end smallexample
5744
5745 @noindent
5746 is invalid even if the size of the structure is the same as the size of
5747 the @code{int}.
5748
5749 @item visibility ("@var{visibility_type}")
5750 @cindex @code{visibility} variable attribute
5751 This attribute affects the linkage of the declaration to which it is attached.
5752 The @code{visibility} attribute is described in
5753 @ref{Common Function Attributes}.
5754
5755 @item weak
5756 @cindex @code{weak} variable attribute
5757 The @code{weak} attribute is described in
5758 @ref{Common Function Attributes}.
5759
5760 @end table
5761
5762 @node AVR Variable Attributes
5763 @subsection AVR Variable Attributes
5764
5765 @table @code
5766 @item progmem
5767 @cindex @code{progmem} variable attribute, AVR
5768 The @code{progmem} attribute is used on the AVR to place read-only
5769 data in the non-volatile program memory (flash). The @code{progmem}
5770 attribute accomplishes this by putting respective variables into a
5771 section whose name starts with @code{.progmem}.
5772
5773 This attribute works similar to the @code{section} attribute
5774 but adds additional checking. Notice that just like the
5775 @code{section} attribute, @code{progmem} affects the location
5776 of the data but not how this data is accessed.
5777
5778 In order to read data located with the @code{progmem} attribute
5779 (inline) assembler must be used.
5780 @smallexample
5781 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5782 #include <avr/pgmspace.h>
5783
5784 /* Locate var in flash memory */
5785 const int var[2] PROGMEM = @{ 1, 2 @};
5786
5787 int read_var (int i)
5788 @{
5789 /* Access var[] by accessor macro from avr/pgmspace.h */
5790 return (int) pgm_read_word (& var[i]);
5791 @}
5792 @end smallexample
5793
5794 AVR is a Harvard architecture processor and data and read-only data
5795 normally resides in the data memory (RAM).
5796
5797 See also the @ref{AVR Named Address Spaces} section for
5798 an alternate way to locate and access data in flash memory.
5799
5800 @item io
5801 @itemx io (@var{addr})
5802 @cindex @code{io} variable attribute, AVR
5803 Variables with the @code{io} attribute are used to address
5804 memory-mapped peripherals in the io address range.
5805 If an address is specified, the variable
5806 is assigned that address, and the value is interpreted as an
5807 address in the data address space.
5808 Example:
5809
5810 @smallexample
5811 volatile int porta __attribute__((io (0x22)));
5812 @end smallexample
5813
5814 The address specified in the address in the data address range.
5815
5816 Otherwise, the variable it is not assigned an address, but the
5817 compiler will still use in/out instructions where applicable,
5818 assuming some other module assigns an address in the io address range.
5819 Example:
5820
5821 @smallexample
5822 extern volatile int porta __attribute__((io));
5823 @end smallexample
5824
5825 @item io_low
5826 @itemx io_low (@var{addr})
5827 @cindex @code{io_low} variable attribute, AVR
5828 This is like the @code{io} attribute, but additionally it informs the
5829 compiler that the object lies in the lower half of the I/O area,
5830 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5831 instructions.
5832
5833 @item address
5834 @itemx address (@var{addr})
5835 @cindex @code{address} variable attribute, AVR
5836 Variables with the @code{address} attribute are used to address
5837 memory-mapped peripherals that may lie outside the io address range.
5838
5839 @smallexample
5840 volatile int porta __attribute__((address (0x600)));
5841 @end smallexample
5842
5843 @end table
5844
5845 @node Blackfin Variable Attributes
5846 @subsection Blackfin Variable Attributes
5847
5848 Three attributes are currently defined for the Blackfin.
5849
5850 @table @code
5851 @item l1_data
5852 @itemx l1_data_A
5853 @itemx l1_data_B
5854 @cindex @code{l1_data} variable attribute, Blackfin
5855 @cindex @code{l1_data_A} variable attribute, Blackfin
5856 @cindex @code{l1_data_B} variable attribute, Blackfin
5857 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5858 Variables with @code{l1_data} attribute are put into the specific section
5859 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5860 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5861 attribute are put into the specific section named @code{.l1.data.B}.
5862
5863 @item l2
5864 @cindex @code{l2} variable attribute, Blackfin
5865 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5866 Variables with @code{l2} attribute are put into the specific section
5867 named @code{.l2.data}.
5868 @end table
5869
5870 @node H8/300 Variable Attributes
5871 @subsection H8/300 Variable Attributes
5872
5873 These variable attributes are available for H8/300 targets:
5874
5875 @table @code
5876 @item eightbit_data
5877 @cindex @code{eightbit_data} variable attribute, H8/300
5878 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5879 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5880 variable should be placed into the eight-bit data section.
5881 The compiler generates more efficient code for certain operations
5882 on data in the eight-bit data area. Note the eight-bit data area is limited to
5883 256 bytes of data.
5884
5885 You must use GAS and GLD from GNU binutils version 2.7 or later for
5886 this attribute to work correctly.
5887
5888 @item tiny_data
5889 @cindex @code{tiny_data} variable attribute, H8/300
5890 @cindex tiny data section on the H8/300H and H8S
5891 Use this attribute on the H8/300H and H8S to indicate that the specified
5892 variable should be placed into the tiny data section.
5893 The compiler generates more efficient code for loads and stores
5894 on data in the tiny data section. Note the tiny data area is limited to
5895 slightly under 32KB of data.
5896
5897 @end table
5898
5899 @node IA-64 Variable Attributes
5900 @subsection IA-64 Variable Attributes
5901
5902 The IA-64 back end supports the following variable attribute:
5903
5904 @table @code
5905 @item model (@var{model-name})
5906 @cindex @code{model} variable attribute, IA-64
5907
5908 On IA-64, use this attribute to set the addressability of an object.
5909 At present, the only supported identifier for @var{model-name} is
5910 @code{small}, indicating addressability via ``small'' (22-bit)
5911 addresses (so that their addresses can be loaded with the @code{addl}
5912 instruction). Caveat: such addressing is by definition not position
5913 independent and hence this attribute must not be used for objects
5914 defined by shared libraries.
5915
5916 @end table
5917
5918 @node M32R/D Variable Attributes
5919 @subsection M32R/D Variable Attributes
5920
5921 One attribute is currently defined for the M32R/D@.
5922
5923 @table @code
5924 @item model (@var{model-name})
5925 @cindex @code{model-name} variable attribute, M32R/D
5926 @cindex variable addressability on the M32R/D
5927 Use this attribute on the M32R/D to set the addressability of an object.
5928 The identifier @var{model-name} is one of @code{small}, @code{medium},
5929 or @code{large}, representing each of the code models.
5930
5931 Small model objects live in the lower 16MB of memory (so that their
5932 addresses can be loaded with the @code{ld24} instruction).
5933
5934 Medium and large model objects may live anywhere in the 32-bit address space
5935 (the compiler generates @code{seth/add3} instructions to load their
5936 addresses).
5937 @end table
5938
5939 @node MeP Variable Attributes
5940 @subsection MeP Variable Attributes
5941
5942 The MeP target has a number of addressing modes and busses. The
5943 @code{near} space spans the standard memory space's first 16 megabytes
5944 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5945 The @code{based} space is a 128-byte region in the memory space that
5946 is addressed relative to the @code{$tp} register. The @code{tiny}
5947 space is a 65536-byte region relative to the @code{$gp} register. In
5948 addition to these memory regions, the MeP target has a separate 16-bit
5949 control bus which is specified with @code{cb} attributes.
5950
5951 @table @code
5952
5953 @item based
5954 @cindex @code{based} variable attribute, MeP
5955 Any variable with the @code{based} attribute is assigned to the
5956 @code{.based} section, and is accessed with relative to the
5957 @code{$tp} register.
5958
5959 @item tiny
5960 @cindex @code{tiny} variable attribute, MeP
5961 Likewise, the @code{tiny} attribute assigned variables to the
5962 @code{.tiny} section, relative to the @code{$gp} register.
5963
5964 @item near
5965 @cindex @code{near} variable attribute, MeP
5966 Variables with the @code{near} attribute are assumed to have addresses
5967 that fit in a 24-bit addressing mode. This is the default for large
5968 variables (@code{-mtiny=4} is the default) but this attribute can
5969 override @code{-mtiny=} for small variables, or override @code{-ml}.
5970
5971 @item far
5972 @cindex @code{far} variable attribute, MeP
5973 Variables with the @code{far} attribute are addressed using a full
5974 32-bit address. Since this covers the entire memory space, this
5975 allows modules to make no assumptions about where variables might be
5976 stored.
5977
5978 @item io
5979 @cindex @code{io} variable attribute, MeP
5980 @itemx io (@var{addr})
5981 Variables with the @code{io} attribute are used to address
5982 memory-mapped peripherals. If an address is specified, the variable
5983 is assigned that address, else it is not assigned an address (it is
5984 assumed some other module assigns an address). Example:
5985
5986 @smallexample
5987 int timer_count __attribute__((io(0x123)));
5988 @end smallexample
5989
5990 @item cb
5991 @itemx cb (@var{addr})
5992 @cindex @code{cb} variable attribute, MeP
5993 Variables with the @code{cb} attribute are used to access the control
5994 bus, using special instructions. @code{addr} indicates the control bus
5995 address. Example:
5996
5997 @smallexample
5998 int cpu_clock __attribute__((cb(0x123)));
5999 @end smallexample
6000
6001 @end table
6002
6003 @node Microsoft Windows Variable Attributes
6004 @subsection Microsoft Windows Variable Attributes
6005
6006 You can use these attributes on Microsoft Windows targets.
6007 @ref{x86 Variable Attributes} for additional Windows compatibility
6008 attributes available on all x86 targets.
6009
6010 @table @code
6011 @item dllimport
6012 @itemx dllexport
6013 @cindex @code{dllimport} variable attribute
6014 @cindex @code{dllexport} variable attribute
6015 The @code{dllimport} and @code{dllexport} attributes are described in
6016 @ref{Microsoft Windows Function Attributes}.
6017
6018 @item selectany
6019 @cindex @code{selectany} variable attribute
6020 The @code{selectany} attribute causes an initialized global variable to
6021 have link-once semantics. When multiple definitions of the variable are
6022 encountered by the linker, the first is selected and the remainder are
6023 discarded. Following usage by the Microsoft compiler, the linker is told
6024 @emph{not} to warn about size or content differences of the multiple
6025 definitions.
6026
6027 Although the primary usage of this attribute is for POD types, the
6028 attribute can also be applied to global C++ objects that are initialized
6029 by a constructor. In this case, the static initialization and destruction
6030 code for the object is emitted in each translation defining the object,
6031 but the calls to the constructor and destructor are protected by a
6032 link-once guard variable.
6033
6034 The @code{selectany} attribute is only available on Microsoft Windows
6035 targets. You can use @code{__declspec (selectany)} as a synonym for
6036 @code{__attribute__ ((selectany))} for compatibility with other
6037 compilers.
6038
6039 @item shared
6040 @cindex @code{shared} variable attribute
6041 On Microsoft Windows, in addition to putting variable definitions in a named
6042 section, the section can also be shared among all running copies of an
6043 executable or DLL@. For example, this small program defines shared data
6044 by putting it in a named section @code{shared} and marking the section
6045 shareable:
6046
6047 @smallexample
6048 int foo __attribute__((section ("shared"), shared)) = 0;
6049
6050 int
6051 main()
6052 @{
6053 /* @r{Read and write foo. All running
6054 copies see the same value.} */
6055 return 0;
6056 @}
6057 @end smallexample
6058
6059 @noindent
6060 You may only use the @code{shared} attribute along with @code{section}
6061 attribute with a fully-initialized global definition because of the way
6062 linkers work. See @code{section} attribute for more information.
6063
6064 The @code{shared} attribute is only available on Microsoft Windows@.
6065
6066 @end table
6067
6068 @node MSP430 Variable Attributes
6069 @subsection MSP430 Variable Attributes
6070
6071 @table @code
6072 @item noinit
6073 @cindex @code{noinit} variable attribute, MSP430
6074 Any data with the @code{noinit} attribute will not be initialised by
6075 the C runtime startup code, or the program loader. Not initialising
6076 data in this way can reduce program startup times.
6077
6078 @item persistent
6079 @cindex @code{persistent} variable attribute, MSP430
6080 Any variable with the @code{persistent} attribute will not be
6081 initialised by the C runtime startup code. Instead its value will be
6082 set once, when the application is loaded, and then never initialised
6083 again, even if the processor is reset or the program restarts.
6084 Persistent data is intended to be placed into FLASH RAM, where its
6085 value will be retained across resets. The linker script being used to
6086 create the application should ensure that persistent data is correctly
6087 placed.
6088
6089 @item lower
6090 @itemx upper
6091 @itemx either
6092 @cindex @code{lower} variable attribute, MSP430
6093 @cindex @code{upper} variable attribute, MSP430
6094 @cindex @code{either} variable attribute, MSP430
6095 These attributes are the same as the MSP430 function attributes of the
6096 same name (@pxref{MSP430 Function Attributes}).
6097 These attributes can be applied to both functions and variables.
6098 @end table
6099
6100 @node PowerPC Variable Attributes
6101 @subsection PowerPC Variable Attributes
6102
6103 Three attributes currently are defined for PowerPC configurations:
6104 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6105
6106 @cindex @code{ms_struct} variable attribute, PowerPC
6107 @cindex @code{gcc_struct} variable attribute, PowerPC
6108 For full documentation of the struct attributes please see the
6109 documentation in @ref{x86 Variable Attributes}.
6110
6111 @cindex @code{altivec} variable attribute, PowerPC
6112 For documentation of @code{altivec} attribute please see the
6113 documentation in @ref{PowerPC Type Attributes}.
6114
6115 @node RL78 Variable Attributes
6116 @subsection RL78 Variable Attributes
6117
6118 @cindex @code{saddr} variable attribute, RL78
6119 The RL78 back end supports the @code{saddr} variable attribute. This
6120 specifies placement of the corresponding variable in the SADDR area,
6121 which can be accessed more efficiently than the default memory region.
6122
6123 @node SPU Variable Attributes
6124 @subsection SPU Variable Attributes
6125
6126 @cindex @code{spu_vector} variable attribute, SPU
6127 The SPU supports the @code{spu_vector} attribute for variables. For
6128 documentation of this attribute please see the documentation in
6129 @ref{SPU Type Attributes}.
6130
6131 @node V850 Variable Attributes
6132 @subsection V850 Variable Attributes
6133
6134 These variable attributes are supported by the V850 back end:
6135
6136 @table @code
6137
6138 @item sda
6139 @cindex @code{sda} variable attribute, V850
6140 Use this attribute to explicitly place a variable in the small data area,
6141 which can hold up to 64 kilobytes.
6142
6143 @item tda
6144 @cindex @code{tda} variable attribute, V850
6145 Use this attribute to explicitly place a variable in the tiny data area,
6146 which can hold up to 256 bytes in total.
6147
6148 @item zda
6149 @cindex @code{zda} variable attribute, V850
6150 Use this attribute to explicitly place a variable in the first 32 kilobytes
6151 of memory.
6152 @end table
6153
6154 @node x86 Variable Attributes
6155 @subsection x86 Variable Attributes
6156
6157 Two attributes are currently defined for x86 configurations:
6158 @code{ms_struct} and @code{gcc_struct}.
6159
6160 @table @code
6161 @item ms_struct
6162 @itemx gcc_struct
6163 @cindex @code{ms_struct} variable attribute, x86
6164 @cindex @code{gcc_struct} variable attribute, x86
6165
6166 If @code{packed} is used on a structure, or if bit-fields are used,
6167 it may be that the Microsoft ABI lays out the structure differently
6168 than the way GCC normally does. Particularly when moving packed
6169 data between functions compiled with GCC and the native Microsoft compiler
6170 (either via function call or as data in a file), it may be necessary to access
6171 either format.
6172
6173 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6174 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6175 command-line options, respectively;
6176 see @ref{x86 Options}, for details of how structure layout is affected.
6177 @xref{x86 Type Attributes}, for information about the corresponding
6178 attributes on types.
6179
6180 @end table
6181
6182 @node Xstormy16 Variable Attributes
6183 @subsection Xstormy16 Variable Attributes
6184
6185 One attribute is currently defined for xstormy16 configurations:
6186 @code{below100}.
6187
6188 @table @code
6189 @item below100
6190 @cindex @code{below100} variable attribute, Xstormy16
6191
6192 If a variable has the @code{below100} attribute (@code{BELOW100} is
6193 allowed also), GCC places the variable in the first 0x100 bytes of
6194 memory and use special opcodes to access it. Such variables are
6195 placed in either the @code{.bss_below100} section or the
6196 @code{.data_below100} section.
6197
6198 @end table
6199
6200 @node Type Attributes
6201 @section Specifying Attributes of Types
6202 @cindex attribute of types
6203 @cindex type attributes
6204
6205 The keyword @code{__attribute__} allows you to specify special
6206 attributes of types. Some type attributes apply only to @code{struct}
6207 and @code{union} types, while others can apply to any type defined
6208 via a @code{typedef} declaration. Other attributes are defined for
6209 functions (@pxref{Function Attributes}), labels (@pxref{Label
6210 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6211 variables (@pxref{Variable Attributes}).
6212
6213 The @code{__attribute__} keyword is followed by an attribute specification
6214 inside double parentheses.
6215
6216 You may specify type attributes in an enum, struct or union type
6217 declaration or definition by placing them immediately after the
6218 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6219 syntax is to place them just past the closing curly brace of the
6220 definition.
6221
6222 You can also include type attributes in a @code{typedef} declaration.
6223 @xref{Attribute Syntax}, for details of the exact syntax for using
6224 attributes.
6225
6226 @menu
6227 * Common Type Attributes::
6228 * ARM Type Attributes::
6229 * MeP Type Attributes::
6230 * PowerPC Type Attributes::
6231 * SPU Type Attributes::
6232 * x86 Type Attributes::
6233 @end menu
6234
6235 @node Common Type Attributes
6236 @subsection Common Type Attributes
6237
6238 The following type attributes are supported on most targets.
6239
6240 @table @code
6241 @cindex @code{aligned} type attribute
6242 @item aligned (@var{alignment})
6243 This attribute specifies a minimum alignment (in bytes) for variables
6244 of the specified type. For example, the declarations:
6245
6246 @smallexample
6247 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6248 typedef int more_aligned_int __attribute__ ((aligned (8)));
6249 @end smallexample
6250
6251 @noindent
6252 force the compiler to ensure (as far as it can) that each variable whose
6253 type is @code{struct S} or @code{more_aligned_int} is allocated and
6254 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6255 variables of type @code{struct S} aligned to 8-byte boundaries allows
6256 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6257 store) instructions when copying one variable of type @code{struct S} to
6258 another, thus improving run-time efficiency.
6259
6260 Note that the alignment of any given @code{struct} or @code{union} type
6261 is required by the ISO C standard to be at least a perfect multiple of
6262 the lowest common multiple of the alignments of all of the members of
6263 the @code{struct} or @code{union} in question. This means that you @emph{can}
6264 effectively adjust the alignment of a @code{struct} or @code{union}
6265 type by attaching an @code{aligned} attribute to any one of the members
6266 of such a type, but the notation illustrated in the example above is a
6267 more obvious, intuitive, and readable way to request the compiler to
6268 adjust the alignment of an entire @code{struct} or @code{union} type.
6269
6270 As in the preceding example, you can explicitly specify the alignment
6271 (in bytes) that you wish the compiler to use for a given @code{struct}
6272 or @code{union} type. Alternatively, you can leave out the alignment factor
6273 and just ask the compiler to align a type to the maximum
6274 useful alignment for the target machine you are compiling for. For
6275 example, you could write:
6276
6277 @smallexample
6278 struct S @{ short f[3]; @} __attribute__ ((aligned));
6279 @end smallexample
6280
6281 Whenever you leave out the alignment factor in an @code{aligned}
6282 attribute specification, the compiler automatically sets the alignment
6283 for the type to the largest alignment that is ever used for any data
6284 type on the target machine you are compiling for. Doing this can often
6285 make copy operations more efficient, because the compiler can use
6286 whatever instructions copy the biggest chunks of memory when performing
6287 copies to or from the variables that have types that you have aligned
6288 this way.
6289
6290 In the example above, if the size of each @code{short} is 2 bytes, then
6291 the size of the entire @code{struct S} type is 6 bytes. The smallest
6292 power of two that is greater than or equal to that is 8, so the
6293 compiler sets the alignment for the entire @code{struct S} type to 8
6294 bytes.
6295
6296 Note that although you can ask the compiler to select a time-efficient
6297 alignment for a given type and then declare only individual stand-alone
6298 objects of that type, the compiler's ability to select a time-efficient
6299 alignment is primarily useful only when you plan to create arrays of
6300 variables having the relevant (efficiently aligned) type. If you
6301 declare or use arrays of variables of an efficiently-aligned type, then
6302 it is likely that your program also does pointer arithmetic (or
6303 subscripting, which amounts to the same thing) on pointers to the
6304 relevant type, and the code that the compiler generates for these
6305 pointer arithmetic operations is often more efficient for
6306 efficiently-aligned types than for other types.
6307
6308 Note that the effectiveness of @code{aligned} attributes may be limited
6309 by inherent limitations in your linker. On many systems, the linker is
6310 only able to arrange for variables to be aligned up to a certain maximum
6311 alignment. (For some linkers, the maximum supported alignment may
6312 be very very small.) If your linker is only able to align variables
6313 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6314 in an @code{__attribute__} still only provides you with 8-byte
6315 alignment. See your linker documentation for further information.
6316
6317 The @code{aligned} attribute can only increase alignment. Alignment
6318 can be decreased by specifying the @code{packed} attribute. See below.
6319
6320 @item bnd_variable_size
6321 @cindex @code{bnd_variable_size} type attribute
6322 @cindex Pointer Bounds Checker attributes
6323 When applied to a structure field, this attribute tells Pointer
6324 Bounds Checker that the size of this field should not be computed
6325 using static type information. It may be used to mark variably-sized
6326 static array fields placed at the end of a structure.
6327
6328 @smallexample
6329 struct S
6330 @{
6331 int size;
6332 char data[1];
6333 @}
6334 S *p = (S *)malloc (sizeof(S) + 100);
6335 p->data[10] = 0; //Bounds violation
6336 @end smallexample
6337
6338 @noindent
6339 By using an attribute for the field we may avoid unwanted bound
6340 violation checks:
6341
6342 @smallexample
6343 struct S
6344 @{
6345 int size;
6346 char data[1] __attribute__((bnd_variable_size));
6347 @}
6348 S *p = (S *)malloc (sizeof(S) + 100);
6349 p->data[10] = 0; //OK
6350 @end smallexample
6351
6352 @item deprecated
6353 @itemx deprecated (@var{msg})
6354 @cindex @code{deprecated} type attribute
6355 The @code{deprecated} attribute results in a warning if the type
6356 is used anywhere in the source file. This is useful when identifying
6357 types that are expected to be removed in a future version of a program.
6358 If possible, the warning also includes the location of the declaration
6359 of the deprecated type, to enable users to easily find further
6360 information about why the type is deprecated, or what they should do
6361 instead. Note that the warnings only occur for uses and then only
6362 if the type is being applied to an identifier that itself is not being
6363 declared as deprecated.
6364
6365 @smallexample
6366 typedef int T1 __attribute__ ((deprecated));
6367 T1 x;
6368 typedef T1 T2;
6369 T2 y;
6370 typedef T1 T3 __attribute__ ((deprecated));
6371 T3 z __attribute__ ((deprecated));
6372 @end smallexample
6373
6374 @noindent
6375 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6376 warning is issued for line 4 because T2 is not explicitly
6377 deprecated. Line 5 has no warning because T3 is explicitly
6378 deprecated. Similarly for line 6. The optional @var{msg}
6379 argument, which must be a string, is printed in the warning if
6380 present.
6381
6382 The @code{deprecated} attribute can also be used for functions and
6383 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6384
6385 @item designated_init
6386 @cindex @code{designated_init} type attribute
6387 This attribute may only be applied to structure types. It indicates
6388 that any initialization of an object of this type must use designated
6389 initializers rather than positional initializers. The intent of this
6390 attribute is to allow the programmer to indicate that a structure's
6391 layout may change, and that therefore relying on positional
6392 initialization will result in future breakage.
6393
6394 GCC emits warnings based on this attribute by default; use
6395 @option{-Wno-designated-init} to suppress them.
6396
6397 @item may_alias
6398 @cindex @code{may_alias} type attribute
6399 Accesses through pointers to types with this attribute are not subject
6400 to type-based alias analysis, but are instead assumed to be able to alias
6401 any other type of objects.
6402 In the context of section 6.5 paragraph 7 of the C99 standard,
6403 an lvalue expression
6404 dereferencing such a pointer is treated like having a character type.
6405 See @option{-fstrict-aliasing} for more information on aliasing issues.
6406 This extension exists to support some vector APIs, in which pointers to
6407 one vector type are permitted to alias pointers to a different vector type.
6408
6409 Note that an object of a type with this attribute does not have any
6410 special semantics.
6411
6412 Example of use:
6413
6414 @smallexample
6415 typedef short __attribute__((__may_alias__)) short_a;
6416
6417 int
6418 main (void)
6419 @{
6420 int a = 0x12345678;
6421 short_a *b = (short_a *) &a;
6422
6423 b[1] = 0;
6424
6425 if (a == 0x12345678)
6426 abort();
6427
6428 exit(0);
6429 @}
6430 @end smallexample
6431
6432 @noindent
6433 If you replaced @code{short_a} with @code{short} in the variable
6434 declaration, the above program would abort when compiled with
6435 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6436 above.
6437
6438 @item packed
6439 @cindex @code{packed} type attribute
6440 This attribute, attached to @code{struct} or @code{union} type
6441 definition, specifies that each member (other than zero-width bit-fields)
6442 of the structure or union is placed to minimize the memory required. When
6443 attached to an @code{enum} definition, it indicates that the smallest
6444 integral type should be used.
6445
6446 @opindex fshort-enums
6447 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6448 types is equivalent to specifying the @code{packed} attribute on each
6449 of the structure or union members. Specifying the @option{-fshort-enums}
6450 flag on the command line is equivalent to specifying the @code{packed}
6451 attribute on all @code{enum} definitions.
6452
6453 In the following example @code{struct my_packed_struct}'s members are
6454 packed closely together, but the internal layout of its @code{s} member
6455 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6456 be packed too.
6457
6458 @smallexample
6459 struct my_unpacked_struct
6460 @{
6461 char c;
6462 int i;
6463 @};
6464
6465 struct __attribute__ ((__packed__)) my_packed_struct
6466 @{
6467 char c;
6468 int i;
6469 struct my_unpacked_struct s;
6470 @};
6471 @end smallexample
6472
6473 You may only specify the @code{packed} attribute attribute on the definition
6474 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6475 that does not also define the enumerated type, structure or union.
6476
6477 @item scalar_storage_order ("@var{endianness}")
6478 @cindex @code{scalar_storage_order} type attribute
6479 When attached to a @code{union} or a @code{struct}, this attribute sets
6480 the storage order, aka endianness, of the scalar fields of the type, as
6481 well as the array fields whose component is scalar. The supported
6482 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6483 has no effects on fields which are themselves a @code{union}, a @code{struct}
6484 or an array whose component is a @code{union} or a @code{struct}, and it is
6485 possible for these fields to have a different scalar storage order than the
6486 enclosing type.
6487
6488 This attribute is supported only for targets that use a uniform default
6489 scalar storage order (fortunately, most of them), i.e. targets that store
6490 the scalars either all in big-endian or all in little-endian.
6491
6492 Additional restrictions are enforced for types with the reverse scalar
6493 storage order with regard to the scalar storage order of the target:
6494
6495 @itemize
6496 @item Taking the address of a scalar field of a @code{union} or a
6497 @code{struct} with reverse scalar storage order is not permitted and yields
6498 an error.
6499 @item Taking the address of an array field, whose component is scalar, of
6500 a @code{union} or a @code{struct} with reverse scalar storage order is
6501 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6502 is specified.
6503 @item Taking the address of a @code{union} or a @code{struct} with reverse
6504 scalar storage order is permitted.
6505 @end itemize
6506
6507 These restrictions exist because the storage order attribute is lost when
6508 the address of a scalar or the address of an array with scalar component is
6509 taken, so storing indirectly through this address generally does not work.
6510 The second case is nevertheless allowed to be able to perform a block copy
6511 from or to the array.
6512
6513 Moreover, the use of type punning or aliasing to toggle the storage order
6514 is not supported; that is to say, a given scalar object cannot be accessed
6515 through distinct types that assign a different storage order to it.
6516
6517 @item transparent_union
6518 @cindex @code{transparent_union} type attribute
6519
6520 This attribute, attached to a @code{union} type definition, indicates
6521 that any function parameter having that union type causes calls to that
6522 function to be treated in a special way.
6523
6524 First, the argument corresponding to a transparent union type can be of
6525 any type in the union; no cast is required. Also, if the union contains
6526 a pointer type, the corresponding argument can be a null pointer
6527 constant or a void pointer expression; and if the union contains a void
6528 pointer type, the corresponding argument can be any pointer expression.
6529 If the union member type is a pointer, qualifiers like @code{const} on
6530 the referenced type must be respected, just as with normal pointer
6531 conversions.
6532
6533 Second, the argument is passed to the function using the calling
6534 conventions of the first member of the transparent union, not the calling
6535 conventions of the union itself. All members of the union must have the
6536 same machine representation; this is necessary for this argument passing
6537 to work properly.
6538
6539 Transparent unions are designed for library functions that have multiple
6540 interfaces for compatibility reasons. For example, suppose the
6541 @code{wait} function must accept either a value of type @code{int *} to
6542 comply with POSIX, or a value of type @code{union wait *} to comply with
6543 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6544 @code{wait} would accept both kinds of arguments, but it would also
6545 accept any other pointer type and this would make argument type checking
6546 less useful. Instead, @code{<sys/wait.h>} might define the interface
6547 as follows:
6548
6549 @smallexample
6550 typedef union __attribute__ ((__transparent_union__))
6551 @{
6552 int *__ip;
6553 union wait *__up;
6554 @} wait_status_ptr_t;
6555
6556 pid_t wait (wait_status_ptr_t);
6557 @end smallexample
6558
6559 @noindent
6560 This interface allows either @code{int *} or @code{union wait *}
6561 arguments to be passed, using the @code{int *} calling convention.
6562 The program can call @code{wait} with arguments of either type:
6563
6564 @smallexample
6565 int w1 () @{ int w; return wait (&w); @}
6566 int w2 () @{ union wait w; return wait (&w); @}
6567 @end smallexample
6568
6569 @noindent
6570 With this interface, @code{wait}'s implementation might look like this:
6571
6572 @smallexample
6573 pid_t wait (wait_status_ptr_t p)
6574 @{
6575 return waitpid (-1, p.__ip, 0);
6576 @}
6577 @end smallexample
6578
6579 @item unused
6580 @cindex @code{unused} type attribute
6581 When attached to a type (including a @code{union} or a @code{struct}),
6582 this attribute means that variables of that type are meant to appear
6583 possibly unused. GCC does not produce a warning for any variables of
6584 that type, even if the variable appears to do nothing. This is often
6585 the case with lock or thread classes, which are usually defined and then
6586 not referenced, but contain constructors and destructors that have
6587 nontrivial bookkeeping functions.
6588
6589 @item visibility
6590 @cindex @code{visibility} type attribute
6591 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6592 applied to class, struct, union and enum types. Unlike other type
6593 attributes, the attribute must appear between the initial keyword and
6594 the name of the type; it cannot appear after the body of the type.
6595
6596 Note that the type visibility is applied to vague linkage entities
6597 associated with the class (vtable, typeinfo node, etc.). In
6598 particular, if a class is thrown as an exception in one shared object
6599 and caught in another, the class must have default visibility.
6600 Otherwise the two shared objects are unable to use the same
6601 typeinfo node and exception handling will break.
6602
6603 @end table
6604
6605 To specify multiple attributes, separate them by commas within the
6606 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6607 packed))}.
6608
6609 @node ARM Type Attributes
6610 @subsection ARM Type Attributes
6611
6612 @cindex @code{notshared} type attribute, ARM
6613 On those ARM targets that support @code{dllimport} (such as Symbian
6614 OS), you can use the @code{notshared} attribute to indicate that the
6615 virtual table and other similar data for a class should not be
6616 exported from a DLL@. For example:
6617
6618 @smallexample
6619 class __declspec(notshared) C @{
6620 public:
6621 __declspec(dllimport) C();
6622 virtual void f();
6623 @}
6624
6625 __declspec(dllexport)
6626 C::C() @{@}
6627 @end smallexample
6628
6629 @noindent
6630 In this code, @code{C::C} is exported from the current DLL, but the
6631 virtual table for @code{C} is not exported. (You can use
6632 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6633 most Symbian OS code uses @code{__declspec}.)
6634
6635 @node MeP Type Attributes
6636 @subsection MeP Type Attributes
6637
6638 @cindex @code{based} type attribute, MeP
6639 @cindex @code{tiny} type attribute, MeP
6640 @cindex @code{near} type attribute, MeP
6641 @cindex @code{far} type attribute, MeP
6642 Many of the MeP variable attributes may be applied to types as well.
6643 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6644 @code{far} attributes may be applied to either. The @code{io} and
6645 @code{cb} attributes may not be applied to types.
6646
6647 @node PowerPC Type Attributes
6648 @subsection PowerPC Type Attributes
6649
6650 Three attributes currently are defined for PowerPC configurations:
6651 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6652
6653 @cindex @code{ms_struct} type attribute, PowerPC
6654 @cindex @code{gcc_struct} type attribute, PowerPC
6655 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6656 attributes please see the documentation in @ref{x86 Type Attributes}.
6657
6658 @cindex @code{altivec} type attribute, PowerPC
6659 The @code{altivec} attribute allows one to declare AltiVec vector data
6660 types supported by the AltiVec Programming Interface Manual. The
6661 attribute requires an argument to specify one of three vector types:
6662 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6663 and @code{bool__} (always followed by unsigned).
6664
6665 @smallexample
6666 __attribute__((altivec(vector__)))
6667 __attribute__((altivec(pixel__))) unsigned short
6668 __attribute__((altivec(bool__))) unsigned
6669 @end smallexample
6670
6671 These attributes mainly are intended to support the @code{__vector},
6672 @code{__pixel}, and @code{__bool} AltiVec keywords.
6673
6674 @node SPU Type Attributes
6675 @subsection SPU Type Attributes
6676
6677 @cindex @code{spu_vector} type attribute, SPU
6678 The SPU supports the @code{spu_vector} attribute for types. This attribute
6679 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6680 Language Extensions Specification. It is intended to support the
6681 @code{__vector} keyword.
6682
6683 @node x86 Type Attributes
6684 @subsection x86 Type Attributes
6685
6686 Two attributes are currently defined for x86 configurations:
6687 @code{ms_struct} and @code{gcc_struct}.
6688
6689 @table @code
6690
6691 @item ms_struct
6692 @itemx gcc_struct
6693 @cindex @code{ms_struct} type attribute, x86
6694 @cindex @code{gcc_struct} type attribute, x86
6695
6696 If @code{packed} is used on a structure, or if bit-fields are used
6697 it may be that the Microsoft ABI packs them differently
6698 than GCC normally packs them. Particularly when moving packed
6699 data between functions compiled with GCC and the native Microsoft compiler
6700 (either via function call or as data in a file), it may be necessary to access
6701 either format.
6702
6703 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6704 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6705 command-line options, respectively;
6706 see @ref{x86 Options}, for details of how structure layout is affected.
6707 @xref{x86 Variable Attributes}, for information about the corresponding
6708 attributes on variables.
6709
6710 @end table
6711
6712 @node Label Attributes
6713 @section Label Attributes
6714 @cindex Label Attributes
6715
6716 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6717 details of the exact syntax for using attributes. Other attributes are
6718 available for functions (@pxref{Function Attributes}), variables
6719 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6720 and for types (@pxref{Type Attributes}).
6721
6722 This example uses the @code{cold} label attribute to indicate the
6723 @code{ErrorHandling} branch is unlikely to be taken and that the
6724 @code{ErrorHandling} label is unused:
6725
6726 @smallexample
6727
6728 asm goto ("some asm" : : : : NoError);
6729
6730 /* This branch (the fall-through from the asm) is less commonly used */
6731 ErrorHandling:
6732 __attribute__((cold, unused)); /* Semi-colon is required here */
6733 printf("error\n");
6734 return 0;
6735
6736 NoError:
6737 printf("no error\n");
6738 return 1;
6739 @end smallexample
6740
6741 @table @code
6742 @item unused
6743 @cindex @code{unused} label attribute
6744 This feature is intended for program-generated code that may contain
6745 unused labels, but which is compiled with @option{-Wall}. It is
6746 not normally appropriate to use in it human-written code, though it
6747 could be useful in cases where the code that jumps to the label is
6748 contained within an @code{#ifdef} conditional.
6749
6750 @item hot
6751 @cindex @code{hot} label attribute
6752 The @code{hot} attribute on a label is used to inform the compiler that
6753 the path following the label is more likely than paths that are not so
6754 annotated. This attribute is used in cases where @code{__builtin_expect}
6755 cannot be used, for instance with computed goto or @code{asm goto}.
6756
6757 @item cold
6758 @cindex @code{cold} label attribute
6759 The @code{cold} attribute on labels is used to inform the compiler that
6760 the path following the label is unlikely to be executed. This attribute
6761 is used in cases where @code{__builtin_expect} cannot be used, for instance
6762 with computed goto or @code{asm goto}.
6763
6764 @end table
6765
6766 @node Enumerator Attributes
6767 @section Enumerator Attributes
6768 @cindex Enumerator Attributes
6769
6770 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6771 details of the exact syntax for using attributes. Other attributes are
6772 available for functions (@pxref{Function Attributes}), variables
6773 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6774 and for types (@pxref{Type Attributes}).
6775
6776 This example uses the @code{deprecated} enumerator attribute to indicate the
6777 @code{oldval} enumerator is deprecated:
6778
6779 @smallexample
6780 enum E @{
6781 oldval __attribute__((deprecated)),
6782 newval
6783 @};
6784
6785 int
6786 fn (void)
6787 @{
6788 return oldval;
6789 @}
6790 @end smallexample
6791
6792 @table @code
6793 @item deprecated
6794 @cindex @code{deprecated} enumerator attribute
6795 The @code{deprecated} attribute results in a warning if the enumerator
6796 is used anywhere in the source file. This is useful when identifying
6797 enumerators that are expected to be removed in a future version of a
6798 program. The warning also includes the location of the declaration
6799 of the deprecated enumerator, to enable users to easily find further
6800 information about why the enumerator is deprecated, or what they should
6801 do instead. Note that the warnings only occurs for uses.
6802
6803 @end table
6804
6805 @node Attribute Syntax
6806 @section Attribute Syntax
6807 @cindex attribute syntax
6808
6809 This section describes the syntax with which @code{__attribute__} may be
6810 used, and the constructs to which attribute specifiers bind, for the C
6811 language. Some details may vary for C++ and Objective-C@. Because of
6812 infelicities in the grammar for attributes, some forms described here
6813 may not be successfully parsed in all cases.
6814
6815 There are some problems with the semantics of attributes in C++. For
6816 example, there are no manglings for attributes, although they may affect
6817 code generation, so problems may arise when attributed types are used in
6818 conjunction with templates or overloading. Similarly, @code{typeid}
6819 does not distinguish between types with different attributes. Support
6820 for attributes in C++ may be restricted in future to attributes on
6821 declarations only, but not on nested declarators.
6822
6823 @xref{Function Attributes}, for details of the semantics of attributes
6824 applying to functions. @xref{Variable Attributes}, for details of the
6825 semantics of attributes applying to variables. @xref{Type Attributes},
6826 for details of the semantics of attributes applying to structure, union
6827 and enumerated types.
6828 @xref{Label Attributes}, for details of the semantics of attributes
6829 applying to labels.
6830 @xref{Enumerator Attributes}, for details of the semantics of attributes
6831 applying to enumerators.
6832
6833 An @dfn{attribute specifier} is of the form
6834 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6835 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6836 each attribute is one of the following:
6837
6838 @itemize @bullet
6839 @item
6840 Empty. Empty attributes are ignored.
6841
6842 @item
6843 An attribute name
6844 (which may be an identifier such as @code{unused}, or a reserved
6845 word such as @code{const}).
6846
6847 @item
6848 An attribute name followed by a parenthesized list of
6849 parameters for the attribute.
6850 These parameters take one of the following forms:
6851
6852 @itemize @bullet
6853 @item
6854 An identifier. For example, @code{mode} attributes use this form.
6855
6856 @item
6857 An identifier followed by a comma and a non-empty comma-separated list
6858 of expressions. For example, @code{format} attributes use this form.
6859
6860 @item
6861 A possibly empty comma-separated list of expressions. For example,
6862 @code{format_arg} attributes use this form with the list being a single
6863 integer constant expression, and @code{alias} attributes use this form
6864 with the list being a single string constant.
6865 @end itemize
6866 @end itemize
6867
6868 An @dfn{attribute specifier list} is a sequence of one or more attribute
6869 specifiers, not separated by any other tokens.
6870
6871 You may optionally specify attribute names with @samp{__}
6872 preceding and following the name.
6873 This allows you to use them in header files without
6874 being concerned about a possible macro of the same name. For example,
6875 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6876
6877
6878 @subsubheading Label Attributes
6879
6880 In GNU C, an attribute specifier list may appear after the colon following a
6881 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6882 attributes on labels if the attribute specifier is immediately
6883 followed by a semicolon (i.e., the label applies to an empty
6884 statement). If the semicolon is missing, C++ label attributes are
6885 ambiguous, as it is permissible for a declaration, which could begin
6886 with an attribute list, to be labelled in C++. Declarations cannot be
6887 labelled in C90 or C99, so the ambiguity does not arise there.
6888
6889 @subsubheading Enumerator Attributes
6890
6891 In GNU C, an attribute specifier list may appear as part of an enumerator.
6892 The attribute goes after the enumeration constant, before @code{=}, if
6893 present. The optional attribute in the enumerator appertains to the
6894 enumeration constant. It is not possible to place the attribute after
6895 the constant expression, if present.
6896
6897 @subsubheading Type Attributes
6898
6899 An attribute specifier list may appear as part of a @code{struct},
6900 @code{union} or @code{enum} specifier. It may go either immediately
6901 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6902 the closing brace. The former syntax is preferred.
6903 Where attribute specifiers follow the closing brace, they are considered
6904 to relate to the structure, union or enumerated type defined, not to any
6905 enclosing declaration the type specifier appears in, and the type
6906 defined is not complete until after the attribute specifiers.
6907 @c Otherwise, there would be the following problems: a shift/reduce
6908 @c conflict between attributes binding the struct/union/enum and
6909 @c binding to the list of specifiers/qualifiers; and "aligned"
6910 @c attributes could use sizeof for the structure, but the size could be
6911 @c changed later by "packed" attributes.
6912
6913
6914 @subsubheading All other attributes
6915
6916 Otherwise, an attribute specifier appears as part of a declaration,
6917 counting declarations of unnamed parameters and type names, and relates
6918 to that declaration (which may be nested in another declaration, for
6919 example in the case of a parameter declaration), or to a particular declarator
6920 within a declaration. Where an
6921 attribute specifier is applied to a parameter declared as a function or
6922 an array, it should apply to the function or array rather than the
6923 pointer to which the parameter is implicitly converted, but this is not
6924 yet correctly implemented.
6925
6926 Any list of specifiers and qualifiers at the start of a declaration may
6927 contain attribute specifiers, whether or not such a list may in that
6928 context contain storage class specifiers. (Some attributes, however,
6929 are essentially in the nature of storage class specifiers, and only make
6930 sense where storage class specifiers may be used; for example,
6931 @code{section}.) There is one necessary limitation to this syntax: the
6932 first old-style parameter declaration in a function definition cannot
6933 begin with an attribute specifier, because such an attribute applies to
6934 the function instead by syntax described below (which, however, is not
6935 yet implemented in this case). In some other cases, attribute
6936 specifiers are permitted by this grammar but not yet supported by the
6937 compiler. All attribute specifiers in this place relate to the
6938 declaration as a whole. In the obsolescent usage where a type of
6939 @code{int} is implied by the absence of type specifiers, such a list of
6940 specifiers and qualifiers may be an attribute specifier list with no
6941 other specifiers or qualifiers.
6942
6943 At present, the first parameter in a function prototype must have some
6944 type specifier that is not an attribute specifier; this resolves an
6945 ambiguity in the interpretation of @code{void f(int
6946 (__attribute__((foo)) x))}, but is subject to change. At present, if
6947 the parentheses of a function declarator contain only attributes then
6948 those attributes are ignored, rather than yielding an error or warning
6949 or implying a single parameter of type int, but this is subject to
6950 change.
6951
6952 An attribute specifier list may appear immediately before a declarator
6953 (other than the first) in a comma-separated list of declarators in a
6954 declaration of more than one identifier using a single list of
6955 specifiers and qualifiers. Such attribute specifiers apply
6956 only to the identifier before whose declarator they appear. For
6957 example, in
6958
6959 @smallexample
6960 __attribute__((noreturn)) void d0 (void),
6961 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6962 d2 (void);
6963 @end smallexample
6964
6965 @noindent
6966 the @code{noreturn} attribute applies to all the functions
6967 declared; the @code{format} attribute only applies to @code{d1}.
6968
6969 An attribute specifier list may appear immediately before the comma,
6970 @code{=} or semicolon terminating the declaration of an identifier other
6971 than a function definition. Such attribute specifiers apply
6972 to the declared object or function. Where an
6973 assembler name for an object or function is specified (@pxref{Asm
6974 Labels}), the attribute must follow the @code{asm}
6975 specification.
6976
6977 An attribute specifier list may, in future, be permitted to appear after
6978 the declarator in a function definition (before any old-style parameter
6979 declarations or the function body).
6980
6981 Attribute specifiers may be mixed with type qualifiers appearing inside
6982 the @code{[]} of a parameter array declarator, in the C99 construct by
6983 which such qualifiers are applied to the pointer to which the array is
6984 implicitly converted. Such attribute specifiers apply to the pointer,
6985 not to the array, but at present this is not implemented and they are
6986 ignored.
6987
6988 An attribute specifier list may appear at the start of a nested
6989 declarator. At present, there are some limitations in this usage: the
6990 attributes correctly apply to the declarator, but for most individual
6991 attributes the semantics this implies are not implemented.
6992 When attribute specifiers follow the @code{*} of a pointer
6993 declarator, they may be mixed with any type qualifiers present.
6994 The following describes the formal semantics of this syntax. It makes the
6995 most sense if you are familiar with the formal specification of
6996 declarators in the ISO C standard.
6997
6998 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6999 D1}, where @code{T} contains declaration specifiers that specify a type
7000 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7001 contains an identifier @var{ident}. The type specified for @var{ident}
7002 for derived declarators whose type does not include an attribute
7003 specifier is as in the ISO C standard.
7004
7005 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7006 and the declaration @code{T D} specifies the type
7007 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7008 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7009 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7010
7011 If @code{D1} has the form @code{*
7012 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7013 declaration @code{T D} specifies the type
7014 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7015 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7016 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7017 @var{ident}.
7018
7019 For example,
7020
7021 @smallexample
7022 void (__attribute__((noreturn)) ****f) (void);
7023 @end smallexample
7024
7025 @noindent
7026 specifies the type ``pointer to pointer to pointer to pointer to
7027 non-returning function returning @code{void}''. As another example,
7028
7029 @smallexample
7030 char *__attribute__((aligned(8))) *f;
7031 @end smallexample
7032
7033 @noindent
7034 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7035 Note again that this does not work with most attributes; for example,
7036 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7037 is not yet supported.
7038
7039 For compatibility with existing code written for compiler versions that
7040 did not implement attributes on nested declarators, some laxity is
7041 allowed in the placing of attributes. If an attribute that only applies
7042 to types is applied to a declaration, it is treated as applying to
7043 the type of that declaration. If an attribute that only applies to
7044 declarations is applied to the type of a declaration, it is treated
7045 as applying to that declaration; and, for compatibility with code
7046 placing the attributes immediately before the identifier declared, such
7047 an attribute applied to a function return type is treated as
7048 applying to the function type, and such an attribute applied to an array
7049 element type is treated as applying to the array type. If an
7050 attribute that only applies to function types is applied to a
7051 pointer-to-function type, it is treated as applying to the pointer
7052 target type; if such an attribute is applied to a function return type
7053 that is not a pointer-to-function type, it is treated as applying
7054 to the function type.
7055
7056 @node Function Prototypes
7057 @section Prototypes and Old-Style Function Definitions
7058 @cindex function prototype declarations
7059 @cindex old-style function definitions
7060 @cindex promotion of formal parameters
7061
7062 GNU C extends ISO C to allow a function prototype to override a later
7063 old-style non-prototype definition. Consider the following example:
7064
7065 @smallexample
7066 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7067 #ifdef __STDC__
7068 #define P(x) x
7069 #else
7070 #define P(x) ()
7071 #endif
7072
7073 /* @r{Prototype function declaration.} */
7074 int isroot P((uid_t));
7075
7076 /* @r{Old-style function definition.} */
7077 int
7078 isroot (x) /* @r{??? lossage here ???} */
7079 uid_t x;
7080 @{
7081 return x == 0;
7082 @}
7083 @end smallexample
7084
7085 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7086 not allow this example, because subword arguments in old-style
7087 non-prototype definitions are promoted. Therefore in this example the
7088 function definition's argument is really an @code{int}, which does not
7089 match the prototype argument type of @code{short}.
7090
7091 This restriction of ISO C makes it hard to write code that is portable
7092 to traditional C compilers, because the programmer does not know
7093 whether the @code{uid_t} type is @code{short}, @code{int}, or
7094 @code{long}. Therefore, in cases like these GNU C allows a prototype
7095 to override a later old-style definition. More precisely, in GNU C, a
7096 function prototype argument type overrides the argument type specified
7097 by a later old-style definition if the former type is the same as the
7098 latter type before promotion. Thus in GNU C the above example is
7099 equivalent to the following:
7100
7101 @smallexample
7102 int isroot (uid_t);
7103
7104 int
7105 isroot (uid_t x)
7106 @{
7107 return x == 0;
7108 @}
7109 @end smallexample
7110
7111 @noindent
7112 GNU C++ does not support old-style function definitions, so this
7113 extension is irrelevant.
7114
7115 @node C++ Comments
7116 @section C++ Style Comments
7117 @cindex @code{//}
7118 @cindex C++ comments
7119 @cindex comments, C++ style
7120
7121 In GNU C, you may use C++ style comments, which start with @samp{//} and
7122 continue until the end of the line. Many other C implementations allow
7123 such comments, and they are included in the 1999 C standard. However,
7124 C++ style comments are not recognized if you specify an @option{-std}
7125 option specifying a version of ISO C before C99, or @option{-ansi}
7126 (equivalent to @option{-std=c90}).
7127
7128 @node Dollar Signs
7129 @section Dollar Signs in Identifier Names
7130 @cindex $
7131 @cindex dollar signs in identifier names
7132 @cindex identifier names, dollar signs in
7133
7134 In GNU C, you may normally use dollar signs in identifier names.
7135 This is because many traditional C implementations allow such identifiers.
7136 However, dollar signs in identifiers are not supported on a few target
7137 machines, typically because the target assembler does not allow them.
7138
7139 @node Character Escapes
7140 @section The Character @key{ESC} in Constants
7141
7142 You can use the sequence @samp{\e} in a string or character constant to
7143 stand for the ASCII character @key{ESC}.
7144
7145 @node Alignment
7146 @section Inquiring on Alignment of Types or Variables
7147 @cindex alignment
7148 @cindex type alignment
7149 @cindex variable alignment
7150
7151 The keyword @code{__alignof__} allows you to inquire about how an object
7152 is aligned, or the minimum alignment usually required by a type. Its
7153 syntax is just like @code{sizeof}.
7154
7155 For example, if the target machine requires a @code{double} value to be
7156 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7157 This is true on many RISC machines. On more traditional machine
7158 designs, @code{__alignof__ (double)} is 4 or even 2.
7159
7160 Some machines never actually require alignment; they allow reference to any
7161 data type even at an odd address. For these machines, @code{__alignof__}
7162 reports the smallest alignment that GCC gives the data type, usually as
7163 mandated by the target ABI.
7164
7165 If the operand of @code{__alignof__} is an lvalue rather than a type,
7166 its value is the required alignment for its type, taking into account
7167 any minimum alignment specified with GCC's @code{__attribute__}
7168 extension (@pxref{Variable Attributes}). For example, after this
7169 declaration:
7170
7171 @smallexample
7172 struct foo @{ int x; char y; @} foo1;
7173 @end smallexample
7174
7175 @noindent
7176 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7177 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7178
7179 It is an error to ask for the alignment of an incomplete type.
7180
7181
7182 @node Inline
7183 @section An Inline Function is As Fast As a Macro
7184 @cindex inline functions
7185 @cindex integrating function code
7186 @cindex open coding
7187 @cindex macros, inline alternative
7188
7189 By declaring a function inline, you can direct GCC to make
7190 calls to that function faster. One way GCC can achieve this is to
7191 integrate that function's code into the code for its callers. This
7192 makes execution faster by eliminating the function-call overhead; in
7193 addition, if any of the actual argument values are constant, their
7194 known values may permit simplifications at compile time so that not
7195 all of the inline function's code needs to be included. The effect on
7196 code size is less predictable; object code may be larger or smaller
7197 with function inlining, depending on the particular case. You can
7198 also direct GCC to try to integrate all ``simple enough'' functions
7199 into their callers with the option @option{-finline-functions}.
7200
7201 GCC implements three different semantics of declaring a function
7202 inline. One is available with @option{-std=gnu89} or
7203 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7204 on all inline declarations, another when
7205 @option{-std=c99}, @option{-std=c11},
7206 @option{-std=gnu99} or @option{-std=gnu11}
7207 (without @option{-fgnu89-inline}), and the third
7208 is used when compiling C++.
7209
7210 To declare a function inline, use the @code{inline} keyword in its
7211 declaration, like this:
7212
7213 @smallexample
7214 static inline int
7215 inc (int *a)
7216 @{
7217 return (*a)++;
7218 @}
7219 @end smallexample
7220
7221 If you are writing a header file to be included in ISO C90 programs, write
7222 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7223
7224 The three types of inlining behave similarly in two important cases:
7225 when the @code{inline} keyword is used on a @code{static} function,
7226 like the example above, and when a function is first declared without
7227 using the @code{inline} keyword and then is defined with
7228 @code{inline}, like this:
7229
7230 @smallexample
7231 extern int inc (int *a);
7232 inline int
7233 inc (int *a)
7234 @{
7235 return (*a)++;
7236 @}
7237 @end smallexample
7238
7239 In both of these common cases, the program behaves the same as if you
7240 had not used the @code{inline} keyword, except for its speed.
7241
7242 @cindex inline functions, omission of
7243 @opindex fkeep-inline-functions
7244 When a function is both inline and @code{static}, if all calls to the
7245 function are integrated into the caller, and the function's address is
7246 never used, then the function's own assembler code is never referenced.
7247 In this case, GCC does not actually output assembler code for the
7248 function, unless you specify the option @option{-fkeep-inline-functions}.
7249 If there is a nonintegrated call, then the function is compiled to
7250 assembler code as usual. The function must also be compiled as usual if
7251 the program refers to its address, because that can't be inlined.
7252
7253 @opindex Winline
7254 Note that certain usages in a function definition can make it unsuitable
7255 for inline substitution. Among these usages are: variadic functions,
7256 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7257 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7258 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7259 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7260 function marked @code{inline} could not be substituted, and gives the
7261 reason for the failure.
7262
7263 @cindex automatic @code{inline} for C++ member fns
7264 @cindex @code{inline} automatic for C++ member fns
7265 @cindex member fns, automatically @code{inline}
7266 @cindex C++ member fns, automatically @code{inline}
7267 @opindex fno-default-inline
7268 As required by ISO C++, GCC considers member functions defined within
7269 the body of a class to be marked inline even if they are
7270 not explicitly declared with the @code{inline} keyword. You can
7271 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7272 Options,,Options Controlling C++ Dialect}.
7273
7274 GCC does not inline any functions when not optimizing unless you specify
7275 the @samp{always_inline} attribute for the function, like this:
7276
7277 @smallexample
7278 /* @r{Prototype.} */
7279 inline void foo (const char) __attribute__((always_inline));
7280 @end smallexample
7281
7282 The remainder of this section is specific to GNU C90 inlining.
7283
7284 @cindex non-static inline function
7285 When an inline function is not @code{static}, then the compiler must assume
7286 that there may be calls from other source files; since a global symbol can
7287 be defined only once in any program, the function must not be defined in
7288 the other source files, so the calls therein cannot be integrated.
7289 Therefore, a non-@code{static} inline function is always compiled on its
7290 own in the usual fashion.
7291
7292 If you specify both @code{inline} and @code{extern} in the function
7293 definition, then the definition is used only for inlining. In no case
7294 is the function compiled on its own, not even if you refer to its
7295 address explicitly. Such an address becomes an external reference, as
7296 if you had only declared the function, and had not defined it.
7297
7298 This combination of @code{inline} and @code{extern} has almost the
7299 effect of a macro. The way to use it is to put a function definition in
7300 a header file with these keywords, and put another copy of the
7301 definition (lacking @code{inline} and @code{extern}) in a library file.
7302 The definition in the header file causes most calls to the function
7303 to be inlined. If any uses of the function remain, they refer to
7304 the single copy in the library.
7305
7306 @node Volatiles
7307 @section When is a Volatile Object Accessed?
7308 @cindex accessing volatiles
7309 @cindex volatile read
7310 @cindex volatile write
7311 @cindex volatile access
7312
7313 C has the concept of volatile objects. These are normally accessed by
7314 pointers and used for accessing hardware or inter-thread
7315 communication. The standard encourages compilers to refrain from
7316 optimizations concerning accesses to volatile objects, but leaves it
7317 implementation defined as to what constitutes a volatile access. The
7318 minimum requirement is that at a sequence point all previous accesses
7319 to volatile objects have stabilized and no subsequent accesses have
7320 occurred. Thus an implementation is free to reorder and combine
7321 volatile accesses that occur between sequence points, but cannot do
7322 so for accesses across a sequence point. The use of volatile does
7323 not allow you to violate the restriction on updating objects multiple
7324 times between two sequence points.
7325
7326 Accesses to non-volatile objects are not ordered with respect to
7327 volatile accesses. You cannot use a volatile object as a memory
7328 barrier to order a sequence of writes to non-volatile memory. For
7329 instance:
7330
7331 @smallexample
7332 int *ptr = @var{something};
7333 volatile int vobj;
7334 *ptr = @var{something};
7335 vobj = 1;
7336 @end smallexample
7337
7338 @noindent
7339 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7340 that the write to @var{*ptr} occurs by the time the update
7341 of @var{vobj} happens. If you need this guarantee, you must use
7342 a stronger memory barrier such as:
7343
7344 @smallexample
7345 int *ptr = @var{something};
7346 volatile int vobj;
7347 *ptr = @var{something};
7348 asm volatile ("" : : : "memory");
7349 vobj = 1;
7350 @end smallexample
7351
7352 A scalar volatile object is read when it is accessed in a void context:
7353
7354 @smallexample
7355 volatile int *src = @var{somevalue};
7356 *src;
7357 @end smallexample
7358
7359 Such expressions are rvalues, and GCC implements this as a
7360 read of the volatile object being pointed to.
7361
7362 Assignments are also expressions and have an rvalue. However when
7363 assigning to a scalar volatile, the volatile object is not reread,
7364 regardless of whether the assignment expression's rvalue is used or
7365 not. If the assignment's rvalue is used, the value is that assigned
7366 to the volatile object. For instance, there is no read of @var{vobj}
7367 in all the following cases:
7368
7369 @smallexample
7370 int obj;
7371 volatile int vobj;
7372 vobj = @var{something};
7373 obj = vobj = @var{something};
7374 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7375 obj = (@var{something}, vobj = @var{anotherthing});
7376 @end smallexample
7377
7378 If you need to read the volatile object after an assignment has
7379 occurred, you must use a separate expression with an intervening
7380 sequence point.
7381
7382 As bit-fields are not individually addressable, volatile bit-fields may
7383 be implicitly read when written to, or when adjacent bit-fields are
7384 accessed. Bit-field operations may be optimized such that adjacent
7385 bit-fields are only partially accessed, if they straddle a storage unit
7386 boundary. For these reasons it is unwise to use volatile bit-fields to
7387 access hardware.
7388
7389 @node Using Assembly Language with C
7390 @section How to Use Inline Assembly Language in C Code
7391 @cindex @code{asm} keyword
7392 @cindex assembly language in C
7393 @cindex inline assembly language
7394 @cindex mixing assembly language and C
7395
7396 The @code{asm} keyword allows you to embed assembler instructions
7397 within C code. GCC provides two forms of inline @code{asm}
7398 statements. A @dfn{basic @code{asm}} statement is one with no
7399 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7400 statement (@pxref{Extended Asm}) includes one or more operands.
7401 The extended form is preferred for mixing C and assembly language
7402 within a function, but to include assembly language at
7403 top level you must use basic @code{asm}.
7404
7405 You can also use the @code{asm} keyword to override the assembler name
7406 for a C symbol, or to place a C variable in a specific register.
7407
7408 @menu
7409 * Basic Asm:: Inline assembler without operands.
7410 * Extended Asm:: Inline assembler with operands.
7411 * Constraints:: Constraints for @code{asm} operands
7412 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7413 * Explicit Register Variables:: Defining variables residing in specified
7414 registers.
7415 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7416 @end menu
7417
7418 @node Basic Asm
7419 @subsection Basic Asm --- Assembler Instructions Without Operands
7420 @cindex basic @code{asm}
7421 @cindex assembly language in C, basic
7422
7423 A basic @code{asm} statement has the following syntax:
7424
7425 @example
7426 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7427 @end example
7428
7429 The @code{asm} keyword is a GNU extension.
7430 When writing code that can be compiled with @option{-ansi} and the
7431 various @option{-std} options, use @code{__asm__} instead of
7432 @code{asm} (@pxref{Alternate Keywords}).
7433
7434 @subsubheading Qualifiers
7435 @table @code
7436 @item volatile
7437 The optional @code{volatile} qualifier has no effect.
7438 All basic @code{asm} blocks are implicitly volatile.
7439 @end table
7440
7441 @subsubheading Parameters
7442 @table @var
7443
7444 @item AssemblerInstructions
7445 This is a literal string that specifies the assembler code. The string can
7446 contain any instructions recognized by the assembler, including directives.
7447 GCC does not parse the assembler instructions themselves and
7448 does not know what they mean or even whether they are valid assembler input.
7449
7450 You may place multiple assembler instructions together in a single @code{asm}
7451 string, separated by the characters normally used in assembly code for the
7452 system. A combination that works in most places is a newline to break the
7453 line, plus a tab character (written as @samp{\n\t}).
7454 Some assemblers allow semicolons as a line separator. However,
7455 note that some assembler dialects use semicolons to start a comment.
7456 @end table
7457
7458 @subsubheading Remarks
7459 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7460 smaller, safer, and more efficient code, and in most cases it is a
7461 better solution than basic @code{asm}. However, there are two
7462 situations where only basic @code{asm} can be used:
7463
7464 @itemize @bullet
7465 @item
7466 Extended @code{asm} statements have to be inside a C
7467 function, so to write inline assembly language at file scope (``top-level''),
7468 outside of C functions, you must use basic @code{asm}.
7469 You can use this technique to emit assembler directives,
7470 define assembly language macros that can be invoked elsewhere in the file,
7471 or write entire functions in assembly language.
7472
7473 @item
7474 Functions declared
7475 with the @code{naked} attribute also require basic @code{asm}
7476 (@pxref{Function Attributes}).
7477 @end itemize
7478
7479 Safely accessing C data and calling functions from basic @code{asm} is more
7480 complex than it may appear. To access C data, it is better to use extended
7481 @code{asm}.
7482
7483 Do not expect a sequence of @code{asm} statements to remain perfectly
7484 consecutive after compilation. If certain instructions need to remain
7485 consecutive in the output, put them in a single multi-instruction @code{asm}
7486 statement. Note that GCC's optimizers can move @code{asm} statements
7487 relative to other code, including across jumps.
7488
7489 @code{asm} statements may not perform jumps into other @code{asm} statements.
7490 GCC does not know about these jumps, and therefore cannot take
7491 account of them when deciding how to optimize. Jumps from @code{asm} to C
7492 labels are only supported in extended @code{asm}.
7493
7494 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7495 assembly code when optimizing. This can lead to unexpected duplicate
7496 symbol errors during compilation if your assembly code defines symbols or
7497 labels.
7498
7499 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7500 making it a potential source of incompatibilities between compilers. These
7501 incompatibilities may not produce compiler warnings/errors.
7502
7503 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7504 means there is no way to communicate to the compiler what is happening
7505 inside them. GCC has no visibility of symbols in the @code{asm} and may
7506 discard them as unreferenced. It also does not know about side effects of
7507 the assembler code, such as modifications to memory or registers. Unlike
7508 some compilers, GCC assumes that no changes to either memory or registers
7509 occur. This assumption may change in a future release.
7510
7511 To avoid complications from future changes to the semantics and the
7512 compatibility issues between compilers, consider replacing basic @code{asm}
7513 with extended @code{asm}. See
7514 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7515 from basic asm to extended asm} for information about how to perform this
7516 conversion.
7517
7518 The compiler copies the assembler instructions in a basic @code{asm}
7519 verbatim to the assembly language output file, without
7520 processing dialects or any of the @samp{%} operators that are available with
7521 extended @code{asm}. This results in minor differences between basic
7522 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7523 registers you might use @samp{%eax} in basic @code{asm} and
7524 @samp{%%eax} in extended @code{asm}.
7525
7526 On targets such as x86 that support multiple assembler dialects,
7527 all basic @code{asm} blocks use the assembler dialect specified by the
7528 @option{-masm} command-line option (@pxref{x86 Options}).
7529 Basic @code{asm} provides no
7530 mechanism to provide different assembler strings for different dialects.
7531
7532 Here is an example of basic @code{asm} for i386:
7533
7534 @example
7535 /* Note that this code will not compile with -masm=intel */
7536 #define DebugBreak() asm("int $3")
7537 @end example
7538
7539 @node Extended Asm
7540 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7541 @cindex extended @code{asm}
7542 @cindex assembly language in C, extended
7543
7544 With extended @code{asm} you can read and write C variables from
7545 assembler and perform jumps from assembler code to C labels.
7546 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7547 the operand parameters after the assembler template:
7548
7549 @example
7550 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7551 : @var{OutputOperands}
7552 @r{[} : @var{InputOperands}
7553 @r{[} : @var{Clobbers} @r{]} @r{]})
7554
7555 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7556 :
7557 : @var{InputOperands}
7558 : @var{Clobbers}
7559 : @var{GotoLabels})
7560 @end example
7561
7562 The @code{asm} keyword is a GNU extension.
7563 When writing code that can be compiled with @option{-ansi} and the
7564 various @option{-std} options, use @code{__asm__} instead of
7565 @code{asm} (@pxref{Alternate Keywords}).
7566
7567 @subsubheading Qualifiers
7568 @table @code
7569
7570 @item volatile
7571 The typical use of extended @code{asm} statements is to manipulate input
7572 values to produce output values. However, your @code{asm} statements may
7573 also produce side effects. If so, you may need to use the @code{volatile}
7574 qualifier to disable certain optimizations. @xref{Volatile}.
7575
7576 @item goto
7577 This qualifier informs the compiler that the @code{asm} statement may
7578 perform a jump to one of the labels listed in the @var{GotoLabels}.
7579 @xref{GotoLabels}.
7580 @end table
7581
7582 @subsubheading Parameters
7583 @table @var
7584 @item AssemblerTemplate
7585 This is a literal string that is the template for the assembler code. It is a
7586 combination of fixed text and tokens that refer to the input, output,
7587 and goto parameters. @xref{AssemblerTemplate}.
7588
7589 @item OutputOperands
7590 A comma-separated list of the C variables modified by the instructions in the
7591 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7592
7593 @item InputOperands
7594 A comma-separated list of C expressions read by the instructions in the
7595 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7596
7597 @item Clobbers
7598 A comma-separated list of registers or other values changed by the
7599 @var{AssemblerTemplate}, beyond those listed as outputs.
7600 An empty list is permitted. @xref{Clobbers}.
7601
7602 @item GotoLabels
7603 When you are using the @code{goto} form of @code{asm}, this section contains
7604 the list of all C labels to which the code in the
7605 @var{AssemblerTemplate} may jump.
7606 @xref{GotoLabels}.
7607
7608 @code{asm} statements may not perform jumps into other @code{asm} statements,
7609 only to the listed @var{GotoLabels}.
7610 GCC's optimizers do not know about other jumps; therefore they cannot take
7611 account of them when deciding how to optimize.
7612 @end table
7613
7614 The total number of input + output + goto operands is limited to 30.
7615
7616 @subsubheading Remarks
7617 The @code{asm} statement allows you to include assembly instructions directly
7618 within C code. This may help you to maximize performance in time-sensitive
7619 code or to access assembly instructions that are not readily available to C
7620 programs.
7621
7622 Note that extended @code{asm} statements must be inside a function. Only
7623 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7624 Functions declared with the @code{naked} attribute also require basic
7625 @code{asm} (@pxref{Function Attributes}).
7626
7627 While the uses of @code{asm} are many and varied, it may help to think of an
7628 @code{asm} statement as a series of low-level instructions that convert input
7629 parameters to output parameters. So a simple (if not particularly useful)
7630 example for i386 using @code{asm} might look like this:
7631
7632 @example
7633 int src = 1;
7634 int dst;
7635
7636 asm ("mov %1, %0\n\t"
7637 "add $1, %0"
7638 : "=r" (dst)
7639 : "r" (src));
7640
7641 printf("%d\n", dst);
7642 @end example
7643
7644 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7645
7646 @anchor{Volatile}
7647 @subsubsection Volatile
7648 @cindex volatile @code{asm}
7649 @cindex @code{asm} volatile
7650
7651 GCC's optimizers sometimes discard @code{asm} statements if they determine
7652 there is no need for the output variables. Also, the optimizers may move
7653 code out of loops if they believe that the code will always return the same
7654 result (i.e. none of its input values change between calls). Using the
7655 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7656 that have no output operands, including @code{asm goto} statements,
7657 are implicitly volatile.
7658
7659 This i386 code demonstrates a case that does not use (or require) the
7660 @code{volatile} qualifier. If it is performing assertion checking, this code
7661 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7662 unreferenced by any code. As a result, the optimizers can discard the
7663 @code{asm} statement, which in turn removes the need for the entire
7664 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7665 isn't needed you allow the optimizers to produce the most efficient code
7666 possible.
7667
7668 @example
7669 void DoCheck(uint32_t dwSomeValue)
7670 @{
7671 uint32_t dwRes;
7672
7673 // Assumes dwSomeValue is not zero.
7674 asm ("bsfl %1,%0"
7675 : "=r" (dwRes)
7676 : "r" (dwSomeValue)
7677 : "cc");
7678
7679 assert(dwRes > 3);
7680 @}
7681 @end example
7682
7683 The next example shows a case where the optimizers can recognize that the input
7684 (@code{dwSomeValue}) never changes during the execution of the function and can
7685 therefore move the @code{asm} outside the loop to produce more efficient code.
7686 Again, using @code{volatile} disables this type of optimization.
7687
7688 @example
7689 void do_print(uint32_t dwSomeValue)
7690 @{
7691 uint32_t dwRes;
7692
7693 for (uint32_t x=0; x < 5; x++)
7694 @{
7695 // Assumes dwSomeValue is not zero.
7696 asm ("bsfl %1,%0"
7697 : "=r" (dwRes)
7698 : "r" (dwSomeValue)
7699 : "cc");
7700
7701 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7702 @}
7703 @}
7704 @end example
7705
7706 The following example demonstrates a case where you need to use the
7707 @code{volatile} qualifier.
7708 It uses the x86 @code{rdtsc} instruction, which reads
7709 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7710 the optimizers might assume that the @code{asm} block will always return the
7711 same value and therefore optimize away the second call.
7712
7713 @example
7714 uint64_t msr;
7715
7716 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7717 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7718 "or %%rdx, %0" // 'Or' in the lower bits.
7719 : "=a" (msr)
7720 :
7721 : "rdx");
7722
7723 printf("msr: %llx\n", msr);
7724
7725 // Do other work...
7726
7727 // Reprint the timestamp
7728 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7729 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7730 "or %%rdx, %0" // 'Or' in the lower bits.
7731 : "=a" (msr)
7732 :
7733 : "rdx");
7734
7735 printf("msr: %llx\n", msr);
7736 @end example
7737
7738 GCC's optimizers do not treat this code like the non-volatile code in the
7739 earlier examples. They do not move it out of loops or omit it on the
7740 assumption that the result from a previous call is still valid.
7741
7742 Note that the compiler can move even volatile @code{asm} instructions relative
7743 to other code, including across jump instructions. For example, on many
7744 targets there is a system register that controls the rounding mode of
7745 floating-point operations. Setting it with a volatile @code{asm}, as in the
7746 following PowerPC example, does not work reliably.
7747
7748 @example
7749 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7750 sum = x + y;
7751 @end example
7752
7753 The compiler may move the addition back before the volatile @code{asm}. To
7754 make it work as expected, add an artificial dependency to the @code{asm} by
7755 referencing a variable in the subsequent code, for example:
7756
7757 @example
7758 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7759 sum = x + y;
7760 @end example
7761
7762 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7763 assembly code when optimizing. This can lead to unexpected duplicate symbol
7764 errors during compilation if your asm code defines symbols or labels.
7765 Using @samp{%=}
7766 (@pxref{AssemblerTemplate}) may help resolve this problem.
7767
7768 @anchor{AssemblerTemplate}
7769 @subsubsection Assembler Template
7770 @cindex @code{asm} assembler template
7771
7772 An assembler template is a literal string containing assembler instructions.
7773 The compiler replaces tokens in the template that refer
7774 to inputs, outputs, and goto labels,
7775 and then outputs the resulting string to the assembler. The
7776 string can contain any instructions recognized by the assembler, including
7777 directives. GCC does not parse the assembler instructions
7778 themselves and does not know what they mean or even whether they are valid
7779 assembler input. However, it does count the statements
7780 (@pxref{Size of an asm}).
7781
7782 You may place multiple assembler instructions together in a single @code{asm}
7783 string, separated by the characters normally used in assembly code for the
7784 system. A combination that works in most places is a newline to break the
7785 line, plus a tab character to move to the instruction field (written as
7786 @samp{\n\t}).
7787 Some assemblers allow semicolons as a line separator. However, note
7788 that some assembler dialects use semicolons to start a comment.
7789
7790 Do not expect a sequence of @code{asm} statements to remain perfectly
7791 consecutive after compilation, even when you are using the @code{volatile}
7792 qualifier. If certain instructions need to remain consecutive in the output,
7793 put them in a single multi-instruction asm statement.
7794
7795 Accessing data from C programs without using input/output operands (such as
7796 by using global symbols directly from the assembler template) may not work as
7797 expected. Similarly, calling functions directly from an assembler template
7798 requires a detailed understanding of the target assembler and ABI.
7799
7800 Since GCC does not parse the assembler template,
7801 it has no visibility of any
7802 symbols it references. This may result in GCC discarding those symbols as
7803 unreferenced unless they are also listed as input, output, or goto operands.
7804
7805 @subsubheading Special format strings
7806
7807 In addition to the tokens described by the input, output, and goto operands,
7808 these tokens have special meanings in the assembler template:
7809
7810 @table @samp
7811 @item %%
7812 Outputs a single @samp{%} into the assembler code.
7813
7814 @item %=
7815 Outputs a number that is unique to each instance of the @code{asm}
7816 statement in the entire compilation. This option is useful when creating local
7817 labels and referring to them multiple times in a single template that
7818 generates multiple assembler instructions.
7819
7820 @item %@{
7821 @itemx %|
7822 @itemx %@}
7823 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7824 into the assembler code. When unescaped, these characters have special
7825 meaning to indicate multiple assembler dialects, as described below.
7826 @end table
7827
7828 @subsubheading Multiple assembler dialects in @code{asm} templates
7829
7830 On targets such as x86, GCC supports multiple assembler dialects.
7831 The @option{-masm} option controls which dialect GCC uses as its
7832 default for inline assembler. The target-specific documentation for the
7833 @option{-masm} option contains the list of supported dialects, as well as the
7834 default dialect if the option is not specified. This information may be
7835 important to understand, since assembler code that works correctly when
7836 compiled using one dialect will likely fail if compiled using another.
7837 @xref{x86 Options}.
7838
7839 If your code needs to support multiple assembler dialects (for example, if
7840 you are writing public headers that need to support a variety of compilation
7841 options), use constructs of this form:
7842
7843 @example
7844 @{ dialect0 | dialect1 | dialect2... @}
7845 @end example
7846
7847 This construct outputs @code{dialect0}
7848 when using dialect #0 to compile the code,
7849 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7850 braces than the number of dialects the compiler supports, the construct
7851 outputs nothing.
7852
7853 For example, if an x86 compiler supports two dialects
7854 (@samp{att}, @samp{intel}), an
7855 assembler template such as this:
7856
7857 @example
7858 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7859 @end example
7860
7861 @noindent
7862 is equivalent to one of
7863
7864 @example
7865 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7866 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7867 @end example
7868
7869 Using that same compiler, this code:
7870
7871 @example
7872 "xchg@{l@}\t@{%%@}ebx, %1"
7873 @end example
7874
7875 @noindent
7876 corresponds to either
7877
7878 @example
7879 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7880 "xchg\tebx, %1" @r{/* intel dialect */}
7881 @end example
7882
7883 There is no support for nesting dialect alternatives.
7884
7885 @anchor{OutputOperands}
7886 @subsubsection Output Operands
7887 @cindex @code{asm} output operands
7888
7889 An @code{asm} statement has zero or more output operands indicating the names
7890 of C variables modified by the assembler code.
7891
7892 In this i386 example, @code{old} (referred to in the template string as
7893 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7894 (@code{%2}) is an input:
7895
7896 @example
7897 bool old;
7898
7899 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7900 "sbb %0,%0" // Use the CF to calculate old.
7901 : "=r" (old), "+rm" (*Base)
7902 : "Ir" (Offset)
7903 : "cc");
7904
7905 return old;
7906 @end example
7907
7908 Operands are separated by commas. Each operand has this format:
7909
7910 @example
7911 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7912 @end example
7913
7914 @table @var
7915 @item asmSymbolicName
7916 Specifies a symbolic name for the operand.
7917 Reference the name in the assembler template
7918 by enclosing it in square brackets
7919 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7920 that contains the definition. Any valid C variable name is acceptable,
7921 including names already defined in the surrounding code. No two operands
7922 within the same @code{asm} statement can use the same symbolic name.
7923
7924 When not using an @var{asmSymbolicName}, use the (zero-based) position
7925 of the operand
7926 in the list of operands in the assembler template. For example if there are
7927 three output operands, use @samp{%0} in the template to refer to the first,
7928 @samp{%1} for the second, and @samp{%2} for the third.
7929
7930 @item constraint
7931 A string constant specifying constraints on the placement of the operand;
7932 @xref{Constraints}, for details.
7933
7934 Output constraints must begin with either @samp{=} (a variable overwriting an
7935 existing value) or @samp{+} (when reading and writing). When using
7936 @samp{=}, do not assume the location contains the existing value
7937 on entry to the @code{asm}, except
7938 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7939
7940 After the prefix, there must be one or more additional constraints
7941 (@pxref{Constraints}) that describe where the value resides. Common
7942 constraints include @samp{r} for register and @samp{m} for memory.
7943 When you list more than one possible location (for example, @code{"=rm"}),
7944 the compiler chooses the most efficient one based on the current context.
7945 If you list as many alternates as the @code{asm} statement allows, you permit
7946 the optimizers to produce the best possible code.
7947 If you must use a specific register, but your Machine Constraints do not
7948 provide sufficient control to select the specific register you want,
7949 local register variables may provide a solution (@pxref{Local Register
7950 Variables}).
7951
7952 @item cvariablename
7953 Specifies a C lvalue expression to hold the output, typically a variable name.
7954 The enclosing parentheses are a required part of the syntax.
7955
7956 @end table
7957
7958 When the compiler selects the registers to use to
7959 represent the output operands, it does not use any of the clobbered registers
7960 (@pxref{Clobbers}).
7961
7962 Output operand expressions must be lvalues. The compiler cannot check whether
7963 the operands have data types that are reasonable for the instruction being
7964 executed. For output expressions that are not directly addressable (for
7965 example a bit-field), the constraint must allow a register. In that case, GCC
7966 uses the register as the output of the @code{asm}, and then stores that
7967 register into the output.
7968
7969 Operands using the @samp{+} constraint modifier count as two operands
7970 (that is, both as input and output) towards the total maximum of 30 operands
7971 per @code{asm} statement.
7972
7973 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7974 operands that must not overlap an input. Otherwise,
7975 GCC may allocate the output operand in the same register as an unrelated
7976 input operand, on the assumption that the assembler code consumes its
7977 inputs before producing outputs. This assumption may be false if the assembler
7978 code actually consists of more than one instruction.
7979
7980 The same problem can occur if one output parameter (@var{a}) allows a register
7981 constraint and another output parameter (@var{b}) allows a memory constraint.
7982 The code generated by GCC to access the memory address in @var{b} can contain
7983 registers which @emph{might} be shared by @var{a}, and GCC considers those
7984 registers to be inputs to the asm. As above, GCC assumes that such input
7985 registers are consumed before any outputs are written. This assumption may
7986 result in incorrect behavior if the asm writes to @var{a} before using
7987 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7988 ensures that modifying @var{a} does not affect the address referenced by
7989 @var{b}. Otherwise, the location of @var{b}
7990 is undefined if @var{a} is modified before using @var{b}.
7991
7992 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
7993 instead of simply @samp{%2}). Typically these qualifiers are hardware
7994 dependent. The list of supported modifiers for x86 is found at
7995 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7996
7997 If the C code that follows the @code{asm} makes no use of any of the output
7998 operands, use @code{volatile} for the @code{asm} statement to prevent the
7999 optimizers from discarding the @code{asm} statement as unneeded
8000 (see @ref{Volatile}).
8001
8002 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8003 references the first output operand as @code{%0} (were there a second, it
8004 would be @code{%1}, etc). The number of the first input operand is one greater
8005 than that of the last output operand. In this i386 example, that makes
8006 @code{Mask} referenced as @code{%1}:
8007
8008 @example
8009 uint32_t Mask = 1234;
8010 uint32_t Index;
8011
8012 asm ("bsfl %1, %0"
8013 : "=r" (Index)
8014 : "r" (Mask)
8015 : "cc");
8016 @end example
8017
8018 That code overwrites the variable @code{Index} (@samp{=}),
8019 placing the value in a register (@samp{r}).
8020 Using the generic @samp{r} constraint instead of a constraint for a specific
8021 register allows the compiler to pick the register to use, which can result
8022 in more efficient code. This may not be possible if an assembler instruction
8023 requires a specific register.
8024
8025 The following i386 example uses the @var{asmSymbolicName} syntax.
8026 It produces the
8027 same result as the code above, but some may consider it more readable or more
8028 maintainable since reordering index numbers is not necessary when adding or
8029 removing operands. The names @code{aIndex} and @code{aMask}
8030 are only used in this example to emphasize which
8031 names get used where.
8032 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8033
8034 @example
8035 uint32_t Mask = 1234;
8036 uint32_t Index;
8037
8038 asm ("bsfl %[aMask], %[aIndex]"
8039 : [aIndex] "=r" (Index)
8040 : [aMask] "r" (Mask)
8041 : "cc");
8042 @end example
8043
8044 Here are some more examples of output operands.
8045
8046 @example
8047 uint32_t c = 1;
8048 uint32_t d;
8049 uint32_t *e = &c;
8050
8051 asm ("mov %[e], %[d]"
8052 : [d] "=rm" (d)
8053 : [e] "rm" (*e));
8054 @end example
8055
8056 Here, @code{d} may either be in a register or in memory. Since the compiler
8057 might already have the current value of the @code{uint32_t} location
8058 pointed to by @code{e}
8059 in a register, you can enable it to choose the best location
8060 for @code{d} by specifying both constraints.
8061
8062 @anchor{FlagOutputOperands}
8063 @subsubsection Flag Output Operands
8064 @cindex @code{asm} flag output operands
8065
8066 Some targets have a special register that holds the ``flags'' for the
8067 result of an operation or comparison. Normally, the contents of that
8068 register are either unmodifed by the asm, or the asm is considered to
8069 clobber the contents.
8070
8071 On some targets, a special form of output operand exists by which
8072 conditions in the flags register may be outputs of the asm. The set of
8073 conditions supported are target specific, but the general rule is that
8074 the output variable must be a scalar integer, and the value is boolean.
8075 When supported, the target defines the preprocessor symbol
8076 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8077
8078 Because of the special nature of the flag output operands, the constraint
8079 may not include alternatives.
8080
8081 Most often, the target has only one flags register, and thus is an implied
8082 operand of many instructions. In this case, the operand should not be
8083 referenced within the assembler template via @code{%0} etc, as there's
8084 no corresponding text in the assembly language.
8085
8086 @table @asis
8087 @item x86 family
8088 The flag output constraints for the x86 family are of the form
8089 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8090 conditions defined in the ISA manual for @code{j@var{cc}} or
8091 @code{set@var{cc}}.
8092
8093 @table @code
8094 @item a
8095 ``above'' or unsigned greater than
8096 @item ae
8097 ``above or equal'' or unsigned greater than or equal
8098 @item b
8099 ``below'' or unsigned less than
8100 @item be
8101 ``below or equal'' or unsigned less than or equal
8102 @item c
8103 carry flag set
8104 @item e
8105 @itemx z
8106 ``equal'' or zero flag set
8107 @item g
8108 signed greater than
8109 @item ge
8110 signed greater than or equal
8111 @item l
8112 signed less than
8113 @item le
8114 signed less than or equal
8115 @item o
8116 overflow flag set
8117 @item p
8118 parity flag set
8119 @item s
8120 sign flag set
8121 @item na
8122 @itemx nae
8123 @itemx nb
8124 @itemx nbe
8125 @itemx nc
8126 @itemx ne
8127 @itemx ng
8128 @itemx nge
8129 @itemx nl
8130 @itemx nle
8131 @itemx no
8132 @itemx np
8133 @itemx ns
8134 @itemx nz
8135 ``not'' @var{flag}, or inverted versions of those above
8136 @end table
8137
8138 @end table
8139
8140 @anchor{InputOperands}
8141 @subsubsection Input Operands
8142 @cindex @code{asm} input operands
8143 @cindex @code{asm} expressions
8144
8145 Input operands make values from C variables and expressions available to the
8146 assembly code.
8147
8148 Operands are separated by commas. Each operand has this format:
8149
8150 @example
8151 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8152 @end example
8153
8154 @table @var
8155 @item asmSymbolicName
8156 Specifies a symbolic name for the operand.
8157 Reference the name in the assembler template
8158 by enclosing it in square brackets
8159 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8160 that contains the definition. Any valid C variable name is acceptable,
8161 including names already defined in the surrounding code. No two operands
8162 within the same @code{asm} statement can use the same symbolic name.
8163
8164 When not using an @var{asmSymbolicName}, use the (zero-based) position
8165 of the operand
8166 in the list of operands in the assembler template. For example if there are
8167 two output operands and three inputs,
8168 use @samp{%2} in the template to refer to the first input operand,
8169 @samp{%3} for the second, and @samp{%4} for the third.
8170
8171 @item constraint
8172 A string constant specifying constraints on the placement of the operand;
8173 @xref{Constraints}, for details.
8174
8175 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8176 When you list more than one possible location (for example, @samp{"irm"}),
8177 the compiler chooses the most efficient one based on the current context.
8178 If you must use a specific register, but your Machine Constraints do not
8179 provide sufficient control to select the specific register you want,
8180 local register variables may provide a solution (@pxref{Local Register
8181 Variables}).
8182
8183 Input constraints can also be digits (for example, @code{"0"}). This indicates
8184 that the specified input must be in the same place as the output constraint
8185 at the (zero-based) index in the output constraint list.
8186 When using @var{asmSymbolicName} syntax for the output operands,
8187 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8188
8189 @item cexpression
8190 This is the C variable or expression being passed to the @code{asm} statement
8191 as input. The enclosing parentheses are a required part of the syntax.
8192
8193 @end table
8194
8195 When the compiler selects the registers to use to represent the input
8196 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8197
8198 If there are no output operands but there are input operands, place two
8199 consecutive colons where the output operands would go:
8200
8201 @example
8202 __asm__ ("some instructions"
8203 : /* No outputs. */
8204 : "r" (Offset / 8));
8205 @end example
8206
8207 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8208 (except for inputs tied to outputs). The compiler assumes that on exit from
8209 the @code{asm} statement these operands contain the same values as they
8210 had before executing the statement.
8211 It is @emph{not} possible to use clobbers
8212 to inform the compiler that the values in these inputs are changing. One
8213 common work-around is to tie the changing input variable to an output variable
8214 that never gets used. Note, however, that if the code that follows the
8215 @code{asm} statement makes no use of any of the output operands, the GCC
8216 optimizers may discard the @code{asm} statement as unneeded
8217 (see @ref{Volatile}).
8218
8219 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8220 instead of simply @samp{%2}). Typically these qualifiers are hardware
8221 dependent. The list of supported modifiers for x86 is found at
8222 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8223
8224 In this example using the fictitious @code{combine} instruction, the
8225 constraint @code{"0"} for input operand 1 says that it must occupy the same
8226 location as output operand 0. Only input operands may use numbers in
8227 constraints, and they must each refer to an output operand. Only a number (or
8228 the symbolic assembler name) in the constraint can guarantee that one operand
8229 is in the same place as another. The mere fact that @code{foo} is the value of
8230 both operands is not enough to guarantee that they are in the same place in
8231 the generated assembler code.
8232
8233 @example
8234 asm ("combine %2, %0"
8235 : "=r" (foo)
8236 : "0" (foo), "g" (bar));
8237 @end example
8238
8239 Here is an example using symbolic names.
8240
8241 @example
8242 asm ("cmoveq %1, %2, %[result]"
8243 : [result] "=r"(result)
8244 : "r" (test), "r" (new), "[result]" (old));
8245 @end example
8246
8247 @anchor{Clobbers}
8248 @subsubsection Clobbers
8249 @cindex @code{asm} clobbers
8250
8251 While the compiler is aware of changes to entries listed in the output
8252 operands, the inline @code{asm} code may modify more than just the outputs. For
8253 example, calculations may require additional registers, or the processor may
8254 overwrite a register as a side effect of a particular assembler instruction.
8255 In order to inform the compiler of these changes, list them in the clobber
8256 list. Clobber list items are either register names or the special clobbers
8257 (listed below). Each clobber list item is a string constant
8258 enclosed in double quotes and separated by commas.
8259
8260 Clobber descriptions may not in any way overlap with an input or output
8261 operand. For example, you may not have an operand describing a register class
8262 with one member when listing that register in the clobber list. Variables
8263 declared to live in specific registers (@pxref{Explicit Register
8264 Variables}) and used
8265 as @code{asm} input or output operands must have no part mentioned in the
8266 clobber description. In particular, there is no way to specify that input
8267 operands get modified without also specifying them as output operands.
8268
8269 When the compiler selects which registers to use to represent input and output
8270 operands, it does not use any of the clobbered registers. As a result,
8271 clobbered registers are available for any use in the assembler code.
8272
8273 Here is a realistic example for the VAX showing the use of clobbered
8274 registers:
8275
8276 @example
8277 asm volatile ("movc3 %0, %1, %2"
8278 : /* No outputs. */
8279 : "g" (from), "g" (to), "g" (count)
8280 : "r0", "r1", "r2", "r3", "r4", "r5");
8281 @end example
8282
8283 Also, there are two special clobber arguments:
8284
8285 @table @code
8286 @item "cc"
8287 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8288 register. On some machines, GCC represents the condition codes as a specific
8289 hardware register; @code{"cc"} serves to name this register.
8290 On other machines, condition code handling is different,
8291 and specifying @code{"cc"} has no effect. But
8292 it is valid no matter what the target.
8293
8294 @item "memory"
8295 The @code{"memory"} clobber tells the compiler that the assembly code
8296 performs memory
8297 reads or writes to items other than those listed in the input and output
8298 operands (for example, accessing the memory pointed to by one of the input
8299 parameters). To ensure memory contains correct values, GCC may need to flush
8300 specific register values to memory before executing the @code{asm}. Further,
8301 the compiler does not assume that any values read from memory before an
8302 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8303 needed.
8304 Using the @code{"memory"} clobber effectively forms a read/write
8305 memory barrier for the compiler.
8306
8307 Note that this clobber does not prevent the @emph{processor} from doing
8308 speculative reads past the @code{asm} statement. To prevent that, you need
8309 processor-specific fence instructions.
8310
8311 Flushing registers to memory has performance implications and may be an issue
8312 for time-sensitive code. You can use a trick to avoid this if the size of
8313 the memory being accessed is known at compile time. For example, if accessing
8314 ten bytes of a string, use a memory input like:
8315
8316 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8317
8318 @end table
8319
8320 @anchor{GotoLabels}
8321 @subsubsection Goto Labels
8322 @cindex @code{asm} goto labels
8323
8324 @code{asm goto} allows assembly code to jump to one or more C labels. The
8325 @var{GotoLabels} section in an @code{asm goto} statement contains
8326 a comma-separated
8327 list of all C labels to which the assembler code may jump. GCC assumes that
8328 @code{asm} execution falls through to the next statement (if this is not the
8329 case, consider using the @code{__builtin_unreachable} intrinsic after the
8330 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8331 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8332 Attributes}).
8333
8334 An @code{asm goto} statement cannot have outputs.
8335 This is due to an internal restriction of
8336 the compiler: control transfer instructions cannot have outputs.
8337 If the assembler code does modify anything, use the @code{"memory"} clobber
8338 to force the
8339 optimizers to flush all register values to memory and reload them if
8340 necessary after the @code{asm} statement.
8341
8342 Also note that an @code{asm goto} statement is always implicitly
8343 considered volatile.
8344
8345 To reference a label in the assembler template,
8346 prefix it with @samp{%l} (lowercase @samp{L}) followed
8347 by its (zero-based) position in @var{GotoLabels} plus the number of input
8348 operands. For example, if the @code{asm} has three inputs and references two
8349 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8350
8351 Alternately, you can reference labels using the actual C label name enclosed
8352 in brackets. For example, to reference a label named @code{carry}, you can
8353 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8354 section when using this approach.
8355
8356 Here is an example of @code{asm goto} for i386:
8357
8358 @example
8359 asm goto (
8360 "btl %1, %0\n\t"
8361 "jc %l2"
8362 : /* No outputs. */
8363 : "r" (p1), "r" (p2)
8364 : "cc"
8365 : carry);
8366
8367 return 0;
8368
8369 carry:
8370 return 1;
8371 @end example
8372
8373 The following example shows an @code{asm goto} that uses a memory clobber.
8374
8375 @example
8376 int frob(int x)
8377 @{
8378 int y;
8379 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8380 : /* No outputs. */
8381 : "r"(x), "r"(&y)
8382 : "r5", "memory"
8383 : error);
8384 return y;
8385 error:
8386 return -1;
8387 @}
8388 @end example
8389
8390 @anchor{x86Operandmodifiers}
8391 @subsubsection x86 Operand Modifiers
8392
8393 References to input, output, and goto operands in the assembler template
8394 of extended @code{asm} statements can use
8395 modifiers to affect the way the operands are formatted in
8396 the code output to the assembler. For example, the
8397 following code uses the @samp{h} and @samp{b} modifiers for x86:
8398
8399 @example
8400 uint16_t num;
8401 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8402 @end example
8403
8404 @noindent
8405 These modifiers generate this assembler code:
8406
8407 @example
8408 xchg %ah, %al
8409 @end example
8410
8411 The rest of this discussion uses the following code for illustrative purposes.
8412
8413 @example
8414 int main()
8415 @{
8416 int iInt = 1;
8417
8418 top:
8419
8420 asm volatile goto ("some assembler instructions here"
8421 : /* No outputs. */
8422 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8423 : /* No clobbers. */
8424 : top);
8425 @}
8426 @end example
8427
8428 With no modifiers, this is what the output from the operands would be for the
8429 @samp{att} and @samp{intel} dialects of assembler:
8430
8431 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8432 @headitem Operand @tab masm=att @tab masm=intel
8433 @item @code{%0}
8434 @tab @code{%eax}
8435 @tab @code{eax}
8436 @item @code{%1}
8437 @tab @code{$2}
8438 @tab @code{2}
8439 @item @code{%2}
8440 @tab @code{$.L2}
8441 @tab @code{OFFSET FLAT:.L2}
8442 @end multitable
8443
8444 The table below shows the list of supported modifiers and their effects.
8445
8446 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8447 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8448 @item @code{z}
8449 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8450 @tab @code{%z0}
8451 @tab @code{l}
8452 @tab
8453 @item @code{b}
8454 @tab Print the QImode name of the register.
8455 @tab @code{%b0}
8456 @tab @code{%al}
8457 @tab @code{al}
8458 @item @code{h}
8459 @tab Print the QImode name for a ``high'' register.
8460 @tab @code{%h0}
8461 @tab @code{%ah}
8462 @tab @code{ah}
8463 @item @code{w}
8464 @tab Print the HImode name of the register.
8465 @tab @code{%w0}
8466 @tab @code{%ax}
8467 @tab @code{ax}
8468 @item @code{k}
8469 @tab Print the SImode name of the register.
8470 @tab @code{%k0}
8471 @tab @code{%eax}
8472 @tab @code{eax}
8473 @item @code{q}
8474 @tab Print the DImode name of the register.
8475 @tab @code{%q0}
8476 @tab @code{%rax}
8477 @tab @code{rax}
8478 @item @code{l}
8479 @tab Print the label name with no punctuation.
8480 @tab @code{%l2}
8481 @tab @code{.L2}
8482 @tab @code{.L2}
8483 @item @code{c}
8484 @tab Require a constant operand and print the constant expression with no punctuation.
8485 @tab @code{%c1}
8486 @tab @code{2}
8487 @tab @code{2}
8488 @end multitable
8489
8490 @anchor{x86floatingpointasmoperands}
8491 @subsubsection x86 Floating-Point @code{asm} Operands
8492
8493 On x86 targets, there are several rules on the usage of stack-like registers
8494 in the operands of an @code{asm}. These rules apply only to the operands
8495 that are stack-like registers:
8496
8497 @enumerate
8498 @item
8499 Given a set of input registers that die in an @code{asm}, it is
8500 necessary to know which are implicitly popped by the @code{asm}, and
8501 which must be explicitly popped by GCC@.
8502
8503 An input register that is implicitly popped by the @code{asm} must be
8504 explicitly clobbered, unless it is constrained to match an
8505 output operand.
8506
8507 @item
8508 For any input register that is implicitly popped by an @code{asm}, it is
8509 necessary to know how to adjust the stack to compensate for the pop.
8510 If any non-popped input is closer to the top of the reg-stack than
8511 the implicitly popped register, it would not be possible to know what the
8512 stack looked like---it's not clear how the rest of the stack ``slides
8513 up''.
8514
8515 All implicitly popped input registers must be closer to the top of
8516 the reg-stack than any input that is not implicitly popped.
8517
8518 It is possible that if an input dies in an @code{asm}, the compiler might
8519 use the input register for an output reload. Consider this example:
8520
8521 @smallexample
8522 asm ("foo" : "=t" (a) : "f" (b));
8523 @end smallexample
8524
8525 @noindent
8526 This code says that input @code{b} is not popped by the @code{asm}, and that
8527 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8528 deeper after the @code{asm} than it was before. But, it is possible that
8529 reload may think that it can use the same register for both the input and
8530 the output.
8531
8532 To prevent this from happening,
8533 if any input operand uses the @samp{f} constraint, all output register
8534 constraints must use the @samp{&} early-clobber modifier.
8535
8536 The example above is correctly written as:
8537
8538 @smallexample
8539 asm ("foo" : "=&t" (a) : "f" (b));
8540 @end smallexample
8541
8542 @item
8543 Some operands need to be in particular places on the stack. All
8544 output operands fall in this category---GCC has no other way to
8545 know which registers the outputs appear in unless you indicate
8546 this in the constraints.
8547
8548 Output operands must specifically indicate which register an output
8549 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8550 constraints must select a class with a single register.
8551
8552 @item
8553 Output operands may not be ``inserted'' between existing stack registers.
8554 Since no 387 opcode uses a read/write operand, all output operands
8555 are dead before the @code{asm}, and are pushed by the @code{asm}.
8556 It makes no sense to push anywhere but the top of the reg-stack.
8557
8558 Output operands must start at the top of the reg-stack: output
8559 operands may not ``skip'' a register.
8560
8561 @item
8562 Some @code{asm} statements may need extra stack space for internal
8563 calculations. This can be guaranteed by clobbering stack registers
8564 unrelated to the inputs and outputs.
8565
8566 @end enumerate
8567
8568 This @code{asm}
8569 takes one input, which is internally popped, and produces two outputs.
8570
8571 @smallexample
8572 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8573 @end smallexample
8574
8575 @noindent
8576 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8577 and replaces them with one output. The @code{st(1)} clobber is necessary
8578 for the compiler to know that @code{fyl2xp1} pops both inputs.
8579
8580 @smallexample
8581 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8582 @end smallexample
8583
8584 @lowersections
8585 @include md.texi
8586 @raisesections
8587
8588 @node Asm Labels
8589 @subsection Controlling Names Used in Assembler Code
8590 @cindex assembler names for identifiers
8591 @cindex names used in assembler code
8592 @cindex identifiers, names in assembler code
8593
8594 You can specify the name to be used in the assembler code for a C
8595 function or variable by writing the @code{asm} (or @code{__asm__})
8596 keyword after the declarator.
8597 It is up to you to make sure that the assembler names you choose do not
8598 conflict with any other assembler symbols, or reference registers.
8599
8600 @subsubheading Assembler names for data:
8601
8602 This sample shows how to specify the assembler name for data:
8603
8604 @smallexample
8605 int foo asm ("myfoo") = 2;
8606 @end smallexample
8607
8608 @noindent
8609 This specifies that the name to be used for the variable @code{foo} in
8610 the assembler code should be @samp{myfoo} rather than the usual
8611 @samp{_foo}.
8612
8613 On systems where an underscore is normally prepended to the name of a C
8614 variable, this feature allows you to define names for the
8615 linker that do not start with an underscore.
8616
8617 GCC does not support using this feature with a non-static local variable
8618 since such variables do not have assembler names. If you are
8619 trying to put the variable in a particular register, see
8620 @ref{Explicit Register Variables}.
8621
8622 @subsubheading Assembler names for functions:
8623
8624 To specify the assembler name for functions, write a declaration for the
8625 function before its definition and put @code{asm} there, like this:
8626
8627 @smallexample
8628 int func (int x, int y) asm ("MYFUNC");
8629
8630 int func (int x, int y)
8631 @{
8632 /* @r{@dots{}} */
8633 @end smallexample
8634
8635 @noindent
8636 This specifies that the name to be used for the function @code{func} in
8637 the assembler code should be @code{MYFUNC}.
8638
8639 @node Explicit Register Variables
8640 @subsection Variables in Specified Registers
8641 @anchor{Explicit Reg Vars}
8642 @cindex explicit register variables
8643 @cindex variables in specified registers
8644 @cindex specified registers
8645
8646 GNU C allows you to associate specific hardware registers with C
8647 variables. In almost all cases, allowing the compiler to assign
8648 registers produces the best code. However under certain unusual
8649 circumstances, more precise control over the variable storage is
8650 required.
8651
8652 Both global and local variables can be associated with a register. The
8653 consequences of performing this association are very different between
8654 the two, as explained in the sections below.
8655
8656 @menu
8657 * Global Register Variables:: Variables declared at global scope.
8658 * Local Register Variables:: Variables declared within a function.
8659 @end menu
8660
8661 @node Global Register Variables
8662 @subsubsection Defining Global Register Variables
8663 @anchor{Global Reg Vars}
8664 @cindex global register variables
8665 @cindex registers, global variables in
8666 @cindex registers, global allocation
8667
8668 You can define a global register variable and associate it with a specified
8669 register like this:
8670
8671 @smallexample
8672 register int *foo asm ("r12");
8673 @end smallexample
8674
8675 @noindent
8676 Here @code{r12} is the name of the register that should be used. Note that
8677 this is the same syntax used for defining local register variables, but for
8678 a global variable the declaration appears outside a function. The
8679 @code{register} keyword is required, and cannot be combined with
8680 @code{static}. The register name must be a valid register name for the
8681 target platform.
8682
8683 Registers are a scarce resource on most systems and allowing the
8684 compiler to manage their usage usually results in the best code. However,
8685 under special circumstances it can make sense to reserve some globally.
8686 For example this may be useful in programs such as programming language
8687 interpreters that have a couple of global variables that are accessed
8688 very often.
8689
8690 After defining a global register variable, for the current compilation
8691 unit:
8692
8693 @itemize @bullet
8694 @item The register is reserved entirely for this use, and will not be
8695 allocated for any other purpose.
8696 @item The register is not saved and restored by any functions.
8697 @item Stores into this register are never deleted even if they appear to be
8698 dead, but references may be deleted, moved or simplified.
8699 @end itemize
8700
8701 Note that these points @emph{only} apply to code that is compiled with the
8702 definition. The behavior of code that is merely linked in (for example
8703 code from libraries) is not affected.
8704
8705 If you want to recompile source files that do not actually use your global
8706 register variable so they do not use the specified register for any other
8707 purpose, you need not actually add the global register declaration to
8708 their source code. It suffices to specify the compiler option
8709 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8710 register.
8711
8712 @subsubheading Declaring the variable
8713
8714 Global register variables can not have initial values, because an
8715 executable file has no means to supply initial contents for a register.
8716
8717 When selecting a register, choose one that is normally saved and
8718 restored by function calls on your machine. This ensures that code
8719 which is unaware of this reservation (such as library routines) will
8720 restore it before returning.
8721
8722 On machines with register windows, be sure to choose a global
8723 register that is not affected magically by the function call mechanism.
8724
8725 @subsubheading Using the variable
8726
8727 @cindex @code{qsort}, and global register variables
8728 When calling routines that are not aware of the reservation, be
8729 cautious if those routines call back into code which uses them. As an
8730 example, if you call the system library version of @code{qsort}, it may
8731 clobber your registers during execution, but (if you have selected
8732 appropriate registers) it will restore them before returning. However
8733 it will @emph{not} restore them before calling @code{qsort}'s comparison
8734 function. As a result, global values will not reliably be available to
8735 the comparison function unless the @code{qsort} function itself is rebuilt.
8736
8737 Similarly, it is not safe to access the global register variables from signal
8738 handlers or from more than one thread of control. Unless you recompile
8739 them specially for the task at hand, the system library routines may
8740 temporarily use the register for other things.
8741
8742 @cindex register variable after @code{longjmp}
8743 @cindex global register after @code{longjmp}
8744 @cindex value after @code{longjmp}
8745 @findex longjmp
8746 @findex setjmp
8747 On most machines, @code{longjmp} restores to each global register
8748 variable the value it had at the time of the @code{setjmp}. On some
8749 machines, however, @code{longjmp} does not change the value of global
8750 register variables. To be portable, the function that called @code{setjmp}
8751 should make other arrangements to save the values of the global register
8752 variables, and to restore them in a @code{longjmp}. This way, the same
8753 thing happens regardless of what @code{longjmp} does.
8754
8755 Eventually there may be a way of asking the compiler to choose a register
8756 automatically, but first we need to figure out how it should choose and
8757 how to enable you to guide the choice. No solution is evident.
8758
8759 @node Local Register Variables
8760 @subsubsection Specifying Registers for Local Variables
8761 @anchor{Local Reg Vars}
8762 @cindex local variables, specifying registers
8763 @cindex specifying registers for local variables
8764 @cindex registers for local variables
8765
8766 You can define a local register variable and associate it with a specified
8767 register like this:
8768
8769 @smallexample
8770 register int *foo asm ("r12");
8771 @end smallexample
8772
8773 @noindent
8774 Here @code{r12} is the name of the register that should be used. Note
8775 that this is the same syntax used for defining global register variables,
8776 but for a local variable the declaration appears within a function. The
8777 @code{register} keyword is required, and cannot be combined with
8778 @code{static}. The register name must be a valid register name for the
8779 target platform.
8780
8781 As with global register variables, it is recommended that you choose
8782 a register that is normally saved and restored by function calls on your
8783 machine, so that calls to library routines will not clobber it.
8784
8785 The only supported use for this feature is to specify registers
8786 for input and output operands when calling Extended @code{asm}
8787 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8788 particular machine don't provide sufficient control to select the desired
8789 register. To force an operand into a register, create a local variable
8790 and specify the register name after the variable's declaration. Then use
8791 the local variable for the @code{asm} operand and specify any constraint
8792 letter that matches the register:
8793
8794 @smallexample
8795 register int *p1 asm ("r0") = @dots{};
8796 register int *p2 asm ("r1") = @dots{};
8797 register int *result asm ("r0");
8798 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8799 @end smallexample
8800
8801 @emph{Warning:} In the above example, be aware that a register (for example
8802 @code{r0}) can be call-clobbered by subsequent code, including function
8803 calls and library calls for arithmetic operators on other variables (for
8804 example the initialization of @code{p2}). In this case, use temporary
8805 variables for expressions between the register assignments:
8806
8807 @smallexample
8808 int t1 = @dots{};
8809 register int *p1 asm ("r0") = @dots{};
8810 register int *p2 asm ("r1") = t1;
8811 register int *result asm ("r0");
8812 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8813 @end smallexample
8814
8815 Defining a register variable does not reserve the register. Other than
8816 when invoking the Extended @code{asm}, the contents of the specified
8817 register are not guaranteed. For this reason, the following uses
8818 are explicitly @emph{not} supported. If they appear to work, it is only
8819 happenstance, and may stop working as intended due to (seemingly)
8820 unrelated changes in surrounding code, or even minor changes in the
8821 optimization of a future version of gcc:
8822
8823 @itemize @bullet
8824 @item Passing parameters to or from Basic @code{asm}
8825 @item Passing parameters to or from Extended @code{asm} without using input
8826 or output operands.
8827 @item Passing parameters to or from routines written in assembler (or
8828 other languages) using non-standard calling conventions.
8829 @end itemize
8830
8831 Some developers use Local Register Variables in an attempt to improve
8832 gcc's allocation of registers, especially in large functions. In this
8833 case the register name is essentially a hint to the register allocator.
8834 While in some instances this can generate better code, improvements are
8835 subject to the whims of the allocator/optimizers. Since there are no
8836 guarantees that your improvements won't be lost, this usage of Local
8837 Register Variables is discouraged.
8838
8839 On the MIPS platform, there is related use for local register variables
8840 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8841 Defining coprocessor specifics for MIPS targets, gccint,
8842 GNU Compiler Collection (GCC) Internals}).
8843
8844 @node Size of an asm
8845 @subsection Size of an @code{asm}
8846
8847 Some targets require that GCC track the size of each instruction used
8848 in order to generate correct code. Because the final length of the
8849 code produced by an @code{asm} statement is only known by the
8850 assembler, GCC must make an estimate as to how big it will be. It
8851 does this by counting the number of instructions in the pattern of the
8852 @code{asm} and multiplying that by the length of the longest
8853 instruction supported by that processor. (When working out the number
8854 of instructions, it assumes that any occurrence of a newline or of
8855 whatever statement separator character is supported by the assembler --
8856 typically @samp{;} --- indicates the end of an instruction.)
8857
8858 Normally, GCC's estimate is adequate to ensure that correct
8859 code is generated, but it is possible to confuse the compiler if you use
8860 pseudo instructions or assembler macros that expand into multiple real
8861 instructions, or if you use assembler directives that expand to more
8862 space in the object file than is needed for a single instruction.
8863 If this happens then the assembler may produce a diagnostic saying that
8864 a label is unreachable.
8865
8866 @node Alternate Keywords
8867 @section Alternate Keywords
8868 @cindex alternate keywords
8869 @cindex keywords, alternate
8870
8871 @option{-ansi} and the various @option{-std} options disable certain
8872 keywords. This causes trouble when you want to use GNU C extensions, or
8873 a general-purpose header file that should be usable by all programs,
8874 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8875 @code{inline} are not available in programs compiled with
8876 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8877 program compiled with @option{-std=c99} or @option{-std=c11}). The
8878 ISO C99 keyword
8879 @code{restrict} is only available when @option{-std=gnu99} (which will
8880 eventually be the default) or @option{-std=c99} (or the equivalent
8881 @option{-std=iso9899:1999}), or an option for a later standard
8882 version, is used.
8883
8884 The way to solve these problems is to put @samp{__} at the beginning and
8885 end of each problematical keyword. For example, use @code{__asm__}
8886 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8887
8888 Other C compilers won't accept these alternative keywords; if you want to
8889 compile with another compiler, you can define the alternate keywords as
8890 macros to replace them with the customary keywords. It looks like this:
8891
8892 @smallexample
8893 #ifndef __GNUC__
8894 #define __asm__ asm
8895 #endif
8896 @end smallexample
8897
8898 @findex __extension__
8899 @opindex pedantic
8900 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8901 You can
8902 prevent such warnings within one expression by writing
8903 @code{__extension__} before the expression. @code{__extension__} has no
8904 effect aside from this.
8905
8906 @node Incomplete Enums
8907 @section Incomplete @code{enum} Types
8908
8909 You can define an @code{enum} tag without specifying its possible values.
8910 This results in an incomplete type, much like what you get if you write
8911 @code{struct foo} without describing the elements. A later declaration
8912 that does specify the possible values completes the type.
8913
8914 You can't allocate variables or storage using the type while it is
8915 incomplete. However, you can work with pointers to that type.
8916
8917 This extension may not be very useful, but it makes the handling of
8918 @code{enum} more consistent with the way @code{struct} and @code{union}
8919 are handled.
8920
8921 This extension is not supported by GNU C++.
8922
8923 @node Function Names
8924 @section Function Names as Strings
8925 @cindex @code{__func__} identifier
8926 @cindex @code{__FUNCTION__} identifier
8927 @cindex @code{__PRETTY_FUNCTION__} identifier
8928
8929 GCC provides three magic variables that hold the name of the current
8930 function, as a string. The first of these is @code{__func__}, which
8931 is part of the C99 standard:
8932
8933 The identifier @code{__func__} is implicitly declared by the translator
8934 as if, immediately following the opening brace of each function
8935 definition, the declaration
8936
8937 @smallexample
8938 static const char __func__[] = "function-name";
8939 @end smallexample
8940
8941 @noindent
8942 appeared, where function-name is the name of the lexically-enclosing
8943 function. This name is the unadorned name of the function.
8944
8945 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8946 backward compatibility with old versions of GCC.
8947
8948 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8949 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8950 the type signature of the function as well as its bare name. For
8951 example, this program:
8952
8953 @smallexample
8954 extern "C" @{
8955 extern int printf (char *, ...);
8956 @}
8957
8958 class a @{
8959 public:
8960 void sub (int i)
8961 @{
8962 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8963 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8964 @}
8965 @};
8966
8967 int
8968 main (void)
8969 @{
8970 a ax;
8971 ax.sub (0);
8972 return 0;
8973 @}
8974 @end smallexample
8975
8976 @noindent
8977 gives this output:
8978
8979 @smallexample
8980 __FUNCTION__ = sub
8981 __PRETTY_FUNCTION__ = void a::sub(int)
8982 @end smallexample
8983
8984 These identifiers are variables, not preprocessor macros, and may not
8985 be used to initialize @code{char} arrays or be concatenated with other string
8986 literals.
8987
8988 @node Return Address
8989 @section Getting the Return or Frame Address of a Function
8990
8991 These functions may be used to get information about the callers of a
8992 function.
8993
8994 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8995 This function returns the return address of the current function, or of
8996 one of its callers. The @var{level} argument is number of frames to
8997 scan up the call stack. A value of @code{0} yields the return address
8998 of the current function, a value of @code{1} yields the return address
8999 of the caller of the current function, and so forth. When inlining
9000 the expected behavior is that the function returns the address of
9001 the function that is returned to. To work around this behavior use
9002 the @code{noinline} function attribute.
9003
9004 The @var{level} argument must be a constant integer.
9005
9006 On some machines it may be impossible to determine the return address of
9007 any function other than the current one; in such cases, or when the top
9008 of the stack has been reached, this function returns @code{0} or a
9009 random value. In addition, @code{__builtin_frame_address} may be used
9010 to determine if the top of the stack has been reached.
9011
9012 Additional post-processing of the returned value may be needed, see
9013 @code{__builtin_extract_return_addr}.
9014
9015 Calling this function with a nonzero argument can have unpredictable
9016 effects, including crashing the calling program. As a result, calls
9017 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9018 option is in effect. Such calls should only be made in debugging
9019 situations.
9020 @end deftypefn
9021
9022 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9023 The address as returned by @code{__builtin_return_address} may have to be fed
9024 through this function to get the actual encoded address. For example, on the
9025 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9026 platforms an offset has to be added for the true next instruction to be
9027 executed.
9028
9029 If no fixup is needed, this function simply passes through @var{addr}.
9030 @end deftypefn
9031
9032 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9033 This function does the reverse of @code{__builtin_extract_return_addr}.
9034 @end deftypefn
9035
9036 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9037 This function is similar to @code{__builtin_return_address}, but it
9038 returns the address of the function frame rather than the return address
9039 of the function. Calling @code{__builtin_frame_address} with a value of
9040 @code{0} yields the frame address of the current function, a value of
9041 @code{1} yields the frame address of the caller of the current function,
9042 and so forth.
9043
9044 The frame is the area on the stack that holds local variables and saved
9045 registers. The frame address is normally the address of the first word
9046 pushed on to the stack by the function. However, the exact definition
9047 depends upon the processor and the calling convention. If the processor
9048 has a dedicated frame pointer register, and the function has a frame,
9049 then @code{__builtin_frame_address} returns the value of the frame
9050 pointer register.
9051
9052 On some machines it may be impossible to determine the frame address of
9053 any function other than the current one; in such cases, or when the top
9054 of the stack has been reached, this function returns @code{0} if
9055 the first frame pointer is properly initialized by the startup code.
9056
9057 Calling this function with a nonzero argument can have unpredictable
9058 effects, including crashing the calling program. As a result, calls
9059 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9060 option is in effect. Such calls should only be made in debugging
9061 situations.
9062 @end deftypefn
9063
9064 @node Vector Extensions
9065 @section Using Vector Instructions through Built-in Functions
9066
9067 On some targets, the instruction set contains SIMD vector instructions which
9068 operate on multiple values contained in one large register at the same time.
9069 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9070 this way.
9071
9072 The first step in using these extensions is to provide the necessary data
9073 types. This should be done using an appropriate @code{typedef}:
9074
9075 @smallexample
9076 typedef int v4si __attribute__ ((vector_size (16)));
9077 @end smallexample
9078
9079 @noindent
9080 The @code{int} type specifies the base type, while the attribute specifies
9081 the vector size for the variable, measured in bytes. For example, the
9082 declaration above causes the compiler to set the mode for the @code{v4si}
9083 type to be 16 bytes wide and divided into @code{int} sized units. For
9084 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9085 corresponding mode of @code{foo} is @acronym{V4SI}.
9086
9087 The @code{vector_size} attribute is only applicable to integral and
9088 float scalars, although arrays, pointers, and function return values
9089 are allowed in conjunction with this construct. Only sizes that are
9090 a power of two are currently allowed.
9091
9092 All the basic integer types can be used as base types, both as signed
9093 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9094 @code{long long}. In addition, @code{float} and @code{double} can be
9095 used to build floating-point vector types.
9096
9097 Specifying a combination that is not valid for the current architecture
9098 causes GCC to synthesize the instructions using a narrower mode.
9099 For example, if you specify a variable of type @code{V4SI} and your
9100 architecture does not allow for this specific SIMD type, GCC
9101 produces code that uses 4 @code{SIs}.
9102
9103 The types defined in this manner can be used with a subset of normal C
9104 operations. Currently, GCC allows using the following operators
9105 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9106
9107 The operations behave like C++ @code{valarrays}. Addition is defined as
9108 the addition of the corresponding elements of the operands. For
9109 example, in the code below, each of the 4 elements in @var{a} is
9110 added to the corresponding 4 elements in @var{b} and the resulting
9111 vector is stored in @var{c}.
9112
9113 @smallexample
9114 typedef int v4si __attribute__ ((vector_size (16)));
9115
9116 v4si a, b, c;
9117
9118 c = a + b;
9119 @end smallexample
9120
9121 Subtraction, multiplication, division, and the logical operations
9122 operate in a similar manner. Likewise, the result of using the unary
9123 minus or complement operators on a vector type is a vector whose
9124 elements are the negative or complemented values of the corresponding
9125 elements in the operand.
9126
9127 It is possible to use shifting operators @code{<<}, @code{>>} on
9128 integer-type vectors. The operation is defined as following: @code{@{a0,
9129 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9130 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9131 elements.
9132
9133 For convenience, it is allowed to use a binary vector operation
9134 where one operand is a scalar. In that case the compiler transforms
9135 the scalar operand into a vector where each element is the scalar from
9136 the operation. The transformation happens only if the scalar could be
9137 safely converted to the vector-element type.
9138 Consider the following code.
9139
9140 @smallexample
9141 typedef int v4si __attribute__ ((vector_size (16)));
9142
9143 v4si a, b, c;
9144 long l;
9145
9146 a = b + 1; /* a = b + @{1,1,1,1@}; */
9147 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9148
9149 a = l + a; /* Error, cannot convert long to int. */
9150 @end smallexample
9151
9152 Vectors can be subscripted as if the vector were an array with
9153 the same number of elements and base type. Out of bound accesses
9154 invoke undefined behavior at run time. Warnings for out of bound
9155 accesses for vector subscription can be enabled with
9156 @option{-Warray-bounds}.
9157
9158 Vector comparison is supported with standard comparison
9159 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9160 vector expressions of integer-type or real-type. Comparison between
9161 integer-type vectors and real-type vectors are not supported. The
9162 result of the comparison is a vector of the same width and number of
9163 elements as the comparison operands with a signed integral element
9164 type.
9165
9166 Vectors are compared element-wise producing 0 when comparison is false
9167 and -1 (constant of the appropriate type where all bits are set)
9168 otherwise. Consider the following example.
9169
9170 @smallexample
9171 typedef int v4si __attribute__ ((vector_size (16)));
9172
9173 v4si a = @{1,2,3,4@};
9174 v4si b = @{3,2,1,4@};
9175 v4si c;
9176
9177 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9178 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9179 @end smallexample
9180
9181 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9182 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9183 integer vector with the same number of elements of the same size as @code{b}
9184 and @code{c}, computes all three arguments and creates a vector
9185 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9186 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9187 As in the case of binary operations, this syntax is also accepted when
9188 one of @code{b} or @code{c} is a scalar that is then transformed into a
9189 vector. If both @code{b} and @code{c} are scalars and the type of
9190 @code{true?b:c} has the same size as the element type of @code{a}, then
9191 @code{b} and @code{c} are converted to a vector type whose elements have
9192 this type and with the same number of elements as @code{a}.
9193
9194 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9195 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9196 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9197 For mixed operations between a scalar @code{s} and a vector @code{v},
9198 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9199 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9200
9201 Vector shuffling is available using functions
9202 @code{__builtin_shuffle (vec, mask)} and
9203 @code{__builtin_shuffle (vec0, vec1, mask)}.
9204 Both functions construct a permutation of elements from one or two
9205 vectors and return a vector of the same type as the input vector(s).
9206 The @var{mask} is an integral vector with the same width (@var{W})
9207 and element count (@var{N}) as the output vector.
9208
9209 The elements of the input vectors are numbered in memory ordering of
9210 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9211 elements of @var{mask} are considered modulo @var{N} in the single-operand
9212 case and modulo @math{2*@var{N}} in the two-operand case.
9213
9214 Consider the following example,
9215
9216 @smallexample
9217 typedef int v4si __attribute__ ((vector_size (16)));
9218
9219 v4si a = @{1,2,3,4@};
9220 v4si b = @{5,6,7,8@};
9221 v4si mask1 = @{0,1,1,3@};
9222 v4si mask2 = @{0,4,2,5@};
9223 v4si res;
9224
9225 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9226 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9227 @end smallexample
9228
9229 Note that @code{__builtin_shuffle} is intentionally semantically
9230 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9231
9232 You can declare variables and use them in function calls and returns, as
9233 well as in assignments and some casts. You can specify a vector type as
9234 a return type for a function. Vector types can also be used as function
9235 arguments. It is possible to cast from one vector type to another,
9236 provided they are of the same size (in fact, you can also cast vectors
9237 to and from other datatypes of the same size).
9238
9239 You cannot operate between vectors of different lengths or different
9240 signedness without a cast.
9241
9242 @node Offsetof
9243 @section Support for @code{offsetof}
9244 @findex __builtin_offsetof
9245
9246 GCC implements for both C and C++ a syntactic extension to implement
9247 the @code{offsetof} macro.
9248
9249 @smallexample
9250 primary:
9251 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9252
9253 offsetof_member_designator:
9254 @code{identifier}
9255 | offsetof_member_designator "." @code{identifier}
9256 | offsetof_member_designator "[" @code{expr} "]"
9257 @end smallexample
9258
9259 This extension is sufficient such that
9260
9261 @smallexample
9262 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9263 @end smallexample
9264
9265 @noindent
9266 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9267 may be dependent. In either case, @var{member} may consist of a single
9268 identifier, or a sequence of member accesses and array references.
9269
9270 @node __sync Builtins
9271 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9272
9273 The following built-in functions
9274 are intended to be compatible with those described
9275 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9276 section 7.4. As such, they depart from normal GCC practice by not using
9277 the @samp{__builtin_} prefix and also by being overloaded so that they
9278 work on multiple types.
9279
9280 The definition given in the Intel documentation allows only for the use of
9281 the types @code{int}, @code{long}, @code{long long} or their unsigned
9282 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9283 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9284 Operations on pointer arguments are performed as if the operands were
9285 of the @code{uintptr_t} type. That is, they are not scaled by the size
9286 of the type to which the pointer points.
9287
9288 These functions are implemented in terms of the @samp{__atomic}
9289 builtins (@pxref{__atomic Builtins}). They should not be used for new
9290 code which should use the @samp{__atomic} builtins instead.
9291
9292 Not all operations are supported by all target processors. If a particular
9293 operation cannot be implemented on the target processor, a warning is
9294 generated and a call to an external function is generated. The external
9295 function carries the same name as the built-in version,
9296 with an additional suffix
9297 @samp{_@var{n}} where @var{n} is the size of the data type.
9298
9299 @c ??? Should we have a mechanism to suppress this warning? This is almost
9300 @c useful for implementing the operation under the control of an external
9301 @c mutex.
9302
9303 In most cases, these built-in functions are considered a @dfn{full barrier}.
9304 That is,
9305 no memory operand is moved across the operation, either forward or
9306 backward. Further, instructions are issued as necessary to prevent the
9307 processor from speculating loads across the operation and from queuing stores
9308 after the operation.
9309
9310 All of the routines are described in the Intel documentation to take
9311 ``an optional list of variables protected by the memory barrier''. It's
9312 not clear what is meant by that; it could mean that @emph{only} the
9313 listed variables are protected, or it could mean a list of additional
9314 variables to be protected. The list is ignored by GCC which treats it as
9315 empty. GCC interprets an empty list as meaning that all globally
9316 accessible variables should be protected.
9317
9318 @table @code
9319 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9320 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9321 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9322 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9323 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9324 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9325 @findex __sync_fetch_and_add
9326 @findex __sync_fetch_and_sub
9327 @findex __sync_fetch_and_or
9328 @findex __sync_fetch_and_and
9329 @findex __sync_fetch_and_xor
9330 @findex __sync_fetch_and_nand
9331 These built-in functions perform the operation suggested by the name, and
9332 returns the value that had previously been in memory. That is, operations
9333 on integer operands have the following semantics. Operations on pointer
9334 arguments are performed as if the operands were of the @code{uintptr_t}
9335 type. That is, they are not scaled by the size of the type to which
9336 the pointer points.
9337
9338 @smallexample
9339 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9340 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9341 @end smallexample
9342
9343 The object pointed to by the first argument must be of integer or pointer
9344 type. It must not be a Boolean type.
9345
9346 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9347 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9348
9349 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9350 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9351 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9352 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9353 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9354 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9355 @findex __sync_add_and_fetch
9356 @findex __sync_sub_and_fetch
9357 @findex __sync_or_and_fetch
9358 @findex __sync_and_and_fetch
9359 @findex __sync_xor_and_fetch
9360 @findex __sync_nand_and_fetch
9361 These built-in functions perform the operation suggested by the name, and
9362 return the new value. That is, operations on integer operands have
9363 the following semantics. Operations on pointer operands are performed as
9364 if the operand's type were @code{uintptr_t}.
9365
9366 @smallexample
9367 @{ *ptr @var{op}= value; return *ptr; @}
9368 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9369 @end smallexample
9370
9371 The same constraints on arguments apply as for the corresponding
9372 @code{__sync_op_and_fetch} built-in functions.
9373
9374 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9375 as @code{*ptr = ~(*ptr & value)} instead of
9376 @code{*ptr = ~*ptr & value}.
9377
9378 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9379 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9380 @findex __sync_bool_compare_and_swap
9381 @findex __sync_val_compare_and_swap
9382 These built-in functions perform an atomic compare and swap.
9383 That is, if the current
9384 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9385 @code{*@var{ptr}}.
9386
9387 The ``bool'' version returns true if the comparison is successful and
9388 @var{newval} is written. The ``val'' version returns the contents
9389 of @code{*@var{ptr}} before the operation.
9390
9391 @item __sync_synchronize (...)
9392 @findex __sync_synchronize
9393 This built-in function issues a full memory barrier.
9394
9395 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9396 @findex __sync_lock_test_and_set
9397 This built-in function, as described by Intel, is not a traditional test-and-set
9398 operation, but rather an atomic exchange operation. It writes @var{value}
9399 into @code{*@var{ptr}}, and returns the previous contents of
9400 @code{*@var{ptr}}.
9401
9402 Many targets have only minimal support for such locks, and do not support
9403 a full exchange operation. In this case, a target may support reduced
9404 functionality here by which the @emph{only} valid value to store is the
9405 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9406 is implementation defined.
9407
9408 This built-in function is not a full barrier,
9409 but rather an @dfn{acquire barrier}.
9410 This means that references after the operation cannot move to (or be
9411 speculated to) before the operation, but previous memory stores may not
9412 be globally visible yet, and previous memory loads may not yet be
9413 satisfied.
9414
9415 @item void __sync_lock_release (@var{type} *ptr, ...)
9416 @findex __sync_lock_release
9417 This built-in function releases the lock acquired by
9418 @code{__sync_lock_test_and_set}.
9419 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9420
9421 This built-in function is not a full barrier,
9422 but rather a @dfn{release barrier}.
9423 This means that all previous memory stores are globally visible, and all
9424 previous memory loads have been satisfied, but following memory reads
9425 are not prevented from being speculated to before the barrier.
9426 @end table
9427
9428 @node __atomic Builtins
9429 @section Built-in Functions for Memory Model Aware Atomic Operations
9430
9431 The following built-in functions approximately match the requirements
9432 for the C++11 memory model. They are all
9433 identified by being prefixed with @samp{__atomic} and most are
9434 overloaded so that they work with multiple types.
9435
9436 These functions are intended to replace the legacy @samp{__sync}
9437 builtins. The main difference is that the memory order that is requested
9438 is a parameter to the functions. New code should always use the
9439 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9440
9441 Note that the @samp{__atomic} builtins assume that programs will
9442 conform to the C++11 memory model. In particular, they assume
9443 that programs are free of data races. See the C++11 standard for
9444 detailed requirements.
9445
9446 The @samp{__atomic} builtins can be used with any integral scalar or
9447 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9448 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9449 supported by the architecture.
9450
9451 The four non-arithmetic functions (load, store, exchange, and
9452 compare_exchange) all have a generic version as well. This generic
9453 version works on any data type. It uses the lock-free built-in function
9454 if the specific data type size makes that possible; otherwise, an
9455 external call is left to be resolved at run time. This external call is
9456 the same format with the addition of a @samp{size_t} parameter inserted
9457 as the first parameter indicating the size of the object being pointed to.
9458 All objects must be the same size.
9459
9460 There are 6 different memory orders that can be specified. These map
9461 to the C++11 memory orders with the same names, see the C++11 standard
9462 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9463 on atomic synchronization} for detailed definitions. Individual
9464 targets may also support additional memory orders for use on specific
9465 architectures. Refer to the target documentation for details of
9466 these.
9467
9468 An atomic operation can both constrain code motion and
9469 be mapped to hardware instructions for synchronization between threads
9470 (e.g., a fence). To which extent this happens is controlled by the
9471 memory orders, which are listed here in approximately ascending order of
9472 strength. The description of each memory order is only meant to roughly
9473 illustrate the effects and is not a specification; see the C++11
9474 memory model for precise semantics.
9475
9476 @table @code
9477 @item __ATOMIC_RELAXED
9478 Implies no inter-thread ordering constraints.
9479 @item __ATOMIC_CONSUME
9480 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9481 memory order because of a deficiency in C++11's semantics for
9482 @code{memory_order_consume}.
9483 @item __ATOMIC_ACQUIRE
9484 Creates an inter-thread happens-before constraint from the release (or
9485 stronger) semantic store to this acquire load. Can prevent hoisting
9486 of code to before the operation.
9487 @item __ATOMIC_RELEASE
9488 Creates an inter-thread happens-before constraint to acquire (or stronger)
9489 semantic loads that read from this release store. Can prevent sinking
9490 of code to after the operation.
9491 @item __ATOMIC_ACQ_REL
9492 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9493 @code{__ATOMIC_RELEASE}.
9494 @item __ATOMIC_SEQ_CST
9495 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9496 @end table
9497
9498 Note that in the C++11 memory model, @emph{fences} (e.g.,
9499 @samp{__atomic_thread_fence}) take effect in combination with other
9500 atomic operations on specific memory locations (e.g., atomic loads);
9501 operations on specific memory locations do not necessarily affect other
9502 operations in the same way.
9503
9504 Target architectures are encouraged to provide their own patterns for
9505 each of the atomic built-in functions. If no target is provided, the original
9506 non-memory model set of @samp{__sync} atomic built-in functions are
9507 used, along with any required synchronization fences surrounding it in
9508 order to achieve the proper behavior. Execution in this case is subject
9509 to the same restrictions as those built-in functions.
9510
9511 If there is no pattern or mechanism to provide a lock-free instruction
9512 sequence, a call is made to an external routine with the same parameters
9513 to be resolved at run time.
9514
9515 When implementing patterns for these built-in functions, the memory order
9516 parameter can be ignored as long as the pattern implements the most
9517 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9518 orders execute correctly with this memory order but they may not execute as
9519 efficiently as they could with a more appropriate implementation of the
9520 relaxed requirements.
9521
9522 Note that the C++11 standard allows for the memory order parameter to be
9523 determined at run time rather than at compile time. These built-in
9524 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9525 than invoke a runtime library call or inline a switch statement. This is
9526 standard compliant, safe, and the simplest approach for now.
9527
9528 The memory order parameter is a signed int, but only the lower 16 bits are
9529 reserved for the memory order. The remainder of the signed int is reserved
9530 for target use and should be 0. Use of the predefined atomic values
9531 ensures proper usage.
9532
9533 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9534 This built-in function implements an atomic load operation. It returns the
9535 contents of @code{*@var{ptr}}.
9536
9537 The valid memory order variants are
9538 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9539 and @code{__ATOMIC_CONSUME}.
9540
9541 @end deftypefn
9542
9543 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9544 This is the generic version of an atomic load. It returns the
9545 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9546
9547 @end deftypefn
9548
9549 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9550 This built-in function implements an atomic store operation. It writes
9551 @code{@var{val}} into @code{*@var{ptr}}.
9552
9553 The valid memory order variants are
9554 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9555
9556 @end deftypefn
9557
9558 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9559 This is the generic version of an atomic store. It stores the value
9560 of @code{*@var{val}} into @code{*@var{ptr}}.
9561
9562 @end deftypefn
9563
9564 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9565 This built-in function implements an atomic exchange operation. It writes
9566 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9567 @code{*@var{ptr}}.
9568
9569 The valid memory order variants are
9570 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9571 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9572
9573 @end deftypefn
9574
9575 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9576 This is the generic version of an atomic exchange. It stores the
9577 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9578 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9579
9580 @end deftypefn
9581
9582 @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)
9583 This built-in function implements an atomic compare and exchange operation.
9584 This compares the contents of @code{*@var{ptr}} with the contents of
9585 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9586 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9587 equal, the operation is a @emph{read} and the current contents of
9588 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9589 for weak compare_exchange, which may fail spuriously, and false for
9590 the strong variation, which never fails spuriously. Many targets
9591 only offer the strong variation and ignore the parameter. When in doubt, use
9592 the strong variation.
9593
9594 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9595 and memory is affected according to the
9596 memory order specified by @var{success_memorder}. There are no
9597 restrictions on what memory order can be used here.
9598
9599 Otherwise, false is returned and memory is affected according
9600 to @var{failure_memorder}. This memory order cannot be
9601 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9602 stronger order than that specified by @var{success_memorder}.
9603
9604 @end deftypefn
9605
9606 @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)
9607 This built-in function implements the generic version of
9608 @code{__atomic_compare_exchange}. The function is virtually identical to
9609 @code{__atomic_compare_exchange_n}, except the desired value is also a
9610 pointer.
9611
9612 @end deftypefn
9613
9614 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9615 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9616 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9617 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9618 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9619 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9620 These built-in functions perform the operation suggested by the name, and
9621 return the result of the operation. Operations on pointer arguments are
9622 performed as if the operands were of the @code{uintptr_t} type. That is,
9623 they are not scaled by the size of the type to which the pointer points.
9624
9625 @smallexample
9626 @{ *ptr @var{op}= val; return *ptr; @}
9627 @end smallexample
9628
9629 The object pointed to by the first argument must be of integer or pointer
9630 type. It must not be a Boolean type. All memory orders are valid.
9631
9632 @end deftypefn
9633
9634 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9635 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9636 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9637 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9638 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9639 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9640 These built-in functions perform the operation suggested by the name, and
9641 return the value that had previously been in @code{*@var{ptr}}. Operations
9642 on pointer arguments are performed as if the operands were of
9643 the @code{uintptr_t} type. That is, they are not scaled by the size of
9644 the type to which the pointer points.
9645
9646 @smallexample
9647 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9648 @end smallexample
9649
9650 The same constraints on arguments apply as for the corresponding
9651 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9652
9653 @end deftypefn
9654
9655 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9656
9657 This built-in function performs an atomic test-and-set operation on
9658 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9659 defined nonzero ``set'' value and the return value is @code{true} if and only
9660 if the previous contents were ``set''.
9661 It should be only used for operands of type @code{bool} or @code{char}. For
9662 other types only part of the value may be set.
9663
9664 All memory orders are valid.
9665
9666 @end deftypefn
9667
9668 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9669
9670 This built-in function performs an atomic clear operation on
9671 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9672 It should be only used for operands of type @code{bool} or @code{char} and
9673 in conjunction with @code{__atomic_test_and_set}.
9674 For other types it may only clear partially. If the type is not @code{bool}
9675 prefer using @code{__atomic_store}.
9676
9677 The valid memory order variants are
9678 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9679 @code{__ATOMIC_RELEASE}.
9680
9681 @end deftypefn
9682
9683 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9684
9685 This built-in function acts as a synchronization fence between threads
9686 based on the specified memory order.
9687
9688 All memory orders are valid.
9689
9690 @end deftypefn
9691
9692 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9693
9694 This built-in function acts as a synchronization fence between a thread
9695 and signal handlers based in the same thread.
9696
9697 All memory orders are valid.
9698
9699 @end deftypefn
9700
9701 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9702
9703 This built-in function returns true if objects of @var{size} bytes always
9704 generate lock-free atomic instructions for the target architecture.
9705 @var{size} must resolve to a compile-time constant and the result also
9706 resolves to a compile-time constant.
9707
9708 @var{ptr} is an optional pointer to the object that may be used to determine
9709 alignment. A value of 0 indicates typical alignment should be used. The
9710 compiler may also ignore this parameter.
9711
9712 @smallexample
9713 if (__atomic_always_lock_free (sizeof (long long), 0))
9714 @end smallexample
9715
9716 @end deftypefn
9717
9718 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9719
9720 This built-in function returns true if objects of @var{size} bytes always
9721 generate lock-free atomic instructions for the target architecture. If
9722 the built-in function is not known to be lock-free, a call is made to a
9723 runtime routine named @code{__atomic_is_lock_free}.
9724
9725 @var{ptr} is an optional pointer to the object that may be used to determine
9726 alignment. A value of 0 indicates typical alignment should be used. The
9727 compiler may also ignore this parameter.
9728 @end deftypefn
9729
9730 @node Integer Overflow Builtins
9731 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9732
9733 The following built-in functions allow performing simple arithmetic operations
9734 together with checking whether the operations overflowed.
9735
9736 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9737 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9738 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9739 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9740 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9741 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9742 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9743
9744 These built-in functions promote the first two operands into infinite precision signed
9745 type and perform addition on those promoted operands. The result is then
9746 cast to the type the third pointer argument points to and stored there.
9747 If the stored result is equal to the infinite precision result, the built-in
9748 functions return false, otherwise they return true. As the addition is
9749 performed in infinite signed precision, these built-in functions have fully defined
9750 behavior for all argument values.
9751
9752 The first built-in function allows arbitrary integral types for operands and
9753 the result type must be pointer to some integer type, the rest of the built-in
9754 functions have explicit integer types.
9755
9756 The compiler will attempt to use hardware instructions to implement
9757 these built-in functions where possible, like conditional jump on overflow
9758 after addition, conditional jump on carry etc.
9759
9760 @end deftypefn
9761
9762 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9763 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9764 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9765 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9766 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9767 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9768 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9769
9770 These built-in functions are similar to the add overflow checking built-in
9771 functions above, except they perform subtraction, subtract the second argument
9772 from the first one, instead of addition.
9773
9774 @end deftypefn
9775
9776 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9777 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9778 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9779 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9780 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9781 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9782 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9783
9784 These built-in functions are similar to the add overflow checking built-in
9785 functions above, except they perform multiplication, instead of addition.
9786
9787 @end deftypefn
9788
9789 @node x86 specific memory model extensions for transactional memory
9790 @section x86-Specific Memory Model Extensions for Transactional Memory
9791
9792 The x86 architecture supports additional memory ordering flags
9793 to mark lock critical sections for hardware lock elision.
9794 These must be specified in addition to an existing memory order to
9795 atomic intrinsics.
9796
9797 @table @code
9798 @item __ATOMIC_HLE_ACQUIRE
9799 Start lock elision on a lock variable.
9800 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9801 @item __ATOMIC_HLE_RELEASE
9802 End lock elision on a lock variable.
9803 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9804 @end table
9805
9806 When a lock acquire fails, it is required for good performance to abort
9807 the transaction quickly. This can be done with a @code{_mm_pause}.
9808
9809 @smallexample
9810 #include <immintrin.h> // For _mm_pause
9811
9812 int lockvar;
9813
9814 /* Acquire lock with lock elision */
9815 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9816 _mm_pause(); /* Abort failed transaction */
9817 ...
9818 /* Free lock with lock elision */
9819 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9820 @end smallexample
9821
9822 @node Object Size Checking
9823 @section Object Size Checking Built-in Functions
9824 @findex __builtin_object_size
9825 @findex __builtin___memcpy_chk
9826 @findex __builtin___mempcpy_chk
9827 @findex __builtin___memmove_chk
9828 @findex __builtin___memset_chk
9829 @findex __builtin___strcpy_chk
9830 @findex __builtin___stpcpy_chk
9831 @findex __builtin___strncpy_chk
9832 @findex __builtin___strcat_chk
9833 @findex __builtin___strncat_chk
9834 @findex __builtin___sprintf_chk
9835 @findex __builtin___snprintf_chk
9836 @findex __builtin___vsprintf_chk
9837 @findex __builtin___vsnprintf_chk
9838 @findex __builtin___printf_chk
9839 @findex __builtin___vprintf_chk
9840 @findex __builtin___fprintf_chk
9841 @findex __builtin___vfprintf_chk
9842
9843 GCC implements a limited buffer overflow protection mechanism
9844 that can prevent some buffer overflow attacks.
9845
9846 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9847 is a built-in construct that returns a constant number of bytes from
9848 @var{ptr} to the end of the object @var{ptr} pointer points to
9849 (if known at compile time). @code{__builtin_object_size} never evaluates
9850 its arguments for side-effects. If there are any side-effects in them, it
9851 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9852 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9853 point to and all of them are known at compile time, the returned number
9854 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9855 0 and minimum if nonzero. If it is not possible to determine which objects
9856 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9857 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9858 for @var{type} 2 or 3.
9859
9860 @var{type} is an integer constant from 0 to 3. If the least significant
9861 bit is clear, objects are whole variables, if it is set, a closest
9862 surrounding subobject is considered the object a pointer points to.
9863 The second bit determines if maximum or minimum of remaining bytes
9864 is computed.
9865
9866 @smallexample
9867 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9868 char *p = &var.buf1[1], *q = &var.b;
9869
9870 /* Here the object p points to is var. */
9871 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9872 /* The subobject p points to is var.buf1. */
9873 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9874 /* The object q points to is var. */
9875 assert (__builtin_object_size (q, 0)
9876 == (char *) (&var + 1) - (char *) &var.b);
9877 /* The subobject q points to is var.b. */
9878 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9879 @end smallexample
9880 @end deftypefn
9881
9882 There are built-in functions added for many common string operation
9883 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9884 built-in is provided. This built-in has an additional last argument,
9885 which is the number of bytes remaining in object the @var{dest}
9886 argument points to or @code{(size_t) -1} if the size is not known.
9887
9888 The built-in functions are optimized into the normal string functions
9889 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9890 it is known at compile time that the destination object will not
9891 be overflown. If the compiler can determine at compile time the
9892 object will be always overflown, it issues a warning.
9893
9894 The intended use can be e.g.@:
9895
9896 @smallexample
9897 #undef memcpy
9898 #define bos0(dest) __builtin_object_size (dest, 0)
9899 #define memcpy(dest, src, n) \
9900 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9901
9902 char *volatile p;
9903 char buf[10];
9904 /* It is unknown what object p points to, so this is optimized
9905 into plain memcpy - no checking is possible. */
9906 memcpy (p, "abcde", n);
9907 /* Destination is known and length too. It is known at compile
9908 time there will be no overflow. */
9909 memcpy (&buf[5], "abcde", 5);
9910 /* Destination is known, but the length is not known at compile time.
9911 This will result in __memcpy_chk call that can check for overflow
9912 at run time. */
9913 memcpy (&buf[5], "abcde", n);
9914 /* Destination is known and it is known at compile time there will
9915 be overflow. There will be a warning and __memcpy_chk call that
9916 will abort the program at run time. */
9917 memcpy (&buf[6], "abcde", 5);
9918 @end smallexample
9919
9920 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9921 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9922 @code{strcat} and @code{strncat}.
9923
9924 There are also checking built-in functions for formatted output functions.
9925 @smallexample
9926 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9927 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9928 const char *fmt, ...);
9929 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9930 va_list ap);
9931 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9932 const char *fmt, va_list ap);
9933 @end smallexample
9934
9935 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9936 etc.@: functions and can contain implementation specific flags on what
9937 additional security measures the checking function might take, such as
9938 handling @code{%n} differently.
9939
9940 The @var{os} argument is the object size @var{s} points to, like in the
9941 other built-in functions. There is a small difference in the behavior
9942 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9943 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9944 the checking function is called with @var{os} argument set to
9945 @code{(size_t) -1}.
9946
9947 In addition to this, there are checking built-in functions
9948 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9949 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9950 These have just one additional argument, @var{flag}, right before
9951 format string @var{fmt}. If the compiler is able to optimize them to
9952 @code{fputc} etc.@: functions, it does, otherwise the checking function
9953 is called and the @var{flag} argument passed to it.
9954
9955 @node Pointer Bounds Checker builtins
9956 @section Pointer Bounds Checker Built-in Functions
9957 @cindex Pointer Bounds Checker builtins
9958 @findex __builtin___bnd_set_ptr_bounds
9959 @findex __builtin___bnd_narrow_ptr_bounds
9960 @findex __builtin___bnd_copy_ptr_bounds
9961 @findex __builtin___bnd_init_ptr_bounds
9962 @findex __builtin___bnd_null_ptr_bounds
9963 @findex __builtin___bnd_store_ptr_bounds
9964 @findex __builtin___bnd_chk_ptr_lbounds
9965 @findex __builtin___bnd_chk_ptr_ubounds
9966 @findex __builtin___bnd_chk_ptr_bounds
9967 @findex __builtin___bnd_get_ptr_lbound
9968 @findex __builtin___bnd_get_ptr_ubound
9969
9970 GCC provides a set of built-in functions to control Pointer Bounds Checker
9971 instrumentation. Note that all Pointer Bounds Checker builtins can be used
9972 even if you compile with Pointer Bounds Checker off
9973 (@option{-fno-check-pointer-bounds}).
9974 The behavior may differ in such case as documented below.
9975
9976 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9977
9978 This built-in function returns a new pointer with the value of @var{q}, and
9979 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
9980 Bounds Checker off, the built-in function just returns the first argument.
9981
9982 @smallexample
9983 extern void *__wrap_malloc (size_t n)
9984 @{
9985 void *p = (void *)__real_malloc (n);
9986 if (!p) return __builtin___bnd_null_ptr_bounds (p);
9987 return __builtin___bnd_set_ptr_bounds (p, n);
9988 @}
9989 @end smallexample
9990
9991 @end deftypefn
9992
9993 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
9994
9995 This built-in function returns a new pointer with the value of @var{p}
9996 and associates it with the narrowed bounds formed by the intersection
9997 of bounds associated with @var{q} and the bounds
9998 [@var{p}, @var{p} + @var{size} - 1].
9999 With Pointer Bounds Checker off, the built-in function just returns the first
10000 argument.
10001
10002 @smallexample
10003 void init_objects (object *objs, size_t size)
10004 @{
10005 size_t i;
10006 /* Initialize objects one-by-one passing pointers with bounds of
10007 an object, not the full array of objects. */
10008 for (i = 0; i < size; i++)
10009 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10010 sizeof(object)));
10011 @}
10012 @end smallexample
10013
10014 @end deftypefn
10015
10016 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10017
10018 This built-in function returns a new pointer with the value of @var{q},
10019 and associates it with the bounds already associated with pointer @var{r}.
10020 With Pointer Bounds Checker off, the built-in function just returns the first
10021 argument.
10022
10023 @smallexample
10024 /* Here is a way to get pointer to object's field but
10025 still with the full object's bounds. */
10026 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10027 objptr);
10028 @end smallexample
10029
10030 @end deftypefn
10031
10032 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10033
10034 This built-in function returns a new pointer with the value of @var{q}, and
10035 associates it with INIT (allowing full memory access) bounds. With Pointer
10036 Bounds Checker off, the built-in function just returns the first argument.
10037
10038 @end deftypefn
10039
10040 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10041
10042 This built-in function returns a new pointer with the value of @var{q}, and
10043 associates it with NULL (allowing no memory access) bounds. With Pointer
10044 Bounds Checker off, the built-in function just returns the first argument.
10045
10046 @end deftypefn
10047
10048 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10049
10050 This built-in function stores the bounds associated with pointer @var{ptr_val}
10051 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10052 bounds from legacy code without touching the associated pointer's memory when
10053 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10054 function call is ignored.
10055
10056 @end deftypefn
10057
10058 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10059
10060 This built-in function checks if the pointer @var{q} is within the lower
10061 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10062 function call is ignored.
10063
10064 @smallexample
10065 extern void *__wrap_memset (void *dst, int c, size_t len)
10066 @{
10067 if (len > 0)
10068 @{
10069 __builtin___bnd_chk_ptr_lbounds (dst);
10070 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10071 __real_memset (dst, c, len);
10072 @}
10073 return dst;
10074 @}
10075 @end smallexample
10076
10077 @end deftypefn
10078
10079 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10080
10081 This built-in function checks if the pointer @var{q} is within the upper
10082 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10083 function call is ignored.
10084
10085 @end deftypefn
10086
10087 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10088
10089 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10090 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10091 off, the built-in function call is ignored.
10092
10093 @smallexample
10094 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10095 @{
10096 if (n > 0)
10097 @{
10098 __bnd_chk_ptr_bounds (dst, n);
10099 __bnd_chk_ptr_bounds (src, n);
10100 __real_memcpy (dst, src, n);
10101 @}
10102 return dst;
10103 @}
10104 @end smallexample
10105
10106 @end deftypefn
10107
10108 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10109
10110 This built-in function returns the lower bound associated
10111 with the pointer @var{q}, as a pointer value.
10112 This is useful for debugging using @code{printf}.
10113 With Pointer Bounds Checker off, the built-in function returns 0.
10114
10115 @smallexample
10116 void *lb = __builtin___bnd_get_ptr_lbound (q);
10117 void *ub = __builtin___bnd_get_ptr_ubound (q);
10118 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10119 @end smallexample
10120
10121 @end deftypefn
10122
10123 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10124
10125 This built-in function returns the upper bound (which is a pointer) associated
10126 with the pointer @var{q}. With Pointer Bounds Checker off,
10127 the built-in function returns -1.
10128
10129 @end deftypefn
10130
10131 @node Cilk Plus Builtins
10132 @section Cilk Plus C/C++ Language Extension Built-in Functions
10133
10134 GCC provides support for the following built-in reduction functions if Cilk Plus
10135 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10136
10137 @itemize @bullet
10138 @item @code{__sec_implicit_index}
10139 @item @code{__sec_reduce}
10140 @item @code{__sec_reduce_add}
10141 @item @code{__sec_reduce_all_nonzero}
10142 @item @code{__sec_reduce_all_zero}
10143 @item @code{__sec_reduce_any_nonzero}
10144 @item @code{__sec_reduce_any_zero}
10145 @item @code{__sec_reduce_max}
10146 @item @code{__sec_reduce_min}
10147 @item @code{__sec_reduce_max_ind}
10148 @item @code{__sec_reduce_min_ind}
10149 @item @code{__sec_reduce_mul}
10150 @item @code{__sec_reduce_mutating}
10151 @end itemize
10152
10153 Further details and examples about these built-in functions are described
10154 in the Cilk Plus language manual which can be found at
10155 @uref{http://www.cilkplus.org}.
10156
10157 @node Other Builtins
10158 @section Other Built-in Functions Provided by GCC
10159 @cindex built-in functions
10160 @findex __builtin_alloca
10161 @findex __builtin_alloca_with_align
10162 @findex __builtin_call_with_static_chain
10163 @findex __builtin_fpclassify
10164 @findex __builtin_isfinite
10165 @findex __builtin_isnormal
10166 @findex __builtin_isgreater
10167 @findex __builtin_isgreaterequal
10168 @findex __builtin_isinf_sign
10169 @findex __builtin_isless
10170 @findex __builtin_islessequal
10171 @findex __builtin_islessgreater
10172 @findex __builtin_isunordered
10173 @findex __builtin_powi
10174 @findex __builtin_powif
10175 @findex __builtin_powil
10176 @findex _Exit
10177 @findex _exit
10178 @findex abort
10179 @findex abs
10180 @findex acos
10181 @findex acosf
10182 @findex acosh
10183 @findex acoshf
10184 @findex acoshl
10185 @findex acosl
10186 @findex alloca
10187 @findex asin
10188 @findex asinf
10189 @findex asinh
10190 @findex asinhf
10191 @findex asinhl
10192 @findex asinl
10193 @findex atan
10194 @findex atan2
10195 @findex atan2f
10196 @findex atan2l
10197 @findex atanf
10198 @findex atanh
10199 @findex atanhf
10200 @findex atanhl
10201 @findex atanl
10202 @findex bcmp
10203 @findex bzero
10204 @findex cabs
10205 @findex cabsf
10206 @findex cabsl
10207 @findex cacos
10208 @findex cacosf
10209 @findex cacosh
10210 @findex cacoshf
10211 @findex cacoshl
10212 @findex cacosl
10213 @findex calloc
10214 @findex carg
10215 @findex cargf
10216 @findex cargl
10217 @findex casin
10218 @findex casinf
10219 @findex casinh
10220 @findex casinhf
10221 @findex casinhl
10222 @findex casinl
10223 @findex catan
10224 @findex catanf
10225 @findex catanh
10226 @findex catanhf
10227 @findex catanhl
10228 @findex catanl
10229 @findex cbrt
10230 @findex cbrtf
10231 @findex cbrtl
10232 @findex ccos
10233 @findex ccosf
10234 @findex ccosh
10235 @findex ccoshf
10236 @findex ccoshl
10237 @findex ccosl
10238 @findex ceil
10239 @findex ceilf
10240 @findex ceill
10241 @findex cexp
10242 @findex cexpf
10243 @findex cexpl
10244 @findex cimag
10245 @findex cimagf
10246 @findex cimagl
10247 @findex clog
10248 @findex clogf
10249 @findex clogl
10250 @findex clog10
10251 @findex clog10f
10252 @findex clog10l
10253 @findex conj
10254 @findex conjf
10255 @findex conjl
10256 @findex copysign
10257 @findex copysignf
10258 @findex copysignl
10259 @findex cos
10260 @findex cosf
10261 @findex cosh
10262 @findex coshf
10263 @findex coshl
10264 @findex cosl
10265 @findex cpow
10266 @findex cpowf
10267 @findex cpowl
10268 @findex cproj
10269 @findex cprojf
10270 @findex cprojl
10271 @findex creal
10272 @findex crealf
10273 @findex creall
10274 @findex csin
10275 @findex csinf
10276 @findex csinh
10277 @findex csinhf
10278 @findex csinhl
10279 @findex csinl
10280 @findex csqrt
10281 @findex csqrtf
10282 @findex csqrtl
10283 @findex ctan
10284 @findex ctanf
10285 @findex ctanh
10286 @findex ctanhf
10287 @findex ctanhl
10288 @findex ctanl
10289 @findex dcgettext
10290 @findex dgettext
10291 @findex drem
10292 @findex dremf
10293 @findex dreml
10294 @findex erf
10295 @findex erfc
10296 @findex erfcf
10297 @findex erfcl
10298 @findex erff
10299 @findex erfl
10300 @findex exit
10301 @findex exp
10302 @findex exp10
10303 @findex exp10f
10304 @findex exp10l
10305 @findex exp2
10306 @findex exp2f
10307 @findex exp2l
10308 @findex expf
10309 @findex expl
10310 @findex expm1
10311 @findex expm1f
10312 @findex expm1l
10313 @findex fabs
10314 @findex fabsf
10315 @findex fabsl
10316 @findex fdim
10317 @findex fdimf
10318 @findex fdiml
10319 @findex ffs
10320 @findex floor
10321 @findex floorf
10322 @findex floorl
10323 @findex fma
10324 @findex fmaf
10325 @findex fmal
10326 @findex fmax
10327 @findex fmaxf
10328 @findex fmaxl
10329 @findex fmin
10330 @findex fminf
10331 @findex fminl
10332 @findex fmod
10333 @findex fmodf
10334 @findex fmodl
10335 @findex fprintf
10336 @findex fprintf_unlocked
10337 @findex fputs
10338 @findex fputs_unlocked
10339 @findex frexp
10340 @findex frexpf
10341 @findex frexpl
10342 @findex fscanf
10343 @findex gamma
10344 @findex gammaf
10345 @findex gammal
10346 @findex gamma_r
10347 @findex gammaf_r
10348 @findex gammal_r
10349 @findex gettext
10350 @findex hypot
10351 @findex hypotf
10352 @findex hypotl
10353 @findex ilogb
10354 @findex ilogbf
10355 @findex ilogbl
10356 @findex imaxabs
10357 @findex index
10358 @findex isalnum
10359 @findex isalpha
10360 @findex isascii
10361 @findex isblank
10362 @findex iscntrl
10363 @findex isdigit
10364 @findex isgraph
10365 @findex islower
10366 @findex isprint
10367 @findex ispunct
10368 @findex isspace
10369 @findex isupper
10370 @findex iswalnum
10371 @findex iswalpha
10372 @findex iswblank
10373 @findex iswcntrl
10374 @findex iswdigit
10375 @findex iswgraph
10376 @findex iswlower
10377 @findex iswprint
10378 @findex iswpunct
10379 @findex iswspace
10380 @findex iswupper
10381 @findex iswxdigit
10382 @findex isxdigit
10383 @findex j0
10384 @findex j0f
10385 @findex j0l
10386 @findex j1
10387 @findex j1f
10388 @findex j1l
10389 @findex jn
10390 @findex jnf
10391 @findex jnl
10392 @findex labs
10393 @findex ldexp
10394 @findex ldexpf
10395 @findex ldexpl
10396 @findex lgamma
10397 @findex lgammaf
10398 @findex lgammal
10399 @findex lgamma_r
10400 @findex lgammaf_r
10401 @findex lgammal_r
10402 @findex llabs
10403 @findex llrint
10404 @findex llrintf
10405 @findex llrintl
10406 @findex llround
10407 @findex llroundf
10408 @findex llroundl
10409 @findex log
10410 @findex log10
10411 @findex log10f
10412 @findex log10l
10413 @findex log1p
10414 @findex log1pf
10415 @findex log1pl
10416 @findex log2
10417 @findex log2f
10418 @findex log2l
10419 @findex logb
10420 @findex logbf
10421 @findex logbl
10422 @findex logf
10423 @findex logl
10424 @findex lrint
10425 @findex lrintf
10426 @findex lrintl
10427 @findex lround
10428 @findex lroundf
10429 @findex lroundl
10430 @findex malloc
10431 @findex memchr
10432 @findex memcmp
10433 @findex memcpy
10434 @findex mempcpy
10435 @findex memset
10436 @findex modf
10437 @findex modff
10438 @findex modfl
10439 @findex nearbyint
10440 @findex nearbyintf
10441 @findex nearbyintl
10442 @findex nextafter
10443 @findex nextafterf
10444 @findex nextafterl
10445 @findex nexttoward
10446 @findex nexttowardf
10447 @findex nexttowardl
10448 @findex pow
10449 @findex pow10
10450 @findex pow10f
10451 @findex pow10l
10452 @findex powf
10453 @findex powl
10454 @findex printf
10455 @findex printf_unlocked
10456 @findex putchar
10457 @findex puts
10458 @findex remainder
10459 @findex remainderf
10460 @findex remainderl
10461 @findex remquo
10462 @findex remquof
10463 @findex remquol
10464 @findex rindex
10465 @findex rint
10466 @findex rintf
10467 @findex rintl
10468 @findex round
10469 @findex roundf
10470 @findex roundl
10471 @findex scalb
10472 @findex scalbf
10473 @findex scalbl
10474 @findex scalbln
10475 @findex scalblnf
10476 @findex scalblnf
10477 @findex scalbn
10478 @findex scalbnf
10479 @findex scanfnl
10480 @findex signbit
10481 @findex signbitf
10482 @findex signbitl
10483 @findex signbitd32
10484 @findex signbitd64
10485 @findex signbitd128
10486 @findex significand
10487 @findex significandf
10488 @findex significandl
10489 @findex sin
10490 @findex sincos
10491 @findex sincosf
10492 @findex sincosl
10493 @findex sinf
10494 @findex sinh
10495 @findex sinhf
10496 @findex sinhl
10497 @findex sinl
10498 @findex snprintf
10499 @findex sprintf
10500 @findex sqrt
10501 @findex sqrtf
10502 @findex sqrtl
10503 @findex sscanf
10504 @findex stpcpy
10505 @findex stpncpy
10506 @findex strcasecmp
10507 @findex strcat
10508 @findex strchr
10509 @findex strcmp
10510 @findex strcpy
10511 @findex strcspn
10512 @findex strdup
10513 @findex strfmon
10514 @findex strftime
10515 @findex strlen
10516 @findex strncasecmp
10517 @findex strncat
10518 @findex strncmp
10519 @findex strncpy
10520 @findex strndup
10521 @findex strpbrk
10522 @findex strrchr
10523 @findex strspn
10524 @findex strstr
10525 @findex tan
10526 @findex tanf
10527 @findex tanh
10528 @findex tanhf
10529 @findex tanhl
10530 @findex tanl
10531 @findex tgamma
10532 @findex tgammaf
10533 @findex tgammal
10534 @findex toascii
10535 @findex tolower
10536 @findex toupper
10537 @findex towlower
10538 @findex towupper
10539 @findex trunc
10540 @findex truncf
10541 @findex truncl
10542 @findex vfprintf
10543 @findex vfscanf
10544 @findex vprintf
10545 @findex vscanf
10546 @findex vsnprintf
10547 @findex vsprintf
10548 @findex vsscanf
10549 @findex y0
10550 @findex y0f
10551 @findex y0l
10552 @findex y1
10553 @findex y1f
10554 @findex y1l
10555 @findex yn
10556 @findex ynf
10557 @findex ynl
10558
10559 GCC provides a large number of built-in functions other than the ones
10560 mentioned above. Some of these are for internal use in the processing
10561 of exceptions or variable-length argument lists and are not
10562 documented here because they may change from time to time; we do not
10563 recommend general use of these functions.
10564
10565 The remaining functions are provided for optimization purposes.
10566
10567 With the exception of built-ins that have library equivalents such as
10568 the standard C library functions discussed below, or that expand to
10569 library calls, GCC built-in functions are always expanded inline and
10570 thus do not have corresponding entry points and their address cannot
10571 be obtained. Attempting to use them in an expression other than
10572 a function call results in a compile-time error.
10573
10574 @opindex fno-builtin
10575 GCC includes built-in versions of many of the functions in the standard
10576 C library. These functions come in two forms: one whose names start with
10577 the @code{__builtin_} prefix, and the other without. Both forms have the
10578 same type (including prototype), the same address (when their address is
10579 taken), and the same meaning as the C library functions even if you specify
10580 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10581 functions are only optimized in certain cases; if they are not optimized in
10582 a particular case, a call to the library function is emitted.
10583
10584 @opindex ansi
10585 @opindex std
10586 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10587 @option{-std=c99} or @option{-std=c11}), the functions
10588 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10589 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10590 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10591 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10592 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10593 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10594 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10595 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10596 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10597 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10598 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10599 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10600 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10601 @code{significandl}, @code{significand}, @code{sincosf},
10602 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10603 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10604 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10605 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10606 @code{yn}
10607 may be handled as built-in functions.
10608 All these functions have corresponding versions
10609 prefixed with @code{__builtin_}, which may be used even in strict C90
10610 mode.
10611
10612 The ISO C99 functions
10613 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10614 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10615 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10616 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10617 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10618 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10619 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10620 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10621 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10622 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10623 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10624 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10625 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10626 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10627 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10628 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10629 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10630 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10631 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10632 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10633 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10634 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10635 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10636 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10637 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10638 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10639 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10640 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10641 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10642 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10643 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10644 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10645 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10646 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10647 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10648 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10649 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10650 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10651 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10652 are handled as built-in functions
10653 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10654
10655 There are also built-in versions of the ISO C99 functions
10656 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10657 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10658 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10659 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10660 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10661 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10662 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10663 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10664 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10665 that are recognized in any mode since ISO C90 reserves these names for
10666 the purpose to which ISO C99 puts them. All these functions have
10667 corresponding versions prefixed with @code{__builtin_}.
10668
10669 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10670 @code{clog10l} which names are reserved by ISO C99 for future use.
10671 All these functions have versions prefixed with @code{__builtin_}.
10672
10673 The ISO C94 functions
10674 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10675 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10676 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10677 @code{towupper}
10678 are handled as built-in functions
10679 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10680
10681 The ISO C90 functions
10682 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10683 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10684 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10685 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10686 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10687 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10688 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10689 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10690 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10691 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10692 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10693 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10694 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10695 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10696 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10697 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10698 are all recognized as built-in functions unless
10699 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10700 is specified for an individual function). All of these functions have
10701 corresponding versions prefixed with @code{__builtin_}.
10702
10703 GCC provides built-in versions of the ISO C99 floating-point comparison
10704 macros that avoid raising exceptions for unordered operands. They have
10705 the same names as the standard macros ( @code{isgreater},
10706 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10707 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10708 prefixed. We intend for a library implementor to be able to simply
10709 @code{#define} each standard macro to its built-in equivalent.
10710 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10711 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10712 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10713 built-in functions appear both with and without the @code{__builtin_} prefix.
10714
10715 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10716 The @code{__builtin_alloca} function must be called at block scope.
10717 The function allocates an object @var{size} bytes large on the stack
10718 of the calling function. The object is aligned on the default stack
10719 alignment boundary for the target determined by the
10720 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10721 function returns a pointer to the first byte of the allocated object.
10722 The lifetime of the allocated object ends just before the calling
10723 function returns to its caller. This is so even when
10724 @code{__builtin_alloca} is called within a nested block.
10725
10726 For example, the following function allocates eight objects of @code{n}
10727 bytes each on the stack, storing a pointer to each in consecutive elements
10728 of the array @code{a}. It then passes the array to function @code{g}
10729 which can safely use the storage pointed to by each of the array elements.
10730
10731 @smallexample
10732 void f (unsigned n)
10733 @{
10734 void *a [8];
10735 for (int i = 0; i != 8; ++i)
10736 a [i] = __builtin_alloca (n);
10737
10738 g (a, n); // @r{safe}
10739 @}
10740 @end smallexample
10741
10742 Since the @code{__builtin_alloca} function doesn't validate its argument
10743 it is the responsibility of its caller to make sure the argument doesn't
10744 cause it to exceed the stack size limit.
10745 The @code{__builtin_alloca} function is provided to make it possible to
10746 allocate on the stack arrays of bytes with an upper bound that may be
10747 computed at run time. Since C99 Variable Length Arrays offer
10748 similar functionality under a portable, more convenient, and safer
10749 interface they are recommended instead, in both C99 and C++ programs
10750 where GCC provides them as an extension.
10751 @xref{Variable Length}, for details.
10752
10753 @end deftypefn
10754
10755 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10756 The @code{__builtin_alloca_with_align} function must be called at block
10757 scope. The function allocates an object @var{size} bytes large on
10758 the stack of the calling function. The allocated object is aligned on
10759 the boundary specified by the argument @var{alignment} whose unit is given
10760 in bits (not bytes). The @var{size} argument must be positive and not
10761 exceed the stack size limit. The @var{alignment} argument must be a constant
10762 integer expression that evaluates to a power of 2 greater than or equal to
10763 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10764 with other values are rejected with an error indicating the valid bounds.
10765 The function returns a pointer to the first byte of the allocated object.
10766 The lifetime of the allocated object ends at the end of the block in which
10767 the function was called. The allocated storage is released no later than
10768 just before the calling function returns to its caller, but may be released
10769 at the end of the block in which the function was called.
10770
10771 For example, in the following function the call to @code{g} is unsafe
10772 because when @code{overalign} is non-zero, the space allocated by
10773 @code{__builtin_alloca_with_align} may have been released at the end
10774 of the @code{if} statement in which it was called.
10775
10776 @smallexample
10777 void f (unsigned n, bool overalign)
10778 @{
10779 void *p;
10780 if (overalign)
10781 p = __builtin_alloca_with_align (n, 64 /* bits */);
10782 else
10783 p = __builtin_alloc (n);
10784
10785 g (p, n); // @r{unsafe}
10786 @}
10787 @end smallexample
10788
10789 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10790 @var{size} argument it is the responsibility of its caller to make sure
10791 the argument doesn't cause it to exceed the stack size limit.
10792 The @code{__builtin_alloca_with_align} function is provided to make
10793 it possible to allocate on the stack overaligned arrays of bytes with
10794 an upper bound that may be computed at run time. Since C99
10795 Variable Length Arrays offer the same functionality under
10796 a portable, more convenient, and safer interface they are recommended
10797 instead, in both C99 and C++ programs where GCC provides them as
10798 an extension. @xref{Variable Length}, for details.
10799
10800 @end deftypefn
10801
10802 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10803
10804 You can use the built-in function @code{__builtin_types_compatible_p} to
10805 determine whether two types are the same.
10806
10807 This built-in function returns 1 if the unqualified versions of the
10808 types @var{type1} and @var{type2} (which are types, not expressions) are
10809 compatible, 0 otherwise. The result of this built-in function can be
10810 used in integer constant expressions.
10811
10812 This built-in function ignores top level qualifiers (e.g., @code{const},
10813 @code{volatile}). For example, @code{int} is equivalent to @code{const
10814 int}.
10815
10816 The type @code{int[]} and @code{int[5]} are compatible. On the other
10817 hand, @code{int} and @code{char *} are not compatible, even if the size
10818 of their types, on the particular architecture are the same. Also, the
10819 amount of pointer indirection is taken into account when determining
10820 similarity. Consequently, @code{short *} is not similar to
10821 @code{short **}. Furthermore, two types that are typedefed are
10822 considered compatible if their underlying types are compatible.
10823
10824 An @code{enum} type is not considered to be compatible with another
10825 @code{enum} type even if both are compatible with the same integer
10826 type; this is what the C standard specifies.
10827 For example, @code{enum @{foo, bar@}} is not similar to
10828 @code{enum @{hot, dog@}}.
10829
10830 You typically use this function in code whose execution varies
10831 depending on the arguments' types. For example:
10832
10833 @smallexample
10834 #define foo(x) \
10835 (@{ \
10836 typeof (x) tmp = (x); \
10837 if (__builtin_types_compatible_p (typeof (x), long double)) \
10838 tmp = foo_long_double (tmp); \
10839 else if (__builtin_types_compatible_p (typeof (x), double)) \
10840 tmp = foo_double (tmp); \
10841 else if (__builtin_types_compatible_p (typeof (x), float)) \
10842 tmp = foo_float (tmp); \
10843 else \
10844 abort (); \
10845 tmp; \
10846 @})
10847 @end smallexample
10848
10849 @emph{Note:} This construct is only available for C@.
10850
10851 @end deftypefn
10852
10853 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10854
10855 The @var{call_exp} expression must be a function call, and the
10856 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10857 is passed to the function call in the target's static chain location.
10858 The result of builtin is the result of the function call.
10859
10860 @emph{Note:} This builtin is only available for C@.
10861 This builtin can be used to call Go closures from C.
10862
10863 @end deftypefn
10864
10865 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10866
10867 You can use the built-in function @code{__builtin_choose_expr} to
10868 evaluate code depending on the value of a constant expression. This
10869 built-in function returns @var{exp1} if @var{const_exp}, which is an
10870 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10871
10872 This built-in function is analogous to the @samp{? :} operator in C,
10873 except that the expression returned has its type unaltered by promotion
10874 rules. Also, the built-in function does not evaluate the expression
10875 that is not chosen. For example, if @var{const_exp} evaluates to true,
10876 @var{exp2} is not evaluated even if it has side-effects.
10877
10878 This built-in function can return an lvalue if the chosen argument is an
10879 lvalue.
10880
10881 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10882 type. Similarly, if @var{exp2} is returned, its return type is the same
10883 as @var{exp2}.
10884
10885 Example:
10886
10887 @smallexample
10888 #define foo(x) \
10889 __builtin_choose_expr ( \
10890 __builtin_types_compatible_p (typeof (x), double), \
10891 foo_double (x), \
10892 __builtin_choose_expr ( \
10893 __builtin_types_compatible_p (typeof (x), float), \
10894 foo_float (x), \
10895 /* @r{The void expression results in a compile-time error} \
10896 @r{when assigning the result to something.} */ \
10897 (void)0))
10898 @end smallexample
10899
10900 @emph{Note:} This construct is only available for C@. Furthermore, the
10901 unused expression (@var{exp1} or @var{exp2} depending on the value of
10902 @var{const_exp}) may still generate syntax errors. This may change in
10903 future revisions.
10904
10905 @end deftypefn
10906
10907 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10908
10909 The built-in function @code{__builtin_complex} is provided for use in
10910 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10911 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10912 real binary floating-point type, and the result has the corresponding
10913 complex type with real and imaginary parts @var{real} and @var{imag}.
10914 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10915 infinities, NaNs and negative zeros are involved.
10916
10917 @end deftypefn
10918
10919 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10920 You can use the built-in function @code{__builtin_constant_p} to
10921 determine if a value is known to be constant at compile time and hence
10922 that GCC can perform constant-folding on expressions involving that
10923 value. The argument of the function is the value to test. The function
10924 returns the integer 1 if the argument is known to be a compile-time
10925 constant and 0 if it is not known to be a compile-time constant. A
10926 return of 0 does not indicate that the value is @emph{not} a constant,
10927 but merely that GCC cannot prove it is a constant with the specified
10928 value of the @option{-O} option.
10929
10930 You typically use this function in an embedded application where
10931 memory is a critical resource. If you have some complex calculation,
10932 you may want it to be folded if it involves constants, but need to call
10933 a function if it does not. For example:
10934
10935 @smallexample
10936 #define Scale_Value(X) \
10937 (__builtin_constant_p (X) \
10938 ? ((X) * SCALE + OFFSET) : Scale (X))
10939 @end smallexample
10940
10941 You may use this built-in function in either a macro or an inline
10942 function. However, if you use it in an inlined function and pass an
10943 argument of the function as the argument to the built-in, GCC
10944 never returns 1 when you call the inline function with a string constant
10945 or compound literal (@pxref{Compound Literals}) and does not return 1
10946 when you pass a constant numeric value to the inline function unless you
10947 specify the @option{-O} option.
10948
10949 You may also use @code{__builtin_constant_p} in initializers for static
10950 data. For instance, you can write
10951
10952 @smallexample
10953 static const int table[] = @{
10954 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10955 /* @r{@dots{}} */
10956 @};
10957 @end smallexample
10958
10959 @noindent
10960 This is an acceptable initializer even if @var{EXPRESSION} is not a
10961 constant expression, including the case where
10962 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10963 folded to a constant but @var{EXPRESSION} contains operands that are
10964 not otherwise permitted in a static initializer (for example,
10965 @code{0 && foo ()}). GCC must be more conservative about evaluating the
10966 built-in in this case, because it has no opportunity to perform
10967 optimization.
10968 @end deftypefn
10969
10970 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10971 @opindex fprofile-arcs
10972 You may use @code{__builtin_expect} to provide the compiler with
10973 branch prediction information. In general, you should prefer to
10974 use actual profile feedback for this (@option{-fprofile-arcs}), as
10975 programmers are notoriously bad at predicting how their programs
10976 actually perform. However, there are applications in which this
10977 data is hard to collect.
10978
10979 The return value is the value of @var{exp}, which should be an integral
10980 expression. The semantics of the built-in are that it is expected that
10981 @var{exp} == @var{c}. For example:
10982
10983 @smallexample
10984 if (__builtin_expect (x, 0))
10985 foo ();
10986 @end smallexample
10987
10988 @noindent
10989 indicates that we do not expect to call @code{foo}, since
10990 we expect @code{x} to be zero. Since you are limited to integral
10991 expressions for @var{exp}, you should use constructions such as
10992
10993 @smallexample
10994 if (__builtin_expect (ptr != NULL, 1))
10995 foo (*ptr);
10996 @end smallexample
10997
10998 @noindent
10999 when testing pointer or floating-point values.
11000 @end deftypefn
11001
11002 @deftypefn {Built-in Function} void __builtin_trap (void)
11003 This function causes the program to exit abnormally. GCC implements
11004 this function by using a target-dependent mechanism (such as
11005 intentionally executing an illegal instruction) or by calling
11006 @code{abort}. The mechanism used may vary from release to release so
11007 you should not rely on any particular implementation.
11008 @end deftypefn
11009
11010 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11011 If control flow reaches the point of the @code{__builtin_unreachable},
11012 the program is undefined. It is useful in situations where the
11013 compiler cannot deduce the unreachability of the code.
11014
11015 One such case is immediately following an @code{asm} statement that
11016 either never terminates, or one that transfers control elsewhere
11017 and never returns. In this example, without the
11018 @code{__builtin_unreachable}, GCC issues a warning that control
11019 reaches the end of a non-void function. It also generates code
11020 to return after the @code{asm}.
11021
11022 @smallexample
11023 int f (int c, int v)
11024 @{
11025 if (c)
11026 @{
11027 return v;
11028 @}
11029 else
11030 @{
11031 asm("jmp error_handler");
11032 __builtin_unreachable ();
11033 @}
11034 @}
11035 @end smallexample
11036
11037 @noindent
11038 Because the @code{asm} statement unconditionally transfers control out
11039 of the function, control never reaches the end of the function
11040 body. The @code{__builtin_unreachable} is in fact unreachable and
11041 communicates this fact to the compiler.
11042
11043 Another use for @code{__builtin_unreachable} is following a call a
11044 function that never returns but that is not declared
11045 @code{__attribute__((noreturn))}, as in this example:
11046
11047 @smallexample
11048 void function_that_never_returns (void);
11049
11050 int g (int c)
11051 @{
11052 if (c)
11053 @{
11054 return 1;
11055 @}
11056 else
11057 @{
11058 function_that_never_returns ();
11059 __builtin_unreachable ();
11060 @}
11061 @}
11062 @end smallexample
11063
11064 @end deftypefn
11065
11066 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11067 This function returns its first argument, and allows the compiler
11068 to assume that the returned pointer is at least @var{align} bytes
11069 aligned. This built-in can have either two or three arguments,
11070 if it has three, the third argument should have integer type, and
11071 if it is nonzero means misalignment offset. For example:
11072
11073 @smallexample
11074 void *x = __builtin_assume_aligned (arg, 16);
11075 @end smallexample
11076
11077 @noindent
11078 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11079 16-byte aligned, while:
11080
11081 @smallexample
11082 void *x = __builtin_assume_aligned (arg, 32, 8);
11083 @end smallexample
11084
11085 @noindent
11086 means that the compiler can assume for @code{x}, set to @code{arg}, that
11087 @code{(char *) x - 8} is 32-byte aligned.
11088 @end deftypefn
11089
11090 @deftypefn {Built-in Function} int __builtin_LINE ()
11091 This function is the equivalent to the preprocessor @code{__LINE__}
11092 macro and returns the line number of the invocation of the built-in.
11093 In a C++ default argument for a function @var{F}, it gets the line number of
11094 the call to @var{F}.
11095 @end deftypefn
11096
11097 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11098 This function is the equivalent to the preprocessor @code{__FUNCTION__}
11099 macro and returns the function name the invocation of the built-in is in.
11100 @end deftypefn
11101
11102 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11103 This function is the equivalent to the preprocessor @code{__FILE__}
11104 macro and returns the file name the invocation of the built-in is in.
11105 In a C++ default argument for a function @var{F}, it gets the file name of
11106 the call to @var{F}.
11107 @end deftypefn
11108
11109 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11110 This function is used to flush the processor's instruction cache for
11111 the region of memory between @var{begin} inclusive and @var{end}
11112 exclusive. Some targets require that the instruction cache be
11113 flushed, after modifying memory containing code, in order to obtain
11114 deterministic behavior.
11115
11116 If the target does not require instruction cache flushes,
11117 @code{__builtin___clear_cache} has no effect. Otherwise either
11118 instructions are emitted in-line to clear the instruction cache or a
11119 call to the @code{__clear_cache} function in libgcc is made.
11120 @end deftypefn
11121
11122 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11123 This function is used to minimize cache-miss latency by moving data into
11124 a cache before it is accessed.
11125 You can insert calls to @code{__builtin_prefetch} into code for which
11126 you know addresses of data in memory that is likely to be accessed soon.
11127 If the target supports them, data prefetch instructions are generated.
11128 If the prefetch is done early enough before the access then the data will
11129 be in the cache by the time it is accessed.
11130
11131 The value of @var{addr} is the address of the memory to prefetch.
11132 There are two optional arguments, @var{rw} and @var{locality}.
11133 The value of @var{rw} is a compile-time constant one or zero; one
11134 means that the prefetch is preparing for a write to the memory address
11135 and zero, the default, means that the prefetch is preparing for a read.
11136 The value @var{locality} must be a compile-time constant integer between
11137 zero and three. A value of zero means that the data has no temporal
11138 locality, so it need not be left in the cache after the access. A value
11139 of three means that the data has a high degree of temporal locality and
11140 should be left in all levels of cache possible. Values of one and two
11141 mean, respectively, a low or moderate degree of temporal locality. The
11142 default is three.
11143
11144 @smallexample
11145 for (i = 0; i < n; i++)
11146 @{
11147 a[i] = a[i] + b[i];
11148 __builtin_prefetch (&a[i+j], 1, 1);
11149 __builtin_prefetch (&b[i+j], 0, 1);
11150 /* @r{@dots{}} */
11151 @}
11152 @end smallexample
11153
11154 Data prefetch does not generate faults if @var{addr} is invalid, but
11155 the address expression itself must be valid. For example, a prefetch
11156 of @code{p->next} does not fault if @code{p->next} is not a valid
11157 address, but evaluation faults if @code{p} is not a valid address.
11158
11159 If the target does not support data prefetch, the address expression
11160 is evaluated if it includes side effects but no other code is generated
11161 and GCC does not issue a warning.
11162 @end deftypefn
11163
11164 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11165 Returns a positive infinity, if supported by the floating-point format,
11166 else @code{DBL_MAX}. This function is suitable for implementing the
11167 ISO C macro @code{HUGE_VAL}.
11168 @end deftypefn
11169
11170 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11171 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11172 @end deftypefn
11173
11174 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11175 Similar to @code{__builtin_huge_val}, except the return
11176 type is @code{long double}.
11177 @end deftypefn
11178
11179 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11180 This built-in implements the C99 fpclassify functionality. The first
11181 five int arguments should be the target library's notion of the
11182 possible FP classes and are used for return values. They must be
11183 constant values and they must appear in this order: @code{FP_NAN},
11184 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11185 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11186 to classify. GCC treats the last argument as type-generic, which
11187 means it does not do default promotion from float to double.
11188 @end deftypefn
11189
11190 @deftypefn {Built-in Function} double __builtin_inf (void)
11191 Similar to @code{__builtin_huge_val}, except a warning is generated
11192 if the target floating-point format does not support infinities.
11193 @end deftypefn
11194
11195 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11196 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11197 @end deftypefn
11198
11199 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11200 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11201 @end deftypefn
11202
11203 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11204 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11205 @end deftypefn
11206
11207 @deftypefn {Built-in Function} float __builtin_inff (void)
11208 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11209 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11210 @end deftypefn
11211
11212 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11213 Similar to @code{__builtin_inf}, except the return
11214 type is @code{long double}.
11215 @end deftypefn
11216
11217 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11218 Similar to @code{isinf}, except the return value is -1 for
11219 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11220 Note while the parameter list is an
11221 ellipsis, this function only accepts exactly one floating-point
11222 argument. GCC treats this parameter as type-generic, which means it
11223 does not do default promotion from float to double.
11224 @end deftypefn
11225
11226 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11227 This is an implementation of the ISO C99 function @code{nan}.
11228
11229 Since ISO C99 defines this function in terms of @code{strtod}, which we
11230 do not implement, a description of the parsing is in order. The string
11231 is parsed as by @code{strtol}; that is, the base is recognized by
11232 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11233 in the significand such that the least significant bit of the number
11234 is at the least significant bit of the significand. The number is
11235 truncated to fit the significand field provided. The significand is
11236 forced to be a quiet NaN@.
11237
11238 This function, if given a string literal all of which would have been
11239 consumed by @code{strtol}, is evaluated early enough that it is considered a
11240 compile-time constant.
11241 @end deftypefn
11242
11243 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11244 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11245 @end deftypefn
11246
11247 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11248 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11249 @end deftypefn
11250
11251 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11252 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11253 @end deftypefn
11254
11255 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11256 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11257 @end deftypefn
11258
11259 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11260 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11261 @end deftypefn
11262
11263 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11264 Similar to @code{__builtin_nan}, except the significand is forced
11265 to be a signaling NaN@. The @code{nans} function is proposed by
11266 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11267 @end deftypefn
11268
11269 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11270 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11271 @end deftypefn
11272
11273 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11274 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11275 @end deftypefn
11276
11277 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11278 Returns one plus the index of the least significant 1-bit of @var{x}, or
11279 if @var{x} is zero, returns zero.
11280 @end deftypefn
11281
11282 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11283 Returns the number of leading 0-bits in @var{x}, starting at the most
11284 significant bit position. If @var{x} is 0, the result is undefined.
11285 @end deftypefn
11286
11287 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11288 Returns the number of trailing 0-bits in @var{x}, starting at the least
11289 significant bit position. If @var{x} is 0, the result is undefined.
11290 @end deftypefn
11291
11292 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11293 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11294 number of bits following the most significant bit that are identical
11295 to it. There are no special cases for 0 or other values.
11296 @end deftypefn
11297
11298 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11299 Returns the number of 1-bits in @var{x}.
11300 @end deftypefn
11301
11302 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11303 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11304 modulo 2.
11305 @end deftypefn
11306
11307 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11308 Similar to @code{__builtin_ffs}, except the argument type is
11309 @code{long}.
11310 @end deftypefn
11311
11312 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11313 Similar to @code{__builtin_clz}, except the argument type is
11314 @code{unsigned long}.
11315 @end deftypefn
11316
11317 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11318 Similar to @code{__builtin_ctz}, except the argument type is
11319 @code{unsigned long}.
11320 @end deftypefn
11321
11322 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11323 Similar to @code{__builtin_clrsb}, except the argument type is
11324 @code{long}.
11325 @end deftypefn
11326
11327 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11328 Similar to @code{__builtin_popcount}, except the argument type is
11329 @code{unsigned long}.
11330 @end deftypefn
11331
11332 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11333 Similar to @code{__builtin_parity}, except the argument type is
11334 @code{unsigned long}.
11335 @end deftypefn
11336
11337 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11338 Similar to @code{__builtin_ffs}, except the argument type is
11339 @code{long long}.
11340 @end deftypefn
11341
11342 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11343 Similar to @code{__builtin_clz}, except the argument type is
11344 @code{unsigned long long}.
11345 @end deftypefn
11346
11347 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11348 Similar to @code{__builtin_ctz}, except the argument type is
11349 @code{unsigned long long}.
11350 @end deftypefn
11351
11352 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11353 Similar to @code{__builtin_clrsb}, except the argument type is
11354 @code{long long}.
11355 @end deftypefn
11356
11357 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11358 Similar to @code{__builtin_popcount}, except the argument type is
11359 @code{unsigned long long}.
11360 @end deftypefn
11361
11362 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11363 Similar to @code{__builtin_parity}, except the argument type is
11364 @code{unsigned long long}.
11365 @end deftypefn
11366
11367 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11368 Returns the first argument raised to the power of the second. Unlike the
11369 @code{pow} function no guarantees about precision and rounding are made.
11370 @end deftypefn
11371
11372 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11373 Similar to @code{__builtin_powi}, except the argument and return types
11374 are @code{float}.
11375 @end deftypefn
11376
11377 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11378 Similar to @code{__builtin_powi}, except the argument and return types
11379 are @code{long double}.
11380 @end deftypefn
11381
11382 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11383 Returns @var{x} with the order of the bytes reversed; for example,
11384 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11385 exactly 8 bits.
11386 @end deftypefn
11387
11388 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11389 Similar to @code{__builtin_bswap16}, except the argument and return types
11390 are 32 bit.
11391 @end deftypefn
11392
11393 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11394 Similar to @code{__builtin_bswap32}, except the argument and return types
11395 are 64 bit.
11396 @end deftypefn
11397
11398 @node Target Builtins
11399 @section Built-in Functions Specific to Particular Target Machines
11400
11401 On some target machines, GCC supports many built-in functions specific
11402 to those machines. Generally these generate calls to specific machine
11403 instructions, but allow the compiler to schedule those calls.
11404
11405 @menu
11406 * AArch64 Built-in Functions::
11407 * Alpha Built-in Functions::
11408 * Altera Nios II Built-in Functions::
11409 * ARC Built-in Functions::
11410 * ARC SIMD Built-in Functions::
11411 * ARM iWMMXt Built-in Functions::
11412 * ARM C Language Extensions (ACLE)::
11413 * ARM Floating Point Status and Control Intrinsics::
11414 * AVR Built-in Functions::
11415 * Blackfin Built-in Functions::
11416 * FR-V Built-in Functions::
11417 * MIPS DSP Built-in Functions::
11418 * MIPS Paired-Single Support::
11419 * MIPS Loongson Built-in Functions::
11420 * Other MIPS Built-in Functions::
11421 * MSP430 Built-in Functions::
11422 * NDS32 Built-in Functions::
11423 * picoChip Built-in Functions::
11424 * PowerPC Built-in Functions::
11425 * PowerPC AltiVec/VSX Built-in Functions::
11426 * PowerPC Hardware Transactional Memory Built-in Functions::
11427 * RX Built-in Functions::
11428 * S/390 System z Built-in Functions::
11429 * SH Built-in Functions::
11430 * SPARC VIS Built-in Functions::
11431 * SPU Built-in Functions::
11432 * TI C6X Built-in Functions::
11433 * TILE-Gx Built-in Functions::
11434 * TILEPro Built-in Functions::
11435 * x86 Built-in Functions::
11436 * x86 transactional memory intrinsics::
11437 @end menu
11438
11439 @node AArch64 Built-in Functions
11440 @subsection AArch64 Built-in Functions
11441
11442 These built-in functions are available for the AArch64 family of
11443 processors.
11444 @smallexample
11445 unsigned int __builtin_aarch64_get_fpcr ()
11446 void __builtin_aarch64_set_fpcr (unsigned int)
11447 unsigned int __builtin_aarch64_get_fpsr ()
11448 void __builtin_aarch64_set_fpsr (unsigned int)
11449 @end smallexample
11450
11451 @node Alpha Built-in Functions
11452 @subsection Alpha Built-in Functions
11453
11454 These built-in functions are available for the Alpha family of
11455 processors, depending on the command-line switches used.
11456
11457 The following built-in functions are always available. They
11458 all generate the machine instruction that is part of the name.
11459
11460 @smallexample
11461 long __builtin_alpha_implver (void)
11462 long __builtin_alpha_rpcc (void)
11463 long __builtin_alpha_amask (long)
11464 long __builtin_alpha_cmpbge (long, long)
11465 long __builtin_alpha_extbl (long, long)
11466 long __builtin_alpha_extwl (long, long)
11467 long __builtin_alpha_extll (long, long)
11468 long __builtin_alpha_extql (long, long)
11469 long __builtin_alpha_extwh (long, long)
11470 long __builtin_alpha_extlh (long, long)
11471 long __builtin_alpha_extqh (long, long)
11472 long __builtin_alpha_insbl (long, long)
11473 long __builtin_alpha_inswl (long, long)
11474 long __builtin_alpha_insll (long, long)
11475 long __builtin_alpha_insql (long, long)
11476 long __builtin_alpha_inswh (long, long)
11477 long __builtin_alpha_inslh (long, long)
11478 long __builtin_alpha_insqh (long, long)
11479 long __builtin_alpha_mskbl (long, long)
11480 long __builtin_alpha_mskwl (long, long)
11481 long __builtin_alpha_mskll (long, long)
11482 long __builtin_alpha_mskql (long, long)
11483 long __builtin_alpha_mskwh (long, long)
11484 long __builtin_alpha_msklh (long, long)
11485 long __builtin_alpha_mskqh (long, long)
11486 long __builtin_alpha_umulh (long, long)
11487 long __builtin_alpha_zap (long, long)
11488 long __builtin_alpha_zapnot (long, long)
11489 @end smallexample
11490
11491 The following built-in functions are always with @option{-mmax}
11492 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11493 later. They all generate the machine instruction that is part
11494 of the name.
11495
11496 @smallexample
11497 long __builtin_alpha_pklb (long)
11498 long __builtin_alpha_pkwb (long)
11499 long __builtin_alpha_unpkbl (long)
11500 long __builtin_alpha_unpkbw (long)
11501 long __builtin_alpha_minub8 (long, long)
11502 long __builtin_alpha_minsb8 (long, long)
11503 long __builtin_alpha_minuw4 (long, long)
11504 long __builtin_alpha_minsw4 (long, long)
11505 long __builtin_alpha_maxub8 (long, long)
11506 long __builtin_alpha_maxsb8 (long, long)
11507 long __builtin_alpha_maxuw4 (long, long)
11508 long __builtin_alpha_maxsw4 (long, long)
11509 long __builtin_alpha_perr (long, long)
11510 @end smallexample
11511
11512 The following built-in functions are always with @option{-mcix}
11513 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11514 later. They all generate the machine instruction that is part
11515 of the name.
11516
11517 @smallexample
11518 long __builtin_alpha_cttz (long)
11519 long __builtin_alpha_ctlz (long)
11520 long __builtin_alpha_ctpop (long)
11521 @end smallexample
11522
11523 The following built-in functions are available on systems that use the OSF/1
11524 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11525 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11526 @code{rdval} and @code{wrval}.
11527
11528 @smallexample
11529 void *__builtin_thread_pointer (void)
11530 void __builtin_set_thread_pointer (void *)
11531 @end smallexample
11532
11533 @node Altera Nios II Built-in Functions
11534 @subsection Altera Nios II Built-in Functions
11535
11536 These built-in functions are available for the Altera Nios II
11537 family of processors.
11538
11539 The following built-in functions are always available. They
11540 all generate the machine instruction that is part of the name.
11541
11542 @example
11543 int __builtin_ldbio (volatile const void *)
11544 int __builtin_ldbuio (volatile const void *)
11545 int __builtin_ldhio (volatile const void *)
11546 int __builtin_ldhuio (volatile const void *)
11547 int __builtin_ldwio (volatile const void *)
11548 void __builtin_stbio (volatile void *, int)
11549 void __builtin_sthio (volatile void *, int)
11550 void __builtin_stwio (volatile void *, int)
11551 void __builtin_sync (void)
11552 int __builtin_rdctl (int)
11553 int __builtin_rdprs (int, int)
11554 void __builtin_wrctl (int, int)
11555 void __builtin_flushd (volatile void *)
11556 void __builtin_flushda (volatile void *)
11557 int __builtin_wrpie (int);
11558 void __builtin_eni (int);
11559 int __builtin_ldex (volatile const void *)
11560 int __builtin_stex (volatile void *, int)
11561 int __builtin_ldsex (volatile const void *)
11562 int __builtin_stsex (volatile void *, int)
11563 @end example
11564
11565 The following built-in functions are always available. They
11566 all generate a Nios II Custom Instruction. The name of the
11567 function represents the types that the function takes and
11568 returns. The letter before the @code{n} is the return type
11569 or void if absent. The @code{n} represents the first parameter
11570 to all the custom instructions, the custom instruction number.
11571 The two letters after the @code{n} represent the up to two
11572 parameters to the function.
11573
11574 The letters represent the following data types:
11575 @table @code
11576 @item <no letter>
11577 @code{void} for return type and no parameter for parameter types.
11578
11579 @item i
11580 @code{int} for return type and parameter type
11581
11582 @item f
11583 @code{float} for return type and parameter type
11584
11585 @item p
11586 @code{void *} for return type and parameter type
11587
11588 @end table
11589
11590 And the function names are:
11591 @example
11592 void __builtin_custom_n (void)
11593 void __builtin_custom_ni (int)
11594 void __builtin_custom_nf (float)
11595 void __builtin_custom_np (void *)
11596 void __builtin_custom_nii (int, int)
11597 void __builtin_custom_nif (int, float)
11598 void __builtin_custom_nip (int, void *)
11599 void __builtin_custom_nfi (float, int)
11600 void __builtin_custom_nff (float, float)
11601 void __builtin_custom_nfp (float, void *)
11602 void __builtin_custom_npi (void *, int)
11603 void __builtin_custom_npf (void *, float)
11604 void __builtin_custom_npp (void *, void *)
11605 int __builtin_custom_in (void)
11606 int __builtin_custom_ini (int)
11607 int __builtin_custom_inf (float)
11608 int __builtin_custom_inp (void *)
11609 int __builtin_custom_inii (int, int)
11610 int __builtin_custom_inif (int, float)
11611 int __builtin_custom_inip (int, void *)
11612 int __builtin_custom_infi (float, int)
11613 int __builtin_custom_inff (float, float)
11614 int __builtin_custom_infp (float, void *)
11615 int __builtin_custom_inpi (void *, int)
11616 int __builtin_custom_inpf (void *, float)
11617 int __builtin_custom_inpp (void *, void *)
11618 float __builtin_custom_fn (void)
11619 float __builtin_custom_fni (int)
11620 float __builtin_custom_fnf (float)
11621 float __builtin_custom_fnp (void *)
11622 float __builtin_custom_fnii (int, int)
11623 float __builtin_custom_fnif (int, float)
11624 float __builtin_custom_fnip (int, void *)
11625 float __builtin_custom_fnfi (float, int)
11626 float __builtin_custom_fnff (float, float)
11627 float __builtin_custom_fnfp (float, void *)
11628 float __builtin_custom_fnpi (void *, int)
11629 float __builtin_custom_fnpf (void *, float)
11630 float __builtin_custom_fnpp (void *, void *)
11631 void * __builtin_custom_pn (void)
11632 void * __builtin_custom_pni (int)
11633 void * __builtin_custom_pnf (float)
11634 void * __builtin_custom_pnp (void *)
11635 void * __builtin_custom_pnii (int, int)
11636 void * __builtin_custom_pnif (int, float)
11637 void * __builtin_custom_pnip (int, void *)
11638 void * __builtin_custom_pnfi (float, int)
11639 void * __builtin_custom_pnff (float, float)
11640 void * __builtin_custom_pnfp (float, void *)
11641 void * __builtin_custom_pnpi (void *, int)
11642 void * __builtin_custom_pnpf (void *, float)
11643 void * __builtin_custom_pnpp (void *, void *)
11644 @end example
11645
11646 @node ARC Built-in Functions
11647 @subsection ARC Built-in Functions
11648
11649 The following built-in functions are provided for ARC targets. The
11650 built-ins generate the corresponding assembly instructions. In the
11651 examples given below, the generated code often requires an operand or
11652 result to be in a register. Where necessary further code will be
11653 generated to ensure this is true, but for brevity this is not
11654 described in each case.
11655
11656 @emph{Note:} Using a built-in to generate an instruction not supported
11657 by a target may cause problems. At present the compiler is not
11658 guaranteed to detect such misuse, and as a result an internal compiler
11659 error may be generated.
11660
11661 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11662 Return 1 if @var{val} is known to have the byte alignment given
11663 by @var{alignval}, otherwise return 0.
11664 Note that this is different from
11665 @smallexample
11666 __alignof__(*(char *)@var{val}) >= alignval
11667 @end smallexample
11668 because __alignof__ sees only the type of the dereference, whereas
11669 __builtin_arc_align uses alignment information from the pointer
11670 as well as from the pointed-to type.
11671 The information available will depend on optimization level.
11672 @end deftypefn
11673
11674 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11675 Generates
11676 @example
11677 brk
11678 @end example
11679 @end deftypefn
11680
11681 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11682 The operand is the number of a register to be read. Generates:
11683 @example
11684 mov @var{dest}, r@var{regno}
11685 @end example
11686 where the value in @var{dest} will be the result returned from the
11687 built-in.
11688 @end deftypefn
11689
11690 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11691 The first operand is the number of a register to be written, the
11692 second operand is a compile time constant to write into that
11693 register. Generates:
11694 @example
11695 mov r@var{regno}, @var{val}
11696 @end example
11697 @end deftypefn
11698
11699 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11700 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11701 Generates:
11702 @example
11703 divaw @var{dest}, @var{a}, @var{b}
11704 @end example
11705 where the value in @var{dest} will be the result returned from the
11706 built-in.
11707 @end deftypefn
11708
11709 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11710 Generates
11711 @example
11712 flag @var{a}
11713 @end example
11714 @end deftypefn
11715
11716 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11717 The operand, @var{auxv}, is the address of an auxiliary register and
11718 must be a compile time constant. Generates:
11719 @example
11720 lr @var{dest}, [@var{auxr}]
11721 @end example
11722 Where the value in @var{dest} will be the result returned from the
11723 built-in.
11724 @end deftypefn
11725
11726 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11727 Only available with @option{-mmul64}. Generates:
11728 @example
11729 mul64 @var{a}, @var{b}
11730 @end example
11731 @end deftypefn
11732
11733 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11734 Only available with @option{-mmul64}. Generates:
11735 @example
11736 mulu64 @var{a}, @var{b}
11737 @end example
11738 @end deftypefn
11739
11740 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11741 Generates:
11742 @example
11743 nop
11744 @end example
11745 @end deftypefn
11746
11747 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11748 Only valid if the @samp{norm} instruction is available through the
11749 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11750 Generates:
11751 @example
11752 norm @var{dest}, @var{src}
11753 @end example
11754 Where the value in @var{dest} will be the result returned from the
11755 built-in.
11756 @end deftypefn
11757
11758 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11759 Only valid if the @samp{normw} instruction is available through the
11760 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11761 Generates:
11762 @example
11763 normw @var{dest}, @var{src}
11764 @end example
11765 Where the value in @var{dest} will be the result returned from the
11766 built-in.
11767 @end deftypefn
11768
11769 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11770 Generates:
11771 @example
11772 rtie
11773 @end example
11774 @end deftypefn
11775
11776 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11777 Generates:
11778 @example
11779 sleep @var{a}
11780 @end example
11781 @end deftypefn
11782
11783 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11784 The first argument, @var{auxv}, is the address of an auxiliary
11785 register, the second argument, @var{val}, is a compile time constant
11786 to be written to the register. Generates:
11787 @example
11788 sr @var{auxr}, [@var{val}]
11789 @end example
11790 @end deftypefn
11791
11792 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11793 Only valid with @option{-mswap}. Generates:
11794 @example
11795 swap @var{dest}, @var{src}
11796 @end example
11797 Where the value in @var{dest} will be the result returned from the
11798 built-in.
11799 @end deftypefn
11800
11801 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11802 Generates:
11803 @example
11804 swi
11805 @end example
11806 @end deftypefn
11807
11808 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11809 Only available with @option{-mcpu=ARC700}. Generates:
11810 @example
11811 sync
11812 @end example
11813 @end deftypefn
11814
11815 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11816 Only available with @option{-mcpu=ARC700}. Generates:
11817 @example
11818 trap_s @var{c}
11819 @end example
11820 @end deftypefn
11821
11822 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11823 Only available with @option{-mcpu=ARC700}. Generates:
11824 @example
11825 unimp_s
11826 @end example
11827 @end deftypefn
11828
11829 The instructions generated by the following builtins are not
11830 considered as candidates for scheduling. They are not moved around by
11831 the compiler during scheduling, and thus can be expected to appear
11832 where they are put in the C code:
11833 @example
11834 __builtin_arc_brk()
11835 __builtin_arc_core_read()
11836 __builtin_arc_core_write()
11837 __builtin_arc_flag()
11838 __builtin_arc_lr()
11839 __builtin_arc_sleep()
11840 __builtin_arc_sr()
11841 __builtin_arc_swi()
11842 @end example
11843
11844 @node ARC SIMD Built-in Functions
11845 @subsection ARC SIMD Built-in Functions
11846
11847 SIMD builtins provided by the compiler can be used to generate the
11848 vector instructions. This section describes the available builtins
11849 and their usage in programs. With the @option{-msimd} option, the
11850 compiler provides 128-bit vector types, which can be specified using
11851 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11852 can be included to use the following predefined types:
11853 @example
11854 typedef int __v4si __attribute__((vector_size(16)));
11855 typedef short __v8hi __attribute__((vector_size(16)));
11856 @end example
11857
11858 These types can be used to define 128-bit variables. The built-in
11859 functions listed in the following section can be used on these
11860 variables to generate the vector operations.
11861
11862 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11863 @file{arc-simd.h} also provides equivalent macros called
11864 @code{_@var{someinsn}} that can be used for programming ease and
11865 improved readability. The following macros for DMA control are also
11866 provided:
11867 @example
11868 #define _setup_dma_in_channel_reg _vdiwr
11869 #define _setup_dma_out_channel_reg _vdowr
11870 @end example
11871
11872 The following is a complete list of all the SIMD built-ins provided
11873 for ARC, grouped by calling signature.
11874
11875 The following take two @code{__v8hi} arguments and return a
11876 @code{__v8hi} result:
11877 @example
11878 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11879 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11880 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11881 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11882 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11883 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11884 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11885 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11886 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11887 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11888 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11889 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11890 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11891 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11892 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11893 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11894 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11895 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11896 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11897 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11898 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11899 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11900 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11901 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11902 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11903 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11904 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11905 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11906 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11907 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11908 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11909 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11910 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11911 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11912 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11913 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11914 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11915 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11916 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11917 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11918 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11919 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11920 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11921 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11922 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11923 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11924 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11925 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11926 @end example
11927
11928 The following take one @code{__v8hi} and one @code{int} argument and return a
11929 @code{__v8hi} result:
11930
11931 @example
11932 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11933 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11934 __v8hi __builtin_arc_vbminw (__v8hi, int)
11935 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11936 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11937 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11938 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11939 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11940 @end example
11941
11942 The following take one @code{__v8hi} argument and one @code{int} argument which
11943 must be a 3-bit compile time constant indicating a register number
11944 I0-I7. They return a @code{__v8hi} result.
11945 @example
11946 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11947 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11948 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11949 @end example
11950
11951 The following take one @code{__v8hi} argument and one @code{int}
11952 argument which must be a 6-bit compile time constant. They return a
11953 @code{__v8hi} result.
11954 @example
11955 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11956 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11957 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11958 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11959 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11960 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11961 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11962 @end example
11963
11964 The following take one @code{__v8hi} argument and one @code{int} argument which
11965 must be a 8-bit compile time constant. They return a @code{__v8hi}
11966 result.
11967 @example
11968 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11969 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11970 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11971 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11972 @end example
11973
11974 The following take two @code{int} arguments, the second of which which
11975 must be a 8-bit compile time constant. They return a @code{__v8hi}
11976 result:
11977 @example
11978 __v8hi __builtin_arc_vmovaw (int, const int)
11979 __v8hi __builtin_arc_vmovw (int, const int)
11980 __v8hi __builtin_arc_vmovzw (int, const int)
11981 @end example
11982
11983 The following take a single @code{__v8hi} argument and return a
11984 @code{__v8hi} result:
11985 @example
11986 __v8hi __builtin_arc_vabsaw (__v8hi)
11987 __v8hi __builtin_arc_vabsw (__v8hi)
11988 __v8hi __builtin_arc_vaddsuw (__v8hi)
11989 __v8hi __builtin_arc_vexch1 (__v8hi)
11990 __v8hi __builtin_arc_vexch2 (__v8hi)
11991 __v8hi __builtin_arc_vexch4 (__v8hi)
11992 __v8hi __builtin_arc_vsignw (__v8hi)
11993 __v8hi __builtin_arc_vupbaw (__v8hi)
11994 __v8hi __builtin_arc_vupbw (__v8hi)
11995 __v8hi __builtin_arc_vupsbaw (__v8hi)
11996 __v8hi __builtin_arc_vupsbw (__v8hi)
11997 @end example
11998
11999 The following take two @code{int} arguments and return no result:
12000 @example
12001 void __builtin_arc_vdirun (int, int)
12002 void __builtin_arc_vdorun (int, int)
12003 @end example
12004
12005 The following take two @code{int} arguments and return no result. The
12006 first argument must a 3-bit compile time constant indicating one of
12007 the DR0-DR7 DMA setup channels:
12008 @example
12009 void __builtin_arc_vdiwr (const int, int)
12010 void __builtin_arc_vdowr (const int, int)
12011 @end example
12012
12013 The following take an @code{int} argument and return no result:
12014 @example
12015 void __builtin_arc_vendrec (int)
12016 void __builtin_arc_vrec (int)
12017 void __builtin_arc_vrecrun (int)
12018 void __builtin_arc_vrun (int)
12019 @end example
12020
12021 The following take a @code{__v8hi} argument and two @code{int}
12022 arguments and return a @code{__v8hi} result. The second argument must
12023 be a 3-bit compile time constants, indicating one the registers I0-I7,
12024 and the third argument must be an 8-bit compile time constant.
12025
12026 @emph{Note:} Although the equivalent hardware instructions do not take
12027 an SIMD register as an operand, these builtins overwrite the relevant
12028 bits of the @code{__v8hi} register provided as the first argument with
12029 the value loaded from the @code{[Ib, u8]} location in the SDM.
12030
12031 @example
12032 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12033 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12034 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12035 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12036 @end example
12037
12038 The following take two @code{int} arguments and return a @code{__v8hi}
12039 result. The first argument must be a 3-bit compile time constants,
12040 indicating one the registers I0-I7, and the second argument must be an
12041 8-bit compile time constant.
12042
12043 @example
12044 __v8hi __builtin_arc_vld128 (const int, const int)
12045 __v8hi __builtin_arc_vld64w (const int, const int)
12046 @end example
12047
12048 The following take a @code{__v8hi} argument and two @code{int}
12049 arguments and return no result. The second argument must be a 3-bit
12050 compile time constants, indicating one the registers I0-I7, and the
12051 third argument must be an 8-bit compile time constant.
12052
12053 @example
12054 void __builtin_arc_vst128 (__v8hi, const int, const int)
12055 void __builtin_arc_vst64 (__v8hi, const int, const int)
12056 @end example
12057
12058 The following take a @code{__v8hi} argument and three @code{int}
12059 arguments and return no result. The second argument must be a 3-bit
12060 compile-time constant, identifying the 16-bit sub-register to be
12061 stored, the third argument must be a 3-bit compile time constants,
12062 indicating one the registers I0-I7, and the fourth argument must be an
12063 8-bit compile time constant.
12064
12065 @example
12066 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12067 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12068 @end example
12069
12070 @node ARM iWMMXt Built-in Functions
12071 @subsection ARM iWMMXt Built-in Functions
12072
12073 These built-in functions are available for the ARM family of
12074 processors when the @option{-mcpu=iwmmxt} switch is used:
12075
12076 @smallexample
12077 typedef int v2si __attribute__ ((vector_size (8)));
12078 typedef short v4hi __attribute__ ((vector_size (8)));
12079 typedef char v8qi __attribute__ ((vector_size (8)));
12080
12081 int __builtin_arm_getwcgr0 (void)
12082 void __builtin_arm_setwcgr0 (int)
12083 int __builtin_arm_getwcgr1 (void)
12084 void __builtin_arm_setwcgr1 (int)
12085 int __builtin_arm_getwcgr2 (void)
12086 void __builtin_arm_setwcgr2 (int)
12087 int __builtin_arm_getwcgr3 (void)
12088 void __builtin_arm_setwcgr3 (int)
12089 int __builtin_arm_textrmsb (v8qi, int)
12090 int __builtin_arm_textrmsh (v4hi, int)
12091 int __builtin_arm_textrmsw (v2si, int)
12092 int __builtin_arm_textrmub (v8qi, int)
12093 int __builtin_arm_textrmuh (v4hi, int)
12094 int __builtin_arm_textrmuw (v2si, int)
12095 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12096 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12097 v2si __builtin_arm_tinsrw (v2si, int, int)
12098 long long __builtin_arm_tmia (long long, int, int)
12099 long long __builtin_arm_tmiabb (long long, int, int)
12100 long long __builtin_arm_tmiabt (long long, int, int)
12101 long long __builtin_arm_tmiaph (long long, int, int)
12102 long long __builtin_arm_tmiatb (long long, int, int)
12103 long long __builtin_arm_tmiatt (long long, int, int)
12104 int __builtin_arm_tmovmskb (v8qi)
12105 int __builtin_arm_tmovmskh (v4hi)
12106 int __builtin_arm_tmovmskw (v2si)
12107 long long __builtin_arm_waccb (v8qi)
12108 long long __builtin_arm_wacch (v4hi)
12109 long long __builtin_arm_waccw (v2si)
12110 v8qi __builtin_arm_waddb (v8qi, v8qi)
12111 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12112 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12113 v4hi __builtin_arm_waddh (v4hi, v4hi)
12114 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12115 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12116 v2si __builtin_arm_waddw (v2si, v2si)
12117 v2si __builtin_arm_waddwss (v2si, v2si)
12118 v2si __builtin_arm_waddwus (v2si, v2si)
12119 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12120 long long __builtin_arm_wand(long long, long long)
12121 long long __builtin_arm_wandn (long long, long long)
12122 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12123 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12124 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12125 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12126 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12127 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12128 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12129 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12130 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12131 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12132 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12133 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12134 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12135 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12136 long long __builtin_arm_wmacsz (v4hi, v4hi)
12137 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12138 long long __builtin_arm_wmacuz (v4hi, v4hi)
12139 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12140 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12141 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12142 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12143 v2si __builtin_arm_wmaxsw (v2si, v2si)
12144 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12145 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12146 v2si __builtin_arm_wmaxuw (v2si, v2si)
12147 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12148 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12149 v2si __builtin_arm_wminsw (v2si, v2si)
12150 v8qi __builtin_arm_wminub (v8qi, v8qi)
12151 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12152 v2si __builtin_arm_wminuw (v2si, v2si)
12153 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12154 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12155 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12156 long long __builtin_arm_wor (long long, long long)
12157 v2si __builtin_arm_wpackdss (long long, long long)
12158 v2si __builtin_arm_wpackdus (long long, long long)
12159 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12160 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12161 v4hi __builtin_arm_wpackwss (v2si, v2si)
12162 v4hi __builtin_arm_wpackwus (v2si, v2si)
12163 long long __builtin_arm_wrord (long long, long long)
12164 long long __builtin_arm_wrordi (long long, int)
12165 v4hi __builtin_arm_wrorh (v4hi, long long)
12166 v4hi __builtin_arm_wrorhi (v4hi, int)
12167 v2si __builtin_arm_wrorw (v2si, long long)
12168 v2si __builtin_arm_wrorwi (v2si, int)
12169 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12170 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12171 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12172 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12173 v4hi __builtin_arm_wshufh (v4hi, int)
12174 long long __builtin_arm_wslld (long long, long long)
12175 long long __builtin_arm_wslldi (long long, int)
12176 v4hi __builtin_arm_wsllh (v4hi, long long)
12177 v4hi __builtin_arm_wsllhi (v4hi, int)
12178 v2si __builtin_arm_wsllw (v2si, long long)
12179 v2si __builtin_arm_wsllwi (v2si, int)
12180 long long __builtin_arm_wsrad (long long, long long)
12181 long long __builtin_arm_wsradi (long long, int)
12182 v4hi __builtin_arm_wsrah (v4hi, long long)
12183 v4hi __builtin_arm_wsrahi (v4hi, int)
12184 v2si __builtin_arm_wsraw (v2si, long long)
12185 v2si __builtin_arm_wsrawi (v2si, int)
12186 long long __builtin_arm_wsrld (long long, long long)
12187 long long __builtin_arm_wsrldi (long long, int)
12188 v4hi __builtin_arm_wsrlh (v4hi, long long)
12189 v4hi __builtin_arm_wsrlhi (v4hi, int)
12190 v2si __builtin_arm_wsrlw (v2si, long long)
12191 v2si __builtin_arm_wsrlwi (v2si, int)
12192 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12193 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12194 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12195 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12196 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12197 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12198 v2si __builtin_arm_wsubw (v2si, v2si)
12199 v2si __builtin_arm_wsubwss (v2si, v2si)
12200 v2si __builtin_arm_wsubwus (v2si, v2si)
12201 v4hi __builtin_arm_wunpckehsb (v8qi)
12202 v2si __builtin_arm_wunpckehsh (v4hi)
12203 long long __builtin_arm_wunpckehsw (v2si)
12204 v4hi __builtin_arm_wunpckehub (v8qi)
12205 v2si __builtin_arm_wunpckehuh (v4hi)
12206 long long __builtin_arm_wunpckehuw (v2si)
12207 v4hi __builtin_arm_wunpckelsb (v8qi)
12208 v2si __builtin_arm_wunpckelsh (v4hi)
12209 long long __builtin_arm_wunpckelsw (v2si)
12210 v4hi __builtin_arm_wunpckelub (v8qi)
12211 v2si __builtin_arm_wunpckeluh (v4hi)
12212 long long __builtin_arm_wunpckeluw (v2si)
12213 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12214 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12215 v2si __builtin_arm_wunpckihw (v2si, v2si)
12216 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12217 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12218 v2si __builtin_arm_wunpckilw (v2si, v2si)
12219 long long __builtin_arm_wxor (long long, long long)
12220 long long __builtin_arm_wzero ()
12221 @end smallexample
12222
12223
12224 @node ARM C Language Extensions (ACLE)
12225 @subsection ARM C Language Extensions (ACLE)
12226
12227 GCC implements extensions for C as described in the ARM C Language
12228 Extensions (ACLE) specification, which can be found at
12229 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12230
12231 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12232 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12233 intrinsics can be found at
12234 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12235 The built-in intrinsics for the Advanced SIMD extension are available when
12236 NEON is enabled.
12237
12238 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12239 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12240 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12241 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12242 intrinsics yet.
12243
12244 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12245 availability of extensions.
12246
12247 @node ARM Floating Point Status and Control Intrinsics
12248 @subsection ARM Floating Point Status and Control Intrinsics
12249
12250 These built-in functions are available for the ARM family of
12251 processors with floating-point unit.
12252
12253 @smallexample
12254 unsigned int __builtin_arm_get_fpscr ()
12255 void __builtin_arm_set_fpscr (unsigned int)
12256 @end smallexample
12257
12258 @node AVR Built-in Functions
12259 @subsection AVR Built-in Functions
12260
12261 For each built-in function for AVR, there is an equally named,
12262 uppercase built-in macro defined. That way users can easily query if
12263 or if not a specific built-in is implemented or not. For example, if
12264 @code{__builtin_avr_nop} is available the macro
12265 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12266
12267 The following built-in functions map to the respective machine
12268 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12269 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12270 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12271 as library call if no hardware multiplier is available.
12272
12273 @smallexample
12274 void __builtin_avr_nop (void)
12275 void __builtin_avr_sei (void)
12276 void __builtin_avr_cli (void)
12277 void __builtin_avr_sleep (void)
12278 void __builtin_avr_wdr (void)
12279 unsigned char __builtin_avr_swap (unsigned char)
12280 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12281 int __builtin_avr_fmuls (char, char)
12282 int __builtin_avr_fmulsu (char, unsigned char)
12283 @end smallexample
12284
12285 In order to delay execution for a specific number of cycles, GCC
12286 implements
12287 @smallexample
12288 void __builtin_avr_delay_cycles (unsigned long ticks)
12289 @end smallexample
12290
12291 @noindent
12292 @code{ticks} is the number of ticks to delay execution. Note that this
12293 built-in does not take into account the effect of interrupts that
12294 might increase delay time. @code{ticks} must be a compile-time
12295 integer constant; delays with a variable number of cycles are not supported.
12296
12297 @smallexample
12298 char __builtin_avr_flash_segment (const __memx void*)
12299 @end smallexample
12300
12301 @noindent
12302 This built-in takes a byte address to the 24-bit
12303 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12304 the number of the flash segment (the 64 KiB chunk) where the address
12305 points to. Counting starts at @code{0}.
12306 If the address does not point to flash memory, return @code{-1}.
12307
12308 @smallexample
12309 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12310 @end smallexample
12311
12312 @noindent
12313 Insert bits from @var{bits} into @var{val} and return the resulting
12314 value. The nibbles of @var{map} determine how the insertion is
12315 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12316 @enumerate
12317 @item If @var{X} is @code{0xf},
12318 then the @var{n}-th bit of @var{val} is returned unaltered.
12319
12320 @item If X is in the range 0@dots{}7,
12321 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12322
12323 @item If X is in the range 8@dots{}@code{0xe},
12324 then the @var{n}-th result bit is undefined.
12325 @end enumerate
12326
12327 @noindent
12328 One typical use case for this built-in is adjusting input and
12329 output values to non-contiguous port layouts. Some examples:
12330
12331 @smallexample
12332 // same as val, bits is unused
12333 __builtin_avr_insert_bits (0xffffffff, bits, val)
12334 @end smallexample
12335
12336 @smallexample
12337 // same as bits, val is unused
12338 __builtin_avr_insert_bits (0x76543210, bits, val)
12339 @end smallexample
12340
12341 @smallexample
12342 // same as rotating bits by 4
12343 __builtin_avr_insert_bits (0x32107654, bits, 0)
12344 @end smallexample
12345
12346 @smallexample
12347 // high nibble of result is the high nibble of val
12348 // low nibble of result is the low nibble of bits
12349 __builtin_avr_insert_bits (0xffff3210, bits, val)
12350 @end smallexample
12351
12352 @smallexample
12353 // reverse the bit order of bits
12354 __builtin_avr_insert_bits (0x01234567, bits, 0)
12355 @end smallexample
12356
12357 @node Blackfin Built-in Functions
12358 @subsection Blackfin Built-in Functions
12359
12360 Currently, there are two Blackfin-specific built-in functions. These are
12361 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12362 using inline assembly; by using these built-in functions the compiler can
12363 automatically add workarounds for hardware errata involving these
12364 instructions. These functions are named as follows:
12365
12366 @smallexample
12367 void __builtin_bfin_csync (void)
12368 void __builtin_bfin_ssync (void)
12369 @end smallexample
12370
12371 @node FR-V Built-in Functions
12372 @subsection FR-V Built-in Functions
12373
12374 GCC provides many FR-V-specific built-in functions. In general,
12375 these functions are intended to be compatible with those described
12376 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12377 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12378 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12379 pointer rather than by value.
12380
12381 Most of the functions are named after specific FR-V instructions.
12382 Such functions are said to be ``directly mapped'' and are summarized
12383 here in tabular form.
12384
12385 @menu
12386 * Argument Types::
12387 * Directly-mapped Integer Functions::
12388 * Directly-mapped Media Functions::
12389 * Raw read/write Functions::
12390 * Other Built-in Functions::
12391 @end menu
12392
12393 @node Argument Types
12394 @subsubsection Argument Types
12395
12396 The arguments to the built-in functions can be divided into three groups:
12397 register numbers, compile-time constants and run-time values. In order
12398 to make this classification clear at a glance, the arguments and return
12399 values are given the following pseudo types:
12400
12401 @multitable @columnfractions .20 .30 .15 .35
12402 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12403 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12404 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12405 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12406 @item @code{uw2} @tab @code{unsigned long long} @tab No
12407 @tab an unsigned doubleword
12408 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12409 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12410 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12411 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12412 @end multitable
12413
12414 These pseudo types are not defined by GCC, they are simply a notational
12415 convenience used in this manual.
12416
12417 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12418 and @code{sw2} are evaluated at run time. They correspond to
12419 register operands in the underlying FR-V instructions.
12420
12421 @code{const} arguments represent immediate operands in the underlying
12422 FR-V instructions. They must be compile-time constants.
12423
12424 @code{acc} arguments are evaluated at compile time and specify the number
12425 of an accumulator register. For example, an @code{acc} argument of 2
12426 selects the ACC2 register.
12427
12428 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12429 number of an IACC register. See @pxref{Other Built-in Functions}
12430 for more details.
12431
12432 @node Directly-mapped Integer Functions
12433 @subsubsection Directly-Mapped Integer Functions
12434
12435 The functions listed below map directly to FR-V I-type instructions.
12436
12437 @multitable @columnfractions .45 .32 .23
12438 @item Function prototype @tab Example usage @tab Assembly output
12439 @item @code{sw1 __ADDSS (sw1, sw1)}
12440 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12441 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12442 @item @code{sw1 __SCAN (sw1, sw1)}
12443 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12444 @tab @code{SCAN @var{a},@var{b},@var{c}}
12445 @item @code{sw1 __SCUTSS (sw1)}
12446 @tab @code{@var{b} = __SCUTSS (@var{a})}
12447 @tab @code{SCUTSS @var{a},@var{b}}
12448 @item @code{sw1 __SLASS (sw1, sw1)}
12449 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12450 @tab @code{SLASS @var{a},@var{b},@var{c}}
12451 @item @code{void __SMASS (sw1, sw1)}
12452 @tab @code{__SMASS (@var{a}, @var{b})}
12453 @tab @code{SMASS @var{a},@var{b}}
12454 @item @code{void __SMSSS (sw1, sw1)}
12455 @tab @code{__SMSSS (@var{a}, @var{b})}
12456 @tab @code{SMSSS @var{a},@var{b}}
12457 @item @code{void __SMU (sw1, sw1)}
12458 @tab @code{__SMU (@var{a}, @var{b})}
12459 @tab @code{SMU @var{a},@var{b}}
12460 @item @code{sw2 __SMUL (sw1, sw1)}
12461 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12462 @tab @code{SMUL @var{a},@var{b},@var{c}}
12463 @item @code{sw1 __SUBSS (sw1, sw1)}
12464 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12465 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12466 @item @code{uw2 __UMUL (uw1, uw1)}
12467 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12468 @tab @code{UMUL @var{a},@var{b},@var{c}}
12469 @end multitable
12470
12471 @node Directly-mapped Media Functions
12472 @subsubsection Directly-Mapped Media Functions
12473
12474 The functions listed below map directly to FR-V M-type instructions.
12475
12476 @multitable @columnfractions .45 .32 .23
12477 @item Function prototype @tab Example usage @tab Assembly output
12478 @item @code{uw1 __MABSHS (sw1)}
12479 @tab @code{@var{b} = __MABSHS (@var{a})}
12480 @tab @code{MABSHS @var{a},@var{b}}
12481 @item @code{void __MADDACCS (acc, acc)}
12482 @tab @code{__MADDACCS (@var{b}, @var{a})}
12483 @tab @code{MADDACCS @var{a},@var{b}}
12484 @item @code{sw1 __MADDHSS (sw1, sw1)}
12485 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12486 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12487 @item @code{uw1 __MADDHUS (uw1, uw1)}
12488 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12489 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12490 @item @code{uw1 __MAND (uw1, uw1)}
12491 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12492 @tab @code{MAND @var{a},@var{b},@var{c}}
12493 @item @code{void __MASACCS (acc, acc)}
12494 @tab @code{__MASACCS (@var{b}, @var{a})}
12495 @tab @code{MASACCS @var{a},@var{b}}
12496 @item @code{uw1 __MAVEH (uw1, uw1)}
12497 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12498 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12499 @item @code{uw2 __MBTOH (uw1)}
12500 @tab @code{@var{b} = __MBTOH (@var{a})}
12501 @tab @code{MBTOH @var{a},@var{b}}
12502 @item @code{void __MBTOHE (uw1 *, uw1)}
12503 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12504 @tab @code{MBTOHE @var{a},@var{b}}
12505 @item @code{void __MCLRACC (acc)}
12506 @tab @code{__MCLRACC (@var{a})}
12507 @tab @code{MCLRACC @var{a}}
12508 @item @code{void __MCLRACCA (void)}
12509 @tab @code{__MCLRACCA ()}
12510 @tab @code{MCLRACCA}
12511 @item @code{uw1 __Mcop1 (uw1, uw1)}
12512 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12513 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12514 @item @code{uw1 __Mcop2 (uw1, uw1)}
12515 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12516 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12517 @item @code{uw1 __MCPLHI (uw2, const)}
12518 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12519 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12520 @item @code{uw1 __MCPLI (uw2, const)}
12521 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12522 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12523 @item @code{void __MCPXIS (acc, sw1, sw1)}
12524 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12525 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12526 @item @code{void __MCPXIU (acc, uw1, uw1)}
12527 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12528 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12529 @item @code{void __MCPXRS (acc, sw1, sw1)}
12530 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12531 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12532 @item @code{void __MCPXRU (acc, uw1, uw1)}
12533 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12534 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12535 @item @code{uw1 __MCUT (acc, uw1)}
12536 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12537 @tab @code{MCUT @var{a},@var{b},@var{c}}
12538 @item @code{uw1 __MCUTSS (acc, sw1)}
12539 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12540 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12541 @item @code{void __MDADDACCS (acc, acc)}
12542 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12543 @tab @code{MDADDACCS @var{a},@var{b}}
12544 @item @code{void __MDASACCS (acc, acc)}
12545 @tab @code{__MDASACCS (@var{b}, @var{a})}
12546 @tab @code{MDASACCS @var{a},@var{b}}
12547 @item @code{uw2 __MDCUTSSI (acc, const)}
12548 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12549 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12550 @item @code{uw2 __MDPACKH (uw2, uw2)}
12551 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12552 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12553 @item @code{uw2 __MDROTLI (uw2, const)}
12554 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12555 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12556 @item @code{void __MDSUBACCS (acc, acc)}
12557 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12558 @tab @code{MDSUBACCS @var{a},@var{b}}
12559 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12560 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12561 @tab @code{MDUNPACKH @var{a},@var{b}}
12562 @item @code{uw2 __MEXPDHD (uw1, const)}
12563 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12564 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12565 @item @code{uw1 __MEXPDHW (uw1, const)}
12566 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12567 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12568 @item @code{uw1 __MHDSETH (uw1, const)}
12569 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12570 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12571 @item @code{sw1 __MHDSETS (const)}
12572 @tab @code{@var{b} = __MHDSETS (@var{a})}
12573 @tab @code{MHDSETS #@var{a},@var{b}}
12574 @item @code{uw1 __MHSETHIH (uw1, const)}
12575 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12576 @tab @code{MHSETHIH #@var{a},@var{b}}
12577 @item @code{sw1 __MHSETHIS (sw1, const)}
12578 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12579 @tab @code{MHSETHIS #@var{a},@var{b}}
12580 @item @code{uw1 __MHSETLOH (uw1, const)}
12581 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12582 @tab @code{MHSETLOH #@var{a},@var{b}}
12583 @item @code{sw1 __MHSETLOS (sw1, const)}
12584 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12585 @tab @code{MHSETLOS #@var{a},@var{b}}
12586 @item @code{uw1 __MHTOB (uw2)}
12587 @tab @code{@var{b} = __MHTOB (@var{a})}
12588 @tab @code{MHTOB @var{a},@var{b}}
12589 @item @code{void __MMACHS (acc, sw1, sw1)}
12590 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12591 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12592 @item @code{void __MMACHU (acc, uw1, uw1)}
12593 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12594 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12595 @item @code{void __MMRDHS (acc, sw1, sw1)}
12596 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12597 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12598 @item @code{void __MMRDHU (acc, uw1, uw1)}
12599 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12600 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12601 @item @code{void __MMULHS (acc, sw1, sw1)}
12602 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12603 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12604 @item @code{void __MMULHU (acc, uw1, uw1)}
12605 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12606 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12607 @item @code{void __MMULXHS (acc, sw1, sw1)}
12608 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12609 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12610 @item @code{void __MMULXHU (acc, uw1, uw1)}
12611 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12612 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12613 @item @code{uw1 __MNOT (uw1)}
12614 @tab @code{@var{b} = __MNOT (@var{a})}
12615 @tab @code{MNOT @var{a},@var{b}}
12616 @item @code{uw1 __MOR (uw1, uw1)}
12617 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12618 @tab @code{MOR @var{a},@var{b},@var{c}}
12619 @item @code{uw1 __MPACKH (uh, uh)}
12620 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12621 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12622 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12623 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12624 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12625 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12626 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12627 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12628 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12629 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12630 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12631 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12632 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12633 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12634 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12635 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12636 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12637 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12638 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12639 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12640 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12641 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12642 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12643 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12644 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12645 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12646 @item @code{void __MQMACHS (acc, sw2, sw2)}
12647 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12648 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12649 @item @code{void __MQMACHU (acc, uw2, uw2)}
12650 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12651 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12652 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12653 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12654 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12655 @item @code{void __MQMULHS (acc, sw2, sw2)}
12656 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12657 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12658 @item @code{void __MQMULHU (acc, uw2, uw2)}
12659 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12660 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12661 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12662 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12663 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12664 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12665 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12666 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12667 @item @code{sw2 __MQSATHS (sw2, sw2)}
12668 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12669 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12670 @item @code{uw2 __MQSLLHI (uw2, int)}
12671 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12672 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12673 @item @code{sw2 __MQSRAHI (sw2, int)}
12674 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12675 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12676 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12677 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12678 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12679 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12680 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12681 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12682 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12683 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12684 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12685 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12686 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12687 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12688 @item @code{uw1 __MRDACC (acc)}
12689 @tab @code{@var{b} = __MRDACC (@var{a})}
12690 @tab @code{MRDACC @var{a},@var{b}}
12691 @item @code{uw1 __MRDACCG (acc)}
12692 @tab @code{@var{b} = __MRDACCG (@var{a})}
12693 @tab @code{MRDACCG @var{a},@var{b}}
12694 @item @code{uw1 __MROTLI (uw1, const)}
12695 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12696 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12697 @item @code{uw1 __MROTRI (uw1, const)}
12698 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12699 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12700 @item @code{sw1 __MSATHS (sw1, sw1)}
12701 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12702 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12703 @item @code{uw1 __MSATHU (uw1, uw1)}
12704 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12705 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12706 @item @code{uw1 __MSLLHI (uw1, const)}
12707 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12708 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12709 @item @code{sw1 __MSRAHI (sw1, const)}
12710 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12711 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12712 @item @code{uw1 __MSRLHI (uw1, const)}
12713 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12714 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12715 @item @code{void __MSUBACCS (acc, acc)}
12716 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12717 @tab @code{MSUBACCS @var{a},@var{b}}
12718 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12719 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12720 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12721 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12722 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12723 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12724 @item @code{void __MTRAP (void)}
12725 @tab @code{__MTRAP ()}
12726 @tab @code{MTRAP}
12727 @item @code{uw2 __MUNPACKH (uw1)}
12728 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12729 @tab @code{MUNPACKH @var{a},@var{b}}
12730 @item @code{uw1 __MWCUT (uw2, uw1)}
12731 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12732 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12733 @item @code{void __MWTACC (acc, uw1)}
12734 @tab @code{__MWTACC (@var{b}, @var{a})}
12735 @tab @code{MWTACC @var{a},@var{b}}
12736 @item @code{void __MWTACCG (acc, uw1)}
12737 @tab @code{__MWTACCG (@var{b}, @var{a})}
12738 @tab @code{MWTACCG @var{a},@var{b}}
12739 @item @code{uw1 __MXOR (uw1, uw1)}
12740 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12741 @tab @code{MXOR @var{a},@var{b},@var{c}}
12742 @end multitable
12743
12744 @node Raw read/write Functions
12745 @subsubsection Raw Read/Write Functions
12746
12747 This sections describes built-in functions related to read and write
12748 instructions to access memory. These functions generate
12749 @code{membar} instructions to flush the I/O load and stores where
12750 appropriate, as described in Fujitsu's manual described above.
12751
12752 @table @code
12753
12754 @item unsigned char __builtin_read8 (void *@var{data})
12755 @item unsigned short __builtin_read16 (void *@var{data})
12756 @item unsigned long __builtin_read32 (void *@var{data})
12757 @item unsigned long long __builtin_read64 (void *@var{data})
12758
12759 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12760 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12761 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12762 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12763 @end table
12764
12765 @node Other Built-in Functions
12766 @subsubsection Other Built-in Functions
12767
12768 This section describes built-in functions that are not named after
12769 a specific FR-V instruction.
12770
12771 @table @code
12772 @item sw2 __IACCreadll (iacc @var{reg})
12773 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12774 for future expansion and must be 0.
12775
12776 @item sw1 __IACCreadl (iacc @var{reg})
12777 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12778 Other values of @var{reg} are rejected as invalid.
12779
12780 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12781 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12782 is reserved for future expansion and must be 0.
12783
12784 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12785 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12786 is 1. Other values of @var{reg} are rejected as invalid.
12787
12788 @item void __data_prefetch0 (const void *@var{x})
12789 Use the @code{dcpl} instruction to load the contents of address @var{x}
12790 into the data cache.
12791
12792 @item void __data_prefetch (const void *@var{x})
12793 Use the @code{nldub} instruction to load the contents of address @var{x}
12794 into the data cache. The instruction is issued in slot I1@.
12795 @end table
12796
12797 @node MIPS DSP Built-in Functions
12798 @subsection MIPS DSP Built-in Functions
12799
12800 The MIPS DSP Application-Specific Extension (ASE) includes new
12801 instructions that are designed to improve the performance of DSP and
12802 media applications. It provides instructions that operate on packed
12803 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12804
12805 GCC supports MIPS DSP operations using both the generic
12806 vector extensions (@pxref{Vector Extensions}) and a collection of
12807 MIPS-specific built-in functions. Both kinds of support are
12808 enabled by the @option{-mdsp} command-line option.
12809
12810 Revision 2 of the ASE was introduced in the second half of 2006.
12811 This revision adds extra instructions to the original ASE, but is
12812 otherwise backwards-compatible with it. You can select revision 2
12813 using the command-line option @option{-mdspr2}; this option implies
12814 @option{-mdsp}.
12815
12816 The SCOUNT and POS bits of the DSP control register are global. The
12817 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12818 POS bits. During optimization, the compiler does not delete these
12819 instructions and it does not delete calls to functions containing
12820 these instructions.
12821
12822 At present, GCC only provides support for operations on 32-bit
12823 vectors. The vector type associated with 8-bit integer data is
12824 usually called @code{v4i8}, the vector type associated with Q7
12825 is usually called @code{v4q7}, the vector type associated with 16-bit
12826 integer data is usually called @code{v2i16}, and the vector type
12827 associated with Q15 is usually called @code{v2q15}. They can be
12828 defined in C as follows:
12829
12830 @smallexample
12831 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12832 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12833 typedef short v2i16 __attribute__ ((vector_size(4)));
12834 typedef short v2q15 __attribute__ ((vector_size(4)));
12835 @end smallexample
12836
12837 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12838 initialized in the same way as aggregates. For example:
12839
12840 @smallexample
12841 v4i8 a = @{1, 2, 3, 4@};
12842 v4i8 b;
12843 b = (v4i8) @{5, 6, 7, 8@};
12844
12845 v2q15 c = @{0x0fcb, 0x3a75@};
12846 v2q15 d;
12847 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12848 @end smallexample
12849
12850 @emph{Note:} The CPU's endianness determines the order in which values
12851 are packed. On little-endian targets, the first value is the least
12852 significant and the last value is the most significant. The opposite
12853 order applies to big-endian targets. For example, the code above
12854 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12855 and @code{4} on big-endian targets.
12856
12857 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12858 representation. As shown in this example, the integer representation
12859 of a Q7 value can be obtained by multiplying the fractional value by
12860 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12861 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12862 @code{0x1.0p31}.
12863
12864 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12865 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12866 and @code{c} and @code{d} are @code{v2q15} values.
12867
12868 @multitable @columnfractions .50 .50
12869 @item C code @tab MIPS instruction
12870 @item @code{a + b} @tab @code{addu.qb}
12871 @item @code{c + d} @tab @code{addq.ph}
12872 @item @code{a - b} @tab @code{subu.qb}
12873 @item @code{c - d} @tab @code{subq.ph}
12874 @end multitable
12875
12876 The table below lists the @code{v2i16} operation for which
12877 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12878 @code{v2i16} values.
12879
12880 @multitable @columnfractions .50 .50
12881 @item C code @tab MIPS instruction
12882 @item @code{e * f} @tab @code{mul.ph}
12883 @end multitable
12884
12885 It is easier to describe the DSP built-in functions if we first define
12886 the following types:
12887
12888 @smallexample
12889 typedef int q31;
12890 typedef int i32;
12891 typedef unsigned int ui32;
12892 typedef long long a64;
12893 @end smallexample
12894
12895 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12896 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12897 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12898 @code{long long}, but we use @code{a64} to indicate values that are
12899 placed in one of the four DSP accumulators (@code{$ac0},
12900 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12901
12902 Also, some built-in functions prefer or require immediate numbers as
12903 parameters, because the corresponding DSP instructions accept both immediate
12904 numbers and register operands, or accept immediate numbers only. The
12905 immediate parameters are listed as follows.
12906
12907 @smallexample
12908 imm0_3: 0 to 3.
12909 imm0_7: 0 to 7.
12910 imm0_15: 0 to 15.
12911 imm0_31: 0 to 31.
12912 imm0_63: 0 to 63.
12913 imm0_255: 0 to 255.
12914 imm_n32_31: -32 to 31.
12915 imm_n512_511: -512 to 511.
12916 @end smallexample
12917
12918 The following built-in functions map directly to a particular MIPS DSP
12919 instruction. Please refer to the architecture specification
12920 for details on what each instruction does.
12921
12922 @smallexample
12923 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12924 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12925 q31 __builtin_mips_addq_s_w (q31, q31)
12926 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12927 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12928 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12929 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12930 q31 __builtin_mips_subq_s_w (q31, q31)
12931 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12932 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12933 i32 __builtin_mips_addsc (i32, i32)
12934 i32 __builtin_mips_addwc (i32, i32)
12935 i32 __builtin_mips_modsub (i32, i32)
12936 i32 __builtin_mips_raddu_w_qb (v4i8)
12937 v2q15 __builtin_mips_absq_s_ph (v2q15)
12938 q31 __builtin_mips_absq_s_w (q31)
12939 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12940 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12941 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12942 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12943 q31 __builtin_mips_preceq_w_phl (v2q15)
12944 q31 __builtin_mips_preceq_w_phr (v2q15)
12945 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12946 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12947 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12948 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12949 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12950 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12951 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12952 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12953 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12954 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12955 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12956 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12957 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12958 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12959 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12960 q31 __builtin_mips_shll_s_w (q31, i32)
12961 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12962 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12963 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12964 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12965 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12966 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12967 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12968 q31 __builtin_mips_shra_r_w (q31, i32)
12969 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12970 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12971 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12972 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12973 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12974 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12975 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12976 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12977 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12978 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12979 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12980 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12981 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12982 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12983 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12984 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12985 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12986 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12987 i32 __builtin_mips_bitrev (i32)
12988 i32 __builtin_mips_insv (i32, i32)
12989 v4i8 __builtin_mips_repl_qb (imm0_255)
12990 v4i8 __builtin_mips_repl_qb (i32)
12991 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12992 v2q15 __builtin_mips_repl_ph (i32)
12993 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12994 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12995 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12996 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12997 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12998 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12999 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13000 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13001 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13002 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13003 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13004 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13005 i32 __builtin_mips_extr_w (a64, imm0_31)
13006 i32 __builtin_mips_extr_w (a64, i32)
13007 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13008 i32 __builtin_mips_extr_s_h (a64, i32)
13009 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13010 i32 __builtin_mips_extr_rs_w (a64, i32)
13011 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13012 i32 __builtin_mips_extr_r_w (a64, i32)
13013 i32 __builtin_mips_extp (a64, imm0_31)
13014 i32 __builtin_mips_extp (a64, i32)
13015 i32 __builtin_mips_extpdp (a64, imm0_31)
13016 i32 __builtin_mips_extpdp (a64, i32)
13017 a64 __builtin_mips_shilo (a64, imm_n32_31)
13018 a64 __builtin_mips_shilo (a64, i32)
13019 a64 __builtin_mips_mthlip (a64, i32)
13020 void __builtin_mips_wrdsp (i32, imm0_63)
13021 i32 __builtin_mips_rddsp (imm0_63)
13022 i32 __builtin_mips_lbux (void *, i32)
13023 i32 __builtin_mips_lhx (void *, i32)
13024 i32 __builtin_mips_lwx (void *, i32)
13025 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13026 i32 __builtin_mips_bposge32 (void)
13027 a64 __builtin_mips_madd (a64, i32, i32);
13028 a64 __builtin_mips_maddu (a64, ui32, ui32);
13029 a64 __builtin_mips_msub (a64, i32, i32);
13030 a64 __builtin_mips_msubu (a64, ui32, ui32);
13031 a64 __builtin_mips_mult (i32, i32);
13032 a64 __builtin_mips_multu (ui32, ui32);
13033 @end smallexample
13034
13035 The following built-in functions map directly to a particular MIPS DSP REV 2
13036 instruction. Please refer to the architecture specification
13037 for details on what each instruction does.
13038
13039 @smallexample
13040 v4q7 __builtin_mips_absq_s_qb (v4q7);
13041 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13042 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13043 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13044 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13045 i32 __builtin_mips_append (i32, i32, imm0_31);
13046 i32 __builtin_mips_balign (i32, i32, imm0_3);
13047 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13048 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13049 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13050 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13051 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13052 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13053 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13054 q31 __builtin_mips_mulq_rs_w (q31, q31);
13055 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13056 q31 __builtin_mips_mulq_s_w (q31, q31);
13057 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13058 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13059 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13060 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13061 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13062 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13063 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13064 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13065 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13066 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13067 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13068 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13069 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13070 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13071 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13072 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13073 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13074 q31 __builtin_mips_addqh_w (q31, q31);
13075 q31 __builtin_mips_addqh_r_w (q31, q31);
13076 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13077 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13078 q31 __builtin_mips_subqh_w (q31, q31);
13079 q31 __builtin_mips_subqh_r_w (q31, q31);
13080 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13081 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13082 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13083 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13084 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13085 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13086 @end smallexample
13087
13088
13089 @node MIPS Paired-Single Support
13090 @subsection MIPS Paired-Single Support
13091
13092 The MIPS64 architecture includes a number of instructions that
13093 operate on pairs of single-precision floating-point values.
13094 Each pair is packed into a 64-bit floating-point register,
13095 with one element being designated the ``upper half'' and
13096 the other being designated the ``lower half''.
13097
13098 GCC supports paired-single operations using both the generic
13099 vector extensions (@pxref{Vector Extensions}) and a collection of
13100 MIPS-specific built-in functions. Both kinds of support are
13101 enabled by the @option{-mpaired-single} command-line option.
13102
13103 The vector type associated with paired-single values is usually
13104 called @code{v2sf}. It can be defined in C as follows:
13105
13106 @smallexample
13107 typedef float v2sf __attribute__ ((vector_size (8)));
13108 @end smallexample
13109
13110 @code{v2sf} values are initialized in the same way as aggregates.
13111 For example:
13112
13113 @smallexample
13114 v2sf a = @{1.5, 9.1@};
13115 v2sf b;
13116 float e, f;
13117 b = (v2sf) @{e, f@};
13118 @end smallexample
13119
13120 @emph{Note:} The CPU's endianness determines which value is stored in
13121 the upper half of a register and which value is stored in the lower half.
13122 On little-endian targets, the first value is the lower one and the second
13123 value is the upper one. The opposite order applies to big-endian targets.
13124 For example, the code above sets the lower half of @code{a} to
13125 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13126
13127 @node MIPS Loongson Built-in Functions
13128 @subsection MIPS Loongson Built-in Functions
13129
13130 GCC provides intrinsics to access the SIMD instructions provided by the
13131 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13132 available after inclusion of the @code{loongson.h} header file,
13133 operate on the following 64-bit vector types:
13134
13135 @itemize
13136 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13137 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13138 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13139 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13140 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13141 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13142 @end itemize
13143
13144 The intrinsics provided are listed below; each is named after the
13145 machine instruction to which it corresponds, with suffixes added as
13146 appropriate to distinguish intrinsics that expand to the same machine
13147 instruction yet have different argument types. Refer to the architecture
13148 documentation for a description of the functionality of each
13149 instruction.
13150
13151 @smallexample
13152 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13153 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13154 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13155 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13156 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13157 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13158 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13159 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13160 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13161 uint64_t paddd_u (uint64_t s, uint64_t t);
13162 int64_t paddd_s (int64_t s, int64_t t);
13163 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13164 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13165 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13166 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13167 uint64_t pandn_ud (uint64_t s, uint64_t t);
13168 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13169 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13170 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13171 int64_t pandn_sd (int64_t s, int64_t t);
13172 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13173 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13174 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13175 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13176 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13177 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13178 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13179 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13180 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13181 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13182 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13183 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13184 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13185 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13186 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13187 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13188 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13189 uint16x4_t pextrh_u (uint16x4_t s, int field);
13190 int16x4_t pextrh_s (int16x4_t s, int field);
13191 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13192 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13193 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13194 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13195 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13196 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13197 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13198 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13199 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13200 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13201 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13202 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13203 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13204 uint8x8_t pmovmskb_u (uint8x8_t s);
13205 int8x8_t pmovmskb_s (int8x8_t s);
13206 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13207 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13208 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13209 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13210 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13211 uint16x4_t biadd (uint8x8_t s);
13212 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13213 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13214 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13215 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13216 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13217 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13218 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13219 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13220 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13221 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13222 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13223 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13224 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13225 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13226 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13227 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13228 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13229 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13230 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13231 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13232 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13233 uint64_t psubd_u (uint64_t s, uint64_t t);
13234 int64_t psubd_s (int64_t s, int64_t t);
13235 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13236 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13237 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13238 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13239 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13240 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13241 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13242 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13243 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13244 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13245 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13246 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13247 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13248 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13249 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13250 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13251 @end smallexample
13252
13253 @menu
13254 * Paired-Single Arithmetic::
13255 * Paired-Single Built-in Functions::
13256 * MIPS-3D Built-in Functions::
13257 @end menu
13258
13259 @node Paired-Single Arithmetic
13260 @subsubsection Paired-Single Arithmetic
13261
13262 The table below lists the @code{v2sf} operations for which hardware
13263 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13264 values and @code{x} is an integral value.
13265
13266 @multitable @columnfractions .50 .50
13267 @item C code @tab MIPS instruction
13268 @item @code{a + b} @tab @code{add.ps}
13269 @item @code{a - b} @tab @code{sub.ps}
13270 @item @code{-a} @tab @code{neg.ps}
13271 @item @code{a * b} @tab @code{mul.ps}
13272 @item @code{a * b + c} @tab @code{madd.ps}
13273 @item @code{a * b - c} @tab @code{msub.ps}
13274 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13275 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13276 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13277 @end multitable
13278
13279 Note that the multiply-accumulate instructions can be disabled
13280 using the command-line option @code{-mno-fused-madd}.
13281
13282 @node Paired-Single Built-in Functions
13283 @subsubsection Paired-Single Built-in Functions
13284
13285 The following paired-single functions map directly to a particular
13286 MIPS instruction. Please refer to the architecture specification
13287 for details on what each instruction does.
13288
13289 @table @code
13290 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13291 Pair lower lower (@code{pll.ps}).
13292
13293 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13294 Pair upper lower (@code{pul.ps}).
13295
13296 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13297 Pair lower upper (@code{plu.ps}).
13298
13299 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13300 Pair upper upper (@code{puu.ps}).
13301
13302 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13303 Convert pair to paired single (@code{cvt.ps.s}).
13304
13305 @item float __builtin_mips_cvt_s_pl (v2sf)
13306 Convert pair lower to single (@code{cvt.s.pl}).
13307
13308 @item float __builtin_mips_cvt_s_pu (v2sf)
13309 Convert pair upper to single (@code{cvt.s.pu}).
13310
13311 @item v2sf __builtin_mips_abs_ps (v2sf)
13312 Absolute value (@code{abs.ps}).
13313
13314 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13315 Align variable (@code{alnv.ps}).
13316
13317 @emph{Note:} The value of the third parameter must be 0 or 4
13318 modulo 8, otherwise the result is unpredictable. Please read the
13319 instruction description for details.
13320 @end table
13321
13322 The following multi-instruction functions are also available.
13323 In each case, @var{cond} can be any of the 16 floating-point conditions:
13324 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13325 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13326 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13327
13328 @table @code
13329 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13330 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13331 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13332 @code{movt.ps}/@code{movf.ps}).
13333
13334 The @code{movt} functions return the value @var{x} computed by:
13335
13336 @smallexample
13337 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13338 mov.ps @var{x},@var{c}
13339 movt.ps @var{x},@var{d},@var{cc}
13340 @end smallexample
13341
13342 The @code{movf} functions are similar but use @code{movf.ps} instead
13343 of @code{movt.ps}.
13344
13345 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13346 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13347 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13348 @code{bc1t}/@code{bc1f}).
13349
13350 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13351 and return either the upper or lower half of the result. For example:
13352
13353 @smallexample
13354 v2sf a, b;
13355 if (__builtin_mips_upper_c_eq_ps (a, b))
13356 upper_halves_are_equal ();
13357 else
13358 upper_halves_are_unequal ();
13359
13360 if (__builtin_mips_lower_c_eq_ps (a, b))
13361 lower_halves_are_equal ();
13362 else
13363 lower_halves_are_unequal ();
13364 @end smallexample
13365 @end table
13366
13367 @node MIPS-3D Built-in Functions
13368 @subsubsection MIPS-3D Built-in Functions
13369
13370 The MIPS-3D Application-Specific Extension (ASE) includes additional
13371 paired-single instructions that are designed to improve the performance
13372 of 3D graphics operations. Support for these instructions is controlled
13373 by the @option{-mips3d} command-line option.
13374
13375 The functions listed below map directly to a particular MIPS-3D
13376 instruction. Please refer to the architecture specification for
13377 more details on what each instruction does.
13378
13379 @table @code
13380 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13381 Reduction add (@code{addr.ps}).
13382
13383 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13384 Reduction multiply (@code{mulr.ps}).
13385
13386 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13387 Convert paired single to paired word (@code{cvt.pw.ps}).
13388
13389 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13390 Convert paired word to paired single (@code{cvt.ps.pw}).
13391
13392 @item float __builtin_mips_recip1_s (float)
13393 @itemx double __builtin_mips_recip1_d (double)
13394 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13395 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13396
13397 @item float __builtin_mips_recip2_s (float, float)
13398 @itemx double __builtin_mips_recip2_d (double, double)
13399 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13400 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13401
13402 @item float __builtin_mips_rsqrt1_s (float)
13403 @itemx double __builtin_mips_rsqrt1_d (double)
13404 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13405 Reduced-precision reciprocal square root (sequence step 1)
13406 (@code{rsqrt1.@var{fmt}}).
13407
13408 @item float __builtin_mips_rsqrt2_s (float, float)
13409 @itemx double __builtin_mips_rsqrt2_d (double, double)
13410 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13411 Reduced-precision reciprocal square root (sequence step 2)
13412 (@code{rsqrt2.@var{fmt}}).
13413 @end table
13414
13415 The following multi-instruction functions are also available.
13416 In each case, @var{cond} can be any of the 16 floating-point conditions:
13417 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13418 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13419 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13420
13421 @table @code
13422 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13423 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13424 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13425 @code{bc1t}/@code{bc1f}).
13426
13427 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13428 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13429 For example:
13430
13431 @smallexample
13432 float a, b;
13433 if (__builtin_mips_cabs_eq_s (a, b))
13434 true ();
13435 else
13436 false ();
13437 @end smallexample
13438
13439 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13440 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13441 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13442 @code{bc1t}/@code{bc1f}).
13443
13444 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13445 and return either the upper or lower half of the result. For example:
13446
13447 @smallexample
13448 v2sf a, b;
13449 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13450 upper_halves_are_equal ();
13451 else
13452 upper_halves_are_unequal ();
13453
13454 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13455 lower_halves_are_equal ();
13456 else
13457 lower_halves_are_unequal ();
13458 @end smallexample
13459
13460 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13461 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13462 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13463 @code{movt.ps}/@code{movf.ps}).
13464
13465 The @code{movt} functions return the value @var{x} computed by:
13466
13467 @smallexample
13468 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13469 mov.ps @var{x},@var{c}
13470 movt.ps @var{x},@var{d},@var{cc}
13471 @end smallexample
13472
13473 The @code{movf} functions are similar but use @code{movf.ps} instead
13474 of @code{movt.ps}.
13475
13476 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13477 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13478 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13479 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13480 Comparison of two paired-single values
13481 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13482 @code{bc1any2t}/@code{bc1any2f}).
13483
13484 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13485 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13486 result is true and the @code{all} forms return true if both results are true.
13487 For example:
13488
13489 @smallexample
13490 v2sf a, b;
13491 if (__builtin_mips_any_c_eq_ps (a, b))
13492 one_is_true ();
13493 else
13494 both_are_false ();
13495
13496 if (__builtin_mips_all_c_eq_ps (a, b))
13497 both_are_true ();
13498 else
13499 one_is_false ();
13500 @end smallexample
13501
13502 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13503 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13504 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13505 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13506 Comparison of four paired-single values
13507 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13508 @code{bc1any4t}/@code{bc1any4f}).
13509
13510 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13511 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13512 The @code{any} forms return true if any of the four results are true
13513 and the @code{all} forms return true if all four results are true.
13514 For example:
13515
13516 @smallexample
13517 v2sf a, b, c, d;
13518 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13519 some_are_true ();
13520 else
13521 all_are_false ();
13522
13523 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13524 all_are_true ();
13525 else
13526 some_are_false ();
13527 @end smallexample
13528 @end table
13529
13530 @node Other MIPS Built-in Functions
13531 @subsection Other MIPS Built-in Functions
13532
13533 GCC provides other MIPS-specific built-in functions:
13534
13535 @table @code
13536 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13537 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13538 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13539 when this function is available.
13540
13541 @item unsigned int __builtin_mips_get_fcsr (void)
13542 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13543 Get and set the contents of the floating-point control and status register
13544 (FPU control register 31). These functions are only available in hard-float
13545 code but can be called in both MIPS16 and non-MIPS16 contexts.
13546
13547 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13548 register except the condition codes, which GCC assumes are preserved.
13549 @end table
13550
13551 @node MSP430 Built-in Functions
13552 @subsection MSP430 Built-in Functions
13553
13554 GCC provides a couple of special builtin functions to aid in the
13555 writing of interrupt handlers in C.
13556
13557 @table @code
13558 @item __bic_SR_register_on_exit (int @var{mask})
13559 This clears the indicated bits in the saved copy of the status register
13560 currently residing on the stack. This only works inside interrupt
13561 handlers and the changes to the status register will only take affect
13562 once the handler returns.
13563
13564 @item __bis_SR_register_on_exit (int @var{mask})
13565 This sets the indicated bits in the saved copy of the status register
13566 currently residing on the stack. This only works inside interrupt
13567 handlers and the changes to the status register will only take affect
13568 once the handler returns.
13569
13570 @item __delay_cycles (long long @var{cycles})
13571 This inserts an instruction sequence that takes exactly @var{cycles}
13572 cycles (between 0 and about 17E9) to complete. The inserted sequence
13573 may use jumps, loops, or no-ops, and does not interfere with any other
13574 instructions. Note that @var{cycles} must be a compile-time constant
13575 integer - that is, you must pass a number, not a variable that may be
13576 optimized to a constant later. The number of cycles delayed by this
13577 builtin is exact.
13578 @end table
13579
13580 @node NDS32 Built-in Functions
13581 @subsection NDS32 Built-in Functions
13582
13583 These built-in functions are available for the NDS32 target:
13584
13585 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13586 Insert an ISYNC instruction into the instruction stream where
13587 @var{addr} is an instruction address for serialization.
13588 @end deftypefn
13589
13590 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13591 Insert an ISB instruction into the instruction stream.
13592 @end deftypefn
13593
13594 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13595 Return the content of a system register which is mapped by @var{sr}.
13596 @end deftypefn
13597
13598 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13599 Return the content of a user space register which is mapped by @var{usr}.
13600 @end deftypefn
13601
13602 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13603 Move the @var{value} to a system register which is mapped by @var{sr}.
13604 @end deftypefn
13605
13606 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13607 Move the @var{value} to a user space register which is mapped by @var{usr}.
13608 @end deftypefn
13609
13610 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13611 Enable global interrupt.
13612 @end deftypefn
13613
13614 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13615 Disable global interrupt.
13616 @end deftypefn
13617
13618 @node picoChip Built-in Functions
13619 @subsection picoChip Built-in Functions
13620
13621 GCC provides an interface to selected machine instructions from the
13622 picoChip instruction set.
13623
13624 @table @code
13625 @item int __builtin_sbc (int @var{value})
13626 Sign bit count. Return the number of consecutive bits in @var{value}
13627 that have the same value as the sign bit. The result is the number of
13628 leading sign bits minus one, giving the number of redundant sign bits in
13629 @var{value}.
13630
13631 @item int __builtin_byteswap (int @var{value})
13632 Byte swap. Return the result of swapping the upper and lower bytes of
13633 @var{value}.
13634
13635 @item int __builtin_brev (int @var{value})
13636 Bit reversal. Return the result of reversing the bits in
13637 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13638 and so on.
13639
13640 @item int __builtin_adds (int @var{x}, int @var{y})
13641 Saturating addition. Return the result of adding @var{x} and @var{y},
13642 storing the value 32767 if the result overflows.
13643
13644 @item int __builtin_subs (int @var{x}, int @var{y})
13645 Saturating subtraction. Return the result of subtracting @var{y} from
13646 @var{x}, storing the value @minus{}32768 if the result overflows.
13647
13648 @item void __builtin_halt (void)
13649 Halt. The processor stops execution. This built-in is useful for
13650 implementing assertions.
13651
13652 @end table
13653
13654 @node PowerPC Built-in Functions
13655 @subsection PowerPC Built-in Functions
13656
13657 The following built-in functions are always available and can be used to
13658 check the PowerPC target platform type:
13659
13660 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
13661 This function is a @code{nop} on the PowerPC platform and is included solely
13662 to maintain API compatibility with the x86 builtins.
13663 @end deftypefn
13664
13665 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
13666 This function returns a value of @code{1} if the run-time CPU is of type
13667 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
13668 detected:
13669
13670 @table @samp
13671 @item power9
13672 IBM POWER9 Server CPU.
13673 @item power8
13674 IBM POWER8 Server CPU.
13675 @item power7
13676 IBM POWER7 Server CPU.
13677 @item power6x
13678 IBM POWER6 Server CPU (RAW mode).
13679 @item power6
13680 IBM POWER6 Server CPU (Architected mode).
13681 @item power5+
13682 IBM POWER5+ Server CPU.
13683 @item power5
13684 IBM POWER5 Server CPU.
13685 @item ppc970
13686 IBM 970 Server CPU (ie, Apple G5).
13687 @item power4
13688 IBM POWER4 Server CPU.
13689 @item ppca2
13690 IBM A2 64-bit Embedded CPU
13691 @item ppc476
13692 IBM PowerPC 476FP 32-bit Embedded CPU.
13693 @item ppc464
13694 IBM PowerPC 464 32-bit Embedded CPU.
13695 @item ppc440
13696 PowerPC 440 32-bit Embedded CPU.
13697 @item ppc405
13698 PowerPC 405 32-bit Embedded CPU.
13699 @item ppc-cell-be
13700 IBM PowerPC Cell Broadband Engine Architecture CPU.
13701 @end table
13702
13703 Here is an example:
13704 @smallexample
13705 if (__builtin_cpu_is ("power8"))
13706 @{
13707 do_power8 (); // POWER8 specific implementation.
13708 @}
13709 else
13710 @{
13711 do_generic (); // Generic implementation.
13712 @}
13713 @end smallexample
13714 @end deftypefn
13715
13716 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
13717 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
13718 feature @var{feature} and returns @code{0} otherwise. The following features can be
13719 detected:
13720
13721 @table @samp
13722 @item 4xxmac
13723 4xx CPU has a Multiply Accumulator.
13724 @item altivec
13725 CPU has a SIMD/Vector Unit.
13726 @item arch_2_05
13727 CPU supports ISA 2.05 (eg, POWER6)
13728 @item arch_2_06
13729 CPU supports ISA 2.06 (eg, POWER7)
13730 @item arch_2_07
13731 CPU supports ISA 2.07 (eg, POWER8)
13732 @item arch_3_00
13733 CPU supports ISA 3.00 (eg, POWER9)
13734 @item archpmu
13735 CPU supports the set of compatible performance monitoring events.
13736 @item booke
13737 CPU supports the Embedded ISA category.
13738 @item cellbe
13739 CPU has a CELL broadband engine.
13740 @item dfp
13741 CPU has a decimal floating point unit.
13742 @item dscr
13743 CPU supports the data stream control register.
13744 @item ebb
13745 CPU supports event base branching.
13746 @item efpdouble
13747 CPU has a SPE double precision floating point unit.
13748 @item efpsingle
13749 CPU has a SPE single precision floating point unit.
13750 @item fpu
13751 CPU has a floating point unit.
13752 @item htm
13753 CPU has hardware transaction memory instructions.
13754 @item htm-nosc
13755 Kernel aborts hardware transactions when a syscall is made.
13756 @item ic_snoop
13757 CPU supports icache snooping capabilities.
13758 @item ieee128
13759 CPU supports 128-bit IEEE binary floating point instructions.
13760 @item isel
13761 CPU supports the integer select instruction.
13762 @item mmu
13763 CPU has a memory management unit.
13764 @item notb
13765 CPU does not have a timebase (eg, 601 and 403gx).
13766 @item pa6t
13767 CPU supports the PA Semi 6T CORE ISA.
13768 @item power4
13769 CPU supports ISA 2.00 (eg, POWER4)
13770 @item power5
13771 CPU supports ISA 2.02 (eg, POWER5)
13772 @item power5+
13773 CPU supports ISA 2.03 (eg, POWER5+)
13774 @item power6x
13775 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
13776 @item ppc32
13777 CPU supports 32-bit mode execution.
13778 @item ppc601
13779 CPU supports the old POWER ISA (eg, 601)
13780 @item ppc64
13781 CPU supports 64-bit mode execution.
13782 @item ppcle
13783 CPU supports a little-endian mode that uses address swizzling.
13784 @item smt
13785 CPU support simultaneous multi-threading.
13786 @item spe
13787 CPU has a signal processing extension unit.
13788 @item tar
13789 CPU supports the target address register.
13790 @item true_le
13791 CPU supports true little-endian mode.
13792 @item ucache
13793 CPU has unified I/D cache.
13794 @item vcrypto
13795 CPU supports the vector cryptography instructions.
13796 @item vsx
13797 CPU supports the vector-scalar extension.
13798 @end table
13799
13800 Here is an example:
13801 @smallexample
13802 if (__builtin_cpu_supports ("fpu"))
13803 @{
13804 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
13805 @}
13806 else
13807 @{
13808 dst = __fadd (src1, src2); // Software FP addition function.
13809 @}
13810 @end smallexample
13811 @end deftypefn
13812
13813 These built-in functions are available for the PowerPC family of
13814 processors:
13815 @smallexample
13816 float __builtin_recipdivf (float, float);
13817 float __builtin_rsqrtf (float);
13818 double __builtin_recipdiv (double, double);
13819 double __builtin_rsqrt (double);
13820 uint64_t __builtin_ppc_get_timebase ();
13821 unsigned long __builtin_ppc_mftb ();
13822 double __builtin_unpack_longdouble (long double, int);
13823 long double __builtin_pack_longdouble (double, double);
13824 @end smallexample
13825
13826 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13827 @code{__builtin_rsqrtf} functions generate multiple instructions to
13828 implement the reciprocal sqrt functionality using reciprocal sqrt
13829 estimate instructions.
13830
13831 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13832 functions generate multiple instructions to implement division using
13833 the reciprocal estimate instructions.
13834
13835 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13836 functions generate instructions to read the Time Base Register. The
13837 @code{__builtin_ppc_get_timebase} function may generate multiple
13838 instructions and always returns the 64 bits of the Time Base Register.
13839 The @code{__builtin_ppc_mftb} function always generates one instruction and
13840 returns the Time Base Register value as an unsigned long, throwing away
13841 the most significant word on 32-bit environments.
13842
13843 The following built-in functions are available for the PowerPC family
13844 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13845 or @option{-mpopcntd}):
13846 @smallexample
13847 long __builtin_bpermd (long, long);
13848 int __builtin_divwe (int, int);
13849 int __builtin_divweo (int, int);
13850 unsigned int __builtin_divweu (unsigned int, unsigned int);
13851 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13852 long __builtin_divde (long, long);
13853 long __builtin_divdeo (long, long);
13854 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13855 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13856 unsigned int cdtbcd (unsigned int);
13857 unsigned int cbcdtd (unsigned int);
13858 unsigned int addg6s (unsigned int, unsigned int);
13859 @end smallexample
13860
13861 The @code{__builtin_divde}, @code{__builtin_divdeo},
13862 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13863 64-bit environment support ISA 2.06 or later.
13864
13865 The following built-in functions are available for the PowerPC family
13866 of processors when hardware decimal floating point
13867 (@option{-mhard-dfp}) is available:
13868 @smallexample
13869 _Decimal64 __builtin_dxex (_Decimal64);
13870 _Decimal128 __builtin_dxexq (_Decimal128);
13871 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13872 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13873 _Decimal64 __builtin_denbcd (int, _Decimal64);
13874 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13875 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13876 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13877 _Decimal64 __builtin_dscli (_Decimal64, int);
13878 _Decimal128 __builtin_dscliq (_Decimal128, int);
13879 _Decimal64 __builtin_dscri (_Decimal64, int);
13880 _Decimal128 __builtin_dscriq (_Decimal128, int);
13881 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13882 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13883 @end smallexample
13884
13885 The following built-in functions are available for the PowerPC family
13886 of processors when the Vector Scalar (vsx) instruction set is
13887 available:
13888 @smallexample
13889 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13890 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13891 unsigned long long);
13892 @end smallexample
13893
13894 @node PowerPC AltiVec/VSX Built-in Functions
13895 @subsection PowerPC AltiVec Built-in Functions
13896
13897 GCC provides an interface for the PowerPC family of processors to access
13898 the AltiVec operations described in Motorola's AltiVec Programming
13899 Interface Manual. The interface is made available by including
13900 @code{<altivec.h>} and using @option{-maltivec} and
13901 @option{-mabi=altivec}. The interface supports the following vector
13902 types.
13903
13904 @smallexample
13905 vector unsigned char
13906 vector signed char
13907 vector bool char
13908
13909 vector unsigned short
13910 vector signed short
13911 vector bool short
13912 vector pixel
13913
13914 vector unsigned int
13915 vector signed int
13916 vector bool int
13917 vector float
13918 @end smallexample
13919
13920 If @option{-mvsx} is used the following additional vector types are
13921 implemented.
13922
13923 @smallexample
13924 vector unsigned long
13925 vector signed long
13926 vector double
13927 @end smallexample
13928
13929 The long types are only implemented for 64-bit code generation, and
13930 the long type is only used in the floating point/integer conversion
13931 instructions.
13932
13933 GCC's implementation of the high-level language interface available from
13934 C and C++ code differs from Motorola's documentation in several ways.
13935
13936 @itemize @bullet
13937
13938 @item
13939 A vector constant is a list of constant expressions within curly braces.
13940
13941 @item
13942 A vector initializer requires no cast if the vector constant is of the
13943 same type as the variable it is initializing.
13944
13945 @item
13946 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13947 vector type is the default signedness of the base type. The default
13948 varies depending on the operating system, so a portable program should
13949 always specify the signedness.
13950
13951 @item
13952 Compiling with @option{-maltivec} adds keywords @code{__vector},
13953 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13954 @code{bool}. When compiling ISO C, the context-sensitive substitution
13955 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13956 disabled. To use them, you must include @code{<altivec.h>} instead.
13957
13958 @item
13959 GCC allows using a @code{typedef} name as the type specifier for a
13960 vector type.
13961
13962 @item
13963 For C, overloaded functions are implemented with macros so the following
13964 does not work:
13965
13966 @smallexample
13967 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13968 @end smallexample
13969
13970 @noindent
13971 Since @code{vec_add} is a macro, the vector constant in the example
13972 is treated as four separate arguments. Wrap the entire argument in
13973 parentheses for this to work.
13974 @end itemize
13975
13976 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13977 Internally, GCC uses built-in functions to achieve the functionality in
13978 the aforementioned header file, but they are not supported and are
13979 subject to change without notice.
13980
13981 The following interfaces are supported for the generic and specific
13982 AltiVec operations and the AltiVec predicates. In cases where there
13983 is a direct mapping between generic and specific operations, only the
13984 generic names are shown here, although the specific operations can also
13985 be used.
13986
13987 Arguments that are documented as @code{const int} require literal
13988 integral values within the range required for that operation.
13989
13990 @smallexample
13991 vector signed char vec_abs (vector signed char);
13992 vector signed short vec_abs (vector signed short);
13993 vector signed int vec_abs (vector signed int);
13994 vector float vec_abs (vector float);
13995
13996 vector signed char vec_abss (vector signed char);
13997 vector signed short vec_abss (vector signed short);
13998 vector signed int vec_abss (vector signed int);
13999
14000 vector signed char vec_add (vector bool char, vector signed char);
14001 vector signed char vec_add (vector signed char, vector bool char);
14002 vector signed char vec_add (vector signed char, vector signed char);
14003 vector unsigned char vec_add (vector bool char, vector unsigned char);
14004 vector unsigned char vec_add (vector unsigned char, vector bool char);
14005 vector unsigned char vec_add (vector unsigned char,
14006 vector unsigned char);
14007 vector signed short vec_add (vector bool short, vector signed short);
14008 vector signed short vec_add (vector signed short, vector bool short);
14009 vector signed short vec_add (vector signed short, vector signed short);
14010 vector unsigned short vec_add (vector bool short,
14011 vector unsigned short);
14012 vector unsigned short vec_add (vector unsigned short,
14013 vector bool short);
14014 vector unsigned short vec_add (vector unsigned short,
14015 vector unsigned short);
14016 vector signed int vec_add (vector bool int, vector signed int);
14017 vector signed int vec_add (vector signed int, vector bool int);
14018 vector signed int vec_add (vector signed int, vector signed int);
14019 vector unsigned int vec_add (vector bool int, vector unsigned int);
14020 vector unsigned int vec_add (vector unsigned int, vector bool int);
14021 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14022 vector float vec_add (vector float, vector float);
14023
14024 vector float vec_vaddfp (vector float, vector float);
14025
14026 vector signed int vec_vadduwm (vector bool int, vector signed int);
14027 vector signed int vec_vadduwm (vector signed int, vector bool int);
14028 vector signed int vec_vadduwm (vector signed int, vector signed int);
14029 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14030 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14031 vector unsigned int vec_vadduwm (vector unsigned int,
14032 vector unsigned int);
14033
14034 vector signed short vec_vadduhm (vector bool short,
14035 vector signed short);
14036 vector signed short vec_vadduhm (vector signed short,
14037 vector bool short);
14038 vector signed short vec_vadduhm (vector signed short,
14039 vector signed short);
14040 vector unsigned short vec_vadduhm (vector bool short,
14041 vector unsigned short);
14042 vector unsigned short vec_vadduhm (vector unsigned short,
14043 vector bool short);
14044 vector unsigned short vec_vadduhm (vector unsigned short,
14045 vector unsigned short);
14046
14047 vector signed char vec_vaddubm (vector bool char, vector signed char);
14048 vector signed char vec_vaddubm (vector signed char, vector bool char);
14049 vector signed char vec_vaddubm (vector signed char, vector signed char);
14050 vector unsigned char vec_vaddubm (vector bool char,
14051 vector unsigned char);
14052 vector unsigned char vec_vaddubm (vector unsigned char,
14053 vector bool char);
14054 vector unsigned char vec_vaddubm (vector unsigned char,
14055 vector unsigned char);
14056
14057 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14058
14059 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14060 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14061 vector unsigned char vec_adds (vector unsigned char,
14062 vector unsigned char);
14063 vector signed char vec_adds (vector bool char, vector signed char);
14064 vector signed char vec_adds (vector signed char, vector bool char);
14065 vector signed char vec_adds (vector signed char, vector signed char);
14066 vector unsigned short vec_adds (vector bool short,
14067 vector unsigned short);
14068 vector unsigned short vec_adds (vector unsigned short,
14069 vector bool short);
14070 vector unsigned short vec_adds (vector unsigned short,
14071 vector unsigned short);
14072 vector signed short vec_adds (vector bool short, vector signed short);
14073 vector signed short vec_adds (vector signed short, vector bool short);
14074 vector signed short vec_adds (vector signed short, vector signed short);
14075 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14076 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14077 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14078 vector signed int vec_adds (vector bool int, vector signed int);
14079 vector signed int vec_adds (vector signed int, vector bool int);
14080 vector signed int vec_adds (vector signed int, vector signed int);
14081
14082 vector signed int vec_vaddsws (vector bool int, vector signed int);
14083 vector signed int vec_vaddsws (vector signed int, vector bool int);
14084 vector signed int vec_vaddsws (vector signed int, vector signed int);
14085
14086 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14087 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14088 vector unsigned int vec_vadduws (vector unsigned int,
14089 vector unsigned int);
14090
14091 vector signed short vec_vaddshs (vector bool short,
14092 vector signed short);
14093 vector signed short vec_vaddshs (vector signed short,
14094 vector bool short);
14095 vector signed short vec_vaddshs (vector signed short,
14096 vector signed short);
14097
14098 vector unsigned short vec_vadduhs (vector bool short,
14099 vector unsigned short);
14100 vector unsigned short vec_vadduhs (vector unsigned short,
14101 vector bool short);
14102 vector unsigned short vec_vadduhs (vector unsigned short,
14103 vector unsigned short);
14104
14105 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14106 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14107 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14108
14109 vector unsigned char vec_vaddubs (vector bool char,
14110 vector unsigned char);
14111 vector unsigned char vec_vaddubs (vector unsigned char,
14112 vector bool char);
14113 vector unsigned char vec_vaddubs (vector unsigned char,
14114 vector unsigned char);
14115
14116 vector float vec_and (vector float, vector float);
14117 vector float vec_and (vector float, vector bool int);
14118 vector float vec_and (vector bool int, vector float);
14119 vector bool int vec_and (vector bool int, vector bool int);
14120 vector signed int vec_and (vector bool int, vector signed int);
14121 vector signed int vec_and (vector signed int, vector bool int);
14122 vector signed int vec_and (vector signed int, vector signed int);
14123 vector unsigned int vec_and (vector bool int, vector unsigned int);
14124 vector unsigned int vec_and (vector unsigned int, vector bool int);
14125 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14126 vector bool short vec_and (vector bool short, vector bool short);
14127 vector signed short vec_and (vector bool short, vector signed short);
14128 vector signed short vec_and (vector signed short, vector bool short);
14129 vector signed short vec_and (vector signed short, vector signed short);
14130 vector unsigned short vec_and (vector bool short,
14131 vector unsigned short);
14132 vector unsigned short vec_and (vector unsigned short,
14133 vector bool short);
14134 vector unsigned short vec_and (vector unsigned short,
14135 vector unsigned short);
14136 vector signed char vec_and (vector bool char, vector signed char);
14137 vector bool char vec_and (vector bool char, vector bool char);
14138 vector signed char vec_and (vector signed char, vector bool char);
14139 vector signed char vec_and (vector signed char, vector signed char);
14140 vector unsigned char vec_and (vector bool char, vector unsigned char);
14141 vector unsigned char vec_and (vector unsigned char, vector bool char);
14142 vector unsigned char vec_and (vector unsigned char,
14143 vector unsigned char);
14144
14145 vector float vec_andc (vector float, vector float);
14146 vector float vec_andc (vector float, vector bool int);
14147 vector float vec_andc (vector bool int, vector float);
14148 vector bool int vec_andc (vector bool int, vector bool int);
14149 vector signed int vec_andc (vector bool int, vector signed int);
14150 vector signed int vec_andc (vector signed int, vector bool int);
14151 vector signed int vec_andc (vector signed int, vector signed int);
14152 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14153 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14154 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14155 vector bool short vec_andc (vector bool short, vector bool short);
14156 vector signed short vec_andc (vector bool short, vector signed short);
14157 vector signed short vec_andc (vector signed short, vector bool short);
14158 vector signed short vec_andc (vector signed short, vector signed short);
14159 vector unsigned short vec_andc (vector bool short,
14160 vector unsigned short);
14161 vector unsigned short vec_andc (vector unsigned short,
14162 vector bool short);
14163 vector unsigned short vec_andc (vector unsigned short,
14164 vector unsigned short);
14165 vector signed char vec_andc (vector bool char, vector signed char);
14166 vector bool char vec_andc (vector bool char, vector bool char);
14167 vector signed char vec_andc (vector signed char, vector bool char);
14168 vector signed char vec_andc (vector signed char, vector signed char);
14169 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14170 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14171 vector unsigned char vec_andc (vector unsigned char,
14172 vector unsigned char);
14173
14174 vector unsigned char vec_avg (vector unsigned char,
14175 vector unsigned char);
14176 vector signed char vec_avg (vector signed char, vector signed char);
14177 vector unsigned short vec_avg (vector unsigned short,
14178 vector unsigned short);
14179 vector signed short vec_avg (vector signed short, vector signed short);
14180 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14181 vector signed int vec_avg (vector signed int, vector signed int);
14182
14183 vector signed int vec_vavgsw (vector signed int, vector signed int);
14184
14185 vector unsigned int vec_vavguw (vector unsigned int,
14186 vector unsigned int);
14187
14188 vector signed short vec_vavgsh (vector signed short,
14189 vector signed short);
14190
14191 vector unsigned short vec_vavguh (vector unsigned short,
14192 vector unsigned short);
14193
14194 vector signed char vec_vavgsb (vector signed char, vector signed char);
14195
14196 vector unsigned char vec_vavgub (vector unsigned char,
14197 vector unsigned char);
14198
14199 vector float vec_copysign (vector float);
14200
14201 vector float vec_ceil (vector float);
14202
14203 vector signed int vec_cmpb (vector float, vector float);
14204
14205 vector bool char vec_cmpeq (vector signed char, vector signed char);
14206 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14207 vector bool short vec_cmpeq (vector signed short, vector signed short);
14208 vector bool short vec_cmpeq (vector unsigned short,
14209 vector unsigned short);
14210 vector bool int vec_cmpeq (vector signed int, vector signed int);
14211 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14212 vector bool int vec_cmpeq (vector float, vector float);
14213
14214 vector bool int vec_vcmpeqfp (vector float, vector float);
14215
14216 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14217 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14218
14219 vector bool short vec_vcmpequh (vector signed short,
14220 vector signed short);
14221 vector bool short vec_vcmpequh (vector unsigned short,
14222 vector unsigned short);
14223
14224 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14225 vector bool char vec_vcmpequb (vector unsigned char,
14226 vector unsigned char);
14227
14228 vector bool int vec_cmpge (vector float, vector float);
14229
14230 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14231 vector bool char vec_cmpgt (vector signed char, vector signed char);
14232 vector bool short vec_cmpgt (vector unsigned short,
14233 vector unsigned short);
14234 vector bool short vec_cmpgt (vector signed short, vector signed short);
14235 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14236 vector bool int vec_cmpgt (vector signed int, vector signed int);
14237 vector bool int vec_cmpgt (vector float, vector float);
14238
14239 vector bool int vec_vcmpgtfp (vector float, vector float);
14240
14241 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14242
14243 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14244
14245 vector bool short vec_vcmpgtsh (vector signed short,
14246 vector signed short);
14247
14248 vector bool short vec_vcmpgtuh (vector unsigned short,
14249 vector unsigned short);
14250
14251 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14252
14253 vector bool char vec_vcmpgtub (vector unsigned char,
14254 vector unsigned char);
14255
14256 vector bool int vec_cmple (vector float, vector float);
14257
14258 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14259 vector bool char vec_cmplt (vector signed char, vector signed char);
14260 vector bool short vec_cmplt (vector unsigned short,
14261 vector unsigned short);
14262 vector bool short vec_cmplt (vector signed short, vector signed short);
14263 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14264 vector bool int vec_cmplt (vector signed int, vector signed int);
14265 vector bool int vec_cmplt (vector float, vector float);
14266
14267 vector float vec_cpsgn (vector float, vector float);
14268
14269 vector float vec_ctf (vector unsigned int, const int);
14270 vector float vec_ctf (vector signed int, const int);
14271 vector double vec_ctf (vector unsigned long, const int);
14272 vector double vec_ctf (vector signed long, const int);
14273
14274 vector float vec_vcfsx (vector signed int, const int);
14275
14276 vector float vec_vcfux (vector unsigned int, const int);
14277
14278 vector signed int vec_cts (vector float, const int);
14279 vector signed long vec_cts (vector double, const int);
14280
14281 vector unsigned int vec_ctu (vector float, const int);
14282 vector unsigned long vec_ctu (vector double, const int);
14283
14284 void vec_dss (const int);
14285
14286 void vec_dssall (void);
14287
14288 void vec_dst (const vector unsigned char *, int, const int);
14289 void vec_dst (const vector signed char *, int, const int);
14290 void vec_dst (const vector bool char *, int, const int);
14291 void vec_dst (const vector unsigned short *, int, const int);
14292 void vec_dst (const vector signed short *, int, const int);
14293 void vec_dst (const vector bool short *, int, const int);
14294 void vec_dst (const vector pixel *, int, const int);
14295 void vec_dst (const vector unsigned int *, int, const int);
14296 void vec_dst (const vector signed int *, int, const int);
14297 void vec_dst (const vector bool int *, int, const int);
14298 void vec_dst (const vector float *, int, const int);
14299 void vec_dst (const unsigned char *, int, const int);
14300 void vec_dst (const signed char *, int, const int);
14301 void vec_dst (const unsigned short *, int, const int);
14302 void vec_dst (const short *, int, const int);
14303 void vec_dst (const unsigned int *, int, const int);
14304 void vec_dst (const int *, int, const int);
14305 void vec_dst (const unsigned long *, int, const int);
14306 void vec_dst (const long *, int, const int);
14307 void vec_dst (const float *, int, const int);
14308
14309 void vec_dstst (const vector unsigned char *, int, const int);
14310 void vec_dstst (const vector signed char *, int, const int);
14311 void vec_dstst (const vector bool char *, int, const int);
14312 void vec_dstst (const vector unsigned short *, int, const int);
14313 void vec_dstst (const vector signed short *, int, const int);
14314 void vec_dstst (const vector bool short *, int, const int);
14315 void vec_dstst (const vector pixel *, int, const int);
14316 void vec_dstst (const vector unsigned int *, int, const int);
14317 void vec_dstst (const vector signed int *, int, const int);
14318 void vec_dstst (const vector bool int *, int, const int);
14319 void vec_dstst (const vector float *, int, const int);
14320 void vec_dstst (const unsigned char *, int, const int);
14321 void vec_dstst (const signed char *, int, const int);
14322 void vec_dstst (const unsigned short *, int, const int);
14323 void vec_dstst (const short *, int, const int);
14324 void vec_dstst (const unsigned int *, int, const int);
14325 void vec_dstst (const int *, int, const int);
14326 void vec_dstst (const unsigned long *, int, const int);
14327 void vec_dstst (const long *, int, const int);
14328 void vec_dstst (const float *, int, const int);
14329
14330 void vec_dststt (const vector unsigned char *, int, const int);
14331 void vec_dststt (const vector signed char *, int, const int);
14332 void vec_dststt (const vector bool char *, int, const int);
14333 void vec_dststt (const vector unsigned short *, int, const int);
14334 void vec_dststt (const vector signed short *, int, const int);
14335 void vec_dststt (const vector bool short *, int, const int);
14336 void vec_dststt (const vector pixel *, int, const int);
14337 void vec_dststt (const vector unsigned int *, int, const int);
14338 void vec_dststt (const vector signed int *, int, const int);
14339 void vec_dststt (const vector bool int *, int, const int);
14340 void vec_dststt (const vector float *, int, const int);
14341 void vec_dststt (const unsigned char *, int, const int);
14342 void vec_dststt (const signed char *, int, const int);
14343 void vec_dststt (const unsigned short *, int, const int);
14344 void vec_dststt (const short *, int, const int);
14345 void vec_dststt (const unsigned int *, int, const int);
14346 void vec_dststt (const int *, int, const int);
14347 void vec_dststt (const unsigned long *, int, const int);
14348 void vec_dststt (const long *, int, const int);
14349 void vec_dststt (const float *, int, const int);
14350
14351 void vec_dstt (const vector unsigned char *, int, const int);
14352 void vec_dstt (const vector signed char *, int, const int);
14353 void vec_dstt (const vector bool char *, int, const int);
14354 void vec_dstt (const vector unsigned short *, int, const int);
14355 void vec_dstt (const vector signed short *, int, const int);
14356 void vec_dstt (const vector bool short *, int, const int);
14357 void vec_dstt (const vector pixel *, int, const int);
14358 void vec_dstt (const vector unsigned int *, int, const int);
14359 void vec_dstt (const vector signed int *, int, const int);
14360 void vec_dstt (const vector bool int *, int, const int);
14361 void vec_dstt (const vector float *, int, const int);
14362 void vec_dstt (const unsigned char *, int, const int);
14363 void vec_dstt (const signed char *, int, const int);
14364 void vec_dstt (const unsigned short *, int, const int);
14365 void vec_dstt (const short *, int, const int);
14366 void vec_dstt (const unsigned int *, int, const int);
14367 void vec_dstt (const int *, int, const int);
14368 void vec_dstt (const unsigned long *, int, const int);
14369 void vec_dstt (const long *, int, const int);
14370 void vec_dstt (const float *, int, const int);
14371
14372 vector float vec_expte (vector float);
14373
14374 vector float vec_floor (vector float);
14375
14376 vector float vec_ld (int, const vector float *);
14377 vector float vec_ld (int, const float *);
14378 vector bool int vec_ld (int, const vector bool int *);
14379 vector signed int vec_ld (int, const vector signed int *);
14380 vector signed int vec_ld (int, const int *);
14381 vector signed int vec_ld (int, const long *);
14382 vector unsigned int vec_ld (int, const vector unsigned int *);
14383 vector unsigned int vec_ld (int, const unsigned int *);
14384 vector unsigned int vec_ld (int, const unsigned long *);
14385 vector bool short vec_ld (int, const vector bool short *);
14386 vector pixel vec_ld (int, const vector pixel *);
14387 vector signed short vec_ld (int, const vector signed short *);
14388 vector signed short vec_ld (int, const short *);
14389 vector unsigned short vec_ld (int, const vector unsigned short *);
14390 vector unsigned short vec_ld (int, const unsigned short *);
14391 vector bool char vec_ld (int, const vector bool char *);
14392 vector signed char vec_ld (int, const vector signed char *);
14393 vector signed char vec_ld (int, const signed char *);
14394 vector unsigned char vec_ld (int, const vector unsigned char *);
14395 vector unsigned char vec_ld (int, const unsigned char *);
14396
14397 vector signed char vec_lde (int, const signed char *);
14398 vector unsigned char vec_lde (int, const unsigned char *);
14399 vector signed short vec_lde (int, const short *);
14400 vector unsigned short vec_lde (int, const unsigned short *);
14401 vector float vec_lde (int, const float *);
14402 vector signed int vec_lde (int, const int *);
14403 vector unsigned int vec_lde (int, const unsigned int *);
14404 vector signed int vec_lde (int, const long *);
14405 vector unsigned int vec_lde (int, const unsigned long *);
14406
14407 vector float vec_lvewx (int, float *);
14408 vector signed int vec_lvewx (int, int *);
14409 vector unsigned int vec_lvewx (int, unsigned int *);
14410 vector signed int vec_lvewx (int, long *);
14411 vector unsigned int vec_lvewx (int, unsigned long *);
14412
14413 vector signed short vec_lvehx (int, short *);
14414 vector unsigned short vec_lvehx (int, unsigned short *);
14415
14416 vector signed char vec_lvebx (int, char *);
14417 vector unsigned char vec_lvebx (int, unsigned char *);
14418
14419 vector float vec_ldl (int, const vector float *);
14420 vector float vec_ldl (int, const float *);
14421 vector bool int vec_ldl (int, const vector bool int *);
14422 vector signed int vec_ldl (int, const vector signed int *);
14423 vector signed int vec_ldl (int, const int *);
14424 vector signed int vec_ldl (int, const long *);
14425 vector unsigned int vec_ldl (int, const vector unsigned int *);
14426 vector unsigned int vec_ldl (int, const unsigned int *);
14427 vector unsigned int vec_ldl (int, const unsigned long *);
14428 vector bool short vec_ldl (int, const vector bool short *);
14429 vector pixel vec_ldl (int, const vector pixel *);
14430 vector signed short vec_ldl (int, const vector signed short *);
14431 vector signed short vec_ldl (int, const short *);
14432 vector unsigned short vec_ldl (int, const vector unsigned short *);
14433 vector unsigned short vec_ldl (int, const unsigned short *);
14434 vector bool char vec_ldl (int, const vector bool char *);
14435 vector signed char vec_ldl (int, const vector signed char *);
14436 vector signed char vec_ldl (int, const signed char *);
14437 vector unsigned char vec_ldl (int, const vector unsigned char *);
14438 vector unsigned char vec_ldl (int, const unsigned char *);
14439
14440 vector float vec_loge (vector float);
14441
14442 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14443 vector unsigned char vec_lvsl (int, const volatile signed char *);
14444 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14445 vector unsigned char vec_lvsl (int, const volatile short *);
14446 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14447 vector unsigned char vec_lvsl (int, const volatile int *);
14448 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14449 vector unsigned char vec_lvsl (int, const volatile long *);
14450 vector unsigned char vec_lvsl (int, const volatile float *);
14451
14452 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14453 vector unsigned char vec_lvsr (int, const volatile signed char *);
14454 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14455 vector unsigned char vec_lvsr (int, const volatile short *);
14456 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14457 vector unsigned char vec_lvsr (int, const volatile int *);
14458 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14459 vector unsigned char vec_lvsr (int, const volatile long *);
14460 vector unsigned char vec_lvsr (int, const volatile float *);
14461
14462 vector float vec_madd (vector float, vector float, vector float);
14463
14464 vector signed short vec_madds (vector signed short,
14465 vector signed short,
14466 vector signed short);
14467
14468 vector unsigned char vec_max (vector bool char, vector unsigned char);
14469 vector unsigned char vec_max (vector unsigned char, vector bool char);
14470 vector unsigned char vec_max (vector unsigned char,
14471 vector unsigned char);
14472 vector signed char vec_max (vector bool char, vector signed char);
14473 vector signed char vec_max (vector signed char, vector bool char);
14474 vector signed char vec_max (vector signed char, vector signed char);
14475 vector unsigned short vec_max (vector bool short,
14476 vector unsigned short);
14477 vector unsigned short vec_max (vector unsigned short,
14478 vector bool short);
14479 vector unsigned short vec_max (vector unsigned short,
14480 vector unsigned short);
14481 vector signed short vec_max (vector bool short, vector signed short);
14482 vector signed short vec_max (vector signed short, vector bool short);
14483 vector signed short vec_max (vector signed short, vector signed short);
14484 vector unsigned int vec_max (vector bool int, vector unsigned int);
14485 vector unsigned int vec_max (vector unsigned int, vector bool int);
14486 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14487 vector signed int vec_max (vector bool int, vector signed int);
14488 vector signed int vec_max (vector signed int, vector bool int);
14489 vector signed int vec_max (vector signed int, vector signed int);
14490 vector float vec_max (vector float, vector float);
14491
14492 vector float vec_vmaxfp (vector float, vector float);
14493
14494 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14495 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14496 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14497
14498 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14499 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14500 vector unsigned int vec_vmaxuw (vector unsigned int,
14501 vector unsigned int);
14502
14503 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14504 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14505 vector signed short vec_vmaxsh (vector signed short,
14506 vector signed short);
14507
14508 vector unsigned short vec_vmaxuh (vector bool short,
14509 vector unsigned short);
14510 vector unsigned short vec_vmaxuh (vector unsigned short,
14511 vector bool short);
14512 vector unsigned short vec_vmaxuh (vector unsigned short,
14513 vector unsigned short);
14514
14515 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14516 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14517 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14518
14519 vector unsigned char vec_vmaxub (vector bool char,
14520 vector unsigned char);
14521 vector unsigned char vec_vmaxub (vector unsigned char,
14522 vector bool char);
14523 vector unsigned char vec_vmaxub (vector unsigned char,
14524 vector unsigned char);
14525
14526 vector bool char vec_mergeh (vector bool char, vector bool char);
14527 vector signed char vec_mergeh (vector signed char, vector signed char);
14528 vector unsigned char vec_mergeh (vector unsigned char,
14529 vector unsigned char);
14530 vector bool short vec_mergeh (vector bool short, vector bool short);
14531 vector pixel vec_mergeh (vector pixel, vector pixel);
14532 vector signed short vec_mergeh (vector signed short,
14533 vector signed short);
14534 vector unsigned short vec_mergeh (vector unsigned short,
14535 vector unsigned short);
14536 vector float vec_mergeh (vector float, vector float);
14537 vector bool int vec_mergeh (vector bool int, vector bool int);
14538 vector signed int vec_mergeh (vector signed int, vector signed int);
14539 vector unsigned int vec_mergeh (vector unsigned int,
14540 vector unsigned int);
14541
14542 vector float vec_vmrghw (vector float, vector float);
14543 vector bool int vec_vmrghw (vector bool int, vector bool int);
14544 vector signed int vec_vmrghw (vector signed int, vector signed int);
14545 vector unsigned int vec_vmrghw (vector unsigned int,
14546 vector unsigned int);
14547
14548 vector bool short vec_vmrghh (vector bool short, vector bool short);
14549 vector signed short vec_vmrghh (vector signed short,
14550 vector signed short);
14551 vector unsigned short vec_vmrghh (vector unsigned short,
14552 vector unsigned short);
14553 vector pixel vec_vmrghh (vector pixel, vector pixel);
14554
14555 vector bool char vec_vmrghb (vector bool char, vector bool char);
14556 vector signed char vec_vmrghb (vector signed char, vector signed char);
14557 vector unsigned char vec_vmrghb (vector unsigned char,
14558 vector unsigned char);
14559
14560 vector bool char vec_mergel (vector bool char, vector bool char);
14561 vector signed char vec_mergel (vector signed char, vector signed char);
14562 vector unsigned char vec_mergel (vector unsigned char,
14563 vector unsigned char);
14564 vector bool short vec_mergel (vector bool short, vector bool short);
14565 vector pixel vec_mergel (vector pixel, vector pixel);
14566 vector signed short vec_mergel (vector signed short,
14567 vector signed short);
14568 vector unsigned short vec_mergel (vector unsigned short,
14569 vector unsigned short);
14570 vector float vec_mergel (vector float, vector float);
14571 vector bool int vec_mergel (vector bool int, vector bool int);
14572 vector signed int vec_mergel (vector signed int, vector signed int);
14573 vector unsigned int vec_mergel (vector unsigned int,
14574 vector unsigned int);
14575
14576 vector float vec_vmrglw (vector float, vector float);
14577 vector signed int vec_vmrglw (vector signed int, vector signed int);
14578 vector unsigned int vec_vmrglw (vector unsigned int,
14579 vector unsigned int);
14580 vector bool int vec_vmrglw (vector bool int, vector bool int);
14581
14582 vector bool short vec_vmrglh (vector bool short, vector bool short);
14583 vector signed short vec_vmrglh (vector signed short,
14584 vector signed short);
14585 vector unsigned short vec_vmrglh (vector unsigned short,
14586 vector unsigned short);
14587 vector pixel vec_vmrglh (vector pixel, vector pixel);
14588
14589 vector bool char vec_vmrglb (vector bool char, vector bool char);
14590 vector signed char vec_vmrglb (vector signed char, vector signed char);
14591 vector unsigned char vec_vmrglb (vector unsigned char,
14592 vector unsigned char);
14593
14594 vector unsigned short vec_mfvscr (void);
14595
14596 vector unsigned char vec_min (vector bool char, vector unsigned char);
14597 vector unsigned char vec_min (vector unsigned char, vector bool char);
14598 vector unsigned char vec_min (vector unsigned char,
14599 vector unsigned char);
14600 vector signed char vec_min (vector bool char, vector signed char);
14601 vector signed char vec_min (vector signed char, vector bool char);
14602 vector signed char vec_min (vector signed char, vector signed char);
14603 vector unsigned short vec_min (vector bool short,
14604 vector unsigned short);
14605 vector unsigned short vec_min (vector unsigned short,
14606 vector bool short);
14607 vector unsigned short vec_min (vector unsigned short,
14608 vector unsigned short);
14609 vector signed short vec_min (vector bool short, vector signed short);
14610 vector signed short vec_min (vector signed short, vector bool short);
14611 vector signed short vec_min (vector signed short, vector signed short);
14612 vector unsigned int vec_min (vector bool int, vector unsigned int);
14613 vector unsigned int vec_min (vector unsigned int, vector bool int);
14614 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14615 vector signed int vec_min (vector bool int, vector signed int);
14616 vector signed int vec_min (vector signed int, vector bool int);
14617 vector signed int vec_min (vector signed int, vector signed int);
14618 vector float vec_min (vector float, vector float);
14619
14620 vector float vec_vminfp (vector float, vector float);
14621
14622 vector signed int vec_vminsw (vector bool int, vector signed int);
14623 vector signed int vec_vminsw (vector signed int, vector bool int);
14624 vector signed int vec_vminsw (vector signed int, vector signed int);
14625
14626 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14627 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14628 vector unsigned int vec_vminuw (vector unsigned int,
14629 vector unsigned int);
14630
14631 vector signed short vec_vminsh (vector bool short, vector signed short);
14632 vector signed short vec_vminsh (vector signed short, vector bool short);
14633 vector signed short vec_vminsh (vector signed short,
14634 vector signed short);
14635
14636 vector unsigned short vec_vminuh (vector bool short,
14637 vector unsigned short);
14638 vector unsigned short vec_vminuh (vector unsigned short,
14639 vector bool short);
14640 vector unsigned short vec_vminuh (vector unsigned short,
14641 vector unsigned short);
14642
14643 vector signed char vec_vminsb (vector bool char, vector signed char);
14644 vector signed char vec_vminsb (vector signed char, vector bool char);
14645 vector signed char vec_vminsb (vector signed char, vector signed char);
14646
14647 vector unsigned char vec_vminub (vector bool char,
14648 vector unsigned char);
14649 vector unsigned char vec_vminub (vector unsigned char,
14650 vector bool char);
14651 vector unsigned char vec_vminub (vector unsigned char,
14652 vector unsigned char);
14653
14654 vector signed short vec_mladd (vector signed short,
14655 vector signed short,
14656 vector signed short);
14657 vector signed short vec_mladd (vector signed short,
14658 vector unsigned short,
14659 vector unsigned short);
14660 vector signed short vec_mladd (vector unsigned short,
14661 vector signed short,
14662 vector signed short);
14663 vector unsigned short vec_mladd (vector unsigned short,
14664 vector unsigned short,
14665 vector unsigned short);
14666
14667 vector signed short vec_mradds (vector signed short,
14668 vector signed short,
14669 vector signed short);
14670
14671 vector unsigned int vec_msum (vector unsigned char,
14672 vector unsigned char,
14673 vector unsigned int);
14674 vector signed int vec_msum (vector signed char,
14675 vector unsigned char,
14676 vector signed int);
14677 vector unsigned int vec_msum (vector unsigned short,
14678 vector unsigned short,
14679 vector unsigned int);
14680 vector signed int vec_msum (vector signed short,
14681 vector signed short,
14682 vector signed int);
14683
14684 vector signed int vec_vmsumshm (vector signed short,
14685 vector signed short,
14686 vector signed int);
14687
14688 vector unsigned int vec_vmsumuhm (vector unsigned short,
14689 vector unsigned short,
14690 vector unsigned int);
14691
14692 vector signed int vec_vmsummbm (vector signed char,
14693 vector unsigned char,
14694 vector signed int);
14695
14696 vector unsigned int vec_vmsumubm (vector unsigned char,
14697 vector unsigned char,
14698 vector unsigned int);
14699
14700 vector unsigned int vec_msums (vector unsigned short,
14701 vector unsigned short,
14702 vector unsigned int);
14703 vector signed int vec_msums (vector signed short,
14704 vector signed short,
14705 vector signed int);
14706
14707 vector signed int vec_vmsumshs (vector signed short,
14708 vector signed short,
14709 vector signed int);
14710
14711 vector unsigned int vec_vmsumuhs (vector unsigned short,
14712 vector unsigned short,
14713 vector unsigned int);
14714
14715 void vec_mtvscr (vector signed int);
14716 void vec_mtvscr (vector unsigned int);
14717 void vec_mtvscr (vector bool int);
14718 void vec_mtvscr (vector signed short);
14719 void vec_mtvscr (vector unsigned short);
14720 void vec_mtvscr (vector bool short);
14721 void vec_mtvscr (vector pixel);
14722 void vec_mtvscr (vector signed char);
14723 void vec_mtvscr (vector unsigned char);
14724 void vec_mtvscr (vector bool char);
14725
14726 vector unsigned short vec_mule (vector unsigned char,
14727 vector unsigned char);
14728 vector signed short vec_mule (vector signed char,
14729 vector signed char);
14730 vector unsigned int vec_mule (vector unsigned short,
14731 vector unsigned short);
14732 vector signed int vec_mule (vector signed short, vector signed short);
14733
14734 vector signed int vec_vmulesh (vector signed short,
14735 vector signed short);
14736
14737 vector unsigned int vec_vmuleuh (vector unsigned short,
14738 vector unsigned short);
14739
14740 vector signed short vec_vmulesb (vector signed char,
14741 vector signed char);
14742
14743 vector unsigned short vec_vmuleub (vector unsigned char,
14744 vector unsigned char);
14745
14746 vector unsigned short vec_mulo (vector unsigned char,
14747 vector unsigned char);
14748 vector signed short vec_mulo (vector signed char, vector signed char);
14749 vector unsigned int vec_mulo (vector unsigned short,
14750 vector unsigned short);
14751 vector signed int vec_mulo (vector signed short, vector signed short);
14752
14753 vector signed int vec_vmulosh (vector signed short,
14754 vector signed short);
14755
14756 vector unsigned int vec_vmulouh (vector unsigned short,
14757 vector unsigned short);
14758
14759 vector signed short vec_vmulosb (vector signed char,
14760 vector signed char);
14761
14762 vector unsigned short vec_vmuloub (vector unsigned char,
14763 vector unsigned char);
14764
14765 vector float vec_nmsub (vector float, vector float, vector float);
14766
14767 vector float vec_nor (vector float, vector float);
14768 vector signed int vec_nor (vector signed int, vector signed int);
14769 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14770 vector bool int vec_nor (vector bool int, vector bool int);
14771 vector signed short vec_nor (vector signed short, vector signed short);
14772 vector unsigned short vec_nor (vector unsigned short,
14773 vector unsigned short);
14774 vector bool short vec_nor (vector bool short, vector bool short);
14775 vector signed char vec_nor (vector signed char, vector signed char);
14776 vector unsigned char vec_nor (vector unsigned char,
14777 vector unsigned char);
14778 vector bool char vec_nor (vector bool char, vector bool char);
14779
14780 vector float vec_or (vector float, vector float);
14781 vector float vec_or (vector float, vector bool int);
14782 vector float vec_or (vector bool int, vector float);
14783 vector bool int vec_or (vector bool int, vector bool int);
14784 vector signed int vec_or (vector bool int, vector signed int);
14785 vector signed int vec_or (vector signed int, vector bool int);
14786 vector signed int vec_or (vector signed int, vector signed int);
14787 vector unsigned int vec_or (vector bool int, vector unsigned int);
14788 vector unsigned int vec_or (vector unsigned int, vector bool int);
14789 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14790 vector bool short vec_or (vector bool short, vector bool short);
14791 vector signed short vec_or (vector bool short, vector signed short);
14792 vector signed short vec_or (vector signed short, vector bool short);
14793 vector signed short vec_or (vector signed short, vector signed short);
14794 vector unsigned short vec_or (vector bool short, vector unsigned short);
14795 vector unsigned short vec_or (vector unsigned short, vector bool short);
14796 vector unsigned short vec_or (vector unsigned short,
14797 vector unsigned short);
14798 vector signed char vec_or (vector bool char, vector signed char);
14799 vector bool char vec_or (vector bool char, vector bool char);
14800 vector signed char vec_or (vector signed char, vector bool char);
14801 vector signed char vec_or (vector signed char, vector signed char);
14802 vector unsigned char vec_or (vector bool char, vector unsigned char);
14803 vector unsigned char vec_or (vector unsigned char, vector bool char);
14804 vector unsigned char vec_or (vector unsigned char,
14805 vector unsigned char);
14806
14807 vector signed char vec_pack (vector signed short, vector signed short);
14808 vector unsigned char vec_pack (vector unsigned short,
14809 vector unsigned short);
14810 vector bool char vec_pack (vector bool short, vector bool short);
14811 vector signed short vec_pack (vector signed int, vector signed int);
14812 vector unsigned short vec_pack (vector unsigned int,
14813 vector unsigned int);
14814 vector bool short vec_pack (vector bool int, vector bool int);
14815
14816 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14817 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14818 vector unsigned short vec_vpkuwum (vector unsigned int,
14819 vector unsigned int);
14820
14821 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14822 vector signed char vec_vpkuhum (vector signed short,
14823 vector signed short);
14824 vector unsigned char vec_vpkuhum (vector unsigned short,
14825 vector unsigned short);
14826
14827 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14828
14829 vector unsigned char vec_packs (vector unsigned short,
14830 vector unsigned short);
14831 vector signed char vec_packs (vector signed short, vector signed short);
14832 vector unsigned short vec_packs (vector unsigned int,
14833 vector unsigned int);
14834 vector signed short vec_packs (vector signed int, vector signed int);
14835
14836 vector signed short vec_vpkswss (vector signed int, vector signed int);
14837
14838 vector unsigned short vec_vpkuwus (vector unsigned int,
14839 vector unsigned int);
14840
14841 vector signed char vec_vpkshss (vector signed short,
14842 vector signed short);
14843
14844 vector unsigned char vec_vpkuhus (vector unsigned short,
14845 vector unsigned short);
14846
14847 vector unsigned char vec_packsu (vector unsigned short,
14848 vector unsigned short);
14849 vector unsigned char vec_packsu (vector signed short,
14850 vector signed short);
14851 vector unsigned short vec_packsu (vector unsigned int,
14852 vector unsigned int);
14853 vector unsigned short vec_packsu (vector signed int, vector signed int);
14854
14855 vector unsigned short vec_vpkswus (vector signed int,
14856 vector signed int);
14857
14858 vector unsigned char vec_vpkshus (vector signed short,
14859 vector signed short);
14860
14861 vector float vec_perm (vector float,
14862 vector float,
14863 vector unsigned char);
14864 vector signed int vec_perm (vector signed int,
14865 vector signed int,
14866 vector unsigned char);
14867 vector unsigned int vec_perm (vector unsigned int,
14868 vector unsigned int,
14869 vector unsigned char);
14870 vector bool int vec_perm (vector bool int,
14871 vector bool int,
14872 vector unsigned char);
14873 vector signed short vec_perm (vector signed short,
14874 vector signed short,
14875 vector unsigned char);
14876 vector unsigned short vec_perm (vector unsigned short,
14877 vector unsigned short,
14878 vector unsigned char);
14879 vector bool short vec_perm (vector bool short,
14880 vector bool short,
14881 vector unsigned char);
14882 vector pixel vec_perm (vector pixel,
14883 vector pixel,
14884 vector unsigned char);
14885 vector signed char vec_perm (vector signed char,
14886 vector signed char,
14887 vector unsigned char);
14888 vector unsigned char vec_perm (vector unsigned char,
14889 vector unsigned char,
14890 vector unsigned char);
14891 vector bool char vec_perm (vector bool char,
14892 vector bool char,
14893 vector unsigned char);
14894
14895 vector float vec_re (vector float);
14896
14897 vector signed char vec_rl (vector signed char,
14898 vector unsigned char);
14899 vector unsigned char vec_rl (vector unsigned char,
14900 vector unsigned char);
14901 vector signed short vec_rl (vector signed short, vector unsigned short);
14902 vector unsigned short vec_rl (vector unsigned short,
14903 vector unsigned short);
14904 vector signed int vec_rl (vector signed int, vector unsigned int);
14905 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14906
14907 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14908 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14909
14910 vector signed short vec_vrlh (vector signed short,
14911 vector unsigned short);
14912 vector unsigned short vec_vrlh (vector unsigned short,
14913 vector unsigned short);
14914
14915 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14916 vector unsigned char vec_vrlb (vector unsigned char,
14917 vector unsigned char);
14918
14919 vector float vec_round (vector float);
14920
14921 vector float vec_recip (vector float, vector float);
14922
14923 vector float vec_rsqrt (vector float);
14924
14925 vector float vec_rsqrte (vector float);
14926
14927 vector float vec_sel (vector float, vector float, vector bool int);
14928 vector float vec_sel (vector float, vector float, vector unsigned int);
14929 vector signed int vec_sel (vector signed int,
14930 vector signed int,
14931 vector bool int);
14932 vector signed int vec_sel (vector signed int,
14933 vector signed int,
14934 vector unsigned int);
14935 vector unsigned int vec_sel (vector unsigned int,
14936 vector unsigned int,
14937 vector bool int);
14938 vector unsigned int vec_sel (vector unsigned int,
14939 vector unsigned int,
14940 vector unsigned int);
14941 vector bool int vec_sel (vector bool int,
14942 vector bool int,
14943 vector bool int);
14944 vector bool int vec_sel (vector bool int,
14945 vector bool int,
14946 vector unsigned int);
14947 vector signed short vec_sel (vector signed short,
14948 vector signed short,
14949 vector bool short);
14950 vector signed short vec_sel (vector signed short,
14951 vector signed short,
14952 vector unsigned short);
14953 vector unsigned short vec_sel (vector unsigned short,
14954 vector unsigned short,
14955 vector bool short);
14956 vector unsigned short vec_sel (vector unsigned short,
14957 vector unsigned short,
14958 vector unsigned short);
14959 vector bool short vec_sel (vector bool short,
14960 vector bool short,
14961 vector bool short);
14962 vector bool short vec_sel (vector bool short,
14963 vector bool short,
14964 vector unsigned short);
14965 vector signed char vec_sel (vector signed char,
14966 vector signed char,
14967 vector bool char);
14968 vector signed char vec_sel (vector signed char,
14969 vector signed char,
14970 vector unsigned char);
14971 vector unsigned char vec_sel (vector unsigned char,
14972 vector unsigned char,
14973 vector bool char);
14974 vector unsigned char vec_sel (vector unsigned char,
14975 vector unsigned char,
14976 vector unsigned char);
14977 vector bool char vec_sel (vector bool char,
14978 vector bool char,
14979 vector bool char);
14980 vector bool char vec_sel (vector bool char,
14981 vector bool char,
14982 vector unsigned char);
14983
14984 vector signed char vec_sl (vector signed char,
14985 vector unsigned char);
14986 vector unsigned char vec_sl (vector unsigned char,
14987 vector unsigned char);
14988 vector signed short vec_sl (vector signed short, vector unsigned short);
14989 vector unsigned short vec_sl (vector unsigned short,
14990 vector unsigned short);
14991 vector signed int vec_sl (vector signed int, vector unsigned int);
14992 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14993
14994 vector signed int vec_vslw (vector signed int, vector unsigned int);
14995 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14996
14997 vector signed short vec_vslh (vector signed short,
14998 vector unsigned short);
14999 vector unsigned short vec_vslh (vector unsigned short,
15000 vector unsigned short);
15001
15002 vector signed char vec_vslb (vector signed char, vector unsigned char);
15003 vector unsigned char vec_vslb (vector unsigned char,
15004 vector unsigned char);
15005
15006 vector float vec_sld (vector float, vector float, const int);
15007 vector signed int vec_sld (vector signed int,
15008 vector signed int,
15009 const int);
15010 vector unsigned int vec_sld (vector unsigned int,
15011 vector unsigned int,
15012 const int);
15013 vector bool int vec_sld (vector bool int,
15014 vector bool int,
15015 const int);
15016 vector signed short vec_sld (vector signed short,
15017 vector signed short,
15018 const int);
15019 vector unsigned short vec_sld (vector unsigned short,
15020 vector unsigned short,
15021 const int);
15022 vector bool short vec_sld (vector bool short,
15023 vector bool short,
15024 const int);
15025 vector pixel vec_sld (vector pixel,
15026 vector pixel,
15027 const int);
15028 vector signed char vec_sld (vector signed char,
15029 vector signed char,
15030 const int);
15031 vector unsigned char vec_sld (vector unsigned char,
15032 vector unsigned char,
15033 const int);
15034 vector bool char vec_sld (vector bool char,
15035 vector bool char,
15036 const int);
15037
15038 vector signed int vec_sll (vector signed int,
15039 vector unsigned int);
15040 vector signed int vec_sll (vector signed int,
15041 vector unsigned short);
15042 vector signed int vec_sll (vector signed int,
15043 vector unsigned char);
15044 vector unsigned int vec_sll (vector unsigned int,
15045 vector unsigned int);
15046 vector unsigned int vec_sll (vector unsigned int,
15047 vector unsigned short);
15048 vector unsigned int vec_sll (vector unsigned int,
15049 vector unsigned char);
15050 vector bool int vec_sll (vector bool int,
15051 vector unsigned int);
15052 vector bool int vec_sll (vector bool int,
15053 vector unsigned short);
15054 vector bool int vec_sll (vector bool int,
15055 vector unsigned char);
15056 vector signed short vec_sll (vector signed short,
15057 vector unsigned int);
15058 vector signed short vec_sll (vector signed short,
15059 vector unsigned short);
15060 vector signed short vec_sll (vector signed short,
15061 vector unsigned char);
15062 vector unsigned short vec_sll (vector unsigned short,
15063 vector unsigned int);
15064 vector unsigned short vec_sll (vector unsigned short,
15065 vector unsigned short);
15066 vector unsigned short vec_sll (vector unsigned short,
15067 vector unsigned char);
15068 vector bool short vec_sll (vector bool short, vector unsigned int);
15069 vector bool short vec_sll (vector bool short, vector unsigned short);
15070 vector bool short vec_sll (vector bool short, vector unsigned char);
15071 vector pixel vec_sll (vector pixel, vector unsigned int);
15072 vector pixel vec_sll (vector pixel, vector unsigned short);
15073 vector pixel vec_sll (vector pixel, vector unsigned char);
15074 vector signed char vec_sll (vector signed char, vector unsigned int);
15075 vector signed char vec_sll (vector signed char, vector unsigned short);
15076 vector signed char vec_sll (vector signed char, vector unsigned char);
15077 vector unsigned char vec_sll (vector unsigned char,
15078 vector unsigned int);
15079 vector unsigned char vec_sll (vector unsigned char,
15080 vector unsigned short);
15081 vector unsigned char vec_sll (vector unsigned char,
15082 vector unsigned char);
15083 vector bool char vec_sll (vector bool char, vector unsigned int);
15084 vector bool char vec_sll (vector bool char, vector unsigned short);
15085 vector bool char vec_sll (vector bool char, vector unsigned char);
15086
15087 vector float vec_slo (vector float, vector signed char);
15088 vector float vec_slo (vector float, vector unsigned char);
15089 vector signed int vec_slo (vector signed int, vector signed char);
15090 vector signed int vec_slo (vector signed int, vector unsigned char);
15091 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15092 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15093 vector signed short vec_slo (vector signed short, vector signed char);
15094 vector signed short vec_slo (vector signed short, vector unsigned char);
15095 vector unsigned short vec_slo (vector unsigned short,
15096 vector signed char);
15097 vector unsigned short vec_slo (vector unsigned short,
15098 vector unsigned char);
15099 vector pixel vec_slo (vector pixel, vector signed char);
15100 vector pixel vec_slo (vector pixel, vector unsigned char);
15101 vector signed char vec_slo (vector signed char, vector signed char);
15102 vector signed char vec_slo (vector signed char, vector unsigned char);
15103 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15104 vector unsigned char vec_slo (vector unsigned char,
15105 vector unsigned char);
15106
15107 vector signed char vec_splat (vector signed char, const int);
15108 vector unsigned char vec_splat (vector unsigned char, const int);
15109 vector bool char vec_splat (vector bool char, const int);
15110 vector signed short vec_splat (vector signed short, const int);
15111 vector unsigned short vec_splat (vector unsigned short, const int);
15112 vector bool short vec_splat (vector bool short, const int);
15113 vector pixel vec_splat (vector pixel, const int);
15114 vector float vec_splat (vector float, const int);
15115 vector signed int vec_splat (vector signed int, const int);
15116 vector unsigned int vec_splat (vector unsigned int, const int);
15117 vector bool int vec_splat (vector bool int, const int);
15118 vector signed long vec_splat (vector signed long, const int);
15119 vector unsigned long vec_splat (vector unsigned long, const int);
15120
15121 vector signed char vec_splats (signed char);
15122 vector unsigned char vec_splats (unsigned char);
15123 vector signed short vec_splats (signed short);
15124 vector unsigned short vec_splats (unsigned short);
15125 vector signed int vec_splats (signed int);
15126 vector unsigned int vec_splats (unsigned int);
15127 vector float vec_splats (float);
15128
15129 vector float vec_vspltw (vector float, const int);
15130 vector signed int vec_vspltw (vector signed int, const int);
15131 vector unsigned int vec_vspltw (vector unsigned int, const int);
15132 vector bool int vec_vspltw (vector bool int, const int);
15133
15134 vector bool short vec_vsplth (vector bool short, const int);
15135 vector signed short vec_vsplth (vector signed short, const int);
15136 vector unsigned short vec_vsplth (vector unsigned short, const int);
15137 vector pixel vec_vsplth (vector pixel, const int);
15138
15139 vector signed char vec_vspltb (vector signed char, const int);
15140 vector unsigned char vec_vspltb (vector unsigned char, const int);
15141 vector bool char vec_vspltb (vector bool char, const int);
15142
15143 vector signed char vec_splat_s8 (const int);
15144
15145 vector signed short vec_splat_s16 (const int);
15146
15147 vector signed int vec_splat_s32 (const int);
15148
15149 vector unsigned char vec_splat_u8 (const int);
15150
15151 vector unsigned short vec_splat_u16 (const int);
15152
15153 vector unsigned int vec_splat_u32 (const int);
15154
15155 vector signed char vec_sr (vector signed char, vector unsigned char);
15156 vector unsigned char vec_sr (vector unsigned char,
15157 vector unsigned char);
15158 vector signed short vec_sr (vector signed short,
15159 vector unsigned short);
15160 vector unsigned short vec_sr (vector unsigned short,
15161 vector unsigned short);
15162 vector signed int vec_sr (vector signed int, vector unsigned int);
15163 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15164
15165 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15166 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15167
15168 vector signed short vec_vsrh (vector signed short,
15169 vector unsigned short);
15170 vector unsigned short vec_vsrh (vector unsigned short,
15171 vector unsigned short);
15172
15173 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15174 vector unsigned char vec_vsrb (vector unsigned char,
15175 vector unsigned char);
15176
15177 vector signed char vec_sra (vector signed char, vector unsigned char);
15178 vector unsigned char vec_sra (vector unsigned char,
15179 vector unsigned char);
15180 vector signed short vec_sra (vector signed short,
15181 vector unsigned short);
15182 vector unsigned short vec_sra (vector unsigned short,
15183 vector unsigned short);
15184 vector signed int vec_sra (vector signed int, vector unsigned int);
15185 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15186
15187 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15188 vector unsigned int vec_vsraw (vector unsigned int,
15189 vector unsigned int);
15190
15191 vector signed short vec_vsrah (vector signed short,
15192 vector unsigned short);
15193 vector unsigned short vec_vsrah (vector unsigned short,
15194 vector unsigned short);
15195
15196 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15197 vector unsigned char vec_vsrab (vector unsigned char,
15198 vector unsigned char);
15199
15200 vector signed int vec_srl (vector signed int, vector unsigned int);
15201 vector signed int vec_srl (vector signed int, vector unsigned short);
15202 vector signed int vec_srl (vector signed int, vector unsigned char);
15203 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15204 vector unsigned int vec_srl (vector unsigned int,
15205 vector unsigned short);
15206 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15207 vector bool int vec_srl (vector bool int, vector unsigned int);
15208 vector bool int vec_srl (vector bool int, vector unsigned short);
15209 vector bool int vec_srl (vector bool int, vector unsigned char);
15210 vector signed short vec_srl (vector signed short, vector unsigned int);
15211 vector signed short vec_srl (vector signed short,
15212 vector unsigned short);
15213 vector signed short vec_srl (vector signed short, vector unsigned char);
15214 vector unsigned short vec_srl (vector unsigned short,
15215 vector unsigned int);
15216 vector unsigned short vec_srl (vector unsigned short,
15217 vector unsigned short);
15218 vector unsigned short vec_srl (vector unsigned short,
15219 vector unsigned char);
15220 vector bool short vec_srl (vector bool short, vector unsigned int);
15221 vector bool short vec_srl (vector bool short, vector unsigned short);
15222 vector bool short vec_srl (vector bool short, vector unsigned char);
15223 vector pixel vec_srl (vector pixel, vector unsigned int);
15224 vector pixel vec_srl (vector pixel, vector unsigned short);
15225 vector pixel vec_srl (vector pixel, vector unsigned char);
15226 vector signed char vec_srl (vector signed char, vector unsigned int);
15227 vector signed char vec_srl (vector signed char, vector unsigned short);
15228 vector signed char vec_srl (vector signed char, vector unsigned char);
15229 vector unsigned char vec_srl (vector unsigned char,
15230 vector unsigned int);
15231 vector unsigned char vec_srl (vector unsigned char,
15232 vector unsigned short);
15233 vector unsigned char vec_srl (vector unsigned char,
15234 vector unsigned char);
15235 vector bool char vec_srl (vector bool char, vector unsigned int);
15236 vector bool char vec_srl (vector bool char, vector unsigned short);
15237 vector bool char vec_srl (vector bool char, vector unsigned char);
15238
15239 vector float vec_sro (vector float, vector signed char);
15240 vector float vec_sro (vector float, vector unsigned char);
15241 vector signed int vec_sro (vector signed int, vector signed char);
15242 vector signed int vec_sro (vector signed int, vector unsigned char);
15243 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15244 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15245 vector signed short vec_sro (vector signed short, vector signed char);
15246 vector signed short vec_sro (vector signed short, vector unsigned char);
15247 vector unsigned short vec_sro (vector unsigned short,
15248 vector signed char);
15249 vector unsigned short vec_sro (vector unsigned short,
15250 vector unsigned char);
15251 vector pixel vec_sro (vector pixel, vector signed char);
15252 vector pixel vec_sro (vector pixel, vector unsigned char);
15253 vector signed char vec_sro (vector signed char, vector signed char);
15254 vector signed char vec_sro (vector signed char, vector unsigned char);
15255 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15256 vector unsigned char vec_sro (vector unsigned char,
15257 vector unsigned char);
15258
15259 void vec_st (vector float, int, vector float *);
15260 void vec_st (vector float, int, float *);
15261 void vec_st (vector signed int, int, vector signed int *);
15262 void vec_st (vector signed int, int, int *);
15263 void vec_st (vector unsigned int, int, vector unsigned int *);
15264 void vec_st (vector unsigned int, int, unsigned int *);
15265 void vec_st (vector bool int, int, vector bool int *);
15266 void vec_st (vector bool int, int, unsigned int *);
15267 void vec_st (vector bool int, int, int *);
15268 void vec_st (vector signed short, int, vector signed short *);
15269 void vec_st (vector signed short, int, short *);
15270 void vec_st (vector unsigned short, int, vector unsigned short *);
15271 void vec_st (vector unsigned short, int, unsigned short *);
15272 void vec_st (vector bool short, int, vector bool short *);
15273 void vec_st (vector bool short, int, unsigned short *);
15274 void vec_st (vector pixel, int, vector pixel *);
15275 void vec_st (vector pixel, int, unsigned short *);
15276 void vec_st (vector pixel, int, short *);
15277 void vec_st (vector bool short, int, short *);
15278 void vec_st (vector signed char, int, vector signed char *);
15279 void vec_st (vector signed char, int, signed char *);
15280 void vec_st (vector unsigned char, int, vector unsigned char *);
15281 void vec_st (vector unsigned char, int, unsigned char *);
15282 void vec_st (vector bool char, int, vector bool char *);
15283 void vec_st (vector bool char, int, unsigned char *);
15284 void vec_st (vector bool char, int, signed char *);
15285
15286 void vec_ste (vector signed char, int, signed char *);
15287 void vec_ste (vector unsigned char, int, unsigned char *);
15288 void vec_ste (vector bool char, int, signed char *);
15289 void vec_ste (vector bool char, int, unsigned char *);
15290 void vec_ste (vector signed short, int, short *);
15291 void vec_ste (vector unsigned short, int, unsigned short *);
15292 void vec_ste (vector bool short, int, short *);
15293 void vec_ste (vector bool short, int, unsigned short *);
15294 void vec_ste (vector pixel, int, short *);
15295 void vec_ste (vector pixel, int, unsigned short *);
15296 void vec_ste (vector float, int, float *);
15297 void vec_ste (vector signed int, int, int *);
15298 void vec_ste (vector unsigned int, int, unsigned int *);
15299 void vec_ste (vector bool int, int, int *);
15300 void vec_ste (vector bool int, int, unsigned int *);
15301
15302 void vec_stvewx (vector float, int, float *);
15303 void vec_stvewx (vector signed int, int, int *);
15304 void vec_stvewx (vector unsigned int, int, unsigned int *);
15305 void vec_stvewx (vector bool int, int, int *);
15306 void vec_stvewx (vector bool int, int, unsigned int *);
15307
15308 void vec_stvehx (vector signed short, int, short *);
15309 void vec_stvehx (vector unsigned short, int, unsigned short *);
15310 void vec_stvehx (vector bool short, int, short *);
15311 void vec_stvehx (vector bool short, int, unsigned short *);
15312 void vec_stvehx (vector pixel, int, short *);
15313 void vec_stvehx (vector pixel, int, unsigned short *);
15314
15315 void vec_stvebx (vector signed char, int, signed char *);
15316 void vec_stvebx (vector unsigned char, int, unsigned char *);
15317 void vec_stvebx (vector bool char, int, signed char *);
15318 void vec_stvebx (vector bool char, int, unsigned char *);
15319
15320 void vec_stl (vector float, int, vector float *);
15321 void vec_stl (vector float, int, float *);
15322 void vec_stl (vector signed int, int, vector signed int *);
15323 void vec_stl (vector signed int, int, int *);
15324 void vec_stl (vector unsigned int, int, vector unsigned int *);
15325 void vec_stl (vector unsigned int, int, unsigned int *);
15326 void vec_stl (vector bool int, int, vector bool int *);
15327 void vec_stl (vector bool int, int, unsigned int *);
15328 void vec_stl (vector bool int, int, int *);
15329 void vec_stl (vector signed short, int, vector signed short *);
15330 void vec_stl (vector signed short, int, short *);
15331 void vec_stl (vector unsigned short, int, vector unsigned short *);
15332 void vec_stl (vector unsigned short, int, unsigned short *);
15333 void vec_stl (vector bool short, int, vector bool short *);
15334 void vec_stl (vector bool short, int, unsigned short *);
15335 void vec_stl (vector bool short, int, short *);
15336 void vec_stl (vector pixel, int, vector pixel *);
15337 void vec_stl (vector pixel, int, unsigned short *);
15338 void vec_stl (vector pixel, int, short *);
15339 void vec_stl (vector signed char, int, vector signed char *);
15340 void vec_stl (vector signed char, int, signed char *);
15341 void vec_stl (vector unsigned char, int, vector unsigned char *);
15342 void vec_stl (vector unsigned char, int, unsigned char *);
15343 void vec_stl (vector bool char, int, vector bool char *);
15344 void vec_stl (vector bool char, int, unsigned char *);
15345 void vec_stl (vector bool char, int, signed char *);
15346
15347 vector signed char vec_sub (vector bool char, vector signed char);
15348 vector signed char vec_sub (vector signed char, vector bool char);
15349 vector signed char vec_sub (vector signed char, vector signed char);
15350 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15351 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15352 vector unsigned char vec_sub (vector unsigned char,
15353 vector unsigned char);
15354 vector signed short vec_sub (vector bool short, vector signed short);
15355 vector signed short vec_sub (vector signed short, vector bool short);
15356 vector signed short vec_sub (vector signed short, vector signed short);
15357 vector unsigned short vec_sub (vector bool short,
15358 vector unsigned short);
15359 vector unsigned short vec_sub (vector unsigned short,
15360 vector bool short);
15361 vector unsigned short vec_sub (vector unsigned short,
15362 vector unsigned short);
15363 vector signed int vec_sub (vector bool int, vector signed int);
15364 vector signed int vec_sub (vector signed int, vector bool int);
15365 vector signed int vec_sub (vector signed int, vector signed int);
15366 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15367 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15368 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15369 vector float vec_sub (vector float, vector float);
15370
15371 vector float vec_vsubfp (vector float, vector float);
15372
15373 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15374 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15375 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15376 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15377 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15378 vector unsigned int vec_vsubuwm (vector unsigned int,
15379 vector unsigned int);
15380
15381 vector signed short vec_vsubuhm (vector bool short,
15382 vector signed short);
15383 vector signed short vec_vsubuhm (vector signed short,
15384 vector bool short);
15385 vector signed short vec_vsubuhm (vector signed short,
15386 vector signed short);
15387 vector unsigned short vec_vsubuhm (vector bool short,
15388 vector unsigned short);
15389 vector unsigned short vec_vsubuhm (vector unsigned short,
15390 vector bool short);
15391 vector unsigned short vec_vsubuhm (vector unsigned short,
15392 vector unsigned short);
15393
15394 vector signed char vec_vsububm (vector bool char, vector signed char);
15395 vector signed char vec_vsububm (vector signed char, vector bool char);
15396 vector signed char vec_vsububm (vector signed char, vector signed char);
15397 vector unsigned char vec_vsububm (vector bool char,
15398 vector unsigned char);
15399 vector unsigned char vec_vsububm (vector unsigned char,
15400 vector bool char);
15401 vector unsigned char vec_vsububm (vector unsigned char,
15402 vector unsigned char);
15403
15404 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15405
15406 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15407 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15408 vector unsigned char vec_subs (vector unsigned char,
15409 vector unsigned char);
15410 vector signed char vec_subs (vector bool char, vector signed char);
15411 vector signed char vec_subs (vector signed char, vector bool char);
15412 vector signed char vec_subs (vector signed char, vector signed char);
15413 vector unsigned short vec_subs (vector bool short,
15414 vector unsigned short);
15415 vector unsigned short vec_subs (vector unsigned short,
15416 vector bool short);
15417 vector unsigned short vec_subs (vector unsigned short,
15418 vector unsigned short);
15419 vector signed short vec_subs (vector bool short, vector signed short);
15420 vector signed short vec_subs (vector signed short, vector bool short);
15421 vector signed short vec_subs (vector signed short, vector signed short);
15422 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15423 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15424 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15425 vector signed int vec_subs (vector bool int, vector signed int);
15426 vector signed int vec_subs (vector signed int, vector bool int);
15427 vector signed int vec_subs (vector signed int, vector signed int);
15428
15429 vector signed int vec_vsubsws (vector bool int, vector signed int);
15430 vector signed int vec_vsubsws (vector signed int, vector bool int);
15431 vector signed int vec_vsubsws (vector signed int, vector signed int);
15432
15433 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15434 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15435 vector unsigned int vec_vsubuws (vector unsigned int,
15436 vector unsigned int);
15437
15438 vector signed short vec_vsubshs (vector bool short,
15439 vector signed short);
15440 vector signed short vec_vsubshs (vector signed short,
15441 vector bool short);
15442 vector signed short vec_vsubshs (vector signed short,
15443 vector signed short);
15444
15445 vector unsigned short vec_vsubuhs (vector bool short,
15446 vector unsigned short);
15447 vector unsigned short vec_vsubuhs (vector unsigned short,
15448 vector bool short);
15449 vector unsigned short vec_vsubuhs (vector unsigned short,
15450 vector unsigned short);
15451
15452 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15453 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15454 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15455
15456 vector unsigned char vec_vsububs (vector bool char,
15457 vector unsigned char);
15458 vector unsigned char vec_vsububs (vector unsigned char,
15459 vector bool char);
15460 vector unsigned char vec_vsububs (vector unsigned char,
15461 vector unsigned char);
15462
15463 vector unsigned int vec_sum4s (vector unsigned char,
15464 vector unsigned int);
15465 vector signed int vec_sum4s (vector signed char, vector signed int);
15466 vector signed int vec_sum4s (vector signed short, vector signed int);
15467
15468 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15469
15470 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15471
15472 vector unsigned int vec_vsum4ubs (vector unsigned char,
15473 vector unsigned int);
15474
15475 vector signed int vec_sum2s (vector signed int, vector signed int);
15476
15477 vector signed int vec_sums (vector signed int, vector signed int);
15478
15479 vector float vec_trunc (vector float);
15480
15481 vector signed short vec_unpackh (vector signed char);
15482 vector bool short vec_unpackh (vector bool char);
15483 vector signed int vec_unpackh (vector signed short);
15484 vector bool int vec_unpackh (vector bool short);
15485 vector unsigned int vec_unpackh (vector pixel);
15486
15487 vector bool int vec_vupkhsh (vector bool short);
15488 vector signed int vec_vupkhsh (vector signed short);
15489
15490 vector unsigned int vec_vupkhpx (vector pixel);
15491
15492 vector bool short vec_vupkhsb (vector bool char);
15493 vector signed short vec_vupkhsb (vector signed char);
15494
15495 vector signed short vec_unpackl (vector signed char);
15496 vector bool short vec_unpackl (vector bool char);
15497 vector unsigned int vec_unpackl (vector pixel);
15498 vector signed int vec_unpackl (vector signed short);
15499 vector bool int vec_unpackl (vector bool short);
15500
15501 vector unsigned int vec_vupklpx (vector pixel);
15502
15503 vector bool int vec_vupklsh (vector bool short);
15504 vector signed int vec_vupklsh (vector signed short);
15505
15506 vector bool short vec_vupklsb (vector bool char);
15507 vector signed short vec_vupklsb (vector signed char);
15508
15509 vector float vec_xor (vector float, vector float);
15510 vector float vec_xor (vector float, vector bool int);
15511 vector float vec_xor (vector bool int, vector float);
15512 vector bool int vec_xor (vector bool int, vector bool int);
15513 vector signed int vec_xor (vector bool int, vector signed int);
15514 vector signed int vec_xor (vector signed int, vector bool int);
15515 vector signed int vec_xor (vector signed int, vector signed int);
15516 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15517 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15518 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15519 vector bool short vec_xor (vector bool short, vector bool short);
15520 vector signed short vec_xor (vector bool short, vector signed short);
15521 vector signed short vec_xor (vector signed short, vector bool short);
15522 vector signed short vec_xor (vector signed short, vector signed short);
15523 vector unsigned short vec_xor (vector bool short,
15524 vector unsigned short);
15525 vector unsigned short vec_xor (vector unsigned short,
15526 vector bool short);
15527 vector unsigned short vec_xor (vector unsigned short,
15528 vector unsigned short);
15529 vector signed char vec_xor (vector bool char, vector signed char);
15530 vector bool char vec_xor (vector bool char, vector bool char);
15531 vector signed char vec_xor (vector signed char, vector bool char);
15532 vector signed char vec_xor (vector signed char, vector signed char);
15533 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15534 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15535 vector unsigned char vec_xor (vector unsigned char,
15536 vector unsigned char);
15537
15538 int vec_all_eq (vector signed char, vector bool char);
15539 int vec_all_eq (vector signed char, vector signed char);
15540 int vec_all_eq (vector unsigned char, vector bool char);
15541 int vec_all_eq (vector unsigned char, vector unsigned char);
15542 int vec_all_eq (vector bool char, vector bool char);
15543 int vec_all_eq (vector bool char, vector unsigned char);
15544 int vec_all_eq (vector bool char, vector signed char);
15545 int vec_all_eq (vector signed short, vector bool short);
15546 int vec_all_eq (vector signed short, vector signed short);
15547 int vec_all_eq (vector unsigned short, vector bool short);
15548 int vec_all_eq (vector unsigned short, vector unsigned short);
15549 int vec_all_eq (vector bool short, vector bool short);
15550 int vec_all_eq (vector bool short, vector unsigned short);
15551 int vec_all_eq (vector bool short, vector signed short);
15552 int vec_all_eq (vector pixel, vector pixel);
15553 int vec_all_eq (vector signed int, vector bool int);
15554 int vec_all_eq (vector signed int, vector signed int);
15555 int vec_all_eq (vector unsigned int, vector bool int);
15556 int vec_all_eq (vector unsigned int, vector unsigned int);
15557 int vec_all_eq (vector bool int, vector bool int);
15558 int vec_all_eq (vector bool int, vector unsigned int);
15559 int vec_all_eq (vector bool int, vector signed int);
15560 int vec_all_eq (vector float, vector float);
15561
15562 int vec_all_ge (vector bool char, vector unsigned char);
15563 int vec_all_ge (vector unsigned char, vector bool char);
15564 int vec_all_ge (vector unsigned char, vector unsigned char);
15565 int vec_all_ge (vector bool char, vector signed char);
15566 int vec_all_ge (vector signed char, vector bool char);
15567 int vec_all_ge (vector signed char, vector signed char);
15568 int vec_all_ge (vector bool short, vector unsigned short);
15569 int vec_all_ge (vector unsigned short, vector bool short);
15570 int vec_all_ge (vector unsigned short, vector unsigned short);
15571 int vec_all_ge (vector signed short, vector signed short);
15572 int vec_all_ge (vector bool short, vector signed short);
15573 int vec_all_ge (vector signed short, vector bool short);
15574 int vec_all_ge (vector bool int, vector unsigned int);
15575 int vec_all_ge (vector unsigned int, vector bool int);
15576 int vec_all_ge (vector unsigned int, vector unsigned int);
15577 int vec_all_ge (vector bool int, vector signed int);
15578 int vec_all_ge (vector signed int, vector bool int);
15579 int vec_all_ge (vector signed int, vector signed int);
15580 int vec_all_ge (vector float, vector float);
15581
15582 int vec_all_gt (vector bool char, vector unsigned char);
15583 int vec_all_gt (vector unsigned char, vector bool char);
15584 int vec_all_gt (vector unsigned char, vector unsigned char);
15585 int vec_all_gt (vector bool char, vector signed char);
15586 int vec_all_gt (vector signed char, vector bool char);
15587 int vec_all_gt (vector signed char, vector signed char);
15588 int vec_all_gt (vector bool short, vector unsigned short);
15589 int vec_all_gt (vector unsigned short, vector bool short);
15590 int vec_all_gt (vector unsigned short, vector unsigned short);
15591 int vec_all_gt (vector bool short, vector signed short);
15592 int vec_all_gt (vector signed short, vector bool short);
15593 int vec_all_gt (vector signed short, vector signed short);
15594 int vec_all_gt (vector bool int, vector unsigned int);
15595 int vec_all_gt (vector unsigned int, vector bool int);
15596 int vec_all_gt (vector unsigned int, vector unsigned int);
15597 int vec_all_gt (vector bool int, vector signed int);
15598 int vec_all_gt (vector signed int, vector bool int);
15599 int vec_all_gt (vector signed int, vector signed int);
15600 int vec_all_gt (vector float, vector float);
15601
15602 int vec_all_in (vector float, vector float);
15603
15604 int vec_all_le (vector bool char, vector unsigned char);
15605 int vec_all_le (vector unsigned char, vector bool char);
15606 int vec_all_le (vector unsigned char, vector unsigned char);
15607 int vec_all_le (vector bool char, vector signed char);
15608 int vec_all_le (vector signed char, vector bool char);
15609 int vec_all_le (vector signed char, vector signed char);
15610 int vec_all_le (vector bool short, vector unsigned short);
15611 int vec_all_le (vector unsigned short, vector bool short);
15612 int vec_all_le (vector unsigned short, vector unsigned short);
15613 int vec_all_le (vector bool short, vector signed short);
15614 int vec_all_le (vector signed short, vector bool short);
15615 int vec_all_le (vector signed short, vector signed short);
15616 int vec_all_le (vector bool int, vector unsigned int);
15617 int vec_all_le (vector unsigned int, vector bool int);
15618 int vec_all_le (vector unsigned int, vector unsigned int);
15619 int vec_all_le (vector bool int, vector signed int);
15620 int vec_all_le (vector signed int, vector bool int);
15621 int vec_all_le (vector signed int, vector signed int);
15622 int vec_all_le (vector float, vector float);
15623
15624 int vec_all_lt (vector bool char, vector unsigned char);
15625 int vec_all_lt (vector unsigned char, vector bool char);
15626 int vec_all_lt (vector unsigned char, vector unsigned char);
15627 int vec_all_lt (vector bool char, vector signed char);
15628 int vec_all_lt (vector signed char, vector bool char);
15629 int vec_all_lt (vector signed char, vector signed char);
15630 int vec_all_lt (vector bool short, vector unsigned short);
15631 int vec_all_lt (vector unsigned short, vector bool short);
15632 int vec_all_lt (vector unsigned short, vector unsigned short);
15633 int vec_all_lt (vector bool short, vector signed short);
15634 int vec_all_lt (vector signed short, vector bool short);
15635 int vec_all_lt (vector signed short, vector signed short);
15636 int vec_all_lt (vector bool int, vector unsigned int);
15637 int vec_all_lt (vector unsigned int, vector bool int);
15638 int vec_all_lt (vector unsigned int, vector unsigned int);
15639 int vec_all_lt (vector bool int, vector signed int);
15640 int vec_all_lt (vector signed int, vector bool int);
15641 int vec_all_lt (vector signed int, vector signed int);
15642 int vec_all_lt (vector float, vector float);
15643
15644 int vec_all_nan (vector float);
15645
15646 int vec_all_ne (vector signed char, vector bool char);
15647 int vec_all_ne (vector signed char, vector signed char);
15648 int vec_all_ne (vector unsigned char, vector bool char);
15649 int vec_all_ne (vector unsigned char, vector unsigned char);
15650 int vec_all_ne (vector bool char, vector bool char);
15651 int vec_all_ne (vector bool char, vector unsigned char);
15652 int vec_all_ne (vector bool char, vector signed char);
15653 int vec_all_ne (vector signed short, vector bool short);
15654 int vec_all_ne (vector signed short, vector signed short);
15655 int vec_all_ne (vector unsigned short, vector bool short);
15656 int vec_all_ne (vector unsigned short, vector unsigned short);
15657 int vec_all_ne (vector bool short, vector bool short);
15658 int vec_all_ne (vector bool short, vector unsigned short);
15659 int vec_all_ne (vector bool short, vector signed short);
15660 int vec_all_ne (vector pixel, vector pixel);
15661 int vec_all_ne (vector signed int, vector bool int);
15662 int vec_all_ne (vector signed int, vector signed int);
15663 int vec_all_ne (vector unsigned int, vector bool int);
15664 int vec_all_ne (vector unsigned int, vector unsigned int);
15665 int vec_all_ne (vector bool int, vector bool int);
15666 int vec_all_ne (vector bool int, vector unsigned int);
15667 int vec_all_ne (vector bool int, vector signed int);
15668 int vec_all_ne (vector float, vector float);
15669
15670 int vec_all_nge (vector float, vector float);
15671
15672 int vec_all_ngt (vector float, vector float);
15673
15674 int vec_all_nle (vector float, vector float);
15675
15676 int vec_all_nlt (vector float, vector float);
15677
15678 int vec_all_numeric (vector float);
15679
15680 int vec_any_eq (vector signed char, vector bool char);
15681 int vec_any_eq (vector signed char, vector signed char);
15682 int vec_any_eq (vector unsigned char, vector bool char);
15683 int vec_any_eq (vector unsigned char, vector unsigned char);
15684 int vec_any_eq (vector bool char, vector bool char);
15685 int vec_any_eq (vector bool char, vector unsigned char);
15686 int vec_any_eq (vector bool char, vector signed char);
15687 int vec_any_eq (vector signed short, vector bool short);
15688 int vec_any_eq (vector signed short, vector signed short);
15689 int vec_any_eq (vector unsigned short, vector bool short);
15690 int vec_any_eq (vector unsigned short, vector unsigned short);
15691 int vec_any_eq (vector bool short, vector bool short);
15692 int vec_any_eq (vector bool short, vector unsigned short);
15693 int vec_any_eq (vector bool short, vector signed short);
15694 int vec_any_eq (vector pixel, vector pixel);
15695 int vec_any_eq (vector signed int, vector bool int);
15696 int vec_any_eq (vector signed int, vector signed int);
15697 int vec_any_eq (vector unsigned int, vector bool int);
15698 int vec_any_eq (vector unsigned int, vector unsigned int);
15699 int vec_any_eq (vector bool int, vector bool int);
15700 int vec_any_eq (vector bool int, vector unsigned int);
15701 int vec_any_eq (vector bool int, vector signed int);
15702 int vec_any_eq (vector float, vector float);
15703
15704 int vec_any_ge (vector signed char, vector bool char);
15705 int vec_any_ge (vector unsigned char, vector bool char);
15706 int vec_any_ge (vector unsigned char, vector unsigned char);
15707 int vec_any_ge (vector signed char, vector signed char);
15708 int vec_any_ge (vector bool char, vector unsigned char);
15709 int vec_any_ge (vector bool char, vector signed char);
15710 int vec_any_ge (vector unsigned short, vector bool short);
15711 int vec_any_ge (vector unsigned short, vector unsigned short);
15712 int vec_any_ge (vector signed short, vector signed short);
15713 int vec_any_ge (vector signed short, vector bool short);
15714 int vec_any_ge (vector bool short, vector unsigned short);
15715 int vec_any_ge (vector bool short, vector signed short);
15716 int vec_any_ge (vector signed int, vector bool int);
15717 int vec_any_ge (vector unsigned int, vector bool int);
15718 int vec_any_ge (vector unsigned int, vector unsigned int);
15719 int vec_any_ge (vector signed int, vector signed int);
15720 int vec_any_ge (vector bool int, vector unsigned int);
15721 int vec_any_ge (vector bool int, vector signed int);
15722 int vec_any_ge (vector float, vector float);
15723
15724 int vec_any_gt (vector bool char, vector unsigned char);
15725 int vec_any_gt (vector unsigned char, vector bool char);
15726 int vec_any_gt (vector unsigned char, vector unsigned char);
15727 int vec_any_gt (vector bool char, vector signed char);
15728 int vec_any_gt (vector signed char, vector bool char);
15729 int vec_any_gt (vector signed char, vector signed char);
15730 int vec_any_gt (vector bool short, vector unsigned short);
15731 int vec_any_gt (vector unsigned short, vector bool short);
15732 int vec_any_gt (vector unsigned short, vector unsigned short);
15733 int vec_any_gt (vector bool short, vector signed short);
15734 int vec_any_gt (vector signed short, vector bool short);
15735 int vec_any_gt (vector signed short, vector signed short);
15736 int vec_any_gt (vector bool int, vector unsigned int);
15737 int vec_any_gt (vector unsigned int, vector bool int);
15738 int vec_any_gt (vector unsigned int, vector unsigned int);
15739 int vec_any_gt (vector bool int, vector signed int);
15740 int vec_any_gt (vector signed int, vector bool int);
15741 int vec_any_gt (vector signed int, vector signed int);
15742 int vec_any_gt (vector float, vector float);
15743
15744 int vec_any_le (vector bool char, vector unsigned char);
15745 int vec_any_le (vector unsigned char, vector bool char);
15746 int vec_any_le (vector unsigned char, vector unsigned char);
15747 int vec_any_le (vector bool char, vector signed char);
15748 int vec_any_le (vector signed char, vector bool char);
15749 int vec_any_le (vector signed char, vector signed char);
15750 int vec_any_le (vector bool short, vector unsigned short);
15751 int vec_any_le (vector unsigned short, vector bool short);
15752 int vec_any_le (vector unsigned short, vector unsigned short);
15753 int vec_any_le (vector bool short, vector signed short);
15754 int vec_any_le (vector signed short, vector bool short);
15755 int vec_any_le (vector signed short, vector signed short);
15756 int vec_any_le (vector bool int, vector unsigned int);
15757 int vec_any_le (vector unsigned int, vector bool int);
15758 int vec_any_le (vector unsigned int, vector unsigned int);
15759 int vec_any_le (vector bool int, vector signed int);
15760 int vec_any_le (vector signed int, vector bool int);
15761 int vec_any_le (vector signed int, vector signed int);
15762 int vec_any_le (vector float, vector float);
15763
15764 int vec_any_lt (vector bool char, vector unsigned char);
15765 int vec_any_lt (vector unsigned char, vector bool char);
15766 int vec_any_lt (vector unsigned char, vector unsigned char);
15767 int vec_any_lt (vector bool char, vector signed char);
15768 int vec_any_lt (vector signed char, vector bool char);
15769 int vec_any_lt (vector signed char, vector signed char);
15770 int vec_any_lt (vector bool short, vector unsigned short);
15771 int vec_any_lt (vector unsigned short, vector bool short);
15772 int vec_any_lt (vector unsigned short, vector unsigned short);
15773 int vec_any_lt (vector bool short, vector signed short);
15774 int vec_any_lt (vector signed short, vector bool short);
15775 int vec_any_lt (vector signed short, vector signed short);
15776 int vec_any_lt (vector bool int, vector unsigned int);
15777 int vec_any_lt (vector unsigned int, vector bool int);
15778 int vec_any_lt (vector unsigned int, vector unsigned int);
15779 int vec_any_lt (vector bool int, vector signed int);
15780 int vec_any_lt (vector signed int, vector bool int);
15781 int vec_any_lt (vector signed int, vector signed int);
15782 int vec_any_lt (vector float, vector float);
15783
15784 int vec_any_nan (vector float);
15785
15786 int vec_any_ne (vector signed char, vector bool char);
15787 int vec_any_ne (vector signed char, vector signed char);
15788 int vec_any_ne (vector unsigned char, vector bool char);
15789 int vec_any_ne (vector unsigned char, vector unsigned char);
15790 int vec_any_ne (vector bool char, vector bool char);
15791 int vec_any_ne (vector bool char, vector unsigned char);
15792 int vec_any_ne (vector bool char, vector signed char);
15793 int vec_any_ne (vector signed short, vector bool short);
15794 int vec_any_ne (vector signed short, vector signed short);
15795 int vec_any_ne (vector unsigned short, vector bool short);
15796 int vec_any_ne (vector unsigned short, vector unsigned short);
15797 int vec_any_ne (vector bool short, vector bool short);
15798 int vec_any_ne (vector bool short, vector unsigned short);
15799 int vec_any_ne (vector bool short, vector signed short);
15800 int vec_any_ne (vector pixel, vector pixel);
15801 int vec_any_ne (vector signed int, vector bool int);
15802 int vec_any_ne (vector signed int, vector signed int);
15803 int vec_any_ne (vector unsigned int, vector bool int);
15804 int vec_any_ne (vector unsigned int, vector unsigned int);
15805 int vec_any_ne (vector bool int, vector bool int);
15806 int vec_any_ne (vector bool int, vector unsigned int);
15807 int vec_any_ne (vector bool int, vector signed int);
15808 int vec_any_ne (vector float, vector float);
15809
15810 int vec_any_nge (vector float, vector float);
15811
15812 int vec_any_ngt (vector float, vector float);
15813
15814 int vec_any_nle (vector float, vector float);
15815
15816 int vec_any_nlt (vector float, vector float);
15817
15818 int vec_any_numeric (vector float);
15819
15820 int vec_any_out (vector float, vector float);
15821 @end smallexample
15822
15823 If the vector/scalar (VSX) instruction set is available, the following
15824 additional functions are available:
15825
15826 @smallexample
15827 vector double vec_abs (vector double);
15828 vector double vec_add (vector double, vector double);
15829 vector double vec_and (vector double, vector double);
15830 vector double vec_and (vector double, vector bool long);
15831 vector double vec_and (vector bool long, vector double);
15832 vector long vec_and (vector long, vector long);
15833 vector long vec_and (vector long, vector bool long);
15834 vector long vec_and (vector bool long, vector long);
15835 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15836 vector unsigned long vec_and (vector unsigned long, vector bool long);
15837 vector unsigned long vec_and (vector bool long, vector unsigned long);
15838 vector double vec_andc (vector double, vector double);
15839 vector double vec_andc (vector double, vector bool long);
15840 vector double vec_andc (vector bool long, vector double);
15841 vector long vec_andc (vector long, vector long);
15842 vector long vec_andc (vector long, vector bool long);
15843 vector long vec_andc (vector bool long, vector long);
15844 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15845 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15846 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15847 vector double vec_ceil (vector double);
15848 vector bool long vec_cmpeq (vector double, vector double);
15849 vector bool long vec_cmpge (vector double, vector double);
15850 vector bool long vec_cmpgt (vector double, vector double);
15851 vector bool long vec_cmple (vector double, vector double);
15852 vector bool long vec_cmplt (vector double, vector double);
15853 vector double vec_cpsgn (vector double, vector double);
15854 vector float vec_div (vector float, vector float);
15855 vector double vec_div (vector double, vector double);
15856 vector long vec_div (vector long, vector long);
15857 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15858 vector double vec_floor (vector double);
15859 vector double vec_ld (int, const vector double *);
15860 vector double vec_ld (int, const double *);
15861 vector double vec_ldl (int, const vector double *);
15862 vector double vec_ldl (int, const double *);
15863 vector unsigned char vec_lvsl (int, const volatile double *);
15864 vector unsigned char vec_lvsr (int, const volatile double *);
15865 vector double vec_madd (vector double, vector double, vector double);
15866 vector double vec_max (vector double, vector double);
15867 vector signed long vec_mergeh (vector signed long, vector signed long);
15868 vector signed long vec_mergeh (vector signed long, vector bool long);
15869 vector signed long vec_mergeh (vector bool long, vector signed long);
15870 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15871 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15872 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15873 vector signed long vec_mergel (vector signed long, vector signed long);
15874 vector signed long vec_mergel (vector signed long, vector bool long);
15875 vector signed long vec_mergel (vector bool long, vector signed long);
15876 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15877 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15878 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15879 vector double vec_min (vector double, vector double);
15880 vector float vec_msub (vector float, vector float, vector float);
15881 vector double vec_msub (vector double, vector double, vector double);
15882 vector float vec_mul (vector float, vector float);
15883 vector double vec_mul (vector double, vector double);
15884 vector long vec_mul (vector long, vector long);
15885 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15886 vector float vec_nearbyint (vector float);
15887 vector double vec_nearbyint (vector double);
15888 vector float vec_nmadd (vector float, vector float, vector float);
15889 vector double vec_nmadd (vector double, vector double, vector double);
15890 vector double vec_nmsub (vector double, vector double, vector double);
15891 vector double vec_nor (vector double, vector double);
15892 vector long vec_nor (vector long, vector long);
15893 vector long vec_nor (vector long, vector bool long);
15894 vector long vec_nor (vector bool long, vector long);
15895 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15896 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15897 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15898 vector double vec_or (vector double, vector double);
15899 vector double vec_or (vector double, vector bool long);
15900 vector double vec_or (vector bool long, vector double);
15901 vector long vec_or (vector long, vector long);
15902 vector long vec_or (vector long, vector bool long);
15903 vector long vec_or (vector bool long, vector long);
15904 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15905 vector unsigned long vec_or (vector unsigned long, vector bool long);
15906 vector unsigned long vec_or (vector bool long, vector unsigned long);
15907 vector double vec_perm (vector double, vector double, vector unsigned char);
15908 vector long vec_perm (vector long, vector long, vector unsigned char);
15909 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15910 vector unsigned char);
15911 vector double vec_rint (vector double);
15912 vector double vec_recip (vector double, vector double);
15913 vector double vec_rsqrt (vector double);
15914 vector double vec_rsqrte (vector double);
15915 vector double vec_sel (vector double, vector double, vector bool long);
15916 vector double vec_sel (vector double, vector double, vector unsigned long);
15917 vector long vec_sel (vector long, vector long, vector long);
15918 vector long vec_sel (vector long, vector long, vector unsigned long);
15919 vector long vec_sel (vector long, vector long, vector bool long);
15920 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15921 vector long);
15922 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15923 vector unsigned long);
15924 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15925 vector bool long);
15926 vector double vec_splats (double);
15927 vector signed long vec_splats (signed long);
15928 vector unsigned long vec_splats (unsigned long);
15929 vector float vec_sqrt (vector float);
15930 vector double vec_sqrt (vector double);
15931 void vec_st (vector double, int, vector double *);
15932 void vec_st (vector double, int, double *);
15933 vector double vec_sub (vector double, vector double);
15934 vector double vec_trunc (vector double);
15935 vector double vec_xor (vector double, vector double);
15936 vector double vec_xor (vector double, vector bool long);
15937 vector double vec_xor (vector bool long, vector double);
15938 vector long vec_xor (vector long, vector long);
15939 vector long vec_xor (vector long, vector bool long);
15940 vector long vec_xor (vector bool long, vector long);
15941 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15942 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15943 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15944 int vec_all_eq (vector double, vector double);
15945 int vec_all_ge (vector double, vector double);
15946 int vec_all_gt (vector double, vector double);
15947 int vec_all_le (vector double, vector double);
15948 int vec_all_lt (vector double, vector double);
15949 int vec_all_nan (vector double);
15950 int vec_all_ne (vector double, vector double);
15951 int vec_all_nge (vector double, vector double);
15952 int vec_all_ngt (vector double, vector double);
15953 int vec_all_nle (vector double, vector double);
15954 int vec_all_nlt (vector double, vector double);
15955 int vec_all_numeric (vector double);
15956 int vec_any_eq (vector double, vector double);
15957 int vec_any_ge (vector double, vector double);
15958 int vec_any_gt (vector double, vector double);
15959 int vec_any_le (vector double, vector double);
15960 int vec_any_lt (vector double, vector double);
15961 int vec_any_nan (vector double);
15962 int vec_any_ne (vector double, vector double);
15963 int vec_any_nge (vector double, vector double);
15964 int vec_any_ngt (vector double, vector double);
15965 int vec_any_nle (vector double, vector double);
15966 int vec_any_nlt (vector double, vector double);
15967 int vec_any_numeric (vector double);
15968
15969 vector double vec_vsx_ld (int, const vector double *);
15970 vector double vec_vsx_ld (int, const double *);
15971 vector float vec_vsx_ld (int, const vector float *);
15972 vector float vec_vsx_ld (int, const float *);
15973 vector bool int vec_vsx_ld (int, const vector bool int *);
15974 vector signed int vec_vsx_ld (int, const vector signed int *);
15975 vector signed int vec_vsx_ld (int, const int *);
15976 vector signed int vec_vsx_ld (int, const long *);
15977 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15978 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15979 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15980 vector bool short vec_vsx_ld (int, const vector bool short *);
15981 vector pixel vec_vsx_ld (int, const vector pixel *);
15982 vector signed short vec_vsx_ld (int, const vector signed short *);
15983 vector signed short vec_vsx_ld (int, const short *);
15984 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15985 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15986 vector bool char vec_vsx_ld (int, const vector bool char *);
15987 vector signed char vec_vsx_ld (int, const vector signed char *);
15988 vector signed char vec_vsx_ld (int, const signed char *);
15989 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15990 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15991
15992 void vec_vsx_st (vector double, int, vector double *);
15993 void vec_vsx_st (vector double, int, double *);
15994 void vec_vsx_st (vector float, int, vector float *);
15995 void vec_vsx_st (vector float, int, float *);
15996 void vec_vsx_st (vector signed int, int, vector signed int *);
15997 void vec_vsx_st (vector signed int, int, int *);
15998 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15999 void vec_vsx_st (vector unsigned int, int, unsigned int *);
16000 void vec_vsx_st (vector bool int, int, vector bool int *);
16001 void vec_vsx_st (vector bool int, int, unsigned int *);
16002 void vec_vsx_st (vector bool int, int, int *);
16003 void vec_vsx_st (vector signed short, int, vector signed short *);
16004 void vec_vsx_st (vector signed short, int, short *);
16005 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
16006 void vec_vsx_st (vector unsigned short, int, unsigned short *);
16007 void vec_vsx_st (vector bool short, int, vector bool short *);
16008 void vec_vsx_st (vector bool short, int, unsigned short *);
16009 void vec_vsx_st (vector pixel, int, vector pixel *);
16010 void vec_vsx_st (vector pixel, int, unsigned short *);
16011 void vec_vsx_st (vector pixel, int, short *);
16012 void vec_vsx_st (vector bool short, int, short *);
16013 void vec_vsx_st (vector signed char, int, vector signed char *);
16014 void vec_vsx_st (vector signed char, int, signed char *);
16015 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16016 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16017 void vec_vsx_st (vector bool char, int, vector bool char *);
16018 void vec_vsx_st (vector bool char, int, unsigned char *);
16019 void vec_vsx_st (vector bool char, int, signed char *);
16020
16021 vector double vec_xxpermdi (vector double, vector double, int);
16022 vector float vec_xxpermdi (vector float, vector float, int);
16023 vector long long vec_xxpermdi (vector long long, vector long long, int);
16024 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16025 vector unsigned long long, int);
16026 vector int vec_xxpermdi (vector int, vector int, int);
16027 vector unsigned int vec_xxpermdi (vector unsigned int,
16028 vector unsigned int, int);
16029 vector short vec_xxpermdi (vector short, vector short, int);
16030 vector unsigned short vec_xxpermdi (vector unsigned short,
16031 vector unsigned short, int);
16032 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16033 vector unsigned char vec_xxpermdi (vector unsigned char,
16034 vector unsigned char, int);
16035
16036 vector double vec_xxsldi (vector double, vector double, int);
16037 vector float vec_xxsldi (vector float, vector float, int);
16038 vector long long vec_xxsldi (vector long long, vector long long, int);
16039 vector unsigned long long vec_xxsldi (vector unsigned long long,
16040 vector unsigned long long, int);
16041 vector int vec_xxsldi (vector int, vector int, int);
16042 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16043 vector short vec_xxsldi (vector short, vector short, int);
16044 vector unsigned short vec_xxsldi (vector unsigned short,
16045 vector unsigned short, int);
16046 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16047 vector unsigned char vec_xxsldi (vector unsigned char,
16048 vector unsigned char, int);
16049 @end smallexample
16050
16051 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16052 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16053 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16054 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16055 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16056
16057 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16058 instruction set is available, the following additional functions are
16059 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16060 can use @var{vector long} instead of @var{vector long long},
16061 @var{vector bool long} instead of @var{vector bool long long}, and
16062 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16063
16064 @smallexample
16065 vector long long vec_abs (vector long long);
16066
16067 vector long long vec_add (vector long long, vector long long);
16068 vector unsigned long long vec_add (vector unsigned long long,
16069 vector unsigned long long);
16070
16071 int vec_all_eq (vector long long, vector long long);
16072 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16073 int vec_all_ge (vector long long, vector long long);
16074 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16075 int vec_all_gt (vector long long, vector long long);
16076 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16077 int vec_all_le (vector long long, vector long long);
16078 int vec_all_le (vector unsigned long long, vector unsigned long long);
16079 int vec_all_lt (vector long long, vector long long);
16080 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16081 int vec_all_ne (vector long long, vector long long);
16082 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16083
16084 int vec_any_eq (vector long long, vector long long);
16085 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16086 int vec_any_ge (vector long long, vector long long);
16087 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16088 int vec_any_gt (vector long long, vector long long);
16089 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16090 int vec_any_le (vector long long, vector long long);
16091 int vec_any_le (vector unsigned long long, vector unsigned long long);
16092 int vec_any_lt (vector long long, vector long long);
16093 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16094 int vec_any_ne (vector long long, vector long long);
16095 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16096
16097 vector long long vec_eqv (vector long long, vector long long);
16098 vector long long vec_eqv (vector bool long long, vector long long);
16099 vector long long vec_eqv (vector long long, vector bool long long);
16100 vector unsigned long long vec_eqv (vector unsigned long long,
16101 vector unsigned long long);
16102 vector unsigned long long vec_eqv (vector bool long long,
16103 vector unsigned long long);
16104 vector unsigned long long vec_eqv (vector unsigned long long,
16105 vector bool long long);
16106 vector int vec_eqv (vector int, vector int);
16107 vector int vec_eqv (vector bool int, vector int);
16108 vector int vec_eqv (vector int, vector bool int);
16109 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16110 vector unsigned int vec_eqv (vector bool unsigned int,
16111 vector unsigned int);
16112 vector unsigned int vec_eqv (vector unsigned int,
16113 vector bool unsigned int);
16114 vector short vec_eqv (vector short, vector short);
16115 vector short vec_eqv (vector bool short, vector short);
16116 vector short vec_eqv (vector short, vector bool short);
16117 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16118 vector unsigned short vec_eqv (vector bool unsigned short,
16119 vector unsigned short);
16120 vector unsigned short vec_eqv (vector unsigned short,
16121 vector bool unsigned short);
16122 vector signed char vec_eqv (vector signed char, vector signed char);
16123 vector signed char vec_eqv (vector bool signed char, vector signed char);
16124 vector signed char vec_eqv (vector signed char, vector bool signed char);
16125 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16126 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16127 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16128
16129 vector long long vec_max (vector long long, vector long long);
16130 vector unsigned long long vec_max (vector unsigned long long,
16131 vector unsigned long long);
16132
16133 vector signed int vec_mergee (vector signed int, vector signed int);
16134 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16135 vector bool int vec_mergee (vector bool int, vector bool int);
16136
16137 vector signed int vec_mergeo (vector signed int, vector signed int);
16138 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16139 vector bool int vec_mergeo (vector bool int, vector bool int);
16140
16141 vector long long vec_min (vector long long, vector long long);
16142 vector unsigned long long vec_min (vector unsigned long long,
16143 vector unsigned long long);
16144
16145 vector long long vec_nand (vector long long, vector long long);
16146 vector long long vec_nand (vector bool long long, vector long long);
16147 vector long long vec_nand (vector long long, vector bool long long);
16148 vector unsigned long long vec_nand (vector unsigned long long,
16149 vector unsigned long long);
16150 vector unsigned long long vec_nand (vector bool long long,
16151 vector unsigned long long);
16152 vector unsigned long long vec_nand (vector unsigned long long,
16153 vector bool long long);
16154 vector int vec_nand (vector int, vector int);
16155 vector int vec_nand (vector bool int, vector int);
16156 vector int vec_nand (vector int, vector bool int);
16157 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16158 vector unsigned int vec_nand (vector bool unsigned int,
16159 vector unsigned int);
16160 vector unsigned int vec_nand (vector unsigned int,
16161 vector bool unsigned int);
16162 vector short vec_nand (vector short, vector short);
16163 vector short vec_nand (vector bool short, vector short);
16164 vector short vec_nand (vector short, vector bool short);
16165 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16166 vector unsigned short vec_nand (vector bool unsigned short,
16167 vector unsigned short);
16168 vector unsigned short vec_nand (vector unsigned short,
16169 vector bool unsigned short);
16170 vector signed char vec_nand (vector signed char, vector signed char);
16171 vector signed char vec_nand (vector bool signed char, vector signed char);
16172 vector signed char vec_nand (vector signed char, vector bool signed char);
16173 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16174 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16175 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16176
16177 vector long long vec_orc (vector long long, vector long long);
16178 vector long long vec_orc (vector bool long long, vector long long);
16179 vector long long vec_orc (vector long long, vector bool long long);
16180 vector unsigned long long vec_orc (vector unsigned long long,
16181 vector unsigned long long);
16182 vector unsigned long long vec_orc (vector bool long long,
16183 vector unsigned long long);
16184 vector unsigned long long vec_orc (vector unsigned long long,
16185 vector bool long long);
16186 vector int vec_orc (vector int, vector int);
16187 vector int vec_orc (vector bool int, vector int);
16188 vector int vec_orc (vector int, vector bool int);
16189 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16190 vector unsigned int vec_orc (vector bool unsigned int,
16191 vector unsigned int);
16192 vector unsigned int vec_orc (vector unsigned int,
16193 vector bool unsigned int);
16194 vector short vec_orc (vector short, vector short);
16195 vector short vec_orc (vector bool short, vector short);
16196 vector short vec_orc (vector short, vector bool short);
16197 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16198 vector unsigned short vec_orc (vector bool unsigned short,
16199 vector unsigned short);
16200 vector unsigned short vec_orc (vector unsigned short,
16201 vector bool unsigned short);
16202 vector signed char vec_orc (vector signed char, vector signed char);
16203 vector signed char vec_orc (vector bool signed char, vector signed char);
16204 vector signed char vec_orc (vector signed char, vector bool signed char);
16205 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16206 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16207 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16208
16209 vector int vec_pack (vector long long, vector long long);
16210 vector unsigned int vec_pack (vector unsigned long long,
16211 vector unsigned long long);
16212 vector bool int vec_pack (vector bool long long, vector bool long long);
16213
16214 vector int vec_packs (vector long long, vector long long);
16215 vector unsigned int vec_packs (vector unsigned long long,
16216 vector unsigned long long);
16217
16218 vector unsigned int vec_packsu (vector long long, vector long long);
16219 vector unsigned int vec_packsu (vector unsigned long long,
16220 vector unsigned long long);
16221
16222 vector long long vec_rl (vector long long,
16223 vector unsigned long long);
16224 vector long long vec_rl (vector unsigned long long,
16225 vector unsigned long long);
16226
16227 vector long long vec_sl (vector long long, vector unsigned long long);
16228 vector long long vec_sl (vector unsigned long long,
16229 vector unsigned long long);
16230
16231 vector long long vec_sr (vector long long, vector unsigned long long);
16232 vector unsigned long long char vec_sr (vector unsigned long long,
16233 vector unsigned long long);
16234
16235 vector long long vec_sra (vector long long, vector unsigned long long);
16236 vector unsigned long long vec_sra (vector unsigned long long,
16237 vector unsigned long long);
16238
16239 vector long long vec_sub (vector long long, vector long long);
16240 vector unsigned long long vec_sub (vector unsigned long long,
16241 vector unsigned long long);
16242
16243 vector long long vec_unpackh (vector int);
16244 vector unsigned long long vec_unpackh (vector unsigned int);
16245
16246 vector long long vec_unpackl (vector int);
16247 vector unsigned long long vec_unpackl (vector unsigned int);
16248
16249 vector long long vec_vaddudm (vector long long, vector long long);
16250 vector long long vec_vaddudm (vector bool long long, vector long long);
16251 vector long long vec_vaddudm (vector long long, vector bool long long);
16252 vector unsigned long long vec_vaddudm (vector unsigned long long,
16253 vector unsigned long long);
16254 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16255 vector unsigned long long);
16256 vector unsigned long long vec_vaddudm (vector unsigned long long,
16257 vector bool unsigned long long);
16258
16259 vector long long vec_vbpermq (vector signed char, vector signed char);
16260 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16261
16262 vector long long vec_cntlz (vector long long);
16263 vector unsigned long long vec_cntlz (vector unsigned long long);
16264 vector int vec_cntlz (vector int);
16265 vector unsigned int vec_cntlz (vector int);
16266 vector short vec_cntlz (vector short);
16267 vector unsigned short vec_cntlz (vector unsigned short);
16268 vector signed char vec_cntlz (vector signed char);
16269 vector unsigned char vec_cntlz (vector unsigned char);
16270
16271 vector long long vec_vclz (vector long long);
16272 vector unsigned long long vec_vclz (vector unsigned long long);
16273 vector int vec_vclz (vector int);
16274 vector unsigned int vec_vclz (vector int);
16275 vector short vec_vclz (vector short);
16276 vector unsigned short vec_vclz (vector unsigned short);
16277 vector signed char vec_vclz (vector signed char);
16278 vector unsigned char vec_vclz (vector unsigned char);
16279
16280 vector signed char vec_vclzb (vector signed char);
16281 vector unsigned char vec_vclzb (vector unsigned char);
16282
16283 vector long long vec_vclzd (vector long long);
16284 vector unsigned long long vec_vclzd (vector unsigned long long);
16285
16286 vector short vec_vclzh (vector short);
16287 vector unsigned short vec_vclzh (vector unsigned short);
16288
16289 vector int vec_vclzw (vector int);
16290 vector unsigned int vec_vclzw (vector int);
16291
16292 vector signed char vec_vgbbd (vector signed char);
16293 vector unsigned char vec_vgbbd (vector unsigned char);
16294
16295 vector long long vec_vmaxsd (vector long long, vector long long);
16296
16297 vector unsigned long long vec_vmaxud (vector unsigned long long,
16298 unsigned vector long long);
16299
16300 vector long long vec_vminsd (vector long long, vector long long);
16301
16302 vector unsigned long long vec_vminud (vector long long,
16303 vector long long);
16304
16305 vector int vec_vpksdss (vector long long, vector long long);
16306 vector unsigned int vec_vpksdss (vector long long, vector long long);
16307
16308 vector unsigned int vec_vpkudus (vector unsigned long long,
16309 vector unsigned long long);
16310
16311 vector int vec_vpkudum (vector long long, vector long long);
16312 vector unsigned int vec_vpkudum (vector unsigned long long,
16313 vector unsigned long long);
16314 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16315
16316 vector long long vec_vpopcnt (vector long long);
16317 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16318 vector int vec_vpopcnt (vector int);
16319 vector unsigned int vec_vpopcnt (vector int);
16320 vector short vec_vpopcnt (vector short);
16321 vector unsigned short vec_vpopcnt (vector unsigned short);
16322 vector signed char vec_vpopcnt (vector signed char);
16323 vector unsigned char vec_vpopcnt (vector unsigned char);
16324
16325 vector signed char vec_vpopcntb (vector signed char);
16326 vector unsigned char vec_vpopcntb (vector unsigned char);
16327
16328 vector long long vec_vpopcntd (vector long long);
16329 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16330
16331 vector short vec_vpopcnth (vector short);
16332 vector unsigned short vec_vpopcnth (vector unsigned short);
16333
16334 vector int vec_vpopcntw (vector int);
16335 vector unsigned int vec_vpopcntw (vector int);
16336
16337 vector long long vec_vrld (vector long long, vector unsigned long long);
16338 vector unsigned long long vec_vrld (vector unsigned long long,
16339 vector unsigned long long);
16340
16341 vector long long vec_vsld (vector long long, vector unsigned long long);
16342 vector long long vec_vsld (vector unsigned long long,
16343 vector unsigned long long);
16344
16345 vector long long vec_vsrad (vector long long, vector unsigned long long);
16346 vector unsigned long long vec_vsrad (vector unsigned long long,
16347 vector unsigned long long);
16348
16349 vector long long vec_vsrd (vector long long, vector unsigned long long);
16350 vector unsigned long long char vec_vsrd (vector unsigned long long,
16351 vector unsigned long long);
16352
16353 vector long long vec_vsubudm (vector long long, vector long long);
16354 vector long long vec_vsubudm (vector bool long long, vector long long);
16355 vector long long vec_vsubudm (vector long long, vector bool long long);
16356 vector unsigned long long vec_vsubudm (vector unsigned long long,
16357 vector unsigned long long);
16358 vector unsigned long long vec_vsubudm (vector bool long long,
16359 vector unsigned long long);
16360 vector unsigned long long vec_vsubudm (vector unsigned long long,
16361 vector bool long long);
16362
16363 vector long long vec_vupkhsw (vector int);
16364 vector unsigned long long vec_vupkhsw (vector unsigned int);
16365
16366 vector long long vec_vupklsw (vector int);
16367 vector unsigned long long vec_vupklsw (vector int);
16368 @end smallexample
16369
16370 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16371 instruction set is available, the following additional functions are
16372 available for 64-bit targets. New vector types
16373 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16374 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16375 builtins.
16376
16377 The normal vector extract, and set operations work on
16378 @var{vector __int128_t} and @var{vector __uint128_t} types,
16379 but the index value must be 0.
16380
16381 @smallexample
16382 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16383 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16384
16385 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16386 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16387
16388 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16389 vector __int128_t);
16390 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16391 vector __uint128_t);
16392
16393 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16394 vector __int128_t);
16395 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16396 vector __uint128_t);
16397
16398 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16399 vector __int128_t);
16400 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16401 vector __uint128_t);
16402
16403 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16404 vector __int128_t);
16405 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16406 vector __uint128_t);
16407
16408 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16409 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16410
16411 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16412 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16413
16414 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16415 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16416 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16417 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16418 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16419 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16420 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16421 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16422 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16423 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16424 @end smallexample
16425
16426 If the cryptographic instructions are enabled (@option{-mcrypto} or
16427 @option{-mcpu=power8}), the following builtins are enabled.
16428
16429 @smallexample
16430 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16431
16432 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16433 vector unsigned long long);
16434
16435 vector unsigned long long __builtin_crypto_vcipherlast
16436 (vector unsigned long long,
16437 vector unsigned long long);
16438
16439 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16440 vector unsigned long long);
16441
16442 vector unsigned long long __builtin_crypto_vncipherlast
16443 (vector unsigned long long,
16444 vector unsigned long long);
16445
16446 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16447 vector unsigned char,
16448 vector unsigned char);
16449
16450 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16451 vector unsigned short,
16452 vector unsigned short);
16453
16454 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16455 vector unsigned int,
16456 vector unsigned int);
16457
16458 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16459 vector unsigned long long,
16460 vector unsigned long long);
16461
16462 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16463 vector unsigned char);
16464
16465 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16466 vector unsigned short);
16467
16468 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16469 vector unsigned int);
16470
16471 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16472 vector unsigned long long);
16473
16474 vector unsigned long long __builtin_crypto_vshasigmad
16475 (vector unsigned long long, int, int);
16476
16477 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16478 int, int);
16479 @end smallexample
16480
16481 The second argument to the @var{__builtin_crypto_vshasigmad} and
16482 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16483 integer that is 0 or 1. The third argument to these builtin functions
16484 must be a constant integer in the range of 0 to 15.
16485
16486 @node PowerPC Hardware Transactional Memory Built-in Functions
16487 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16488 GCC provides two interfaces for accessing the Hardware Transactional
16489 Memory (HTM) instructions available on some of the PowerPC family
16490 of processors (eg, POWER8). The two interfaces come in a low level
16491 interface, consisting of built-in functions specific to PowerPC and a
16492 higher level interface consisting of inline functions that are common
16493 between PowerPC and S/390.
16494
16495 @subsubsection PowerPC HTM Low Level Built-in Functions
16496
16497 The following low level built-in functions are available with
16498 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16499 They all generate the machine instruction that is part of the name.
16500
16501 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16502 the full 4-bit condition register value set by their associated hardware
16503 instruction. The header file @code{htmintrin.h} defines some macros that can
16504 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16505 returns a simple true or false value depending on whether a transaction was
16506 successfully started or not. The arguments of the builtins match exactly the
16507 type and order of the associated hardware instruction's operands, except for
16508 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16509 Refer to the ISA manual for a description of each instruction's operands.
16510
16511 @smallexample
16512 unsigned int __builtin_tbegin (unsigned int)
16513 unsigned int __builtin_tend (unsigned int)
16514
16515 unsigned int __builtin_tabort (unsigned int)
16516 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16517 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16518 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16519 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16520
16521 unsigned int __builtin_tcheck (void)
16522 unsigned int __builtin_treclaim (unsigned int)
16523 unsigned int __builtin_trechkpt (void)
16524 unsigned int __builtin_tsr (unsigned int)
16525 @end smallexample
16526
16527 In addition to the above HTM built-ins, we have added built-ins for
16528 some common extended mnemonics of the HTM instructions:
16529
16530 @smallexample
16531 unsigned int __builtin_tendall (void)
16532 unsigned int __builtin_tresume (void)
16533 unsigned int __builtin_tsuspend (void)
16534 @end smallexample
16535
16536 Note that the semantics of the above HTM builtins are required to mimic
16537 the locking semantics used for critical sections. Builtins that are used
16538 to create a new transaction or restart a suspended transaction must have
16539 lock acquisition like semantics while those builtins that end or suspend a
16540 transaction must have lock release like semantics. Specifically, this must
16541 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16542 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16543 that returns 0, and lock release is as-if an execution of
16544 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16545 implicit implementation-defined lock used for all transactions. The HTM
16546 instructions associated with with the builtins inherently provide the
16547 correct acquisition and release hardware barriers required. However,
16548 the compiler must also be prohibited from moving loads and stores across
16549 the builtins in a way that would violate their semantics. This has been
16550 accomplished by adding memory barriers to the associated HTM instructions
16551 (which is a conservative approach to provide acquire and release semantics).
16552 Earlier versions of the compiler did not treat the HTM instructions as
16553 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16554 be used to determine whether the current compiler treats HTM instructions
16555 as memory barriers or not. This allows the user to explicitly add memory
16556 barriers to their code when using an older version of the compiler.
16557
16558 The following set of built-in functions are available to gain access
16559 to the HTM specific special purpose registers.
16560
16561 @smallexample
16562 unsigned long __builtin_get_texasr (void)
16563 unsigned long __builtin_get_texasru (void)
16564 unsigned long __builtin_get_tfhar (void)
16565 unsigned long __builtin_get_tfiar (void)
16566
16567 void __builtin_set_texasr (unsigned long);
16568 void __builtin_set_texasru (unsigned long);
16569 void __builtin_set_tfhar (unsigned long);
16570 void __builtin_set_tfiar (unsigned long);
16571 @end smallexample
16572
16573 Example usage of these low level built-in functions may look like:
16574
16575 @smallexample
16576 #include <htmintrin.h>
16577
16578 int num_retries = 10;
16579
16580 while (1)
16581 @{
16582 if (__builtin_tbegin (0))
16583 @{
16584 /* Transaction State Initiated. */
16585 if (is_locked (lock))
16586 __builtin_tabort (0);
16587 ... transaction code...
16588 __builtin_tend (0);
16589 break;
16590 @}
16591 else
16592 @{
16593 /* Transaction State Failed. Use locks if the transaction
16594 failure is "persistent" or we've tried too many times. */
16595 if (num_retries-- <= 0
16596 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16597 @{
16598 acquire_lock (lock);
16599 ... non transactional fallback path...
16600 release_lock (lock);
16601 break;
16602 @}
16603 @}
16604 @}
16605 @end smallexample
16606
16607 One final built-in function has been added that returns the value of
16608 the 2-bit Transaction State field of the Machine Status Register (MSR)
16609 as stored in @code{CR0}.
16610
16611 @smallexample
16612 unsigned long __builtin_ttest (void)
16613 @end smallexample
16614
16615 This built-in can be used to determine the current transaction state
16616 using the following code example:
16617
16618 @smallexample
16619 #include <htmintrin.h>
16620
16621 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16622
16623 if (tx_state == _HTM_TRANSACTIONAL)
16624 @{
16625 /* Code to use in transactional state. */
16626 @}
16627 else if (tx_state == _HTM_NONTRANSACTIONAL)
16628 @{
16629 /* Code to use in non-transactional state. */
16630 @}
16631 else if (tx_state == _HTM_SUSPENDED)
16632 @{
16633 /* Code to use in transaction suspended state. */
16634 @}
16635 @end smallexample
16636
16637 @subsubsection PowerPC HTM High Level Inline Functions
16638
16639 The following high level HTM interface is made available by including
16640 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16641 where CPU is `power8' or later. This interface is common between PowerPC
16642 and S/390, allowing users to write one HTM source implementation that
16643 can be compiled and executed on either system.
16644
16645 @smallexample
16646 long __TM_simple_begin (void)
16647 long __TM_begin (void* const TM_buff)
16648 long __TM_end (void)
16649 void __TM_abort (void)
16650 void __TM_named_abort (unsigned char const code)
16651 void __TM_resume (void)
16652 void __TM_suspend (void)
16653
16654 long __TM_is_user_abort (void* const TM_buff)
16655 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16656 long __TM_is_illegal (void* const TM_buff)
16657 long __TM_is_footprint_exceeded (void* const TM_buff)
16658 long __TM_nesting_depth (void* const TM_buff)
16659 long __TM_is_nested_too_deep(void* const TM_buff)
16660 long __TM_is_conflict(void* const TM_buff)
16661 long __TM_is_failure_persistent(void* const TM_buff)
16662 long __TM_failure_address(void* const TM_buff)
16663 long long __TM_failure_code(void* const TM_buff)
16664 @end smallexample
16665
16666 Using these common set of HTM inline functions, we can create
16667 a more portable version of the HTM example in the previous
16668 section that will work on either PowerPC or S/390:
16669
16670 @smallexample
16671 #include <htmxlintrin.h>
16672
16673 int num_retries = 10;
16674 TM_buff_type TM_buff;
16675
16676 while (1)
16677 @{
16678 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16679 @{
16680 /* Transaction State Initiated. */
16681 if (is_locked (lock))
16682 __TM_abort ();
16683 ... transaction code...
16684 __TM_end ();
16685 break;
16686 @}
16687 else
16688 @{
16689 /* Transaction State Failed. Use locks if the transaction
16690 failure is "persistent" or we've tried too many times. */
16691 if (num_retries-- <= 0
16692 || __TM_is_failure_persistent (TM_buff))
16693 @{
16694 acquire_lock (lock);
16695 ... non transactional fallback path...
16696 release_lock (lock);
16697 break;
16698 @}
16699 @}
16700 @}
16701 @end smallexample
16702
16703 @node RX Built-in Functions
16704 @subsection RX Built-in Functions
16705 GCC supports some of the RX instructions which cannot be expressed in
16706 the C programming language via the use of built-in functions. The
16707 following functions are supported:
16708
16709 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16710 Generates the @code{brk} machine instruction.
16711 @end deftypefn
16712
16713 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16714 Generates the @code{clrpsw} machine instruction to clear the specified
16715 bit in the processor status word.
16716 @end deftypefn
16717
16718 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16719 Generates the @code{int} machine instruction to generate an interrupt
16720 with the specified value.
16721 @end deftypefn
16722
16723 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16724 Generates the @code{machi} machine instruction to add the result of
16725 multiplying the top 16 bits of the two arguments into the
16726 accumulator.
16727 @end deftypefn
16728
16729 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16730 Generates the @code{maclo} machine instruction to add the result of
16731 multiplying the bottom 16 bits of the two arguments into the
16732 accumulator.
16733 @end deftypefn
16734
16735 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16736 Generates the @code{mulhi} machine instruction to place the result of
16737 multiplying the top 16 bits of the two arguments into the
16738 accumulator.
16739 @end deftypefn
16740
16741 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16742 Generates the @code{mullo} machine instruction to place the result of
16743 multiplying the bottom 16 bits of the two arguments into the
16744 accumulator.
16745 @end deftypefn
16746
16747 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16748 Generates the @code{mvfachi} machine instruction to read the top
16749 32 bits of the accumulator.
16750 @end deftypefn
16751
16752 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16753 Generates the @code{mvfacmi} machine instruction to read the middle
16754 32 bits of the accumulator.
16755 @end deftypefn
16756
16757 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16758 Generates the @code{mvfc} machine instruction which reads the control
16759 register specified in its argument and returns its value.
16760 @end deftypefn
16761
16762 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16763 Generates the @code{mvtachi} machine instruction to set the top
16764 32 bits of the accumulator.
16765 @end deftypefn
16766
16767 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16768 Generates the @code{mvtaclo} machine instruction to set the bottom
16769 32 bits of the accumulator.
16770 @end deftypefn
16771
16772 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16773 Generates the @code{mvtc} machine instruction which sets control
16774 register number @code{reg} to @code{val}.
16775 @end deftypefn
16776
16777 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16778 Generates the @code{mvtipl} machine instruction set the interrupt
16779 priority level.
16780 @end deftypefn
16781
16782 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16783 Generates the @code{racw} machine instruction to round the accumulator
16784 according to the specified mode.
16785 @end deftypefn
16786
16787 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16788 Generates the @code{revw} machine instruction which swaps the bytes in
16789 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16790 and also bits 16--23 occupy bits 24--31 and vice versa.
16791 @end deftypefn
16792
16793 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16794 Generates the @code{rmpa} machine instruction which initiates a
16795 repeated multiply and accumulate sequence.
16796 @end deftypefn
16797
16798 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16799 Generates the @code{round} machine instruction which returns the
16800 floating-point argument rounded according to the current rounding mode
16801 set in the floating-point status word register.
16802 @end deftypefn
16803
16804 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16805 Generates the @code{sat} machine instruction which returns the
16806 saturated value of the argument.
16807 @end deftypefn
16808
16809 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16810 Generates the @code{setpsw} machine instruction to set the specified
16811 bit in the processor status word.
16812 @end deftypefn
16813
16814 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16815 Generates the @code{wait} machine instruction.
16816 @end deftypefn
16817
16818 @node S/390 System z Built-in Functions
16819 @subsection S/390 System z Built-in Functions
16820 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16821 Generates the @code{tbegin} machine instruction starting a
16822 non-constrained hardware transaction. If the parameter is non-NULL the
16823 memory area is used to store the transaction diagnostic buffer and
16824 will be passed as first operand to @code{tbegin}. This buffer can be
16825 defined using the @code{struct __htm_tdb} C struct defined in
16826 @code{htmintrin.h} and must reside on a double-word boundary. The
16827 second tbegin operand is set to @code{0xff0c}. This enables
16828 save/restore of all GPRs and disables aborts for FPR and AR
16829 manipulations inside the transaction body. The condition code set by
16830 the tbegin instruction is returned as integer value. The tbegin
16831 instruction by definition overwrites the content of all FPRs. The
16832 compiler will generate code which saves and restores the FPRs. For
16833 soft-float code it is recommended to used the @code{*_nofloat}
16834 variant. In order to prevent a TDB from being written it is required
16835 to pass a constant zero value as parameter. Passing a zero value
16836 through a variable is not sufficient. Although modifications of
16837 access registers inside the transaction will not trigger an
16838 transaction abort it is not supported to actually modify them. Access
16839 registers do not get saved when entering a transaction. They will have
16840 undefined state when reaching the abort code.
16841 @end deftypefn
16842
16843 Macros for the possible return codes of tbegin are defined in the
16844 @code{htmintrin.h} header file:
16845
16846 @table @code
16847 @item _HTM_TBEGIN_STARTED
16848 @code{tbegin} has been executed as part of normal processing. The
16849 transaction body is supposed to be executed.
16850 @item _HTM_TBEGIN_INDETERMINATE
16851 The transaction was aborted due to an indeterminate condition which
16852 might be persistent.
16853 @item _HTM_TBEGIN_TRANSIENT
16854 The transaction aborted due to a transient failure. The transaction
16855 should be re-executed in that case.
16856 @item _HTM_TBEGIN_PERSISTENT
16857 The transaction aborted due to a persistent failure. Re-execution
16858 under same circumstances will not be productive.
16859 @end table
16860
16861 @defmac _HTM_FIRST_USER_ABORT_CODE
16862 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16863 specifies the first abort code which can be used for
16864 @code{__builtin_tabort}. Values below this threshold are reserved for
16865 machine use.
16866 @end defmac
16867
16868 @deftp {Data type} {struct __htm_tdb}
16869 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16870 the structure of the transaction diagnostic block as specified in the
16871 Principles of Operation manual chapter 5-91.
16872 @end deftp
16873
16874 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16875 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16876 Using this variant in code making use of FPRs will leave the FPRs in
16877 undefined state when entering the transaction abort handler code.
16878 @end deftypefn
16879
16880 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16881 In addition to @code{__builtin_tbegin} a loop for transient failures
16882 is generated. If tbegin returns a condition code of 2 the transaction
16883 will be retried as often as specified in the second argument. The
16884 perform processor assist instruction is used to tell the CPU about the
16885 number of fails so far.
16886 @end deftypefn
16887
16888 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16889 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16890 restores. Using this variant in code making use of FPRs will leave
16891 the FPRs in undefined state when entering the transaction abort
16892 handler code.
16893 @end deftypefn
16894
16895 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16896 Generates the @code{tbeginc} machine instruction starting a constrained
16897 hardware transaction. The second operand is set to @code{0xff08}.
16898 @end deftypefn
16899
16900 @deftypefn {Built-in Function} int __builtin_tend (void)
16901 Generates the @code{tend} machine instruction finishing a transaction
16902 and making the changes visible to other threads. The condition code
16903 generated by tend is returned as integer value.
16904 @end deftypefn
16905
16906 @deftypefn {Built-in Function} void __builtin_tabort (int)
16907 Generates the @code{tabort} machine instruction with the specified
16908 abort code. Abort codes from 0 through 255 are reserved and will
16909 result in an error message.
16910 @end deftypefn
16911
16912 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16913 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16914 integer parameter is loaded into rX and a value of zero is loaded into
16915 rY. The integer parameter specifies the number of times the
16916 transaction repeatedly aborted.
16917 @end deftypefn
16918
16919 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16920 Generates the @code{etnd} machine instruction. The current nesting
16921 depth is returned as integer value. For a nesting depth of 0 the code
16922 is not executed as part of an transaction.
16923 @end deftypefn
16924
16925 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16926
16927 Generates the @code{ntstg} machine instruction. The second argument
16928 is written to the first arguments location. The store operation will
16929 not be rolled-back in case of an transaction abort.
16930 @end deftypefn
16931
16932 @node SH Built-in Functions
16933 @subsection SH Built-in Functions
16934 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16935 families of processors:
16936
16937 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16938 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16939 used by system code that manages threads and execution contexts. The compiler
16940 normally does not generate code that modifies the contents of @samp{GBR} and
16941 thus the value is preserved across function calls. Changing the @samp{GBR}
16942 value in user code must be done with caution, since the compiler might use
16943 @samp{GBR} in order to access thread local variables.
16944
16945 @end deftypefn
16946
16947 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16948 Returns the value that is currently set in the @samp{GBR} register.
16949 Memory loads and stores that use the thread pointer as a base address are
16950 turned into @samp{GBR} based displacement loads and stores, if possible.
16951 For example:
16952 @smallexample
16953 struct my_tcb
16954 @{
16955 int a, b, c, d, e;
16956 @};
16957
16958 int get_tcb_value (void)
16959 @{
16960 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16961 return ((my_tcb*)__builtin_thread_pointer ())->c;
16962 @}
16963
16964 @end smallexample
16965 @end deftypefn
16966
16967 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16968 Returns the value that is currently set in the @samp{FPSCR} register.
16969 @end deftypefn
16970
16971 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16972 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16973 preserving the current values of the FR, SZ and PR bits.
16974 @end deftypefn
16975
16976 @node SPARC VIS Built-in Functions
16977 @subsection SPARC VIS Built-in Functions
16978
16979 GCC supports SIMD operations on the SPARC using both the generic vector
16980 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16981 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16982 switch, the VIS extension is exposed as the following built-in functions:
16983
16984 @smallexample
16985 typedef int v1si __attribute__ ((vector_size (4)));
16986 typedef int v2si __attribute__ ((vector_size (8)));
16987 typedef short v4hi __attribute__ ((vector_size (8)));
16988 typedef short v2hi __attribute__ ((vector_size (4)));
16989 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16990 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16991
16992 void __builtin_vis_write_gsr (int64_t);
16993 int64_t __builtin_vis_read_gsr (void);
16994
16995 void * __builtin_vis_alignaddr (void *, long);
16996 void * __builtin_vis_alignaddrl (void *, long);
16997 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16998 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16999 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
17000 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
17001
17002 v4hi __builtin_vis_fexpand (v4qi);
17003
17004 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
17005 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
17006 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
17007 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
17008 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
17009 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
17010 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
17011
17012 v4qi __builtin_vis_fpack16 (v4hi);
17013 v8qi __builtin_vis_fpack32 (v2si, v8qi);
17014 v2hi __builtin_vis_fpackfix (v2si);
17015 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
17016
17017 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
17018
17019 long __builtin_vis_edge8 (void *, void *);
17020 long __builtin_vis_edge8l (void *, void *);
17021 long __builtin_vis_edge16 (void *, void *);
17022 long __builtin_vis_edge16l (void *, void *);
17023 long __builtin_vis_edge32 (void *, void *);
17024 long __builtin_vis_edge32l (void *, void *);
17025
17026 long __builtin_vis_fcmple16 (v4hi, v4hi);
17027 long __builtin_vis_fcmple32 (v2si, v2si);
17028 long __builtin_vis_fcmpne16 (v4hi, v4hi);
17029 long __builtin_vis_fcmpne32 (v2si, v2si);
17030 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
17031 long __builtin_vis_fcmpgt32 (v2si, v2si);
17032 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
17033 long __builtin_vis_fcmpeq32 (v2si, v2si);
17034
17035 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
17036 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
17037 v2si __builtin_vis_fpadd32 (v2si, v2si);
17038 v1si __builtin_vis_fpadd32s (v1si, v1si);
17039 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17040 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17041 v2si __builtin_vis_fpsub32 (v2si, v2si);
17042 v1si __builtin_vis_fpsub32s (v1si, v1si);
17043
17044 long __builtin_vis_array8 (long, long);
17045 long __builtin_vis_array16 (long, long);
17046 long __builtin_vis_array32 (long, long);
17047 @end smallexample
17048
17049 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17050 functions also become available:
17051
17052 @smallexample
17053 long __builtin_vis_bmask (long, long);
17054 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17055 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17056 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17057 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17058
17059 long __builtin_vis_edge8n (void *, void *);
17060 long __builtin_vis_edge8ln (void *, void *);
17061 long __builtin_vis_edge16n (void *, void *);
17062 long __builtin_vis_edge16ln (void *, void *);
17063 long __builtin_vis_edge32n (void *, void *);
17064 long __builtin_vis_edge32ln (void *, void *);
17065 @end smallexample
17066
17067 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17068 functions also become available:
17069
17070 @smallexample
17071 void __builtin_vis_cmask8 (long);
17072 void __builtin_vis_cmask16 (long);
17073 void __builtin_vis_cmask32 (long);
17074
17075 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17076
17077 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17078 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17079 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17080 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17081 v2si __builtin_vis_fsll16 (v2si, v2si);
17082 v2si __builtin_vis_fslas16 (v2si, v2si);
17083 v2si __builtin_vis_fsrl16 (v2si, v2si);
17084 v2si __builtin_vis_fsra16 (v2si, v2si);
17085
17086 long __builtin_vis_pdistn (v8qi, v8qi);
17087
17088 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17089
17090 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17091 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17092
17093 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17094 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17095 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17096 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17097 v2si __builtin_vis_fpadds32 (v2si, v2si);
17098 v1si __builtin_vis_fpadds32s (v1si, v1si);
17099 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17100 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17101
17102 long __builtin_vis_fucmple8 (v8qi, v8qi);
17103 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17104 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17105 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17106
17107 float __builtin_vis_fhadds (float, float);
17108 double __builtin_vis_fhaddd (double, double);
17109 float __builtin_vis_fhsubs (float, float);
17110 double __builtin_vis_fhsubd (double, double);
17111 float __builtin_vis_fnhadds (float, float);
17112 double __builtin_vis_fnhaddd (double, double);
17113
17114 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17115 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17116 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17117 @end smallexample
17118
17119 @node SPU Built-in Functions
17120 @subsection SPU Built-in Functions
17121
17122 GCC provides extensions for the SPU processor as described in the
17123 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17124 found at @uref{http://cell.scei.co.jp/} or
17125 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
17126 implementation differs in several ways.
17127
17128 @itemize @bullet
17129
17130 @item
17131 The optional extension of specifying vector constants in parentheses is
17132 not supported.
17133
17134 @item
17135 A vector initializer requires no cast if the vector constant is of the
17136 same type as the variable it is initializing.
17137
17138 @item
17139 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17140 vector type is the default signedness of the base type. The default
17141 varies depending on the operating system, so a portable program should
17142 always specify the signedness.
17143
17144 @item
17145 By default, the keyword @code{__vector} is added. The macro
17146 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17147 undefined.
17148
17149 @item
17150 GCC allows using a @code{typedef} name as the type specifier for a
17151 vector type.
17152
17153 @item
17154 For C, overloaded functions are implemented with macros so the following
17155 does not work:
17156
17157 @smallexample
17158 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17159 @end smallexample
17160
17161 @noindent
17162 Since @code{spu_add} is a macro, the vector constant in the example
17163 is treated as four separate arguments. Wrap the entire argument in
17164 parentheses for this to work.
17165
17166 @item
17167 The extended version of @code{__builtin_expect} is not supported.
17168
17169 @end itemize
17170
17171 @emph{Note:} Only the interface described in the aforementioned
17172 specification is supported. Internally, GCC uses built-in functions to
17173 implement the required functionality, but these are not supported and
17174 are subject to change without notice.
17175
17176 @node TI C6X Built-in Functions
17177 @subsection TI C6X Built-in Functions
17178
17179 GCC provides intrinsics to access certain instructions of the TI C6X
17180 processors. These intrinsics, listed below, are available after
17181 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
17182 to C6X instructions.
17183
17184 @smallexample
17185
17186 int _sadd (int, int)
17187 int _ssub (int, int)
17188 int _sadd2 (int, int)
17189 int _ssub2 (int, int)
17190 long long _mpy2 (int, int)
17191 long long _smpy2 (int, int)
17192 int _add4 (int, int)
17193 int _sub4 (int, int)
17194 int _saddu4 (int, int)
17195
17196 int _smpy (int, int)
17197 int _smpyh (int, int)
17198 int _smpyhl (int, int)
17199 int _smpylh (int, int)
17200
17201 int _sshl (int, int)
17202 int _subc (int, int)
17203
17204 int _avg2 (int, int)
17205 int _avgu4 (int, int)
17206
17207 int _clrr (int, int)
17208 int _extr (int, int)
17209 int _extru (int, int)
17210 int _abs (int)
17211 int _abs2 (int)
17212
17213 @end smallexample
17214
17215 @node TILE-Gx Built-in Functions
17216 @subsection TILE-Gx Built-in Functions
17217
17218 GCC provides intrinsics to access every instruction of the TILE-Gx
17219 processor. The intrinsics are of the form:
17220
17221 @smallexample
17222
17223 unsigned long long __insn_@var{op} (...)
17224
17225 @end smallexample
17226
17227 Where @var{op} is the name of the instruction. Refer to the ISA manual
17228 for the complete list of instructions.
17229
17230 GCC also provides intrinsics to directly access the network registers.
17231 The intrinsics are:
17232
17233 @smallexample
17234
17235 unsigned long long __tile_idn0_receive (void)
17236 unsigned long long __tile_idn1_receive (void)
17237 unsigned long long __tile_udn0_receive (void)
17238 unsigned long long __tile_udn1_receive (void)
17239 unsigned long long __tile_udn2_receive (void)
17240 unsigned long long __tile_udn3_receive (void)
17241 void __tile_idn_send (unsigned long long)
17242 void __tile_udn_send (unsigned long long)
17243
17244 @end smallexample
17245
17246 The intrinsic @code{void __tile_network_barrier (void)} is used to
17247 guarantee that no network operations before it are reordered with
17248 those after it.
17249
17250 @node TILEPro Built-in Functions
17251 @subsection TILEPro Built-in Functions
17252
17253 GCC provides intrinsics to access every instruction of the TILEPro
17254 processor. The intrinsics are of the form:
17255
17256 @smallexample
17257
17258 unsigned __insn_@var{op} (...)
17259
17260 @end smallexample
17261
17262 @noindent
17263 where @var{op} is the name of the instruction. Refer to the ISA manual
17264 for the complete list of instructions.
17265
17266 GCC also provides intrinsics to directly access the network registers.
17267 The intrinsics are:
17268
17269 @smallexample
17270
17271 unsigned __tile_idn0_receive (void)
17272 unsigned __tile_idn1_receive (void)
17273 unsigned __tile_sn_receive (void)
17274 unsigned __tile_udn0_receive (void)
17275 unsigned __tile_udn1_receive (void)
17276 unsigned __tile_udn2_receive (void)
17277 unsigned __tile_udn3_receive (void)
17278 void __tile_idn_send (unsigned)
17279 void __tile_sn_send (unsigned)
17280 void __tile_udn_send (unsigned)
17281
17282 @end smallexample
17283
17284 The intrinsic @code{void __tile_network_barrier (void)} is used to
17285 guarantee that no network operations before it are reordered with
17286 those after it.
17287
17288 @node x86 Built-in Functions
17289 @subsection x86 Built-in Functions
17290
17291 These built-in functions are available for the x86-32 and x86-64 family
17292 of computers, depending on the command-line switches used.
17293
17294 If you specify command-line switches such as @option{-msse},
17295 the compiler could use the extended instruction sets even if the built-ins
17296 are not used explicitly in the program. For this reason, applications
17297 that perform run-time CPU detection must compile separate files for each
17298 supported architecture, using the appropriate flags. In particular,
17299 the file containing the CPU detection code should be compiled without
17300 these options.
17301
17302 The following machine modes are available for use with MMX built-in functions
17303 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
17304 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
17305 vector of eight 8-bit integers. Some of the built-in functions operate on
17306 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
17307
17308 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
17309 of two 32-bit floating-point values.
17310
17311 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
17312 floating-point values. Some instructions use a vector of four 32-bit
17313 integers, these use @code{V4SI}. Finally, some instructions operate on an
17314 entire vector register, interpreting it as a 128-bit integer, these use mode
17315 @code{TI}.
17316
17317 In 64-bit mode, the x86-64 family of processors uses additional built-in
17318 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
17319 floating point and @code{TC} 128-bit complex floating-point values.
17320
17321 The following floating-point built-in functions are available in 64-bit
17322 mode. All of them implement the function that is part of the name.
17323
17324 @smallexample
17325 __float128 __builtin_fabsq (__float128)
17326 __float128 __builtin_copysignq (__float128, __float128)
17327 @end smallexample
17328
17329 The following built-in function is always available.
17330
17331 @table @code
17332 @item void __builtin_ia32_pause (void)
17333 Generates the @code{pause} machine instruction with a compiler memory
17334 barrier.
17335 @end table
17336
17337 The following floating-point built-in functions are made available in the
17338 64-bit mode.
17339
17340 @table @code
17341 @item __float128 __builtin_infq (void)
17342 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
17343 @findex __builtin_infq
17344
17345 @item __float128 __builtin_huge_valq (void)
17346 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
17347 @findex __builtin_huge_valq
17348 @end table
17349
17350 The following built-in functions are always available and can be used to
17351 check the target platform type.
17352
17353 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
17354 This function runs the CPU detection code to check the type of CPU and the
17355 features supported. This built-in function needs to be invoked along with the built-in functions
17356 to check CPU type and features, @code{__builtin_cpu_is} and
17357 @code{__builtin_cpu_supports}, only when used in a function that is
17358 executed before any constructors are called. The CPU detection code is
17359 automatically executed in a very high priority constructor.
17360
17361 For example, this function has to be used in @code{ifunc} resolvers that
17362 check for CPU type using the built-in functions @code{__builtin_cpu_is}
17363 and @code{__builtin_cpu_supports}, or in constructors on targets that
17364 don't support constructor priority.
17365 @smallexample
17366
17367 static void (*resolve_memcpy (void)) (void)
17368 @{
17369 // ifunc resolvers fire before constructors, explicitly call the init
17370 // function.
17371 __builtin_cpu_init ();
17372 if (__builtin_cpu_supports ("ssse3"))
17373 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
17374 else
17375 return default_memcpy;
17376 @}
17377
17378 void *memcpy (void *, const void *, size_t)
17379 __attribute__ ((ifunc ("resolve_memcpy")));
17380 @end smallexample
17381
17382 @end deftypefn
17383
17384 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
17385 This function returns a positive integer if the run-time CPU
17386 is of type @var{cpuname}
17387 and returns @code{0} otherwise. The following CPU names can be detected:
17388
17389 @table @samp
17390 @item intel
17391 Intel CPU.
17392
17393 @item atom
17394 Intel Atom CPU.
17395
17396 @item core2
17397 Intel Core 2 CPU.
17398
17399 @item corei7
17400 Intel Core i7 CPU.
17401
17402 @item nehalem
17403 Intel Core i7 Nehalem CPU.
17404
17405 @item westmere
17406 Intel Core i7 Westmere CPU.
17407
17408 @item sandybridge
17409 Intel Core i7 Sandy Bridge CPU.
17410
17411 @item amd
17412 AMD CPU.
17413
17414 @item amdfam10h
17415 AMD Family 10h CPU.
17416
17417 @item barcelona
17418 AMD Family 10h Barcelona CPU.
17419
17420 @item shanghai
17421 AMD Family 10h Shanghai CPU.
17422
17423 @item istanbul
17424 AMD Family 10h Istanbul CPU.
17425
17426 @item btver1
17427 AMD Family 14h CPU.
17428
17429 @item amdfam15h
17430 AMD Family 15h CPU.
17431
17432 @item bdver1
17433 AMD Family 15h Bulldozer version 1.
17434
17435 @item bdver2
17436 AMD Family 15h Bulldozer version 2.
17437
17438 @item bdver3
17439 AMD Family 15h Bulldozer version 3.
17440
17441 @item bdver4
17442 AMD Family 15h Bulldozer version 4.
17443
17444 @item btver2
17445 AMD Family 16h CPU.
17446
17447 @item znver1
17448 AMD Family 17h CPU.
17449 @end table
17450
17451 Here is an example:
17452 @smallexample
17453 if (__builtin_cpu_is ("corei7"))
17454 @{
17455 do_corei7 (); // Core i7 specific implementation.
17456 @}
17457 else
17458 @{
17459 do_generic (); // Generic implementation.
17460 @}
17461 @end smallexample
17462 @end deftypefn
17463
17464 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17465 This function returns a positive integer if the run-time CPU
17466 supports @var{feature}
17467 and returns @code{0} otherwise. The following features can be detected:
17468
17469 @table @samp
17470 @item cmov
17471 CMOV instruction.
17472 @item mmx
17473 MMX instructions.
17474 @item popcnt
17475 POPCNT instruction.
17476 @item sse
17477 SSE instructions.
17478 @item sse2
17479 SSE2 instructions.
17480 @item sse3
17481 SSE3 instructions.
17482 @item ssse3
17483 SSSE3 instructions.
17484 @item sse4.1
17485 SSE4.1 instructions.
17486 @item sse4.2
17487 SSE4.2 instructions.
17488 @item avx
17489 AVX instructions.
17490 @item avx2
17491 AVX2 instructions.
17492 @item avx512f
17493 AVX512F instructions.
17494 @end table
17495
17496 Here is an example:
17497 @smallexample
17498 if (__builtin_cpu_supports ("popcnt"))
17499 @{
17500 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17501 @}
17502 else
17503 @{
17504 count = generic_countbits (n); //generic implementation.
17505 @}
17506 @end smallexample
17507 @end deftypefn
17508
17509
17510 The following built-in functions are made available by @option{-mmmx}.
17511 All of them generate the machine instruction that is part of the name.
17512
17513 @smallexample
17514 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17515 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17516 v2si __builtin_ia32_paddd (v2si, v2si)
17517 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17518 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17519 v2si __builtin_ia32_psubd (v2si, v2si)
17520 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17521 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17522 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17523 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17524 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17525 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17526 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17527 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17528 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17529 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17530 di __builtin_ia32_pand (di, di)
17531 di __builtin_ia32_pandn (di,di)
17532 di __builtin_ia32_por (di, di)
17533 di __builtin_ia32_pxor (di, di)
17534 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17535 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17536 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17537 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17538 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17539 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17540 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17541 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17542 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17543 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17544 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17545 v2si __builtin_ia32_punpckldq (v2si, v2si)
17546 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17547 v4hi __builtin_ia32_packssdw (v2si, v2si)
17548 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17549
17550 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17551 v2si __builtin_ia32_pslld (v2si, v2si)
17552 v1di __builtin_ia32_psllq (v1di, v1di)
17553 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17554 v2si __builtin_ia32_psrld (v2si, v2si)
17555 v1di __builtin_ia32_psrlq (v1di, v1di)
17556 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17557 v2si __builtin_ia32_psrad (v2si, v2si)
17558 v4hi __builtin_ia32_psllwi (v4hi, int)
17559 v2si __builtin_ia32_pslldi (v2si, int)
17560 v1di __builtin_ia32_psllqi (v1di, int)
17561 v4hi __builtin_ia32_psrlwi (v4hi, int)
17562 v2si __builtin_ia32_psrldi (v2si, int)
17563 v1di __builtin_ia32_psrlqi (v1di, int)
17564 v4hi __builtin_ia32_psrawi (v4hi, int)
17565 v2si __builtin_ia32_psradi (v2si, int)
17566
17567 @end smallexample
17568
17569 The following built-in functions are made available either with
17570 @option{-msse}, or with a combination of @option{-m3dnow} and
17571 @option{-march=athlon}. All of them generate the machine
17572 instruction that is part of the name.
17573
17574 @smallexample
17575 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17576 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17577 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17578 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17579 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17580 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17581 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17582 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17583 int __builtin_ia32_pmovmskb (v8qi)
17584 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17585 void __builtin_ia32_movntq (di *, di)
17586 void __builtin_ia32_sfence (void)
17587 @end smallexample
17588
17589 The following built-in functions are available when @option{-msse} is used.
17590 All of them generate the machine instruction that is part of the name.
17591
17592 @smallexample
17593 int __builtin_ia32_comieq (v4sf, v4sf)
17594 int __builtin_ia32_comineq (v4sf, v4sf)
17595 int __builtin_ia32_comilt (v4sf, v4sf)
17596 int __builtin_ia32_comile (v4sf, v4sf)
17597 int __builtin_ia32_comigt (v4sf, v4sf)
17598 int __builtin_ia32_comige (v4sf, v4sf)
17599 int __builtin_ia32_ucomieq (v4sf, v4sf)
17600 int __builtin_ia32_ucomineq (v4sf, v4sf)
17601 int __builtin_ia32_ucomilt (v4sf, v4sf)
17602 int __builtin_ia32_ucomile (v4sf, v4sf)
17603 int __builtin_ia32_ucomigt (v4sf, v4sf)
17604 int __builtin_ia32_ucomige (v4sf, v4sf)
17605 v4sf __builtin_ia32_addps (v4sf, v4sf)
17606 v4sf __builtin_ia32_subps (v4sf, v4sf)
17607 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17608 v4sf __builtin_ia32_divps (v4sf, v4sf)
17609 v4sf __builtin_ia32_addss (v4sf, v4sf)
17610 v4sf __builtin_ia32_subss (v4sf, v4sf)
17611 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17612 v4sf __builtin_ia32_divss (v4sf, v4sf)
17613 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17614 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17615 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17616 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17617 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17618 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17619 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17620 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17621 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17622 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17623 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17624 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17625 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17626 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17627 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17628 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17629 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17630 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17631 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17632 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17633 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17634 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17635 v4sf __builtin_ia32_minps (v4sf, v4sf)
17636 v4sf __builtin_ia32_minss (v4sf, v4sf)
17637 v4sf __builtin_ia32_andps (v4sf, v4sf)
17638 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17639 v4sf __builtin_ia32_orps (v4sf, v4sf)
17640 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17641 v4sf __builtin_ia32_movss (v4sf, v4sf)
17642 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17643 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17644 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17645 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17646 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17647 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17648 v2si __builtin_ia32_cvtps2pi (v4sf)
17649 int __builtin_ia32_cvtss2si (v4sf)
17650 v2si __builtin_ia32_cvttps2pi (v4sf)
17651 int __builtin_ia32_cvttss2si (v4sf)
17652 v4sf __builtin_ia32_rcpps (v4sf)
17653 v4sf __builtin_ia32_rsqrtps (v4sf)
17654 v4sf __builtin_ia32_sqrtps (v4sf)
17655 v4sf __builtin_ia32_rcpss (v4sf)
17656 v4sf __builtin_ia32_rsqrtss (v4sf)
17657 v4sf __builtin_ia32_sqrtss (v4sf)
17658 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17659 void __builtin_ia32_movntps (float *, v4sf)
17660 int __builtin_ia32_movmskps (v4sf)
17661 @end smallexample
17662
17663 The following built-in functions are available when @option{-msse} is used.
17664
17665 @table @code
17666 @item v4sf __builtin_ia32_loadups (float *)
17667 Generates the @code{movups} machine instruction as a load from memory.
17668 @item void __builtin_ia32_storeups (float *, v4sf)
17669 Generates the @code{movups} machine instruction as a store to memory.
17670 @item v4sf __builtin_ia32_loadss (float *)
17671 Generates the @code{movss} machine instruction as a load from memory.
17672 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17673 Generates the @code{movhps} machine instruction as a load from memory.
17674 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17675 Generates the @code{movlps} machine instruction as a load from memory
17676 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17677 Generates the @code{movhps} machine instruction as a store to memory.
17678 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17679 Generates the @code{movlps} machine instruction as a store to memory.
17680 @end table
17681
17682 The following built-in functions are available when @option{-msse2} is used.
17683 All of them generate the machine instruction that is part of the name.
17684
17685 @smallexample
17686 int __builtin_ia32_comisdeq (v2df, v2df)
17687 int __builtin_ia32_comisdlt (v2df, v2df)
17688 int __builtin_ia32_comisdle (v2df, v2df)
17689 int __builtin_ia32_comisdgt (v2df, v2df)
17690 int __builtin_ia32_comisdge (v2df, v2df)
17691 int __builtin_ia32_comisdneq (v2df, v2df)
17692 int __builtin_ia32_ucomisdeq (v2df, v2df)
17693 int __builtin_ia32_ucomisdlt (v2df, v2df)
17694 int __builtin_ia32_ucomisdle (v2df, v2df)
17695 int __builtin_ia32_ucomisdgt (v2df, v2df)
17696 int __builtin_ia32_ucomisdge (v2df, v2df)
17697 int __builtin_ia32_ucomisdneq (v2df, v2df)
17698 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17699 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17700 v2df __builtin_ia32_cmplepd (v2df, v2df)
17701 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17702 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17703 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17704 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17705 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17706 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17707 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17708 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17709 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17710 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17711 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17712 v2df __builtin_ia32_cmplesd (v2df, v2df)
17713 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17714 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17715 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17716 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17717 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17718 v2di __builtin_ia32_paddq (v2di, v2di)
17719 v2di __builtin_ia32_psubq (v2di, v2di)
17720 v2df __builtin_ia32_addpd (v2df, v2df)
17721 v2df __builtin_ia32_subpd (v2df, v2df)
17722 v2df __builtin_ia32_mulpd (v2df, v2df)
17723 v2df __builtin_ia32_divpd (v2df, v2df)
17724 v2df __builtin_ia32_addsd (v2df, v2df)
17725 v2df __builtin_ia32_subsd (v2df, v2df)
17726 v2df __builtin_ia32_mulsd (v2df, v2df)
17727 v2df __builtin_ia32_divsd (v2df, v2df)
17728 v2df __builtin_ia32_minpd (v2df, v2df)
17729 v2df __builtin_ia32_maxpd (v2df, v2df)
17730 v2df __builtin_ia32_minsd (v2df, v2df)
17731 v2df __builtin_ia32_maxsd (v2df, v2df)
17732 v2df __builtin_ia32_andpd (v2df, v2df)
17733 v2df __builtin_ia32_andnpd (v2df, v2df)
17734 v2df __builtin_ia32_orpd (v2df, v2df)
17735 v2df __builtin_ia32_xorpd (v2df, v2df)
17736 v2df __builtin_ia32_movsd (v2df, v2df)
17737 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17738 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17739 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17740 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17741 v4si __builtin_ia32_paddd128 (v4si, v4si)
17742 v2di __builtin_ia32_paddq128 (v2di, v2di)
17743 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17744 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17745 v4si __builtin_ia32_psubd128 (v4si, v4si)
17746 v2di __builtin_ia32_psubq128 (v2di, v2di)
17747 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17748 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17749 v2di __builtin_ia32_pand128 (v2di, v2di)
17750 v2di __builtin_ia32_pandn128 (v2di, v2di)
17751 v2di __builtin_ia32_por128 (v2di, v2di)
17752 v2di __builtin_ia32_pxor128 (v2di, v2di)
17753 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17754 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17755 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17756 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17757 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17758 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17759 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17760 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17761 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17762 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17763 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17764 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17765 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17766 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17767 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17768 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17769 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17770 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17771 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17772 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17773 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17774 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17775 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17776 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17777 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17778 v2df __builtin_ia32_loadupd (double *)
17779 void __builtin_ia32_storeupd (double *, v2df)
17780 v2df __builtin_ia32_loadhpd (v2df, double const *)
17781 v2df __builtin_ia32_loadlpd (v2df, double const *)
17782 int __builtin_ia32_movmskpd (v2df)
17783 int __builtin_ia32_pmovmskb128 (v16qi)
17784 void __builtin_ia32_movnti (int *, int)
17785 void __builtin_ia32_movnti64 (long long int *, long long int)
17786 void __builtin_ia32_movntpd (double *, v2df)
17787 void __builtin_ia32_movntdq (v2df *, v2df)
17788 v4si __builtin_ia32_pshufd (v4si, int)
17789 v8hi __builtin_ia32_pshuflw (v8hi, int)
17790 v8hi __builtin_ia32_pshufhw (v8hi, int)
17791 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17792 v2df __builtin_ia32_sqrtpd (v2df)
17793 v2df __builtin_ia32_sqrtsd (v2df)
17794 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17795 v2df __builtin_ia32_cvtdq2pd (v4si)
17796 v4sf __builtin_ia32_cvtdq2ps (v4si)
17797 v4si __builtin_ia32_cvtpd2dq (v2df)
17798 v2si __builtin_ia32_cvtpd2pi (v2df)
17799 v4sf __builtin_ia32_cvtpd2ps (v2df)
17800 v4si __builtin_ia32_cvttpd2dq (v2df)
17801 v2si __builtin_ia32_cvttpd2pi (v2df)
17802 v2df __builtin_ia32_cvtpi2pd (v2si)
17803 int __builtin_ia32_cvtsd2si (v2df)
17804 int __builtin_ia32_cvttsd2si (v2df)
17805 long long __builtin_ia32_cvtsd2si64 (v2df)
17806 long long __builtin_ia32_cvttsd2si64 (v2df)
17807 v4si __builtin_ia32_cvtps2dq (v4sf)
17808 v2df __builtin_ia32_cvtps2pd (v4sf)
17809 v4si __builtin_ia32_cvttps2dq (v4sf)
17810 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17811 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17812 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17813 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17814 void __builtin_ia32_clflush (const void *)
17815 void __builtin_ia32_lfence (void)
17816 void __builtin_ia32_mfence (void)
17817 v16qi __builtin_ia32_loaddqu (const char *)
17818 void __builtin_ia32_storedqu (char *, v16qi)
17819 v1di __builtin_ia32_pmuludq (v2si, v2si)
17820 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17821 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17822 v4si __builtin_ia32_pslld128 (v4si, v4si)
17823 v2di __builtin_ia32_psllq128 (v2di, v2di)
17824 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17825 v4si __builtin_ia32_psrld128 (v4si, v4si)
17826 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17827 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17828 v4si __builtin_ia32_psrad128 (v4si, v4si)
17829 v2di __builtin_ia32_pslldqi128 (v2di, int)
17830 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17831 v4si __builtin_ia32_pslldi128 (v4si, int)
17832 v2di __builtin_ia32_psllqi128 (v2di, int)
17833 v2di __builtin_ia32_psrldqi128 (v2di, int)
17834 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17835 v4si __builtin_ia32_psrldi128 (v4si, int)
17836 v2di __builtin_ia32_psrlqi128 (v2di, int)
17837 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17838 v4si __builtin_ia32_psradi128 (v4si, int)
17839 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17840 v2di __builtin_ia32_movq128 (v2di)
17841 @end smallexample
17842
17843 The following built-in functions are available when @option{-msse3} is used.
17844 All of them generate the machine instruction that is part of the name.
17845
17846 @smallexample
17847 v2df __builtin_ia32_addsubpd (v2df, v2df)
17848 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17849 v2df __builtin_ia32_haddpd (v2df, v2df)
17850 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17851 v2df __builtin_ia32_hsubpd (v2df, v2df)
17852 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17853 v16qi __builtin_ia32_lddqu (char const *)
17854 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17855 v4sf __builtin_ia32_movshdup (v4sf)
17856 v4sf __builtin_ia32_movsldup (v4sf)
17857 void __builtin_ia32_mwait (unsigned int, unsigned int)
17858 @end smallexample
17859
17860 The following built-in functions are available when @option{-mssse3} is used.
17861 All of them generate the machine instruction that is part of the name.
17862
17863 @smallexample
17864 v2si __builtin_ia32_phaddd (v2si, v2si)
17865 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17866 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17867 v2si __builtin_ia32_phsubd (v2si, v2si)
17868 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17869 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17870 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17871 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17872 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17873 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17874 v2si __builtin_ia32_psignd (v2si, v2si)
17875 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17876 v1di __builtin_ia32_palignr (v1di, v1di, int)
17877 v8qi __builtin_ia32_pabsb (v8qi)
17878 v2si __builtin_ia32_pabsd (v2si)
17879 v4hi __builtin_ia32_pabsw (v4hi)
17880 @end smallexample
17881
17882 The following built-in functions are available when @option{-mssse3} is used.
17883 All of them generate the machine instruction that is part of the name.
17884
17885 @smallexample
17886 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17887 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17888 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17889 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17890 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17891 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17892 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17893 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17894 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17895 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17896 v4si __builtin_ia32_psignd128 (v4si, v4si)
17897 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17898 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17899 v16qi __builtin_ia32_pabsb128 (v16qi)
17900 v4si __builtin_ia32_pabsd128 (v4si)
17901 v8hi __builtin_ia32_pabsw128 (v8hi)
17902 @end smallexample
17903
17904 The following built-in functions are available when @option{-msse4.1} is
17905 used. All of them generate the machine instruction that is part of the
17906 name.
17907
17908 @smallexample
17909 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17910 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17911 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17912 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17913 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17914 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17915 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17916 v2di __builtin_ia32_movntdqa (v2di *);
17917 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17918 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17919 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17920 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17921 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17922 v8hi __builtin_ia32_phminposuw128 (v8hi)
17923 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17924 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17925 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17926 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17927 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17928 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17929 v4si __builtin_ia32_pminud128 (v4si, v4si)
17930 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17931 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17932 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17933 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17934 v2di __builtin_ia32_pmovsxdq128 (v4si)
17935 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17936 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17937 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17938 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17939 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17940 v2di __builtin_ia32_pmovzxdq128 (v4si)
17941 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17942 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17943 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17944 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17945 int __builtin_ia32_ptestc128 (v2di, v2di)
17946 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17947 int __builtin_ia32_ptestz128 (v2di, v2di)
17948 v2df __builtin_ia32_roundpd (v2df, const int)
17949 v4sf __builtin_ia32_roundps (v4sf, const int)
17950 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17951 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17952 @end smallexample
17953
17954 The following built-in functions are available when @option{-msse4.1} is
17955 used.
17956
17957 @table @code
17958 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17959 Generates the @code{insertps} machine instruction.
17960 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17961 Generates the @code{pextrb} machine instruction.
17962 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17963 Generates the @code{pinsrb} machine instruction.
17964 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17965 Generates the @code{pinsrd} machine instruction.
17966 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17967 Generates the @code{pinsrq} machine instruction in 64bit mode.
17968 @end table
17969
17970 The following built-in functions are changed to generate new SSE4.1
17971 instructions when @option{-msse4.1} is used.
17972
17973 @table @code
17974 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17975 Generates the @code{extractps} machine instruction.
17976 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17977 Generates the @code{pextrd} machine instruction.
17978 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17979 Generates the @code{pextrq} machine instruction in 64bit mode.
17980 @end table
17981
17982 The following built-in functions are available when @option{-msse4.2} is
17983 used. All of them generate the machine instruction that is part of the
17984 name.
17985
17986 @smallexample
17987 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17988 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17989 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17990 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17991 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17992 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17993 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17994 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17995 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17996 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17997 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17998 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17999 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
18000 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
18001 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
18002 @end smallexample
18003
18004 The following built-in functions are available when @option{-msse4.2} is
18005 used.
18006
18007 @table @code
18008 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
18009 Generates the @code{crc32b} machine instruction.
18010 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
18011 Generates the @code{crc32w} machine instruction.
18012 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
18013 Generates the @code{crc32l} machine instruction.
18014 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
18015 Generates the @code{crc32q} machine instruction.
18016 @end table
18017
18018 The following built-in functions are changed to generate new SSE4.2
18019 instructions when @option{-msse4.2} is used.
18020
18021 @table @code
18022 @item int __builtin_popcount (unsigned int)
18023 Generates the @code{popcntl} machine instruction.
18024 @item int __builtin_popcountl (unsigned long)
18025 Generates the @code{popcntl} or @code{popcntq} machine instruction,
18026 depending on the size of @code{unsigned long}.
18027 @item int __builtin_popcountll (unsigned long long)
18028 Generates the @code{popcntq} machine instruction.
18029 @end table
18030
18031 The following built-in functions are available when @option{-mavx} is
18032 used. All of them generate the machine instruction that is part of the
18033 name.
18034
18035 @smallexample
18036 v4df __builtin_ia32_addpd256 (v4df,v4df)
18037 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
18038 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
18039 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
18040 v4df __builtin_ia32_andnpd256 (v4df,v4df)
18041 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
18042 v4df __builtin_ia32_andpd256 (v4df,v4df)
18043 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
18044 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
18045 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
18046 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
18047 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
18048 v2df __builtin_ia32_cmppd (v2df,v2df,int)
18049 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
18050 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
18051 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
18052 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
18053 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
18054 v4df __builtin_ia32_cvtdq2pd256 (v4si)
18055 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
18056 v4si __builtin_ia32_cvtpd2dq256 (v4df)
18057 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
18058 v8si __builtin_ia32_cvtps2dq256 (v8sf)
18059 v4df __builtin_ia32_cvtps2pd256 (v4sf)
18060 v4si __builtin_ia32_cvttpd2dq256 (v4df)
18061 v8si __builtin_ia32_cvttps2dq256 (v8sf)
18062 v4df __builtin_ia32_divpd256 (v4df,v4df)
18063 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
18064 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
18065 v4df __builtin_ia32_haddpd256 (v4df,v4df)
18066 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
18067 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
18068 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
18069 v32qi __builtin_ia32_lddqu256 (pcchar)
18070 v32qi __builtin_ia32_loaddqu256 (pcchar)
18071 v4df __builtin_ia32_loadupd256 (pcdouble)
18072 v8sf __builtin_ia32_loadups256 (pcfloat)
18073 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
18074 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
18075 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
18076 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
18077 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
18078 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
18079 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
18080 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
18081 v4df __builtin_ia32_maxpd256 (v4df,v4df)
18082 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
18083 v4df __builtin_ia32_minpd256 (v4df,v4df)
18084 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
18085 v4df __builtin_ia32_movddup256 (v4df)
18086 int __builtin_ia32_movmskpd256 (v4df)
18087 int __builtin_ia32_movmskps256 (v8sf)
18088 v8sf __builtin_ia32_movshdup256 (v8sf)
18089 v8sf __builtin_ia32_movsldup256 (v8sf)
18090 v4df __builtin_ia32_mulpd256 (v4df,v4df)
18091 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
18092 v4df __builtin_ia32_orpd256 (v4df,v4df)
18093 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
18094 v2df __builtin_ia32_pd_pd256 (v4df)
18095 v4df __builtin_ia32_pd256_pd (v2df)
18096 v4sf __builtin_ia32_ps_ps256 (v8sf)
18097 v8sf __builtin_ia32_ps256_ps (v4sf)
18098 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
18099 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
18100 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
18101 v8sf __builtin_ia32_rcpps256 (v8sf)
18102 v4df __builtin_ia32_roundpd256 (v4df,int)
18103 v8sf __builtin_ia32_roundps256 (v8sf,int)
18104 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
18105 v8sf __builtin_ia32_rsqrtps256 (v8sf)
18106 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
18107 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
18108 v4si __builtin_ia32_si_si256 (v8si)
18109 v8si __builtin_ia32_si256_si (v4si)
18110 v4df __builtin_ia32_sqrtpd256 (v4df)
18111 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
18112 v8sf __builtin_ia32_sqrtps256 (v8sf)
18113 void __builtin_ia32_storedqu256 (pchar,v32qi)
18114 void __builtin_ia32_storeupd256 (pdouble,v4df)
18115 void __builtin_ia32_storeups256 (pfloat,v8sf)
18116 v4df __builtin_ia32_subpd256 (v4df,v4df)
18117 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
18118 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
18119 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
18120 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
18121 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
18122 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
18123 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
18124 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
18125 v4sf __builtin_ia32_vbroadcastss (pcfloat)
18126 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
18127 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
18128 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
18129 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
18130 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
18131 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
18132 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
18133 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
18134 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
18135 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
18136 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
18137 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
18138 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
18139 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
18140 v2df __builtin_ia32_vpermilpd (v2df,int)
18141 v4df __builtin_ia32_vpermilpd256 (v4df,int)
18142 v4sf __builtin_ia32_vpermilps (v4sf,int)
18143 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
18144 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
18145 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
18146 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
18147 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
18148 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
18149 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
18150 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
18151 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
18152 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
18153 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
18154 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
18155 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
18156 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
18157 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
18158 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
18159 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
18160 void __builtin_ia32_vzeroall (void)
18161 void __builtin_ia32_vzeroupper (void)
18162 v4df __builtin_ia32_xorpd256 (v4df,v4df)
18163 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
18164 @end smallexample
18165
18166 The following built-in functions are available when @option{-mavx2} is
18167 used. All of them generate the machine instruction that is part of the
18168 name.
18169
18170 @smallexample
18171 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
18172 v32qi __builtin_ia32_pabsb256 (v32qi)
18173 v16hi __builtin_ia32_pabsw256 (v16hi)
18174 v8si __builtin_ia32_pabsd256 (v8si)
18175 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
18176 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
18177 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
18178 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
18179 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
18180 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
18181 v8si __builtin_ia32_paddd256 (v8si,v8si)
18182 v4di __builtin_ia32_paddq256 (v4di,v4di)
18183 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
18184 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
18185 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
18186 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
18187 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
18188 v4di __builtin_ia32_andsi256 (v4di,v4di)
18189 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
18190 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
18191 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
18192 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
18193 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
18194 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
18195 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
18196 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
18197 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
18198 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
18199 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
18200 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
18201 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
18202 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
18203 v8si __builtin_ia32_phaddd256 (v8si,v8si)
18204 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
18205 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
18206 v8si __builtin_ia32_phsubd256 (v8si,v8si)
18207 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
18208 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
18209 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
18210 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
18211 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
18212 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
18213 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
18214 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
18215 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
18216 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
18217 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
18218 v8si __builtin_ia32_pminsd256 (v8si,v8si)
18219 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
18220 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
18221 v8si __builtin_ia32_pminud256 (v8si,v8si)
18222 int __builtin_ia32_pmovmskb256 (v32qi)
18223 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
18224 v8si __builtin_ia32_pmovsxbd256 (v16qi)
18225 v4di __builtin_ia32_pmovsxbq256 (v16qi)
18226 v8si __builtin_ia32_pmovsxwd256 (v8hi)
18227 v4di __builtin_ia32_pmovsxwq256 (v8hi)
18228 v4di __builtin_ia32_pmovsxdq256 (v4si)
18229 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
18230 v8si __builtin_ia32_pmovzxbd256 (v16qi)
18231 v4di __builtin_ia32_pmovzxbq256 (v16qi)
18232 v8si __builtin_ia32_pmovzxwd256 (v8hi)
18233 v4di __builtin_ia32_pmovzxwq256 (v8hi)
18234 v4di __builtin_ia32_pmovzxdq256 (v4si)
18235 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
18236 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
18237 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
18238 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
18239 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
18240 v8si __builtin_ia32_pmulld256 (v8si,v8si)
18241 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
18242 v4di __builtin_ia32_por256 (v4di,v4di)
18243 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
18244 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
18245 v8si __builtin_ia32_pshufd256 (v8si,int)
18246 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
18247 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
18248 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
18249 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
18250 v8si __builtin_ia32_psignd256 (v8si,v8si)
18251 v4di __builtin_ia32_pslldqi256 (v4di,int)
18252 v16hi __builtin_ia32_psllwi256 (16hi,int)
18253 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
18254 v8si __builtin_ia32_pslldi256 (v8si,int)
18255 v8si __builtin_ia32_pslld256(v8si,v4si)
18256 v4di __builtin_ia32_psllqi256 (v4di,int)
18257 v4di __builtin_ia32_psllq256(v4di,v2di)
18258 v16hi __builtin_ia32_psrawi256 (v16hi,int)
18259 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
18260 v8si __builtin_ia32_psradi256 (v8si,int)
18261 v8si __builtin_ia32_psrad256 (v8si,v4si)
18262 v4di __builtin_ia32_psrldqi256 (v4di, int)
18263 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
18264 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
18265 v8si __builtin_ia32_psrldi256 (v8si,int)
18266 v8si __builtin_ia32_psrld256 (v8si,v4si)
18267 v4di __builtin_ia32_psrlqi256 (v4di,int)
18268 v4di __builtin_ia32_psrlq256(v4di,v2di)
18269 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
18270 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
18271 v8si __builtin_ia32_psubd256 (v8si,v8si)
18272 v4di __builtin_ia32_psubq256 (v4di,v4di)
18273 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
18274 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
18275 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
18276 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
18277 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
18278 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
18279 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
18280 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
18281 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
18282 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
18283 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
18284 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
18285 v4di __builtin_ia32_pxor256 (v4di,v4di)
18286 v4di __builtin_ia32_movntdqa256 (pv4di)
18287 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
18288 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
18289 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
18290 v4di __builtin_ia32_vbroadcastsi256 (v2di)
18291 v4si __builtin_ia32_pblendd128 (v4si,v4si)
18292 v8si __builtin_ia32_pblendd256 (v8si,v8si)
18293 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
18294 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
18295 v8si __builtin_ia32_pbroadcastd256 (v4si)
18296 v4di __builtin_ia32_pbroadcastq256 (v2di)
18297 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
18298 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
18299 v4si __builtin_ia32_pbroadcastd128 (v4si)
18300 v2di __builtin_ia32_pbroadcastq128 (v2di)
18301 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
18302 v4df __builtin_ia32_permdf256 (v4df,int)
18303 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
18304 v4di __builtin_ia32_permdi256 (v4di,int)
18305 v4di __builtin_ia32_permti256 (v4di,v4di,int)
18306 v4di __builtin_ia32_extract128i256 (v4di,int)
18307 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
18308 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
18309 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
18310 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
18311 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
18312 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
18313 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
18314 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
18315 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
18316 v8si __builtin_ia32_psllv8si (v8si,v8si)
18317 v4si __builtin_ia32_psllv4si (v4si,v4si)
18318 v4di __builtin_ia32_psllv4di (v4di,v4di)
18319 v2di __builtin_ia32_psllv2di (v2di,v2di)
18320 v8si __builtin_ia32_psrav8si (v8si,v8si)
18321 v4si __builtin_ia32_psrav4si (v4si,v4si)
18322 v8si __builtin_ia32_psrlv8si (v8si,v8si)
18323 v4si __builtin_ia32_psrlv4si (v4si,v4si)
18324 v4di __builtin_ia32_psrlv4di (v4di,v4di)
18325 v2di __builtin_ia32_psrlv2di (v2di,v2di)
18326 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
18327 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
18328 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
18329 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
18330 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
18331 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
18332 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
18333 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
18334 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
18335 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
18336 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
18337 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
18338 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
18339 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
18340 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
18341 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
18342 @end smallexample
18343
18344 The following built-in functions are available when @option{-maes} is
18345 used. All of them generate the machine instruction that is part of the
18346 name.
18347
18348 @smallexample
18349 v2di __builtin_ia32_aesenc128 (v2di, v2di)
18350 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
18351 v2di __builtin_ia32_aesdec128 (v2di, v2di)
18352 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
18353 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
18354 v2di __builtin_ia32_aesimc128 (v2di)
18355 @end smallexample
18356
18357 The following built-in function is available when @option{-mpclmul} is
18358 used.
18359
18360 @table @code
18361 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
18362 Generates the @code{pclmulqdq} machine instruction.
18363 @end table
18364
18365 The following built-in function is available when @option{-mfsgsbase} is
18366 used. All of them generate the machine instruction that is part of the
18367 name.
18368
18369 @smallexample
18370 unsigned int __builtin_ia32_rdfsbase32 (void)
18371 unsigned long long __builtin_ia32_rdfsbase64 (void)
18372 unsigned int __builtin_ia32_rdgsbase32 (void)
18373 unsigned long long __builtin_ia32_rdgsbase64 (void)
18374 void _writefsbase_u32 (unsigned int)
18375 void _writefsbase_u64 (unsigned long long)
18376 void _writegsbase_u32 (unsigned int)
18377 void _writegsbase_u64 (unsigned long long)
18378 @end smallexample
18379
18380 The following built-in function is available when @option{-mrdrnd} is
18381 used. All of them generate the machine instruction that is part of the
18382 name.
18383
18384 @smallexample
18385 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
18386 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
18387 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
18388 @end smallexample
18389
18390 The following built-in functions are available when @option{-msse4a} is used.
18391 All of them generate the machine instruction that is part of the name.
18392
18393 @smallexample
18394 void __builtin_ia32_movntsd (double *, v2df)
18395 void __builtin_ia32_movntss (float *, v4sf)
18396 v2di __builtin_ia32_extrq (v2di, v16qi)
18397 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
18398 v2di __builtin_ia32_insertq (v2di, v2di)
18399 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
18400 @end smallexample
18401
18402 The following built-in functions are available when @option{-mxop} is used.
18403 @smallexample
18404 v2df __builtin_ia32_vfrczpd (v2df)
18405 v4sf __builtin_ia32_vfrczps (v4sf)
18406 v2df __builtin_ia32_vfrczsd (v2df)
18407 v4sf __builtin_ia32_vfrczss (v4sf)
18408 v4df __builtin_ia32_vfrczpd256 (v4df)
18409 v8sf __builtin_ia32_vfrczps256 (v8sf)
18410 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18411 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18412 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18413 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18414 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18415 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18416 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18417 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18418 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18419 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18420 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18421 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18422 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18423 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18424 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18425 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18426 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18427 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18428 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18429 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18430 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18431 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18432 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18433 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18434 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18435 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18436 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18437 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18438 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18439 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18440 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18441 v4si __builtin_ia32_vpcomged (v4si, v4si)
18442 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18443 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18444 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18445 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18446 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18447 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18448 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18449 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18450 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18451 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18452 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18453 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18454 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18455 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18456 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18457 v4si __builtin_ia32_vpcomled (v4si, v4si)
18458 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18459 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18460 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18461 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18462 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18463 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18464 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18465 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18466 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18467 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18468 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18469 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18470 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18471 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18472 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18473 v4si __builtin_ia32_vpcomned (v4si, v4si)
18474 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18475 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18476 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18477 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18478 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18479 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18480 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18481 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18482 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18483 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18484 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18485 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18486 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18487 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18488 v4si __builtin_ia32_vphaddbd (v16qi)
18489 v2di __builtin_ia32_vphaddbq (v16qi)
18490 v8hi __builtin_ia32_vphaddbw (v16qi)
18491 v2di __builtin_ia32_vphadddq (v4si)
18492 v4si __builtin_ia32_vphaddubd (v16qi)
18493 v2di __builtin_ia32_vphaddubq (v16qi)
18494 v8hi __builtin_ia32_vphaddubw (v16qi)
18495 v2di __builtin_ia32_vphaddudq (v4si)
18496 v4si __builtin_ia32_vphadduwd (v8hi)
18497 v2di __builtin_ia32_vphadduwq (v8hi)
18498 v4si __builtin_ia32_vphaddwd (v8hi)
18499 v2di __builtin_ia32_vphaddwq (v8hi)
18500 v8hi __builtin_ia32_vphsubbw (v16qi)
18501 v2di __builtin_ia32_vphsubdq (v4si)
18502 v4si __builtin_ia32_vphsubwd (v8hi)
18503 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18504 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18505 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18506 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18507 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18508 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18509 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18510 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18511 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18512 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18513 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18514 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18515 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18516 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18517 v4si __builtin_ia32_vprotd (v4si, v4si)
18518 v2di __builtin_ia32_vprotq (v2di, v2di)
18519 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18520 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18521 v4si __builtin_ia32_vpshad (v4si, v4si)
18522 v2di __builtin_ia32_vpshaq (v2di, v2di)
18523 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18524 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18525 v4si __builtin_ia32_vpshld (v4si, v4si)
18526 v2di __builtin_ia32_vpshlq (v2di, v2di)
18527 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18528 @end smallexample
18529
18530 The following built-in functions are available when @option{-mfma4} is used.
18531 All of them generate the machine instruction that is part of the name.
18532
18533 @smallexample
18534 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18535 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18536 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18537 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18538 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18539 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18540 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18541 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18542 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18543 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18544 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18545 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18546 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18547 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18548 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18549 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18550 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18551 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18552 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18553 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18554 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18555 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18556 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18557 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18558 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18559 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18560 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18561 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18562 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18563 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18564 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18565 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18566
18567 @end smallexample
18568
18569 The following built-in functions are available when @option{-mlwp} is used.
18570
18571 @smallexample
18572 void __builtin_ia32_llwpcb16 (void *);
18573 void __builtin_ia32_llwpcb32 (void *);
18574 void __builtin_ia32_llwpcb64 (void *);
18575 void * __builtin_ia32_llwpcb16 (void);
18576 void * __builtin_ia32_llwpcb32 (void);
18577 void * __builtin_ia32_llwpcb64 (void);
18578 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18579 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18580 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18581 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18582 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18583 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18584 @end smallexample
18585
18586 The following built-in functions are available when @option{-mbmi} is used.
18587 All of them generate the machine instruction that is part of the name.
18588 @smallexample
18589 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18590 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18591 @end smallexample
18592
18593 The following built-in functions are available when @option{-mbmi2} is used.
18594 All of them generate the machine instruction that is part of the name.
18595 @smallexample
18596 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18597 unsigned int _pdep_u32 (unsigned int, unsigned int)
18598 unsigned int _pext_u32 (unsigned int, unsigned int)
18599 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18600 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18601 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18602 @end smallexample
18603
18604 The following built-in functions are available when @option{-mlzcnt} is used.
18605 All of them generate the machine instruction that is part of the name.
18606 @smallexample
18607 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18608 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18609 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18610 @end smallexample
18611
18612 The following built-in functions are available when @option{-mfxsr} is used.
18613 All of them generate the machine instruction that is part of the name.
18614 @smallexample
18615 void __builtin_ia32_fxsave (void *)
18616 void __builtin_ia32_fxrstor (void *)
18617 void __builtin_ia32_fxsave64 (void *)
18618 void __builtin_ia32_fxrstor64 (void *)
18619 @end smallexample
18620
18621 The following built-in functions are available when @option{-mxsave} is used.
18622 All of them generate the machine instruction that is part of the name.
18623 @smallexample
18624 void __builtin_ia32_xsave (void *, long long)
18625 void __builtin_ia32_xrstor (void *, long long)
18626 void __builtin_ia32_xsave64 (void *, long long)
18627 void __builtin_ia32_xrstor64 (void *, long long)
18628 @end smallexample
18629
18630 The following built-in functions are available when @option{-mxsaveopt} is used.
18631 All of them generate the machine instruction that is part of the name.
18632 @smallexample
18633 void __builtin_ia32_xsaveopt (void *, long long)
18634 void __builtin_ia32_xsaveopt64 (void *, long long)
18635 @end smallexample
18636
18637 The following built-in functions are available when @option{-mtbm} is used.
18638 Both of them generate the immediate form of the bextr machine instruction.
18639 @smallexample
18640 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18641 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18642 @end smallexample
18643
18644
18645 The following built-in functions are available when @option{-m3dnow} is used.
18646 All of them generate the machine instruction that is part of the name.
18647
18648 @smallexample
18649 void __builtin_ia32_femms (void)
18650 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18651 v2si __builtin_ia32_pf2id (v2sf)
18652 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18653 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18654 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18655 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18656 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18657 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18658 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18659 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18660 v2sf __builtin_ia32_pfrcp (v2sf)
18661 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18662 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18663 v2sf __builtin_ia32_pfrsqrt (v2sf)
18664 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18665 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18666 v2sf __builtin_ia32_pi2fd (v2si)
18667 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18668 @end smallexample
18669
18670 The following built-in functions are available when both @option{-m3dnow}
18671 and @option{-march=athlon} are used. All of them generate the machine
18672 instruction that is part of the name.
18673
18674 @smallexample
18675 v2si __builtin_ia32_pf2iw (v2sf)
18676 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18677 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18678 v2sf __builtin_ia32_pi2fw (v2si)
18679 v2sf __builtin_ia32_pswapdsf (v2sf)
18680 v2si __builtin_ia32_pswapdsi (v2si)
18681 @end smallexample
18682
18683 The following built-in functions are available when @option{-mrtm} is used
18684 They are used for restricted transactional memory. These are the internal
18685 low level functions. Normally the functions in
18686 @ref{x86 transactional memory intrinsics} should be used instead.
18687
18688 @smallexample
18689 int __builtin_ia32_xbegin ()
18690 void __builtin_ia32_xend ()
18691 void __builtin_ia32_xabort (status)
18692 int __builtin_ia32_xtest ()
18693 @end smallexample
18694
18695 The following built-in functions are available when @option{-mmwaitx} is used.
18696 All of them generate the machine instruction that is part of the name.
18697 @smallexample
18698 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18699 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18700 @end smallexample
18701
18702 The following built-in functions are available when @option{-mclzero} is used.
18703 All of them generate the machine instruction that is part of the name.
18704 @smallexample
18705 void __builtin_i32_clzero (void *)
18706 @end smallexample
18707
18708 The following built-in functions are available when @option{-mpku} is used.
18709 They generate reads and writes to PKRU.
18710 @smallexample
18711 void __builtin_ia32_wrpkru (unsigned int)
18712 unsigned int __builtin_ia32_rdpkru ()
18713 @end smallexample
18714
18715 @node x86 transactional memory intrinsics
18716 @subsection x86 Transactional Memory Intrinsics
18717
18718 These hardware transactional memory intrinsics for x86 allow you to use
18719 memory transactions with RTM (Restricted Transactional Memory).
18720 This support is enabled with the @option{-mrtm} option.
18721 For using HLE (Hardware Lock Elision) see
18722 @ref{x86 specific memory model extensions for transactional memory} instead.
18723
18724 A memory transaction commits all changes to memory in an atomic way,
18725 as visible to other threads. If the transaction fails it is rolled back
18726 and all side effects discarded.
18727
18728 Generally there is no guarantee that a memory transaction ever succeeds
18729 and suitable fallback code always needs to be supplied.
18730
18731 @deftypefn {RTM Function} {unsigned} _xbegin ()
18732 Start a RTM (Restricted Transactional Memory) transaction.
18733 Returns @code{_XBEGIN_STARTED} when the transaction
18734 started successfully (note this is not 0, so the constant has to be
18735 explicitly tested).
18736
18737 If the transaction aborts, all side-effects
18738 are undone and an abort code encoded as a bit mask is returned.
18739 The following macros are defined:
18740
18741 @table @code
18742 @item _XABORT_EXPLICIT
18743 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18744 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18745 @item _XABORT_RETRY
18746 Transaction retry is possible.
18747 @item _XABORT_CONFLICT
18748 Transaction abort due to a memory conflict with another thread.
18749 @item _XABORT_CAPACITY
18750 Transaction abort due to the transaction using too much memory.
18751 @item _XABORT_DEBUG
18752 Transaction abort due to a debug trap.
18753 @item _XABORT_NESTED
18754 Transaction abort in an inner nested transaction.
18755 @end table
18756
18757 There is no guarantee
18758 any transaction ever succeeds, so there always needs to be a valid
18759 fallback path.
18760 @end deftypefn
18761
18762 @deftypefn {RTM Function} {void} _xend ()
18763 Commit the current transaction. When no transaction is active this faults.
18764 All memory side-effects of the transaction become visible
18765 to other threads in an atomic manner.
18766 @end deftypefn
18767
18768 @deftypefn {RTM Function} {int} _xtest ()
18769 Return a nonzero value if a transaction is currently active, otherwise 0.
18770 @end deftypefn
18771
18772 @deftypefn {RTM Function} {void} _xabort (status)
18773 Abort the current transaction. When no transaction is active this is a no-op.
18774 The @var{status} is an 8-bit constant; its value is encoded in the return
18775 value from @code{_xbegin}.
18776 @end deftypefn
18777
18778 Here is an example showing handling for @code{_XABORT_RETRY}
18779 and a fallback path for other failures:
18780
18781 @smallexample
18782 #include <immintrin.h>
18783
18784 int n_tries, max_tries;
18785 unsigned status = _XABORT_EXPLICIT;
18786 ...
18787
18788 for (n_tries = 0; n_tries < max_tries; n_tries++)
18789 @{
18790 status = _xbegin ();
18791 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18792 break;
18793 @}
18794 if (status == _XBEGIN_STARTED)
18795 @{
18796 ... transaction code...
18797 _xend ();
18798 @}
18799 else
18800 @{
18801 ... non-transactional fallback path...
18802 @}
18803 @end smallexample
18804
18805 @noindent
18806 Note that, in most cases, the transactional and non-transactional code
18807 must synchronize together to ensure consistency.
18808
18809 @node Target Format Checks
18810 @section Format Checks Specific to Particular Target Machines
18811
18812 For some target machines, GCC supports additional options to the
18813 format attribute
18814 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18815
18816 @menu
18817 * Solaris Format Checks::
18818 * Darwin Format Checks::
18819 @end menu
18820
18821 @node Solaris Format Checks
18822 @subsection Solaris Format Checks
18823
18824 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18825 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18826 conversions, and the two-argument @code{%b} conversion for displaying
18827 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18828
18829 @node Darwin Format Checks
18830 @subsection Darwin Format Checks
18831
18832 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18833 attribute context. Declarations made with such attribution are parsed for correct syntax
18834 and format argument types. However, parsing of the format string itself is currently undefined
18835 and is not carried out by this version of the compiler.
18836
18837 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18838 also be used as format arguments. Note that the relevant headers are only likely to be
18839 available on Darwin (OSX) installations. On such installations, the XCode and system
18840 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18841 associated functions.
18842
18843 @node Pragmas
18844 @section Pragmas Accepted by GCC
18845 @cindex pragmas
18846 @cindex @code{#pragma}
18847
18848 GCC supports several types of pragmas, primarily in order to compile
18849 code originally written for other compilers. Note that in general
18850 we do not recommend the use of pragmas; @xref{Function Attributes},
18851 for further explanation.
18852
18853 @menu
18854 * AArch64 Pragmas::
18855 * ARM Pragmas::
18856 * M32C Pragmas::
18857 * MeP Pragmas::
18858 * RS/6000 and PowerPC Pragmas::
18859 * S/390 Pragmas::
18860 * Darwin Pragmas::
18861 * Solaris Pragmas::
18862 * Symbol-Renaming Pragmas::
18863 * Structure-Layout Pragmas::
18864 * Weak Pragmas::
18865 * Diagnostic Pragmas::
18866 * Visibility Pragmas::
18867 * Push/Pop Macro Pragmas::
18868 * Function Specific Option Pragmas::
18869 * Loop-Specific Pragmas::
18870 @end menu
18871
18872 @node AArch64 Pragmas
18873 @subsection AArch64 Pragmas
18874
18875 The pragmas defined by the AArch64 target correspond to the AArch64
18876 target function attributes. They can be specified as below:
18877 @smallexample
18878 #pragma GCC target("string")
18879 @end smallexample
18880
18881 where @code{@var{string}} can be any string accepted as an AArch64 target
18882 attribute. @xref{AArch64 Function Attributes}, for more details
18883 on the permissible values of @code{string}.
18884
18885 @node ARM Pragmas
18886 @subsection ARM Pragmas
18887
18888 The ARM target defines pragmas for controlling the default addition of
18889 @code{long_call} and @code{short_call} attributes to functions.
18890 @xref{Function Attributes}, for information about the effects of these
18891 attributes.
18892
18893 @table @code
18894 @item long_calls
18895 @cindex pragma, long_calls
18896 Set all subsequent functions to have the @code{long_call} attribute.
18897
18898 @item no_long_calls
18899 @cindex pragma, no_long_calls
18900 Set all subsequent functions to have the @code{short_call} attribute.
18901
18902 @item long_calls_off
18903 @cindex pragma, long_calls_off
18904 Do not affect the @code{long_call} or @code{short_call} attributes of
18905 subsequent functions.
18906 @end table
18907
18908 @node M32C Pragmas
18909 @subsection M32C Pragmas
18910
18911 @table @code
18912 @item GCC memregs @var{number}
18913 @cindex pragma, memregs
18914 Overrides the command-line option @code{-memregs=} for the current
18915 file. Use with care! This pragma must be before any function in the
18916 file, and mixing different memregs values in different objects may
18917 make them incompatible. This pragma is useful when a
18918 performance-critical function uses a memreg for temporary values,
18919 as it may allow you to reduce the number of memregs used.
18920
18921 @item ADDRESS @var{name} @var{address}
18922 @cindex pragma, address
18923 For any declared symbols matching @var{name}, this does three things
18924 to that symbol: it forces the symbol to be located at the given
18925 address (a number), it forces the symbol to be volatile, and it
18926 changes the symbol's scope to be static. This pragma exists for
18927 compatibility with other compilers, but note that the common
18928 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18929 instead). Example:
18930
18931 @smallexample
18932 #pragma ADDRESS port3 0x103
18933 char port3;
18934 @end smallexample
18935
18936 @end table
18937
18938 @node MeP Pragmas
18939 @subsection MeP Pragmas
18940
18941 @table @code
18942
18943 @item custom io_volatile (on|off)
18944 @cindex pragma, custom io_volatile
18945 Overrides the command-line option @code{-mio-volatile} for the current
18946 file. Note that for compatibility with future GCC releases, this
18947 option should only be used once before any @code{io} variables in each
18948 file.
18949
18950 @item GCC coprocessor available @var{registers}
18951 @cindex pragma, coprocessor available
18952 Specifies which coprocessor registers are available to the register
18953 allocator. @var{registers} may be a single register, register range
18954 separated by ellipses, or comma-separated list of those. Example:
18955
18956 @smallexample
18957 #pragma GCC coprocessor available $c0...$c10, $c28
18958 @end smallexample
18959
18960 @item GCC coprocessor call_saved @var{registers}
18961 @cindex pragma, coprocessor call_saved
18962 Specifies which coprocessor registers are to be saved and restored by
18963 any function using them. @var{registers} may be a single register,
18964 register range separated by ellipses, or comma-separated list of
18965 those. Example:
18966
18967 @smallexample
18968 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18969 @end smallexample
18970
18971 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18972 @cindex pragma, coprocessor subclass
18973 Creates and defines a register class. These register classes can be
18974 used by inline @code{asm} constructs. @var{registers} may be a single
18975 register, register range separated by ellipses, or comma-separated
18976 list of those. Example:
18977
18978 @smallexample
18979 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18980
18981 asm ("cpfoo %0" : "=B" (x));
18982 @end smallexample
18983
18984 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18985 @cindex pragma, disinterrupt
18986 For the named functions, the compiler adds code to disable interrupts
18987 for the duration of those functions. If any functions so named
18988 are not encountered in the source, a warning is emitted that the pragma is
18989 not used. Examples:
18990
18991 @smallexample
18992 #pragma disinterrupt foo
18993 #pragma disinterrupt bar, grill
18994 int foo () @{ @dots{} @}
18995 @end smallexample
18996
18997 @item GCC call @var{name} , @var{name} @dots{}
18998 @cindex pragma, call
18999 For the named functions, the compiler always uses a register-indirect
19000 call model when calling the named functions. Examples:
19001
19002 @smallexample
19003 extern int foo ();
19004 #pragma call foo
19005 @end smallexample
19006
19007 @end table
19008
19009 @node RS/6000 and PowerPC Pragmas
19010 @subsection RS/6000 and PowerPC Pragmas
19011
19012 The RS/6000 and PowerPC targets define one pragma for controlling
19013 whether or not the @code{longcall} attribute is added to function
19014 declarations by default. This pragma overrides the @option{-mlongcall}
19015 option, but not the @code{longcall} and @code{shortcall} attributes.
19016 @xref{RS/6000 and PowerPC Options}, for more information about when long
19017 calls are and are not necessary.
19018
19019 @table @code
19020 @item longcall (1)
19021 @cindex pragma, longcall
19022 Apply the @code{longcall} attribute to all subsequent function
19023 declarations.
19024
19025 @item longcall (0)
19026 Do not apply the @code{longcall} attribute to subsequent function
19027 declarations.
19028 @end table
19029
19030 @c Describe h8300 pragmas here.
19031 @c Describe sh pragmas here.
19032 @c Describe v850 pragmas here.
19033
19034 @node S/390 Pragmas
19035 @subsection S/390 Pragmas
19036
19037 The pragmas defined by the S/390 target correspond to the S/390
19038 target function attributes and some the additional options:
19039
19040 @table @samp
19041 @item zvector
19042 @itemx no-zvector
19043 @end table
19044
19045 Note that options of the pragma, unlike options of the target
19046 attribute, do change the value of preprocessor macros like
19047 @code{__VEC__}. They can be specified as below:
19048
19049 @smallexample
19050 #pragma GCC target("string[,string]...")
19051 #pragma GCC target("string"[,"string"]...)
19052 @end smallexample
19053
19054 @node Darwin Pragmas
19055 @subsection Darwin Pragmas
19056
19057 The following pragmas are available for all architectures running the
19058 Darwin operating system. These are useful for compatibility with other
19059 Mac OS compilers.
19060
19061 @table @code
19062 @item mark @var{tokens}@dots{}
19063 @cindex pragma, mark
19064 This pragma is accepted, but has no effect.
19065
19066 @item options align=@var{alignment}
19067 @cindex pragma, options align
19068 This pragma sets the alignment of fields in structures. The values of
19069 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
19070 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
19071 properly; to restore the previous setting, use @code{reset} for the
19072 @var{alignment}.
19073
19074 @item segment @var{tokens}@dots{}
19075 @cindex pragma, segment
19076 This pragma is accepted, but has no effect.
19077
19078 @item unused (@var{var} [, @var{var}]@dots{})
19079 @cindex pragma, unused
19080 This pragma declares variables to be possibly unused. GCC does not
19081 produce warnings for the listed variables. The effect is similar to
19082 that of the @code{unused} attribute, except that this pragma may appear
19083 anywhere within the variables' scopes.
19084 @end table
19085
19086 @node Solaris Pragmas
19087 @subsection Solaris Pragmas
19088
19089 The Solaris target supports @code{#pragma redefine_extname}
19090 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
19091 @code{#pragma} directives for compatibility with the system compiler.
19092
19093 @table @code
19094 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
19095 @cindex pragma, align
19096
19097 Increase the minimum alignment of each @var{variable} to @var{alignment}.
19098 This is the same as GCC's @code{aligned} attribute @pxref{Variable
19099 Attributes}). Macro expansion occurs on the arguments to this pragma
19100 when compiling C and Objective-C@. It does not currently occur when
19101 compiling C++, but this is a bug which may be fixed in a future
19102 release.
19103
19104 @item fini (@var{function} [, @var{function}]...)
19105 @cindex pragma, fini
19106
19107 This pragma causes each listed @var{function} to be called after
19108 main, or during shared module unloading, by adding a call to the
19109 @code{.fini} section.
19110
19111 @item init (@var{function} [, @var{function}]...)
19112 @cindex pragma, init
19113
19114 This pragma causes each listed @var{function} to be called during
19115 initialization (before @code{main}) or during shared module loading, by
19116 adding a call to the @code{.init} section.
19117
19118 @end table
19119
19120 @node Symbol-Renaming Pragmas
19121 @subsection Symbol-Renaming Pragmas
19122
19123 GCC supports a @code{#pragma} directive that changes the name used in
19124 assembly for a given declaration. While this pragma is supported on all
19125 platforms, it is intended primarily to provide compatibility with the
19126 Solaris system headers. This effect can also be achieved using the asm
19127 labels extension (@pxref{Asm Labels}).
19128
19129 @table @code
19130 @item redefine_extname @var{oldname} @var{newname}
19131 @cindex pragma, redefine_extname
19132
19133 This pragma gives the C function @var{oldname} the assembly symbol
19134 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
19135 is defined if this pragma is available (currently on all platforms).
19136 @end table
19137
19138 This pragma and the asm labels extension interact in a complicated
19139 manner. Here are some corner cases you may want to be aware of:
19140
19141 @enumerate
19142 @item This pragma silently applies only to declarations with external
19143 linkage. Asm labels do not have this restriction.
19144
19145 @item In C++, this pragma silently applies only to declarations with
19146 ``C'' linkage. Again, asm labels do not have this restriction.
19147
19148 @item If either of the ways of changing the assembly name of a
19149 declaration are applied to a declaration whose assembly name has
19150 already been determined (either by a previous use of one of these
19151 features, or because the compiler needed the assembly name in order to
19152 generate code), and the new name is different, a warning issues and
19153 the name does not change.
19154
19155 @item The @var{oldname} used by @code{#pragma redefine_extname} is
19156 always the C-language name.
19157 @end enumerate
19158
19159 @node Structure-Layout Pragmas
19160 @subsection Structure-Layout Pragmas
19161
19162 For compatibility with Microsoft Windows compilers, GCC supports a
19163 set of @code{#pragma} directives that change the maximum alignment of
19164 members of structures (other than zero-width bit-fields), unions, and
19165 classes subsequently defined. The @var{n} value below always is required
19166 to be a small power of two and specifies the new alignment in bytes.
19167
19168 @enumerate
19169 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
19170 @item @code{#pragma pack()} sets the alignment to the one that was in
19171 effect when compilation started (see also command-line option
19172 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
19173 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
19174 setting on an internal stack and then optionally sets the new alignment.
19175 @item @code{#pragma pack(pop)} restores the alignment setting to the one
19176 saved at the top of the internal stack (and removes that stack entry).
19177 Note that @code{#pragma pack([@var{n}])} does not influence this internal
19178 stack; thus it is possible to have @code{#pragma pack(push)} followed by
19179 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
19180 @code{#pragma pack(pop)}.
19181 @end enumerate
19182
19183 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
19184 directive which lays out structures and unions subsequently defined as the
19185 documented @code{__attribute__ ((ms_struct))}.
19186
19187 @enumerate
19188 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
19189 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
19190 @item @code{#pragma ms_struct reset} goes back to the default layout.
19191 @end enumerate
19192
19193 Most targets also support the @code{#pragma scalar_storage_order} directive
19194 which lays out structures and unions subsequently defined as the documented
19195 @code{__attribute__ ((scalar_storage_order))}.
19196
19197 @enumerate
19198 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
19199 of the scalar fields to big-endian.
19200 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
19201 of the scalar fields to little-endian.
19202 @item @code{#pragma scalar_storage_order default} goes back to the endianness
19203 that was in effect when compilation started (see also command-line option
19204 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
19205 @end enumerate
19206
19207 @node Weak Pragmas
19208 @subsection Weak Pragmas
19209
19210 For compatibility with SVR4, GCC supports a set of @code{#pragma}
19211 directives for declaring symbols to be weak, and defining weak
19212 aliases.
19213
19214 @table @code
19215 @item #pragma weak @var{symbol}
19216 @cindex pragma, weak
19217 This pragma declares @var{symbol} to be weak, as if the declaration
19218 had the attribute of the same name. The pragma may appear before
19219 or after the declaration of @var{symbol}. It is not an error for
19220 @var{symbol} to never be defined at all.
19221
19222 @item #pragma weak @var{symbol1} = @var{symbol2}
19223 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
19224 It is an error if @var{symbol2} is not defined in the current
19225 translation unit.
19226 @end table
19227
19228 @node Diagnostic Pragmas
19229 @subsection Diagnostic Pragmas
19230
19231 GCC allows the user to selectively enable or disable certain types of
19232 diagnostics, and change the kind of the diagnostic. For example, a
19233 project's policy might require that all sources compile with
19234 @option{-Werror} but certain files might have exceptions allowing
19235 specific types of warnings. Or, a project might selectively enable
19236 diagnostics and treat them as errors depending on which preprocessor
19237 macros are defined.
19238
19239 @table @code
19240 @item #pragma GCC diagnostic @var{kind} @var{option}
19241 @cindex pragma, diagnostic
19242
19243 Modifies the disposition of a diagnostic. Note that not all
19244 diagnostics are modifiable; at the moment only warnings (normally
19245 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
19246 Use @option{-fdiagnostics-show-option} to determine which diagnostics
19247 are controllable and which option controls them.
19248
19249 @var{kind} is @samp{error} to treat this diagnostic as an error,
19250 @samp{warning} to treat it like a warning (even if @option{-Werror} is
19251 in effect), or @samp{ignored} if the diagnostic is to be ignored.
19252 @var{option} is a double quoted string that matches the command-line
19253 option.
19254
19255 @smallexample
19256 #pragma GCC diagnostic warning "-Wformat"
19257 #pragma GCC diagnostic error "-Wformat"
19258 #pragma GCC diagnostic ignored "-Wformat"
19259 @end smallexample
19260
19261 Note that these pragmas override any command-line options. GCC keeps
19262 track of the location of each pragma, and issues diagnostics according
19263 to the state as of that point in the source file. Thus, pragmas occurring
19264 after a line do not affect diagnostics caused by that line.
19265
19266 @item #pragma GCC diagnostic push
19267 @itemx #pragma GCC diagnostic pop
19268
19269 Causes GCC to remember the state of the diagnostics as of each
19270 @code{push}, and restore to that point at each @code{pop}. If a
19271 @code{pop} has no matching @code{push}, the command-line options are
19272 restored.
19273
19274 @smallexample
19275 #pragma GCC diagnostic error "-Wuninitialized"
19276 foo(a); /* error is given for this one */
19277 #pragma GCC diagnostic push
19278 #pragma GCC diagnostic ignored "-Wuninitialized"
19279 foo(b); /* no diagnostic for this one */
19280 #pragma GCC diagnostic pop
19281 foo(c); /* error is given for this one */
19282 #pragma GCC diagnostic pop
19283 foo(d); /* depends on command-line options */
19284 @end smallexample
19285
19286 @end table
19287
19288 GCC also offers a simple mechanism for printing messages during
19289 compilation.
19290
19291 @table @code
19292 @item #pragma message @var{string}
19293 @cindex pragma, diagnostic
19294
19295 Prints @var{string} as a compiler message on compilation. The message
19296 is informational only, and is neither a compilation warning nor an error.
19297
19298 @smallexample
19299 #pragma message "Compiling " __FILE__ "..."
19300 @end smallexample
19301
19302 @var{string} may be parenthesized, and is printed with location
19303 information. For example,
19304
19305 @smallexample
19306 #define DO_PRAGMA(x) _Pragma (#x)
19307 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
19308
19309 TODO(Remember to fix this)
19310 @end smallexample
19311
19312 @noindent
19313 prints @samp{/tmp/file.c:4: note: #pragma message:
19314 TODO - Remember to fix this}.
19315
19316 @end table
19317
19318 @node Visibility Pragmas
19319 @subsection Visibility Pragmas
19320
19321 @table @code
19322 @item #pragma GCC visibility push(@var{visibility})
19323 @itemx #pragma GCC visibility pop
19324 @cindex pragma, visibility
19325
19326 This pragma allows the user to set the visibility for multiple
19327 declarations without having to give each a visibility attribute
19328 (@pxref{Function Attributes}).
19329
19330 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
19331 declarations. Class members and template specializations are not
19332 affected; if you want to override the visibility for a particular
19333 member or instantiation, you must use an attribute.
19334
19335 @end table
19336
19337
19338 @node Push/Pop Macro Pragmas
19339 @subsection Push/Pop Macro Pragmas
19340
19341 For compatibility with Microsoft Windows compilers, GCC supports
19342 @samp{#pragma push_macro(@var{"macro_name"})}
19343 and @samp{#pragma pop_macro(@var{"macro_name"})}.
19344
19345 @table @code
19346 @item #pragma push_macro(@var{"macro_name"})
19347 @cindex pragma, push_macro
19348 This pragma saves the value of the macro named as @var{macro_name} to
19349 the top of the stack for this macro.
19350
19351 @item #pragma pop_macro(@var{"macro_name"})
19352 @cindex pragma, pop_macro
19353 This pragma sets the value of the macro named as @var{macro_name} to
19354 the value on top of the stack for this macro. If the stack for
19355 @var{macro_name} is empty, the value of the macro remains unchanged.
19356 @end table
19357
19358 For example:
19359
19360 @smallexample
19361 #define X 1
19362 #pragma push_macro("X")
19363 #undef X
19364 #define X -1
19365 #pragma pop_macro("X")
19366 int x [X];
19367 @end smallexample
19368
19369 @noindent
19370 In this example, the definition of X as 1 is saved by @code{#pragma
19371 push_macro} and restored by @code{#pragma pop_macro}.
19372
19373 @node Function Specific Option Pragmas
19374 @subsection Function Specific Option Pragmas
19375
19376 @table @code
19377 @item #pragma GCC target (@var{"string"}...)
19378 @cindex pragma GCC target
19379
19380 This pragma allows you to set target specific options for functions
19381 defined later in the source file. One or more strings can be
19382 specified. Each function that is defined after this point is as
19383 if @code{attribute((target("STRING")))} was specified for that
19384 function. The parenthesis around the options is optional.
19385 @xref{Function Attributes}, for more information about the
19386 @code{target} attribute and the attribute syntax.
19387
19388 The @code{#pragma GCC target} pragma is presently implemented for
19389 x86, PowerPC, and Nios II targets only.
19390 @end table
19391
19392 @table @code
19393 @item #pragma GCC optimize (@var{"string"}...)
19394 @cindex pragma GCC optimize
19395
19396 This pragma allows you to set global optimization options for functions
19397 defined later in the source file. One or more strings can be
19398 specified. Each function that is defined after this point is as
19399 if @code{attribute((optimize("STRING")))} was specified for that
19400 function. The parenthesis around the options is optional.
19401 @xref{Function Attributes}, for more information about the
19402 @code{optimize} attribute and the attribute syntax.
19403 @end table
19404
19405 @table @code
19406 @item #pragma GCC push_options
19407 @itemx #pragma GCC pop_options
19408 @cindex pragma GCC push_options
19409 @cindex pragma GCC pop_options
19410
19411 These pragmas maintain a stack of the current target and optimization
19412 options. It is intended for include files where you temporarily want
19413 to switch to using a different @samp{#pragma GCC target} or
19414 @samp{#pragma GCC optimize} and then to pop back to the previous
19415 options.
19416 @end table
19417
19418 @table @code
19419 @item #pragma GCC reset_options
19420 @cindex pragma GCC reset_options
19421
19422 This pragma clears the current @code{#pragma GCC target} and
19423 @code{#pragma GCC optimize} to use the default switches as specified
19424 on the command line.
19425 @end table
19426
19427 @node Loop-Specific Pragmas
19428 @subsection Loop-Specific Pragmas
19429
19430 @table @code
19431 @item #pragma GCC ivdep
19432 @cindex pragma GCC ivdep
19433 @end table
19434
19435 With this pragma, the programmer asserts that there are no loop-carried
19436 dependencies which would prevent consecutive iterations of
19437 the following loop from executing concurrently with SIMD
19438 (single instruction multiple data) instructions.
19439
19440 For example, the compiler can only unconditionally vectorize the following
19441 loop with the pragma:
19442
19443 @smallexample
19444 void foo (int n, int *a, int *b, int *c)
19445 @{
19446 int i, j;
19447 #pragma GCC ivdep
19448 for (i = 0; i < n; ++i)
19449 a[i] = b[i] + c[i];
19450 @}
19451 @end smallexample
19452
19453 @noindent
19454 In this example, using the @code{restrict} qualifier had the same
19455 effect. In the following example, that would not be possible. Assume
19456 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19457 that it can unconditionally vectorize the following loop:
19458
19459 @smallexample
19460 void ignore_vec_dep (int *a, int k, int c, int m)
19461 @{
19462 #pragma GCC ivdep
19463 for (int i = 0; i < m; i++)
19464 a[i] = a[i + k] * c;
19465 @}
19466 @end smallexample
19467
19468
19469 @node Unnamed Fields
19470 @section Unnamed Structure and Union Fields
19471 @cindex @code{struct}
19472 @cindex @code{union}
19473
19474 As permitted by ISO C11 and for compatibility with other compilers,
19475 GCC allows you to define
19476 a structure or union that contains, as fields, structures and unions
19477 without names. For example:
19478
19479 @smallexample
19480 struct @{
19481 int a;
19482 union @{
19483 int b;
19484 float c;
19485 @};
19486 int d;
19487 @} foo;
19488 @end smallexample
19489
19490 @noindent
19491 In this example, you are able to access members of the unnamed
19492 union with code like @samp{foo.b}. Note that only unnamed structs and
19493 unions are allowed, you may not have, for example, an unnamed
19494 @code{int}.
19495
19496 You must never create such structures that cause ambiguous field definitions.
19497 For example, in this structure:
19498
19499 @smallexample
19500 struct @{
19501 int a;
19502 struct @{
19503 int a;
19504 @};
19505 @} foo;
19506 @end smallexample
19507
19508 @noindent
19509 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19510 The compiler gives errors for such constructs.
19511
19512 @opindex fms-extensions
19513 Unless @option{-fms-extensions} is used, the unnamed field must be a
19514 structure or union definition without a tag (for example, @samp{struct
19515 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19516 also be a definition with a tag such as @samp{struct foo @{ int a;
19517 @};}, a reference to a previously defined structure or union such as
19518 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19519 previously defined structure or union type.
19520
19521 @opindex fplan9-extensions
19522 The option @option{-fplan9-extensions} enables
19523 @option{-fms-extensions} as well as two other extensions. First, a
19524 pointer to a structure is automatically converted to a pointer to an
19525 anonymous field for assignments and function calls. For example:
19526
19527 @smallexample
19528 struct s1 @{ int a; @};
19529 struct s2 @{ struct s1; @};
19530 extern void f1 (struct s1 *);
19531 void f2 (struct s2 *p) @{ f1 (p); @}
19532 @end smallexample
19533
19534 @noindent
19535 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19536 converted into a pointer to the anonymous field.
19537
19538 Second, when the type of an anonymous field is a @code{typedef} for a
19539 @code{struct} or @code{union}, code may refer to the field using the
19540 name of the @code{typedef}.
19541
19542 @smallexample
19543 typedef struct @{ int a; @} s1;
19544 struct s2 @{ s1; @};
19545 s1 f1 (struct s2 *p) @{ return p->s1; @}
19546 @end smallexample
19547
19548 These usages are only permitted when they are not ambiguous.
19549
19550 @node Thread-Local
19551 @section Thread-Local Storage
19552 @cindex Thread-Local Storage
19553 @cindex @acronym{TLS}
19554 @cindex @code{__thread}
19555
19556 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19557 are allocated such that there is one instance of the variable per extant
19558 thread. The runtime model GCC uses to implement this originates
19559 in the IA-64 processor-specific ABI, but has since been migrated
19560 to other processors as well. It requires significant support from
19561 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19562 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19563 is not available everywhere.
19564
19565 At the user level, the extension is visible with a new storage
19566 class keyword: @code{__thread}. For example:
19567
19568 @smallexample
19569 __thread int i;
19570 extern __thread struct state s;
19571 static __thread char *p;
19572 @end smallexample
19573
19574 The @code{__thread} specifier may be used alone, with the @code{extern}
19575 or @code{static} specifiers, but with no other storage class specifier.
19576 When used with @code{extern} or @code{static}, @code{__thread} must appear
19577 immediately after the other storage class specifier.
19578
19579 The @code{__thread} specifier may be applied to any global, file-scoped
19580 static, function-scoped static, or static data member of a class. It may
19581 not be applied to block-scoped automatic or non-static data member.
19582
19583 When the address-of operator is applied to a thread-local variable, it is
19584 evaluated at run time and returns the address of the current thread's
19585 instance of that variable. An address so obtained may be used by any
19586 thread. When a thread terminates, any pointers to thread-local variables
19587 in that thread become invalid.
19588
19589 No static initialization may refer to the address of a thread-local variable.
19590
19591 In C++, if an initializer is present for a thread-local variable, it must
19592 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19593 standard.
19594
19595 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19596 ELF Handling For Thread-Local Storage} for a detailed explanation of
19597 the four thread-local storage addressing models, and how the runtime
19598 is expected to function.
19599
19600 @menu
19601 * C99 Thread-Local Edits::
19602 * C++98 Thread-Local Edits::
19603 @end menu
19604
19605 @node C99 Thread-Local Edits
19606 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19607
19608 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19609 that document the exact semantics of the language extension.
19610
19611 @itemize @bullet
19612 @item
19613 @cite{5.1.2 Execution environments}
19614
19615 Add new text after paragraph 1
19616
19617 @quotation
19618 Within either execution environment, a @dfn{thread} is a flow of
19619 control within a program. It is implementation defined whether
19620 or not there may be more than one thread associated with a program.
19621 It is implementation defined how threads beyond the first are
19622 created, the name and type of the function called at thread
19623 startup, and how threads may be terminated. However, objects
19624 with thread storage duration shall be initialized before thread
19625 startup.
19626 @end quotation
19627
19628 @item
19629 @cite{6.2.4 Storage durations of objects}
19630
19631 Add new text before paragraph 3
19632
19633 @quotation
19634 An object whose identifier is declared with the storage-class
19635 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19636 Its lifetime is the entire execution of the thread, and its
19637 stored value is initialized only once, prior to thread startup.
19638 @end quotation
19639
19640 @item
19641 @cite{6.4.1 Keywords}
19642
19643 Add @code{__thread}.
19644
19645 @item
19646 @cite{6.7.1 Storage-class specifiers}
19647
19648 Add @code{__thread} to the list of storage class specifiers in
19649 paragraph 1.
19650
19651 Change paragraph 2 to
19652
19653 @quotation
19654 With the exception of @code{__thread}, at most one storage-class
19655 specifier may be given [@dots{}]. The @code{__thread} specifier may
19656 be used alone, or immediately following @code{extern} or
19657 @code{static}.
19658 @end quotation
19659
19660 Add new text after paragraph 6
19661
19662 @quotation
19663 The declaration of an identifier for a variable that has
19664 block scope that specifies @code{__thread} shall also
19665 specify either @code{extern} or @code{static}.
19666
19667 The @code{__thread} specifier shall be used only with
19668 variables.
19669 @end quotation
19670 @end itemize
19671
19672 @node C++98 Thread-Local Edits
19673 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19674
19675 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19676 that document the exact semantics of the language extension.
19677
19678 @itemize @bullet
19679 @item
19680 @b{[intro.execution]}
19681
19682 New text after paragraph 4
19683
19684 @quotation
19685 A @dfn{thread} is a flow of control within the abstract machine.
19686 It is implementation defined whether or not there may be more than
19687 one thread.
19688 @end quotation
19689
19690 New text after paragraph 7
19691
19692 @quotation
19693 It is unspecified whether additional action must be taken to
19694 ensure when and whether side effects are visible to other threads.
19695 @end quotation
19696
19697 @item
19698 @b{[lex.key]}
19699
19700 Add @code{__thread}.
19701
19702 @item
19703 @b{[basic.start.main]}
19704
19705 Add after paragraph 5
19706
19707 @quotation
19708 The thread that begins execution at the @code{main} function is called
19709 the @dfn{main thread}. It is implementation defined how functions
19710 beginning threads other than the main thread are designated or typed.
19711 A function so designated, as well as the @code{main} function, is called
19712 a @dfn{thread startup function}. It is implementation defined what
19713 happens if a thread startup function returns. It is implementation
19714 defined what happens to other threads when any thread calls @code{exit}.
19715 @end quotation
19716
19717 @item
19718 @b{[basic.start.init]}
19719
19720 Add after paragraph 4
19721
19722 @quotation
19723 The storage for an object of thread storage duration shall be
19724 statically initialized before the first statement of the thread startup
19725 function. An object of thread storage duration shall not require
19726 dynamic initialization.
19727 @end quotation
19728
19729 @item
19730 @b{[basic.start.term]}
19731
19732 Add after paragraph 3
19733
19734 @quotation
19735 The type of an object with thread storage duration shall not have a
19736 non-trivial destructor, nor shall it be an array type whose elements
19737 (directly or indirectly) have non-trivial destructors.
19738 @end quotation
19739
19740 @item
19741 @b{[basic.stc]}
19742
19743 Add ``thread storage duration'' to the list in paragraph 1.
19744
19745 Change paragraph 2
19746
19747 @quotation
19748 Thread, static, and automatic storage durations are associated with
19749 objects introduced by declarations [@dots{}].
19750 @end quotation
19751
19752 Add @code{__thread} to the list of specifiers in paragraph 3.
19753
19754 @item
19755 @b{[basic.stc.thread]}
19756
19757 New section before @b{[basic.stc.static]}
19758
19759 @quotation
19760 The keyword @code{__thread} applied to a non-local object gives the
19761 object thread storage duration.
19762
19763 A local variable or class data member declared both @code{static}
19764 and @code{__thread} gives the variable or member thread storage
19765 duration.
19766 @end quotation
19767
19768 @item
19769 @b{[basic.stc.static]}
19770
19771 Change paragraph 1
19772
19773 @quotation
19774 All objects that have neither thread storage duration, dynamic
19775 storage duration nor are local [@dots{}].
19776 @end quotation
19777
19778 @item
19779 @b{[dcl.stc]}
19780
19781 Add @code{__thread} to the list in paragraph 1.
19782
19783 Change paragraph 1
19784
19785 @quotation
19786 With the exception of @code{__thread}, at most one
19787 @var{storage-class-specifier} shall appear in a given
19788 @var{decl-specifier-seq}. The @code{__thread} specifier may
19789 be used alone, or immediately following the @code{extern} or
19790 @code{static} specifiers. [@dots{}]
19791 @end quotation
19792
19793 Add after paragraph 5
19794
19795 @quotation
19796 The @code{__thread} specifier can be applied only to the names of objects
19797 and to anonymous unions.
19798 @end quotation
19799
19800 @item
19801 @b{[class.mem]}
19802
19803 Add after paragraph 6
19804
19805 @quotation
19806 Non-@code{static} members shall not be @code{__thread}.
19807 @end quotation
19808 @end itemize
19809
19810 @node Binary constants
19811 @section Binary Constants using the @samp{0b} Prefix
19812 @cindex Binary constants using the @samp{0b} prefix
19813
19814 Integer constants can be written as binary constants, consisting of a
19815 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19816 @samp{0B}. This is particularly useful in environments that operate a
19817 lot on the bit level (like microcontrollers).
19818
19819 The following statements are identical:
19820
19821 @smallexample
19822 i = 42;
19823 i = 0x2a;
19824 i = 052;
19825 i = 0b101010;
19826 @end smallexample
19827
19828 The type of these constants follows the same rules as for octal or
19829 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19830 can be applied.
19831
19832 @node C++ Extensions
19833 @chapter Extensions to the C++ Language
19834 @cindex extensions, C++ language
19835 @cindex C++ language extensions
19836
19837 The GNU compiler provides these extensions to the C++ language (and you
19838 can also use most of the C language extensions in your C++ programs). If you
19839 want to write code that checks whether these features are available, you can
19840 test for the GNU compiler the same way as for C programs: check for a
19841 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19842 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19843 Predefined Macros,cpp,The GNU C Preprocessor}).
19844
19845 @menu
19846 * C++ Volatiles:: What constitutes an access to a volatile object.
19847 * Restricted Pointers:: C99 restricted pointers and references.
19848 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19849 * C++ Interface:: You can use a single C++ header file for both
19850 declarations and definitions.
19851 * Template Instantiation:: Methods for ensuring that exactly one copy of
19852 each needed template instantiation is emitted.
19853 * Bound member functions:: You can extract a function pointer to the
19854 method denoted by a @samp{->*} or @samp{.*} expression.
19855 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19856 * Function Multiversioning:: Declaring multiple function versions.
19857 * Namespace Association:: Strong using-directives for namespace association.
19858 * Type Traits:: Compiler support for type traits.
19859 * C++ Concepts:: Improved support for generic programming.
19860 * Java Exceptions:: Tweaking exception handling to work with Java.
19861 * Deprecated Features:: Things will disappear from G++.
19862 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19863 @end menu
19864
19865 @node C++ Volatiles
19866 @section When is a Volatile C++ Object Accessed?
19867 @cindex accessing volatiles
19868 @cindex volatile read
19869 @cindex volatile write
19870 @cindex volatile access
19871
19872 The C++ standard differs from the C standard in its treatment of
19873 volatile objects. It fails to specify what constitutes a volatile
19874 access, except to say that C++ should behave in a similar manner to C
19875 with respect to volatiles, where possible. However, the different
19876 lvalueness of expressions between C and C++ complicate the behavior.
19877 G++ behaves the same as GCC for volatile access, @xref{C
19878 Extensions,,Volatiles}, for a description of GCC's behavior.
19879
19880 The C and C++ language specifications differ when an object is
19881 accessed in a void context:
19882
19883 @smallexample
19884 volatile int *src = @var{somevalue};
19885 *src;
19886 @end smallexample
19887
19888 The C++ standard specifies that such expressions do not undergo lvalue
19889 to rvalue conversion, and that the type of the dereferenced object may
19890 be incomplete. The C++ standard does not specify explicitly that it
19891 is lvalue to rvalue conversion that is responsible for causing an
19892 access. There is reason to believe that it is, because otherwise
19893 certain simple expressions become undefined. However, because it
19894 would surprise most programmers, G++ treats dereferencing a pointer to
19895 volatile object of complete type as GCC would do for an equivalent
19896 type in C@. When the object has incomplete type, G++ issues a
19897 warning; if you wish to force an error, you must force a conversion to
19898 rvalue with, for instance, a static cast.
19899
19900 When using a reference to volatile, G++ does not treat equivalent
19901 expressions as accesses to volatiles, but instead issues a warning that
19902 no volatile is accessed. The rationale for this is that otherwise it
19903 becomes difficult to determine where volatile access occur, and not
19904 possible to ignore the return value from functions returning volatile
19905 references. Again, if you wish to force a read, cast the reference to
19906 an rvalue.
19907
19908 G++ implements the same behavior as GCC does when assigning to a
19909 volatile object---there is no reread of the assigned-to object, the
19910 assigned rvalue is reused. Note that in C++ assignment expressions
19911 are lvalues, and if used as an lvalue, the volatile object is
19912 referred to. For instance, @var{vref} refers to @var{vobj}, as
19913 expected, in the following example:
19914
19915 @smallexample
19916 volatile int vobj;
19917 volatile int &vref = vobj = @var{something};
19918 @end smallexample
19919
19920 @node Restricted Pointers
19921 @section Restricting Pointer Aliasing
19922 @cindex restricted pointers
19923 @cindex restricted references
19924 @cindex restricted this pointer
19925
19926 As with the C front end, G++ understands the C99 feature of restricted pointers,
19927 specified with the @code{__restrict__}, or @code{__restrict} type
19928 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19929 language flag, @code{restrict} is not a keyword in C++.
19930
19931 In addition to allowing restricted pointers, you can specify restricted
19932 references, which indicate that the reference is not aliased in the local
19933 context.
19934
19935 @smallexample
19936 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19937 @{
19938 /* @r{@dots{}} */
19939 @}
19940 @end smallexample
19941
19942 @noindent
19943 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19944 @var{rref} refers to a (different) unaliased integer.
19945
19946 You may also specify whether a member function's @var{this} pointer is
19947 unaliased by using @code{__restrict__} as a member function qualifier.
19948
19949 @smallexample
19950 void T::fn () __restrict__
19951 @{
19952 /* @r{@dots{}} */
19953 @}
19954 @end smallexample
19955
19956 @noindent
19957 Within the body of @code{T::fn}, @var{this} has the effective
19958 definition @code{T *__restrict__ const this}. Notice that the
19959 interpretation of a @code{__restrict__} member function qualifier is
19960 different to that of @code{const} or @code{volatile} qualifier, in that it
19961 is applied to the pointer rather than the object. This is consistent with
19962 other compilers that implement restricted pointers.
19963
19964 As with all outermost parameter qualifiers, @code{__restrict__} is
19965 ignored in function definition matching. This means you only need to
19966 specify @code{__restrict__} in a function definition, rather than
19967 in a function prototype as well.
19968
19969 @node Vague Linkage
19970 @section Vague Linkage
19971 @cindex vague linkage
19972
19973 There are several constructs in C++ that require space in the object
19974 file but are not clearly tied to a single translation unit. We say that
19975 these constructs have ``vague linkage''. Typically such constructs are
19976 emitted wherever they are needed, though sometimes we can be more
19977 clever.
19978
19979 @table @asis
19980 @item Inline Functions
19981 Inline functions are typically defined in a header file which can be
19982 included in many different compilations. Hopefully they can usually be
19983 inlined, but sometimes an out-of-line copy is necessary, if the address
19984 of the function is taken or if inlining fails. In general, we emit an
19985 out-of-line copy in all translation units where one is needed. As an
19986 exception, we only emit inline virtual functions with the vtable, since
19987 it always requires a copy.
19988
19989 Local static variables and string constants used in an inline function
19990 are also considered to have vague linkage, since they must be shared
19991 between all inlined and out-of-line instances of the function.
19992
19993 @item VTables
19994 @cindex vtable
19995 C++ virtual functions are implemented in most compilers using a lookup
19996 table, known as a vtable. The vtable contains pointers to the virtual
19997 functions provided by a class, and each object of the class contains a
19998 pointer to its vtable (or vtables, in some multiple-inheritance
19999 situations). If the class declares any non-inline, non-pure virtual
20000 functions, the first one is chosen as the ``key method'' for the class,
20001 and the vtable is only emitted in the translation unit where the key
20002 method is defined.
20003
20004 @emph{Note:} If the chosen key method is later defined as inline, the
20005 vtable is still emitted in every translation unit that defines it.
20006 Make sure that any inline virtuals are declared inline in the class
20007 body, even if they are not defined there.
20008
20009 @item @code{type_info} objects
20010 @cindex @code{type_info}
20011 @cindex RTTI
20012 C++ requires information about types to be written out in order to
20013 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
20014 For polymorphic classes (classes with virtual functions), the @samp{type_info}
20015 object is written out along with the vtable so that @samp{dynamic_cast}
20016 can determine the dynamic type of a class object at run time. For all
20017 other types, we write out the @samp{type_info} object when it is used: when
20018 applying @samp{typeid} to an expression, throwing an object, or
20019 referring to a type in a catch clause or exception specification.
20020
20021 @item Template Instantiations
20022 Most everything in this section also applies to template instantiations,
20023 but there are other options as well.
20024 @xref{Template Instantiation,,Where's the Template?}.
20025
20026 @end table
20027
20028 When used with GNU ld version 2.8 or later on an ELF system such as
20029 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
20030 these constructs will be discarded at link time. This is known as
20031 COMDAT support.
20032
20033 On targets that don't support COMDAT, but do support weak symbols, GCC
20034 uses them. This way one copy overrides all the others, but
20035 the unused copies still take up space in the executable.
20036
20037 For targets that do not support either COMDAT or weak symbols,
20038 most entities with vague linkage are emitted as local symbols to
20039 avoid duplicate definition errors from the linker. This does not happen
20040 for local statics in inlines, however, as having multiple copies
20041 almost certainly breaks things.
20042
20043 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
20044 another way to control placement of these constructs.
20045
20046 @node C++ Interface
20047 @section C++ Interface and Implementation Pragmas
20048
20049 @cindex interface and implementation headers, C++
20050 @cindex C++ interface and implementation headers
20051 @cindex pragmas, interface and implementation
20052
20053 @code{#pragma interface} and @code{#pragma implementation} provide the
20054 user with a way of explicitly directing the compiler to emit entities
20055 with vague linkage (and debugging information) in a particular
20056 translation unit.
20057
20058 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
20059 by COMDAT support and the ``key method'' heuristic
20060 mentioned in @ref{Vague Linkage}. Using them can actually cause your
20061 program to grow due to unnecessary out-of-line copies of inline
20062 functions.
20063
20064 @table @code
20065 @item #pragma interface
20066 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
20067 @kindex #pragma interface
20068 Use this directive in @emph{header files} that define object classes, to save
20069 space in most of the object files that use those classes. Normally,
20070 local copies of certain information (backup copies of inline member
20071 functions, debugging information, and the internal tables that implement
20072 virtual functions) must be kept in each object file that includes class
20073 definitions. You can use this pragma to avoid such duplication. When a
20074 header file containing @samp{#pragma interface} is included in a
20075 compilation, this auxiliary information is not generated (unless
20076 the main input source file itself uses @samp{#pragma implementation}).
20077 Instead, the object files contain references to be resolved at link
20078 time.
20079
20080 The second form of this directive is useful for the case where you have
20081 multiple headers with the same name in different directories. If you
20082 use this form, you must specify the same string to @samp{#pragma
20083 implementation}.
20084
20085 @item #pragma implementation
20086 @itemx #pragma implementation "@var{objects}.h"
20087 @kindex #pragma implementation
20088 Use this pragma in a @emph{main input file}, when you want full output from
20089 included header files to be generated (and made globally visible). The
20090 included header file, in turn, should use @samp{#pragma interface}.
20091 Backup copies of inline member functions, debugging information, and the
20092 internal tables used to implement virtual functions are all generated in
20093 implementation files.
20094
20095 @cindex implied @code{#pragma implementation}
20096 @cindex @code{#pragma implementation}, implied
20097 @cindex naming convention, implementation headers
20098 If you use @samp{#pragma implementation} with no argument, it applies to
20099 an include file with the same basename@footnote{A file's @dfn{basename}
20100 is the name stripped of all leading path information and of trailing
20101 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
20102 file. For example, in @file{allclass.cc}, giving just
20103 @samp{#pragma implementation}
20104 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
20105
20106 Use the string argument if you want a single implementation file to
20107 include code from multiple header files. (You must also use
20108 @samp{#include} to include the header file; @samp{#pragma
20109 implementation} only specifies how to use the file---it doesn't actually
20110 include it.)
20111
20112 There is no way to split up the contents of a single header file into
20113 multiple implementation files.
20114 @end table
20115
20116 @cindex inlining and C++ pragmas
20117 @cindex C++ pragmas, effect on inlining
20118 @cindex pragmas in C++, effect on inlining
20119 @samp{#pragma implementation} and @samp{#pragma interface} also have an
20120 effect on function inlining.
20121
20122 If you define a class in a header file marked with @samp{#pragma
20123 interface}, the effect on an inline function defined in that class is
20124 similar to an explicit @code{extern} declaration---the compiler emits
20125 no code at all to define an independent version of the function. Its
20126 definition is used only for inlining with its callers.
20127
20128 @opindex fno-implement-inlines
20129 Conversely, when you include the same header file in a main source file
20130 that declares it as @samp{#pragma implementation}, the compiler emits
20131 code for the function itself; this defines a version of the function
20132 that can be found via pointers (or by callers compiled without
20133 inlining). If all calls to the function can be inlined, you can avoid
20134 emitting the function by compiling with @option{-fno-implement-inlines}.
20135 If any calls are not inlined, you will get linker errors.
20136
20137 @node Template Instantiation
20138 @section Where's the Template?
20139 @cindex template instantiation
20140
20141 C++ templates were the first language feature to require more
20142 intelligence from the environment than was traditionally found on a UNIX
20143 system. Somehow the compiler and linker have to make sure that each
20144 template instance occurs exactly once in the executable if it is needed,
20145 and not at all otherwise. There are two basic approaches to this
20146 problem, which are referred to as the Borland model and the Cfront model.
20147
20148 @table @asis
20149 @item Borland model
20150 Borland C++ solved the template instantiation problem by adding the code
20151 equivalent of common blocks to their linker; the compiler emits template
20152 instances in each translation unit that uses them, and the linker
20153 collapses them together. The advantage of this model is that the linker
20154 only has to consider the object files themselves; there is no external
20155 complexity to worry about. The disadvantage is that compilation time
20156 is increased because the template code is being compiled repeatedly.
20157 Code written for this model tends to include definitions of all
20158 templates in the header file, since they must be seen to be
20159 instantiated.
20160
20161 @item Cfront model
20162 The AT&T C++ translator, Cfront, solved the template instantiation
20163 problem by creating the notion of a template repository, an
20164 automatically maintained place where template instances are stored. A
20165 more modern version of the repository works as follows: As individual
20166 object files are built, the compiler places any template definitions and
20167 instantiations encountered in the repository. At link time, the link
20168 wrapper adds in the objects in the repository and compiles any needed
20169 instances that were not previously emitted. The advantages of this
20170 model are more optimal compilation speed and the ability to use the
20171 system linker; to implement the Borland model a compiler vendor also
20172 needs to replace the linker. The disadvantages are vastly increased
20173 complexity, and thus potential for error; for some code this can be
20174 just as transparent, but in practice it can been very difficult to build
20175 multiple programs in one directory and one program in multiple
20176 directories. Code written for this model tends to separate definitions
20177 of non-inline member templates into a separate file, which should be
20178 compiled separately.
20179 @end table
20180
20181 G++ implements the Borland model on targets where the linker supports it,
20182 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
20183 Otherwise G++ implements neither automatic model.
20184
20185 You have the following options for dealing with template instantiations:
20186
20187 @enumerate
20188 @item
20189 Do nothing. Code written for the Borland model works fine, but
20190 each translation unit contains instances of each of the templates it
20191 uses. The duplicate instances will be discarded by the linker, but in
20192 a large program, this can lead to an unacceptable amount of code
20193 duplication in object files or shared libraries.
20194
20195 Duplicate instances of a template can be avoided by defining an explicit
20196 instantiation in one object file, and preventing the compiler from doing
20197 implicit instantiations in any other object files by using an explicit
20198 instantiation declaration, using the @code{extern template} syntax:
20199
20200 @smallexample
20201 extern template int max (int, int);
20202 @end smallexample
20203
20204 This syntax is defined in the C++ 2011 standard, but has been supported by
20205 G++ and other compilers since well before 2011.
20206
20207 Explicit instantiations can be used for the largest or most frequently
20208 duplicated instances, without having to know exactly which other instances
20209 are used in the rest of the program. You can scatter the explicit
20210 instantiations throughout your program, perhaps putting them in the
20211 translation units where the instances are used or the translation units
20212 that define the templates themselves; you can put all of the explicit
20213 instantiations you need into one big file; or you can create small files
20214 like
20215
20216 @smallexample
20217 #include "Foo.h"
20218 #include "Foo.cc"
20219
20220 template class Foo<int>;
20221 template ostream& operator <<
20222 (ostream&, const Foo<int>&);
20223 @end smallexample
20224
20225 @noindent
20226 for each of the instances you need, and create a template instantiation
20227 library from those.
20228
20229 This is the simplest option, but also offers flexibility and
20230 fine-grained control when necessary. It is also the most portable
20231 alternative and programs using this approach will work with most modern
20232 compilers.
20233
20234 @item
20235 @opindex frepo
20236 Compile your template-using code with @option{-frepo}. The compiler
20237 generates files with the extension @samp{.rpo} listing all of the
20238 template instantiations used in the corresponding object files that
20239 could be instantiated there; the link wrapper, @samp{collect2},
20240 then updates the @samp{.rpo} files to tell the compiler where to place
20241 those instantiations and rebuild any affected object files. The
20242 link-time overhead is negligible after the first pass, as the compiler
20243 continues to place the instantiations in the same files.
20244
20245 This can be a suitable option for application code written for the Borland
20246 model, as it usually just works. Code written for the Cfront model
20247 needs to be modified so that the template definitions are available at
20248 one or more points of instantiation; usually this is as simple as adding
20249 @code{#include <tmethods.cc>} to the end of each template header.
20250
20251 For library code, if you want the library to provide all of the template
20252 instantiations it needs, just try to link all of its object files
20253 together; the link will fail, but cause the instantiations to be
20254 generated as a side effect. Be warned, however, that this may cause
20255 conflicts if multiple libraries try to provide the same instantiations.
20256 For greater control, use explicit instantiation as described in the next
20257 option.
20258
20259 @item
20260 @opindex fno-implicit-templates
20261 Compile your code with @option{-fno-implicit-templates} to disable the
20262 implicit generation of template instances, and explicitly instantiate
20263 all the ones you use. This approach requires more knowledge of exactly
20264 which instances you need than do the others, but it's less
20265 mysterious and allows greater control if you want to ensure that only
20266 the intended instances are used.
20267
20268 If you are using Cfront-model code, you can probably get away with not
20269 using @option{-fno-implicit-templates} when compiling files that don't
20270 @samp{#include} the member template definitions.
20271
20272 If you use one big file to do the instantiations, you may want to
20273 compile it without @option{-fno-implicit-templates} so you get all of the
20274 instances required by your explicit instantiations (but not by any
20275 other files) without having to specify them as well.
20276
20277 In addition to forward declaration of explicit instantiations
20278 (with @code{extern}), G++ has extended the template instantiation
20279 syntax to support instantiation of the compiler support data for a
20280 template class (i.e.@: the vtable) without instantiating any of its
20281 members (with @code{inline}), and instantiation of only the static data
20282 members of a template class, without the support data or member
20283 functions (with @code{static}):
20284
20285 @smallexample
20286 inline template class Foo<int>;
20287 static template class Foo<int>;
20288 @end smallexample
20289 @end enumerate
20290
20291 @node Bound member functions
20292 @section Extracting the Function Pointer from a Bound Pointer to Member Function
20293 @cindex pmf
20294 @cindex pointer to member function
20295 @cindex bound pointer to member function
20296
20297 In C++, pointer to member functions (PMFs) are implemented using a wide
20298 pointer of sorts to handle all the possible call mechanisms; the PMF
20299 needs to store information about how to adjust the @samp{this} pointer,
20300 and if the function pointed to is virtual, where to find the vtable, and
20301 where in the vtable to look for the member function. If you are using
20302 PMFs in an inner loop, you should really reconsider that decision. If
20303 that is not an option, you can extract the pointer to the function that
20304 would be called for a given object/PMF pair and call it directly inside
20305 the inner loop, to save a bit of time.
20306
20307 Note that you still pay the penalty for the call through a
20308 function pointer; on most modern architectures, such a call defeats the
20309 branch prediction features of the CPU@. This is also true of normal
20310 virtual function calls.
20311
20312 The syntax for this extension is
20313
20314 @smallexample
20315 extern A a;
20316 extern int (A::*fp)();
20317 typedef int (*fptr)(A *);
20318
20319 fptr p = (fptr)(a.*fp);
20320 @end smallexample
20321
20322 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
20323 no object is needed to obtain the address of the function. They can be
20324 converted to function pointers directly:
20325
20326 @smallexample
20327 fptr p1 = (fptr)(&A::foo);
20328 @end smallexample
20329
20330 @opindex Wno-pmf-conversions
20331 You must specify @option{-Wno-pmf-conversions} to use this extension.
20332
20333 @node C++ Attributes
20334 @section C++-Specific Variable, Function, and Type Attributes
20335
20336 Some attributes only make sense for C++ programs.
20337
20338 @table @code
20339 @item abi_tag ("@var{tag}", ...)
20340 @cindex @code{abi_tag} function attribute
20341 @cindex @code{abi_tag} variable attribute
20342 @cindex @code{abi_tag} type attribute
20343 The @code{abi_tag} attribute can be applied to a function, variable, or class
20344 declaration. It modifies the mangled name of the entity to
20345 incorporate the tag name, in order to distinguish the function or
20346 class from an earlier version with a different ABI; perhaps the class
20347 has changed size, or the function has a different return type that is
20348 not encoded in the mangled name.
20349
20350 The attribute can also be applied to an inline namespace, but does not
20351 affect the mangled name of the namespace; in this case it is only used
20352 for @option{-Wabi-tag} warnings and automatic tagging of functions and
20353 variables. Tagging inline namespaces is generally preferable to
20354 tagging individual declarations, but the latter is sometimes
20355 necessary, such as when only certain members of a class need to be
20356 tagged.
20357
20358 The argument can be a list of strings of arbitrary length. The
20359 strings are sorted on output, so the order of the list is
20360 unimportant.
20361
20362 A redeclaration of an entity must not add new ABI tags,
20363 since doing so would change the mangled name.
20364
20365 The ABI tags apply to a name, so all instantiations and
20366 specializations of a template have the same tags. The attribute will
20367 be ignored if applied to an explicit specialization or instantiation.
20368
20369 The @option{-Wabi-tag} flag enables a warning about a class which does
20370 not have all the ABI tags used by its subobjects and virtual functions; for users with code
20371 that needs to coexist with an earlier ABI, using this option can help
20372 to find all affected types that need to be tagged.
20373
20374 When a type involving an ABI tag is used as the type of a variable or
20375 return type of a function where that tag is not already present in the
20376 signature of the function, the tag is automatically applied to the
20377 variable or function. @option{-Wabi-tag} also warns about this
20378 situation; this warning can be avoided by explicitly tagging the
20379 variable or function or moving it into a tagged inline namespace.
20380
20381 @item init_priority (@var{priority})
20382 @cindex @code{init_priority} variable attribute
20383
20384 In Standard C++, objects defined at namespace scope are guaranteed to be
20385 initialized in an order in strict accordance with that of their definitions
20386 @emph{in a given translation unit}. No guarantee is made for initializations
20387 across translation units. However, GNU C++ allows users to control the
20388 order of initialization of objects defined at namespace scope with the
20389 @code{init_priority} attribute by specifying a relative @var{priority},
20390 a constant integral expression currently bounded between 101 and 65535
20391 inclusive. Lower numbers indicate a higher priority.
20392
20393 In the following example, @code{A} would normally be created before
20394 @code{B}, but the @code{init_priority} attribute reverses that order:
20395
20396 @smallexample
20397 Some_Class A __attribute__ ((init_priority (2000)));
20398 Some_Class B __attribute__ ((init_priority (543)));
20399 @end smallexample
20400
20401 @noindent
20402 Note that the particular values of @var{priority} do not matter; only their
20403 relative ordering.
20404
20405 @item java_interface
20406 @cindex @code{java_interface} type attribute
20407
20408 This type attribute informs C++ that the class is a Java interface. It may
20409 only be applied to classes declared within an @code{extern "Java"} block.
20410 Calls to methods declared in this interface are dispatched using GCJ's
20411 interface table mechanism, instead of regular virtual table dispatch.
20412
20413 @item warn_unused
20414 @cindex @code{warn_unused} type attribute
20415
20416 For C++ types with non-trivial constructors and/or destructors it is
20417 impossible for the compiler to determine whether a variable of this
20418 type is truly unused if it is not referenced. This type attribute
20419 informs the compiler that variables of this type should be warned
20420 about if they appear to be unused, just like variables of fundamental
20421 types.
20422
20423 This attribute is appropriate for types which just represent a value,
20424 such as @code{std::string}; it is not appropriate for types which
20425 control a resource, such as @code{std::lock_guard}.
20426
20427 This attribute is also accepted in C, but it is unnecessary because C
20428 does not have constructors or destructors.
20429
20430 @end table
20431
20432 See also @ref{Namespace Association}.
20433
20434 @node Function Multiversioning
20435 @section Function Multiversioning
20436 @cindex function versions
20437
20438 With the GNU C++ front end, for x86 targets, you may specify multiple
20439 versions of a function, where each function is specialized for a
20440 specific target feature. At runtime, the appropriate version of the
20441 function is automatically executed depending on the characteristics of
20442 the execution platform. Here is an example.
20443
20444 @smallexample
20445 __attribute__ ((target ("default")))
20446 int foo ()
20447 @{
20448 // The default version of foo.
20449 return 0;
20450 @}
20451
20452 __attribute__ ((target ("sse4.2")))
20453 int foo ()
20454 @{
20455 // foo version for SSE4.2
20456 return 1;
20457 @}
20458
20459 __attribute__ ((target ("arch=atom")))
20460 int foo ()
20461 @{
20462 // foo version for the Intel ATOM processor
20463 return 2;
20464 @}
20465
20466 __attribute__ ((target ("arch=amdfam10")))
20467 int foo ()
20468 @{
20469 // foo version for the AMD Family 0x10 processors.
20470 return 3;
20471 @}
20472
20473 int main ()
20474 @{
20475 int (*p)() = &foo;
20476 assert ((*p) () == foo ());
20477 return 0;
20478 @}
20479 @end smallexample
20480
20481 In the above example, four versions of function foo are created. The
20482 first version of foo with the target attribute "default" is the default
20483 version. This version gets executed when no other target specific
20484 version qualifies for execution on a particular platform. A new version
20485 of foo is created by using the same function signature but with a
20486 different target string. Function foo is called or a pointer to it is
20487 taken just like a regular function. GCC takes care of doing the
20488 dispatching to call the right version at runtime. Refer to the
20489 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20490 Function Multiversioning} for more details.
20491
20492 @node Namespace Association
20493 @section Namespace Association
20494
20495 @strong{Caution:} The semantics of this extension are equivalent
20496 to C++ 2011 inline namespaces. Users should use inline namespaces
20497 instead as this extension will be removed in future versions of G++.
20498
20499 A using-directive with @code{__attribute ((strong))} is stronger
20500 than a normal using-directive in two ways:
20501
20502 @itemize @bullet
20503 @item
20504 Templates from the used namespace can be specialized and explicitly
20505 instantiated as though they were members of the using namespace.
20506
20507 @item
20508 The using namespace is considered an associated namespace of all
20509 templates in the used namespace for purposes of argument-dependent
20510 name lookup.
20511 @end itemize
20512
20513 The used namespace must be nested within the using namespace so that
20514 normal unqualified lookup works properly.
20515
20516 This is useful for composing a namespace transparently from
20517 implementation namespaces. For example:
20518
20519 @smallexample
20520 namespace std @{
20521 namespace debug @{
20522 template <class T> struct A @{ @};
20523 @}
20524 using namespace debug __attribute ((__strong__));
20525 template <> struct A<int> @{ @}; // @r{OK to specialize}
20526
20527 template <class T> void f (A<T>);
20528 @}
20529
20530 int main()
20531 @{
20532 f (std::A<float>()); // @r{lookup finds} std::f
20533 f (std::A<int>());
20534 @}
20535 @end smallexample
20536
20537 @node Type Traits
20538 @section Type Traits
20539
20540 The C++ front end implements syntactic extensions that allow
20541 compile-time determination of
20542 various characteristics of a type (or of a
20543 pair of types).
20544
20545 @table @code
20546 @item __has_nothrow_assign (type)
20547 If @code{type} is const qualified or is a reference type then the trait is
20548 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20549 is true, else if @code{type} is a cv class or union type with copy assignment
20550 operators that are known not to throw an exception then the trait is true,
20551 else it is false. Requires: @code{type} shall be a complete type,
20552 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20553
20554 @item __has_nothrow_copy (type)
20555 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20556 @code{type} is a cv class or union type with copy constructors that
20557 are known not to throw an exception then the trait is true, else it is false.
20558 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20559 @code{void}, or an array of unknown bound.
20560
20561 @item __has_nothrow_constructor (type)
20562 If @code{__has_trivial_constructor (type)} is true then the trait is
20563 true, else if @code{type} is a cv class or union type (or array
20564 thereof) with a default constructor that is known not to throw an
20565 exception then the trait is true, else it is false. Requires:
20566 @code{type} shall be a complete type, (possibly cv-qualified)
20567 @code{void}, or an array of unknown bound.
20568
20569 @item __has_trivial_assign (type)
20570 If @code{type} is const qualified or is a reference type then the trait is
20571 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20572 true, else if @code{type} is a cv class or union type with a trivial
20573 copy assignment ([class.copy]) then the trait is true, else it is
20574 false. Requires: @code{type} shall be a complete type, (possibly
20575 cv-qualified) @code{void}, or an array of unknown bound.
20576
20577 @item __has_trivial_copy (type)
20578 If @code{__is_pod (type)} is true or @code{type} is a reference type
20579 then the trait is true, else if @code{type} is a cv class or union type
20580 with a trivial copy constructor ([class.copy]) then the trait
20581 is true, else it is false. Requires: @code{type} shall be a complete
20582 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20583
20584 @item __has_trivial_constructor (type)
20585 If @code{__is_pod (type)} is true then the trait is true, else if
20586 @code{type} is a cv class or union type (or array thereof) with a
20587 trivial default constructor ([class.ctor]) then the trait is true,
20588 else it is false. Requires: @code{type} shall be a complete
20589 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20590
20591 @item __has_trivial_destructor (type)
20592 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20593 the trait is true, else if @code{type} is a cv class or union type (or
20594 array thereof) with a trivial destructor ([class.dtor]) then the trait
20595 is true, else it is false. Requires: @code{type} shall be a complete
20596 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20597
20598 @item __has_virtual_destructor (type)
20599 If @code{type} is a class type with a virtual destructor
20600 ([class.dtor]) then the trait is true, else it is false. Requires:
20601 @code{type} shall be a complete type, (possibly cv-qualified)
20602 @code{void}, or an array of unknown bound.
20603
20604 @item __is_abstract (type)
20605 If @code{type} is an abstract class ([class.abstract]) then the trait
20606 is true, else it is false. Requires: @code{type} shall be a complete
20607 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20608
20609 @item __is_base_of (base_type, derived_type)
20610 If @code{base_type} is a base class of @code{derived_type}
20611 ([class.derived]) then the trait is true, otherwise it is false.
20612 Top-level cv qualifications of @code{base_type} and
20613 @code{derived_type} are ignored. For the purposes of this trait, a
20614 class type is considered is own base. Requires: if @code{__is_class
20615 (base_type)} and @code{__is_class (derived_type)} are true and
20616 @code{base_type} and @code{derived_type} are not the same type
20617 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20618 type. A diagnostic is produced if this requirement is not met.
20619
20620 @item __is_class (type)
20621 If @code{type} is a cv class type, and not a union type
20622 ([basic.compound]) the trait is true, else it is false.
20623
20624 @item __is_empty (type)
20625 If @code{__is_class (type)} is false then the trait is false.
20626 Otherwise @code{type} is considered empty if and only if: @code{type}
20627 has no non-static data members, or all non-static data members, if
20628 any, are bit-fields of length 0, and @code{type} has no virtual
20629 members, and @code{type} has no virtual base classes, and @code{type}
20630 has no base classes @code{base_type} for which
20631 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20632 be a complete type, (possibly cv-qualified) @code{void}, or an array
20633 of unknown bound.
20634
20635 @item __is_enum (type)
20636 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20637 true, else it is false.
20638
20639 @item __is_literal_type (type)
20640 If @code{type} is a literal type ([basic.types]) the trait is
20641 true, else it is false. Requires: @code{type} shall be a complete type,
20642 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20643
20644 @item __is_pod (type)
20645 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20646 else it is false. Requires: @code{type} shall be a complete type,
20647 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20648
20649 @item __is_polymorphic (type)
20650 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20651 is true, else it is false. Requires: @code{type} shall be a complete
20652 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20653
20654 @item __is_standard_layout (type)
20655 If @code{type} is a standard-layout type ([basic.types]) the trait is
20656 true, else it is false. Requires: @code{type} shall be a complete
20657 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20658
20659 @item __is_trivial (type)
20660 If @code{type} is a trivial type ([basic.types]) the trait is
20661 true, else it is false. Requires: @code{type} shall be a complete
20662 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20663
20664 @item __is_union (type)
20665 If @code{type} is a cv union type ([basic.compound]) the trait is
20666 true, else it is false.
20667
20668 @item __underlying_type (type)
20669 The underlying type of @code{type}. Requires: @code{type} shall be
20670 an enumeration type ([dcl.enum]).
20671
20672 @end table
20673
20674
20675 @node C++ Concepts
20676 @section C++ Concepts
20677
20678 C++ concepts provide much-improved support for generic programming. In
20679 particular, they allow the specification of constraints on template arguments.
20680 The constraints are used to extend the usual overloading and partial
20681 specialization capabilities of the language, allowing generic data structures
20682 and algorithms to be ``refined'' based on their properties rather than their
20683 type names.
20684
20685 The following keywords are reserved for concepts.
20686
20687 @table @code
20688 @item assumes
20689 States an expression as an assumption, and if possible, verifies that the
20690 assumption is valid. For example, @code{assume(n > 0)}.
20691
20692 @item axiom
20693 Introduces an axiom definition. Axioms introduce requirements on values.
20694
20695 @item forall
20696 Introduces a universally quantified object in an axiom. For example,
20697 @code{forall (int n) n + 0 == n}).
20698
20699 @item concept
20700 Introduces a concept definition. Concepts are sets of syntactic and semantic
20701 requirements on types and their values.
20702
20703 @item requires
20704 Introduces constraints on template arguments or requirements for a member
20705 function of a class template.
20706
20707 @end table
20708
20709 The front end also exposes a number of internal mechanism that can be used
20710 to simplify the writing of type traits. Note that some of these traits are
20711 likely to be removed in the future.
20712
20713 @table @code
20714 @item __is_same (type1, type2)
20715 A binary type trait: true whenever the type arguments are the same.
20716
20717 @end table
20718
20719
20720 @node Java Exceptions
20721 @section Java Exceptions
20722
20723 The Java language uses a slightly different exception handling model
20724 from C++. Normally, GNU C++ automatically detects when you are
20725 writing C++ code that uses Java exceptions, and handle them
20726 appropriately. However, if C++ code only needs to execute destructors
20727 when Java exceptions are thrown through it, GCC guesses incorrectly.
20728 Sample problematic code is:
20729
20730 @smallexample
20731 struct S @{ ~S(); @};
20732 extern void bar(); // @r{is written in Java, and may throw exceptions}
20733 void foo()
20734 @{
20735 S s;
20736 bar();
20737 @}
20738 @end smallexample
20739
20740 @noindent
20741 The usual effect of an incorrect guess is a link failure, complaining of
20742 a missing routine called @samp{__gxx_personality_v0}.
20743
20744 You can inform the compiler that Java exceptions are to be used in a
20745 translation unit, irrespective of what it might think, by writing
20746 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20747 @samp{#pragma} must appear before any functions that throw or catch
20748 exceptions, or run destructors when exceptions are thrown through them.
20749
20750 You cannot mix Java and C++ exceptions in the same translation unit. It
20751 is believed to be safe to throw a C++ exception from one file through
20752 another file compiled for the Java exception model, or vice versa, but
20753 there may be bugs in this area.
20754
20755 @node Deprecated Features
20756 @section Deprecated Features
20757
20758 In the past, the GNU C++ compiler was extended to experiment with new
20759 features, at a time when the C++ language was still evolving. Now that
20760 the C++ standard is complete, some of those features are superseded by
20761 superior alternatives. Using the old features might cause a warning in
20762 some cases that the feature will be dropped in the future. In other
20763 cases, the feature might be gone already.
20764
20765 While the list below is not exhaustive, it documents some of the options
20766 that are now deprecated:
20767
20768 @table @code
20769 @item -fexternal-templates
20770 @itemx -falt-external-templates
20771 These are two of the many ways for G++ to implement template
20772 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20773 defines how template definitions have to be organized across
20774 implementation units. G++ has an implicit instantiation mechanism that
20775 should work just fine for standard-conforming code.
20776
20777 @item -fstrict-prototype
20778 @itemx -fno-strict-prototype
20779 Previously it was possible to use an empty prototype parameter list to
20780 indicate an unspecified number of parameters (like C), rather than no
20781 parameters, as C++ demands. This feature has been removed, except where
20782 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20783 @end table
20784
20785 G++ allows a virtual function returning @samp{void *} to be overridden
20786 by one returning a different pointer type. This extension to the
20787 covariant return type rules is now deprecated and will be removed from a
20788 future version.
20789
20790 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20791 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20792 and are now removed from G++. Code using these operators should be
20793 modified to use @code{std::min} and @code{std::max} instead.
20794
20795 The named return value extension has been deprecated, and is now
20796 removed from G++.
20797
20798 The use of initializer lists with new expressions has been deprecated,
20799 and is now removed from G++.
20800
20801 Floating and complex non-type template parameters have been deprecated,
20802 and are now removed from G++.
20803
20804 The implicit typename extension has been deprecated and is now
20805 removed from G++.
20806
20807 The use of default arguments in function pointers, function typedefs
20808 and other places where they are not permitted by the standard is
20809 deprecated and will be removed from a future version of G++.
20810
20811 G++ allows floating-point literals to appear in integral constant expressions,
20812 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20813 This extension is deprecated and will be removed from a future version.
20814
20815 G++ allows static data members of const floating-point type to be declared
20816 with an initializer in a class definition. The standard only allows
20817 initializers for static members of const integral types and const
20818 enumeration types so this extension has been deprecated and will be removed
20819 from a future version.
20820
20821 @node Backwards Compatibility
20822 @section Backwards Compatibility
20823 @cindex Backwards Compatibility
20824 @cindex ARM [Annotated C++ Reference Manual]
20825
20826 Now that there is a definitive ISO standard C++, G++ has a specification
20827 to adhere to. The C++ language evolved over time, and features that
20828 used to be acceptable in previous drafts of the standard, such as the ARM
20829 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20830 compilation of C++ written to such drafts, G++ contains some backwards
20831 compatibilities. @emph{All such backwards compatibility features are
20832 liable to disappear in future versions of G++.} They should be considered
20833 deprecated. @xref{Deprecated Features}.
20834
20835 @table @code
20836 @item For scope
20837 If a variable is declared at for scope, it used to remain in scope until
20838 the end of the scope that contained the for statement (rather than just
20839 within the for scope). G++ retains this, but issues a warning, if such a
20840 variable is accessed outside the for scope.
20841
20842 @item Implicit C language
20843 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20844 scope to set the language. On such systems, all header files are
20845 implicitly scoped inside a C language scope. Also, an empty prototype
20846 @code{()} is treated as an unspecified number of arguments, rather
20847 than no arguments, as C++ demands.
20848 @end table
20849
20850 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20851 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr