PR c++/69517 - [5/6 regression] SEGV on a VLA with excess initializer elements
[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 available in GCC for all targets and
1642 provide type safety.
1643
1644 There are other differences between these two methods. Space allocated
1645 with @code{alloca} exists until the containing @emph{function} returns.
1646 The space for a variable-length array is deallocated as soon as the array
1647 name's scope ends, unless you also use @code{alloca} in this scope.
1648
1649 Unlike GCC, G++ instruments variable-length arrays (@xref{Variable Length})
1650 with checks for erroneous uses: when a variable-length array object is
1651 created its runtime bounds are checked to detect non-positive values,
1652 integer overflows, sizes in excess of SIZE_MAX / 2 bytes, and excess
1653 initializers. When an erroneous variable-length array is detected
1654 the runtime arranges for an exception to be thrown that matches a handler
1655 of type @code{std::bad_array_length}.
1656
1657 Also unlike GCC, G++ allows variable-length arrays to be initialized.
1658 However, unlike initializer lists for ordinary multidimensional arrays,
1659 those for multidimensional variable-length arrays must be enclosed in
1660 pairs of curly braces delimiting each sequence of values to use to
1661 initialize each subarray. Initializer lists that aren't unambiguously
1662 enclosed in braces are rejected with an error. For example, in the
1663 following function, the initializer list for the ordinary @code{array}
1664 is accepted even though it isn't fully enclosed in braces. The same
1665 initializer list, however, wouldn't be accepted for a multidimensional
1666 variable-length array. To initialize the variable-length array @code{vla},
1667 the elements of the subarray @code{vla[m]} must be enclosed in braces
1668 as shown. As with ordinary arrays, elements that aren't initialized
1669 explicitly are default-initialized.
1670
1671 @smallexample
1672 void
1673 foo (int m, int n)
1674 @{
1675 int array[2][3] = @{ 1, 2, 4, 5, 6 @};
1676 int vla[m][n] = @{ @{ 1, 2 @}, @{ 4, 5, 6 @} @};
1677 @}
1678 @end smallexample
1679
1680
1681 In C programs (but not in C++) variable-length arrays can also be declared
1682 as function arguments:
1683
1684 @smallexample
1685 struct entry
1686 tester (int len, char data[len][len])
1687 @{
1688 /* @r{@dots{}} */
1689 @}
1690 @end smallexample
1691
1692 The length of an array is computed once when the storage is allocated
1693 and is remembered for the scope of the array in case you access it with
1694 @code{sizeof}.
1695
1696 If you want to pass the array first and the length afterward, you can
1697 use a forward declaration in the parameter list---another GNU extension.
1698
1699 @smallexample
1700 struct entry
1701 tester (int len; char data[len][len], int len)
1702 @{
1703 /* @r{@dots{}} */
1704 @}
1705 @end smallexample
1706
1707 @cindex parameter forward declaration
1708 The @samp{int len} before the semicolon is a @dfn{parameter forward
1709 declaration}, and it serves the purpose of making the name @code{len}
1710 known when the declaration of @code{data} is parsed.
1711
1712 You can write any number of such parameter forward declarations in the
1713 parameter list. They can be separated by commas or semicolons, but the
1714 last one must end with a semicolon, which is followed by the ``real''
1715 parameter declarations. Each forward declaration must match a ``real''
1716 declaration in parameter name and data type. ISO C99 does not support
1717 parameter forward declarations.
1718
1719 @node Variadic Macros
1720 @section Macros with a Variable Number of Arguments.
1721 @cindex variable number of arguments
1722 @cindex macro with variable arguments
1723 @cindex rest argument (in macro)
1724 @cindex variadic macros
1725
1726 In the ISO C standard of 1999, a macro can be declared to accept a
1727 variable number of arguments much as a function can. The syntax for
1728 defining the macro is similar to that of a function. Here is an
1729 example:
1730
1731 @smallexample
1732 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1733 @end smallexample
1734
1735 @noindent
1736 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1737 such a macro, it represents the zero or more tokens until the closing
1738 parenthesis that ends the invocation, including any commas. This set of
1739 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1740 wherever it appears. See the CPP manual for more information.
1741
1742 GCC has long supported variadic macros, and used a different syntax that
1743 allowed you to give a name to the variable arguments just like any other
1744 argument. Here is an example:
1745
1746 @smallexample
1747 #define debug(format, args...) fprintf (stderr, format, args)
1748 @end smallexample
1749
1750 @noindent
1751 This is in all ways equivalent to the ISO C example above, but arguably
1752 more readable and descriptive.
1753
1754 GNU CPP has two further variadic macro extensions, and permits them to
1755 be used with either of the above forms of macro definition.
1756
1757 In standard C, you are not allowed to leave the variable argument out
1758 entirely; but you are allowed to pass an empty argument. For example,
1759 this invocation is invalid in ISO C, because there is no comma after
1760 the string:
1761
1762 @smallexample
1763 debug ("A message")
1764 @end smallexample
1765
1766 GNU CPP permits you to completely omit the variable arguments in this
1767 way. In the above examples, the compiler would complain, though since
1768 the expansion of the macro still has the extra comma after the format
1769 string.
1770
1771 To help solve this problem, CPP behaves specially for variable arguments
1772 used with the token paste operator, @samp{##}. If instead you write
1773
1774 @smallexample
1775 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1776 @end smallexample
1777
1778 @noindent
1779 and if the variable arguments are omitted or empty, the @samp{##}
1780 operator causes the preprocessor to remove the comma before it. If you
1781 do provide some variable arguments in your macro invocation, GNU CPP
1782 does not complain about the paste operation and instead places the
1783 variable arguments after the comma. Just like any other pasted macro
1784 argument, these arguments are not macro expanded.
1785
1786 @node Escaped Newlines
1787 @section Slightly Looser Rules for Escaped Newlines
1788 @cindex escaped newlines
1789 @cindex newlines (escaped)
1790
1791 The preprocessor treatment of escaped newlines is more relaxed
1792 than that specified by the C90 standard, which requires the newline
1793 to immediately follow a backslash.
1794 GCC's implementation allows whitespace in the form
1795 of spaces, horizontal and vertical tabs, and form feeds between the
1796 backslash and the subsequent newline. The preprocessor issues a
1797 warning, but treats it as a valid escaped newline and combines the two
1798 lines to form a single logical line. This works within comments and
1799 tokens, as well as between tokens. Comments are @emph{not} treated as
1800 whitespace for the purposes of this relaxation, since they have not
1801 yet been replaced with spaces.
1802
1803 @node Subscripting
1804 @section Non-Lvalue Arrays May Have Subscripts
1805 @cindex subscripting
1806 @cindex arrays, non-lvalue
1807
1808 @cindex subscripting and function values
1809 In ISO C99, arrays that are not lvalues still decay to pointers, and
1810 may be subscripted, although they may not be modified or used after
1811 the next sequence point and the unary @samp{&} operator may not be
1812 applied to them. As an extension, GNU C allows such arrays to be
1813 subscripted in C90 mode, though otherwise they do not decay to
1814 pointers outside C99 mode. For example,
1815 this is valid in GNU C though not valid in C90:
1816
1817 @smallexample
1818 @group
1819 struct foo @{int a[4];@};
1820
1821 struct foo f();
1822
1823 bar (int index)
1824 @{
1825 return f().a[index];
1826 @}
1827 @end group
1828 @end smallexample
1829
1830 @node Pointer Arith
1831 @section Arithmetic on @code{void}- and Function-Pointers
1832 @cindex void pointers, arithmetic
1833 @cindex void, size of pointer to
1834 @cindex function pointers, arithmetic
1835 @cindex function, size of pointer to
1836
1837 In GNU C, addition and subtraction operations are supported on pointers to
1838 @code{void} and on pointers to functions. This is done by treating the
1839 size of a @code{void} or of a function as 1.
1840
1841 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1842 and on function types, and returns 1.
1843
1844 @opindex Wpointer-arith
1845 The option @option{-Wpointer-arith} requests a warning if these extensions
1846 are used.
1847
1848 @node Pointers to Arrays
1849 @section Pointers to Arrays with Qualifiers Work as Expected
1850 @cindex pointers to arrays
1851 @cindex const qualifier
1852
1853 In GNU C, pointers to arrays with qualifiers work similar to pointers
1854 to other qualified types. For example, a value of type @code{int (*)[5]}
1855 can be used to initialize a variable of type @code{const int (*)[5]}.
1856 These types are incompatible in ISO C because the @code{const} qualifier
1857 is formally attached to the element type of the array and not the
1858 array itself.
1859
1860 @smallexample
1861 extern void
1862 transpose (int N, int M, double out[M][N], const double in[N][M]);
1863 double x[3][2];
1864 double y[2][3];
1865 @r{@dots{}}
1866 transpose(3, 2, y, x);
1867 @end smallexample
1868
1869 @node Initializers
1870 @section Non-Constant Initializers
1871 @cindex initializers, non-constant
1872 @cindex non-constant initializers
1873
1874 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1875 automatic variable are not required to be constant expressions in GNU C@.
1876 Here is an example of an initializer with run-time varying elements:
1877
1878 @smallexample
1879 foo (float f, float g)
1880 @{
1881 float beat_freqs[2] = @{ f-g, f+g @};
1882 /* @r{@dots{}} */
1883 @}
1884 @end smallexample
1885
1886 @node Compound Literals
1887 @section Compound Literals
1888 @cindex constructor expressions
1889 @cindex initializations in expressions
1890 @cindex structures, constructor expression
1891 @cindex expressions, constructor
1892 @cindex compound literals
1893 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1894
1895 ISO C99 supports compound literals. A compound literal looks like
1896 a cast containing an initializer. Its value is an object of the
1897 type specified in the cast, containing the elements specified in
1898 the initializer; it is an lvalue. As an extension, GCC supports
1899 compound literals in C90 mode and in C++, though the semantics are
1900 somewhat different in C++.
1901
1902 Usually, the specified type is a structure. Assume that
1903 @code{struct foo} and @code{structure} are declared as shown:
1904
1905 @smallexample
1906 struct foo @{int a; char b[2];@} structure;
1907 @end smallexample
1908
1909 @noindent
1910 Here is an example of constructing a @code{struct foo} with a compound literal:
1911
1912 @smallexample
1913 structure = ((struct foo) @{x + y, 'a', 0@});
1914 @end smallexample
1915
1916 @noindent
1917 This is equivalent to writing the following:
1918
1919 @smallexample
1920 @{
1921 struct foo temp = @{x + y, 'a', 0@};
1922 structure = temp;
1923 @}
1924 @end smallexample
1925
1926 You can also construct an array, though this is dangerous in C++, as
1927 explained below. If all the elements of the compound literal are
1928 (made up of) simple constant expressions, suitable for use in
1929 initializers of objects of static storage duration, then the compound
1930 literal can be coerced to a pointer to its first element and used in
1931 such an initializer, as shown here:
1932
1933 @smallexample
1934 char **foo = (char *[]) @{ "x", "y", "z" @};
1935 @end smallexample
1936
1937 Compound literals for scalar types and union types are
1938 also allowed, but then the compound literal is equivalent
1939 to a cast.
1940
1941 As a GNU extension, GCC allows initialization of objects with static storage
1942 duration by compound literals (which is not possible in ISO C99, because
1943 the initializer is not a constant).
1944 It is handled as if the object is initialized only with the bracket
1945 enclosed list if the types of the compound literal and the object match.
1946 The initializer list of the compound literal must be constant.
1947 If the object being initialized has array type of unknown size, the size is
1948 determined by compound literal size.
1949
1950 @smallexample
1951 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1952 static int y[] = (int []) @{1, 2, 3@};
1953 static int z[] = (int [3]) @{1@};
1954 @end smallexample
1955
1956 @noindent
1957 The above lines are equivalent to the following:
1958 @smallexample
1959 static struct foo x = @{1, 'a', 'b'@};
1960 static int y[] = @{1, 2, 3@};
1961 static int z[] = @{1, 0, 0@};
1962 @end smallexample
1963
1964 In C, a compound literal designates an unnamed object with static or
1965 automatic storage duration. In C++, a compound literal designates a
1966 temporary object, which only lives until the end of its
1967 full-expression. As a result, well-defined C code that takes the
1968 address of a subobject of a compound literal can be undefined in C++,
1969 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1970 For instance, if the array compound literal example above appeared
1971 inside a function, any subsequent use of @samp{foo} in C++ has
1972 undefined behavior because the lifetime of the array ends after the
1973 declaration of @samp{foo}.
1974
1975 As an optimization, the C++ compiler sometimes gives array compound
1976 literals longer lifetimes: when the array either appears outside a
1977 function or has const-qualified type. If @samp{foo} and its
1978 initializer had elements of @samp{char *const} type rather than
1979 @samp{char *}, or if @samp{foo} were a global variable, the array
1980 would have static storage duration. But it is probably safest just to
1981 avoid the use of array compound literals in code compiled as C++.
1982
1983 @node Designated Inits
1984 @section Designated Initializers
1985 @cindex initializers with labeled elements
1986 @cindex labeled elements in initializers
1987 @cindex case labels in initializers
1988 @cindex designated initializers
1989
1990 Standard C90 requires the elements of an initializer to appear in a fixed
1991 order, the same as the order of the elements in the array or structure
1992 being initialized.
1993
1994 In ISO C99 you can give the elements in any order, specifying the array
1995 indices or structure field names they apply to, and GNU C allows this as
1996 an extension in C90 mode as well. This extension is not
1997 implemented in GNU C++.
1998
1999 To specify an array index, write
2000 @samp{[@var{index}] =} before the element value. For example,
2001
2002 @smallexample
2003 int a[6] = @{ [4] = 29, [2] = 15 @};
2004 @end smallexample
2005
2006 @noindent
2007 is equivalent to
2008
2009 @smallexample
2010 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2011 @end smallexample
2012
2013 @noindent
2014 The index values must be constant expressions, even if the array being
2015 initialized is automatic.
2016
2017 An alternative syntax for this that has been obsolete since GCC 2.5 but
2018 GCC still accepts is to write @samp{[@var{index}]} before the element
2019 value, with no @samp{=}.
2020
2021 To initialize a range of elements to the same value, write
2022 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2023 extension. For example,
2024
2025 @smallexample
2026 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2027 @end smallexample
2028
2029 @noindent
2030 If the value in it has side-effects, the side-effects happen only once,
2031 not for each initialized field by the range initializer.
2032
2033 @noindent
2034 Note that the length of the array is the highest value specified
2035 plus one.
2036
2037 In a structure initializer, specify the name of a field to initialize
2038 with @samp{.@var{fieldname} =} before the element value. For example,
2039 given the following structure,
2040
2041 @smallexample
2042 struct point @{ int x, y; @};
2043 @end smallexample
2044
2045 @noindent
2046 the following initialization
2047
2048 @smallexample
2049 struct point p = @{ .y = yvalue, .x = xvalue @};
2050 @end smallexample
2051
2052 @noindent
2053 is equivalent to
2054
2055 @smallexample
2056 struct point p = @{ xvalue, yvalue @};
2057 @end smallexample
2058
2059 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2060 @samp{@var{fieldname}:}, as shown here:
2061
2062 @smallexample
2063 struct point p = @{ y: yvalue, x: xvalue @};
2064 @end smallexample
2065
2066 Omitted field members are implicitly initialized the same as objects
2067 that have static storage duration.
2068
2069 @cindex designators
2070 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2071 @dfn{designator}. You can also use a designator (or the obsolete colon
2072 syntax) when initializing a union, to specify which element of the union
2073 should be used. For example,
2074
2075 @smallexample
2076 union foo @{ int i; double d; @};
2077
2078 union foo f = @{ .d = 4 @};
2079 @end smallexample
2080
2081 @noindent
2082 converts 4 to a @code{double} to store it in the union using
2083 the second element. By contrast, casting 4 to type @code{union foo}
2084 stores it into the union as the integer @code{i}, since it is
2085 an integer. (@xref{Cast to Union}.)
2086
2087 You can combine this technique of naming elements with ordinary C
2088 initialization of successive elements. Each initializer element that
2089 does not have a designator applies to the next consecutive element of the
2090 array or structure. For example,
2091
2092 @smallexample
2093 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2094 @end smallexample
2095
2096 @noindent
2097 is equivalent to
2098
2099 @smallexample
2100 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2101 @end smallexample
2102
2103 Labeling the elements of an array initializer is especially useful
2104 when the indices are characters or belong to an @code{enum} type.
2105 For example:
2106
2107 @smallexample
2108 int whitespace[256]
2109 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2110 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2111 @end smallexample
2112
2113 @cindex designator lists
2114 You can also write a series of @samp{.@var{fieldname}} and
2115 @samp{[@var{index}]} designators before an @samp{=} to specify a
2116 nested subobject to initialize; the list is taken relative to the
2117 subobject corresponding to the closest surrounding brace pair. For
2118 example, with the @samp{struct point} declaration above:
2119
2120 @smallexample
2121 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2122 @end smallexample
2123
2124 @noindent
2125 If the same field is initialized multiple times, it has the value from
2126 the last initialization. If any such overridden initialization has
2127 side-effect, it is unspecified whether the side-effect happens or not.
2128 Currently, GCC discards them and issues a warning.
2129
2130 @node Case Ranges
2131 @section Case Ranges
2132 @cindex case ranges
2133 @cindex ranges in case statements
2134
2135 You can specify a range of consecutive values in a single @code{case} label,
2136 like this:
2137
2138 @smallexample
2139 case @var{low} ... @var{high}:
2140 @end smallexample
2141
2142 @noindent
2143 This has the same effect as the proper number of individual @code{case}
2144 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2145
2146 This feature is especially useful for ranges of ASCII character codes:
2147
2148 @smallexample
2149 case 'A' ... 'Z':
2150 @end smallexample
2151
2152 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2153 it may be parsed wrong when you use it with integer values. For example,
2154 write this:
2155
2156 @smallexample
2157 case 1 ... 5:
2158 @end smallexample
2159
2160 @noindent
2161 rather than this:
2162
2163 @smallexample
2164 case 1...5:
2165 @end smallexample
2166
2167 @node Cast to Union
2168 @section Cast to a Union Type
2169 @cindex cast to a union
2170 @cindex union, casting to a
2171
2172 A cast to union type is similar to other casts, except that the type
2173 specified is a union type. You can specify the type either with
2174 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2175 a constructor, not a cast, and hence does not yield an lvalue like
2176 normal casts. (@xref{Compound Literals}.)
2177
2178 The types that may be cast to the union type are those of the members
2179 of the union. Thus, given the following union and variables:
2180
2181 @smallexample
2182 union foo @{ int i; double d; @};
2183 int x;
2184 double y;
2185 @end smallexample
2186
2187 @noindent
2188 both @code{x} and @code{y} can be cast to type @code{union foo}.
2189
2190 Using the cast as the right-hand side of an assignment to a variable of
2191 union type is equivalent to storing in a member of the union:
2192
2193 @smallexample
2194 union foo u;
2195 /* @r{@dots{}} */
2196 u = (union foo) x @equiv{} u.i = x
2197 u = (union foo) y @equiv{} u.d = y
2198 @end smallexample
2199
2200 You can also use the union cast as a function argument:
2201
2202 @smallexample
2203 void hack (union foo);
2204 /* @r{@dots{}} */
2205 hack ((union foo) x);
2206 @end smallexample
2207
2208 @node Mixed Declarations
2209 @section Mixed Declarations and Code
2210 @cindex mixed declarations and code
2211 @cindex declarations, mixed with code
2212 @cindex code, mixed with declarations
2213
2214 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2215 within compound statements. As an extension, GNU C also allows this in
2216 C90 mode. For example, you could do:
2217
2218 @smallexample
2219 int i;
2220 /* @r{@dots{}} */
2221 i++;
2222 int j = i + 2;
2223 @end smallexample
2224
2225 Each identifier is visible from where it is declared until the end of
2226 the enclosing block.
2227
2228 @node Function Attributes
2229 @section Declaring Attributes of Functions
2230 @cindex function attributes
2231 @cindex declaring attributes of functions
2232 @cindex @code{volatile} applied to function
2233 @cindex @code{const} applied to function
2234
2235 In GNU C, you can use function attributes to declare certain things
2236 about functions called in your program which help the compiler
2237 optimize calls and check your code more carefully. For example, you
2238 can use attributes to declare that a function never returns
2239 (@code{noreturn}), returns a value depending only on its arguments
2240 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2241
2242 You can also use attributes to control memory placement, code
2243 generation options or call/return conventions within the function
2244 being annotated. Many of these attributes are target-specific. For
2245 example, many targets support attributes for defining interrupt
2246 handler functions, which typically must follow special register usage
2247 and return conventions.
2248
2249 Function attributes are introduced by the @code{__attribute__} keyword
2250 on a declaration, followed by an attribute specification inside double
2251 parentheses. You can specify multiple attributes in a declaration by
2252 separating them by commas within the double parentheses or by
2253 immediately following an attribute declaration with another attribute
2254 declaration. @xref{Attribute Syntax}, for the exact rules on
2255 attribute syntax and placement.
2256
2257 GCC also supports attributes on
2258 variable declarations (@pxref{Variable Attributes}),
2259 labels (@pxref{Label Attributes}),
2260 enumerators (@pxref{Enumerator Attributes}),
2261 and types (@pxref{Type Attributes}).
2262
2263 There is some overlap between the purposes of attributes and pragmas
2264 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2265 found convenient to use @code{__attribute__} to achieve a natural
2266 attachment of attributes to their corresponding declarations, whereas
2267 @code{#pragma} is of use for compatibility with other compilers
2268 or constructs that do not naturally form part of the grammar.
2269
2270 In addition to the attributes documented here,
2271 GCC plugins may provide their own attributes.
2272
2273 @menu
2274 * Common Function Attributes::
2275 * AArch64 Function Attributes::
2276 * ARC Function Attributes::
2277 * ARM Function Attributes::
2278 * AVR Function Attributes::
2279 * Blackfin Function Attributes::
2280 * CR16 Function Attributes::
2281 * Epiphany Function Attributes::
2282 * H8/300 Function Attributes::
2283 * IA-64 Function Attributes::
2284 * M32C Function Attributes::
2285 * M32R/D Function Attributes::
2286 * m68k Function Attributes::
2287 * MCORE Function Attributes::
2288 * MeP Function Attributes::
2289 * MicroBlaze Function Attributes::
2290 * Microsoft Windows Function Attributes::
2291 * MIPS Function Attributes::
2292 * MSP430 Function Attributes::
2293 * NDS32 Function Attributes::
2294 * Nios II Function Attributes::
2295 * Nvidia PTX Function Attributes::
2296 * PowerPC Function Attributes::
2297 * RL78 Function Attributes::
2298 * RX Function Attributes::
2299 * S/390 Function Attributes::
2300 * SH Function Attributes::
2301 * SPU Function Attributes::
2302 * Symbian OS Function Attributes::
2303 * V850 Function Attributes::
2304 * Visium Function Attributes::
2305 * x86 Function Attributes::
2306 * Xstormy16 Function Attributes::
2307 @end menu
2308
2309 @node Common Function Attributes
2310 @subsection Common Function Attributes
2311
2312 The following attributes are supported on most targets.
2313
2314 @table @code
2315 @c Keep this table alphabetized by attribute name. Treat _ as space.
2316
2317 @item alias ("@var{target}")
2318 @cindex @code{alias} function attribute
2319 The @code{alias} attribute causes the declaration to be emitted as an
2320 alias for another symbol, which must be specified. For instance,
2321
2322 @smallexample
2323 void __f () @{ /* @r{Do something.} */; @}
2324 void f () __attribute__ ((weak, alias ("__f")));
2325 @end smallexample
2326
2327 @noindent
2328 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2329 mangled name for the target must be used. It is an error if @samp{__f}
2330 is not defined in the same translation unit.
2331
2332 This attribute requires assembler and object file support,
2333 and may not be available on all targets.
2334
2335 @item aligned (@var{alignment})
2336 @cindex @code{aligned} function attribute
2337 This attribute specifies a minimum alignment for the function,
2338 measured in bytes.
2339
2340 You cannot use this attribute to decrease the alignment of a function,
2341 only to increase it. However, when you explicitly specify a function
2342 alignment this overrides the effect of the
2343 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2344 function.
2345
2346 Note that the effectiveness of @code{aligned} attributes may be
2347 limited by inherent limitations in your linker. On many systems, the
2348 linker is only able to arrange for functions to be aligned up to a
2349 certain maximum alignment. (For some linkers, the maximum supported
2350 alignment may be very very small.) See your linker documentation for
2351 further information.
2352
2353 The @code{aligned} attribute can also be used for variables and fields
2354 (@pxref{Variable Attributes}.)
2355
2356 @item alloc_align
2357 @cindex @code{alloc_align} function attribute
2358 The @code{alloc_align} attribute is used to tell the compiler that the
2359 function return value points to memory, where the returned pointer minimum
2360 alignment is given by one of the functions parameters. GCC uses this
2361 information to improve pointer alignment analysis.
2362
2363 The function parameter denoting the allocated alignment is specified by
2364 one integer argument, whose number is the argument of the attribute.
2365 Argument numbering starts at one.
2366
2367 For instance,
2368
2369 @smallexample
2370 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2371 @end smallexample
2372
2373 @noindent
2374 declares that @code{my_memalign} returns memory with minimum alignment
2375 given by parameter 1.
2376
2377 @item alloc_size
2378 @cindex @code{alloc_size} function attribute
2379 The @code{alloc_size} attribute is used to tell the compiler that the
2380 function return value points to memory, where the size is given by
2381 one or two of the functions parameters. GCC uses this
2382 information to improve the correctness of @code{__builtin_object_size}.
2383
2384 The function parameter(s) denoting the allocated size are specified by
2385 one or two integer arguments supplied to the attribute. The allocated size
2386 is either the value of the single function argument specified or the product
2387 of the two function arguments specified. Argument numbering starts at
2388 one.
2389
2390 For instance,
2391
2392 @smallexample
2393 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2394 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2395 @end smallexample
2396
2397 @noindent
2398 declares that @code{my_calloc} returns memory of the size given by
2399 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2400 of the size given by parameter 2.
2401
2402 @item always_inline
2403 @cindex @code{always_inline} function attribute
2404 Generally, functions are not inlined unless optimization is specified.
2405 For functions declared inline, this attribute inlines the function
2406 independent of any restrictions that otherwise apply to inlining.
2407 Failure to inline such a function is diagnosed as an error.
2408 Note that if such a function is called indirectly the compiler may
2409 or may not inline it depending on optimization level and a failure
2410 to inline an indirect call may or may not be diagnosed.
2411
2412 @item artificial
2413 @cindex @code{artificial} function attribute
2414 This attribute is useful for small inline wrappers that if possible
2415 should appear during debugging as a unit. Depending on the debug
2416 info format it either means marking the function as artificial
2417 or using the caller location for all instructions within the inlined
2418 body.
2419
2420 @item assume_aligned
2421 @cindex @code{assume_aligned} function attribute
2422 The @code{assume_aligned} attribute is used to tell the compiler that the
2423 function return value points to memory, where the returned pointer minimum
2424 alignment is given by the first argument.
2425 If the attribute has two arguments, the second argument is misalignment offset.
2426
2427 For instance
2428
2429 @smallexample
2430 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2431 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2432 @end smallexample
2433
2434 @noindent
2435 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2436 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2437 to 8.
2438
2439 @item bnd_instrument
2440 @cindex @code{bnd_instrument} function attribute
2441 The @code{bnd_instrument} attribute on functions is used to inform the
2442 compiler that the function should be instrumented when compiled
2443 with the @option{-fchkp-instrument-marked-only} option.
2444
2445 @item bnd_legacy
2446 @cindex @code{bnd_legacy} function attribute
2447 @cindex Pointer Bounds Checker attributes
2448 The @code{bnd_legacy} attribute on functions is used to inform the
2449 compiler that the function should not be instrumented when compiled
2450 with the @option{-fcheck-pointer-bounds} option.
2451
2452 @item cold
2453 @cindex @code{cold} function attribute
2454 The @code{cold} attribute on functions is used to inform the compiler that
2455 the function is unlikely to be executed. The function is optimized for
2456 size rather than speed and on many targets it is placed into a special
2457 subsection of the text section so all cold functions appear close together,
2458 improving code locality of non-cold parts of program. The paths leading
2459 to calls of cold functions within code are marked as unlikely by the branch
2460 prediction mechanism. It is thus useful to mark functions used to handle
2461 unlikely conditions, such as @code{perror}, as cold to improve optimization
2462 of hot functions that do call marked functions in rare occasions.
2463
2464 When profile feedback is available, via @option{-fprofile-use}, cold functions
2465 are automatically detected and this attribute is ignored.
2466
2467 @item const
2468 @cindex @code{const} function attribute
2469 @cindex functions that have no side effects
2470 Many functions do not examine any values except their arguments, and
2471 have no effects except the return value. Basically this is just slightly
2472 more strict class than the @code{pure} attribute below, since function is not
2473 allowed to read global memory.
2474
2475 @cindex pointer arguments
2476 Note that a function that has pointer arguments and examines the data
2477 pointed to must @emph{not} be declared @code{const}. Likewise, a
2478 function that calls a non-@code{const} function usually must not be
2479 @code{const}. It does not make sense for a @code{const} function to
2480 return @code{void}.
2481
2482 @item constructor
2483 @itemx destructor
2484 @itemx constructor (@var{priority})
2485 @itemx destructor (@var{priority})
2486 @cindex @code{constructor} function attribute
2487 @cindex @code{destructor} function attribute
2488 The @code{constructor} attribute causes the function to be called
2489 automatically before execution enters @code{main ()}. Similarly, the
2490 @code{destructor} attribute causes the function to be called
2491 automatically after @code{main ()} completes or @code{exit ()} is
2492 called. Functions with these attributes are useful for
2493 initializing data that is used implicitly during the execution of
2494 the program.
2495
2496 You may provide an optional integer priority to control the order in
2497 which constructor and destructor functions are run. A constructor
2498 with a smaller priority number runs before a constructor with a larger
2499 priority number; the opposite relationship holds for destructors. So,
2500 if you have a constructor that allocates a resource and a destructor
2501 that deallocates the same resource, both functions typically have the
2502 same priority. The priorities for constructor and destructor
2503 functions are the same as those specified for namespace-scope C++
2504 objects (@pxref{C++ Attributes}).
2505
2506 These attributes are not currently implemented for Objective-C@.
2507
2508 @item deprecated
2509 @itemx deprecated (@var{msg})
2510 @cindex @code{deprecated} function attribute
2511 The @code{deprecated} attribute results in a warning if the function
2512 is used anywhere in the source file. This is useful when identifying
2513 functions that are expected to be removed in a future version of a
2514 program. The warning also includes the location of the declaration
2515 of the deprecated function, to enable users to easily find further
2516 information about why the function is deprecated, or what they should
2517 do instead. Note that the warnings only occurs for uses:
2518
2519 @smallexample
2520 int old_fn () __attribute__ ((deprecated));
2521 int old_fn ();
2522 int (*fn_ptr)() = old_fn;
2523 @end smallexample
2524
2525 @noindent
2526 results in a warning on line 3 but not line 2. The optional @var{msg}
2527 argument, which must be a string, is printed in the warning if
2528 present.
2529
2530 The @code{deprecated} attribute can also be used for variables and
2531 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2532
2533 @item error ("@var{message}")
2534 @itemx warning ("@var{message}")
2535 @cindex @code{error} function attribute
2536 @cindex @code{warning} function attribute
2537 If the @code{error} or @code{warning} attribute
2538 is used on a function declaration and a call to such a function
2539 is not eliminated through dead code elimination or other optimizations,
2540 an error or warning (respectively) that includes @var{message} is diagnosed.
2541 This is useful
2542 for compile-time checking, especially together with @code{__builtin_constant_p}
2543 and inline functions where checking the inline function arguments is not
2544 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2545
2546 While it is possible to leave the function undefined and thus invoke
2547 a link failure (to define the function with
2548 a message in @code{.gnu.warning*} section),
2549 when using these attributes the problem is diagnosed
2550 earlier and with exact location of the call even in presence of inline
2551 functions or when not emitting debugging information.
2552
2553 @item externally_visible
2554 @cindex @code{externally_visible} function attribute
2555 This attribute, attached to a global variable or function, nullifies
2556 the effect of the @option{-fwhole-program} command-line option, so the
2557 object remains visible outside the current compilation unit.
2558
2559 If @option{-fwhole-program} is used together with @option{-flto} and
2560 @command{gold} is used as the linker plugin,
2561 @code{externally_visible} attributes are automatically added to functions
2562 (not variable yet due to a current @command{gold} issue)
2563 that are accessed outside of LTO objects according to resolution file
2564 produced by @command{gold}.
2565 For other linkers that cannot generate resolution file,
2566 explicit @code{externally_visible} attributes are still necessary.
2567
2568 @item flatten
2569 @cindex @code{flatten} function attribute
2570 Generally, inlining into a function is limited. For a function marked with
2571 this attribute, every call inside this function is inlined, if possible.
2572 Whether the function itself is considered for inlining depends on its size and
2573 the current inlining parameters.
2574
2575 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2576 @cindex @code{format} function attribute
2577 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2578 @opindex Wformat
2579 The @code{format} attribute specifies that a function takes @code{printf},
2580 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2581 should be type-checked against a format string. For example, the
2582 declaration:
2583
2584 @smallexample
2585 extern int
2586 my_printf (void *my_object, const char *my_format, ...)
2587 __attribute__ ((format (printf, 2, 3)));
2588 @end smallexample
2589
2590 @noindent
2591 causes the compiler to check the arguments in calls to @code{my_printf}
2592 for consistency with the @code{printf} style format string argument
2593 @code{my_format}.
2594
2595 The parameter @var{archetype} determines how the format string is
2596 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2597 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2598 @code{strfmon}. (You can also use @code{__printf__},
2599 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2600 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2601 @code{ms_strftime} are also present.
2602 @var{archetype} values such as @code{printf} refer to the formats accepted
2603 by the system's C runtime library,
2604 while values prefixed with @samp{gnu_} always refer
2605 to the formats accepted by the GNU C Library. On Microsoft Windows
2606 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2607 @file{msvcrt.dll} library.
2608 The parameter @var{string-index}
2609 specifies which argument is the format string argument (starting
2610 from 1), while @var{first-to-check} is the number of the first
2611 argument to check against the format string. For functions
2612 where the arguments are not available to be checked (such as
2613 @code{vprintf}), specify the third parameter as zero. In this case the
2614 compiler only checks the format string for consistency. For
2615 @code{strftime} formats, the third parameter is required to be zero.
2616 Since non-static C++ methods have an implicit @code{this} argument, the
2617 arguments of such methods should be counted from two, not one, when
2618 giving values for @var{string-index} and @var{first-to-check}.
2619
2620 In the example above, the format string (@code{my_format}) is the second
2621 argument of the function @code{my_print}, and the arguments to check
2622 start with the third argument, so the correct parameters for the format
2623 attribute are 2 and 3.
2624
2625 @opindex ffreestanding
2626 @opindex fno-builtin
2627 The @code{format} attribute allows you to identify your own functions
2628 that take format strings as arguments, so that GCC can check the
2629 calls to these functions for errors. The compiler always (unless
2630 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2631 for the standard library functions @code{printf}, @code{fprintf},
2632 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2633 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2634 warnings are requested (using @option{-Wformat}), so there is no need to
2635 modify the header file @file{stdio.h}. In C99 mode, the functions
2636 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2637 @code{vsscanf} are also checked. Except in strictly conforming C
2638 standard modes, the X/Open function @code{strfmon} is also checked as
2639 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2640 @xref{C Dialect Options,,Options Controlling C Dialect}.
2641
2642 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2643 recognized in the same context. Declarations including these format attributes
2644 are parsed for correct syntax, however the result of checking of such format
2645 strings is not yet defined, and is not carried out by this version of the
2646 compiler.
2647
2648 The target may also provide additional types of format checks.
2649 @xref{Target Format Checks,,Format Checks Specific to Particular
2650 Target Machines}.
2651
2652 @item format_arg (@var{string-index})
2653 @cindex @code{format_arg} function attribute
2654 @opindex Wformat-nonliteral
2655 The @code{format_arg} attribute specifies that a function takes a format
2656 string for a @code{printf}, @code{scanf}, @code{strftime} or
2657 @code{strfmon} style function and modifies it (for example, to translate
2658 it into another language), so the result can be passed to a
2659 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2660 function (with the remaining arguments to the format function the same
2661 as they would have been for the unmodified string). For example, the
2662 declaration:
2663
2664 @smallexample
2665 extern char *
2666 my_dgettext (char *my_domain, const char *my_format)
2667 __attribute__ ((format_arg (2)));
2668 @end smallexample
2669
2670 @noindent
2671 causes the compiler to check the arguments in calls to a @code{printf},
2672 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2673 format string argument is a call to the @code{my_dgettext} function, for
2674 consistency with the format string argument @code{my_format}. If the
2675 @code{format_arg} attribute had not been specified, all the compiler
2676 could tell in such calls to format functions would be that the format
2677 string argument is not constant; this would generate a warning when
2678 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2679 without the attribute.
2680
2681 The parameter @var{string-index} specifies which argument is the format
2682 string argument (starting from one). Since non-static C++ methods have
2683 an implicit @code{this} argument, the arguments of such methods should
2684 be counted from two.
2685
2686 The @code{format_arg} attribute allows you to identify your own
2687 functions that modify format strings, so that GCC can check the
2688 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2689 type function whose operands are a call to one of your own function.
2690 The compiler always treats @code{gettext}, @code{dgettext}, and
2691 @code{dcgettext} in this manner except when strict ISO C support is
2692 requested by @option{-ansi} or an appropriate @option{-std} option, or
2693 @option{-ffreestanding} or @option{-fno-builtin}
2694 is used. @xref{C Dialect Options,,Options
2695 Controlling C Dialect}.
2696
2697 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2698 @code{NSString} reference for compatibility with the @code{format} attribute
2699 above.
2700
2701 The target may also allow additional types in @code{format-arg} attributes.
2702 @xref{Target Format Checks,,Format Checks Specific to Particular
2703 Target Machines}.
2704
2705 @item gnu_inline
2706 @cindex @code{gnu_inline} function attribute
2707 This attribute should be used with a function that is also declared
2708 with the @code{inline} keyword. It directs GCC to treat the function
2709 as if it were defined in gnu90 mode even when compiling in C99 or
2710 gnu99 mode.
2711
2712 If the function is declared @code{extern}, then this definition of the
2713 function is used only for inlining. In no case is the function
2714 compiled as a standalone function, not even if you take its address
2715 explicitly. Such an address becomes an external reference, as if you
2716 had only declared the function, and had not defined it. This has
2717 almost the effect of a macro. The way to use this is to put a
2718 function definition in a header file with this attribute, and put
2719 another copy of the function, without @code{extern}, in a library
2720 file. The definition in the header file causes most calls to the
2721 function to be inlined. If any uses of the function remain, they
2722 refer to the single copy in the library. Note that the two
2723 definitions of the functions need not be precisely the same, although
2724 if they do not have the same effect your program may behave oddly.
2725
2726 In C, if the function is neither @code{extern} nor @code{static}, then
2727 the function is compiled as a standalone function, as well as being
2728 inlined where possible.
2729
2730 This is how GCC traditionally handled functions declared
2731 @code{inline}. Since ISO C99 specifies a different semantics for
2732 @code{inline}, this function attribute is provided as a transition
2733 measure and as a useful feature in its own right. This attribute is
2734 available in GCC 4.1.3 and later. It is available if either of the
2735 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2736 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2737 Function is As Fast As a Macro}.
2738
2739 In C++, this attribute does not depend on @code{extern} in any way,
2740 but it still requires the @code{inline} keyword to enable its special
2741 behavior.
2742
2743 @item hot
2744 @cindex @code{hot} function attribute
2745 The @code{hot} attribute on a function is used to inform the compiler that
2746 the function is a hot spot of the compiled program. The function is
2747 optimized more aggressively and on many targets it is placed into a special
2748 subsection of the text section so all hot functions appear close together,
2749 improving locality.
2750
2751 When profile feedback is available, via @option{-fprofile-use}, hot functions
2752 are automatically detected and this attribute is ignored.
2753
2754 @item ifunc ("@var{resolver}")
2755 @cindex @code{ifunc} function attribute
2756 @cindex indirect functions
2757 @cindex functions that are dynamically resolved
2758 The @code{ifunc} attribute is used to mark a function as an indirect
2759 function using the STT_GNU_IFUNC symbol type extension to the ELF
2760 standard. This allows the resolution of the symbol value to be
2761 determined dynamically at load time, and an optimized version of the
2762 routine can be selected for the particular processor or other system
2763 characteristics determined then. To use this attribute, first define
2764 the implementation functions available, and a resolver function that
2765 returns a pointer to the selected implementation function. The
2766 implementation functions' declarations must match the API of the
2767 function being implemented, the resolver's declaration is be a
2768 function returning pointer to void function returning void:
2769
2770 @smallexample
2771 void *my_memcpy (void *dst, const void *src, size_t len)
2772 @{
2773 @dots{}
2774 @}
2775
2776 static void (*resolve_memcpy (void)) (void)
2777 @{
2778 return my_memcpy; // we'll just always select this routine
2779 @}
2780 @end smallexample
2781
2782 @noindent
2783 The exported header file declaring the function the user calls would
2784 contain:
2785
2786 @smallexample
2787 extern void *memcpy (void *, const void *, size_t);
2788 @end smallexample
2789
2790 @noindent
2791 allowing the user to call this as a regular function, unaware of the
2792 implementation. Finally, the indirect function needs to be defined in
2793 the same translation unit as the resolver function:
2794
2795 @smallexample
2796 void *memcpy (void *, const void *, size_t)
2797 __attribute__ ((ifunc ("resolve_memcpy")));
2798 @end smallexample
2799
2800 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2801 and GNU C Library version 2.11.1 are required to use this feature.
2802
2803 @item interrupt
2804 @itemx interrupt_handler
2805 Many GCC back ends support attributes to indicate that a function is
2806 an interrupt handler, which tells the compiler to generate function
2807 entry and exit sequences that differ from those from regular
2808 functions. The exact syntax and behavior are target-specific;
2809 refer to the following subsections for details.
2810
2811 @item leaf
2812 @cindex @code{leaf} function attribute
2813 Calls to external functions with this attribute must return to the
2814 current compilation unit only by return or by exception handling. In
2815 particular, a leaf function is not allowed to invoke callback functions
2816 passed to it from the current compilation unit, directly call functions
2817 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2818 might still call functions from other compilation units and thus they
2819 are not necessarily leaf in the sense that they contain no function
2820 calls at all.
2821
2822 The attribute is intended for library functions to improve dataflow
2823 analysis. The compiler takes the hint that any data not escaping the
2824 current compilation unit cannot be used or modified by the leaf
2825 function. For example, the @code{sin} function is a leaf function, but
2826 @code{qsort} is not.
2827
2828 Note that leaf functions might indirectly run a signal handler defined
2829 in the current compilation unit that uses static variables. Similarly,
2830 when lazy symbol resolution is in effect, leaf functions might invoke
2831 indirect functions whose resolver function or implementation function is
2832 defined in the current compilation unit and uses static variables. There
2833 is no standard-compliant way to write such a signal handler, resolver
2834 function, or implementation function, and the best that you can do is to
2835 remove the @code{leaf} attribute or mark all such static variables
2836 @code{volatile}. Lastly, for ELF-based systems that support symbol
2837 interposition, care should be taken that functions defined in the
2838 current compilation unit do not unexpectedly interpose other symbols
2839 based on the defined standards mode and defined feature test macros;
2840 otherwise an inadvertent callback would be added.
2841
2842 The attribute has no effect on functions defined within the current
2843 compilation unit. This is to allow easy merging of multiple compilation
2844 units into one, for example, by using the link-time optimization. For
2845 this reason the attribute is not allowed on types to annotate indirect
2846 calls.
2847
2848 @item malloc
2849 @cindex @code{malloc} function attribute
2850 @cindex functions that behave like malloc
2851 This tells the compiler that a function is @code{malloc}-like, i.e.,
2852 that the pointer @var{P} returned by the function cannot alias any
2853 other pointer valid when the function returns, and moreover no
2854 pointers to valid objects occur in any storage addressed by @var{P}.
2855
2856 Using this attribute can improve optimization. Functions like
2857 @code{malloc} and @code{calloc} have this property because they return
2858 a pointer to uninitialized or zeroed-out storage. However, functions
2859 like @code{realloc} do not have this property, as they can return a
2860 pointer to storage containing pointers.
2861
2862 @item no_icf
2863 @cindex @code{no_icf} function attribute
2864 This function attribute prevents a functions from being merged with another
2865 semantically equivalent function.
2866
2867 @item no_instrument_function
2868 @cindex @code{no_instrument_function} function attribute
2869 @opindex finstrument-functions
2870 If @option{-finstrument-functions} is given, profiling function calls are
2871 generated at entry and exit of most user-compiled functions.
2872 Functions with this attribute are not so instrumented.
2873
2874 @item no_reorder
2875 @cindex @code{no_reorder} function attribute
2876 Do not reorder functions or variables marked @code{no_reorder}
2877 against each other or top level assembler statements the executable.
2878 The actual order in the program will depend on the linker command
2879 line. Static variables marked like this are also not removed.
2880 This has a similar effect
2881 as the @option{-fno-toplevel-reorder} option, but only applies to the
2882 marked symbols.
2883
2884 @item no_sanitize_address
2885 @itemx no_address_safety_analysis
2886 @cindex @code{no_sanitize_address} function attribute
2887 The @code{no_sanitize_address} attribute on functions is used
2888 to inform the compiler that it should not instrument memory accesses
2889 in the function when compiling with the @option{-fsanitize=address} option.
2890 The @code{no_address_safety_analysis} is a deprecated alias of the
2891 @code{no_sanitize_address} attribute, new code should use
2892 @code{no_sanitize_address}.
2893
2894 @item no_sanitize_thread
2895 @cindex @code{no_sanitize_thread} function attribute
2896 The @code{no_sanitize_thread} attribute on functions is used
2897 to inform the compiler that it should not instrument memory accesses
2898 in the function when compiling with the @option{-fsanitize=thread} option.
2899
2900 @item no_sanitize_undefined
2901 @cindex @code{no_sanitize_undefined} function attribute
2902 The @code{no_sanitize_undefined} attribute on functions is used
2903 to inform the compiler that it should not check for undefined behavior
2904 in the function when compiling with the @option{-fsanitize=undefined} option.
2905
2906 @item no_split_stack
2907 @cindex @code{no_split_stack} function attribute
2908 @opindex fsplit-stack
2909 If @option{-fsplit-stack} is given, functions have a small
2910 prologue which decides whether to split the stack. Functions with the
2911 @code{no_split_stack} attribute do not have that prologue, and thus
2912 may run with only a small amount of stack space available.
2913
2914 @item no_stack_limit
2915 @cindex @code{no_stack_limit} function attribute
2916 This attribute locally overrides the @option{-fstack-limit-register}
2917 and @option{-fstack-limit-symbol} command-line options; it has the effect
2918 of disabling stack limit checking in the function it applies to.
2919
2920 @item noclone
2921 @cindex @code{noclone} function attribute
2922 This function attribute prevents a function from being considered for
2923 cloning---a mechanism that produces specialized copies of functions
2924 and which is (currently) performed by interprocedural constant
2925 propagation.
2926
2927 @item noinline
2928 @cindex @code{noinline} function attribute
2929 This function attribute prevents a function from being considered for
2930 inlining.
2931 @c Don't enumerate the optimizations by name here; we try to be
2932 @c future-compatible with this mechanism.
2933 If the function does not have side-effects, there are optimizations
2934 other than inlining that cause function calls to be optimized away,
2935 although the function call is live. To keep such calls from being
2936 optimized away, put
2937 @smallexample
2938 asm ("");
2939 @end smallexample
2940
2941 @noindent
2942 (@pxref{Extended Asm}) in the called function, to serve as a special
2943 side-effect.
2944
2945 @item nonnull (@var{arg-index}, @dots{})
2946 @cindex @code{nonnull} function attribute
2947 @cindex functions with non-null pointer arguments
2948 The @code{nonnull} attribute specifies that some function parameters should
2949 be non-null pointers. For instance, the declaration:
2950
2951 @smallexample
2952 extern void *
2953 my_memcpy (void *dest, const void *src, size_t len)
2954 __attribute__((nonnull (1, 2)));
2955 @end smallexample
2956
2957 @noindent
2958 causes the compiler to check that, in calls to @code{my_memcpy},
2959 arguments @var{dest} and @var{src} are non-null. If the compiler
2960 determines that a null pointer is passed in an argument slot marked
2961 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2962 is issued. The compiler may also choose to make optimizations based
2963 on the knowledge that certain function arguments will never be null.
2964
2965 If no argument index list is given to the @code{nonnull} attribute,
2966 all pointer arguments are marked as non-null. To illustrate, the
2967 following declaration is equivalent to the previous example:
2968
2969 @smallexample
2970 extern void *
2971 my_memcpy (void *dest, const void *src, size_t len)
2972 __attribute__((nonnull));
2973 @end smallexample
2974
2975 @item noplt
2976 @cindex @code{noplt} function attribute
2977 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2978 Calls to functions marked with this attribute in position-independent code
2979 do not use the PLT.
2980
2981 @smallexample
2982 @group
2983 /* Externally defined function foo. */
2984 int foo () __attribute__ ((noplt));
2985
2986 int
2987 main (/* @r{@dots{}} */)
2988 @{
2989 /* @r{@dots{}} */
2990 foo ();
2991 /* @r{@dots{}} */
2992 @}
2993 @end group
2994 @end smallexample
2995
2996 The @code{noplt} attribute on function @code{foo}
2997 tells the compiler to assume that
2998 the function @code{foo} is externally defined and that the call to
2999 @code{foo} must avoid the PLT
3000 in position-independent code.
3001
3002 In position-dependent code, a few targets also convert calls to
3003 functions that are marked to not use the PLT to use the GOT instead.
3004
3005 @item noreturn
3006 @cindex @code{noreturn} function attribute
3007 @cindex functions that never return
3008 A few standard library functions, such as @code{abort} and @code{exit},
3009 cannot return. GCC knows this automatically. Some programs define
3010 their own functions that never return. You can declare them
3011 @code{noreturn} to tell the compiler this fact. For example,
3012
3013 @smallexample
3014 @group
3015 void fatal () __attribute__ ((noreturn));
3016
3017 void
3018 fatal (/* @r{@dots{}} */)
3019 @{
3020 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3021 exit (1);
3022 @}
3023 @end group
3024 @end smallexample
3025
3026 The @code{noreturn} keyword tells the compiler to assume that
3027 @code{fatal} cannot return. It can then optimize without regard to what
3028 would happen if @code{fatal} ever did return. This makes slightly
3029 better code. More importantly, it helps avoid spurious warnings of
3030 uninitialized variables.
3031
3032 The @code{noreturn} keyword does not affect the exceptional path when that
3033 applies: a @code{noreturn}-marked function may still return to the caller
3034 by throwing an exception or calling @code{longjmp}.
3035
3036 Do not assume that registers saved by the calling function are
3037 restored before calling the @code{noreturn} function.
3038
3039 It does not make sense for a @code{noreturn} function to have a return
3040 type other than @code{void}.
3041
3042 @item nothrow
3043 @cindex @code{nothrow} function attribute
3044 The @code{nothrow} attribute is used to inform the compiler that a
3045 function cannot throw an exception. For example, most functions in
3046 the standard C library can be guaranteed not to throw an exception
3047 with the notable exceptions of @code{qsort} and @code{bsearch} that
3048 take function pointer arguments.
3049
3050 @item optimize
3051 @cindex @code{optimize} function attribute
3052 The @code{optimize} attribute is used to specify that a function is to
3053 be compiled with different optimization options than specified on the
3054 command line. Arguments can either be numbers or strings. Numbers
3055 are assumed to be an optimization level. Strings that begin with
3056 @code{O} are assumed to be an optimization option, while other options
3057 are assumed to be used with a @code{-f} prefix. You can also use the
3058 @samp{#pragma GCC optimize} pragma to set the optimization options
3059 that affect more than one function.
3060 @xref{Function Specific Option Pragmas}, for details about the
3061 @samp{#pragma GCC optimize} pragma.
3062
3063 This can be used for instance to have frequently-executed functions
3064 compiled with more aggressive optimization options that produce faster
3065 and larger code, while other functions can be compiled with less
3066 aggressive options.
3067
3068 @item pure
3069 @cindex @code{pure} function attribute
3070 @cindex functions that have no side effects
3071 Many functions have no effects except the return value and their
3072 return value depends only on the parameters and/or global variables.
3073 Such a function can be subject
3074 to common subexpression elimination and loop optimization just as an
3075 arithmetic operator would be. These functions should be declared
3076 with the attribute @code{pure}. For example,
3077
3078 @smallexample
3079 int square (int) __attribute__ ((pure));
3080 @end smallexample
3081
3082 @noindent
3083 says that the hypothetical function @code{square} is safe to call
3084 fewer times than the program says.
3085
3086 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3087 Interesting non-pure functions are functions with infinite loops or those
3088 depending on volatile memory or other system resource, that may change between
3089 two consecutive calls (such as @code{feof} in a multithreading environment).
3090
3091 @item returns_nonnull
3092 @cindex @code{returns_nonnull} function attribute
3093 The @code{returns_nonnull} attribute specifies that the function
3094 return value should be a non-null pointer. For instance, the declaration:
3095
3096 @smallexample
3097 extern void *
3098 mymalloc (size_t len) __attribute__((returns_nonnull));
3099 @end smallexample
3100
3101 @noindent
3102 lets the compiler optimize callers based on the knowledge
3103 that the return value will never be null.
3104
3105 @item returns_twice
3106 @cindex @code{returns_twice} function attribute
3107 @cindex functions that return more than once
3108 The @code{returns_twice} attribute tells the compiler that a function may
3109 return more than one time. The compiler ensures that all registers
3110 are dead before calling such a function and emits a warning about
3111 the variables that may be clobbered after the second return from the
3112 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3113 The @code{longjmp}-like counterpart of such function, if any, might need
3114 to be marked with the @code{noreturn} attribute.
3115
3116 @item section ("@var{section-name}")
3117 @cindex @code{section} function attribute
3118 @cindex functions in arbitrary sections
3119 Normally, the compiler places the code it generates in the @code{text} section.
3120 Sometimes, however, you need additional sections, or you need certain
3121 particular functions to appear in special sections. The @code{section}
3122 attribute specifies that a function lives in a particular section.
3123 For example, the declaration:
3124
3125 @smallexample
3126 extern void foobar (void) __attribute__ ((section ("bar")));
3127 @end smallexample
3128
3129 @noindent
3130 puts the function @code{foobar} in the @code{bar} section.
3131
3132 Some file formats do not support arbitrary sections so the @code{section}
3133 attribute is not available on all platforms.
3134 If you need to map the entire contents of a module to a particular
3135 section, consider using the facilities of the linker instead.
3136
3137 @item sentinel
3138 @cindex @code{sentinel} function attribute
3139 This function attribute ensures that a parameter in a function call is
3140 an explicit @code{NULL}. The attribute is only valid on variadic
3141 functions. By default, the sentinel is located at position zero, the
3142 last parameter of the function call. If an optional integer position
3143 argument P is supplied to the attribute, the sentinel must be located at
3144 position P counting backwards from the end of the argument list.
3145
3146 @smallexample
3147 __attribute__ ((sentinel))
3148 is equivalent to
3149 __attribute__ ((sentinel(0)))
3150 @end smallexample
3151
3152 The attribute is automatically set with a position of 0 for the built-in
3153 functions @code{execl} and @code{execlp}. The built-in function
3154 @code{execle} has the attribute set with a position of 1.
3155
3156 A valid @code{NULL} in this context is defined as zero with any pointer
3157 type. If your system defines the @code{NULL} macro with an integer type
3158 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3159 with a copy that redefines NULL appropriately.
3160
3161 The warnings for missing or incorrect sentinels are enabled with
3162 @option{-Wformat}.
3163
3164 @item simd
3165 @itemx simd("@var{mask}")
3166 @cindex @code{simd} function attribute
3167 This attribute enables creation of one or more function versions that
3168 can process multiple arguments using SIMD instructions from a
3169 single invocation. Specifying this attribute allows compiler to
3170 assume that such versions are available at link time (provided
3171 in the same or another translation unit). Generated versions are
3172 target-dependent and described in the corresponding Vector ABI document. For
3173 x86_64 target this document can be found
3174 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3175
3176 The optional argument @var{mask} may have the value
3177 @code{notinbranch} or @code{inbranch},
3178 and instructs the compiler to generate non-masked or masked
3179 clones correspondingly. By default, all clones are generated.
3180
3181 The attribute should not be used together with Cilk Plus @code{vector}
3182 attribute on the same function.
3183
3184 If the attribute is specified and @code{#pragma omp declare simd} is
3185 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3186 switch is specified, then the attribute is ignored.
3187
3188 @item stack_protect
3189 @cindex @code{stack_protect} function attribute
3190 This attribute adds stack protection code to the function if
3191 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3192 or @option{-fstack-protector-explicit} are set.
3193
3194 @item target (@var{options})
3195 @cindex @code{target} function attribute
3196 Multiple target back ends implement the @code{target} attribute
3197 to specify that a function is to
3198 be compiled with different target options than specified on the
3199 command line. This can be used for instance to have functions
3200 compiled with a different ISA (instruction set architecture) than the
3201 default. You can also use the @samp{#pragma GCC target} pragma to set
3202 more than one function to be compiled with specific target options.
3203 @xref{Function Specific Option Pragmas}, for details about the
3204 @samp{#pragma GCC target} pragma.
3205
3206 For instance, on an x86, you could declare one function with the
3207 @code{target("sse4.1,arch=core2")} attribute and another with
3208 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3209 compiling the first function with @option{-msse4.1} and
3210 @option{-march=core2} options, and the second function with
3211 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3212 to make sure that a function is only invoked on a machine that
3213 supports the particular ISA it is compiled for (for example by using
3214 @code{cpuid} on x86 to determine what feature bits and architecture
3215 family are used).
3216
3217 @smallexample
3218 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3219 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3220 @end smallexample
3221
3222 You can either use multiple
3223 strings separated by commas to specify multiple options,
3224 or separate the options with a comma (@samp{,}) within a single string.
3225
3226 The options supported are specific to each target; refer to @ref{x86
3227 Function Attributes}, @ref{PowerPC Function Attributes},
3228 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3229 for details.
3230
3231 @item target_clones (@var{options})
3232 @cindex @code{target_clones} function attribute
3233 The @code{target_clones} attribute is used to specify that a function
3234 be cloned into multiple versions compiled with different target options
3235 than specified on the command line. The supported options and restrictions
3236 are the same as for @code{target} attribute.
3237
3238 For instance, on an x86, you could compile a function with
3239 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3240 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3241 It also creates a resolver function (see the @code{ifunc} attribute
3242 above) that dynamically selects a clone suitable for current architecture.
3243
3244 @item unused
3245 @cindex @code{unused} function attribute
3246 This attribute, attached to a function, means that the function is meant
3247 to be possibly unused. GCC does not produce a warning for this
3248 function.
3249
3250 @item used
3251 @cindex @code{used} function attribute
3252 This attribute, attached to a function, means that code must be emitted
3253 for the function even if it appears that the function is not referenced.
3254 This is useful, for example, when the function is referenced only in
3255 inline assembly.
3256
3257 When applied to a member function of a C++ class template, the
3258 attribute also means that the function is instantiated if the
3259 class itself is instantiated.
3260
3261 @item visibility ("@var{visibility_type}")
3262 @cindex @code{visibility} function attribute
3263 This attribute affects the linkage of the declaration to which it is attached.
3264 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3265 (@pxref{Common Type Attributes}) as well as functions.
3266
3267 There are four supported @var{visibility_type} values: default,
3268 hidden, protected or internal visibility.
3269
3270 @smallexample
3271 void __attribute__ ((visibility ("protected")))
3272 f () @{ /* @r{Do something.} */; @}
3273 int i __attribute__ ((visibility ("hidden")));
3274 @end smallexample
3275
3276 The possible values of @var{visibility_type} correspond to the
3277 visibility settings in the ELF gABI.
3278
3279 @table @code
3280 @c keep this list of visibilities in alphabetical order.
3281
3282 @item default
3283 Default visibility is the normal case for the object file format.
3284 This value is available for the visibility attribute to override other
3285 options that may change the assumed visibility of entities.
3286
3287 On ELF, default visibility means that the declaration is visible to other
3288 modules and, in shared libraries, means that the declared entity may be
3289 overridden.
3290
3291 On Darwin, default visibility means that the declaration is visible to
3292 other modules.
3293
3294 Default visibility corresponds to ``external linkage'' in the language.
3295
3296 @item hidden
3297 Hidden visibility indicates that the entity declared has a new
3298 form of linkage, which we call ``hidden linkage''. Two
3299 declarations of an object with hidden linkage refer to the same object
3300 if they are in the same shared object.
3301
3302 @item internal
3303 Internal visibility is like hidden visibility, but with additional
3304 processor specific semantics. Unless otherwise specified by the
3305 psABI, GCC defines internal visibility to mean that a function is
3306 @emph{never} called from another module. Compare this with hidden
3307 functions which, while they cannot be referenced directly by other
3308 modules, can be referenced indirectly via function pointers. By
3309 indicating that a function cannot be called from outside the module,
3310 GCC may for instance omit the load of a PIC register since it is known
3311 that the calling function loaded the correct value.
3312
3313 @item protected
3314 Protected visibility is like default visibility except that it
3315 indicates that references within the defining module bind to the
3316 definition in that module. That is, the declared entity cannot be
3317 overridden by another module.
3318
3319 @end table
3320
3321 All visibilities are supported on many, but not all, ELF targets
3322 (supported when the assembler supports the @samp{.visibility}
3323 pseudo-op). Default visibility is supported everywhere. Hidden
3324 visibility is supported on Darwin targets.
3325
3326 The visibility attribute should be applied only to declarations that
3327 would otherwise have external linkage. The attribute should be applied
3328 consistently, so that the same entity should not be declared with
3329 different settings of the attribute.
3330
3331 In C++, the visibility attribute applies to types as well as functions
3332 and objects, because in C++ types have linkage. A class must not have
3333 greater visibility than its non-static data member types and bases,
3334 and class members default to the visibility of their class. Also, a
3335 declaration without explicit visibility is limited to the visibility
3336 of its type.
3337
3338 In C++, you can mark member functions and static member variables of a
3339 class with the visibility attribute. This is useful if you know a
3340 particular method or static member variable should only be used from
3341 one shared object; then you can mark it hidden while the rest of the
3342 class has default visibility. Care must be taken to avoid breaking
3343 the One Definition Rule; for example, it is usually not useful to mark
3344 an inline method as hidden without marking the whole class as hidden.
3345
3346 A C++ namespace declaration can also have the visibility attribute.
3347
3348 @smallexample
3349 namespace nspace1 __attribute__ ((visibility ("protected")))
3350 @{ /* @r{Do something.} */; @}
3351 @end smallexample
3352
3353 This attribute applies only to the particular namespace body, not to
3354 other definitions of the same namespace; it is equivalent to using
3355 @samp{#pragma GCC visibility} before and after the namespace
3356 definition (@pxref{Visibility Pragmas}).
3357
3358 In C++, if a template argument has limited visibility, this
3359 restriction is implicitly propagated to the template instantiation.
3360 Otherwise, template instantiations and specializations default to the
3361 visibility of their template.
3362
3363 If both the template and enclosing class have explicit visibility, the
3364 visibility from the template is used.
3365
3366 @item warn_unused_result
3367 @cindex @code{warn_unused_result} function attribute
3368 The @code{warn_unused_result} attribute causes a warning to be emitted
3369 if a caller of the function with this attribute does not use its
3370 return value. This is useful for functions where not checking
3371 the result is either a security problem or always a bug, such as
3372 @code{realloc}.
3373
3374 @smallexample
3375 int fn () __attribute__ ((warn_unused_result));
3376 int foo ()
3377 @{
3378 if (fn () < 0) return -1;
3379 fn ();
3380 return 0;
3381 @}
3382 @end smallexample
3383
3384 @noindent
3385 results in warning on line 5.
3386
3387 @item weak
3388 @cindex @code{weak} function attribute
3389 The @code{weak} attribute causes the declaration to be emitted as a weak
3390 symbol rather than a global. This is primarily useful in defining
3391 library functions that can be overridden in user code, though it can
3392 also be used with non-function declarations. Weak symbols are supported
3393 for ELF targets, and also for a.out targets when using the GNU assembler
3394 and linker.
3395
3396 @item weakref
3397 @itemx weakref ("@var{target}")
3398 @cindex @code{weakref} function attribute
3399 The @code{weakref} attribute marks a declaration as a weak reference.
3400 Without arguments, it should be accompanied by an @code{alias} attribute
3401 naming the target symbol. Optionally, the @var{target} may be given as
3402 an argument to @code{weakref} itself. In either case, @code{weakref}
3403 implicitly marks the declaration as @code{weak}. Without a
3404 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3405 @code{weakref} is equivalent to @code{weak}.
3406
3407 @smallexample
3408 static int x() __attribute__ ((weakref ("y")));
3409 /* is equivalent to... */
3410 static int x() __attribute__ ((weak, weakref, alias ("y")));
3411 /* and to... */
3412 static int x() __attribute__ ((weakref));
3413 static int x() __attribute__ ((alias ("y")));
3414 @end smallexample
3415
3416 A weak reference is an alias that does not by itself require a
3417 definition to be given for the target symbol. If the target symbol is
3418 only referenced through weak references, then it becomes a @code{weak}
3419 undefined symbol. If it is directly referenced, however, then such
3420 strong references prevail, and a definition is required for the
3421 symbol, not necessarily in the same translation unit.
3422
3423 The effect is equivalent to moving all references to the alias to a
3424 separate translation unit, renaming the alias to the aliased symbol,
3425 declaring it as weak, compiling the two separate translation units and
3426 performing a reloadable link on them.
3427
3428 At present, a declaration to which @code{weakref} is attached can
3429 only be @code{static}.
3430
3431
3432 @end table
3433
3434 @c This is the end of the target-independent attribute table
3435
3436 @node AArch64 Function Attributes
3437 @subsection AArch64 Function Attributes
3438
3439 The following target-specific function attributes are available for the
3440 AArch64 target. For the most part, these options mirror the behavior of
3441 similar command-line options (@pxref{AArch64 Options}), but on a
3442 per-function basis.
3443
3444 @table @code
3445 @item general-regs-only
3446 @cindex @code{general-regs-only} function attribute, AArch64
3447 Indicates that no floating-point or Advanced SIMD registers should be
3448 used when generating code for this function. If the function explicitly
3449 uses floating-point code, then the compiler gives an error. This is
3450 the same behavior as that of the command-line option
3451 @option{-mgeneral-regs-only}.
3452
3453 @item fix-cortex-a53-835769
3454 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3455 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3456 applied to this function. To explicitly disable the workaround for this
3457 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3458 This corresponds to the behavior of the command line options
3459 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3460
3461 @item cmodel=
3462 @cindex @code{cmodel=} function attribute, AArch64
3463 Indicates that code should be generated for a particular code model for
3464 this function. The behavior and permissible arguments are the same as
3465 for the command line option @option{-mcmodel=}.
3466
3467 @item strict-align
3468 @cindex @code{strict-align} function attribute, AArch64
3469 Indicates that the compiler should not assume that unaligned memory references
3470 are handled by the system. The behavior is the same as for the command-line
3471 option @option{-mstrict-align}.
3472
3473 @item omit-leaf-frame-pointer
3474 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3475 Indicates that the frame pointer should be omitted for a leaf function call.
3476 To keep the frame pointer, the inverse attribute
3477 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3478 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3479 and @option{-mno-omit-leaf-frame-pointer}.
3480
3481 @item tls-dialect=
3482 @cindex @code{tls-dialect=} function attribute, AArch64
3483 Specifies the TLS dialect to use for this function. The behavior and
3484 permissible arguments are the same as for the command-line option
3485 @option{-mtls-dialect=}.
3486
3487 @item arch=
3488 @cindex @code{arch=} function attribute, AArch64
3489 Specifies the architecture version and architectural extensions to use
3490 for this function. The behavior and permissible arguments are the same as
3491 for the @option{-march=} command-line option.
3492
3493 @item tune=
3494 @cindex @code{tune=} function attribute, AArch64
3495 Specifies the core for which to tune the performance of this function.
3496 The behavior and permissible arguments are the same as for the @option{-mtune=}
3497 command-line option.
3498
3499 @item cpu=
3500 @cindex @code{cpu=} function attribute, AArch64
3501 Specifies the core for which to tune the performance of this function and also
3502 whose architectural features to use. The behavior and valid arguments are the
3503 same as for the @option{-mcpu=} command-line option.
3504
3505 @end table
3506
3507 The above target attributes can be specified as follows:
3508
3509 @smallexample
3510 __attribute__((target("@var{attr-string}")))
3511 int
3512 f (int a)
3513 @{
3514 return a + 5;
3515 @}
3516 @end smallexample
3517
3518 where @code{@var{attr-string}} is one of the attribute strings specified above.
3519
3520 Additionally, the architectural extension string may be specified on its
3521 own. This can be used to turn on and off particular architectural extensions
3522 without having to specify a particular architecture version or core. Example:
3523
3524 @smallexample
3525 __attribute__((target("+crc+nocrypto")))
3526 int
3527 foo (int a)
3528 @{
3529 return a + 5;
3530 @}
3531 @end smallexample
3532
3533 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3534 extension and disables the @code{crypto} extension for the function @code{foo}
3535 without modifying an existing @option{-march=} or @option{-mcpu} option.
3536
3537 Multiple target function attributes can be specified by separating them with
3538 a comma. For example:
3539 @smallexample
3540 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3541 int
3542 foo (int a)
3543 @{
3544 return a + 5;
3545 @}
3546 @end smallexample
3547
3548 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3549 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3550
3551 @subsubsection Inlining rules
3552 Specifying target attributes on individual functions or performing link-time
3553 optimization across translation units compiled with different target options
3554 can affect function inlining rules:
3555
3556 In particular, a caller function can inline a callee function only if the
3557 architectural features available to the callee are a subset of the features
3558 available to the caller.
3559 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3560 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3561 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3562 because the all the architectural features that function @code{bar} requires
3563 are available to function @code{foo}. Conversely, function @code{bar} cannot
3564 inline function @code{foo}.
3565
3566 Additionally inlining a function compiled with @option{-mstrict-align} into a
3567 function compiled without @code{-mstrict-align} is not allowed.
3568 However, inlining a function compiled without @option{-mstrict-align} into a
3569 function compiled with @option{-mstrict-align} is allowed.
3570
3571 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3572 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3573 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3574 architectural feature rules specified above.
3575
3576 @node ARC Function Attributes
3577 @subsection ARC Function Attributes
3578
3579 These function attributes are supported by the ARC back end:
3580
3581 @table @code
3582 @item interrupt
3583 @cindex @code{interrupt} function attribute, ARC
3584 Use this attribute to indicate
3585 that the specified function is an interrupt handler. The compiler generates
3586 function entry and exit sequences suitable for use in an interrupt handler
3587 when this attribute is present.
3588
3589 On the ARC, you must specify the kind of interrupt to be handled
3590 in a parameter to the interrupt attribute like this:
3591
3592 @smallexample
3593 void f () __attribute__ ((interrupt ("ilink1")));
3594 @end smallexample
3595
3596 Permissible values for this parameter are: @w{@code{ilink1}} and
3597 @w{@code{ilink2}}.
3598
3599 @item long_call
3600 @itemx medium_call
3601 @itemx short_call
3602 @cindex @code{long_call} function attribute, ARC
3603 @cindex @code{medium_call} function attribute, ARC
3604 @cindex @code{short_call} function attribute, ARC
3605 @cindex indirect calls, ARC
3606 These attributes specify how a particular function is called.
3607 These attributes override the
3608 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3609 command-line switches and @code{#pragma long_calls} settings.
3610
3611 For ARC, a function marked with the @code{long_call} attribute is
3612 always called using register-indirect jump-and-link instructions,
3613 thereby enabling the called function to be placed anywhere within the
3614 32-bit address space. A function marked with the @code{medium_call}
3615 attribute will always be close enough to be called with an unconditional
3616 branch-and-link instruction, which has a 25-bit offset from
3617 the call site. A function marked with the @code{short_call}
3618 attribute will always be close enough to be called with a conditional
3619 branch-and-link instruction, which has a 21-bit offset from
3620 the call site.
3621 @end table
3622
3623 @node ARM Function Attributes
3624 @subsection ARM Function Attributes
3625
3626 These function attributes are supported for ARM targets:
3627
3628 @table @code
3629 @item interrupt
3630 @cindex @code{interrupt} function attribute, ARM
3631 Use this attribute to indicate
3632 that the specified function is an interrupt handler. The compiler generates
3633 function entry and exit sequences suitable for use in an interrupt handler
3634 when this attribute is present.
3635
3636 You can specify the kind of interrupt to be handled by
3637 adding an optional parameter to the interrupt attribute like this:
3638
3639 @smallexample
3640 void f () __attribute__ ((interrupt ("IRQ")));
3641 @end smallexample
3642
3643 @noindent
3644 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3645 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3646
3647 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3648 may be called with a word-aligned stack pointer.
3649
3650 @item isr
3651 @cindex @code{isr} function attribute, ARM
3652 Use this attribute on ARM to write Interrupt Service Routines. This is an
3653 alias to the @code{interrupt} attribute above.
3654
3655 @item long_call
3656 @itemx short_call
3657 @cindex @code{long_call} function attribute, ARM
3658 @cindex @code{short_call} function attribute, ARM
3659 @cindex indirect calls, ARM
3660 These attributes specify how a particular function is called.
3661 These attributes override the
3662 @option{-mlong-calls} (@pxref{ARM Options})
3663 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3664 @code{long_call} attribute indicates that the function might be far
3665 away from the call site and require a different (more expensive)
3666 calling sequence. The @code{short_call} attribute always places
3667 the offset to the function from the call site into the @samp{BL}
3668 instruction directly.
3669
3670 @item naked
3671 @cindex @code{naked} function attribute, ARM
3672 This attribute allows the compiler to construct the
3673 requisite function declaration, while allowing the body of the
3674 function to be assembly code. The specified function will not have
3675 prologue/epilogue sequences generated by the compiler. Only basic
3676 @code{asm} statements can safely be included in naked functions
3677 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3678 basic @code{asm} and C code may appear to work, they cannot be
3679 depended upon to work reliably and are not supported.
3680
3681 @item pcs
3682 @cindex @code{pcs} function attribute, ARM
3683
3684 The @code{pcs} attribute can be used to control the calling convention
3685 used for a function on ARM. The attribute takes an argument that specifies
3686 the calling convention to use.
3687
3688 When compiling using the AAPCS ABI (or a variant of it) then valid
3689 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3690 order to use a variant other than @code{"aapcs"} then the compiler must
3691 be permitted to use the appropriate co-processor registers (i.e., the
3692 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3693 For example,
3694
3695 @smallexample
3696 /* Argument passed in r0, and result returned in r0+r1. */
3697 double f2d (float) __attribute__((pcs("aapcs")));
3698 @end smallexample
3699
3700 Variadic functions always use the @code{"aapcs"} calling convention and
3701 the compiler rejects attempts to specify an alternative.
3702
3703 @item target (@var{options})
3704 @cindex @code{target} function attribute
3705 As discussed in @ref{Common Function Attributes}, this attribute
3706 allows specification of target-specific compilation options.
3707
3708 On ARM, the following options are allowed:
3709
3710 @table @samp
3711 @item thumb
3712 @cindex @code{target("thumb")} function attribute, ARM
3713 Force code generation in the Thumb (T16/T32) ISA, depending on the
3714 architecture level.
3715
3716 @item arm
3717 @cindex @code{target("arm")} function attribute, ARM
3718 Force code generation in the ARM (A32) ISA.
3719
3720 Functions from different modes can be inlined in the caller's mode.
3721
3722 @item fpu=
3723 @cindex @code{target("fpu=")} function attribute, ARM
3724 Specifies the fpu for which to tune the performance of this function.
3725 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3726 command-line option.
3727
3728 @end table
3729
3730 @end table
3731
3732 @node AVR Function Attributes
3733 @subsection AVR Function Attributes
3734
3735 These function attributes are supported by the AVR back end:
3736
3737 @table @code
3738 @item interrupt
3739 @cindex @code{interrupt} function attribute, AVR
3740 Use this attribute to indicate
3741 that the specified function is an interrupt handler. The compiler generates
3742 function entry and exit sequences suitable for use in an interrupt handler
3743 when this attribute is present.
3744
3745 On the AVR, the hardware globally disables interrupts when an
3746 interrupt is executed. The first instruction of an interrupt handler
3747 declared with this attribute is a @code{SEI} instruction to
3748 re-enable interrupts. See also the @code{signal} function attribute
3749 that does not insert a @code{SEI} instruction. If both @code{signal} and
3750 @code{interrupt} are specified for the same function, @code{signal}
3751 is silently ignored.
3752
3753 @item naked
3754 @cindex @code{naked} function attribute, AVR
3755 This attribute allows the compiler to construct the
3756 requisite function declaration, while allowing the body of the
3757 function to be assembly code. The specified function will not have
3758 prologue/epilogue sequences generated by the compiler. Only basic
3759 @code{asm} statements can safely be included in naked functions
3760 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3761 basic @code{asm} and C code may appear to work, they cannot be
3762 depended upon to work reliably and are not supported.
3763
3764 @item OS_main
3765 @itemx OS_task
3766 @cindex @code{OS_main} function attribute, AVR
3767 @cindex @code{OS_task} function attribute, AVR
3768 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3769 do not save/restore any call-saved register in their prologue/epilogue.
3770
3771 The @code{OS_main} attribute can be used when there @emph{is
3772 guarantee} that interrupts are disabled at the time when the function
3773 is entered. This saves resources when the stack pointer has to be
3774 changed to set up a frame for local variables.
3775
3776 The @code{OS_task} attribute can be used when there is @emph{no
3777 guarantee} that interrupts are disabled at that time when the function
3778 is entered like for, e@.g@. task functions in a multi-threading operating
3779 system. In that case, changing the stack pointer register is
3780 guarded by save/clear/restore of the global interrupt enable flag.
3781
3782 The differences to the @code{naked} function attribute are:
3783 @itemize @bullet
3784 @item @code{naked} functions do not have a return instruction whereas
3785 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3786 @code{RETI} return instruction.
3787 @item @code{naked} functions do not set up a frame for local variables
3788 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3789 as needed.
3790 @end itemize
3791
3792 @item signal
3793 @cindex @code{signal} function attribute, AVR
3794 Use this attribute on the AVR to indicate that the specified
3795 function is an interrupt handler. The compiler generates function
3796 entry and exit sequences suitable for use in an interrupt handler when this
3797 attribute is present.
3798
3799 See also the @code{interrupt} function attribute.
3800
3801 The AVR hardware globally disables interrupts when an interrupt is executed.
3802 Interrupt handler functions defined with the @code{signal} attribute
3803 do not re-enable interrupts. It is save to enable interrupts in a
3804 @code{signal} handler. This ``save'' only applies to the code
3805 generated by the compiler and not to the IRQ layout of the
3806 application which is responsibility of the application.
3807
3808 If both @code{signal} and @code{interrupt} are specified for the same
3809 function, @code{signal} is silently ignored.
3810 @end table
3811
3812 @node Blackfin Function Attributes
3813 @subsection Blackfin Function Attributes
3814
3815 These function attributes are supported by the Blackfin back end:
3816
3817 @table @code
3818
3819 @item exception_handler
3820 @cindex @code{exception_handler} function attribute
3821 @cindex exception handler functions, Blackfin
3822 Use this attribute on the Blackfin to indicate that the specified function
3823 is an exception handler. The compiler generates function entry and
3824 exit sequences suitable for use in an exception handler when this
3825 attribute is present.
3826
3827 @item interrupt_handler
3828 @cindex @code{interrupt_handler} function attribute, Blackfin
3829 Use this attribute to
3830 indicate that the specified function is an interrupt handler. The compiler
3831 generates function entry and exit sequences suitable for use in an
3832 interrupt handler when this attribute is present.
3833
3834 @item kspisusp
3835 @cindex @code{kspisusp} function attribute, Blackfin
3836 @cindex User stack pointer in interrupts on the Blackfin
3837 When used together with @code{interrupt_handler}, @code{exception_handler}
3838 or @code{nmi_handler}, code is generated to load the stack pointer
3839 from the USP register in the function prologue.
3840
3841 @item l1_text
3842 @cindex @code{l1_text} function attribute, Blackfin
3843 This attribute specifies a function to be placed into L1 Instruction
3844 SRAM@. The function is put into a specific section named @code{.l1.text}.
3845 With @option{-mfdpic}, function calls with a such function as the callee
3846 or caller uses inlined PLT.
3847
3848 @item l2
3849 @cindex @code{l2} function attribute, Blackfin
3850 This attribute specifies a function to be placed into L2
3851 SRAM. The function is put into a specific section named
3852 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3853 an inlined PLT.
3854
3855 @item longcall
3856 @itemx shortcall
3857 @cindex indirect calls, Blackfin
3858 @cindex @code{longcall} function attribute, Blackfin
3859 @cindex @code{shortcall} function attribute, Blackfin
3860 The @code{longcall} attribute
3861 indicates that the function might be far away from the call site and
3862 require a different (more expensive) calling sequence. The
3863 @code{shortcall} attribute indicates that the function is always close
3864 enough for the shorter calling sequence to be used. These attributes
3865 override the @option{-mlongcall} switch.
3866
3867 @item nesting
3868 @cindex @code{nesting} function attribute, Blackfin
3869 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3870 Use this attribute together with @code{interrupt_handler},
3871 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3872 entry code should enable nested interrupts or exceptions.
3873
3874 @item nmi_handler
3875 @cindex @code{nmi_handler} function attribute, Blackfin
3876 @cindex NMI handler functions on the Blackfin processor
3877 Use this attribute on the Blackfin to indicate that the specified function
3878 is an NMI handler. The compiler generates function entry and
3879 exit sequences suitable for use in an NMI handler when this
3880 attribute is present.
3881
3882 @item saveall
3883 @cindex @code{saveall} function attribute, Blackfin
3884 @cindex save all registers on the Blackfin
3885 Use this attribute to indicate that
3886 all registers except the stack pointer should be saved in the prologue
3887 regardless of whether they are used or not.
3888 @end table
3889
3890 @node CR16 Function Attributes
3891 @subsection CR16 Function Attributes
3892
3893 These function attributes are supported by the CR16 back end:
3894
3895 @table @code
3896 @item interrupt
3897 @cindex @code{interrupt} function attribute, CR16
3898 Use this attribute to indicate
3899 that the specified function is an interrupt handler. The compiler generates
3900 function entry and exit sequences suitable for use in an interrupt handler
3901 when this attribute is present.
3902 @end table
3903
3904 @node Epiphany Function Attributes
3905 @subsection Epiphany Function Attributes
3906
3907 These function attributes are supported by the Epiphany back end:
3908
3909 @table @code
3910 @item disinterrupt
3911 @cindex @code{disinterrupt} function attribute, Epiphany
3912 This attribute causes the compiler to emit
3913 instructions to disable interrupts for the duration of the given
3914 function.
3915
3916 @item forwarder_section
3917 @cindex @code{forwarder_section} function attribute, Epiphany
3918 This attribute modifies the behavior of an interrupt handler.
3919 The interrupt handler may be in external memory which cannot be
3920 reached by a branch instruction, so generate a local memory trampoline
3921 to transfer control. The single parameter identifies the section where
3922 the trampoline is placed.
3923
3924 @item interrupt
3925 @cindex @code{interrupt} function attribute, Epiphany
3926 Use this attribute to indicate
3927 that the specified function is an interrupt handler. The compiler generates
3928 function entry and exit sequences suitable for use in an interrupt handler
3929 when this attribute is present. It may also generate
3930 a special section with code to initialize the interrupt vector table.
3931
3932 On Epiphany targets one or more optional parameters can be added like this:
3933
3934 @smallexample
3935 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3936 @end smallexample
3937
3938 Permissible values for these parameters are: @w{@code{reset}},
3939 @w{@code{software_exception}}, @w{@code{page_miss}},
3940 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3941 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3942 Multiple parameters indicate that multiple entries in the interrupt
3943 vector table should be initialized for this function, i.e.@: for each
3944 parameter @w{@var{name}}, a jump to the function is emitted in
3945 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3946 entirely, in which case no interrupt vector table entry is provided.
3947
3948 Note that interrupts are enabled inside the function
3949 unless the @code{disinterrupt} attribute is also specified.
3950
3951 The following examples are all valid uses of these attributes on
3952 Epiphany targets:
3953 @smallexample
3954 void __attribute__ ((interrupt)) universal_handler ();
3955 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3956 void __attribute__ ((interrupt ("dma0, dma1")))
3957 universal_dma_handler ();
3958 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3959 fast_timer_handler ();
3960 void __attribute__ ((interrupt ("dma0, dma1"),
3961 forwarder_section ("tramp")))
3962 external_dma_handler ();
3963 @end smallexample
3964
3965 @item long_call
3966 @itemx short_call
3967 @cindex @code{long_call} function attribute, Epiphany
3968 @cindex @code{short_call} function attribute, Epiphany
3969 @cindex indirect calls, Epiphany
3970 These attributes specify how a particular function is called.
3971 These attributes override the
3972 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3973 command-line switch and @code{#pragma long_calls} settings.
3974 @end table
3975
3976
3977 @node H8/300 Function Attributes
3978 @subsection H8/300 Function Attributes
3979
3980 These function attributes are available for H8/300 targets:
3981
3982 @table @code
3983 @item function_vector
3984 @cindex @code{function_vector} function attribute, H8/300
3985 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3986 that the specified function should be called through the function vector.
3987 Calling a function through the function vector reduces code size; however,
3988 the function vector has a limited size (maximum 128 entries on the H8/300
3989 and 64 entries on the H8/300H and H8S)
3990 and shares space with the interrupt vector.
3991
3992 @item interrupt_handler
3993 @cindex @code{interrupt_handler} function attribute, H8/300
3994 Use this attribute on the H8/300, H8/300H, and H8S to
3995 indicate that the specified function is an interrupt handler. The compiler
3996 generates function entry and exit sequences suitable for use in an
3997 interrupt handler when this attribute is present.
3998
3999 @item saveall
4000 @cindex @code{saveall} function attribute, H8/300
4001 @cindex save all registers on the H8/300, H8/300H, and H8S
4002 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4003 all registers except the stack pointer should be saved in the prologue
4004 regardless of whether they are used or not.
4005 @end table
4006
4007 @node IA-64 Function Attributes
4008 @subsection IA-64 Function Attributes
4009
4010 These function attributes are supported on IA-64 targets:
4011
4012 @table @code
4013 @item syscall_linkage
4014 @cindex @code{syscall_linkage} function attribute, IA-64
4015 This attribute is used to modify the IA-64 calling convention by marking
4016 all input registers as live at all function exits. This makes it possible
4017 to restart a system call after an interrupt without having to save/restore
4018 the input registers. This also prevents kernel data from leaking into
4019 application code.
4020
4021 @item version_id
4022 @cindex @code{version_id} function attribute, IA-64
4023 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4024 symbol to contain a version string, thus allowing for function level
4025 versioning. HP-UX system header files may use function level versioning
4026 for some system calls.
4027
4028 @smallexample
4029 extern int foo () __attribute__((version_id ("20040821")));
4030 @end smallexample
4031
4032 @noindent
4033 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4034 @end table
4035
4036 @node M32C Function Attributes
4037 @subsection M32C Function Attributes
4038
4039 These function attributes are supported by the M32C back end:
4040
4041 @table @code
4042 @item bank_switch
4043 @cindex @code{bank_switch} function attribute, M32C
4044 When added to an interrupt handler with the M32C port, causes the
4045 prologue and epilogue to use bank switching to preserve the registers
4046 rather than saving them on the stack.
4047
4048 @item fast_interrupt
4049 @cindex @code{fast_interrupt} function attribute, M32C
4050 Use this attribute on the M32C port to indicate that the specified
4051 function is a fast interrupt handler. This is just like the
4052 @code{interrupt} attribute, except that @code{freit} is used to return
4053 instead of @code{reit}.
4054
4055 @item function_vector
4056 @cindex @code{function_vector} function attribute, M16C/M32C
4057 On M16C/M32C targets, the @code{function_vector} attribute declares a
4058 special page subroutine call function. Use of this attribute reduces
4059 the code size by 2 bytes for each call generated to the
4060 subroutine. The argument to the attribute is the vector number entry
4061 from the special page vector table which contains the 16 low-order
4062 bits of the subroutine's entry address. Each vector table has special
4063 page number (18 to 255) that is used in @code{jsrs} instructions.
4064 Jump addresses of the routines are generated by adding 0x0F0000 (in
4065 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4066 2-byte addresses set in the vector table. Therefore you need to ensure
4067 that all the special page vector routines should get mapped within the
4068 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4069 (for M32C).
4070
4071 In the following example 2 bytes are saved for each call to
4072 function @code{foo}.
4073
4074 @smallexample
4075 void foo (void) __attribute__((function_vector(0x18)));
4076 void foo (void)
4077 @{
4078 @}
4079
4080 void bar (void)
4081 @{
4082 foo();
4083 @}
4084 @end smallexample
4085
4086 If functions are defined in one file and are called in another file,
4087 then be sure to write this declaration in both files.
4088
4089 This attribute is ignored for R8C target.
4090
4091 @item interrupt
4092 @cindex @code{interrupt} function attribute, M32C
4093 Use this attribute to indicate
4094 that the specified function is an interrupt handler. The compiler generates
4095 function entry and exit sequences suitable for use in an interrupt handler
4096 when this attribute is present.
4097 @end table
4098
4099 @node M32R/D Function Attributes
4100 @subsection M32R/D Function Attributes
4101
4102 These function attributes are supported by the M32R/D back end:
4103
4104 @table @code
4105 @item interrupt
4106 @cindex @code{interrupt} function attribute, M32R/D
4107 Use this attribute to indicate
4108 that the specified function is an interrupt handler. The compiler generates
4109 function entry and exit sequences suitable for use in an interrupt handler
4110 when this attribute is present.
4111
4112 @item model (@var{model-name})
4113 @cindex @code{model} function attribute, M32R/D
4114 @cindex function addressability on the M32R/D
4115
4116 On the M32R/D, use this attribute to set the addressability of an
4117 object, and of the code generated for a function. The identifier
4118 @var{model-name} is one of @code{small}, @code{medium}, or
4119 @code{large}, representing each of the code models.
4120
4121 Small model objects live in the lower 16MB of memory (so that their
4122 addresses can be loaded with the @code{ld24} instruction), and are
4123 callable with the @code{bl} instruction.
4124
4125 Medium model objects may live anywhere in the 32-bit address space (the
4126 compiler generates @code{seth/add3} instructions to load their addresses),
4127 and are callable with the @code{bl} instruction.
4128
4129 Large model objects may live anywhere in the 32-bit address space (the
4130 compiler generates @code{seth/add3} instructions to load their addresses),
4131 and may not be reachable with the @code{bl} instruction (the compiler
4132 generates the much slower @code{seth/add3/jl} instruction sequence).
4133 @end table
4134
4135 @node m68k Function Attributes
4136 @subsection m68k Function Attributes
4137
4138 These function attributes are supported by the m68k back end:
4139
4140 @table @code
4141 @item interrupt
4142 @itemx interrupt_handler
4143 @cindex @code{interrupt} function attribute, m68k
4144 @cindex @code{interrupt_handler} function attribute, m68k
4145 Use this attribute to
4146 indicate that the specified function is an interrupt handler. The compiler
4147 generates function entry and exit sequences suitable for use in an
4148 interrupt handler when this attribute is present. Either name may be used.
4149
4150 @item interrupt_thread
4151 @cindex @code{interrupt_thread} function attribute, fido
4152 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4153 that the specified function is an interrupt handler that is designed
4154 to run as a thread. The compiler omits generate prologue/epilogue
4155 sequences and replaces the return instruction with a @code{sleep}
4156 instruction. This attribute is available only on fido.
4157 @end table
4158
4159 @node MCORE Function Attributes
4160 @subsection MCORE Function Attributes
4161
4162 These function attributes are supported by the MCORE back end:
4163
4164 @table @code
4165 @item naked
4166 @cindex @code{naked} function attribute, MCORE
4167 This attribute allows the compiler to construct the
4168 requisite function declaration, while allowing the body of the
4169 function to be assembly code. The specified function will not have
4170 prologue/epilogue sequences generated by the compiler. Only basic
4171 @code{asm} statements can safely be included in naked functions
4172 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4173 basic @code{asm} and C code may appear to work, they cannot be
4174 depended upon to work reliably and are not supported.
4175 @end table
4176
4177 @node MeP Function Attributes
4178 @subsection MeP Function Attributes
4179
4180 These function attributes are supported by the MeP back end:
4181
4182 @table @code
4183 @item disinterrupt
4184 @cindex @code{disinterrupt} function attribute, MeP
4185 On MeP targets, this attribute causes the compiler to emit
4186 instructions to disable interrupts for the duration of the given
4187 function.
4188
4189 @item interrupt
4190 @cindex @code{interrupt} function attribute, MeP
4191 Use this attribute to indicate
4192 that the specified function is an interrupt handler. The compiler generates
4193 function entry and exit sequences suitable for use in an interrupt handler
4194 when this attribute is present.
4195
4196 @item near
4197 @cindex @code{near} function attribute, MeP
4198 This attribute causes the compiler to assume the called
4199 function is close enough to use the normal calling convention,
4200 overriding the @option{-mtf} command-line option.
4201
4202 @item far
4203 @cindex @code{far} function attribute, MeP
4204 On MeP targets this causes the compiler to use a calling convention
4205 that assumes the called function is too far away for the built-in
4206 addressing modes.
4207
4208 @item vliw
4209 @cindex @code{vliw} function attribute, MeP
4210 The @code{vliw} attribute tells the compiler to emit
4211 instructions in VLIW mode instead of core mode. Note that this
4212 attribute is not allowed unless a VLIW coprocessor has been configured
4213 and enabled through command-line options.
4214 @end table
4215
4216 @node MicroBlaze Function Attributes
4217 @subsection MicroBlaze Function Attributes
4218
4219 These function attributes are supported on MicroBlaze targets:
4220
4221 @table @code
4222 @item save_volatiles
4223 @cindex @code{save_volatiles} function attribute, MicroBlaze
4224 Use this attribute to indicate that the function is
4225 an interrupt handler. All volatile registers (in addition to non-volatile
4226 registers) are saved in the function prologue. If the function is a leaf
4227 function, only volatiles used by the function are saved. A normal function
4228 return is generated instead of a return from interrupt.
4229
4230 @item break_handler
4231 @cindex @code{break_handler} function attribute, MicroBlaze
4232 @cindex break handler functions
4233 Use this attribute to indicate that
4234 the specified function is a break handler. The compiler generates function
4235 entry and exit sequences suitable for use in an break handler when this
4236 attribute is present. The return from @code{break_handler} is done through
4237 the @code{rtbd} instead of @code{rtsd}.
4238
4239 @smallexample
4240 void f () __attribute__ ((break_handler));
4241 @end smallexample
4242
4243 @item interrupt_handler
4244 @itemx fast_interrupt
4245 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4246 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4247 These attributes indicate that the specified function is an interrupt
4248 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4249 used in low-latency interrupt mode, and @code{interrupt_handler} for
4250 interrupts that do not use low-latency handlers. In both cases, GCC
4251 emits appropriate prologue code and generates a return from the handler
4252 using @code{rtid} instead of @code{rtsd}.
4253 @end table
4254
4255 @node Microsoft Windows Function Attributes
4256 @subsection Microsoft Windows Function Attributes
4257
4258 The following attributes are available on Microsoft Windows and Symbian OS
4259 targets.
4260
4261 @table @code
4262 @item dllexport
4263 @cindex @code{dllexport} function attribute
4264 @cindex @code{__declspec(dllexport)}
4265 On Microsoft Windows targets and Symbian OS targets the
4266 @code{dllexport} attribute causes the compiler to provide a global
4267 pointer to a pointer in a DLL, so that it can be referenced with the
4268 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4269 name is formed by combining @code{_imp__} and the function or variable
4270 name.
4271
4272 You can use @code{__declspec(dllexport)} as a synonym for
4273 @code{__attribute__ ((dllexport))} for compatibility with other
4274 compilers.
4275
4276 On systems that support the @code{visibility} attribute, this
4277 attribute also implies ``default'' visibility. It is an error to
4278 explicitly specify any other visibility.
4279
4280 GCC's default behavior is to emit all inline functions with the
4281 @code{dllexport} attribute. Since this can cause object file-size bloat,
4282 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4283 ignore the attribute for inlined functions unless the
4284 @option{-fkeep-inline-functions} flag is used instead.
4285
4286 The attribute is ignored for undefined symbols.
4287
4288 When applied to C++ classes, the attribute marks defined non-inlined
4289 member functions and static data members as exports. Static consts
4290 initialized in-class are not marked unless they are also defined
4291 out-of-class.
4292
4293 For Microsoft Windows targets there are alternative methods for
4294 including the symbol in the DLL's export table such as using a
4295 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4296 the @option{--export-all} linker flag.
4297
4298 @item dllimport
4299 @cindex @code{dllimport} function attribute
4300 @cindex @code{__declspec(dllimport)}
4301 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4302 attribute causes the compiler to reference a function or variable via
4303 a global pointer to a pointer that is set up by the DLL exporting the
4304 symbol. The attribute implies @code{extern}. On Microsoft Windows
4305 targets, the pointer name is formed by combining @code{_imp__} and the
4306 function or variable name.
4307
4308 You can use @code{__declspec(dllimport)} as a synonym for
4309 @code{__attribute__ ((dllimport))} for compatibility with other
4310 compilers.
4311
4312 On systems that support the @code{visibility} attribute, this
4313 attribute also implies ``default'' visibility. It is an error to
4314 explicitly specify any other visibility.
4315
4316 Currently, the attribute is ignored for inlined functions. If the
4317 attribute is applied to a symbol @emph{definition}, an error is reported.
4318 If a symbol previously declared @code{dllimport} is later defined, the
4319 attribute is ignored in subsequent references, and a warning is emitted.
4320 The attribute is also overridden by a subsequent declaration as
4321 @code{dllexport}.
4322
4323 When applied to C++ classes, the attribute marks non-inlined
4324 member functions and static data members as imports. However, the
4325 attribute is ignored for virtual methods to allow creation of vtables
4326 using thunks.
4327
4328 On the SH Symbian OS target the @code{dllimport} attribute also has
4329 another affect---it can cause the vtable and run-time type information
4330 for a class to be exported. This happens when the class has a
4331 dllimported constructor or a non-inline, non-pure virtual function
4332 and, for either of those two conditions, the class also has an inline
4333 constructor or destructor and has a key function that is defined in
4334 the current translation unit.
4335
4336 For Microsoft Windows targets the use of the @code{dllimport}
4337 attribute on functions is not necessary, but provides a small
4338 performance benefit by eliminating a thunk in the DLL@. The use of the
4339 @code{dllimport} attribute on imported variables can be avoided by passing the
4340 @option{--enable-auto-import} switch to the GNU linker. As with
4341 functions, using the attribute for a variable eliminates a thunk in
4342 the DLL@.
4343
4344 One drawback to using this attribute is that a pointer to a
4345 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4346 address. However, a pointer to a @emph{function} with the
4347 @code{dllimport} attribute can be used as a constant initializer; in
4348 this case, the address of a stub function in the import lib is
4349 referenced. On Microsoft Windows targets, the attribute can be disabled
4350 for functions by setting the @option{-mnop-fun-dllimport} flag.
4351 @end table
4352
4353 @node MIPS Function Attributes
4354 @subsection MIPS Function Attributes
4355
4356 These function attributes are supported by the MIPS back end:
4357
4358 @table @code
4359 @item interrupt
4360 @cindex @code{interrupt} function attribute, MIPS
4361 Use this attribute to indicate that the specified function is an interrupt
4362 handler. The compiler generates function entry and exit sequences suitable
4363 for use in an interrupt handler when this attribute is present.
4364 An optional argument is supported for the interrupt attribute which allows
4365 the interrupt mode to be described. By default GCC assumes the external
4366 interrupt controller (EIC) mode is in use, this can be explicitly set using
4367 @code{eic}. When interrupts are non-masked then the requested Interrupt
4368 Priority Level (IPL) is copied to the current IPL which has the effect of only
4369 enabling higher priority interrupts. To use vectored interrupt mode use
4370 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4371 the behavior of the non-masked interrupt support and GCC will arrange to mask
4372 all interrupts from sw0 up to and including the specified interrupt vector.
4373
4374 You can use the following attributes to modify the behavior
4375 of an interrupt handler:
4376 @table @code
4377 @item use_shadow_register_set
4378 @cindex @code{use_shadow_register_set} function attribute, MIPS
4379 Assume that the handler uses a shadow register set, instead of
4380 the main general-purpose registers. An optional argument @code{intstack} is
4381 supported to indicate that the shadow register set contains a valid stack
4382 pointer.
4383
4384 @item keep_interrupts_masked
4385 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4386 Keep interrupts masked for the whole function. Without this attribute,
4387 GCC tries to reenable interrupts for as much of the function as it can.
4388
4389 @item use_debug_exception_return
4390 @cindex @code{use_debug_exception_return} function attribute, MIPS
4391 Return using the @code{deret} instruction. Interrupt handlers that don't
4392 have this attribute return using @code{eret} instead.
4393 @end table
4394
4395 You can use any combination of these attributes, as shown below:
4396 @smallexample
4397 void __attribute__ ((interrupt)) v0 ();
4398 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4399 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4400 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4401 void __attribute__ ((interrupt, use_shadow_register_set,
4402 keep_interrupts_masked)) v4 ();
4403 void __attribute__ ((interrupt, use_shadow_register_set,
4404 use_debug_exception_return)) v5 ();
4405 void __attribute__ ((interrupt, keep_interrupts_masked,
4406 use_debug_exception_return)) v6 ();
4407 void __attribute__ ((interrupt, use_shadow_register_set,
4408 keep_interrupts_masked,
4409 use_debug_exception_return)) v7 ();
4410 void __attribute__ ((interrupt("eic"))) v8 ();
4411 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4412 @end smallexample
4413
4414 @item long_call
4415 @itemx near
4416 @itemx far
4417 @cindex indirect calls, MIPS
4418 @cindex @code{long_call} function attribute, MIPS
4419 @cindex @code{near} function attribute, MIPS
4420 @cindex @code{far} function attribute, MIPS
4421 These attributes specify how a particular function is called on MIPS@.
4422 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4423 command-line switch. The @code{long_call} and @code{far} attributes are
4424 synonyms, and cause the compiler to always call
4425 the function by first loading its address into a register, and then using
4426 the contents of that register. The @code{near} attribute has the opposite
4427 effect; it specifies that non-PIC calls should be made using the more
4428 efficient @code{jal} instruction.
4429
4430 @item mips16
4431 @itemx nomips16
4432 @cindex @code{mips16} function attribute, MIPS
4433 @cindex @code{nomips16} function attribute, MIPS
4434
4435 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4436 function attributes to locally select or turn off MIPS16 code generation.
4437 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4438 while MIPS16 code generation is disabled for functions with the
4439 @code{nomips16} attribute. These attributes override the
4440 @option{-mips16} and @option{-mno-mips16} options on the command line
4441 (@pxref{MIPS Options}).
4442
4443 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4444 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4445 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4446 may interact badly with some GCC extensions such as @code{__builtin_apply}
4447 (@pxref{Constructing Calls}).
4448
4449 @item micromips, MIPS
4450 @itemx nomicromips, MIPS
4451 @cindex @code{micromips} function attribute
4452 @cindex @code{nomicromips} function attribute
4453
4454 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4455 function attributes to locally select or turn off microMIPS code generation.
4456 A function with the @code{micromips} attribute is emitted as microMIPS code,
4457 while microMIPS code generation is disabled for functions with the
4458 @code{nomicromips} attribute. These attributes override the
4459 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4460 (@pxref{MIPS Options}).
4461
4462 When compiling files containing mixed microMIPS and non-microMIPS code, the
4463 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4464 command line,
4465 not that within individual functions. Mixed microMIPS and non-microMIPS code
4466 may interact badly with some GCC extensions such as @code{__builtin_apply}
4467 (@pxref{Constructing Calls}).
4468
4469 @item nocompression
4470 @cindex @code{nocompression} function attribute, MIPS
4471 On MIPS targets, you can use the @code{nocompression} function attribute
4472 to locally turn off MIPS16 and microMIPS code generation. This attribute
4473 overrides the @option{-mips16} and @option{-mmicromips} options on the
4474 command line (@pxref{MIPS Options}).
4475 @end table
4476
4477 @node MSP430 Function Attributes
4478 @subsection MSP430 Function Attributes
4479
4480 These function attributes are supported by the MSP430 back end:
4481
4482 @table @code
4483 @item critical
4484 @cindex @code{critical} function attribute, MSP430
4485 Critical functions disable interrupts upon entry and restore the
4486 previous interrupt state upon exit. Critical functions cannot also
4487 have the @code{naked} or @code{reentrant} attributes. They can have
4488 the @code{interrupt} attribute.
4489
4490 @item interrupt
4491 @cindex @code{interrupt} function attribute, MSP430
4492 Use this attribute to indicate
4493 that the specified function is an interrupt handler. The compiler generates
4494 function entry and exit sequences suitable for use in an interrupt handler
4495 when this attribute is present.
4496
4497 You can provide an argument to the interrupt
4498 attribute which specifies a name or number. If the argument is a
4499 number it indicates the slot in the interrupt vector table (0 - 31) to
4500 which this handler should be assigned. If the argument is a name it
4501 is treated as a symbolic name for the vector slot. These names should
4502 match up with appropriate entries in the linker script. By default
4503 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4504 @code{reset} for vector 31 are recognized.
4505
4506 @item naked
4507 @cindex @code{naked} function attribute, MSP430
4508 This attribute allows the compiler to construct the
4509 requisite function declaration, while allowing the body of the
4510 function to be assembly code. The specified function will not have
4511 prologue/epilogue sequences generated by the compiler. Only basic
4512 @code{asm} statements can safely be included in naked functions
4513 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4514 basic @code{asm} and C code may appear to work, they cannot be
4515 depended upon to work reliably and are not supported.
4516
4517 @item reentrant
4518 @cindex @code{reentrant} function attribute, MSP430
4519 Reentrant functions disable interrupts upon entry and enable them
4520 upon exit. Reentrant functions cannot also have the @code{naked}
4521 or @code{critical} attributes. They can have the @code{interrupt}
4522 attribute.
4523
4524 @item wakeup
4525 @cindex @code{wakeup} function attribute, MSP430
4526 This attribute only applies to interrupt functions. It is silently
4527 ignored if applied to a non-interrupt function. A wakeup interrupt
4528 function will rouse the processor from any low-power state that it
4529 might be in when the function exits.
4530
4531 @item lower
4532 @itemx upper
4533 @itemx either
4534 @cindex @code{lower} function attribute, MSP430
4535 @cindex @code{upper} function attribute, MSP430
4536 @cindex @code{either} function attribute, MSP430
4537 On the MSP430 target these attributes can be used to specify whether
4538 the function or variable should be placed into low memory, high
4539 memory, or the placement should be left to the linker to decide. The
4540 attributes are only significant if compiling for the MSP430X
4541 architecture.
4542
4543 The attributes work in conjunction with a linker script that has been
4544 augmented to specify where to place sections with a @code{.lower} and
4545 a @code{.upper} prefix. So, for example, as well as placing the
4546 @code{.data} section, the script also specifies the placement of a
4547 @code{.lower.data} and a @code{.upper.data} section. The intention
4548 is that @code{lower} sections are placed into a small but easier to
4549 access memory region and the upper sections are placed into a larger, but
4550 slower to access, region.
4551
4552 The @code{either} attribute is special. It tells the linker to place
4553 the object into the corresponding @code{lower} section if there is
4554 room for it. If there is insufficient room then the object is placed
4555 into the corresponding @code{upper} section instead. Note that the
4556 placement algorithm is not very sophisticated. It does not attempt to
4557 find an optimal packing of the @code{lower} sections. It just makes
4558 one pass over the objects and does the best that it can. Using the
4559 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4560 options can help the packing, however, since they produce smaller,
4561 easier to pack regions.
4562 @end table
4563
4564 @node NDS32 Function Attributes
4565 @subsection NDS32 Function Attributes
4566
4567 These function attributes are supported by the NDS32 back end:
4568
4569 @table @code
4570 @item exception
4571 @cindex @code{exception} function attribute
4572 @cindex exception handler functions, NDS32
4573 Use this attribute on the NDS32 target to indicate that the specified function
4574 is an exception handler. The compiler will generate corresponding sections
4575 for use in an exception handler.
4576
4577 @item interrupt
4578 @cindex @code{interrupt} function attribute, NDS32
4579 On NDS32 target, this attribute indicates that the specified function
4580 is an interrupt handler. The compiler generates corresponding sections
4581 for use in an interrupt handler. You can use the following attributes
4582 to modify the behavior:
4583 @table @code
4584 @item nested
4585 @cindex @code{nested} function attribute, NDS32
4586 This interrupt service routine is interruptible.
4587 @item not_nested
4588 @cindex @code{not_nested} function attribute, NDS32
4589 This interrupt service routine is not interruptible.
4590 @item nested_ready
4591 @cindex @code{nested_ready} function attribute, NDS32
4592 This interrupt service routine is interruptible after @code{PSW.GIE}
4593 (global interrupt enable) is set. This allows interrupt service routine to
4594 finish some short critical code before enabling interrupts.
4595 @item save_all
4596 @cindex @code{save_all} function attribute, NDS32
4597 The system will help save all registers into stack before entering
4598 interrupt handler.
4599 @item partial_save
4600 @cindex @code{partial_save} function attribute, NDS32
4601 The system will help save caller registers into stack before entering
4602 interrupt handler.
4603 @end table
4604
4605 @item naked
4606 @cindex @code{naked} function attribute, NDS32
4607 This attribute allows the compiler to construct the
4608 requisite function declaration, while allowing the body of the
4609 function to be assembly code. The specified function will not have
4610 prologue/epilogue sequences generated by the compiler. Only basic
4611 @code{asm} statements can safely be included in naked functions
4612 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4613 basic @code{asm} and C code may appear to work, they cannot be
4614 depended upon to work reliably and are not supported.
4615
4616 @item reset
4617 @cindex @code{reset} function attribute, NDS32
4618 @cindex reset handler functions
4619 Use this attribute on the NDS32 target to indicate that the specified function
4620 is a reset handler. The compiler will generate corresponding sections
4621 for use in a reset handler. You can use the following attributes
4622 to provide extra exception handling:
4623 @table @code
4624 @item nmi
4625 @cindex @code{nmi} function attribute, NDS32
4626 Provide a user-defined function to handle NMI exception.
4627 @item warm
4628 @cindex @code{warm} function attribute, NDS32
4629 Provide a user-defined function to handle warm reset exception.
4630 @end table
4631 @end table
4632
4633 @node Nios II Function Attributes
4634 @subsection Nios II Function Attributes
4635
4636 These function attributes are supported by the Nios II back end:
4637
4638 @table @code
4639 @item target (@var{options})
4640 @cindex @code{target} function attribute
4641 As discussed in @ref{Common Function Attributes}, this attribute
4642 allows specification of target-specific compilation options.
4643
4644 When compiling for Nios II, the following options are allowed:
4645
4646 @table @samp
4647 @item custom-@var{insn}=@var{N}
4648 @itemx no-custom-@var{insn}
4649 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4650 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4651 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4652 custom instruction with encoding @var{N} when generating code that uses
4653 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4654 the custom instruction @var{insn}.
4655 These target attributes correspond to the
4656 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4657 command-line options, and support the same set of @var{insn} keywords.
4658 @xref{Nios II Options}, for more information.
4659
4660 @item custom-fpu-cfg=@var{name}
4661 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4662 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4663 command-line option, to select a predefined set of custom instructions
4664 named @var{name}.
4665 @xref{Nios II Options}, for more information.
4666 @end table
4667 @end table
4668
4669 @node Nvidia PTX Function Attributes
4670 @subsection Nvidia PTX Function Attributes
4671
4672 These function attributes are supported by the Nvidia PTX back end:
4673
4674 @table @code
4675 @item kernel
4676 @cindex @code{kernel} attribute, Nvidia PTX
4677 This attribute indicates that the corresponding function should be compiled
4678 as a kernel function, which can be invoked from the host via the CUDA RT
4679 library.
4680 By default functions are only callable only from other PTX functions.
4681
4682 Kernel functions must have @code{void} return type.
4683 @end table
4684
4685 @node PowerPC Function Attributes
4686 @subsection PowerPC Function Attributes
4687
4688 These function attributes are supported by the PowerPC back end:
4689
4690 @table @code
4691 @item longcall
4692 @itemx shortcall
4693 @cindex indirect calls, PowerPC
4694 @cindex @code{longcall} function attribute, PowerPC
4695 @cindex @code{shortcall} function attribute, PowerPC
4696 The @code{longcall} attribute
4697 indicates that the function might be far away from the call site and
4698 require a different (more expensive) calling sequence. The
4699 @code{shortcall} attribute indicates that the function is always close
4700 enough for the shorter calling sequence to be used. These attributes
4701 override both the @option{-mlongcall} switch and
4702 the @code{#pragma longcall} setting.
4703
4704 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4705 calls are necessary.
4706
4707 @item target (@var{options})
4708 @cindex @code{target} function attribute
4709 As discussed in @ref{Common Function Attributes}, this attribute
4710 allows specification of target-specific compilation options.
4711
4712 On the PowerPC, the following options are allowed:
4713
4714 @table @samp
4715 @item altivec
4716 @itemx no-altivec
4717 @cindex @code{target("altivec")} function attribute, PowerPC
4718 Generate code that uses (does not use) AltiVec instructions. In
4719 32-bit code, you cannot enable AltiVec instructions unless
4720 @option{-mabi=altivec} is used on the command line.
4721
4722 @item cmpb
4723 @itemx no-cmpb
4724 @cindex @code{target("cmpb")} function attribute, PowerPC
4725 Generate code that uses (does not use) the compare bytes instruction
4726 implemented on the POWER6 processor and other processors that support
4727 the PowerPC V2.05 architecture.
4728
4729 @item dlmzb
4730 @itemx no-dlmzb
4731 @cindex @code{target("dlmzb")} function attribute, PowerPC
4732 Generate code that uses (does not use) the string-search @samp{dlmzb}
4733 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4734 generated by default when targeting those processors.
4735
4736 @item fprnd
4737 @itemx no-fprnd
4738 @cindex @code{target("fprnd")} function attribute, PowerPC
4739 Generate code that uses (does not use) the FP round to integer
4740 instructions implemented on the POWER5+ processor and other processors
4741 that support the PowerPC V2.03 architecture.
4742
4743 @item hard-dfp
4744 @itemx no-hard-dfp
4745 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4746 Generate code that uses (does not use) the decimal floating-point
4747 instructions implemented on some POWER processors.
4748
4749 @item isel
4750 @itemx no-isel
4751 @cindex @code{target("isel")} function attribute, PowerPC
4752 Generate code that uses (does not use) ISEL instruction.
4753
4754 @item mfcrf
4755 @itemx no-mfcrf
4756 @cindex @code{target("mfcrf")} function attribute, PowerPC
4757 Generate code that uses (does not use) the move from condition
4758 register field instruction implemented on the POWER4 processor and
4759 other processors that support the PowerPC V2.01 architecture.
4760
4761 @item mfpgpr
4762 @itemx no-mfpgpr
4763 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4764 Generate code that uses (does not use) the FP move to/from general
4765 purpose register instructions implemented on the POWER6X processor and
4766 other processors that support the extended PowerPC V2.05 architecture.
4767
4768 @item mulhw
4769 @itemx no-mulhw
4770 @cindex @code{target("mulhw")} function attribute, PowerPC
4771 Generate code that uses (does not use) the half-word multiply and
4772 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4773 These instructions are generated by default when targeting those
4774 processors.
4775
4776 @item multiple
4777 @itemx no-multiple
4778 @cindex @code{target("multiple")} function attribute, PowerPC
4779 Generate code that uses (does not use) the load multiple word
4780 instructions and the store multiple word instructions.
4781
4782 @item update
4783 @itemx no-update
4784 @cindex @code{target("update")} function attribute, PowerPC
4785 Generate code that uses (does not use) the load or store instructions
4786 that update the base register to the address of the calculated memory
4787 location.
4788
4789 @item popcntb
4790 @itemx no-popcntb
4791 @cindex @code{target("popcntb")} function attribute, PowerPC
4792 Generate code that uses (does not use) the popcount and double-precision
4793 FP reciprocal estimate instruction implemented on the POWER5
4794 processor and other processors that support the PowerPC V2.02
4795 architecture.
4796
4797 @item popcntd
4798 @itemx no-popcntd
4799 @cindex @code{target("popcntd")} function attribute, PowerPC
4800 Generate code that uses (does not use) the popcount instruction
4801 implemented on the POWER7 processor and other processors that support
4802 the PowerPC V2.06 architecture.
4803
4804 @item powerpc-gfxopt
4805 @itemx no-powerpc-gfxopt
4806 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4807 Generate code that uses (does not use) the optional PowerPC
4808 architecture instructions in the Graphics group, including
4809 floating-point select.
4810
4811 @item powerpc-gpopt
4812 @itemx no-powerpc-gpopt
4813 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4814 Generate code that uses (does not use) the optional PowerPC
4815 architecture instructions in the General Purpose group, including
4816 floating-point square root.
4817
4818 @item recip-precision
4819 @itemx no-recip-precision
4820 @cindex @code{target("recip-precision")} function attribute, PowerPC
4821 Assume (do not assume) that the reciprocal estimate instructions
4822 provide higher-precision estimates than is mandated by the PowerPC
4823 ABI.
4824
4825 @item string
4826 @itemx no-string
4827 @cindex @code{target("string")} function attribute, PowerPC
4828 Generate code that uses (does not use) the load string instructions
4829 and the store string word instructions to save multiple registers and
4830 do small block moves.
4831
4832 @item vsx
4833 @itemx no-vsx
4834 @cindex @code{target("vsx")} function attribute, PowerPC
4835 Generate code that uses (does not use) vector/scalar (VSX)
4836 instructions, and also enable the use of built-in functions that allow
4837 more direct access to the VSX instruction set. In 32-bit code, you
4838 cannot enable VSX or AltiVec instructions unless
4839 @option{-mabi=altivec} is used on the command line.
4840
4841 @item friz
4842 @itemx no-friz
4843 @cindex @code{target("friz")} function attribute, PowerPC
4844 Generate (do not generate) the @code{friz} instruction when the
4845 @option{-funsafe-math-optimizations} option is used to optimize
4846 rounding a floating-point value to 64-bit integer and back to floating
4847 point. The @code{friz} instruction does not return the same value if
4848 the floating-point number is too large to fit in an integer.
4849
4850 @item avoid-indexed-addresses
4851 @itemx no-avoid-indexed-addresses
4852 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4853 Generate code that tries to avoid (not avoid) the use of indexed load
4854 or store instructions.
4855
4856 @item paired
4857 @itemx no-paired
4858 @cindex @code{target("paired")} function attribute, PowerPC
4859 Generate code that uses (does not use) the generation of PAIRED simd
4860 instructions.
4861
4862 @item longcall
4863 @itemx no-longcall
4864 @cindex @code{target("longcall")} function attribute, PowerPC
4865 Generate code that assumes (does not assume) that all calls are far
4866 away so that a longer more expensive calling sequence is required.
4867
4868 @item cpu=@var{CPU}
4869 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4870 Specify the architecture to generate code for when compiling the
4871 function. If you select the @code{target("cpu=power7")} attribute when
4872 generating 32-bit code, VSX and AltiVec instructions are not generated
4873 unless you use the @option{-mabi=altivec} option on the command line.
4874
4875 @item tune=@var{TUNE}
4876 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4877 Specify the architecture to tune for when compiling the function. If
4878 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4879 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4880 compilation tunes for the @var{CPU} architecture, and not the
4881 default tuning specified on the command line.
4882 @end table
4883
4884 On the PowerPC, the inliner does not inline a
4885 function that has different target options than the caller, unless the
4886 callee has a subset of the target options of the caller.
4887 @end table
4888
4889 @node RL78 Function Attributes
4890 @subsection RL78 Function Attributes
4891
4892 These function attributes are supported by the RL78 back end:
4893
4894 @table @code
4895 @item interrupt
4896 @itemx brk_interrupt
4897 @cindex @code{interrupt} function attribute, RL78
4898 @cindex @code{brk_interrupt} function attribute, RL78
4899 These attributes indicate
4900 that the specified function is an interrupt handler. The compiler generates
4901 function entry and exit sequences suitable for use in an interrupt handler
4902 when this attribute is present.
4903
4904 Use @code{brk_interrupt} instead of @code{interrupt} for
4905 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4906 that must end with @code{RETB} instead of @code{RETI}).
4907
4908 @item naked
4909 @cindex @code{naked} function attribute, RL78
4910 This attribute allows the compiler to construct the
4911 requisite function declaration, while allowing the body of the
4912 function to be assembly code. The specified function will not have
4913 prologue/epilogue sequences generated by the compiler. Only basic
4914 @code{asm} statements can safely be included in naked functions
4915 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4916 basic @code{asm} and C code may appear to work, they cannot be
4917 depended upon to work reliably and are not supported.
4918 @end table
4919
4920 @node RX Function Attributes
4921 @subsection RX Function Attributes
4922
4923 These function attributes are supported by the RX back end:
4924
4925 @table @code
4926 @item fast_interrupt
4927 @cindex @code{fast_interrupt} function attribute, RX
4928 Use this attribute on the RX port to indicate that the specified
4929 function is a fast interrupt handler. This is just like the
4930 @code{interrupt} attribute, except that @code{freit} is used to return
4931 instead of @code{reit}.
4932
4933 @item interrupt
4934 @cindex @code{interrupt} function attribute, RX
4935 Use this attribute to indicate
4936 that the specified function is an interrupt handler. The compiler generates
4937 function entry and exit sequences suitable for use in an interrupt handler
4938 when this attribute is present.
4939
4940 On RX targets, you may specify one or more vector numbers as arguments
4941 to the attribute, as well as naming an alternate table name.
4942 Parameters are handled sequentially, so one handler can be assigned to
4943 multiple entries in multiple tables. One may also pass the magic
4944 string @code{"$default"} which causes the function to be used for any
4945 unfilled slots in the current table.
4946
4947 This example shows a simple assignment of a function to one vector in
4948 the default table (note that preprocessor macros may be used for
4949 chip-specific symbolic vector names):
4950 @smallexample
4951 void __attribute__ ((interrupt (5))) txd1_handler ();
4952 @end smallexample
4953
4954 This example assigns a function to two slots in the default table
4955 (using preprocessor macros defined elsewhere) and makes it the default
4956 for the @code{dct} table:
4957 @smallexample
4958 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4959 txd1_handler ();
4960 @end smallexample
4961
4962 @item naked
4963 @cindex @code{naked} function attribute, RX
4964 This attribute allows the compiler to construct the
4965 requisite function declaration, while allowing the body of the
4966 function to be assembly code. The specified function will not have
4967 prologue/epilogue sequences generated by the compiler. Only basic
4968 @code{asm} statements can safely be included in naked functions
4969 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4970 basic @code{asm} and C code may appear to work, they cannot be
4971 depended upon to work reliably and are not supported.
4972
4973 @item vector
4974 @cindex @code{vector} function attribute, RX
4975 This RX attribute is similar to the @code{interrupt} attribute, including its
4976 parameters, but does not make the function an interrupt-handler type
4977 function (i.e. it retains the normal C function calling ABI). See the
4978 @code{interrupt} attribute for a description of its arguments.
4979 @end table
4980
4981 @node S/390 Function Attributes
4982 @subsection S/390 Function Attributes
4983
4984 These function attributes are supported on the S/390:
4985
4986 @table @code
4987 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4988 @cindex @code{hotpatch} function attribute, S/390
4989
4990 On S/390 System z targets, you can use this function attribute to
4991 make GCC generate a ``hot-patching'' function prologue. If the
4992 @option{-mhotpatch=} command-line option is used at the same time,
4993 the @code{hotpatch} attribute takes precedence. The first of the
4994 two arguments specifies the number of halfwords to be added before
4995 the function label. A second argument can be used to specify the
4996 number of halfwords to be added after the function label. For
4997 both arguments the maximum allowed value is 1000000.
4998
4999 If both arguments are zero, hotpatching is disabled.
5000
5001 @item target (@var{options})
5002 @cindex @code{target} function attribute
5003 As discussed in @ref{Common Function Attributes}, this attribute
5004 allows specification of target-specific compilation options.
5005
5006 On S/390, the following options are supported:
5007
5008 @table @samp
5009 @item arch=
5010 @item tune=
5011 @item stack-guard=
5012 @item stack-size=
5013 @item branch-cost=
5014 @item warn-framesize=
5015 @item backchain
5016 @itemx no-backchain
5017 @item hard-dfp
5018 @itemx no-hard-dfp
5019 @item hard-float
5020 @itemx soft-float
5021 @item htm
5022 @itemx no-htm
5023 @item vx
5024 @itemx no-vx
5025 @item packed-stack
5026 @itemx no-packed-stack
5027 @item small-exec
5028 @itemx no-small-exec
5029 @item mvcle
5030 @itemx no-mvcle
5031 @item warn-dynamicstack
5032 @itemx no-warn-dynamicstack
5033 @end table
5034
5035 The options work exactly like the S/390 specific command line
5036 options (without the prefix @option{-m}) except that they do not
5037 change any feature macros. For example,
5038
5039 @smallexample
5040 @code{target("no-vx")}
5041 @end smallexample
5042
5043 does not undefine the @code{__VEC__} macro.
5044 @end table
5045
5046 @node SH Function Attributes
5047 @subsection SH Function Attributes
5048
5049 These function attributes are supported on the SH family of processors:
5050
5051 @table @code
5052 @item function_vector
5053 @cindex @code{function_vector} function attribute, SH
5054 @cindex calling functions through the function vector on SH2A
5055 On SH2A targets, this attribute declares a function to be called using the
5056 TBR relative addressing mode. The argument to this attribute is the entry
5057 number of the same function in a vector table containing all the TBR
5058 relative addressable functions. For correct operation the TBR must be setup
5059 accordingly to point to the start of the vector table before any functions with
5060 this attribute are invoked. Usually a good place to do the initialization is
5061 the startup routine. The TBR relative vector table can have at max 256 function
5062 entries. The jumps to these functions are generated using a SH2A specific,
5063 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5064 from GNU binutils version 2.7 or later for this attribute to work correctly.
5065
5066 In an application, for a function being called once, this attribute
5067 saves at least 8 bytes of code; and if other successive calls are being
5068 made to the same function, it saves 2 bytes of code per each of these
5069 calls.
5070
5071 @item interrupt_handler
5072 @cindex @code{interrupt_handler} function attribute, SH
5073 Use this attribute to
5074 indicate that the specified function is an interrupt handler. The compiler
5075 generates function entry and exit sequences suitable for use in an
5076 interrupt handler when this attribute is present.
5077
5078 @item nosave_low_regs
5079 @cindex @code{nosave_low_regs} function attribute, SH
5080 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5081 function should not save and restore registers R0..R7. This can be used on SH3*
5082 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5083 interrupt handlers.
5084
5085 @item renesas
5086 @cindex @code{renesas} function attribute, SH
5087 On SH targets this attribute specifies that the function or struct follows the
5088 Renesas ABI.
5089
5090 @item resbank
5091 @cindex @code{resbank} function attribute, SH
5092 On the SH2A target, this attribute enables the high-speed register
5093 saving and restoration using a register bank for @code{interrupt_handler}
5094 routines. Saving to the bank is performed automatically after the CPU
5095 accepts an interrupt that uses a register bank.
5096
5097 The nineteen 32-bit registers comprising general register R0 to R14,
5098 control register GBR, and system registers MACH, MACL, and PR and the
5099 vector table address offset are saved into a register bank. Register
5100 banks are stacked in first-in last-out (FILO) sequence. Restoration
5101 from the bank is executed by issuing a RESBANK instruction.
5102
5103 @item sp_switch
5104 @cindex @code{sp_switch} function attribute, SH
5105 Use this attribute on the SH to indicate an @code{interrupt_handler}
5106 function should switch to an alternate stack. It expects a string
5107 argument that names a global variable holding the address of the
5108 alternate stack.
5109
5110 @smallexample
5111 void *alt_stack;
5112 void f () __attribute__ ((interrupt_handler,
5113 sp_switch ("alt_stack")));
5114 @end smallexample
5115
5116 @item trap_exit
5117 @cindex @code{trap_exit} function attribute, SH
5118 Use this attribute on the SH for an @code{interrupt_handler} to return using
5119 @code{trapa} instead of @code{rte}. This attribute expects an integer
5120 argument specifying the trap number to be used.
5121
5122 @item trapa_handler
5123 @cindex @code{trapa_handler} function attribute, SH
5124 On SH targets this function attribute is similar to @code{interrupt_handler}
5125 but it does not save and restore all registers.
5126 @end table
5127
5128 @node SPU Function Attributes
5129 @subsection SPU Function Attributes
5130
5131 These function attributes are supported by the SPU back end:
5132
5133 @table @code
5134 @item naked
5135 @cindex @code{naked} function attribute, SPU
5136 This attribute allows the compiler to construct the
5137 requisite function declaration, while allowing the body of the
5138 function to be assembly code. The specified function will not have
5139 prologue/epilogue sequences generated by the compiler. Only basic
5140 @code{asm} statements can safely be included in naked functions
5141 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5142 basic @code{asm} and C code may appear to work, they cannot be
5143 depended upon to work reliably and are not supported.
5144 @end table
5145
5146 @node Symbian OS Function Attributes
5147 @subsection Symbian OS Function Attributes
5148
5149 @xref{Microsoft Windows Function Attributes}, for discussion of the
5150 @code{dllexport} and @code{dllimport} attributes.
5151
5152 @node V850 Function Attributes
5153 @subsection V850 Function Attributes
5154
5155 The V850 back end supports these function attributes:
5156
5157 @table @code
5158 @item interrupt
5159 @itemx interrupt_handler
5160 @cindex @code{interrupt} function attribute, V850
5161 @cindex @code{interrupt_handler} function attribute, V850
5162 Use these attributes to indicate
5163 that the specified function is an interrupt handler. The compiler generates
5164 function entry and exit sequences suitable for use in an interrupt handler
5165 when either attribute is present.
5166 @end table
5167
5168 @node Visium Function Attributes
5169 @subsection Visium Function Attributes
5170
5171 These function attributes are supported by the Visium back end:
5172
5173 @table @code
5174 @item interrupt
5175 @cindex @code{interrupt} function attribute, Visium
5176 Use this attribute to indicate
5177 that the specified function is an interrupt handler. The compiler generates
5178 function entry and exit sequences suitable for use in an interrupt handler
5179 when this attribute is present.
5180 @end table
5181
5182 @node x86 Function Attributes
5183 @subsection x86 Function Attributes
5184
5185 These function attributes are supported by the x86 back end:
5186
5187 @table @code
5188 @item cdecl
5189 @cindex @code{cdecl} function attribute, x86-32
5190 @cindex functions that pop the argument stack on x86-32
5191 @opindex mrtd
5192 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5193 assume that the calling function pops off the stack space used to
5194 pass arguments. This is
5195 useful to override the effects of the @option{-mrtd} switch.
5196
5197 @item fastcall
5198 @cindex @code{fastcall} function attribute, x86-32
5199 @cindex functions that pop the argument stack on x86-32
5200 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5201 pass the first argument (if of integral type) in the register ECX and
5202 the second argument (if of integral type) in the register EDX@. Subsequent
5203 and other typed arguments are passed on the stack. The called function
5204 pops the arguments off the stack. If the number of arguments is variable all
5205 arguments are pushed on the stack.
5206
5207 @item thiscall
5208 @cindex @code{thiscall} function attribute, x86-32
5209 @cindex functions that pop the argument stack on x86-32
5210 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5211 pass the first argument (if of integral type) in the register ECX.
5212 Subsequent and other typed arguments are passed on the stack. The called
5213 function pops the arguments off the stack.
5214 If the number of arguments is variable all arguments are pushed on the
5215 stack.
5216 The @code{thiscall} attribute is intended for C++ non-static member functions.
5217 As a GCC extension, this calling convention can be used for C functions
5218 and for static member methods.
5219
5220 @item ms_abi
5221 @itemx sysv_abi
5222 @cindex @code{ms_abi} function attribute, x86
5223 @cindex @code{sysv_abi} function attribute, x86
5224
5225 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5226 to indicate which calling convention should be used for a function. The
5227 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5228 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5229 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5230 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5231
5232 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5233 requires the @option{-maccumulate-outgoing-args} option.
5234
5235 @item callee_pop_aggregate_return (@var{number})
5236 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5237
5238 On x86-32 targets, you can use this attribute to control how
5239 aggregates are returned in memory. If the caller is responsible for
5240 popping the hidden pointer together with the rest of the arguments, specify
5241 @var{number} equal to zero. If callee is responsible for popping the
5242 hidden pointer, specify @var{number} equal to one.
5243
5244 The default x86-32 ABI assumes that the callee pops the
5245 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5246 the compiler assumes that the
5247 caller pops the stack for hidden pointer.
5248
5249 @item ms_hook_prologue
5250 @cindex @code{ms_hook_prologue} function attribute, x86
5251
5252 On 32-bit and 64-bit x86 targets, you can use
5253 this function attribute to make GCC generate the ``hot-patching'' function
5254 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5255 and newer.
5256
5257 @item regparm (@var{number})
5258 @cindex @code{regparm} function attribute, x86
5259 @cindex functions that are passed arguments in registers on x86-32
5260 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5261 pass arguments number one to @var{number} if they are of integral type
5262 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5263 take a variable number of arguments continue to be passed all of their
5264 arguments on the stack.
5265
5266 Beware that on some ELF systems this attribute is unsuitable for
5267 global functions in shared libraries with lazy binding (which is the
5268 default). Lazy binding sends the first call via resolving code in
5269 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5270 per the standard calling conventions. Solaris 8 is affected by this.
5271 Systems with the GNU C Library version 2.1 or higher
5272 and FreeBSD are believed to be
5273 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5274 disabled with the linker or the loader if desired, to avoid the
5275 problem.)
5276
5277 @item sseregparm
5278 @cindex @code{sseregparm} function attribute, x86
5279 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5280 causes the compiler to pass up to 3 floating-point arguments in
5281 SSE registers instead of on the stack. Functions that take a
5282 variable number of arguments continue to pass all of their
5283 floating-point arguments on the stack.
5284
5285 @item force_align_arg_pointer
5286 @cindex @code{force_align_arg_pointer} function attribute, x86
5287 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5288 applied to individual function definitions, generating an alternate
5289 prologue and epilogue that realigns the run-time stack if necessary.
5290 This supports mixing legacy codes that run with a 4-byte aligned stack
5291 with modern codes that keep a 16-byte stack for SSE compatibility.
5292
5293 @item stdcall
5294 @cindex @code{stdcall} function attribute, x86-32
5295 @cindex functions that pop the argument stack on x86-32
5296 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5297 assume that the called function pops off the stack space used to
5298 pass arguments, unless it takes a variable number of arguments.
5299
5300 @item target (@var{options})
5301 @cindex @code{target} function attribute
5302 As discussed in @ref{Common Function Attributes}, this attribute
5303 allows specification of target-specific compilation options.
5304
5305 On the x86, the following options are allowed:
5306 @table @samp
5307 @item abm
5308 @itemx no-abm
5309 @cindex @code{target("abm")} function attribute, x86
5310 Enable/disable the generation of the advanced bit instructions.
5311
5312 @item aes
5313 @itemx no-aes
5314 @cindex @code{target("aes")} function attribute, x86
5315 Enable/disable the generation of the AES instructions.
5316
5317 @item default
5318 @cindex @code{target("default")} function attribute, x86
5319 @xref{Function Multiversioning}, where it is used to specify the
5320 default function version.
5321
5322 @item mmx
5323 @itemx no-mmx
5324 @cindex @code{target("mmx")} function attribute, x86
5325 Enable/disable the generation of the MMX instructions.
5326
5327 @item pclmul
5328 @itemx no-pclmul
5329 @cindex @code{target("pclmul")} function attribute, x86
5330 Enable/disable the generation of the PCLMUL instructions.
5331
5332 @item popcnt
5333 @itemx no-popcnt
5334 @cindex @code{target("popcnt")} function attribute, x86
5335 Enable/disable the generation of the POPCNT instruction.
5336
5337 @item sse
5338 @itemx no-sse
5339 @cindex @code{target("sse")} function attribute, x86
5340 Enable/disable the generation of the SSE instructions.
5341
5342 @item sse2
5343 @itemx no-sse2
5344 @cindex @code{target("sse2")} function attribute, x86
5345 Enable/disable the generation of the SSE2 instructions.
5346
5347 @item sse3
5348 @itemx no-sse3
5349 @cindex @code{target("sse3")} function attribute, x86
5350 Enable/disable the generation of the SSE3 instructions.
5351
5352 @item sse4
5353 @itemx no-sse4
5354 @cindex @code{target("sse4")} function attribute, x86
5355 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5356 and SSE4.2).
5357
5358 @item sse4.1
5359 @itemx no-sse4.1
5360 @cindex @code{target("sse4.1")} function attribute, x86
5361 Enable/disable the generation of the sse4.1 instructions.
5362
5363 @item sse4.2
5364 @itemx no-sse4.2
5365 @cindex @code{target("sse4.2")} function attribute, x86
5366 Enable/disable the generation of the sse4.2 instructions.
5367
5368 @item sse4a
5369 @itemx no-sse4a
5370 @cindex @code{target("sse4a")} function attribute, x86
5371 Enable/disable the generation of the SSE4A instructions.
5372
5373 @item fma4
5374 @itemx no-fma4
5375 @cindex @code{target("fma4")} function attribute, x86
5376 Enable/disable the generation of the FMA4 instructions.
5377
5378 @item xop
5379 @itemx no-xop
5380 @cindex @code{target("xop")} function attribute, x86
5381 Enable/disable the generation of the XOP instructions.
5382
5383 @item lwp
5384 @itemx no-lwp
5385 @cindex @code{target("lwp")} function attribute, x86
5386 Enable/disable the generation of the LWP instructions.
5387
5388 @item ssse3
5389 @itemx no-ssse3
5390 @cindex @code{target("ssse3")} function attribute, x86
5391 Enable/disable the generation of the SSSE3 instructions.
5392
5393 @item cld
5394 @itemx no-cld
5395 @cindex @code{target("cld")} function attribute, x86
5396 Enable/disable the generation of the CLD before string moves.
5397
5398 @item fancy-math-387
5399 @itemx no-fancy-math-387
5400 @cindex @code{target("fancy-math-387")} function attribute, x86
5401 Enable/disable the generation of the @code{sin}, @code{cos}, and
5402 @code{sqrt} instructions on the 387 floating-point unit.
5403
5404 @item fused-madd
5405 @itemx no-fused-madd
5406 @cindex @code{target("fused-madd")} function attribute, x86
5407 Enable/disable the generation of the fused multiply/add instructions.
5408
5409 @item ieee-fp
5410 @itemx no-ieee-fp
5411 @cindex @code{target("ieee-fp")} function attribute, x86
5412 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5413
5414 @item inline-all-stringops
5415 @itemx no-inline-all-stringops
5416 @cindex @code{target("inline-all-stringops")} function attribute, x86
5417 Enable/disable inlining of string operations.
5418
5419 @item inline-stringops-dynamically
5420 @itemx no-inline-stringops-dynamically
5421 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5422 Enable/disable the generation of the inline code to do small string
5423 operations and calling the library routines for large operations.
5424
5425 @item align-stringops
5426 @itemx no-align-stringops
5427 @cindex @code{target("align-stringops")} function attribute, x86
5428 Do/do not align destination of inlined string operations.
5429
5430 @item recip
5431 @itemx no-recip
5432 @cindex @code{target("recip")} function attribute, x86
5433 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5434 instructions followed an additional Newton-Raphson step instead of
5435 doing a floating-point division.
5436
5437 @item arch=@var{ARCH}
5438 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5439 Specify the architecture to generate code for in compiling the function.
5440
5441 @item tune=@var{TUNE}
5442 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5443 Specify the architecture to tune for in compiling the function.
5444
5445 @item fpmath=@var{FPMATH}
5446 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5447 Specify which floating-point unit to use. You must specify the
5448 @code{target("fpmath=sse,387")} option as
5449 @code{target("fpmath=sse+387")} because the comma would separate
5450 different options.
5451 @end table
5452
5453 On the x86, the inliner does not inline a
5454 function that has different target options than the caller, unless the
5455 callee has a subset of the target options of the caller. For example
5456 a function declared with @code{target("sse3")} can inline a function
5457 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5458 @end table
5459
5460 @node Xstormy16 Function Attributes
5461 @subsection Xstormy16 Function Attributes
5462
5463 These function attributes are supported by the Xstormy16 back end:
5464
5465 @table @code
5466 @item interrupt
5467 @cindex @code{interrupt} function attribute, Xstormy16
5468 Use this attribute to indicate
5469 that the specified function is an interrupt handler. The compiler generates
5470 function entry and exit sequences suitable for use in an interrupt handler
5471 when this attribute is present.
5472 @end table
5473
5474 @node Variable Attributes
5475 @section Specifying Attributes of Variables
5476 @cindex attribute of variables
5477 @cindex variable attributes
5478
5479 The keyword @code{__attribute__} allows you to specify special
5480 attributes of variables or structure fields. This keyword is followed
5481 by an attribute specification inside double parentheses. Some
5482 attributes are currently defined generically for variables.
5483 Other attributes are defined for variables on particular target
5484 systems. Other attributes are available for functions
5485 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5486 enumerators (@pxref{Enumerator Attributes}), and for types
5487 (@pxref{Type Attributes}).
5488 Other front ends might define more attributes
5489 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5490
5491 @xref{Attribute Syntax}, for details of the exact syntax for using
5492 attributes.
5493
5494 @menu
5495 * Common Variable Attributes::
5496 * AVR Variable Attributes::
5497 * Blackfin Variable Attributes::
5498 * H8/300 Variable Attributes::
5499 * IA-64 Variable Attributes::
5500 * M32R/D Variable Attributes::
5501 * MeP Variable Attributes::
5502 * Microsoft Windows Variable Attributes::
5503 * MSP430 Variable Attributes::
5504 * PowerPC Variable Attributes::
5505 * RL78 Variable Attributes::
5506 * SPU Variable Attributes::
5507 * V850 Variable Attributes::
5508 * x86 Variable Attributes::
5509 * Xstormy16 Variable Attributes::
5510 @end menu
5511
5512 @node Common Variable Attributes
5513 @subsection Common Variable Attributes
5514
5515 The following attributes are supported on most targets.
5516
5517 @table @code
5518 @cindex @code{aligned} variable attribute
5519 @item aligned (@var{alignment})
5520 This attribute specifies a minimum alignment for the variable or
5521 structure field, measured in bytes. For example, the declaration:
5522
5523 @smallexample
5524 int x __attribute__ ((aligned (16))) = 0;
5525 @end smallexample
5526
5527 @noindent
5528 causes the compiler to allocate the global variable @code{x} on a
5529 16-byte boundary. On a 68040, this could be used in conjunction with
5530 an @code{asm} expression to access the @code{move16} instruction which
5531 requires 16-byte aligned operands.
5532
5533 You can also specify the alignment of structure fields. For example, to
5534 create a double-word aligned @code{int} pair, you could write:
5535
5536 @smallexample
5537 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5538 @end smallexample
5539
5540 @noindent
5541 This is an alternative to creating a union with a @code{double} member,
5542 which forces the union to be double-word aligned.
5543
5544 As in the preceding examples, you can explicitly specify the alignment
5545 (in bytes) that you wish the compiler to use for a given variable or
5546 structure field. Alternatively, you can leave out the alignment factor
5547 and just ask the compiler to align a variable or field to the
5548 default alignment for the target architecture you are compiling for.
5549 The default alignment is sufficient for all scalar types, but may not be
5550 enough for all vector types on a target that supports vector operations.
5551 The default alignment is fixed for a particular target ABI.
5552
5553 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5554 which is the largest alignment ever used for any data type on the
5555 target machine you are compiling for. For example, you could write:
5556
5557 @smallexample
5558 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5559 @end smallexample
5560
5561 The compiler automatically sets the alignment for the declared
5562 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5563 often make copy operations more efficient, because the compiler can
5564 use whatever instructions copy the biggest chunks of memory when
5565 performing copies to or from the variables or fields that you have
5566 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5567 may change depending on command-line options.
5568
5569 When used on a struct, or struct member, the @code{aligned} attribute can
5570 only increase the alignment; in order to decrease it, the @code{packed}
5571 attribute must be specified as well. When used as part of a typedef, the
5572 @code{aligned} attribute can both increase and decrease alignment, and
5573 specifying the @code{packed} attribute generates a warning.
5574
5575 Note that the effectiveness of @code{aligned} attributes may be limited
5576 by inherent limitations in your linker. On many systems, the linker is
5577 only able to arrange for variables to be aligned up to a certain maximum
5578 alignment. (For some linkers, the maximum supported alignment may
5579 be very very small.) If your linker is only able to align variables
5580 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5581 in an @code{__attribute__} still only provides you with 8-byte
5582 alignment. See your linker documentation for further information.
5583
5584 The @code{aligned} attribute can also be used for functions
5585 (@pxref{Common Function Attributes}.)
5586
5587 @item cleanup (@var{cleanup_function})
5588 @cindex @code{cleanup} variable attribute
5589 The @code{cleanup} attribute runs a function when the variable goes
5590 out of scope. This attribute can only be applied to auto function
5591 scope variables; it may not be applied to parameters or variables
5592 with static storage duration. The function must take one parameter,
5593 a pointer to a type compatible with the variable. The return value
5594 of the function (if any) is ignored.
5595
5596 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5597 is run during the stack unwinding that happens during the
5598 processing of the exception. Note that the @code{cleanup} attribute
5599 does not allow the exception to be caught, only to perform an action.
5600 It is undefined what happens if @var{cleanup_function} does not
5601 return normally.
5602
5603 @item common
5604 @itemx nocommon
5605 @cindex @code{common} variable attribute
5606 @cindex @code{nocommon} variable attribute
5607 @opindex fcommon
5608 @opindex fno-common
5609 The @code{common} attribute requests GCC to place a variable in
5610 ``common'' storage. The @code{nocommon} attribute requests the
5611 opposite---to allocate space for it directly.
5612
5613 These attributes override the default chosen by the
5614 @option{-fno-common} and @option{-fcommon} flags respectively.
5615
5616 @item deprecated
5617 @itemx deprecated (@var{msg})
5618 @cindex @code{deprecated} variable attribute
5619 The @code{deprecated} attribute results in a warning if the variable
5620 is used anywhere in the source file. This is useful when identifying
5621 variables that are expected to be removed in a future version of a
5622 program. The warning also includes the location of the declaration
5623 of the deprecated variable, to enable users to easily find further
5624 information about why the variable is deprecated, or what they should
5625 do instead. Note that the warning only occurs for uses:
5626
5627 @smallexample
5628 extern int old_var __attribute__ ((deprecated));
5629 extern int old_var;
5630 int new_fn () @{ return old_var; @}
5631 @end smallexample
5632
5633 @noindent
5634 results in a warning on line 3 but not line 2. The optional @var{msg}
5635 argument, which must be a string, is printed in the warning if
5636 present.
5637
5638 The @code{deprecated} attribute can also be used for functions and
5639 types (@pxref{Common Function Attributes},
5640 @pxref{Common Type Attributes}).
5641
5642 @item mode (@var{mode})
5643 @cindex @code{mode} variable attribute
5644 This attribute specifies the data type for the declaration---whichever
5645 type corresponds to the mode @var{mode}. This in effect lets you
5646 request an integer or floating-point type according to its width.
5647
5648 You may also specify a mode of @code{byte} or @code{__byte__} to
5649 indicate the mode corresponding to a one-byte integer, @code{word} or
5650 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5651 or @code{__pointer__} for the mode used to represent pointers.
5652
5653 @item packed
5654 @cindex @code{packed} variable attribute
5655 The @code{packed} attribute specifies that a variable or structure field
5656 should have the smallest possible alignment---one byte for a variable,
5657 and one bit for a field, unless you specify a larger value with the
5658 @code{aligned} attribute.
5659
5660 Here is a structure in which the field @code{x} is packed, so that it
5661 immediately follows @code{a}:
5662
5663 @smallexample
5664 struct foo
5665 @{
5666 char a;
5667 int x[2] __attribute__ ((packed));
5668 @};
5669 @end smallexample
5670
5671 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5672 @code{packed} attribute on bit-fields of type @code{char}. This has
5673 been fixed in GCC 4.4 but the change can lead to differences in the
5674 structure layout. See the documentation of
5675 @option{-Wpacked-bitfield-compat} for more information.
5676
5677 @item section ("@var{section-name}")
5678 @cindex @code{section} variable attribute
5679 Normally, the compiler places the objects it generates in sections like
5680 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5681 or you need certain particular variables to appear in special sections,
5682 for example to map to special hardware. The @code{section}
5683 attribute specifies that a variable (or function) lives in a particular
5684 section. For example, this small program uses several specific section names:
5685
5686 @smallexample
5687 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5688 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5689 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5690 int init_data __attribute__ ((section ("INITDATA")));
5691
5692 main()
5693 @{
5694 /* @r{Initialize stack pointer} */
5695 init_sp (stack + sizeof (stack));
5696
5697 /* @r{Initialize initialized data} */
5698 memcpy (&init_data, &data, &edata - &data);
5699
5700 /* @r{Turn on the serial ports} */
5701 init_duart (&a);
5702 init_duart (&b);
5703 @}
5704 @end smallexample
5705
5706 @noindent
5707 Use the @code{section} attribute with
5708 @emph{global} variables and not @emph{local} variables,
5709 as shown in the example.
5710
5711 You may use the @code{section} attribute with initialized or
5712 uninitialized global variables but the linker requires
5713 each object be defined once, with the exception that uninitialized
5714 variables tentatively go in the @code{common} (or @code{bss}) section
5715 and can be multiply ``defined''. Using the @code{section} attribute
5716 changes what section the variable goes into and may cause the
5717 linker to issue an error if an uninitialized variable has multiple
5718 definitions. You can force a variable to be initialized with the
5719 @option{-fno-common} flag or the @code{nocommon} attribute.
5720
5721 Some file formats do not support arbitrary sections so the @code{section}
5722 attribute is not available on all platforms.
5723 If you need to map the entire contents of a module to a particular
5724 section, consider using the facilities of the linker instead.
5725
5726 @item tls_model ("@var{tls_model}")
5727 @cindex @code{tls_model} variable attribute
5728 The @code{tls_model} attribute sets thread-local storage model
5729 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5730 overriding @option{-ftls-model=} command-line switch on a per-variable
5731 basis.
5732 The @var{tls_model} argument should be one of @code{global-dynamic},
5733 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5734
5735 Not all targets support this attribute.
5736
5737 @item unused
5738 @cindex @code{unused} variable attribute
5739 This attribute, attached to a variable, means that the variable is meant
5740 to be possibly unused. GCC does not produce a warning for this
5741 variable.
5742
5743 @item used
5744 @cindex @code{used} variable attribute
5745 This attribute, attached to a variable with static storage, means that
5746 the variable must be emitted even if it appears that the variable is not
5747 referenced.
5748
5749 When applied to a static data member of a C++ class template, the
5750 attribute also means that the member is instantiated if the
5751 class itself is instantiated.
5752
5753 @item vector_size (@var{bytes})
5754 @cindex @code{vector_size} variable attribute
5755 This attribute specifies the vector size for the variable, measured in
5756 bytes. For example, the declaration:
5757
5758 @smallexample
5759 int foo __attribute__ ((vector_size (16)));
5760 @end smallexample
5761
5762 @noindent
5763 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5764 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5765 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5766
5767 This attribute is only applicable to integral and float scalars,
5768 although arrays, pointers, and function return values are allowed in
5769 conjunction with this construct.
5770
5771 Aggregates with this attribute are invalid, even if they are of the same
5772 size as a corresponding scalar. For example, the declaration:
5773
5774 @smallexample
5775 struct S @{ int a; @};
5776 struct S __attribute__ ((vector_size (16))) foo;
5777 @end smallexample
5778
5779 @noindent
5780 is invalid even if the size of the structure is the same as the size of
5781 the @code{int}.
5782
5783 @item visibility ("@var{visibility_type}")
5784 @cindex @code{visibility} variable attribute
5785 This attribute affects the linkage of the declaration to which it is attached.
5786 The @code{visibility} attribute is described in
5787 @ref{Common Function Attributes}.
5788
5789 @item weak
5790 @cindex @code{weak} variable attribute
5791 The @code{weak} attribute is described in
5792 @ref{Common Function Attributes}.
5793
5794 @end table
5795
5796 @node AVR Variable Attributes
5797 @subsection AVR Variable Attributes
5798
5799 @table @code
5800 @item progmem
5801 @cindex @code{progmem} variable attribute, AVR
5802 The @code{progmem} attribute is used on the AVR to place read-only
5803 data in the non-volatile program memory (flash). The @code{progmem}
5804 attribute accomplishes this by putting respective variables into a
5805 section whose name starts with @code{.progmem}.
5806
5807 This attribute works similar to the @code{section} attribute
5808 but adds additional checking. Notice that just like the
5809 @code{section} attribute, @code{progmem} affects the location
5810 of the data but not how this data is accessed.
5811
5812 In order to read data located with the @code{progmem} attribute
5813 (inline) assembler must be used.
5814 @smallexample
5815 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5816 #include <avr/pgmspace.h>
5817
5818 /* Locate var in flash memory */
5819 const int var[2] PROGMEM = @{ 1, 2 @};
5820
5821 int read_var (int i)
5822 @{
5823 /* Access var[] by accessor macro from avr/pgmspace.h */
5824 return (int) pgm_read_word (& var[i]);
5825 @}
5826 @end smallexample
5827
5828 AVR is a Harvard architecture processor and data and read-only data
5829 normally resides in the data memory (RAM).
5830
5831 See also the @ref{AVR Named Address Spaces} section for
5832 an alternate way to locate and access data in flash memory.
5833
5834 @item io
5835 @itemx io (@var{addr})
5836 @cindex @code{io} variable attribute, AVR
5837 Variables with the @code{io} attribute are used to address
5838 memory-mapped peripherals in the io address range.
5839 If an address is specified, the variable
5840 is assigned that address, and the value is interpreted as an
5841 address in the data address space.
5842 Example:
5843
5844 @smallexample
5845 volatile int porta __attribute__((io (0x22)));
5846 @end smallexample
5847
5848 The address specified in the address in the data address range.
5849
5850 Otherwise, the variable it is not assigned an address, but the
5851 compiler will still use in/out instructions where applicable,
5852 assuming some other module assigns an address in the io address range.
5853 Example:
5854
5855 @smallexample
5856 extern volatile int porta __attribute__((io));
5857 @end smallexample
5858
5859 @item io_low
5860 @itemx io_low (@var{addr})
5861 @cindex @code{io_low} variable attribute, AVR
5862 This is like the @code{io} attribute, but additionally it informs the
5863 compiler that the object lies in the lower half of the I/O area,
5864 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5865 instructions.
5866
5867 @item address
5868 @itemx address (@var{addr})
5869 @cindex @code{address} variable attribute, AVR
5870 Variables with the @code{address} attribute are used to address
5871 memory-mapped peripherals that may lie outside the io address range.
5872
5873 @smallexample
5874 volatile int porta __attribute__((address (0x600)));
5875 @end smallexample
5876
5877 @end table
5878
5879 @node Blackfin Variable Attributes
5880 @subsection Blackfin Variable Attributes
5881
5882 Three attributes are currently defined for the Blackfin.
5883
5884 @table @code
5885 @item l1_data
5886 @itemx l1_data_A
5887 @itemx l1_data_B
5888 @cindex @code{l1_data} variable attribute, Blackfin
5889 @cindex @code{l1_data_A} variable attribute, Blackfin
5890 @cindex @code{l1_data_B} variable attribute, Blackfin
5891 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5892 Variables with @code{l1_data} attribute are put into the specific section
5893 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5894 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5895 attribute are put into the specific section named @code{.l1.data.B}.
5896
5897 @item l2
5898 @cindex @code{l2} variable attribute, Blackfin
5899 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5900 Variables with @code{l2} attribute are put into the specific section
5901 named @code{.l2.data}.
5902 @end table
5903
5904 @node H8/300 Variable Attributes
5905 @subsection H8/300 Variable Attributes
5906
5907 These variable attributes are available for H8/300 targets:
5908
5909 @table @code
5910 @item eightbit_data
5911 @cindex @code{eightbit_data} variable attribute, H8/300
5912 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5913 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5914 variable should be placed into the eight-bit data section.
5915 The compiler generates more efficient code for certain operations
5916 on data in the eight-bit data area. Note the eight-bit data area is limited to
5917 256 bytes of data.
5918
5919 You must use GAS and GLD from GNU binutils version 2.7 or later for
5920 this attribute to work correctly.
5921
5922 @item tiny_data
5923 @cindex @code{tiny_data} variable attribute, H8/300
5924 @cindex tiny data section on the H8/300H and H8S
5925 Use this attribute on the H8/300H and H8S to indicate that the specified
5926 variable should be placed into the tiny data section.
5927 The compiler generates more efficient code for loads and stores
5928 on data in the tiny data section. Note the tiny data area is limited to
5929 slightly under 32KB of data.
5930
5931 @end table
5932
5933 @node IA-64 Variable Attributes
5934 @subsection IA-64 Variable Attributes
5935
5936 The IA-64 back end supports the following variable attribute:
5937
5938 @table @code
5939 @item model (@var{model-name})
5940 @cindex @code{model} variable attribute, IA-64
5941
5942 On IA-64, use this attribute to set the addressability of an object.
5943 At present, the only supported identifier for @var{model-name} is
5944 @code{small}, indicating addressability via ``small'' (22-bit)
5945 addresses (so that their addresses can be loaded with the @code{addl}
5946 instruction). Caveat: such addressing is by definition not position
5947 independent and hence this attribute must not be used for objects
5948 defined by shared libraries.
5949
5950 @end table
5951
5952 @node M32R/D Variable Attributes
5953 @subsection M32R/D Variable Attributes
5954
5955 One attribute is currently defined for the M32R/D@.
5956
5957 @table @code
5958 @item model (@var{model-name})
5959 @cindex @code{model-name} variable attribute, M32R/D
5960 @cindex variable addressability on the M32R/D
5961 Use this attribute on the M32R/D to set the addressability of an object.
5962 The identifier @var{model-name} is one of @code{small}, @code{medium},
5963 or @code{large}, representing each of the code models.
5964
5965 Small model objects live in the lower 16MB of memory (so that their
5966 addresses can be loaded with the @code{ld24} instruction).
5967
5968 Medium and large model objects may live anywhere in the 32-bit address space
5969 (the compiler generates @code{seth/add3} instructions to load their
5970 addresses).
5971 @end table
5972
5973 @node MeP Variable Attributes
5974 @subsection MeP Variable Attributes
5975
5976 The MeP target has a number of addressing modes and busses. The
5977 @code{near} space spans the standard memory space's first 16 megabytes
5978 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5979 The @code{based} space is a 128-byte region in the memory space that
5980 is addressed relative to the @code{$tp} register. The @code{tiny}
5981 space is a 65536-byte region relative to the @code{$gp} register. In
5982 addition to these memory regions, the MeP target has a separate 16-bit
5983 control bus which is specified with @code{cb} attributes.
5984
5985 @table @code
5986
5987 @item based
5988 @cindex @code{based} variable attribute, MeP
5989 Any variable with the @code{based} attribute is assigned to the
5990 @code{.based} section, and is accessed with relative to the
5991 @code{$tp} register.
5992
5993 @item tiny
5994 @cindex @code{tiny} variable attribute, MeP
5995 Likewise, the @code{tiny} attribute assigned variables to the
5996 @code{.tiny} section, relative to the @code{$gp} register.
5997
5998 @item near
5999 @cindex @code{near} variable attribute, MeP
6000 Variables with the @code{near} attribute are assumed to have addresses
6001 that fit in a 24-bit addressing mode. This is the default for large
6002 variables (@code{-mtiny=4} is the default) but this attribute can
6003 override @code{-mtiny=} for small variables, or override @code{-ml}.
6004
6005 @item far
6006 @cindex @code{far} variable attribute, MeP
6007 Variables with the @code{far} attribute are addressed using a full
6008 32-bit address. Since this covers the entire memory space, this
6009 allows modules to make no assumptions about where variables might be
6010 stored.
6011
6012 @item io
6013 @cindex @code{io} variable attribute, MeP
6014 @itemx io (@var{addr})
6015 Variables with the @code{io} attribute are used to address
6016 memory-mapped peripherals. If an address is specified, the variable
6017 is assigned that address, else it is not assigned an address (it is
6018 assumed some other module assigns an address). Example:
6019
6020 @smallexample
6021 int timer_count __attribute__((io(0x123)));
6022 @end smallexample
6023
6024 @item cb
6025 @itemx cb (@var{addr})
6026 @cindex @code{cb} variable attribute, MeP
6027 Variables with the @code{cb} attribute are used to access the control
6028 bus, using special instructions. @code{addr} indicates the control bus
6029 address. Example:
6030
6031 @smallexample
6032 int cpu_clock __attribute__((cb(0x123)));
6033 @end smallexample
6034
6035 @end table
6036
6037 @node Microsoft Windows Variable Attributes
6038 @subsection Microsoft Windows Variable Attributes
6039
6040 You can use these attributes on Microsoft Windows targets.
6041 @ref{x86 Variable Attributes} for additional Windows compatibility
6042 attributes available on all x86 targets.
6043
6044 @table @code
6045 @item dllimport
6046 @itemx dllexport
6047 @cindex @code{dllimport} variable attribute
6048 @cindex @code{dllexport} variable attribute
6049 The @code{dllimport} and @code{dllexport} attributes are described in
6050 @ref{Microsoft Windows Function Attributes}.
6051
6052 @item selectany
6053 @cindex @code{selectany} variable attribute
6054 The @code{selectany} attribute causes an initialized global variable to
6055 have link-once semantics. When multiple definitions of the variable are
6056 encountered by the linker, the first is selected and the remainder are
6057 discarded. Following usage by the Microsoft compiler, the linker is told
6058 @emph{not} to warn about size or content differences of the multiple
6059 definitions.
6060
6061 Although the primary usage of this attribute is for POD types, the
6062 attribute can also be applied to global C++ objects that are initialized
6063 by a constructor. In this case, the static initialization and destruction
6064 code for the object is emitted in each translation defining the object,
6065 but the calls to the constructor and destructor are protected by a
6066 link-once guard variable.
6067
6068 The @code{selectany} attribute is only available on Microsoft Windows
6069 targets. You can use @code{__declspec (selectany)} as a synonym for
6070 @code{__attribute__ ((selectany))} for compatibility with other
6071 compilers.
6072
6073 @item shared
6074 @cindex @code{shared} variable attribute
6075 On Microsoft Windows, in addition to putting variable definitions in a named
6076 section, the section can also be shared among all running copies of an
6077 executable or DLL@. For example, this small program defines shared data
6078 by putting it in a named section @code{shared} and marking the section
6079 shareable:
6080
6081 @smallexample
6082 int foo __attribute__((section ("shared"), shared)) = 0;
6083
6084 int
6085 main()
6086 @{
6087 /* @r{Read and write foo. All running
6088 copies see the same value.} */
6089 return 0;
6090 @}
6091 @end smallexample
6092
6093 @noindent
6094 You may only use the @code{shared} attribute along with @code{section}
6095 attribute with a fully-initialized global definition because of the way
6096 linkers work. See @code{section} attribute for more information.
6097
6098 The @code{shared} attribute is only available on Microsoft Windows@.
6099
6100 @end table
6101
6102 @node MSP430 Variable Attributes
6103 @subsection MSP430 Variable Attributes
6104
6105 @table @code
6106 @item noinit
6107 @cindex @code{noinit} variable attribute, MSP430
6108 Any data with the @code{noinit} attribute will not be initialised by
6109 the C runtime startup code, or the program loader. Not initialising
6110 data in this way can reduce program startup times.
6111
6112 @item persistent
6113 @cindex @code{persistent} variable attribute, MSP430
6114 Any variable with the @code{persistent} attribute will not be
6115 initialised by the C runtime startup code. Instead its value will be
6116 set once, when the application is loaded, and then never initialised
6117 again, even if the processor is reset or the program restarts.
6118 Persistent data is intended to be placed into FLASH RAM, where its
6119 value will be retained across resets. The linker script being used to
6120 create the application should ensure that persistent data is correctly
6121 placed.
6122
6123 @item lower
6124 @itemx upper
6125 @itemx either
6126 @cindex @code{lower} variable attribute, MSP430
6127 @cindex @code{upper} variable attribute, MSP430
6128 @cindex @code{either} variable attribute, MSP430
6129 These attributes are the same as the MSP430 function attributes of the
6130 same name (@pxref{MSP430 Function Attributes}).
6131 These attributes can be applied to both functions and variables.
6132 @end table
6133
6134 @node PowerPC Variable Attributes
6135 @subsection PowerPC Variable Attributes
6136
6137 Three attributes currently are defined for PowerPC configurations:
6138 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6139
6140 @cindex @code{ms_struct} variable attribute, PowerPC
6141 @cindex @code{gcc_struct} variable attribute, PowerPC
6142 For full documentation of the struct attributes please see the
6143 documentation in @ref{x86 Variable Attributes}.
6144
6145 @cindex @code{altivec} variable attribute, PowerPC
6146 For documentation of @code{altivec} attribute please see the
6147 documentation in @ref{PowerPC Type Attributes}.
6148
6149 @node RL78 Variable Attributes
6150 @subsection RL78 Variable Attributes
6151
6152 @cindex @code{saddr} variable attribute, RL78
6153 The RL78 back end supports the @code{saddr} variable attribute. This
6154 specifies placement of the corresponding variable in the SADDR area,
6155 which can be accessed more efficiently than the default memory region.
6156
6157 @node SPU Variable Attributes
6158 @subsection SPU Variable Attributes
6159
6160 @cindex @code{spu_vector} variable attribute, SPU
6161 The SPU supports the @code{spu_vector} attribute for variables. For
6162 documentation of this attribute please see the documentation in
6163 @ref{SPU Type Attributes}.
6164
6165 @node V850 Variable Attributes
6166 @subsection V850 Variable Attributes
6167
6168 These variable attributes are supported by the V850 back end:
6169
6170 @table @code
6171
6172 @item sda
6173 @cindex @code{sda} variable attribute, V850
6174 Use this attribute to explicitly place a variable in the small data area,
6175 which can hold up to 64 kilobytes.
6176
6177 @item tda
6178 @cindex @code{tda} variable attribute, V850
6179 Use this attribute to explicitly place a variable in the tiny data area,
6180 which can hold up to 256 bytes in total.
6181
6182 @item zda
6183 @cindex @code{zda} variable attribute, V850
6184 Use this attribute to explicitly place a variable in the first 32 kilobytes
6185 of memory.
6186 @end table
6187
6188 @node x86 Variable Attributes
6189 @subsection x86 Variable Attributes
6190
6191 Two attributes are currently defined for x86 configurations:
6192 @code{ms_struct} and @code{gcc_struct}.
6193
6194 @table @code
6195 @item ms_struct
6196 @itemx gcc_struct
6197 @cindex @code{ms_struct} variable attribute, x86
6198 @cindex @code{gcc_struct} variable attribute, x86
6199
6200 If @code{packed} is used on a structure, or if bit-fields are used,
6201 it may be that the Microsoft ABI lays out the structure differently
6202 than the way GCC normally does. Particularly when moving packed
6203 data between functions compiled with GCC and the native Microsoft compiler
6204 (either via function call or as data in a file), it may be necessary to access
6205 either format.
6206
6207 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6208 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6209 command-line options, respectively;
6210 see @ref{x86 Options}, for details of how structure layout is affected.
6211 @xref{x86 Type Attributes}, for information about the corresponding
6212 attributes on types.
6213
6214 @end table
6215
6216 @node Xstormy16 Variable Attributes
6217 @subsection Xstormy16 Variable Attributes
6218
6219 One attribute is currently defined for xstormy16 configurations:
6220 @code{below100}.
6221
6222 @table @code
6223 @item below100
6224 @cindex @code{below100} variable attribute, Xstormy16
6225
6226 If a variable has the @code{below100} attribute (@code{BELOW100} is
6227 allowed also), GCC places the variable in the first 0x100 bytes of
6228 memory and use special opcodes to access it. Such variables are
6229 placed in either the @code{.bss_below100} section or the
6230 @code{.data_below100} section.
6231
6232 @end table
6233
6234 @node Type Attributes
6235 @section Specifying Attributes of Types
6236 @cindex attribute of types
6237 @cindex type attributes
6238
6239 The keyword @code{__attribute__} allows you to specify special
6240 attributes of types. Some type attributes apply only to @code{struct}
6241 and @code{union} types, while others can apply to any type defined
6242 via a @code{typedef} declaration. Other attributes are defined for
6243 functions (@pxref{Function Attributes}), labels (@pxref{Label
6244 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6245 variables (@pxref{Variable Attributes}).
6246
6247 The @code{__attribute__} keyword is followed by an attribute specification
6248 inside double parentheses.
6249
6250 You may specify type attributes in an enum, struct or union type
6251 declaration or definition by placing them immediately after the
6252 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6253 syntax is to place them just past the closing curly brace of the
6254 definition.
6255
6256 You can also include type attributes in a @code{typedef} declaration.
6257 @xref{Attribute Syntax}, for details of the exact syntax for using
6258 attributes.
6259
6260 @menu
6261 * Common Type Attributes::
6262 * ARM Type Attributes::
6263 * MeP Type Attributes::
6264 * PowerPC Type Attributes::
6265 * SPU Type Attributes::
6266 * x86 Type Attributes::
6267 @end menu
6268
6269 @node Common Type Attributes
6270 @subsection Common Type Attributes
6271
6272 The following type attributes are supported on most targets.
6273
6274 @table @code
6275 @cindex @code{aligned} type attribute
6276 @item aligned (@var{alignment})
6277 This attribute specifies a minimum alignment (in bytes) for variables
6278 of the specified type. For example, the declarations:
6279
6280 @smallexample
6281 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6282 typedef int more_aligned_int __attribute__ ((aligned (8)));
6283 @end smallexample
6284
6285 @noindent
6286 force the compiler to ensure (as far as it can) that each variable whose
6287 type is @code{struct S} or @code{more_aligned_int} is allocated and
6288 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6289 variables of type @code{struct S} aligned to 8-byte boundaries allows
6290 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6291 store) instructions when copying one variable of type @code{struct S} to
6292 another, thus improving run-time efficiency.
6293
6294 Note that the alignment of any given @code{struct} or @code{union} type
6295 is required by the ISO C standard to be at least a perfect multiple of
6296 the lowest common multiple of the alignments of all of the members of
6297 the @code{struct} or @code{union} in question. This means that you @emph{can}
6298 effectively adjust the alignment of a @code{struct} or @code{union}
6299 type by attaching an @code{aligned} attribute to any one of the members
6300 of such a type, but the notation illustrated in the example above is a
6301 more obvious, intuitive, and readable way to request the compiler to
6302 adjust the alignment of an entire @code{struct} or @code{union} type.
6303
6304 As in the preceding example, you can explicitly specify the alignment
6305 (in bytes) that you wish the compiler to use for a given @code{struct}
6306 or @code{union} type. Alternatively, you can leave out the alignment factor
6307 and just ask the compiler to align a type to the maximum
6308 useful alignment for the target machine you are compiling for. For
6309 example, you could write:
6310
6311 @smallexample
6312 struct S @{ short f[3]; @} __attribute__ ((aligned));
6313 @end smallexample
6314
6315 Whenever you leave out the alignment factor in an @code{aligned}
6316 attribute specification, the compiler automatically sets the alignment
6317 for the type to the largest alignment that is ever used for any data
6318 type on the target machine you are compiling for. Doing this can often
6319 make copy operations more efficient, because the compiler can use
6320 whatever instructions copy the biggest chunks of memory when performing
6321 copies to or from the variables that have types that you have aligned
6322 this way.
6323
6324 In the example above, if the size of each @code{short} is 2 bytes, then
6325 the size of the entire @code{struct S} type is 6 bytes. The smallest
6326 power of two that is greater than or equal to that is 8, so the
6327 compiler sets the alignment for the entire @code{struct S} type to 8
6328 bytes.
6329
6330 Note that although you can ask the compiler to select a time-efficient
6331 alignment for a given type and then declare only individual stand-alone
6332 objects of that type, the compiler's ability to select a time-efficient
6333 alignment is primarily useful only when you plan to create arrays of
6334 variables having the relevant (efficiently aligned) type. If you
6335 declare or use arrays of variables of an efficiently-aligned type, then
6336 it is likely that your program also does pointer arithmetic (or
6337 subscripting, which amounts to the same thing) on pointers to the
6338 relevant type, and the code that the compiler generates for these
6339 pointer arithmetic operations is often more efficient for
6340 efficiently-aligned types than for other types.
6341
6342 Note that the effectiveness of @code{aligned} attributes may be limited
6343 by inherent limitations in your linker. On many systems, the linker is
6344 only able to arrange for variables to be aligned up to a certain maximum
6345 alignment. (For some linkers, the maximum supported alignment may
6346 be very very small.) If your linker is only able to align variables
6347 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6348 in an @code{__attribute__} still only provides you with 8-byte
6349 alignment. See your linker documentation for further information.
6350
6351 The @code{aligned} attribute can only increase alignment. Alignment
6352 can be decreased by specifying the @code{packed} attribute. See below.
6353
6354 @item bnd_variable_size
6355 @cindex @code{bnd_variable_size} type attribute
6356 @cindex Pointer Bounds Checker attributes
6357 When applied to a structure field, this attribute tells Pointer
6358 Bounds Checker that the size of this field should not be computed
6359 using static type information. It may be used to mark variably-sized
6360 static array fields placed at the end of a structure.
6361
6362 @smallexample
6363 struct S
6364 @{
6365 int size;
6366 char data[1];
6367 @}
6368 S *p = (S *)malloc (sizeof(S) + 100);
6369 p->data[10] = 0; //Bounds violation
6370 @end smallexample
6371
6372 @noindent
6373 By using an attribute for the field we may avoid unwanted bound
6374 violation checks:
6375
6376 @smallexample
6377 struct S
6378 @{
6379 int size;
6380 char data[1] __attribute__((bnd_variable_size));
6381 @}
6382 S *p = (S *)malloc (sizeof(S) + 100);
6383 p->data[10] = 0; //OK
6384 @end smallexample
6385
6386 @item deprecated
6387 @itemx deprecated (@var{msg})
6388 @cindex @code{deprecated} type attribute
6389 The @code{deprecated} attribute results in a warning if the type
6390 is used anywhere in the source file. This is useful when identifying
6391 types that are expected to be removed in a future version of a program.
6392 If possible, the warning also includes the location of the declaration
6393 of the deprecated type, to enable users to easily find further
6394 information about why the type is deprecated, or what they should do
6395 instead. Note that the warnings only occur for uses and then only
6396 if the type is being applied to an identifier that itself is not being
6397 declared as deprecated.
6398
6399 @smallexample
6400 typedef int T1 __attribute__ ((deprecated));
6401 T1 x;
6402 typedef T1 T2;
6403 T2 y;
6404 typedef T1 T3 __attribute__ ((deprecated));
6405 T3 z __attribute__ ((deprecated));
6406 @end smallexample
6407
6408 @noindent
6409 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6410 warning is issued for line 4 because T2 is not explicitly
6411 deprecated. Line 5 has no warning because T3 is explicitly
6412 deprecated. Similarly for line 6. The optional @var{msg}
6413 argument, which must be a string, is printed in the warning if
6414 present.
6415
6416 The @code{deprecated} attribute can also be used for functions and
6417 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6418
6419 @item designated_init
6420 @cindex @code{designated_init} type attribute
6421 This attribute may only be applied to structure types. It indicates
6422 that any initialization of an object of this type must use designated
6423 initializers rather than positional initializers. The intent of this
6424 attribute is to allow the programmer to indicate that a structure's
6425 layout may change, and that therefore relying on positional
6426 initialization will result in future breakage.
6427
6428 GCC emits warnings based on this attribute by default; use
6429 @option{-Wno-designated-init} to suppress them.
6430
6431 @item may_alias
6432 @cindex @code{may_alias} type attribute
6433 Accesses through pointers to types with this attribute are not subject
6434 to type-based alias analysis, but are instead assumed to be able to alias
6435 any other type of objects.
6436 In the context of section 6.5 paragraph 7 of the C99 standard,
6437 an lvalue expression
6438 dereferencing such a pointer is treated like having a character type.
6439 See @option{-fstrict-aliasing} for more information on aliasing issues.
6440 This extension exists to support some vector APIs, in which pointers to
6441 one vector type are permitted to alias pointers to a different vector type.
6442
6443 Note that an object of a type with this attribute does not have any
6444 special semantics.
6445
6446 Example of use:
6447
6448 @smallexample
6449 typedef short __attribute__((__may_alias__)) short_a;
6450
6451 int
6452 main (void)
6453 @{
6454 int a = 0x12345678;
6455 short_a *b = (short_a *) &a;
6456
6457 b[1] = 0;
6458
6459 if (a == 0x12345678)
6460 abort();
6461
6462 exit(0);
6463 @}
6464 @end smallexample
6465
6466 @noindent
6467 If you replaced @code{short_a} with @code{short} in the variable
6468 declaration, the above program would abort when compiled with
6469 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6470 above.
6471
6472 @item packed
6473 @cindex @code{packed} type attribute
6474 This attribute, attached to @code{struct} or @code{union} type
6475 definition, specifies that each member (other than zero-width bit-fields)
6476 of the structure or union is placed to minimize the memory required. When
6477 attached to an @code{enum} definition, it indicates that the smallest
6478 integral type should be used.
6479
6480 @opindex fshort-enums
6481 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6482 types is equivalent to specifying the @code{packed} attribute on each
6483 of the structure or union members. Specifying the @option{-fshort-enums}
6484 flag on the command line is equivalent to specifying the @code{packed}
6485 attribute on all @code{enum} definitions.
6486
6487 In the following example @code{struct my_packed_struct}'s members are
6488 packed closely together, but the internal layout of its @code{s} member
6489 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6490 be packed too.
6491
6492 @smallexample
6493 struct my_unpacked_struct
6494 @{
6495 char c;
6496 int i;
6497 @};
6498
6499 struct __attribute__ ((__packed__)) my_packed_struct
6500 @{
6501 char c;
6502 int i;
6503 struct my_unpacked_struct s;
6504 @};
6505 @end smallexample
6506
6507 You may only specify the @code{packed} attribute attribute on the definition
6508 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6509 that does not also define the enumerated type, structure or union.
6510
6511 @item scalar_storage_order ("@var{endianness}")
6512 @cindex @code{scalar_storage_order} type attribute
6513 When attached to a @code{union} or a @code{struct}, this attribute sets
6514 the storage order, aka endianness, of the scalar fields of the type, as
6515 well as the array fields whose component is scalar. The supported
6516 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6517 has no effects on fields which are themselves a @code{union}, a @code{struct}
6518 or an array whose component is a @code{union} or a @code{struct}, and it is
6519 possible for these fields to have a different scalar storage order than the
6520 enclosing type.
6521
6522 This attribute is supported only for targets that use a uniform default
6523 scalar storage order (fortunately, most of them), i.e. targets that store
6524 the scalars either all in big-endian or all in little-endian.
6525
6526 Additional restrictions are enforced for types with the reverse scalar
6527 storage order with regard to the scalar storage order of the target:
6528
6529 @itemize
6530 @item Taking the address of a scalar field of a @code{union} or a
6531 @code{struct} with reverse scalar storage order is not permitted and yields
6532 an error.
6533 @item Taking the address of an array field, whose component is scalar, of
6534 a @code{union} or a @code{struct} with reverse scalar storage order is
6535 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6536 is specified.
6537 @item Taking the address of a @code{union} or a @code{struct} with reverse
6538 scalar storage order is permitted.
6539 @end itemize
6540
6541 These restrictions exist because the storage order attribute is lost when
6542 the address of a scalar or the address of an array with scalar component is
6543 taken, so storing indirectly through this address generally does not work.
6544 The second case is nevertheless allowed to be able to perform a block copy
6545 from or to the array.
6546
6547 Moreover, the use of type punning or aliasing to toggle the storage order
6548 is not supported; that is to say, a given scalar object cannot be accessed
6549 through distinct types that assign a different storage order to it.
6550
6551 @item transparent_union
6552 @cindex @code{transparent_union} type attribute
6553
6554 This attribute, attached to a @code{union} type definition, indicates
6555 that any function parameter having that union type causes calls to that
6556 function to be treated in a special way.
6557
6558 First, the argument corresponding to a transparent union type can be of
6559 any type in the union; no cast is required. Also, if the union contains
6560 a pointer type, the corresponding argument can be a null pointer
6561 constant or a void pointer expression; and if the union contains a void
6562 pointer type, the corresponding argument can be any pointer expression.
6563 If the union member type is a pointer, qualifiers like @code{const} on
6564 the referenced type must be respected, just as with normal pointer
6565 conversions.
6566
6567 Second, the argument is passed to the function using the calling
6568 conventions of the first member of the transparent union, not the calling
6569 conventions of the union itself. All members of the union must have the
6570 same machine representation; this is necessary for this argument passing
6571 to work properly.
6572
6573 Transparent unions are designed for library functions that have multiple
6574 interfaces for compatibility reasons. For example, suppose the
6575 @code{wait} function must accept either a value of type @code{int *} to
6576 comply with POSIX, or a value of type @code{union wait *} to comply with
6577 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6578 @code{wait} would accept both kinds of arguments, but it would also
6579 accept any other pointer type and this would make argument type checking
6580 less useful. Instead, @code{<sys/wait.h>} might define the interface
6581 as follows:
6582
6583 @smallexample
6584 typedef union __attribute__ ((__transparent_union__))
6585 @{
6586 int *__ip;
6587 union wait *__up;
6588 @} wait_status_ptr_t;
6589
6590 pid_t wait (wait_status_ptr_t);
6591 @end smallexample
6592
6593 @noindent
6594 This interface allows either @code{int *} or @code{union wait *}
6595 arguments to be passed, using the @code{int *} calling convention.
6596 The program can call @code{wait} with arguments of either type:
6597
6598 @smallexample
6599 int w1 () @{ int w; return wait (&w); @}
6600 int w2 () @{ union wait w; return wait (&w); @}
6601 @end smallexample
6602
6603 @noindent
6604 With this interface, @code{wait}'s implementation might look like this:
6605
6606 @smallexample
6607 pid_t wait (wait_status_ptr_t p)
6608 @{
6609 return waitpid (-1, p.__ip, 0);
6610 @}
6611 @end smallexample
6612
6613 @item unused
6614 @cindex @code{unused} type attribute
6615 When attached to a type (including a @code{union} or a @code{struct}),
6616 this attribute means that variables of that type are meant to appear
6617 possibly unused. GCC does not produce a warning for any variables of
6618 that type, even if the variable appears to do nothing. This is often
6619 the case with lock or thread classes, which are usually defined and then
6620 not referenced, but contain constructors and destructors that have
6621 nontrivial bookkeeping functions.
6622
6623 @item visibility
6624 @cindex @code{visibility} type attribute
6625 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6626 applied to class, struct, union and enum types. Unlike other type
6627 attributes, the attribute must appear between the initial keyword and
6628 the name of the type; it cannot appear after the body of the type.
6629
6630 Note that the type visibility is applied to vague linkage entities
6631 associated with the class (vtable, typeinfo node, etc.). In
6632 particular, if a class is thrown as an exception in one shared object
6633 and caught in another, the class must have default visibility.
6634 Otherwise the two shared objects are unable to use the same
6635 typeinfo node and exception handling will break.
6636
6637 @end table
6638
6639 To specify multiple attributes, separate them by commas within the
6640 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6641 packed))}.
6642
6643 @node ARM Type Attributes
6644 @subsection ARM Type Attributes
6645
6646 @cindex @code{notshared} type attribute, ARM
6647 On those ARM targets that support @code{dllimport} (such as Symbian
6648 OS), you can use the @code{notshared} attribute to indicate that the
6649 virtual table and other similar data for a class should not be
6650 exported from a DLL@. For example:
6651
6652 @smallexample
6653 class __declspec(notshared) C @{
6654 public:
6655 __declspec(dllimport) C();
6656 virtual void f();
6657 @}
6658
6659 __declspec(dllexport)
6660 C::C() @{@}
6661 @end smallexample
6662
6663 @noindent
6664 In this code, @code{C::C} is exported from the current DLL, but the
6665 virtual table for @code{C} is not exported. (You can use
6666 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6667 most Symbian OS code uses @code{__declspec}.)
6668
6669 @node MeP Type Attributes
6670 @subsection MeP Type Attributes
6671
6672 @cindex @code{based} type attribute, MeP
6673 @cindex @code{tiny} type attribute, MeP
6674 @cindex @code{near} type attribute, MeP
6675 @cindex @code{far} type attribute, MeP
6676 Many of the MeP variable attributes may be applied to types as well.
6677 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6678 @code{far} attributes may be applied to either. The @code{io} and
6679 @code{cb} attributes may not be applied to types.
6680
6681 @node PowerPC Type Attributes
6682 @subsection PowerPC Type Attributes
6683
6684 Three attributes currently are defined for PowerPC configurations:
6685 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6686
6687 @cindex @code{ms_struct} type attribute, PowerPC
6688 @cindex @code{gcc_struct} type attribute, PowerPC
6689 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6690 attributes please see the documentation in @ref{x86 Type Attributes}.
6691
6692 @cindex @code{altivec} type attribute, PowerPC
6693 The @code{altivec} attribute allows one to declare AltiVec vector data
6694 types supported by the AltiVec Programming Interface Manual. The
6695 attribute requires an argument to specify one of three vector types:
6696 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6697 and @code{bool__} (always followed by unsigned).
6698
6699 @smallexample
6700 __attribute__((altivec(vector__)))
6701 __attribute__((altivec(pixel__))) unsigned short
6702 __attribute__((altivec(bool__))) unsigned
6703 @end smallexample
6704
6705 These attributes mainly are intended to support the @code{__vector},
6706 @code{__pixel}, and @code{__bool} AltiVec keywords.
6707
6708 @node SPU Type Attributes
6709 @subsection SPU Type Attributes
6710
6711 @cindex @code{spu_vector} type attribute, SPU
6712 The SPU supports the @code{spu_vector} attribute for types. This attribute
6713 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6714 Language Extensions Specification. It is intended to support the
6715 @code{__vector} keyword.
6716
6717 @node x86 Type Attributes
6718 @subsection x86 Type Attributes
6719
6720 Two attributes are currently defined for x86 configurations:
6721 @code{ms_struct} and @code{gcc_struct}.
6722
6723 @table @code
6724
6725 @item ms_struct
6726 @itemx gcc_struct
6727 @cindex @code{ms_struct} type attribute, x86
6728 @cindex @code{gcc_struct} type attribute, x86
6729
6730 If @code{packed} is used on a structure, or if bit-fields are used
6731 it may be that the Microsoft ABI packs them differently
6732 than GCC normally packs them. Particularly when moving packed
6733 data between functions compiled with GCC and the native Microsoft compiler
6734 (either via function call or as data in a file), it may be necessary to access
6735 either format.
6736
6737 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6738 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6739 command-line options, respectively;
6740 see @ref{x86 Options}, for details of how structure layout is affected.
6741 @xref{x86 Variable Attributes}, for information about the corresponding
6742 attributes on variables.
6743
6744 @end table
6745
6746 @node Label Attributes
6747 @section Label Attributes
6748 @cindex Label Attributes
6749
6750 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6751 details of the exact syntax for using attributes. Other attributes are
6752 available for functions (@pxref{Function Attributes}), variables
6753 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6754 and for types (@pxref{Type Attributes}).
6755
6756 This example uses the @code{cold} label attribute to indicate the
6757 @code{ErrorHandling} branch is unlikely to be taken and that the
6758 @code{ErrorHandling} label is unused:
6759
6760 @smallexample
6761
6762 asm goto ("some asm" : : : : NoError);
6763
6764 /* This branch (the fall-through from the asm) is less commonly used */
6765 ErrorHandling:
6766 __attribute__((cold, unused)); /* Semi-colon is required here */
6767 printf("error\n");
6768 return 0;
6769
6770 NoError:
6771 printf("no error\n");
6772 return 1;
6773 @end smallexample
6774
6775 @table @code
6776 @item unused
6777 @cindex @code{unused} label attribute
6778 This feature is intended for program-generated code that may contain
6779 unused labels, but which is compiled with @option{-Wall}. It is
6780 not normally appropriate to use in it human-written code, though it
6781 could be useful in cases where the code that jumps to the label is
6782 contained within an @code{#ifdef} conditional.
6783
6784 @item hot
6785 @cindex @code{hot} label attribute
6786 The @code{hot} attribute on a label is used to inform the compiler that
6787 the path following the label is more likely than paths that are not so
6788 annotated. This attribute is used in cases where @code{__builtin_expect}
6789 cannot be used, for instance with computed goto or @code{asm goto}.
6790
6791 @item cold
6792 @cindex @code{cold} label attribute
6793 The @code{cold} attribute on labels is used to inform the compiler that
6794 the path following the label is unlikely to be executed. This attribute
6795 is used in cases where @code{__builtin_expect} cannot be used, for instance
6796 with computed goto or @code{asm goto}.
6797
6798 @end table
6799
6800 @node Enumerator Attributes
6801 @section Enumerator Attributes
6802 @cindex Enumerator Attributes
6803
6804 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6805 details of the exact syntax for using attributes. Other attributes are
6806 available for functions (@pxref{Function Attributes}), variables
6807 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6808 and for types (@pxref{Type Attributes}).
6809
6810 This example uses the @code{deprecated} enumerator attribute to indicate the
6811 @code{oldval} enumerator is deprecated:
6812
6813 @smallexample
6814 enum E @{
6815 oldval __attribute__((deprecated)),
6816 newval
6817 @};
6818
6819 int
6820 fn (void)
6821 @{
6822 return oldval;
6823 @}
6824 @end smallexample
6825
6826 @table @code
6827 @item deprecated
6828 @cindex @code{deprecated} enumerator attribute
6829 The @code{deprecated} attribute results in a warning if the enumerator
6830 is used anywhere in the source file. This is useful when identifying
6831 enumerators that are expected to be removed in a future version of a
6832 program. The warning also includes the location of the declaration
6833 of the deprecated enumerator, to enable users to easily find further
6834 information about why the enumerator is deprecated, or what they should
6835 do instead. Note that the warnings only occurs for uses.
6836
6837 @end table
6838
6839 @node Attribute Syntax
6840 @section Attribute Syntax
6841 @cindex attribute syntax
6842
6843 This section describes the syntax with which @code{__attribute__} may be
6844 used, and the constructs to which attribute specifiers bind, for the C
6845 language. Some details may vary for C++ and Objective-C@. Because of
6846 infelicities in the grammar for attributes, some forms described here
6847 may not be successfully parsed in all cases.
6848
6849 There are some problems with the semantics of attributes in C++. For
6850 example, there are no manglings for attributes, although they may affect
6851 code generation, so problems may arise when attributed types are used in
6852 conjunction with templates or overloading. Similarly, @code{typeid}
6853 does not distinguish between types with different attributes. Support
6854 for attributes in C++ may be restricted in future to attributes on
6855 declarations only, but not on nested declarators.
6856
6857 @xref{Function Attributes}, for details of the semantics of attributes
6858 applying to functions. @xref{Variable Attributes}, for details of the
6859 semantics of attributes applying to variables. @xref{Type Attributes},
6860 for details of the semantics of attributes applying to structure, union
6861 and enumerated types.
6862 @xref{Label Attributes}, for details of the semantics of attributes
6863 applying to labels.
6864 @xref{Enumerator Attributes}, for details of the semantics of attributes
6865 applying to enumerators.
6866
6867 An @dfn{attribute specifier} is of the form
6868 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6869 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6870 each attribute is one of the following:
6871
6872 @itemize @bullet
6873 @item
6874 Empty. Empty attributes are ignored.
6875
6876 @item
6877 An attribute name
6878 (which may be an identifier such as @code{unused}, or a reserved
6879 word such as @code{const}).
6880
6881 @item
6882 An attribute name followed by a parenthesized list of
6883 parameters for the attribute.
6884 These parameters take one of the following forms:
6885
6886 @itemize @bullet
6887 @item
6888 An identifier. For example, @code{mode} attributes use this form.
6889
6890 @item
6891 An identifier followed by a comma and a non-empty comma-separated list
6892 of expressions. For example, @code{format} attributes use this form.
6893
6894 @item
6895 A possibly empty comma-separated list of expressions. For example,
6896 @code{format_arg} attributes use this form with the list being a single
6897 integer constant expression, and @code{alias} attributes use this form
6898 with the list being a single string constant.
6899 @end itemize
6900 @end itemize
6901
6902 An @dfn{attribute specifier list} is a sequence of one or more attribute
6903 specifiers, not separated by any other tokens.
6904
6905 You may optionally specify attribute names with @samp{__}
6906 preceding and following the name.
6907 This allows you to use them in header files without
6908 being concerned about a possible macro of the same name. For example,
6909 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6910
6911
6912 @subsubheading Label Attributes
6913
6914 In GNU C, an attribute specifier list may appear after the colon following a
6915 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6916 attributes on labels if the attribute specifier is immediately
6917 followed by a semicolon (i.e., the label applies to an empty
6918 statement). If the semicolon is missing, C++ label attributes are
6919 ambiguous, as it is permissible for a declaration, which could begin
6920 with an attribute list, to be labelled in C++. Declarations cannot be
6921 labelled in C90 or C99, so the ambiguity does not arise there.
6922
6923 @subsubheading Enumerator Attributes
6924
6925 In GNU C, an attribute specifier list may appear as part of an enumerator.
6926 The attribute goes after the enumeration constant, before @code{=}, if
6927 present. The optional attribute in the enumerator appertains to the
6928 enumeration constant. It is not possible to place the attribute after
6929 the constant expression, if present.
6930
6931 @subsubheading Type Attributes
6932
6933 An attribute specifier list may appear as part of a @code{struct},
6934 @code{union} or @code{enum} specifier. It may go either immediately
6935 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6936 the closing brace. The former syntax is preferred.
6937 Where attribute specifiers follow the closing brace, they are considered
6938 to relate to the structure, union or enumerated type defined, not to any
6939 enclosing declaration the type specifier appears in, and the type
6940 defined is not complete until after the attribute specifiers.
6941 @c Otherwise, there would be the following problems: a shift/reduce
6942 @c conflict between attributes binding the struct/union/enum and
6943 @c binding to the list of specifiers/qualifiers; and "aligned"
6944 @c attributes could use sizeof for the structure, but the size could be
6945 @c changed later by "packed" attributes.
6946
6947
6948 @subsubheading All other attributes
6949
6950 Otherwise, an attribute specifier appears as part of a declaration,
6951 counting declarations of unnamed parameters and type names, and relates
6952 to that declaration (which may be nested in another declaration, for
6953 example in the case of a parameter declaration), or to a particular declarator
6954 within a declaration. Where an
6955 attribute specifier is applied to a parameter declared as a function or
6956 an array, it should apply to the function or array rather than the
6957 pointer to which the parameter is implicitly converted, but this is not
6958 yet correctly implemented.
6959
6960 Any list of specifiers and qualifiers at the start of a declaration may
6961 contain attribute specifiers, whether or not such a list may in that
6962 context contain storage class specifiers. (Some attributes, however,
6963 are essentially in the nature of storage class specifiers, and only make
6964 sense where storage class specifiers may be used; for example,
6965 @code{section}.) There is one necessary limitation to this syntax: the
6966 first old-style parameter declaration in a function definition cannot
6967 begin with an attribute specifier, because such an attribute applies to
6968 the function instead by syntax described below (which, however, is not
6969 yet implemented in this case). In some other cases, attribute
6970 specifiers are permitted by this grammar but not yet supported by the
6971 compiler. All attribute specifiers in this place relate to the
6972 declaration as a whole. In the obsolescent usage where a type of
6973 @code{int} is implied by the absence of type specifiers, such a list of
6974 specifiers and qualifiers may be an attribute specifier list with no
6975 other specifiers or qualifiers.
6976
6977 At present, the first parameter in a function prototype must have some
6978 type specifier that is not an attribute specifier; this resolves an
6979 ambiguity in the interpretation of @code{void f(int
6980 (__attribute__((foo)) x))}, but is subject to change. At present, if
6981 the parentheses of a function declarator contain only attributes then
6982 those attributes are ignored, rather than yielding an error or warning
6983 or implying a single parameter of type int, but this is subject to
6984 change.
6985
6986 An attribute specifier list may appear immediately before a declarator
6987 (other than the first) in a comma-separated list of declarators in a
6988 declaration of more than one identifier using a single list of
6989 specifiers and qualifiers. Such attribute specifiers apply
6990 only to the identifier before whose declarator they appear. For
6991 example, in
6992
6993 @smallexample
6994 __attribute__((noreturn)) void d0 (void),
6995 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6996 d2 (void);
6997 @end smallexample
6998
6999 @noindent
7000 the @code{noreturn} attribute applies to all the functions
7001 declared; the @code{format} attribute only applies to @code{d1}.
7002
7003 An attribute specifier list may appear immediately before the comma,
7004 @code{=} or semicolon terminating the declaration of an identifier other
7005 than a function definition. Such attribute specifiers apply
7006 to the declared object or function. Where an
7007 assembler name for an object or function is specified (@pxref{Asm
7008 Labels}), the attribute must follow the @code{asm}
7009 specification.
7010
7011 An attribute specifier list may, in future, be permitted to appear after
7012 the declarator in a function definition (before any old-style parameter
7013 declarations or the function body).
7014
7015 Attribute specifiers may be mixed with type qualifiers appearing inside
7016 the @code{[]} of a parameter array declarator, in the C99 construct by
7017 which such qualifiers are applied to the pointer to which the array is
7018 implicitly converted. Such attribute specifiers apply to the pointer,
7019 not to the array, but at present this is not implemented and they are
7020 ignored.
7021
7022 An attribute specifier list may appear at the start of a nested
7023 declarator. At present, there are some limitations in this usage: the
7024 attributes correctly apply to the declarator, but for most individual
7025 attributes the semantics this implies are not implemented.
7026 When attribute specifiers follow the @code{*} of a pointer
7027 declarator, they may be mixed with any type qualifiers present.
7028 The following describes the formal semantics of this syntax. It makes the
7029 most sense if you are familiar with the formal specification of
7030 declarators in the ISO C standard.
7031
7032 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7033 D1}, where @code{T} contains declaration specifiers that specify a type
7034 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7035 contains an identifier @var{ident}. The type specified for @var{ident}
7036 for derived declarators whose type does not include an attribute
7037 specifier is as in the ISO C standard.
7038
7039 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7040 and the declaration @code{T D} specifies the type
7041 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7042 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7043 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7044
7045 If @code{D1} has the form @code{*
7046 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7047 declaration @code{T D} specifies the type
7048 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7049 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7050 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7051 @var{ident}.
7052
7053 For example,
7054
7055 @smallexample
7056 void (__attribute__((noreturn)) ****f) (void);
7057 @end smallexample
7058
7059 @noindent
7060 specifies the type ``pointer to pointer to pointer to pointer to
7061 non-returning function returning @code{void}''. As another example,
7062
7063 @smallexample
7064 char *__attribute__((aligned(8))) *f;
7065 @end smallexample
7066
7067 @noindent
7068 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7069 Note again that this does not work with most attributes; for example,
7070 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7071 is not yet supported.
7072
7073 For compatibility with existing code written for compiler versions that
7074 did not implement attributes on nested declarators, some laxity is
7075 allowed in the placing of attributes. If an attribute that only applies
7076 to types is applied to a declaration, it is treated as applying to
7077 the type of that declaration. If an attribute that only applies to
7078 declarations is applied to the type of a declaration, it is treated
7079 as applying to that declaration; and, for compatibility with code
7080 placing the attributes immediately before the identifier declared, such
7081 an attribute applied to a function return type is treated as
7082 applying to the function type, and such an attribute applied to an array
7083 element type is treated as applying to the array type. If an
7084 attribute that only applies to function types is applied to a
7085 pointer-to-function type, it is treated as applying to the pointer
7086 target type; if such an attribute is applied to a function return type
7087 that is not a pointer-to-function type, it is treated as applying
7088 to the function type.
7089
7090 @node Function Prototypes
7091 @section Prototypes and Old-Style Function Definitions
7092 @cindex function prototype declarations
7093 @cindex old-style function definitions
7094 @cindex promotion of formal parameters
7095
7096 GNU C extends ISO C to allow a function prototype to override a later
7097 old-style non-prototype definition. Consider the following example:
7098
7099 @smallexample
7100 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7101 #ifdef __STDC__
7102 #define P(x) x
7103 #else
7104 #define P(x) ()
7105 #endif
7106
7107 /* @r{Prototype function declaration.} */
7108 int isroot P((uid_t));
7109
7110 /* @r{Old-style function definition.} */
7111 int
7112 isroot (x) /* @r{??? lossage here ???} */
7113 uid_t x;
7114 @{
7115 return x == 0;
7116 @}
7117 @end smallexample
7118
7119 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7120 not allow this example, because subword arguments in old-style
7121 non-prototype definitions are promoted. Therefore in this example the
7122 function definition's argument is really an @code{int}, which does not
7123 match the prototype argument type of @code{short}.
7124
7125 This restriction of ISO C makes it hard to write code that is portable
7126 to traditional C compilers, because the programmer does not know
7127 whether the @code{uid_t} type is @code{short}, @code{int}, or
7128 @code{long}. Therefore, in cases like these GNU C allows a prototype
7129 to override a later old-style definition. More precisely, in GNU C, a
7130 function prototype argument type overrides the argument type specified
7131 by a later old-style definition if the former type is the same as the
7132 latter type before promotion. Thus in GNU C the above example is
7133 equivalent to the following:
7134
7135 @smallexample
7136 int isroot (uid_t);
7137
7138 int
7139 isroot (uid_t x)
7140 @{
7141 return x == 0;
7142 @}
7143 @end smallexample
7144
7145 @noindent
7146 GNU C++ does not support old-style function definitions, so this
7147 extension is irrelevant.
7148
7149 @node C++ Comments
7150 @section C++ Style Comments
7151 @cindex @code{//}
7152 @cindex C++ comments
7153 @cindex comments, C++ style
7154
7155 In GNU C, you may use C++ style comments, which start with @samp{//} and
7156 continue until the end of the line. Many other C implementations allow
7157 such comments, and they are included in the 1999 C standard. However,
7158 C++ style comments are not recognized if you specify an @option{-std}
7159 option specifying a version of ISO C before C99, or @option{-ansi}
7160 (equivalent to @option{-std=c90}).
7161
7162 @node Dollar Signs
7163 @section Dollar Signs in Identifier Names
7164 @cindex $
7165 @cindex dollar signs in identifier names
7166 @cindex identifier names, dollar signs in
7167
7168 In GNU C, you may normally use dollar signs in identifier names.
7169 This is because many traditional C implementations allow such identifiers.
7170 However, dollar signs in identifiers are not supported on a few target
7171 machines, typically because the target assembler does not allow them.
7172
7173 @node Character Escapes
7174 @section The Character @key{ESC} in Constants
7175
7176 You can use the sequence @samp{\e} in a string or character constant to
7177 stand for the ASCII character @key{ESC}.
7178
7179 @node Alignment
7180 @section Inquiring on Alignment of Types or Variables
7181 @cindex alignment
7182 @cindex type alignment
7183 @cindex variable alignment
7184
7185 The keyword @code{__alignof__} allows you to inquire about how an object
7186 is aligned, or the minimum alignment usually required by a type. Its
7187 syntax is just like @code{sizeof}.
7188
7189 For example, if the target machine requires a @code{double} value to be
7190 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7191 This is true on many RISC machines. On more traditional machine
7192 designs, @code{__alignof__ (double)} is 4 or even 2.
7193
7194 Some machines never actually require alignment; they allow reference to any
7195 data type even at an odd address. For these machines, @code{__alignof__}
7196 reports the smallest alignment that GCC gives the data type, usually as
7197 mandated by the target ABI.
7198
7199 If the operand of @code{__alignof__} is an lvalue rather than a type,
7200 its value is the required alignment for its type, taking into account
7201 any minimum alignment specified with GCC's @code{__attribute__}
7202 extension (@pxref{Variable Attributes}). For example, after this
7203 declaration:
7204
7205 @smallexample
7206 struct foo @{ int x; char y; @} foo1;
7207 @end smallexample
7208
7209 @noindent
7210 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7211 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7212
7213 It is an error to ask for the alignment of an incomplete type.
7214
7215
7216 @node Inline
7217 @section An Inline Function is As Fast As a Macro
7218 @cindex inline functions
7219 @cindex integrating function code
7220 @cindex open coding
7221 @cindex macros, inline alternative
7222
7223 By declaring a function inline, you can direct GCC to make
7224 calls to that function faster. One way GCC can achieve this is to
7225 integrate that function's code into the code for its callers. This
7226 makes execution faster by eliminating the function-call overhead; in
7227 addition, if any of the actual argument values are constant, their
7228 known values may permit simplifications at compile time so that not
7229 all of the inline function's code needs to be included. The effect on
7230 code size is less predictable; object code may be larger or smaller
7231 with function inlining, depending on the particular case. You can
7232 also direct GCC to try to integrate all ``simple enough'' functions
7233 into their callers with the option @option{-finline-functions}.
7234
7235 GCC implements three different semantics of declaring a function
7236 inline. One is available with @option{-std=gnu89} or
7237 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7238 on all inline declarations, another when
7239 @option{-std=c99}, @option{-std=c11},
7240 @option{-std=gnu99} or @option{-std=gnu11}
7241 (without @option{-fgnu89-inline}), and the third
7242 is used when compiling C++.
7243
7244 To declare a function inline, use the @code{inline} keyword in its
7245 declaration, like this:
7246
7247 @smallexample
7248 static inline int
7249 inc (int *a)
7250 @{
7251 return (*a)++;
7252 @}
7253 @end smallexample
7254
7255 If you are writing a header file to be included in ISO C90 programs, write
7256 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7257
7258 The three types of inlining behave similarly in two important cases:
7259 when the @code{inline} keyword is used on a @code{static} function,
7260 like the example above, and when a function is first declared without
7261 using the @code{inline} keyword and then is defined with
7262 @code{inline}, like this:
7263
7264 @smallexample
7265 extern int inc (int *a);
7266 inline int
7267 inc (int *a)
7268 @{
7269 return (*a)++;
7270 @}
7271 @end smallexample
7272
7273 In both of these common cases, the program behaves the same as if you
7274 had not used the @code{inline} keyword, except for its speed.
7275
7276 @cindex inline functions, omission of
7277 @opindex fkeep-inline-functions
7278 When a function is both inline and @code{static}, if all calls to the
7279 function are integrated into the caller, and the function's address is
7280 never used, then the function's own assembler code is never referenced.
7281 In this case, GCC does not actually output assembler code for the
7282 function, unless you specify the option @option{-fkeep-inline-functions}.
7283 If there is a nonintegrated call, then the function is compiled to
7284 assembler code as usual. The function must also be compiled as usual if
7285 the program refers to its address, because that can't be inlined.
7286
7287 @opindex Winline
7288 Note that certain usages in a function definition can make it unsuitable
7289 for inline substitution. Among these usages are: variadic functions,
7290 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7291 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7292 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7293 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7294 function marked @code{inline} could not be substituted, and gives the
7295 reason for the failure.
7296
7297 @cindex automatic @code{inline} for C++ member fns
7298 @cindex @code{inline} automatic for C++ member fns
7299 @cindex member fns, automatically @code{inline}
7300 @cindex C++ member fns, automatically @code{inline}
7301 @opindex fno-default-inline
7302 As required by ISO C++, GCC considers member functions defined within
7303 the body of a class to be marked inline even if they are
7304 not explicitly declared with the @code{inline} keyword. You can
7305 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7306 Options,,Options Controlling C++ Dialect}.
7307
7308 GCC does not inline any functions when not optimizing unless you specify
7309 the @samp{always_inline} attribute for the function, like this:
7310
7311 @smallexample
7312 /* @r{Prototype.} */
7313 inline void foo (const char) __attribute__((always_inline));
7314 @end smallexample
7315
7316 The remainder of this section is specific to GNU C90 inlining.
7317
7318 @cindex non-static inline function
7319 When an inline function is not @code{static}, then the compiler must assume
7320 that there may be calls from other source files; since a global symbol can
7321 be defined only once in any program, the function must not be defined in
7322 the other source files, so the calls therein cannot be integrated.
7323 Therefore, a non-@code{static} inline function is always compiled on its
7324 own in the usual fashion.
7325
7326 If you specify both @code{inline} and @code{extern} in the function
7327 definition, then the definition is used only for inlining. In no case
7328 is the function compiled on its own, not even if you refer to its
7329 address explicitly. Such an address becomes an external reference, as
7330 if you had only declared the function, and had not defined it.
7331
7332 This combination of @code{inline} and @code{extern} has almost the
7333 effect of a macro. The way to use it is to put a function definition in
7334 a header file with these keywords, and put another copy of the
7335 definition (lacking @code{inline} and @code{extern}) in a library file.
7336 The definition in the header file causes most calls to the function
7337 to be inlined. If any uses of the function remain, they refer to
7338 the single copy in the library.
7339
7340 @node Volatiles
7341 @section When is a Volatile Object Accessed?
7342 @cindex accessing volatiles
7343 @cindex volatile read
7344 @cindex volatile write
7345 @cindex volatile access
7346
7347 C has the concept of volatile objects. These are normally accessed by
7348 pointers and used for accessing hardware or inter-thread
7349 communication. The standard encourages compilers to refrain from
7350 optimizations concerning accesses to volatile objects, but leaves it
7351 implementation defined as to what constitutes a volatile access. The
7352 minimum requirement is that at a sequence point all previous accesses
7353 to volatile objects have stabilized and no subsequent accesses have
7354 occurred. Thus an implementation is free to reorder and combine
7355 volatile accesses that occur between sequence points, but cannot do
7356 so for accesses across a sequence point. The use of volatile does
7357 not allow you to violate the restriction on updating objects multiple
7358 times between two sequence points.
7359
7360 Accesses to non-volatile objects are not ordered with respect to
7361 volatile accesses. You cannot use a volatile object as a memory
7362 barrier to order a sequence of writes to non-volatile memory. For
7363 instance:
7364
7365 @smallexample
7366 int *ptr = @var{something};
7367 volatile int vobj;
7368 *ptr = @var{something};
7369 vobj = 1;
7370 @end smallexample
7371
7372 @noindent
7373 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7374 that the write to @var{*ptr} occurs by the time the update
7375 of @var{vobj} happens. If you need this guarantee, you must use
7376 a stronger memory barrier such as:
7377
7378 @smallexample
7379 int *ptr = @var{something};
7380 volatile int vobj;
7381 *ptr = @var{something};
7382 asm volatile ("" : : : "memory");
7383 vobj = 1;
7384 @end smallexample
7385
7386 A scalar volatile object is read when it is accessed in a void context:
7387
7388 @smallexample
7389 volatile int *src = @var{somevalue};
7390 *src;
7391 @end smallexample
7392
7393 Such expressions are rvalues, and GCC implements this as a
7394 read of the volatile object being pointed to.
7395
7396 Assignments are also expressions and have an rvalue. However when
7397 assigning to a scalar volatile, the volatile object is not reread,
7398 regardless of whether the assignment expression's rvalue is used or
7399 not. If the assignment's rvalue is used, the value is that assigned
7400 to the volatile object. For instance, there is no read of @var{vobj}
7401 in all the following cases:
7402
7403 @smallexample
7404 int obj;
7405 volatile int vobj;
7406 vobj = @var{something};
7407 obj = vobj = @var{something};
7408 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7409 obj = (@var{something}, vobj = @var{anotherthing});
7410 @end smallexample
7411
7412 If you need to read the volatile object after an assignment has
7413 occurred, you must use a separate expression with an intervening
7414 sequence point.
7415
7416 As bit-fields are not individually addressable, volatile bit-fields may
7417 be implicitly read when written to, or when adjacent bit-fields are
7418 accessed. Bit-field operations may be optimized such that adjacent
7419 bit-fields are only partially accessed, if they straddle a storage unit
7420 boundary. For these reasons it is unwise to use volatile bit-fields to
7421 access hardware.
7422
7423 @node Using Assembly Language with C
7424 @section How to Use Inline Assembly Language in C Code
7425 @cindex @code{asm} keyword
7426 @cindex assembly language in C
7427 @cindex inline assembly language
7428 @cindex mixing assembly language and C
7429
7430 The @code{asm} keyword allows you to embed assembler instructions
7431 within C code. GCC provides two forms of inline @code{asm}
7432 statements. A @dfn{basic @code{asm}} statement is one with no
7433 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7434 statement (@pxref{Extended Asm}) includes one or more operands.
7435 The extended form is preferred for mixing C and assembly language
7436 within a function, but to include assembly language at
7437 top level you must use basic @code{asm}.
7438
7439 You can also use the @code{asm} keyword to override the assembler name
7440 for a C symbol, or to place a C variable in a specific register.
7441
7442 @menu
7443 * Basic Asm:: Inline assembler without operands.
7444 * Extended Asm:: Inline assembler with operands.
7445 * Constraints:: Constraints for @code{asm} operands
7446 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7447 * Explicit Register Variables:: Defining variables residing in specified
7448 registers.
7449 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7450 @end menu
7451
7452 @node Basic Asm
7453 @subsection Basic Asm --- Assembler Instructions Without Operands
7454 @cindex basic @code{asm}
7455 @cindex assembly language in C, basic
7456
7457 A basic @code{asm} statement has the following syntax:
7458
7459 @example
7460 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7461 @end example
7462
7463 The @code{asm} keyword is a GNU extension.
7464 When writing code that can be compiled with @option{-ansi} and the
7465 various @option{-std} options, use @code{__asm__} instead of
7466 @code{asm} (@pxref{Alternate Keywords}).
7467
7468 @subsubheading Qualifiers
7469 @table @code
7470 @item volatile
7471 The optional @code{volatile} qualifier has no effect.
7472 All basic @code{asm} blocks are implicitly volatile.
7473 @end table
7474
7475 @subsubheading Parameters
7476 @table @var
7477
7478 @item AssemblerInstructions
7479 This is a literal string that specifies the assembler code. The string can
7480 contain any instructions recognized by the assembler, including directives.
7481 GCC does not parse the assembler instructions themselves and
7482 does not know what they mean or even whether they are valid assembler input.
7483
7484 You may place multiple assembler instructions together in a single @code{asm}
7485 string, separated by the characters normally used in assembly code for the
7486 system. A combination that works in most places is a newline to break the
7487 line, plus a tab character (written as @samp{\n\t}).
7488 Some assemblers allow semicolons as a line separator. However,
7489 note that some assembler dialects use semicolons to start a comment.
7490 @end table
7491
7492 @subsubheading Remarks
7493 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
7494 smaller, safer, and more efficient code, and in most cases it is a
7495 better solution than basic @code{asm}. However, there are two
7496 situations where only basic @code{asm} can be used:
7497
7498 @itemize @bullet
7499 @item
7500 Extended @code{asm} statements have to be inside a C
7501 function, so to write inline assembly language at file scope (``top-level''),
7502 outside of C functions, you must use basic @code{asm}.
7503 You can use this technique to emit assembler directives,
7504 define assembly language macros that can be invoked elsewhere in the file,
7505 or write entire functions in assembly language.
7506
7507 @item
7508 Functions declared
7509 with the @code{naked} attribute also require basic @code{asm}
7510 (@pxref{Function Attributes}).
7511 @end itemize
7512
7513 Safely accessing C data and calling functions from basic @code{asm} is more
7514 complex than it may appear. To access C data, it is better to use extended
7515 @code{asm}.
7516
7517 Do not expect a sequence of @code{asm} statements to remain perfectly
7518 consecutive after compilation. If certain instructions need to remain
7519 consecutive in the output, put them in a single multi-instruction @code{asm}
7520 statement. Note that GCC's optimizers can move @code{asm} statements
7521 relative to other code, including across jumps.
7522
7523 @code{asm} statements may not perform jumps into other @code{asm} statements.
7524 GCC does not know about these jumps, and therefore cannot take
7525 account of them when deciding how to optimize. Jumps from @code{asm} to C
7526 labels are only supported in extended @code{asm}.
7527
7528 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7529 assembly code when optimizing. This can lead to unexpected duplicate
7530 symbol errors during compilation if your assembly code defines symbols or
7531 labels.
7532
7533 @strong{Warning:} The C standards do not specify semantics for @code{asm},
7534 making it a potential source of incompatibilities between compilers. These
7535 incompatibilities may not produce compiler warnings/errors.
7536
7537 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
7538 means there is no way to communicate to the compiler what is happening
7539 inside them. GCC has no visibility of symbols in the @code{asm} and may
7540 discard them as unreferenced. It also does not know about side effects of
7541 the assembler code, such as modifications to memory or registers. Unlike
7542 some compilers, GCC assumes that no changes to either memory or registers
7543 occur. This assumption may change in a future release.
7544
7545 To avoid complications from future changes to the semantics and the
7546 compatibility issues between compilers, consider replacing basic @code{asm}
7547 with extended @code{asm}. See
7548 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
7549 from basic asm to extended asm} for information about how to perform this
7550 conversion.
7551
7552 The compiler copies the assembler instructions in a basic @code{asm}
7553 verbatim to the assembly language output file, without
7554 processing dialects or any of the @samp{%} operators that are available with
7555 extended @code{asm}. This results in minor differences between basic
7556 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7557 registers you might use @samp{%eax} in basic @code{asm} and
7558 @samp{%%eax} in extended @code{asm}.
7559
7560 On targets such as x86 that support multiple assembler dialects,
7561 all basic @code{asm} blocks use the assembler dialect specified by the
7562 @option{-masm} command-line option (@pxref{x86 Options}).
7563 Basic @code{asm} provides no
7564 mechanism to provide different assembler strings for different dialects.
7565
7566 Here is an example of basic @code{asm} for i386:
7567
7568 @example
7569 /* Note that this code will not compile with -masm=intel */
7570 #define DebugBreak() asm("int $3")
7571 @end example
7572
7573 @node Extended Asm
7574 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7575 @cindex extended @code{asm}
7576 @cindex assembly language in C, extended
7577
7578 With extended @code{asm} you can read and write C variables from
7579 assembler and perform jumps from assembler code to C labels.
7580 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7581 the operand parameters after the assembler template:
7582
7583 @example
7584 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7585 : @var{OutputOperands}
7586 @r{[} : @var{InputOperands}
7587 @r{[} : @var{Clobbers} @r{]} @r{]})
7588
7589 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7590 :
7591 : @var{InputOperands}
7592 : @var{Clobbers}
7593 : @var{GotoLabels})
7594 @end example
7595
7596 The @code{asm} keyword is a GNU extension.
7597 When writing code that can be compiled with @option{-ansi} and the
7598 various @option{-std} options, use @code{__asm__} instead of
7599 @code{asm} (@pxref{Alternate Keywords}).
7600
7601 @subsubheading Qualifiers
7602 @table @code
7603
7604 @item volatile
7605 The typical use of extended @code{asm} statements is to manipulate input
7606 values to produce output values. However, your @code{asm} statements may
7607 also produce side effects. If so, you may need to use the @code{volatile}
7608 qualifier to disable certain optimizations. @xref{Volatile}.
7609
7610 @item goto
7611 This qualifier informs the compiler that the @code{asm} statement may
7612 perform a jump to one of the labels listed in the @var{GotoLabels}.
7613 @xref{GotoLabels}.
7614 @end table
7615
7616 @subsubheading Parameters
7617 @table @var
7618 @item AssemblerTemplate
7619 This is a literal string that is the template for the assembler code. It is a
7620 combination of fixed text and tokens that refer to the input, output,
7621 and goto parameters. @xref{AssemblerTemplate}.
7622
7623 @item OutputOperands
7624 A comma-separated list of the C variables modified by the instructions in the
7625 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7626
7627 @item InputOperands
7628 A comma-separated list of C expressions read by the instructions in the
7629 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7630
7631 @item Clobbers
7632 A comma-separated list of registers or other values changed by the
7633 @var{AssemblerTemplate}, beyond those listed as outputs.
7634 An empty list is permitted. @xref{Clobbers}.
7635
7636 @item GotoLabels
7637 When you are using the @code{goto} form of @code{asm}, this section contains
7638 the list of all C labels to which the code in the
7639 @var{AssemblerTemplate} may jump.
7640 @xref{GotoLabels}.
7641
7642 @code{asm} statements may not perform jumps into other @code{asm} statements,
7643 only to the listed @var{GotoLabels}.
7644 GCC's optimizers do not know about other jumps; therefore they cannot take
7645 account of them when deciding how to optimize.
7646 @end table
7647
7648 The total number of input + output + goto operands is limited to 30.
7649
7650 @subsubheading Remarks
7651 The @code{asm} statement allows you to include assembly instructions directly
7652 within C code. This may help you to maximize performance in time-sensitive
7653 code or to access assembly instructions that are not readily available to C
7654 programs.
7655
7656 Note that extended @code{asm} statements must be inside a function. Only
7657 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7658 Functions declared with the @code{naked} attribute also require basic
7659 @code{asm} (@pxref{Function Attributes}).
7660
7661 While the uses of @code{asm} are many and varied, it may help to think of an
7662 @code{asm} statement as a series of low-level instructions that convert input
7663 parameters to output parameters. So a simple (if not particularly useful)
7664 example for i386 using @code{asm} might look like this:
7665
7666 @example
7667 int src = 1;
7668 int dst;
7669
7670 asm ("mov %1, %0\n\t"
7671 "add $1, %0"
7672 : "=r" (dst)
7673 : "r" (src));
7674
7675 printf("%d\n", dst);
7676 @end example
7677
7678 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7679
7680 @anchor{Volatile}
7681 @subsubsection Volatile
7682 @cindex volatile @code{asm}
7683 @cindex @code{asm} volatile
7684
7685 GCC's optimizers sometimes discard @code{asm} statements if they determine
7686 there is no need for the output variables. Also, the optimizers may move
7687 code out of loops if they believe that the code will always return the same
7688 result (i.e. none of its input values change between calls). Using the
7689 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7690 that have no output operands, including @code{asm goto} statements,
7691 are implicitly volatile.
7692
7693 This i386 code demonstrates a case that does not use (or require) the
7694 @code{volatile} qualifier. If it is performing assertion checking, this code
7695 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7696 unreferenced by any code. As a result, the optimizers can discard the
7697 @code{asm} statement, which in turn removes the need for the entire
7698 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7699 isn't needed you allow the optimizers to produce the most efficient code
7700 possible.
7701
7702 @example
7703 void DoCheck(uint32_t dwSomeValue)
7704 @{
7705 uint32_t dwRes;
7706
7707 // Assumes dwSomeValue is not zero.
7708 asm ("bsfl %1,%0"
7709 : "=r" (dwRes)
7710 : "r" (dwSomeValue)
7711 : "cc");
7712
7713 assert(dwRes > 3);
7714 @}
7715 @end example
7716
7717 The next example shows a case where the optimizers can recognize that the input
7718 (@code{dwSomeValue}) never changes during the execution of the function and can
7719 therefore move the @code{asm} outside the loop to produce more efficient code.
7720 Again, using @code{volatile} disables this type of optimization.
7721
7722 @example
7723 void do_print(uint32_t dwSomeValue)
7724 @{
7725 uint32_t dwRes;
7726
7727 for (uint32_t x=0; x < 5; x++)
7728 @{
7729 // Assumes dwSomeValue is not zero.
7730 asm ("bsfl %1,%0"
7731 : "=r" (dwRes)
7732 : "r" (dwSomeValue)
7733 : "cc");
7734
7735 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7736 @}
7737 @}
7738 @end example
7739
7740 The following example demonstrates a case where you need to use the
7741 @code{volatile} qualifier.
7742 It uses the x86 @code{rdtsc} instruction, which reads
7743 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7744 the optimizers might assume that the @code{asm} block will always return the
7745 same value and therefore optimize away the second call.
7746
7747 @example
7748 uint64_t msr;
7749
7750 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7751 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7752 "or %%rdx, %0" // 'Or' in the lower bits.
7753 : "=a" (msr)
7754 :
7755 : "rdx");
7756
7757 printf("msr: %llx\n", msr);
7758
7759 // Do other work...
7760
7761 // Reprint the timestamp
7762 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7763 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7764 "or %%rdx, %0" // 'Or' in the lower bits.
7765 : "=a" (msr)
7766 :
7767 : "rdx");
7768
7769 printf("msr: %llx\n", msr);
7770 @end example
7771
7772 GCC's optimizers do not treat this code like the non-volatile code in the
7773 earlier examples. They do not move it out of loops or omit it on the
7774 assumption that the result from a previous call is still valid.
7775
7776 Note that the compiler can move even volatile @code{asm} instructions relative
7777 to other code, including across jump instructions. For example, on many
7778 targets there is a system register that controls the rounding mode of
7779 floating-point operations. Setting it with a volatile @code{asm}, as in the
7780 following PowerPC example, does not work reliably.
7781
7782 @example
7783 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7784 sum = x + y;
7785 @end example
7786
7787 The compiler may move the addition back before the volatile @code{asm}. To
7788 make it work as expected, add an artificial dependency to the @code{asm} by
7789 referencing a variable in the subsequent code, for example:
7790
7791 @example
7792 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7793 sum = x + y;
7794 @end example
7795
7796 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7797 assembly code when optimizing. This can lead to unexpected duplicate symbol
7798 errors during compilation if your asm code defines symbols or labels.
7799 Using @samp{%=}
7800 (@pxref{AssemblerTemplate}) may help resolve this problem.
7801
7802 @anchor{AssemblerTemplate}
7803 @subsubsection Assembler Template
7804 @cindex @code{asm} assembler template
7805
7806 An assembler template is a literal string containing assembler instructions.
7807 The compiler replaces tokens in the template that refer
7808 to inputs, outputs, and goto labels,
7809 and then outputs the resulting string to the assembler. The
7810 string can contain any instructions recognized by the assembler, including
7811 directives. GCC does not parse the assembler instructions
7812 themselves and does not know what they mean or even whether they are valid
7813 assembler input. However, it does count the statements
7814 (@pxref{Size of an asm}).
7815
7816 You may place multiple assembler instructions together in a single @code{asm}
7817 string, separated by the characters normally used in assembly code for the
7818 system. A combination that works in most places is a newline to break the
7819 line, plus a tab character to move to the instruction field (written as
7820 @samp{\n\t}).
7821 Some assemblers allow semicolons as a line separator. However, note
7822 that some assembler dialects use semicolons to start a comment.
7823
7824 Do not expect a sequence of @code{asm} statements to remain perfectly
7825 consecutive after compilation, even when you are using the @code{volatile}
7826 qualifier. If certain instructions need to remain consecutive in the output,
7827 put them in a single multi-instruction asm statement.
7828
7829 Accessing data from C programs without using input/output operands (such as
7830 by using global symbols directly from the assembler template) may not work as
7831 expected. Similarly, calling functions directly from an assembler template
7832 requires a detailed understanding of the target assembler and ABI.
7833
7834 Since GCC does not parse the assembler template,
7835 it has no visibility of any
7836 symbols it references. This may result in GCC discarding those symbols as
7837 unreferenced unless they are also listed as input, output, or goto operands.
7838
7839 @subsubheading Special format strings
7840
7841 In addition to the tokens described by the input, output, and goto operands,
7842 these tokens have special meanings in the assembler template:
7843
7844 @table @samp
7845 @item %%
7846 Outputs a single @samp{%} into the assembler code.
7847
7848 @item %=
7849 Outputs a number that is unique to each instance of the @code{asm}
7850 statement in the entire compilation. This option is useful when creating local
7851 labels and referring to them multiple times in a single template that
7852 generates multiple assembler instructions.
7853
7854 @item %@{
7855 @itemx %|
7856 @itemx %@}
7857 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7858 into the assembler code. When unescaped, these characters have special
7859 meaning to indicate multiple assembler dialects, as described below.
7860 @end table
7861
7862 @subsubheading Multiple assembler dialects in @code{asm} templates
7863
7864 On targets such as x86, GCC supports multiple assembler dialects.
7865 The @option{-masm} option controls which dialect GCC uses as its
7866 default for inline assembler. The target-specific documentation for the
7867 @option{-masm} option contains the list of supported dialects, as well as the
7868 default dialect if the option is not specified. This information may be
7869 important to understand, since assembler code that works correctly when
7870 compiled using one dialect will likely fail if compiled using another.
7871 @xref{x86 Options}.
7872
7873 If your code needs to support multiple assembler dialects (for example, if
7874 you are writing public headers that need to support a variety of compilation
7875 options), use constructs of this form:
7876
7877 @example
7878 @{ dialect0 | dialect1 | dialect2... @}
7879 @end example
7880
7881 This construct outputs @code{dialect0}
7882 when using dialect #0 to compile the code,
7883 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7884 braces than the number of dialects the compiler supports, the construct
7885 outputs nothing.
7886
7887 For example, if an x86 compiler supports two dialects
7888 (@samp{att}, @samp{intel}), an
7889 assembler template such as this:
7890
7891 @example
7892 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7893 @end example
7894
7895 @noindent
7896 is equivalent to one of
7897
7898 @example
7899 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7900 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7901 @end example
7902
7903 Using that same compiler, this code:
7904
7905 @example
7906 "xchg@{l@}\t@{%%@}ebx, %1"
7907 @end example
7908
7909 @noindent
7910 corresponds to either
7911
7912 @example
7913 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7914 "xchg\tebx, %1" @r{/* intel dialect */}
7915 @end example
7916
7917 There is no support for nesting dialect alternatives.
7918
7919 @anchor{OutputOperands}
7920 @subsubsection Output Operands
7921 @cindex @code{asm} output operands
7922
7923 An @code{asm} statement has zero or more output operands indicating the names
7924 of C variables modified by the assembler code.
7925
7926 In this i386 example, @code{old} (referred to in the template string as
7927 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7928 (@code{%2}) is an input:
7929
7930 @example
7931 bool old;
7932
7933 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7934 "sbb %0,%0" // Use the CF to calculate old.
7935 : "=r" (old), "+rm" (*Base)
7936 : "Ir" (Offset)
7937 : "cc");
7938
7939 return old;
7940 @end example
7941
7942 Operands are separated by commas. Each operand has this format:
7943
7944 @example
7945 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7946 @end example
7947
7948 @table @var
7949 @item asmSymbolicName
7950 Specifies a symbolic name for the operand.
7951 Reference the name in the assembler template
7952 by enclosing it in square brackets
7953 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7954 that contains the definition. Any valid C variable name is acceptable,
7955 including names already defined in the surrounding code. No two operands
7956 within the same @code{asm} statement can use the same symbolic name.
7957
7958 When not using an @var{asmSymbolicName}, use the (zero-based) position
7959 of the operand
7960 in the list of operands in the assembler template. For example if there are
7961 three output operands, use @samp{%0} in the template to refer to the first,
7962 @samp{%1} for the second, and @samp{%2} for the third.
7963
7964 @item constraint
7965 A string constant specifying constraints on the placement of the operand;
7966 @xref{Constraints}, for details.
7967
7968 Output constraints must begin with either @samp{=} (a variable overwriting an
7969 existing value) or @samp{+} (when reading and writing). When using
7970 @samp{=}, do not assume the location contains the existing value
7971 on entry to the @code{asm}, except
7972 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7973
7974 After the prefix, there must be one or more additional constraints
7975 (@pxref{Constraints}) that describe where the value resides. Common
7976 constraints include @samp{r} for register and @samp{m} for memory.
7977 When you list more than one possible location (for example, @code{"=rm"}),
7978 the compiler chooses the most efficient one based on the current context.
7979 If you list as many alternates as the @code{asm} statement allows, you permit
7980 the optimizers to produce the best possible code.
7981 If you must use a specific register, but your Machine Constraints do not
7982 provide sufficient control to select the specific register you want,
7983 local register variables may provide a solution (@pxref{Local Register
7984 Variables}).
7985
7986 @item cvariablename
7987 Specifies a C lvalue expression to hold the output, typically a variable name.
7988 The enclosing parentheses are a required part of the syntax.
7989
7990 @end table
7991
7992 When the compiler selects the registers to use to
7993 represent the output operands, it does not use any of the clobbered registers
7994 (@pxref{Clobbers}).
7995
7996 Output operand expressions must be lvalues. The compiler cannot check whether
7997 the operands have data types that are reasonable for the instruction being
7998 executed. For output expressions that are not directly addressable (for
7999 example a bit-field), the constraint must allow a register. In that case, GCC
8000 uses the register as the output of the @code{asm}, and then stores that
8001 register into the output.
8002
8003 Operands using the @samp{+} constraint modifier count as two operands
8004 (that is, both as input and output) towards the total maximum of 30 operands
8005 per @code{asm} statement.
8006
8007 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8008 operands that must not overlap an input. Otherwise,
8009 GCC may allocate the output operand in the same register as an unrelated
8010 input operand, on the assumption that the assembler code consumes its
8011 inputs before producing outputs. This assumption may be false if the assembler
8012 code actually consists of more than one instruction.
8013
8014 The same problem can occur if one output parameter (@var{a}) allows a register
8015 constraint and another output parameter (@var{b}) allows a memory constraint.
8016 The code generated by GCC to access the memory address in @var{b} can contain
8017 registers which @emph{might} be shared by @var{a}, and GCC considers those
8018 registers to be inputs to the asm. As above, GCC assumes that such input
8019 registers are consumed before any outputs are written. This assumption may
8020 result in incorrect behavior if the asm writes to @var{a} before using
8021 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8022 ensures that modifying @var{a} does not affect the address referenced by
8023 @var{b}. Otherwise, the location of @var{b}
8024 is undefined if @var{a} is modified before using @var{b}.
8025
8026 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8027 instead of simply @samp{%2}). Typically these qualifiers are hardware
8028 dependent. The list of supported modifiers for x86 is found at
8029 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8030
8031 If the C code that follows the @code{asm} makes no use of any of the output
8032 operands, use @code{volatile} for the @code{asm} statement to prevent the
8033 optimizers from discarding the @code{asm} statement as unneeded
8034 (see @ref{Volatile}).
8035
8036 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8037 references the first output operand as @code{%0} (were there a second, it
8038 would be @code{%1}, etc). The number of the first input operand is one greater
8039 than that of the last output operand. In this i386 example, that makes
8040 @code{Mask} referenced as @code{%1}:
8041
8042 @example
8043 uint32_t Mask = 1234;
8044 uint32_t Index;
8045
8046 asm ("bsfl %1, %0"
8047 : "=r" (Index)
8048 : "r" (Mask)
8049 : "cc");
8050 @end example
8051
8052 That code overwrites the variable @code{Index} (@samp{=}),
8053 placing the value in a register (@samp{r}).
8054 Using the generic @samp{r} constraint instead of a constraint for a specific
8055 register allows the compiler to pick the register to use, which can result
8056 in more efficient code. This may not be possible if an assembler instruction
8057 requires a specific register.
8058
8059 The following i386 example uses the @var{asmSymbolicName} syntax.
8060 It produces the
8061 same result as the code above, but some may consider it more readable or more
8062 maintainable since reordering index numbers is not necessary when adding or
8063 removing operands. The names @code{aIndex} and @code{aMask}
8064 are only used in this example to emphasize which
8065 names get used where.
8066 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8067
8068 @example
8069 uint32_t Mask = 1234;
8070 uint32_t Index;
8071
8072 asm ("bsfl %[aMask], %[aIndex]"
8073 : [aIndex] "=r" (Index)
8074 : [aMask] "r" (Mask)
8075 : "cc");
8076 @end example
8077
8078 Here are some more examples of output operands.
8079
8080 @example
8081 uint32_t c = 1;
8082 uint32_t d;
8083 uint32_t *e = &c;
8084
8085 asm ("mov %[e], %[d]"
8086 : [d] "=rm" (d)
8087 : [e] "rm" (*e));
8088 @end example
8089
8090 Here, @code{d} may either be in a register or in memory. Since the compiler
8091 might already have the current value of the @code{uint32_t} location
8092 pointed to by @code{e}
8093 in a register, you can enable it to choose the best location
8094 for @code{d} by specifying both constraints.
8095
8096 @anchor{FlagOutputOperands}
8097 @subsubsection Flag Output Operands
8098 @cindex @code{asm} flag output operands
8099
8100 Some targets have a special register that holds the ``flags'' for the
8101 result of an operation or comparison. Normally, the contents of that
8102 register are either unmodifed by the asm, or the asm is considered to
8103 clobber the contents.
8104
8105 On some targets, a special form of output operand exists by which
8106 conditions in the flags register may be outputs of the asm. The set of
8107 conditions supported are target specific, but the general rule is that
8108 the output variable must be a scalar integer, and the value is boolean.
8109 When supported, the target defines the preprocessor symbol
8110 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8111
8112 Because of the special nature of the flag output operands, the constraint
8113 may not include alternatives.
8114
8115 Most often, the target has only one flags register, and thus is an implied
8116 operand of many instructions. In this case, the operand should not be
8117 referenced within the assembler template via @code{%0} etc, as there's
8118 no corresponding text in the assembly language.
8119
8120 @table @asis
8121 @item x86 family
8122 The flag output constraints for the x86 family are of the form
8123 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8124 conditions defined in the ISA manual for @code{j@var{cc}} or
8125 @code{set@var{cc}}.
8126
8127 @table @code
8128 @item a
8129 ``above'' or unsigned greater than
8130 @item ae
8131 ``above or equal'' or unsigned greater than or equal
8132 @item b
8133 ``below'' or unsigned less than
8134 @item be
8135 ``below or equal'' or unsigned less than or equal
8136 @item c
8137 carry flag set
8138 @item e
8139 @itemx z
8140 ``equal'' or zero flag set
8141 @item g
8142 signed greater than
8143 @item ge
8144 signed greater than or equal
8145 @item l
8146 signed less than
8147 @item le
8148 signed less than or equal
8149 @item o
8150 overflow flag set
8151 @item p
8152 parity flag set
8153 @item s
8154 sign flag set
8155 @item na
8156 @itemx nae
8157 @itemx nb
8158 @itemx nbe
8159 @itemx nc
8160 @itemx ne
8161 @itemx ng
8162 @itemx nge
8163 @itemx nl
8164 @itemx nle
8165 @itemx no
8166 @itemx np
8167 @itemx ns
8168 @itemx nz
8169 ``not'' @var{flag}, or inverted versions of those above
8170 @end table
8171
8172 @end table
8173
8174 @anchor{InputOperands}
8175 @subsubsection Input Operands
8176 @cindex @code{asm} input operands
8177 @cindex @code{asm} expressions
8178
8179 Input operands make values from C variables and expressions available to the
8180 assembly code.
8181
8182 Operands are separated by commas. Each operand has this format:
8183
8184 @example
8185 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8186 @end example
8187
8188 @table @var
8189 @item asmSymbolicName
8190 Specifies a symbolic name for the operand.
8191 Reference the name in the assembler template
8192 by enclosing it in square brackets
8193 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8194 that contains the definition. Any valid C variable name is acceptable,
8195 including names already defined in the surrounding code. No two operands
8196 within the same @code{asm} statement can use the same symbolic name.
8197
8198 When not using an @var{asmSymbolicName}, use the (zero-based) position
8199 of the operand
8200 in the list of operands in the assembler template. For example if there are
8201 two output operands and three inputs,
8202 use @samp{%2} in the template to refer to the first input operand,
8203 @samp{%3} for the second, and @samp{%4} for the third.
8204
8205 @item constraint
8206 A string constant specifying constraints on the placement of the operand;
8207 @xref{Constraints}, for details.
8208
8209 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8210 When you list more than one possible location (for example, @samp{"irm"}),
8211 the compiler chooses the most efficient one based on the current context.
8212 If you must use a specific register, but your Machine Constraints do not
8213 provide sufficient control to select the specific register you want,
8214 local register variables may provide a solution (@pxref{Local Register
8215 Variables}).
8216
8217 Input constraints can also be digits (for example, @code{"0"}). This indicates
8218 that the specified input must be in the same place as the output constraint
8219 at the (zero-based) index in the output constraint list.
8220 When using @var{asmSymbolicName} syntax for the output operands,
8221 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8222
8223 @item cexpression
8224 This is the C variable or expression being passed to the @code{asm} statement
8225 as input. The enclosing parentheses are a required part of the syntax.
8226
8227 @end table
8228
8229 When the compiler selects the registers to use to represent the input
8230 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8231
8232 If there are no output operands but there are input operands, place two
8233 consecutive colons where the output operands would go:
8234
8235 @example
8236 __asm__ ("some instructions"
8237 : /* No outputs. */
8238 : "r" (Offset / 8));
8239 @end example
8240
8241 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8242 (except for inputs tied to outputs). The compiler assumes that on exit from
8243 the @code{asm} statement these operands contain the same values as they
8244 had before executing the statement.
8245 It is @emph{not} possible to use clobbers
8246 to inform the compiler that the values in these inputs are changing. One
8247 common work-around is to tie the changing input variable to an output variable
8248 that never gets used. Note, however, that if the code that follows the
8249 @code{asm} statement makes no use of any of the output operands, the GCC
8250 optimizers may discard the @code{asm} statement as unneeded
8251 (see @ref{Volatile}).
8252
8253 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8254 instead of simply @samp{%2}). Typically these qualifiers are hardware
8255 dependent. The list of supported modifiers for x86 is found at
8256 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8257
8258 In this example using the fictitious @code{combine} instruction, the
8259 constraint @code{"0"} for input operand 1 says that it must occupy the same
8260 location as output operand 0. Only input operands may use numbers in
8261 constraints, and they must each refer to an output operand. Only a number (or
8262 the symbolic assembler name) in the constraint can guarantee that one operand
8263 is in the same place as another. The mere fact that @code{foo} is the value of
8264 both operands is not enough to guarantee that they are in the same place in
8265 the generated assembler code.
8266
8267 @example
8268 asm ("combine %2, %0"
8269 : "=r" (foo)
8270 : "0" (foo), "g" (bar));
8271 @end example
8272
8273 Here is an example using symbolic names.
8274
8275 @example
8276 asm ("cmoveq %1, %2, %[result]"
8277 : [result] "=r"(result)
8278 : "r" (test), "r" (new), "[result]" (old));
8279 @end example
8280
8281 @anchor{Clobbers}
8282 @subsubsection Clobbers
8283 @cindex @code{asm} clobbers
8284
8285 While the compiler is aware of changes to entries listed in the output
8286 operands, the inline @code{asm} code may modify more than just the outputs. For
8287 example, calculations may require additional registers, or the processor may
8288 overwrite a register as a side effect of a particular assembler instruction.
8289 In order to inform the compiler of these changes, list them in the clobber
8290 list. Clobber list items are either register names or the special clobbers
8291 (listed below). Each clobber list item is a string constant
8292 enclosed in double quotes and separated by commas.
8293
8294 Clobber descriptions may not in any way overlap with an input or output
8295 operand. For example, you may not have an operand describing a register class
8296 with one member when listing that register in the clobber list. Variables
8297 declared to live in specific registers (@pxref{Explicit Register
8298 Variables}) and used
8299 as @code{asm} input or output operands must have no part mentioned in the
8300 clobber description. In particular, there is no way to specify that input
8301 operands get modified without also specifying them as output operands.
8302
8303 When the compiler selects which registers to use to represent input and output
8304 operands, it does not use any of the clobbered registers. As a result,
8305 clobbered registers are available for any use in the assembler code.
8306
8307 Here is a realistic example for the VAX showing the use of clobbered
8308 registers:
8309
8310 @example
8311 asm volatile ("movc3 %0, %1, %2"
8312 : /* No outputs. */
8313 : "g" (from), "g" (to), "g" (count)
8314 : "r0", "r1", "r2", "r3", "r4", "r5");
8315 @end example
8316
8317 Also, there are two special clobber arguments:
8318
8319 @table @code
8320 @item "cc"
8321 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8322 register. On some machines, GCC represents the condition codes as a specific
8323 hardware register; @code{"cc"} serves to name this register.
8324 On other machines, condition code handling is different,
8325 and specifying @code{"cc"} has no effect. But
8326 it is valid no matter what the target.
8327
8328 @item "memory"
8329 The @code{"memory"} clobber tells the compiler that the assembly code
8330 performs memory
8331 reads or writes to items other than those listed in the input and output
8332 operands (for example, accessing the memory pointed to by one of the input
8333 parameters). To ensure memory contains correct values, GCC may need to flush
8334 specific register values to memory before executing the @code{asm}. Further,
8335 the compiler does not assume that any values read from memory before an
8336 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8337 needed.
8338 Using the @code{"memory"} clobber effectively forms a read/write
8339 memory barrier for the compiler.
8340
8341 Note that this clobber does not prevent the @emph{processor} from doing
8342 speculative reads past the @code{asm} statement. To prevent that, you need
8343 processor-specific fence instructions.
8344
8345 Flushing registers to memory has performance implications and may be an issue
8346 for time-sensitive code. You can use a trick to avoid this if the size of
8347 the memory being accessed is known at compile time. For example, if accessing
8348 ten bytes of a string, use a memory input like:
8349
8350 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8351
8352 @end table
8353
8354 @anchor{GotoLabels}
8355 @subsubsection Goto Labels
8356 @cindex @code{asm} goto labels
8357
8358 @code{asm goto} allows assembly code to jump to one or more C labels. The
8359 @var{GotoLabels} section in an @code{asm goto} statement contains
8360 a comma-separated
8361 list of all C labels to which the assembler code may jump. GCC assumes that
8362 @code{asm} execution falls through to the next statement (if this is not the
8363 case, consider using the @code{__builtin_unreachable} intrinsic after the
8364 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8365 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8366 Attributes}).
8367
8368 An @code{asm goto} statement cannot have outputs.
8369 This is due to an internal restriction of
8370 the compiler: control transfer instructions cannot have outputs.
8371 If the assembler code does modify anything, use the @code{"memory"} clobber
8372 to force the
8373 optimizers to flush all register values to memory and reload them if
8374 necessary after the @code{asm} statement.
8375
8376 Also note that an @code{asm goto} statement is always implicitly
8377 considered volatile.
8378
8379 To reference a label in the assembler template,
8380 prefix it with @samp{%l} (lowercase @samp{L}) followed
8381 by its (zero-based) position in @var{GotoLabels} plus the number of input
8382 operands. For example, if the @code{asm} has three inputs and references two
8383 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8384
8385 Alternately, you can reference labels using the actual C label name enclosed
8386 in brackets. For example, to reference a label named @code{carry}, you can
8387 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8388 section when using this approach.
8389
8390 Here is an example of @code{asm goto} for i386:
8391
8392 @example
8393 asm goto (
8394 "btl %1, %0\n\t"
8395 "jc %l2"
8396 : /* No outputs. */
8397 : "r" (p1), "r" (p2)
8398 : "cc"
8399 : carry);
8400
8401 return 0;
8402
8403 carry:
8404 return 1;
8405 @end example
8406
8407 The following example shows an @code{asm goto} that uses a memory clobber.
8408
8409 @example
8410 int frob(int x)
8411 @{
8412 int y;
8413 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8414 : /* No outputs. */
8415 : "r"(x), "r"(&y)
8416 : "r5", "memory"
8417 : error);
8418 return y;
8419 error:
8420 return -1;
8421 @}
8422 @end example
8423
8424 @anchor{x86Operandmodifiers}
8425 @subsubsection x86 Operand Modifiers
8426
8427 References to input, output, and goto operands in the assembler template
8428 of extended @code{asm} statements can use
8429 modifiers to affect the way the operands are formatted in
8430 the code output to the assembler. For example, the
8431 following code uses the @samp{h} and @samp{b} modifiers for x86:
8432
8433 @example
8434 uint16_t num;
8435 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8436 @end example
8437
8438 @noindent
8439 These modifiers generate this assembler code:
8440
8441 @example
8442 xchg %ah, %al
8443 @end example
8444
8445 The rest of this discussion uses the following code for illustrative purposes.
8446
8447 @example
8448 int main()
8449 @{
8450 int iInt = 1;
8451
8452 top:
8453
8454 asm volatile goto ("some assembler instructions here"
8455 : /* No outputs. */
8456 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8457 : /* No clobbers. */
8458 : top);
8459 @}
8460 @end example
8461
8462 With no modifiers, this is what the output from the operands would be for the
8463 @samp{att} and @samp{intel} dialects of assembler:
8464
8465 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8466 @headitem Operand @tab masm=att @tab masm=intel
8467 @item @code{%0}
8468 @tab @code{%eax}
8469 @tab @code{eax}
8470 @item @code{%1}
8471 @tab @code{$2}
8472 @tab @code{2}
8473 @item @code{%2}
8474 @tab @code{$.L2}
8475 @tab @code{OFFSET FLAT:.L2}
8476 @end multitable
8477
8478 The table below shows the list of supported modifiers and their effects.
8479
8480 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8481 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8482 @item @code{z}
8483 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8484 @tab @code{%z0}
8485 @tab @code{l}
8486 @tab
8487 @item @code{b}
8488 @tab Print the QImode name of the register.
8489 @tab @code{%b0}
8490 @tab @code{%al}
8491 @tab @code{al}
8492 @item @code{h}
8493 @tab Print the QImode name for a ``high'' register.
8494 @tab @code{%h0}
8495 @tab @code{%ah}
8496 @tab @code{ah}
8497 @item @code{w}
8498 @tab Print the HImode name of the register.
8499 @tab @code{%w0}
8500 @tab @code{%ax}
8501 @tab @code{ax}
8502 @item @code{k}
8503 @tab Print the SImode name of the register.
8504 @tab @code{%k0}
8505 @tab @code{%eax}
8506 @tab @code{eax}
8507 @item @code{q}
8508 @tab Print the DImode name of the register.
8509 @tab @code{%q0}
8510 @tab @code{%rax}
8511 @tab @code{rax}
8512 @item @code{l}
8513 @tab Print the label name with no punctuation.
8514 @tab @code{%l2}
8515 @tab @code{.L2}
8516 @tab @code{.L2}
8517 @item @code{c}
8518 @tab Require a constant operand and print the constant expression with no punctuation.
8519 @tab @code{%c1}
8520 @tab @code{2}
8521 @tab @code{2}
8522 @end multitable
8523
8524 @anchor{x86floatingpointasmoperands}
8525 @subsubsection x86 Floating-Point @code{asm} Operands
8526
8527 On x86 targets, there are several rules on the usage of stack-like registers
8528 in the operands of an @code{asm}. These rules apply only to the operands
8529 that are stack-like registers:
8530
8531 @enumerate
8532 @item
8533 Given a set of input registers that die in an @code{asm}, it is
8534 necessary to know which are implicitly popped by the @code{asm}, and
8535 which must be explicitly popped by GCC@.
8536
8537 An input register that is implicitly popped by the @code{asm} must be
8538 explicitly clobbered, unless it is constrained to match an
8539 output operand.
8540
8541 @item
8542 For any input register that is implicitly popped by an @code{asm}, it is
8543 necessary to know how to adjust the stack to compensate for the pop.
8544 If any non-popped input is closer to the top of the reg-stack than
8545 the implicitly popped register, it would not be possible to know what the
8546 stack looked like---it's not clear how the rest of the stack ``slides
8547 up''.
8548
8549 All implicitly popped input registers must be closer to the top of
8550 the reg-stack than any input that is not implicitly popped.
8551
8552 It is possible that if an input dies in an @code{asm}, the compiler might
8553 use the input register for an output reload. Consider this example:
8554
8555 @smallexample
8556 asm ("foo" : "=t" (a) : "f" (b));
8557 @end smallexample
8558
8559 @noindent
8560 This code says that input @code{b} is not popped by the @code{asm}, and that
8561 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8562 deeper after the @code{asm} than it was before. But, it is possible that
8563 reload may think that it can use the same register for both the input and
8564 the output.
8565
8566 To prevent this from happening,
8567 if any input operand uses the @samp{f} constraint, all output register
8568 constraints must use the @samp{&} early-clobber modifier.
8569
8570 The example above is correctly written as:
8571
8572 @smallexample
8573 asm ("foo" : "=&t" (a) : "f" (b));
8574 @end smallexample
8575
8576 @item
8577 Some operands need to be in particular places on the stack. All
8578 output operands fall in this category---GCC has no other way to
8579 know which registers the outputs appear in unless you indicate
8580 this in the constraints.
8581
8582 Output operands must specifically indicate which register an output
8583 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8584 constraints must select a class with a single register.
8585
8586 @item
8587 Output operands may not be ``inserted'' between existing stack registers.
8588 Since no 387 opcode uses a read/write operand, all output operands
8589 are dead before the @code{asm}, and are pushed by the @code{asm}.
8590 It makes no sense to push anywhere but the top of the reg-stack.
8591
8592 Output operands must start at the top of the reg-stack: output
8593 operands may not ``skip'' a register.
8594
8595 @item
8596 Some @code{asm} statements may need extra stack space for internal
8597 calculations. This can be guaranteed by clobbering stack registers
8598 unrelated to the inputs and outputs.
8599
8600 @end enumerate
8601
8602 This @code{asm}
8603 takes one input, which is internally popped, and produces two outputs.
8604
8605 @smallexample
8606 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8607 @end smallexample
8608
8609 @noindent
8610 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8611 and replaces them with one output. The @code{st(1)} clobber is necessary
8612 for the compiler to know that @code{fyl2xp1} pops both inputs.
8613
8614 @smallexample
8615 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8616 @end smallexample
8617
8618 @lowersections
8619 @include md.texi
8620 @raisesections
8621
8622 @node Asm Labels
8623 @subsection Controlling Names Used in Assembler Code
8624 @cindex assembler names for identifiers
8625 @cindex names used in assembler code
8626 @cindex identifiers, names in assembler code
8627
8628 You can specify the name to be used in the assembler code for a C
8629 function or variable by writing the @code{asm} (or @code{__asm__})
8630 keyword after the declarator.
8631 It is up to you to make sure that the assembler names you choose do not
8632 conflict with any other assembler symbols, or reference registers.
8633
8634 @subsubheading Assembler names for data:
8635
8636 This sample shows how to specify the assembler name for data:
8637
8638 @smallexample
8639 int foo asm ("myfoo") = 2;
8640 @end smallexample
8641
8642 @noindent
8643 This specifies that the name to be used for the variable @code{foo} in
8644 the assembler code should be @samp{myfoo} rather than the usual
8645 @samp{_foo}.
8646
8647 On systems where an underscore is normally prepended to the name of a C
8648 variable, this feature allows you to define names for the
8649 linker that do not start with an underscore.
8650
8651 GCC does not support using this feature with a non-static local variable
8652 since such variables do not have assembler names. If you are
8653 trying to put the variable in a particular register, see
8654 @ref{Explicit Register Variables}.
8655
8656 @subsubheading Assembler names for functions:
8657
8658 To specify the assembler name for functions, write a declaration for the
8659 function before its definition and put @code{asm} there, like this:
8660
8661 @smallexample
8662 int func (int x, int y) asm ("MYFUNC");
8663
8664 int func (int x, int y)
8665 @{
8666 /* @r{@dots{}} */
8667 @end smallexample
8668
8669 @noindent
8670 This specifies that the name to be used for the function @code{func} in
8671 the assembler code should be @code{MYFUNC}.
8672
8673 @node Explicit Register Variables
8674 @subsection Variables in Specified Registers
8675 @anchor{Explicit Reg Vars}
8676 @cindex explicit register variables
8677 @cindex variables in specified registers
8678 @cindex specified registers
8679
8680 GNU C allows you to associate specific hardware registers with C
8681 variables. In almost all cases, allowing the compiler to assign
8682 registers produces the best code. However under certain unusual
8683 circumstances, more precise control over the variable storage is
8684 required.
8685
8686 Both global and local variables can be associated with a register. The
8687 consequences of performing this association are very different between
8688 the two, as explained in the sections below.
8689
8690 @menu
8691 * Global Register Variables:: Variables declared at global scope.
8692 * Local Register Variables:: Variables declared within a function.
8693 @end menu
8694
8695 @node Global Register Variables
8696 @subsubsection Defining Global Register Variables
8697 @anchor{Global Reg Vars}
8698 @cindex global register variables
8699 @cindex registers, global variables in
8700 @cindex registers, global allocation
8701
8702 You can define a global register variable and associate it with a specified
8703 register like this:
8704
8705 @smallexample
8706 register int *foo asm ("r12");
8707 @end smallexample
8708
8709 @noindent
8710 Here @code{r12} is the name of the register that should be used. Note that
8711 this is the same syntax used for defining local register variables, but for
8712 a global variable the declaration appears outside a function. The
8713 @code{register} keyword is required, and cannot be combined with
8714 @code{static}. The register name must be a valid register name for the
8715 target platform.
8716
8717 Registers are a scarce resource on most systems and allowing the
8718 compiler to manage their usage usually results in the best code. However,
8719 under special circumstances it can make sense to reserve some globally.
8720 For example this may be useful in programs such as programming language
8721 interpreters that have a couple of global variables that are accessed
8722 very often.
8723
8724 After defining a global register variable, for the current compilation
8725 unit:
8726
8727 @itemize @bullet
8728 @item The register is reserved entirely for this use, and will not be
8729 allocated for any other purpose.
8730 @item The register is not saved and restored by any functions.
8731 @item Stores into this register are never deleted even if they appear to be
8732 dead, but references may be deleted, moved or simplified.
8733 @end itemize
8734
8735 Note that these points @emph{only} apply to code that is compiled with the
8736 definition. The behavior of code that is merely linked in (for example
8737 code from libraries) is not affected.
8738
8739 If you want to recompile source files that do not actually use your global
8740 register variable so they do not use the specified register for any other
8741 purpose, you need not actually add the global register declaration to
8742 their source code. It suffices to specify the compiler option
8743 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8744 register.
8745
8746 @subsubheading Declaring the variable
8747
8748 Global register variables can not have initial values, because an
8749 executable file has no means to supply initial contents for a register.
8750
8751 When selecting a register, choose one that is normally saved and
8752 restored by function calls on your machine. This ensures that code
8753 which is unaware of this reservation (such as library routines) will
8754 restore it before returning.
8755
8756 On machines with register windows, be sure to choose a global
8757 register that is not affected magically by the function call mechanism.
8758
8759 @subsubheading Using the variable
8760
8761 @cindex @code{qsort}, and global register variables
8762 When calling routines that are not aware of the reservation, be
8763 cautious if those routines call back into code which uses them. As an
8764 example, if you call the system library version of @code{qsort}, it may
8765 clobber your registers during execution, but (if you have selected
8766 appropriate registers) it will restore them before returning. However
8767 it will @emph{not} restore them before calling @code{qsort}'s comparison
8768 function. As a result, global values will not reliably be available to
8769 the comparison function unless the @code{qsort} function itself is rebuilt.
8770
8771 Similarly, it is not safe to access the global register variables from signal
8772 handlers or from more than one thread of control. Unless you recompile
8773 them specially for the task at hand, the system library routines may
8774 temporarily use the register for other things.
8775
8776 @cindex register variable after @code{longjmp}
8777 @cindex global register after @code{longjmp}
8778 @cindex value after @code{longjmp}
8779 @findex longjmp
8780 @findex setjmp
8781 On most machines, @code{longjmp} restores to each global register
8782 variable the value it had at the time of the @code{setjmp}. On some
8783 machines, however, @code{longjmp} does not change the value of global
8784 register variables. To be portable, the function that called @code{setjmp}
8785 should make other arrangements to save the values of the global register
8786 variables, and to restore them in a @code{longjmp}. This way, the same
8787 thing happens regardless of what @code{longjmp} does.
8788
8789 Eventually there may be a way of asking the compiler to choose a register
8790 automatically, but first we need to figure out how it should choose and
8791 how to enable you to guide the choice. No solution is evident.
8792
8793 @node Local Register Variables
8794 @subsubsection Specifying Registers for Local Variables
8795 @anchor{Local Reg Vars}
8796 @cindex local variables, specifying registers
8797 @cindex specifying registers for local variables
8798 @cindex registers for local variables
8799
8800 You can define a local register variable and associate it with a specified
8801 register like this:
8802
8803 @smallexample
8804 register int *foo asm ("r12");
8805 @end smallexample
8806
8807 @noindent
8808 Here @code{r12} is the name of the register that should be used. Note
8809 that this is the same syntax used for defining global register variables,
8810 but for a local variable the declaration appears within a function. The
8811 @code{register} keyword is required, and cannot be combined with
8812 @code{static}. The register name must be a valid register name for the
8813 target platform.
8814
8815 As with global register variables, it is recommended that you choose
8816 a register that is normally saved and restored by function calls on your
8817 machine, so that calls to library routines will not clobber it.
8818
8819 The only supported use for this feature is to specify registers
8820 for input and output operands when calling Extended @code{asm}
8821 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8822 particular machine don't provide sufficient control to select the desired
8823 register. To force an operand into a register, create a local variable
8824 and specify the register name after the variable's declaration. Then use
8825 the local variable for the @code{asm} operand and specify any constraint
8826 letter that matches the register:
8827
8828 @smallexample
8829 register int *p1 asm ("r0") = @dots{};
8830 register int *p2 asm ("r1") = @dots{};
8831 register int *result asm ("r0");
8832 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8833 @end smallexample
8834
8835 @emph{Warning:} In the above example, be aware that a register (for example
8836 @code{r0}) can be call-clobbered by subsequent code, including function
8837 calls and library calls for arithmetic operators on other variables (for
8838 example the initialization of @code{p2}). In this case, use temporary
8839 variables for expressions between the register assignments:
8840
8841 @smallexample
8842 int t1 = @dots{};
8843 register int *p1 asm ("r0") = @dots{};
8844 register int *p2 asm ("r1") = t1;
8845 register int *result asm ("r0");
8846 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8847 @end smallexample
8848
8849 Defining a register variable does not reserve the register. Other than
8850 when invoking the Extended @code{asm}, the contents of the specified
8851 register are not guaranteed. For this reason, the following uses
8852 are explicitly @emph{not} supported. If they appear to work, it is only
8853 happenstance, and may stop working as intended due to (seemingly)
8854 unrelated changes in surrounding code, or even minor changes in the
8855 optimization of a future version of gcc:
8856
8857 @itemize @bullet
8858 @item Passing parameters to or from Basic @code{asm}
8859 @item Passing parameters to or from Extended @code{asm} without using input
8860 or output operands.
8861 @item Passing parameters to or from routines written in assembler (or
8862 other languages) using non-standard calling conventions.
8863 @end itemize
8864
8865 Some developers use Local Register Variables in an attempt to improve
8866 gcc's allocation of registers, especially in large functions. In this
8867 case the register name is essentially a hint to the register allocator.
8868 While in some instances this can generate better code, improvements are
8869 subject to the whims of the allocator/optimizers. Since there are no
8870 guarantees that your improvements won't be lost, this usage of Local
8871 Register Variables is discouraged.
8872
8873 On the MIPS platform, there is related use for local register variables
8874 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8875 Defining coprocessor specifics for MIPS targets, gccint,
8876 GNU Compiler Collection (GCC) Internals}).
8877
8878 @node Size of an asm
8879 @subsection Size of an @code{asm}
8880
8881 Some targets require that GCC track the size of each instruction used
8882 in order to generate correct code. Because the final length of the
8883 code produced by an @code{asm} statement is only known by the
8884 assembler, GCC must make an estimate as to how big it will be. It
8885 does this by counting the number of instructions in the pattern of the
8886 @code{asm} and multiplying that by the length of the longest
8887 instruction supported by that processor. (When working out the number
8888 of instructions, it assumes that any occurrence of a newline or of
8889 whatever statement separator character is supported by the assembler --
8890 typically @samp{;} --- indicates the end of an instruction.)
8891
8892 Normally, GCC's estimate is adequate to ensure that correct
8893 code is generated, but it is possible to confuse the compiler if you use
8894 pseudo instructions or assembler macros that expand into multiple real
8895 instructions, or if you use assembler directives that expand to more
8896 space in the object file than is needed for a single instruction.
8897 If this happens then the assembler may produce a diagnostic saying that
8898 a label is unreachable.
8899
8900 @node Alternate Keywords
8901 @section Alternate Keywords
8902 @cindex alternate keywords
8903 @cindex keywords, alternate
8904
8905 @option{-ansi} and the various @option{-std} options disable certain
8906 keywords. This causes trouble when you want to use GNU C extensions, or
8907 a general-purpose header file that should be usable by all programs,
8908 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8909 @code{inline} are not available in programs compiled with
8910 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8911 program compiled with @option{-std=c99} or @option{-std=c11}). The
8912 ISO C99 keyword
8913 @code{restrict} is only available when @option{-std=gnu99} (which will
8914 eventually be the default) or @option{-std=c99} (or the equivalent
8915 @option{-std=iso9899:1999}), or an option for a later standard
8916 version, is used.
8917
8918 The way to solve these problems is to put @samp{__} at the beginning and
8919 end of each problematical keyword. For example, use @code{__asm__}
8920 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8921
8922 Other C compilers won't accept these alternative keywords; if you want to
8923 compile with another compiler, you can define the alternate keywords as
8924 macros to replace them with the customary keywords. It looks like this:
8925
8926 @smallexample
8927 #ifndef __GNUC__
8928 #define __asm__ asm
8929 #endif
8930 @end smallexample
8931
8932 @findex __extension__
8933 @opindex pedantic
8934 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8935 You can
8936 prevent such warnings within one expression by writing
8937 @code{__extension__} before the expression. @code{__extension__} has no
8938 effect aside from this.
8939
8940 @node Incomplete Enums
8941 @section Incomplete @code{enum} Types
8942
8943 You can define an @code{enum} tag without specifying its possible values.
8944 This results in an incomplete type, much like what you get if you write
8945 @code{struct foo} without describing the elements. A later declaration
8946 that does specify the possible values completes the type.
8947
8948 You can't allocate variables or storage using the type while it is
8949 incomplete. However, you can work with pointers to that type.
8950
8951 This extension may not be very useful, but it makes the handling of
8952 @code{enum} more consistent with the way @code{struct} and @code{union}
8953 are handled.
8954
8955 This extension is not supported by GNU C++.
8956
8957 @node Function Names
8958 @section Function Names as Strings
8959 @cindex @code{__func__} identifier
8960 @cindex @code{__FUNCTION__} identifier
8961 @cindex @code{__PRETTY_FUNCTION__} identifier
8962
8963 GCC provides three magic variables that hold the name of the current
8964 function, as a string. The first of these is @code{__func__}, which
8965 is part of the C99 standard:
8966
8967 The identifier @code{__func__} is implicitly declared by the translator
8968 as if, immediately following the opening brace of each function
8969 definition, the declaration
8970
8971 @smallexample
8972 static const char __func__[] = "function-name";
8973 @end smallexample
8974
8975 @noindent
8976 appeared, where function-name is the name of the lexically-enclosing
8977 function. This name is the unadorned name of the function.
8978
8979 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8980 backward compatibility with old versions of GCC.
8981
8982 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8983 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8984 the type signature of the function as well as its bare name. For
8985 example, this program:
8986
8987 @smallexample
8988 extern "C" @{
8989 extern int printf (char *, ...);
8990 @}
8991
8992 class a @{
8993 public:
8994 void sub (int i)
8995 @{
8996 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8997 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8998 @}
8999 @};
9000
9001 int
9002 main (void)
9003 @{
9004 a ax;
9005 ax.sub (0);
9006 return 0;
9007 @}
9008 @end smallexample
9009
9010 @noindent
9011 gives this output:
9012
9013 @smallexample
9014 __FUNCTION__ = sub
9015 __PRETTY_FUNCTION__ = void a::sub(int)
9016 @end smallexample
9017
9018 These identifiers are variables, not preprocessor macros, and may not
9019 be used to initialize @code{char} arrays or be concatenated with other string
9020 literals.
9021
9022 @node Return Address
9023 @section Getting the Return or Frame Address of a Function
9024
9025 These functions may be used to get information about the callers of a
9026 function.
9027
9028 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9029 This function returns the return address of the current function, or of
9030 one of its callers. The @var{level} argument is number of frames to
9031 scan up the call stack. A value of @code{0} yields the return address
9032 of the current function, a value of @code{1} yields the return address
9033 of the caller of the current function, and so forth. When inlining
9034 the expected behavior is that the function returns the address of
9035 the function that is returned to. To work around this behavior use
9036 the @code{noinline} function attribute.
9037
9038 The @var{level} argument must be a constant integer.
9039
9040 On some machines it may be impossible to determine the return address of
9041 any function other than the current one; in such cases, or when the top
9042 of the stack has been reached, this function returns @code{0} or a
9043 random value. In addition, @code{__builtin_frame_address} may be used
9044 to determine if the top of the stack has been reached.
9045
9046 Additional post-processing of the returned value may be needed, see
9047 @code{__builtin_extract_return_addr}.
9048
9049 Calling this function with a nonzero argument can have unpredictable
9050 effects, including crashing the calling program. As a result, calls
9051 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9052 option is in effect. Such calls should only be made in debugging
9053 situations.
9054 @end deftypefn
9055
9056 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9057 The address as returned by @code{__builtin_return_address} may have to be fed
9058 through this function to get the actual encoded address. For example, on the
9059 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9060 platforms an offset has to be added for the true next instruction to be
9061 executed.
9062
9063 If no fixup is needed, this function simply passes through @var{addr}.
9064 @end deftypefn
9065
9066 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9067 This function does the reverse of @code{__builtin_extract_return_addr}.
9068 @end deftypefn
9069
9070 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9071 This function is similar to @code{__builtin_return_address}, but it
9072 returns the address of the function frame rather than the return address
9073 of the function. Calling @code{__builtin_frame_address} with a value of
9074 @code{0} yields the frame address of the current function, a value of
9075 @code{1} yields the frame address of the caller of the current function,
9076 and so forth.
9077
9078 The frame is the area on the stack that holds local variables and saved
9079 registers. The frame address is normally the address of the first word
9080 pushed on to the stack by the function. However, the exact definition
9081 depends upon the processor and the calling convention. If the processor
9082 has a dedicated frame pointer register, and the function has a frame,
9083 then @code{__builtin_frame_address} returns the value of the frame
9084 pointer register.
9085
9086 On some machines it may be impossible to determine the frame address of
9087 any function other than the current one; in such cases, or when the top
9088 of the stack has been reached, this function returns @code{0} if
9089 the first frame pointer is properly initialized by the startup code.
9090
9091 Calling this function with a nonzero argument can have unpredictable
9092 effects, including crashing the calling program. As a result, calls
9093 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9094 option is in effect. Such calls should only be made in debugging
9095 situations.
9096 @end deftypefn
9097
9098 @node Vector Extensions
9099 @section Using Vector Instructions through Built-in Functions
9100
9101 On some targets, the instruction set contains SIMD vector instructions which
9102 operate on multiple values contained in one large register at the same time.
9103 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9104 this way.
9105
9106 The first step in using these extensions is to provide the necessary data
9107 types. This should be done using an appropriate @code{typedef}:
9108
9109 @smallexample
9110 typedef int v4si __attribute__ ((vector_size (16)));
9111 @end smallexample
9112
9113 @noindent
9114 The @code{int} type specifies the base type, while the attribute specifies
9115 the vector size for the variable, measured in bytes. For example, the
9116 declaration above causes the compiler to set the mode for the @code{v4si}
9117 type to be 16 bytes wide and divided into @code{int} sized units. For
9118 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9119 corresponding mode of @code{foo} is @acronym{V4SI}.
9120
9121 The @code{vector_size} attribute is only applicable to integral and
9122 float scalars, although arrays, pointers, and function return values
9123 are allowed in conjunction with this construct. Only sizes that are
9124 a power of two are currently allowed.
9125
9126 All the basic integer types can be used as base types, both as signed
9127 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9128 @code{long long}. In addition, @code{float} and @code{double} can be
9129 used to build floating-point vector types.
9130
9131 Specifying a combination that is not valid for the current architecture
9132 causes GCC to synthesize the instructions using a narrower mode.
9133 For example, if you specify a variable of type @code{V4SI} and your
9134 architecture does not allow for this specific SIMD type, GCC
9135 produces code that uses 4 @code{SIs}.
9136
9137 The types defined in this manner can be used with a subset of normal C
9138 operations. Currently, GCC allows using the following operators
9139 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9140
9141 The operations behave like C++ @code{valarrays}. Addition is defined as
9142 the addition of the corresponding elements of the operands. For
9143 example, in the code below, each of the 4 elements in @var{a} is
9144 added to the corresponding 4 elements in @var{b} and the resulting
9145 vector is stored in @var{c}.
9146
9147 @smallexample
9148 typedef int v4si __attribute__ ((vector_size (16)));
9149
9150 v4si a, b, c;
9151
9152 c = a + b;
9153 @end smallexample
9154
9155 Subtraction, multiplication, division, and the logical operations
9156 operate in a similar manner. Likewise, the result of using the unary
9157 minus or complement operators on a vector type is a vector whose
9158 elements are the negative or complemented values of the corresponding
9159 elements in the operand.
9160
9161 It is possible to use shifting operators @code{<<}, @code{>>} on
9162 integer-type vectors. The operation is defined as following: @code{@{a0,
9163 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9164 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9165 elements.
9166
9167 For convenience, it is allowed to use a binary vector operation
9168 where one operand is a scalar. In that case the compiler transforms
9169 the scalar operand into a vector where each element is the scalar from
9170 the operation. The transformation happens only if the scalar could be
9171 safely converted to the vector-element type.
9172 Consider the following code.
9173
9174 @smallexample
9175 typedef int v4si __attribute__ ((vector_size (16)));
9176
9177 v4si a, b, c;
9178 long l;
9179
9180 a = b + 1; /* a = b + @{1,1,1,1@}; */
9181 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9182
9183 a = l + a; /* Error, cannot convert long to int. */
9184 @end smallexample
9185
9186 Vectors can be subscripted as if the vector were an array with
9187 the same number of elements and base type. Out of bound accesses
9188 invoke undefined behavior at run time. Warnings for out of bound
9189 accesses for vector subscription can be enabled with
9190 @option{-Warray-bounds}.
9191
9192 Vector comparison is supported with standard comparison
9193 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9194 vector expressions of integer-type or real-type. Comparison between
9195 integer-type vectors and real-type vectors are not supported. The
9196 result of the comparison is a vector of the same width and number of
9197 elements as the comparison operands with a signed integral element
9198 type.
9199
9200 Vectors are compared element-wise producing 0 when comparison is false
9201 and -1 (constant of the appropriate type where all bits are set)
9202 otherwise. Consider the following example.
9203
9204 @smallexample
9205 typedef int v4si __attribute__ ((vector_size (16)));
9206
9207 v4si a = @{1,2,3,4@};
9208 v4si b = @{3,2,1,4@};
9209 v4si c;
9210
9211 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9212 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9213 @end smallexample
9214
9215 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9216 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9217 integer vector with the same number of elements of the same size as @code{b}
9218 and @code{c}, computes all three arguments and creates a vector
9219 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9220 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9221 As in the case of binary operations, this syntax is also accepted when
9222 one of @code{b} or @code{c} is a scalar that is then transformed into a
9223 vector. If both @code{b} and @code{c} are scalars and the type of
9224 @code{true?b:c} has the same size as the element type of @code{a}, then
9225 @code{b} and @code{c} are converted to a vector type whose elements have
9226 this type and with the same number of elements as @code{a}.
9227
9228 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9229 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9230 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9231 For mixed operations between a scalar @code{s} and a vector @code{v},
9232 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9233 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9234
9235 Vector shuffling is available using functions
9236 @code{__builtin_shuffle (vec, mask)} and
9237 @code{__builtin_shuffle (vec0, vec1, mask)}.
9238 Both functions construct a permutation of elements from one or two
9239 vectors and return a vector of the same type as the input vector(s).
9240 The @var{mask} is an integral vector with the same width (@var{W})
9241 and element count (@var{N}) as the output vector.
9242
9243 The elements of the input vectors are numbered in memory ordering of
9244 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9245 elements of @var{mask} are considered modulo @var{N} in the single-operand
9246 case and modulo @math{2*@var{N}} in the two-operand case.
9247
9248 Consider the following example,
9249
9250 @smallexample
9251 typedef int v4si __attribute__ ((vector_size (16)));
9252
9253 v4si a = @{1,2,3,4@};
9254 v4si b = @{5,6,7,8@};
9255 v4si mask1 = @{0,1,1,3@};
9256 v4si mask2 = @{0,4,2,5@};
9257 v4si res;
9258
9259 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9260 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9261 @end smallexample
9262
9263 Note that @code{__builtin_shuffle} is intentionally semantically
9264 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9265
9266 You can declare variables and use them in function calls and returns, as
9267 well as in assignments and some casts. You can specify a vector type as
9268 a return type for a function. Vector types can also be used as function
9269 arguments. It is possible to cast from one vector type to another,
9270 provided they are of the same size (in fact, you can also cast vectors
9271 to and from other datatypes of the same size).
9272
9273 You cannot operate between vectors of different lengths or different
9274 signedness without a cast.
9275
9276 @node Offsetof
9277 @section Support for @code{offsetof}
9278 @findex __builtin_offsetof
9279
9280 GCC implements for both C and C++ a syntactic extension to implement
9281 the @code{offsetof} macro.
9282
9283 @smallexample
9284 primary:
9285 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9286
9287 offsetof_member_designator:
9288 @code{identifier}
9289 | offsetof_member_designator "." @code{identifier}
9290 | offsetof_member_designator "[" @code{expr} "]"
9291 @end smallexample
9292
9293 This extension is sufficient such that
9294
9295 @smallexample
9296 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9297 @end smallexample
9298
9299 @noindent
9300 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9301 may be dependent. In either case, @var{member} may consist of a single
9302 identifier, or a sequence of member accesses and array references.
9303
9304 @node __sync Builtins
9305 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9306
9307 The following built-in functions
9308 are intended to be compatible with those described
9309 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9310 section 7.4. As such, they depart from normal GCC practice by not using
9311 the @samp{__builtin_} prefix and also by being overloaded so that they
9312 work on multiple types.
9313
9314 The definition given in the Intel documentation allows only for the use of
9315 the types @code{int}, @code{long}, @code{long long} or their unsigned
9316 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9317 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9318 Operations on pointer arguments are performed as if the operands were
9319 of the @code{uintptr_t} type. That is, they are not scaled by the size
9320 of the type to which the pointer points.
9321
9322 These functions are implemented in terms of the @samp{__atomic}
9323 builtins (@pxref{__atomic Builtins}). They should not be used for new
9324 code which should use the @samp{__atomic} builtins instead.
9325
9326 Not all operations are supported by all target processors. If a particular
9327 operation cannot be implemented on the target processor, a warning is
9328 generated and a call to an external function is generated. The external
9329 function carries the same name as the built-in version,
9330 with an additional suffix
9331 @samp{_@var{n}} where @var{n} is the size of the data type.
9332
9333 @c ??? Should we have a mechanism to suppress this warning? This is almost
9334 @c useful for implementing the operation under the control of an external
9335 @c mutex.
9336
9337 In most cases, these built-in functions are considered a @dfn{full barrier}.
9338 That is,
9339 no memory operand is moved across the operation, either forward or
9340 backward. Further, instructions are issued as necessary to prevent the
9341 processor from speculating loads across the operation and from queuing stores
9342 after the operation.
9343
9344 All of the routines are described in the Intel documentation to take
9345 ``an optional list of variables protected by the memory barrier''. It's
9346 not clear what is meant by that; it could mean that @emph{only} the
9347 listed variables are protected, or it could mean a list of additional
9348 variables to be protected. The list is ignored by GCC which treats it as
9349 empty. GCC interprets an empty list as meaning that all globally
9350 accessible variables should be protected.
9351
9352 @table @code
9353 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9354 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9355 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9356 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9357 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9358 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9359 @findex __sync_fetch_and_add
9360 @findex __sync_fetch_and_sub
9361 @findex __sync_fetch_and_or
9362 @findex __sync_fetch_and_and
9363 @findex __sync_fetch_and_xor
9364 @findex __sync_fetch_and_nand
9365 These built-in functions perform the operation suggested by the name, and
9366 returns the value that had previously been in memory. That is, operations
9367 on integer operands have the following semantics. Operations on pointer
9368 arguments are performed as if the operands were of the @code{uintptr_t}
9369 type. That is, they are not scaled by the size of the type to which
9370 the pointer points.
9371
9372 @smallexample
9373 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9374 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9375 @end smallexample
9376
9377 The object pointed to by the first argument must be of integer or pointer
9378 type. It must not be a Boolean type.
9379
9380 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9381 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9382
9383 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9384 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9385 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9386 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9387 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9388 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9389 @findex __sync_add_and_fetch
9390 @findex __sync_sub_and_fetch
9391 @findex __sync_or_and_fetch
9392 @findex __sync_and_and_fetch
9393 @findex __sync_xor_and_fetch
9394 @findex __sync_nand_and_fetch
9395 These built-in functions perform the operation suggested by the name, and
9396 return the new value. That is, operations on integer operands have
9397 the following semantics. Operations on pointer operands are performed as
9398 if the operand's type were @code{uintptr_t}.
9399
9400 @smallexample
9401 @{ *ptr @var{op}= value; return *ptr; @}
9402 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9403 @end smallexample
9404
9405 The same constraints on arguments apply as for the corresponding
9406 @code{__sync_op_and_fetch} built-in functions.
9407
9408 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9409 as @code{*ptr = ~(*ptr & value)} instead of
9410 @code{*ptr = ~*ptr & value}.
9411
9412 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9413 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9414 @findex __sync_bool_compare_and_swap
9415 @findex __sync_val_compare_and_swap
9416 These built-in functions perform an atomic compare and swap.
9417 That is, if the current
9418 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9419 @code{*@var{ptr}}.
9420
9421 The ``bool'' version returns true if the comparison is successful and
9422 @var{newval} is written. The ``val'' version returns the contents
9423 of @code{*@var{ptr}} before the operation.
9424
9425 @item __sync_synchronize (...)
9426 @findex __sync_synchronize
9427 This built-in function issues a full memory barrier.
9428
9429 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9430 @findex __sync_lock_test_and_set
9431 This built-in function, as described by Intel, is not a traditional test-and-set
9432 operation, but rather an atomic exchange operation. It writes @var{value}
9433 into @code{*@var{ptr}}, and returns the previous contents of
9434 @code{*@var{ptr}}.
9435
9436 Many targets have only minimal support for such locks, and do not support
9437 a full exchange operation. In this case, a target may support reduced
9438 functionality here by which the @emph{only} valid value to store is the
9439 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9440 is implementation defined.
9441
9442 This built-in function is not a full barrier,
9443 but rather an @dfn{acquire barrier}.
9444 This means that references after the operation cannot move to (or be
9445 speculated to) before the operation, but previous memory stores may not
9446 be globally visible yet, and previous memory loads may not yet be
9447 satisfied.
9448
9449 @item void __sync_lock_release (@var{type} *ptr, ...)
9450 @findex __sync_lock_release
9451 This built-in function releases the lock acquired by
9452 @code{__sync_lock_test_and_set}.
9453 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9454
9455 This built-in function is not a full barrier,
9456 but rather a @dfn{release barrier}.
9457 This means that all previous memory stores are globally visible, and all
9458 previous memory loads have been satisfied, but following memory reads
9459 are not prevented from being speculated to before the barrier.
9460 @end table
9461
9462 @node __atomic Builtins
9463 @section Built-in Functions for Memory Model Aware Atomic Operations
9464
9465 The following built-in functions approximately match the requirements
9466 for the C++11 memory model. They are all
9467 identified by being prefixed with @samp{__atomic} and most are
9468 overloaded so that they work with multiple types.
9469
9470 These functions are intended to replace the legacy @samp{__sync}
9471 builtins. The main difference is that the memory order that is requested
9472 is a parameter to the functions. New code should always use the
9473 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9474
9475 Note that the @samp{__atomic} builtins assume that programs will
9476 conform to the C++11 memory model. In particular, they assume
9477 that programs are free of data races. See the C++11 standard for
9478 detailed requirements.
9479
9480 The @samp{__atomic} builtins can be used with any integral scalar or
9481 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9482 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9483 supported by the architecture.
9484
9485 The four non-arithmetic functions (load, store, exchange, and
9486 compare_exchange) all have a generic version as well. This generic
9487 version works on any data type. It uses the lock-free built-in function
9488 if the specific data type size makes that possible; otherwise, an
9489 external call is left to be resolved at run time. This external call is
9490 the same format with the addition of a @samp{size_t} parameter inserted
9491 as the first parameter indicating the size of the object being pointed to.
9492 All objects must be the same size.
9493
9494 There are 6 different memory orders that can be specified. These map
9495 to the C++11 memory orders with the same names, see the C++11 standard
9496 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9497 on atomic synchronization} for detailed definitions. Individual
9498 targets may also support additional memory orders for use on specific
9499 architectures. Refer to the target documentation for details of
9500 these.
9501
9502 An atomic operation can both constrain code motion and
9503 be mapped to hardware instructions for synchronization between threads
9504 (e.g., a fence). To which extent this happens is controlled by the
9505 memory orders, which are listed here in approximately ascending order of
9506 strength. The description of each memory order is only meant to roughly
9507 illustrate the effects and is not a specification; see the C++11
9508 memory model for precise semantics.
9509
9510 @table @code
9511 @item __ATOMIC_RELAXED
9512 Implies no inter-thread ordering constraints.
9513 @item __ATOMIC_CONSUME
9514 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9515 memory order because of a deficiency in C++11's semantics for
9516 @code{memory_order_consume}.
9517 @item __ATOMIC_ACQUIRE
9518 Creates an inter-thread happens-before constraint from the release (or
9519 stronger) semantic store to this acquire load. Can prevent hoisting
9520 of code to before the operation.
9521 @item __ATOMIC_RELEASE
9522 Creates an inter-thread happens-before constraint to acquire (or stronger)
9523 semantic loads that read from this release store. Can prevent sinking
9524 of code to after the operation.
9525 @item __ATOMIC_ACQ_REL
9526 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9527 @code{__ATOMIC_RELEASE}.
9528 @item __ATOMIC_SEQ_CST
9529 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9530 @end table
9531
9532 Note that in the C++11 memory model, @emph{fences} (e.g.,
9533 @samp{__atomic_thread_fence}) take effect in combination with other
9534 atomic operations on specific memory locations (e.g., atomic loads);
9535 operations on specific memory locations do not necessarily affect other
9536 operations in the same way.
9537
9538 Target architectures are encouraged to provide their own patterns for
9539 each of the atomic built-in functions. If no target is provided, the original
9540 non-memory model set of @samp{__sync} atomic built-in functions are
9541 used, along with any required synchronization fences surrounding it in
9542 order to achieve the proper behavior. Execution in this case is subject
9543 to the same restrictions as those built-in functions.
9544
9545 If there is no pattern or mechanism to provide a lock-free instruction
9546 sequence, a call is made to an external routine with the same parameters
9547 to be resolved at run time.
9548
9549 When implementing patterns for these built-in functions, the memory order
9550 parameter can be ignored as long as the pattern implements the most
9551 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9552 orders execute correctly with this memory order but they may not execute as
9553 efficiently as they could with a more appropriate implementation of the
9554 relaxed requirements.
9555
9556 Note that the C++11 standard allows for the memory order parameter to be
9557 determined at run time rather than at compile time. These built-in
9558 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9559 than invoke a runtime library call or inline a switch statement. This is
9560 standard compliant, safe, and the simplest approach for now.
9561
9562 The memory order parameter is a signed int, but only the lower 16 bits are
9563 reserved for the memory order. The remainder of the signed int is reserved
9564 for target use and should be 0. Use of the predefined atomic values
9565 ensures proper usage.
9566
9567 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9568 This built-in function implements an atomic load operation. It returns the
9569 contents of @code{*@var{ptr}}.
9570
9571 The valid memory order variants are
9572 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9573 and @code{__ATOMIC_CONSUME}.
9574
9575 @end deftypefn
9576
9577 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9578 This is the generic version of an atomic load. It returns the
9579 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9580
9581 @end deftypefn
9582
9583 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9584 This built-in function implements an atomic store operation. It writes
9585 @code{@var{val}} into @code{*@var{ptr}}.
9586
9587 The valid memory order variants are
9588 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9589
9590 @end deftypefn
9591
9592 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9593 This is the generic version of an atomic store. It stores the value
9594 of @code{*@var{val}} into @code{*@var{ptr}}.
9595
9596 @end deftypefn
9597
9598 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9599 This built-in function implements an atomic exchange operation. It writes
9600 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9601 @code{*@var{ptr}}.
9602
9603 The valid memory order variants are
9604 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9605 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9606
9607 @end deftypefn
9608
9609 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9610 This is the generic version of an atomic exchange. It stores the
9611 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9612 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9613
9614 @end deftypefn
9615
9616 @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)
9617 This built-in function implements an atomic compare and exchange operation.
9618 This compares the contents of @code{*@var{ptr}} with the contents of
9619 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9620 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9621 equal, the operation is a @emph{read} and the current contents of
9622 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9623 for weak compare_exchange, which may fail spuriously, and false for
9624 the strong variation, which never fails spuriously. Many targets
9625 only offer the strong variation and ignore the parameter. When in doubt, use
9626 the strong variation.
9627
9628 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9629 and memory is affected according to the
9630 memory order specified by @var{success_memorder}. There are no
9631 restrictions on what memory order can be used here.
9632
9633 Otherwise, false is returned and memory is affected according
9634 to @var{failure_memorder}. This memory order cannot be
9635 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9636 stronger order than that specified by @var{success_memorder}.
9637
9638 @end deftypefn
9639
9640 @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)
9641 This built-in function implements the generic version of
9642 @code{__atomic_compare_exchange}. The function is virtually identical to
9643 @code{__atomic_compare_exchange_n}, except the desired value is also a
9644 pointer.
9645
9646 @end deftypefn
9647
9648 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9649 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9650 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9651 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9652 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9653 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9654 These built-in functions perform the operation suggested by the name, and
9655 return the result of the operation. Operations on pointer arguments are
9656 performed as if the operands were of the @code{uintptr_t} type. That is,
9657 they are not scaled by the size of the type to which the pointer points.
9658
9659 @smallexample
9660 @{ *ptr @var{op}= val; return *ptr; @}
9661 @end smallexample
9662
9663 The object pointed to by the first argument must be of integer or pointer
9664 type. It must not be a Boolean type. All memory orders are valid.
9665
9666 @end deftypefn
9667
9668 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9669 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9670 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9671 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9672 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9673 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9674 These built-in functions perform the operation suggested by the name, and
9675 return the value that had previously been in @code{*@var{ptr}}. Operations
9676 on pointer arguments are performed as if the operands were of
9677 the @code{uintptr_t} type. That is, they are not scaled by the size of
9678 the type to which the pointer points.
9679
9680 @smallexample
9681 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9682 @end smallexample
9683
9684 The same constraints on arguments apply as for the corresponding
9685 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9686
9687 @end deftypefn
9688
9689 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9690
9691 This built-in function performs an atomic test-and-set operation on
9692 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9693 defined nonzero ``set'' value and the return value is @code{true} if and only
9694 if the previous contents were ``set''.
9695 It should be only used for operands of type @code{bool} or @code{char}. For
9696 other types only part of the value may be set.
9697
9698 All memory orders are valid.
9699
9700 @end deftypefn
9701
9702 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9703
9704 This built-in function performs an atomic clear operation on
9705 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9706 It should be only used for operands of type @code{bool} or @code{char} and
9707 in conjunction with @code{__atomic_test_and_set}.
9708 For other types it may only clear partially. If the type is not @code{bool}
9709 prefer using @code{__atomic_store}.
9710
9711 The valid memory order variants are
9712 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9713 @code{__ATOMIC_RELEASE}.
9714
9715 @end deftypefn
9716
9717 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9718
9719 This built-in function acts as a synchronization fence between threads
9720 based on the specified memory order.
9721
9722 All memory orders are valid.
9723
9724 @end deftypefn
9725
9726 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9727
9728 This built-in function acts as a synchronization fence between a thread
9729 and signal handlers based in the same thread.
9730
9731 All memory orders are valid.
9732
9733 @end deftypefn
9734
9735 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9736
9737 This built-in function returns true if objects of @var{size} bytes always
9738 generate lock-free atomic instructions for the target architecture.
9739 @var{size} must resolve to a compile-time constant and the result also
9740 resolves to a compile-time constant.
9741
9742 @var{ptr} is an optional pointer to the object that may be used to determine
9743 alignment. A value of 0 indicates typical alignment should be used. The
9744 compiler may also ignore this parameter.
9745
9746 @smallexample
9747 if (__atomic_always_lock_free (sizeof (long long), 0))
9748 @end smallexample
9749
9750 @end deftypefn
9751
9752 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9753
9754 This built-in function returns true if objects of @var{size} bytes always
9755 generate lock-free atomic instructions for the target architecture. If
9756 the built-in function is not known to be lock-free, a call is made to a
9757 runtime routine named @code{__atomic_is_lock_free}.
9758
9759 @var{ptr} is an optional pointer to the object that may be used to determine
9760 alignment. A value of 0 indicates typical alignment should be used. The
9761 compiler may also ignore this parameter.
9762 @end deftypefn
9763
9764 @node Integer Overflow Builtins
9765 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9766
9767 The following built-in functions allow performing simple arithmetic operations
9768 together with checking whether the operations overflowed.
9769
9770 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9771 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9772 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9773 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9774 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9775 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9776 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9777
9778 These built-in functions promote the first two operands into infinite precision signed
9779 type and perform addition on those promoted operands. The result is then
9780 cast to the type the third pointer argument points to and stored there.
9781 If the stored result is equal to the infinite precision result, the built-in
9782 functions return false, otherwise they return true. As the addition is
9783 performed in infinite signed precision, these built-in functions have fully defined
9784 behavior for all argument values.
9785
9786 The first built-in function allows arbitrary integral types for operands and
9787 the result type must be pointer to some integer type, the rest of the built-in
9788 functions have explicit integer types.
9789
9790 The compiler will attempt to use hardware instructions to implement
9791 these built-in functions where possible, like conditional jump on overflow
9792 after addition, conditional jump on carry etc.
9793
9794 @end deftypefn
9795
9796 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9797 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9798 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9799 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9800 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9801 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9802 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9803
9804 These built-in functions are similar to the add overflow checking built-in
9805 functions above, except they perform subtraction, subtract the second argument
9806 from the first one, instead of addition.
9807
9808 @end deftypefn
9809
9810 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9811 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9812 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9813 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9814 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9815 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9816 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9817
9818 These built-in functions are similar to the add overflow checking built-in
9819 functions above, except they perform multiplication, instead of addition.
9820
9821 @end deftypefn
9822
9823 @node x86 specific memory model extensions for transactional memory
9824 @section x86-Specific Memory Model Extensions for Transactional Memory
9825
9826 The x86 architecture supports additional memory ordering flags
9827 to mark lock critical sections for hardware lock elision.
9828 These must be specified in addition to an existing memory order to
9829 atomic intrinsics.
9830
9831 @table @code
9832 @item __ATOMIC_HLE_ACQUIRE
9833 Start lock elision on a lock variable.
9834 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9835 @item __ATOMIC_HLE_RELEASE
9836 End lock elision on a lock variable.
9837 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9838 @end table
9839
9840 When a lock acquire fails, it is required for good performance to abort
9841 the transaction quickly. This can be done with a @code{_mm_pause}.
9842
9843 @smallexample
9844 #include <immintrin.h> // For _mm_pause
9845
9846 int lockvar;
9847
9848 /* Acquire lock with lock elision */
9849 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9850 _mm_pause(); /* Abort failed transaction */
9851 ...
9852 /* Free lock with lock elision */
9853 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9854 @end smallexample
9855
9856 @node Object Size Checking
9857 @section Object Size Checking Built-in Functions
9858 @findex __builtin_object_size
9859 @findex __builtin___memcpy_chk
9860 @findex __builtin___mempcpy_chk
9861 @findex __builtin___memmove_chk
9862 @findex __builtin___memset_chk
9863 @findex __builtin___strcpy_chk
9864 @findex __builtin___stpcpy_chk
9865 @findex __builtin___strncpy_chk
9866 @findex __builtin___strcat_chk
9867 @findex __builtin___strncat_chk
9868 @findex __builtin___sprintf_chk
9869 @findex __builtin___snprintf_chk
9870 @findex __builtin___vsprintf_chk
9871 @findex __builtin___vsnprintf_chk
9872 @findex __builtin___printf_chk
9873 @findex __builtin___vprintf_chk
9874 @findex __builtin___fprintf_chk
9875 @findex __builtin___vfprintf_chk
9876
9877 GCC implements a limited buffer overflow protection mechanism
9878 that can prevent some buffer overflow attacks.
9879
9880 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9881 is a built-in construct that returns a constant number of bytes from
9882 @var{ptr} to the end of the object @var{ptr} pointer points to
9883 (if known at compile time). @code{__builtin_object_size} never evaluates
9884 its arguments for side-effects. If there are any side-effects in them, it
9885 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9886 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9887 point to and all of them are known at compile time, the returned number
9888 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9889 0 and minimum if nonzero. If it is not possible to determine which objects
9890 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9891 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9892 for @var{type} 2 or 3.
9893
9894 @var{type} is an integer constant from 0 to 3. If the least significant
9895 bit is clear, objects are whole variables, if it is set, a closest
9896 surrounding subobject is considered the object a pointer points to.
9897 The second bit determines if maximum or minimum of remaining bytes
9898 is computed.
9899
9900 @smallexample
9901 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9902 char *p = &var.buf1[1], *q = &var.b;
9903
9904 /* Here the object p points to is var. */
9905 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9906 /* The subobject p points to is var.buf1. */
9907 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9908 /* The object q points to is var. */
9909 assert (__builtin_object_size (q, 0)
9910 == (char *) (&var + 1) - (char *) &var.b);
9911 /* The subobject q points to is var.b. */
9912 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9913 @end smallexample
9914 @end deftypefn
9915
9916 There are built-in functions added for many common string operation
9917 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9918 built-in is provided. This built-in has an additional last argument,
9919 which is the number of bytes remaining in object the @var{dest}
9920 argument points to or @code{(size_t) -1} if the size is not known.
9921
9922 The built-in functions are optimized into the normal string functions
9923 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9924 it is known at compile time that the destination object will not
9925 be overflown. If the compiler can determine at compile time the
9926 object will be always overflown, it issues a warning.
9927
9928 The intended use can be e.g.@:
9929
9930 @smallexample
9931 #undef memcpy
9932 #define bos0(dest) __builtin_object_size (dest, 0)
9933 #define memcpy(dest, src, n) \
9934 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9935
9936 char *volatile p;
9937 char buf[10];
9938 /* It is unknown what object p points to, so this is optimized
9939 into plain memcpy - no checking is possible. */
9940 memcpy (p, "abcde", n);
9941 /* Destination is known and length too. It is known at compile
9942 time there will be no overflow. */
9943 memcpy (&buf[5], "abcde", 5);
9944 /* Destination is known, but the length is not known at compile time.
9945 This will result in __memcpy_chk call that can check for overflow
9946 at run time. */
9947 memcpy (&buf[5], "abcde", n);
9948 /* Destination is known and it is known at compile time there will
9949 be overflow. There will be a warning and __memcpy_chk call that
9950 will abort the program at run time. */
9951 memcpy (&buf[6], "abcde", 5);
9952 @end smallexample
9953
9954 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9955 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9956 @code{strcat} and @code{strncat}.
9957
9958 There are also checking built-in functions for formatted output functions.
9959 @smallexample
9960 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9961 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9962 const char *fmt, ...);
9963 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9964 va_list ap);
9965 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9966 const char *fmt, va_list ap);
9967 @end smallexample
9968
9969 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9970 etc.@: functions and can contain implementation specific flags on what
9971 additional security measures the checking function might take, such as
9972 handling @code{%n} differently.
9973
9974 The @var{os} argument is the object size @var{s} points to, like in the
9975 other built-in functions. There is a small difference in the behavior
9976 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9977 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9978 the checking function is called with @var{os} argument set to
9979 @code{(size_t) -1}.
9980
9981 In addition to this, there are checking built-in functions
9982 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9983 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9984 These have just one additional argument, @var{flag}, right before
9985 format string @var{fmt}. If the compiler is able to optimize them to
9986 @code{fputc} etc.@: functions, it does, otherwise the checking function
9987 is called and the @var{flag} argument passed to it.
9988
9989 @node Pointer Bounds Checker builtins
9990 @section Pointer Bounds Checker Built-in Functions
9991 @cindex Pointer Bounds Checker builtins
9992 @findex __builtin___bnd_set_ptr_bounds
9993 @findex __builtin___bnd_narrow_ptr_bounds
9994 @findex __builtin___bnd_copy_ptr_bounds
9995 @findex __builtin___bnd_init_ptr_bounds
9996 @findex __builtin___bnd_null_ptr_bounds
9997 @findex __builtin___bnd_store_ptr_bounds
9998 @findex __builtin___bnd_chk_ptr_lbounds
9999 @findex __builtin___bnd_chk_ptr_ubounds
10000 @findex __builtin___bnd_chk_ptr_bounds
10001 @findex __builtin___bnd_get_ptr_lbound
10002 @findex __builtin___bnd_get_ptr_ubound
10003
10004 GCC provides a set of built-in functions to control Pointer Bounds Checker
10005 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10006 even if you compile with Pointer Bounds Checker off
10007 (@option{-fno-check-pointer-bounds}).
10008 The behavior may differ in such case as documented below.
10009
10010 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10011
10012 This built-in function returns a new pointer with the value of @var{q}, and
10013 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10014 Bounds Checker off, the built-in function just returns the first argument.
10015
10016 @smallexample
10017 extern void *__wrap_malloc (size_t n)
10018 @{
10019 void *p = (void *)__real_malloc (n);
10020 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10021 return __builtin___bnd_set_ptr_bounds (p, n);
10022 @}
10023 @end smallexample
10024
10025 @end deftypefn
10026
10027 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10028
10029 This built-in function returns a new pointer with the value of @var{p}
10030 and associates it with the narrowed bounds formed by the intersection
10031 of bounds associated with @var{q} and the bounds
10032 [@var{p}, @var{p} + @var{size} - 1].
10033 With Pointer Bounds Checker off, the built-in function just returns the first
10034 argument.
10035
10036 @smallexample
10037 void init_objects (object *objs, size_t size)
10038 @{
10039 size_t i;
10040 /* Initialize objects one-by-one passing pointers with bounds of
10041 an object, not the full array of objects. */
10042 for (i = 0; i < size; i++)
10043 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10044 sizeof(object)));
10045 @}
10046 @end smallexample
10047
10048 @end deftypefn
10049
10050 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10051
10052 This built-in function returns a new pointer with the value of @var{q},
10053 and associates it with the bounds already associated with pointer @var{r}.
10054 With Pointer Bounds Checker off, the built-in function just returns the first
10055 argument.
10056
10057 @smallexample
10058 /* Here is a way to get pointer to object's field but
10059 still with the full object's bounds. */
10060 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10061 objptr);
10062 @end smallexample
10063
10064 @end deftypefn
10065
10066 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10067
10068 This built-in function returns a new pointer with the value of @var{q}, and
10069 associates it with INIT (allowing full memory access) bounds. With Pointer
10070 Bounds Checker off, the built-in function just returns the first argument.
10071
10072 @end deftypefn
10073
10074 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10075
10076 This built-in function returns a new pointer with the value of @var{q}, and
10077 associates it with NULL (allowing no memory access) bounds. With Pointer
10078 Bounds Checker off, the built-in function just returns the first argument.
10079
10080 @end deftypefn
10081
10082 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10083
10084 This built-in function stores the bounds associated with pointer @var{ptr_val}
10085 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10086 bounds from legacy code without touching the associated pointer's memory when
10087 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10088 function call is ignored.
10089
10090 @end deftypefn
10091
10092 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10093
10094 This built-in function checks if the pointer @var{q} is within the lower
10095 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10096 function call is ignored.
10097
10098 @smallexample
10099 extern void *__wrap_memset (void *dst, int c, size_t len)
10100 @{
10101 if (len > 0)
10102 @{
10103 __builtin___bnd_chk_ptr_lbounds (dst);
10104 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10105 __real_memset (dst, c, len);
10106 @}
10107 return dst;
10108 @}
10109 @end smallexample
10110
10111 @end deftypefn
10112
10113 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10114
10115 This built-in function checks if the pointer @var{q} is within the upper
10116 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10117 function call is ignored.
10118
10119 @end deftypefn
10120
10121 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10122
10123 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10124 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10125 off, the built-in function call is ignored.
10126
10127 @smallexample
10128 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10129 @{
10130 if (n > 0)
10131 @{
10132 __bnd_chk_ptr_bounds (dst, n);
10133 __bnd_chk_ptr_bounds (src, n);
10134 __real_memcpy (dst, src, n);
10135 @}
10136 return dst;
10137 @}
10138 @end smallexample
10139
10140 @end deftypefn
10141
10142 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10143
10144 This built-in function returns the lower bound associated
10145 with the pointer @var{q}, as a pointer value.
10146 This is useful for debugging using @code{printf}.
10147 With Pointer Bounds Checker off, the built-in function returns 0.
10148
10149 @smallexample
10150 void *lb = __builtin___bnd_get_ptr_lbound (q);
10151 void *ub = __builtin___bnd_get_ptr_ubound (q);
10152 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10153 @end smallexample
10154
10155 @end deftypefn
10156
10157 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10158
10159 This built-in function returns the upper bound (which is a pointer) associated
10160 with the pointer @var{q}. With Pointer Bounds Checker off,
10161 the built-in function returns -1.
10162
10163 @end deftypefn
10164
10165 @node Cilk Plus Builtins
10166 @section Cilk Plus C/C++ Language Extension Built-in Functions
10167
10168 GCC provides support for the following built-in reduction functions if Cilk Plus
10169 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10170
10171 @itemize @bullet
10172 @item @code{__sec_implicit_index}
10173 @item @code{__sec_reduce}
10174 @item @code{__sec_reduce_add}
10175 @item @code{__sec_reduce_all_nonzero}
10176 @item @code{__sec_reduce_all_zero}
10177 @item @code{__sec_reduce_any_nonzero}
10178 @item @code{__sec_reduce_any_zero}
10179 @item @code{__sec_reduce_max}
10180 @item @code{__sec_reduce_min}
10181 @item @code{__sec_reduce_max_ind}
10182 @item @code{__sec_reduce_min_ind}
10183 @item @code{__sec_reduce_mul}
10184 @item @code{__sec_reduce_mutating}
10185 @end itemize
10186
10187 Further details and examples about these built-in functions are described
10188 in the Cilk Plus language manual which can be found at
10189 @uref{http://www.cilkplus.org}.
10190
10191 @node Other Builtins
10192 @section Other Built-in Functions Provided by GCC
10193 @cindex built-in functions
10194 @findex __builtin_alloca
10195 @findex __builtin_alloca_with_align
10196 @findex __builtin_call_with_static_chain
10197 @findex __builtin_fpclassify
10198 @findex __builtin_isfinite
10199 @findex __builtin_isnormal
10200 @findex __builtin_isgreater
10201 @findex __builtin_isgreaterequal
10202 @findex __builtin_isinf_sign
10203 @findex __builtin_isless
10204 @findex __builtin_islessequal
10205 @findex __builtin_islessgreater
10206 @findex __builtin_isunordered
10207 @findex __builtin_powi
10208 @findex __builtin_powif
10209 @findex __builtin_powil
10210 @findex _Exit
10211 @findex _exit
10212 @findex abort
10213 @findex abs
10214 @findex acos
10215 @findex acosf
10216 @findex acosh
10217 @findex acoshf
10218 @findex acoshl
10219 @findex acosl
10220 @findex alloca
10221 @findex asin
10222 @findex asinf
10223 @findex asinh
10224 @findex asinhf
10225 @findex asinhl
10226 @findex asinl
10227 @findex atan
10228 @findex atan2
10229 @findex atan2f
10230 @findex atan2l
10231 @findex atanf
10232 @findex atanh
10233 @findex atanhf
10234 @findex atanhl
10235 @findex atanl
10236 @findex bcmp
10237 @findex bzero
10238 @findex cabs
10239 @findex cabsf
10240 @findex cabsl
10241 @findex cacos
10242 @findex cacosf
10243 @findex cacosh
10244 @findex cacoshf
10245 @findex cacoshl
10246 @findex cacosl
10247 @findex calloc
10248 @findex carg
10249 @findex cargf
10250 @findex cargl
10251 @findex casin
10252 @findex casinf
10253 @findex casinh
10254 @findex casinhf
10255 @findex casinhl
10256 @findex casinl
10257 @findex catan
10258 @findex catanf
10259 @findex catanh
10260 @findex catanhf
10261 @findex catanhl
10262 @findex catanl
10263 @findex cbrt
10264 @findex cbrtf
10265 @findex cbrtl
10266 @findex ccos
10267 @findex ccosf
10268 @findex ccosh
10269 @findex ccoshf
10270 @findex ccoshl
10271 @findex ccosl
10272 @findex ceil
10273 @findex ceilf
10274 @findex ceill
10275 @findex cexp
10276 @findex cexpf
10277 @findex cexpl
10278 @findex cimag
10279 @findex cimagf
10280 @findex cimagl
10281 @findex clog
10282 @findex clogf
10283 @findex clogl
10284 @findex clog10
10285 @findex clog10f
10286 @findex clog10l
10287 @findex conj
10288 @findex conjf
10289 @findex conjl
10290 @findex copysign
10291 @findex copysignf
10292 @findex copysignl
10293 @findex cos
10294 @findex cosf
10295 @findex cosh
10296 @findex coshf
10297 @findex coshl
10298 @findex cosl
10299 @findex cpow
10300 @findex cpowf
10301 @findex cpowl
10302 @findex cproj
10303 @findex cprojf
10304 @findex cprojl
10305 @findex creal
10306 @findex crealf
10307 @findex creall
10308 @findex csin
10309 @findex csinf
10310 @findex csinh
10311 @findex csinhf
10312 @findex csinhl
10313 @findex csinl
10314 @findex csqrt
10315 @findex csqrtf
10316 @findex csqrtl
10317 @findex ctan
10318 @findex ctanf
10319 @findex ctanh
10320 @findex ctanhf
10321 @findex ctanhl
10322 @findex ctanl
10323 @findex dcgettext
10324 @findex dgettext
10325 @findex drem
10326 @findex dremf
10327 @findex dreml
10328 @findex erf
10329 @findex erfc
10330 @findex erfcf
10331 @findex erfcl
10332 @findex erff
10333 @findex erfl
10334 @findex exit
10335 @findex exp
10336 @findex exp10
10337 @findex exp10f
10338 @findex exp10l
10339 @findex exp2
10340 @findex exp2f
10341 @findex exp2l
10342 @findex expf
10343 @findex expl
10344 @findex expm1
10345 @findex expm1f
10346 @findex expm1l
10347 @findex fabs
10348 @findex fabsf
10349 @findex fabsl
10350 @findex fdim
10351 @findex fdimf
10352 @findex fdiml
10353 @findex ffs
10354 @findex floor
10355 @findex floorf
10356 @findex floorl
10357 @findex fma
10358 @findex fmaf
10359 @findex fmal
10360 @findex fmax
10361 @findex fmaxf
10362 @findex fmaxl
10363 @findex fmin
10364 @findex fminf
10365 @findex fminl
10366 @findex fmod
10367 @findex fmodf
10368 @findex fmodl
10369 @findex fprintf
10370 @findex fprintf_unlocked
10371 @findex fputs
10372 @findex fputs_unlocked
10373 @findex frexp
10374 @findex frexpf
10375 @findex frexpl
10376 @findex fscanf
10377 @findex gamma
10378 @findex gammaf
10379 @findex gammal
10380 @findex gamma_r
10381 @findex gammaf_r
10382 @findex gammal_r
10383 @findex gettext
10384 @findex hypot
10385 @findex hypotf
10386 @findex hypotl
10387 @findex ilogb
10388 @findex ilogbf
10389 @findex ilogbl
10390 @findex imaxabs
10391 @findex index
10392 @findex isalnum
10393 @findex isalpha
10394 @findex isascii
10395 @findex isblank
10396 @findex iscntrl
10397 @findex isdigit
10398 @findex isgraph
10399 @findex islower
10400 @findex isprint
10401 @findex ispunct
10402 @findex isspace
10403 @findex isupper
10404 @findex iswalnum
10405 @findex iswalpha
10406 @findex iswblank
10407 @findex iswcntrl
10408 @findex iswdigit
10409 @findex iswgraph
10410 @findex iswlower
10411 @findex iswprint
10412 @findex iswpunct
10413 @findex iswspace
10414 @findex iswupper
10415 @findex iswxdigit
10416 @findex isxdigit
10417 @findex j0
10418 @findex j0f
10419 @findex j0l
10420 @findex j1
10421 @findex j1f
10422 @findex j1l
10423 @findex jn
10424 @findex jnf
10425 @findex jnl
10426 @findex labs
10427 @findex ldexp
10428 @findex ldexpf
10429 @findex ldexpl
10430 @findex lgamma
10431 @findex lgammaf
10432 @findex lgammal
10433 @findex lgamma_r
10434 @findex lgammaf_r
10435 @findex lgammal_r
10436 @findex llabs
10437 @findex llrint
10438 @findex llrintf
10439 @findex llrintl
10440 @findex llround
10441 @findex llroundf
10442 @findex llroundl
10443 @findex log
10444 @findex log10
10445 @findex log10f
10446 @findex log10l
10447 @findex log1p
10448 @findex log1pf
10449 @findex log1pl
10450 @findex log2
10451 @findex log2f
10452 @findex log2l
10453 @findex logb
10454 @findex logbf
10455 @findex logbl
10456 @findex logf
10457 @findex logl
10458 @findex lrint
10459 @findex lrintf
10460 @findex lrintl
10461 @findex lround
10462 @findex lroundf
10463 @findex lroundl
10464 @findex malloc
10465 @findex memchr
10466 @findex memcmp
10467 @findex memcpy
10468 @findex mempcpy
10469 @findex memset
10470 @findex modf
10471 @findex modff
10472 @findex modfl
10473 @findex nearbyint
10474 @findex nearbyintf
10475 @findex nearbyintl
10476 @findex nextafter
10477 @findex nextafterf
10478 @findex nextafterl
10479 @findex nexttoward
10480 @findex nexttowardf
10481 @findex nexttowardl
10482 @findex pow
10483 @findex pow10
10484 @findex pow10f
10485 @findex pow10l
10486 @findex powf
10487 @findex powl
10488 @findex printf
10489 @findex printf_unlocked
10490 @findex putchar
10491 @findex puts
10492 @findex remainder
10493 @findex remainderf
10494 @findex remainderl
10495 @findex remquo
10496 @findex remquof
10497 @findex remquol
10498 @findex rindex
10499 @findex rint
10500 @findex rintf
10501 @findex rintl
10502 @findex round
10503 @findex roundf
10504 @findex roundl
10505 @findex scalb
10506 @findex scalbf
10507 @findex scalbl
10508 @findex scalbln
10509 @findex scalblnf
10510 @findex scalblnf
10511 @findex scalbn
10512 @findex scalbnf
10513 @findex scanfnl
10514 @findex signbit
10515 @findex signbitf
10516 @findex signbitl
10517 @findex signbitd32
10518 @findex signbitd64
10519 @findex signbitd128
10520 @findex significand
10521 @findex significandf
10522 @findex significandl
10523 @findex sin
10524 @findex sincos
10525 @findex sincosf
10526 @findex sincosl
10527 @findex sinf
10528 @findex sinh
10529 @findex sinhf
10530 @findex sinhl
10531 @findex sinl
10532 @findex snprintf
10533 @findex sprintf
10534 @findex sqrt
10535 @findex sqrtf
10536 @findex sqrtl
10537 @findex sscanf
10538 @findex stpcpy
10539 @findex stpncpy
10540 @findex strcasecmp
10541 @findex strcat
10542 @findex strchr
10543 @findex strcmp
10544 @findex strcpy
10545 @findex strcspn
10546 @findex strdup
10547 @findex strfmon
10548 @findex strftime
10549 @findex strlen
10550 @findex strncasecmp
10551 @findex strncat
10552 @findex strncmp
10553 @findex strncpy
10554 @findex strndup
10555 @findex strpbrk
10556 @findex strrchr
10557 @findex strspn
10558 @findex strstr
10559 @findex tan
10560 @findex tanf
10561 @findex tanh
10562 @findex tanhf
10563 @findex tanhl
10564 @findex tanl
10565 @findex tgamma
10566 @findex tgammaf
10567 @findex tgammal
10568 @findex toascii
10569 @findex tolower
10570 @findex toupper
10571 @findex towlower
10572 @findex towupper
10573 @findex trunc
10574 @findex truncf
10575 @findex truncl
10576 @findex vfprintf
10577 @findex vfscanf
10578 @findex vprintf
10579 @findex vscanf
10580 @findex vsnprintf
10581 @findex vsprintf
10582 @findex vsscanf
10583 @findex y0
10584 @findex y0f
10585 @findex y0l
10586 @findex y1
10587 @findex y1f
10588 @findex y1l
10589 @findex yn
10590 @findex ynf
10591 @findex ynl
10592
10593 GCC provides a large number of built-in functions other than the ones
10594 mentioned above. Some of these are for internal use in the processing
10595 of exceptions or variable-length argument lists and are not
10596 documented here because they may change from time to time; we do not
10597 recommend general use of these functions.
10598
10599 The remaining functions are provided for optimization purposes.
10600
10601 With the exception of built-ins that have library equivalents such as
10602 the standard C library functions discussed below, or that expand to
10603 library calls, GCC built-in functions are always expanded inline and
10604 thus do not have corresponding entry points and their address cannot
10605 be obtained. Attempting to use them in an expression other than
10606 a function call results in a compile-time error.
10607
10608 @opindex fno-builtin
10609 GCC includes built-in versions of many of the functions in the standard
10610 C library. These functions come in two forms: one whose names start with
10611 the @code{__builtin_} prefix, and the other without. Both forms have the
10612 same type (including prototype), the same address (when their address is
10613 taken), and the same meaning as the C library functions even if you specify
10614 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10615 functions are only optimized in certain cases; if they are not optimized in
10616 a particular case, a call to the library function is emitted.
10617
10618 @opindex ansi
10619 @opindex std
10620 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10621 @option{-std=c99} or @option{-std=c11}), the functions
10622 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10623 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10624 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10625 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10626 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10627 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10628 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10629 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10630 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10631 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10632 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10633 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10634 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10635 @code{significandl}, @code{significand}, @code{sincosf},
10636 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10637 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10638 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10639 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10640 @code{yn}
10641 may be handled as built-in functions.
10642 All these functions have corresponding versions
10643 prefixed with @code{__builtin_}, which may be used even in strict C90
10644 mode.
10645
10646 The ISO C99 functions
10647 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10648 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10649 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10650 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10651 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10652 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10653 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10654 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10655 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10656 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10657 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10658 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10659 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10660 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10661 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10662 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10663 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10664 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10665 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10666 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10667 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10668 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10669 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10670 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10671 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10672 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10673 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10674 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10675 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10676 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10677 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10678 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10679 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10680 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10681 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10682 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10683 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10684 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10685 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10686 are handled as built-in functions
10687 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10688
10689 There are also built-in versions of the ISO C99 functions
10690 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10691 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10692 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10693 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10694 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10695 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10696 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10697 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10698 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10699 that are recognized in any mode since ISO C90 reserves these names for
10700 the purpose to which ISO C99 puts them. All these functions have
10701 corresponding versions prefixed with @code{__builtin_}.
10702
10703 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10704 @code{clog10l} which names are reserved by ISO C99 for future use.
10705 All these functions have versions prefixed with @code{__builtin_}.
10706
10707 The ISO C94 functions
10708 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10709 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10710 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10711 @code{towupper}
10712 are handled as built-in functions
10713 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10714
10715 The ISO C90 functions
10716 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10717 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10718 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10719 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10720 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10721 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10722 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10723 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10724 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10725 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10726 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10727 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10728 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10729 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10730 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10731 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10732 are all recognized as built-in functions unless
10733 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10734 is specified for an individual function). All of these functions have
10735 corresponding versions prefixed with @code{__builtin_}.
10736
10737 GCC provides built-in versions of the ISO C99 floating-point comparison
10738 macros that avoid raising exceptions for unordered operands. They have
10739 the same names as the standard macros ( @code{isgreater},
10740 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10741 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10742 prefixed. We intend for a library implementor to be able to simply
10743 @code{#define} each standard macro to its built-in equivalent.
10744 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10745 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10746 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10747 built-in functions appear both with and without the @code{__builtin_} prefix.
10748
10749 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10750 The @code{__builtin_alloca} function must be called at block scope.
10751 The function allocates an object @var{size} bytes large on the stack
10752 of the calling function. The object is aligned on the default stack
10753 alignment boundary for the target determined by the
10754 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10755 function returns a pointer to the first byte of the allocated object.
10756 The lifetime of the allocated object ends just before the calling
10757 function returns to its caller. This is so even when
10758 @code{__builtin_alloca} is called within a nested block.
10759
10760 For example, the following function allocates eight objects of @code{n}
10761 bytes each on the stack, storing a pointer to each in consecutive elements
10762 of the array @code{a}. It then passes the array to function @code{g}
10763 which can safely use the storage pointed to by each of the array elements.
10764
10765 @smallexample
10766 void f (unsigned n)
10767 @{
10768 void *a [8];
10769 for (int i = 0; i != 8; ++i)
10770 a [i] = __builtin_alloca (n);
10771
10772 g (a, n); // @r{safe}
10773 @}
10774 @end smallexample
10775
10776 Since the @code{__builtin_alloca} function doesn't validate its argument
10777 it is the responsibility of its caller to make sure the argument doesn't
10778 cause it to exceed the stack size limit.
10779 The @code{__builtin_alloca} function is provided to make it possible to
10780 allocate on the stack arrays of bytes with an upper bound that may be
10781 computed at run time. Since C99 Variable Length Arrays offer
10782 similar functionality under a portable, more convenient, and safer
10783 interface they are recommended instead, in both C99 and C++ programs
10784 where GCC provides them as an extension.
10785 @xref{Variable Length}, for details.
10786
10787 @end deftypefn
10788
10789 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10790 The @code{__builtin_alloca_with_align} function must be called at block
10791 scope. The function allocates an object @var{size} bytes large on
10792 the stack of the calling function. The allocated object is aligned on
10793 the boundary specified by the argument @var{alignment} whose unit is given
10794 in bits (not bytes). The @var{size} argument must be positive and not
10795 exceed the stack size limit. The @var{alignment} argument must be a constant
10796 integer expression that evaluates to a power of 2 greater than or equal to
10797 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10798 with other values are rejected with an error indicating the valid bounds.
10799 The function returns a pointer to the first byte of the allocated object.
10800 The lifetime of the allocated object ends at the end of the block in which
10801 the function was called. The allocated storage is released no later than
10802 just before the calling function returns to its caller, but may be released
10803 at the end of the block in which the function was called.
10804
10805 For example, in the following function the call to @code{g} is unsafe
10806 because when @code{overalign} is non-zero, the space allocated by
10807 @code{__builtin_alloca_with_align} may have been released at the end
10808 of the @code{if} statement in which it was called.
10809
10810 @smallexample
10811 void f (unsigned n, bool overalign)
10812 @{
10813 void *p;
10814 if (overalign)
10815 p = __builtin_alloca_with_align (n, 64 /* bits */);
10816 else
10817 p = __builtin_alloc (n);
10818
10819 g (p, n); // @r{unsafe}
10820 @}
10821 @end smallexample
10822
10823 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10824 @var{size} argument it is the responsibility of its caller to make sure
10825 the argument doesn't cause it to exceed the stack size limit.
10826 The @code{__builtin_alloca_with_align} function is provided to make
10827 it possible to allocate on the stack overaligned arrays of bytes with
10828 an upper bound that may be computed at run time. Since C99
10829 Variable Length Arrays offer the same functionality under
10830 a portable, more convenient, and safer interface they are recommended
10831 instead, in both C99 and C++ programs where GCC provides them as
10832 an extension. @xref{Variable Length}, for details.
10833
10834 @end deftypefn
10835
10836 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10837
10838 You can use the built-in function @code{__builtin_types_compatible_p} to
10839 determine whether two types are the same.
10840
10841 This built-in function returns 1 if the unqualified versions of the
10842 types @var{type1} and @var{type2} (which are types, not expressions) are
10843 compatible, 0 otherwise. The result of this built-in function can be
10844 used in integer constant expressions.
10845
10846 This built-in function ignores top level qualifiers (e.g., @code{const},
10847 @code{volatile}). For example, @code{int} is equivalent to @code{const
10848 int}.
10849
10850 The type @code{int[]} and @code{int[5]} are compatible. On the other
10851 hand, @code{int} and @code{char *} are not compatible, even if the size
10852 of their types, on the particular architecture are the same. Also, the
10853 amount of pointer indirection is taken into account when determining
10854 similarity. Consequently, @code{short *} is not similar to
10855 @code{short **}. Furthermore, two types that are typedefed are
10856 considered compatible if their underlying types are compatible.
10857
10858 An @code{enum} type is not considered to be compatible with another
10859 @code{enum} type even if both are compatible with the same integer
10860 type; this is what the C standard specifies.
10861 For example, @code{enum @{foo, bar@}} is not similar to
10862 @code{enum @{hot, dog@}}.
10863
10864 You typically use this function in code whose execution varies
10865 depending on the arguments' types. For example:
10866
10867 @smallexample
10868 #define foo(x) \
10869 (@{ \
10870 typeof (x) tmp = (x); \
10871 if (__builtin_types_compatible_p (typeof (x), long double)) \
10872 tmp = foo_long_double (tmp); \
10873 else if (__builtin_types_compatible_p (typeof (x), double)) \
10874 tmp = foo_double (tmp); \
10875 else if (__builtin_types_compatible_p (typeof (x), float)) \
10876 tmp = foo_float (tmp); \
10877 else \
10878 abort (); \
10879 tmp; \
10880 @})
10881 @end smallexample
10882
10883 @emph{Note:} This construct is only available for C@.
10884
10885 @end deftypefn
10886
10887 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10888
10889 The @var{call_exp} expression must be a function call, and the
10890 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10891 is passed to the function call in the target's static chain location.
10892 The result of builtin is the result of the function call.
10893
10894 @emph{Note:} This builtin is only available for C@.
10895 This builtin can be used to call Go closures from C.
10896
10897 @end deftypefn
10898
10899 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10900
10901 You can use the built-in function @code{__builtin_choose_expr} to
10902 evaluate code depending on the value of a constant expression. This
10903 built-in function returns @var{exp1} if @var{const_exp}, which is an
10904 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10905
10906 This built-in function is analogous to the @samp{? :} operator in C,
10907 except that the expression returned has its type unaltered by promotion
10908 rules. Also, the built-in function does not evaluate the expression
10909 that is not chosen. For example, if @var{const_exp} evaluates to true,
10910 @var{exp2} is not evaluated even if it has side-effects.
10911
10912 This built-in function can return an lvalue if the chosen argument is an
10913 lvalue.
10914
10915 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10916 type. Similarly, if @var{exp2} is returned, its return type is the same
10917 as @var{exp2}.
10918
10919 Example:
10920
10921 @smallexample
10922 #define foo(x) \
10923 __builtin_choose_expr ( \
10924 __builtin_types_compatible_p (typeof (x), double), \
10925 foo_double (x), \
10926 __builtin_choose_expr ( \
10927 __builtin_types_compatible_p (typeof (x), float), \
10928 foo_float (x), \
10929 /* @r{The void expression results in a compile-time error} \
10930 @r{when assigning the result to something.} */ \
10931 (void)0))
10932 @end smallexample
10933
10934 @emph{Note:} This construct is only available for C@. Furthermore, the
10935 unused expression (@var{exp1} or @var{exp2} depending on the value of
10936 @var{const_exp}) may still generate syntax errors. This may change in
10937 future revisions.
10938
10939 @end deftypefn
10940
10941 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10942
10943 The built-in function @code{__builtin_complex} is provided for use in
10944 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10945 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10946 real binary floating-point type, and the result has the corresponding
10947 complex type with real and imaginary parts @var{real} and @var{imag}.
10948 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10949 infinities, NaNs and negative zeros are involved.
10950
10951 @end deftypefn
10952
10953 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10954 You can use the built-in function @code{__builtin_constant_p} to
10955 determine if a value is known to be constant at compile time and hence
10956 that GCC can perform constant-folding on expressions involving that
10957 value. The argument of the function is the value to test. The function
10958 returns the integer 1 if the argument is known to be a compile-time
10959 constant and 0 if it is not known to be a compile-time constant. A
10960 return of 0 does not indicate that the value is @emph{not} a constant,
10961 but merely that GCC cannot prove it is a constant with the specified
10962 value of the @option{-O} option.
10963
10964 You typically use this function in an embedded application where
10965 memory is a critical resource. If you have some complex calculation,
10966 you may want it to be folded if it involves constants, but need to call
10967 a function if it does not. For example:
10968
10969 @smallexample
10970 #define Scale_Value(X) \
10971 (__builtin_constant_p (X) \
10972 ? ((X) * SCALE + OFFSET) : Scale (X))
10973 @end smallexample
10974
10975 You may use this built-in function in either a macro or an inline
10976 function. However, if you use it in an inlined function and pass an
10977 argument of the function as the argument to the built-in, GCC
10978 never returns 1 when you call the inline function with a string constant
10979 or compound literal (@pxref{Compound Literals}) and does not return 1
10980 when you pass a constant numeric value to the inline function unless you
10981 specify the @option{-O} option.
10982
10983 You may also use @code{__builtin_constant_p} in initializers for static
10984 data. For instance, you can write
10985
10986 @smallexample
10987 static const int table[] = @{
10988 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10989 /* @r{@dots{}} */
10990 @};
10991 @end smallexample
10992
10993 @noindent
10994 This is an acceptable initializer even if @var{EXPRESSION} is not a
10995 constant expression, including the case where
10996 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10997 folded to a constant but @var{EXPRESSION} contains operands that are
10998 not otherwise permitted in a static initializer (for example,
10999 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11000 built-in in this case, because it has no opportunity to perform
11001 optimization.
11002 @end deftypefn
11003
11004 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11005 @opindex fprofile-arcs
11006 You may use @code{__builtin_expect} to provide the compiler with
11007 branch prediction information. In general, you should prefer to
11008 use actual profile feedback for this (@option{-fprofile-arcs}), as
11009 programmers are notoriously bad at predicting how their programs
11010 actually perform. However, there are applications in which this
11011 data is hard to collect.
11012
11013 The return value is the value of @var{exp}, which should be an integral
11014 expression. The semantics of the built-in are that it is expected that
11015 @var{exp} == @var{c}. For example:
11016
11017 @smallexample
11018 if (__builtin_expect (x, 0))
11019 foo ();
11020 @end smallexample
11021
11022 @noindent
11023 indicates that we do not expect to call @code{foo}, since
11024 we expect @code{x} to be zero. Since you are limited to integral
11025 expressions for @var{exp}, you should use constructions such as
11026
11027 @smallexample
11028 if (__builtin_expect (ptr != NULL, 1))
11029 foo (*ptr);
11030 @end smallexample
11031
11032 @noindent
11033 when testing pointer or floating-point values.
11034 @end deftypefn
11035
11036 @deftypefn {Built-in Function} void __builtin_trap (void)
11037 This function causes the program to exit abnormally. GCC implements
11038 this function by using a target-dependent mechanism (such as
11039 intentionally executing an illegal instruction) or by calling
11040 @code{abort}. The mechanism used may vary from release to release so
11041 you should not rely on any particular implementation.
11042 @end deftypefn
11043
11044 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11045 If control flow reaches the point of the @code{__builtin_unreachable},
11046 the program is undefined. It is useful in situations where the
11047 compiler cannot deduce the unreachability of the code.
11048
11049 One such case is immediately following an @code{asm} statement that
11050 either never terminates, or one that transfers control elsewhere
11051 and never returns. In this example, without the
11052 @code{__builtin_unreachable}, GCC issues a warning that control
11053 reaches the end of a non-void function. It also generates code
11054 to return after the @code{asm}.
11055
11056 @smallexample
11057 int f (int c, int v)
11058 @{
11059 if (c)
11060 @{
11061 return v;
11062 @}
11063 else
11064 @{
11065 asm("jmp error_handler");
11066 __builtin_unreachable ();
11067 @}
11068 @}
11069 @end smallexample
11070
11071 @noindent
11072 Because the @code{asm} statement unconditionally transfers control out
11073 of the function, control never reaches the end of the function
11074 body. The @code{__builtin_unreachable} is in fact unreachable and
11075 communicates this fact to the compiler.
11076
11077 Another use for @code{__builtin_unreachable} is following a call a
11078 function that never returns but that is not declared
11079 @code{__attribute__((noreturn))}, as in this example:
11080
11081 @smallexample
11082 void function_that_never_returns (void);
11083
11084 int g (int c)
11085 @{
11086 if (c)
11087 @{
11088 return 1;
11089 @}
11090 else
11091 @{
11092 function_that_never_returns ();
11093 __builtin_unreachable ();
11094 @}
11095 @}
11096 @end smallexample
11097
11098 @end deftypefn
11099
11100 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11101 This function returns its first argument, and allows the compiler
11102 to assume that the returned pointer is at least @var{align} bytes
11103 aligned. This built-in can have either two or three arguments,
11104 if it has three, the third argument should have integer type, and
11105 if it is nonzero means misalignment offset. For example:
11106
11107 @smallexample
11108 void *x = __builtin_assume_aligned (arg, 16);
11109 @end smallexample
11110
11111 @noindent
11112 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11113 16-byte aligned, while:
11114
11115 @smallexample
11116 void *x = __builtin_assume_aligned (arg, 32, 8);
11117 @end smallexample
11118
11119 @noindent
11120 means that the compiler can assume for @code{x}, set to @code{arg}, that
11121 @code{(char *) x - 8} is 32-byte aligned.
11122 @end deftypefn
11123
11124 @deftypefn {Built-in Function} int __builtin_LINE ()
11125 This function is the equivalent to the preprocessor @code{__LINE__}
11126 macro and returns the line number of the invocation of the built-in.
11127 In a C++ default argument for a function @var{F}, it gets the line number of
11128 the call to @var{F}.
11129 @end deftypefn
11130
11131 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11132 This function is the equivalent to the preprocessor @code{__FUNCTION__}
11133 macro and returns the function name the invocation of the built-in is in.
11134 @end deftypefn
11135
11136 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11137 This function is the equivalent to the preprocessor @code{__FILE__}
11138 macro and returns the file name the invocation of the built-in is in.
11139 In a C++ default argument for a function @var{F}, it gets the file name of
11140 the call to @var{F}.
11141 @end deftypefn
11142
11143 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11144 This function is used to flush the processor's instruction cache for
11145 the region of memory between @var{begin} inclusive and @var{end}
11146 exclusive. Some targets require that the instruction cache be
11147 flushed, after modifying memory containing code, in order to obtain
11148 deterministic behavior.
11149
11150 If the target does not require instruction cache flushes,
11151 @code{__builtin___clear_cache} has no effect. Otherwise either
11152 instructions are emitted in-line to clear the instruction cache or a
11153 call to the @code{__clear_cache} function in libgcc is made.
11154 @end deftypefn
11155
11156 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11157 This function is used to minimize cache-miss latency by moving data into
11158 a cache before it is accessed.
11159 You can insert calls to @code{__builtin_prefetch} into code for which
11160 you know addresses of data in memory that is likely to be accessed soon.
11161 If the target supports them, data prefetch instructions are generated.
11162 If the prefetch is done early enough before the access then the data will
11163 be in the cache by the time it is accessed.
11164
11165 The value of @var{addr} is the address of the memory to prefetch.
11166 There are two optional arguments, @var{rw} and @var{locality}.
11167 The value of @var{rw} is a compile-time constant one or zero; one
11168 means that the prefetch is preparing for a write to the memory address
11169 and zero, the default, means that the prefetch is preparing for a read.
11170 The value @var{locality} must be a compile-time constant integer between
11171 zero and three. A value of zero means that the data has no temporal
11172 locality, so it need not be left in the cache after the access. A value
11173 of three means that the data has a high degree of temporal locality and
11174 should be left in all levels of cache possible. Values of one and two
11175 mean, respectively, a low or moderate degree of temporal locality. The
11176 default is three.
11177
11178 @smallexample
11179 for (i = 0; i < n; i++)
11180 @{
11181 a[i] = a[i] + b[i];
11182 __builtin_prefetch (&a[i+j], 1, 1);
11183 __builtin_prefetch (&b[i+j], 0, 1);
11184 /* @r{@dots{}} */
11185 @}
11186 @end smallexample
11187
11188 Data prefetch does not generate faults if @var{addr} is invalid, but
11189 the address expression itself must be valid. For example, a prefetch
11190 of @code{p->next} does not fault if @code{p->next} is not a valid
11191 address, but evaluation faults if @code{p} is not a valid address.
11192
11193 If the target does not support data prefetch, the address expression
11194 is evaluated if it includes side effects but no other code is generated
11195 and GCC does not issue a warning.
11196 @end deftypefn
11197
11198 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11199 Returns a positive infinity, if supported by the floating-point format,
11200 else @code{DBL_MAX}. This function is suitable for implementing the
11201 ISO C macro @code{HUGE_VAL}.
11202 @end deftypefn
11203
11204 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11205 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11206 @end deftypefn
11207
11208 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11209 Similar to @code{__builtin_huge_val}, except the return
11210 type is @code{long double}.
11211 @end deftypefn
11212
11213 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11214 This built-in implements the C99 fpclassify functionality. The first
11215 five int arguments should be the target library's notion of the
11216 possible FP classes and are used for return values. They must be
11217 constant values and they must appear in this order: @code{FP_NAN},
11218 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11219 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11220 to classify. GCC treats the last argument as type-generic, which
11221 means it does not do default promotion from float to double.
11222 @end deftypefn
11223
11224 @deftypefn {Built-in Function} double __builtin_inf (void)
11225 Similar to @code{__builtin_huge_val}, except a warning is generated
11226 if the target floating-point format does not support infinities.
11227 @end deftypefn
11228
11229 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11230 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11231 @end deftypefn
11232
11233 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11234 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11235 @end deftypefn
11236
11237 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11238 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11239 @end deftypefn
11240
11241 @deftypefn {Built-in Function} float __builtin_inff (void)
11242 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11243 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11244 @end deftypefn
11245
11246 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11247 Similar to @code{__builtin_inf}, except the return
11248 type is @code{long double}.
11249 @end deftypefn
11250
11251 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11252 Similar to @code{isinf}, except the return value is -1 for
11253 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11254 Note while the parameter list is an
11255 ellipsis, this function only accepts exactly one floating-point
11256 argument. GCC treats this parameter as type-generic, which means it
11257 does not do default promotion from float to double.
11258 @end deftypefn
11259
11260 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11261 This is an implementation of the ISO C99 function @code{nan}.
11262
11263 Since ISO C99 defines this function in terms of @code{strtod}, which we
11264 do not implement, a description of the parsing is in order. The string
11265 is parsed as by @code{strtol}; that is, the base is recognized by
11266 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11267 in the significand such that the least significant bit of the number
11268 is at the least significant bit of the significand. The number is
11269 truncated to fit the significand field provided. The significand is
11270 forced to be a quiet NaN@.
11271
11272 This function, if given a string literal all of which would have been
11273 consumed by @code{strtol}, is evaluated early enough that it is considered a
11274 compile-time constant.
11275 @end deftypefn
11276
11277 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11278 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11279 @end deftypefn
11280
11281 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11282 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11283 @end deftypefn
11284
11285 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11286 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11287 @end deftypefn
11288
11289 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11290 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11291 @end deftypefn
11292
11293 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11294 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11295 @end deftypefn
11296
11297 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11298 Similar to @code{__builtin_nan}, except the significand is forced
11299 to be a signaling NaN@. The @code{nans} function is proposed by
11300 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11301 @end deftypefn
11302
11303 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11304 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11305 @end deftypefn
11306
11307 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11308 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11309 @end deftypefn
11310
11311 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11312 Returns one plus the index of the least significant 1-bit of @var{x}, or
11313 if @var{x} is zero, returns zero.
11314 @end deftypefn
11315
11316 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11317 Returns the number of leading 0-bits in @var{x}, starting at the most
11318 significant bit position. If @var{x} is 0, the result is undefined.
11319 @end deftypefn
11320
11321 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11322 Returns the number of trailing 0-bits in @var{x}, starting at the least
11323 significant bit position. If @var{x} is 0, the result is undefined.
11324 @end deftypefn
11325
11326 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11327 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11328 number of bits following the most significant bit that are identical
11329 to it. There are no special cases for 0 or other values.
11330 @end deftypefn
11331
11332 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11333 Returns the number of 1-bits in @var{x}.
11334 @end deftypefn
11335
11336 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11337 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11338 modulo 2.
11339 @end deftypefn
11340
11341 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11342 Similar to @code{__builtin_ffs}, except the argument type is
11343 @code{long}.
11344 @end deftypefn
11345
11346 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11347 Similar to @code{__builtin_clz}, except the argument type is
11348 @code{unsigned long}.
11349 @end deftypefn
11350
11351 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11352 Similar to @code{__builtin_ctz}, except the argument type is
11353 @code{unsigned long}.
11354 @end deftypefn
11355
11356 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11357 Similar to @code{__builtin_clrsb}, except the argument type is
11358 @code{long}.
11359 @end deftypefn
11360
11361 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11362 Similar to @code{__builtin_popcount}, except the argument type is
11363 @code{unsigned long}.
11364 @end deftypefn
11365
11366 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11367 Similar to @code{__builtin_parity}, except the argument type is
11368 @code{unsigned long}.
11369 @end deftypefn
11370
11371 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11372 Similar to @code{__builtin_ffs}, except the argument type is
11373 @code{long long}.
11374 @end deftypefn
11375
11376 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11377 Similar to @code{__builtin_clz}, except the argument type is
11378 @code{unsigned long long}.
11379 @end deftypefn
11380
11381 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11382 Similar to @code{__builtin_ctz}, except the argument type is
11383 @code{unsigned long long}.
11384 @end deftypefn
11385
11386 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11387 Similar to @code{__builtin_clrsb}, except the argument type is
11388 @code{long long}.
11389 @end deftypefn
11390
11391 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11392 Similar to @code{__builtin_popcount}, except the argument type is
11393 @code{unsigned long long}.
11394 @end deftypefn
11395
11396 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11397 Similar to @code{__builtin_parity}, except the argument type is
11398 @code{unsigned long long}.
11399 @end deftypefn
11400
11401 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11402 Returns the first argument raised to the power of the second. Unlike the
11403 @code{pow} function no guarantees about precision and rounding are made.
11404 @end deftypefn
11405
11406 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11407 Similar to @code{__builtin_powi}, except the argument and return types
11408 are @code{float}.
11409 @end deftypefn
11410
11411 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11412 Similar to @code{__builtin_powi}, except the argument and return types
11413 are @code{long double}.
11414 @end deftypefn
11415
11416 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11417 Returns @var{x} with the order of the bytes reversed; for example,
11418 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11419 exactly 8 bits.
11420 @end deftypefn
11421
11422 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11423 Similar to @code{__builtin_bswap16}, except the argument and return types
11424 are 32 bit.
11425 @end deftypefn
11426
11427 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11428 Similar to @code{__builtin_bswap32}, except the argument and return types
11429 are 64 bit.
11430 @end deftypefn
11431
11432 @node Target Builtins
11433 @section Built-in Functions Specific to Particular Target Machines
11434
11435 On some target machines, GCC supports many built-in functions specific
11436 to those machines. Generally these generate calls to specific machine
11437 instructions, but allow the compiler to schedule those calls.
11438
11439 @menu
11440 * AArch64 Built-in Functions::
11441 * Alpha Built-in Functions::
11442 * Altera Nios II Built-in Functions::
11443 * ARC Built-in Functions::
11444 * ARC SIMD Built-in Functions::
11445 * ARM iWMMXt Built-in Functions::
11446 * ARM C Language Extensions (ACLE)::
11447 * ARM Floating Point Status and Control Intrinsics::
11448 * AVR Built-in Functions::
11449 * Blackfin Built-in Functions::
11450 * FR-V Built-in Functions::
11451 * MIPS DSP Built-in Functions::
11452 * MIPS Paired-Single Support::
11453 * MIPS Loongson Built-in Functions::
11454 * Other MIPS Built-in Functions::
11455 * MSP430 Built-in Functions::
11456 * NDS32 Built-in Functions::
11457 * picoChip Built-in Functions::
11458 * PowerPC Built-in Functions::
11459 * PowerPC AltiVec/VSX Built-in Functions::
11460 * PowerPC Hardware Transactional Memory Built-in Functions::
11461 * RX Built-in Functions::
11462 * S/390 System z Built-in Functions::
11463 * SH Built-in Functions::
11464 * SPARC VIS Built-in Functions::
11465 * SPU Built-in Functions::
11466 * TI C6X Built-in Functions::
11467 * TILE-Gx Built-in Functions::
11468 * TILEPro Built-in Functions::
11469 * x86 Built-in Functions::
11470 * x86 transactional memory intrinsics::
11471 @end menu
11472
11473 @node AArch64 Built-in Functions
11474 @subsection AArch64 Built-in Functions
11475
11476 These built-in functions are available for the AArch64 family of
11477 processors.
11478 @smallexample
11479 unsigned int __builtin_aarch64_get_fpcr ()
11480 void __builtin_aarch64_set_fpcr (unsigned int)
11481 unsigned int __builtin_aarch64_get_fpsr ()
11482 void __builtin_aarch64_set_fpsr (unsigned int)
11483 @end smallexample
11484
11485 @node Alpha Built-in Functions
11486 @subsection Alpha Built-in Functions
11487
11488 These built-in functions are available for the Alpha family of
11489 processors, depending on the command-line switches used.
11490
11491 The following built-in functions are always available. They
11492 all generate the machine instruction that is part of the name.
11493
11494 @smallexample
11495 long __builtin_alpha_implver (void)
11496 long __builtin_alpha_rpcc (void)
11497 long __builtin_alpha_amask (long)
11498 long __builtin_alpha_cmpbge (long, long)
11499 long __builtin_alpha_extbl (long, long)
11500 long __builtin_alpha_extwl (long, long)
11501 long __builtin_alpha_extll (long, long)
11502 long __builtin_alpha_extql (long, long)
11503 long __builtin_alpha_extwh (long, long)
11504 long __builtin_alpha_extlh (long, long)
11505 long __builtin_alpha_extqh (long, long)
11506 long __builtin_alpha_insbl (long, long)
11507 long __builtin_alpha_inswl (long, long)
11508 long __builtin_alpha_insll (long, long)
11509 long __builtin_alpha_insql (long, long)
11510 long __builtin_alpha_inswh (long, long)
11511 long __builtin_alpha_inslh (long, long)
11512 long __builtin_alpha_insqh (long, long)
11513 long __builtin_alpha_mskbl (long, long)
11514 long __builtin_alpha_mskwl (long, long)
11515 long __builtin_alpha_mskll (long, long)
11516 long __builtin_alpha_mskql (long, long)
11517 long __builtin_alpha_mskwh (long, long)
11518 long __builtin_alpha_msklh (long, long)
11519 long __builtin_alpha_mskqh (long, long)
11520 long __builtin_alpha_umulh (long, long)
11521 long __builtin_alpha_zap (long, long)
11522 long __builtin_alpha_zapnot (long, long)
11523 @end smallexample
11524
11525 The following built-in functions are always with @option{-mmax}
11526 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11527 later. They all generate the machine instruction that is part
11528 of the name.
11529
11530 @smallexample
11531 long __builtin_alpha_pklb (long)
11532 long __builtin_alpha_pkwb (long)
11533 long __builtin_alpha_unpkbl (long)
11534 long __builtin_alpha_unpkbw (long)
11535 long __builtin_alpha_minub8 (long, long)
11536 long __builtin_alpha_minsb8 (long, long)
11537 long __builtin_alpha_minuw4 (long, long)
11538 long __builtin_alpha_minsw4 (long, long)
11539 long __builtin_alpha_maxub8 (long, long)
11540 long __builtin_alpha_maxsb8 (long, long)
11541 long __builtin_alpha_maxuw4 (long, long)
11542 long __builtin_alpha_maxsw4 (long, long)
11543 long __builtin_alpha_perr (long, long)
11544 @end smallexample
11545
11546 The following built-in functions are always with @option{-mcix}
11547 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11548 later. They all generate the machine instruction that is part
11549 of the name.
11550
11551 @smallexample
11552 long __builtin_alpha_cttz (long)
11553 long __builtin_alpha_ctlz (long)
11554 long __builtin_alpha_ctpop (long)
11555 @end smallexample
11556
11557 The following built-in functions are available on systems that use the OSF/1
11558 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11559 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11560 @code{rdval} and @code{wrval}.
11561
11562 @smallexample
11563 void *__builtin_thread_pointer (void)
11564 void __builtin_set_thread_pointer (void *)
11565 @end smallexample
11566
11567 @node Altera Nios II Built-in Functions
11568 @subsection Altera Nios II Built-in Functions
11569
11570 These built-in functions are available for the Altera Nios II
11571 family of processors.
11572
11573 The following built-in functions are always available. They
11574 all generate the machine instruction that is part of the name.
11575
11576 @example
11577 int __builtin_ldbio (volatile const void *)
11578 int __builtin_ldbuio (volatile const void *)
11579 int __builtin_ldhio (volatile const void *)
11580 int __builtin_ldhuio (volatile const void *)
11581 int __builtin_ldwio (volatile const void *)
11582 void __builtin_stbio (volatile void *, int)
11583 void __builtin_sthio (volatile void *, int)
11584 void __builtin_stwio (volatile void *, int)
11585 void __builtin_sync (void)
11586 int __builtin_rdctl (int)
11587 int __builtin_rdprs (int, int)
11588 void __builtin_wrctl (int, int)
11589 void __builtin_flushd (volatile void *)
11590 void __builtin_flushda (volatile void *)
11591 int __builtin_wrpie (int);
11592 void __builtin_eni (int);
11593 int __builtin_ldex (volatile const void *)
11594 int __builtin_stex (volatile void *, int)
11595 int __builtin_ldsex (volatile const void *)
11596 int __builtin_stsex (volatile void *, int)
11597 @end example
11598
11599 The following built-in functions are always available. They
11600 all generate a Nios II Custom Instruction. The name of the
11601 function represents the types that the function takes and
11602 returns. The letter before the @code{n} is the return type
11603 or void if absent. The @code{n} represents the first parameter
11604 to all the custom instructions, the custom instruction number.
11605 The two letters after the @code{n} represent the up to two
11606 parameters to the function.
11607
11608 The letters represent the following data types:
11609 @table @code
11610 @item <no letter>
11611 @code{void} for return type and no parameter for parameter types.
11612
11613 @item i
11614 @code{int} for return type and parameter type
11615
11616 @item f
11617 @code{float} for return type and parameter type
11618
11619 @item p
11620 @code{void *} for return type and parameter type
11621
11622 @end table
11623
11624 And the function names are:
11625 @example
11626 void __builtin_custom_n (void)
11627 void __builtin_custom_ni (int)
11628 void __builtin_custom_nf (float)
11629 void __builtin_custom_np (void *)
11630 void __builtin_custom_nii (int, int)
11631 void __builtin_custom_nif (int, float)
11632 void __builtin_custom_nip (int, void *)
11633 void __builtin_custom_nfi (float, int)
11634 void __builtin_custom_nff (float, float)
11635 void __builtin_custom_nfp (float, void *)
11636 void __builtin_custom_npi (void *, int)
11637 void __builtin_custom_npf (void *, float)
11638 void __builtin_custom_npp (void *, void *)
11639 int __builtin_custom_in (void)
11640 int __builtin_custom_ini (int)
11641 int __builtin_custom_inf (float)
11642 int __builtin_custom_inp (void *)
11643 int __builtin_custom_inii (int, int)
11644 int __builtin_custom_inif (int, float)
11645 int __builtin_custom_inip (int, void *)
11646 int __builtin_custom_infi (float, int)
11647 int __builtin_custom_inff (float, float)
11648 int __builtin_custom_infp (float, void *)
11649 int __builtin_custom_inpi (void *, int)
11650 int __builtin_custom_inpf (void *, float)
11651 int __builtin_custom_inpp (void *, void *)
11652 float __builtin_custom_fn (void)
11653 float __builtin_custom_fni (int)
11654 float __builtin_custom_fnf (float)
11655 float __builtin_custom_fnp (void *)
11656 float __builtin_custom_fnii (int, int)
11657 float __builtin_custom_fnif (int, float)
11658 float __builtin_custom_fnip (int, void *)
11659 float __builtin_custom_fnfi (float, int)
11660 float __builtin_custom_fnff (float, float)
11661 float __builtin_custom_fnfp (float, void *)
11662 float __builtin_custom_fnpi (void *, int)
11663 float __builtin_custom_fnpf (void *, float)
11664 float __builtin_custom_fnpp (void *, void *)
11665 void * __builtin_custom_pn (void)
11666 void * __builtin_custom_pni (int)
11667 void * __builtin_custom_pnf (float)
11668 void * __builtin_custom_pnp (void *)
11669 void * __builtin_custom_pnii (int, int)
11670 void * __builtin_custom_pnif (int, float)
11671 void * __builtin_custom_pnip (int, void *)
11672 void * __builtin_custom_pnfi (float, int)
11673 void * __builtin_custom_pnff (float, float)
11674 void * __builtin_custom_pnfp (float, void *)
11675 void * __builtin_custom_pnpi (void *, int)
11676 void * __builtin_custom_pnpf (void *, float)
11677 void * __builtin_custom_pnpp (void *, void *)
11678 @end example
11679
11680 @node ARC Built-in Functions
11681 @subsection ARC Built-in Functions
11682
11683 The following built-in functions are provided for ARC targets. The
11684 built-ins generate the corresponding assembly instructions. In the
11685 examples given below, the generated code often requires an operand or
11686 result to be in a register. Where necessary further code will be
11687 generated to ensure this is true, but for brevity this is not
11688 described in each case.
11689
11690 @emph{Note:} Using a built-in to generate an instruction not supported
11691 by a target may cause problems. At present the compiler is not
11692 guaranteed to detect such misuse, and as a result an internal compiler
11693 error may be generated.
11694
11695 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11696 Return 1 if @var{val} is known to have the byte alignment given
11697 by @var{alignval}, otherwise return 0.
11698 Note that this is different from
11699 @smallexample
11700 __alignof__(*(char *)@var{val}) >= alignval
11701 @end smallexample
11702 because __alignof__ sees only the type of the dereference, whereas
11703 __builtin_arc_align uses alignment information from the pointer
11704 as well as from the pointed-to type.
11705 The information available will depend on optimization level.
11706 @end deftypefn
11707
11708 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11709 Generates
11710 @example
11711 brk
11712 @end example
11713 @end deftypefn
11714
11715 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11716 The operand is the number of a register to be read. Generates:
11717 @example
11718 mov @var{dest}, r@var{regno}
11719 @end example
11720 where the value in @var{dest} will be the result returned from the
11721 built-in.
11722 @end deftypefn
11723
11724 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11725 The first operand is the number of a register to be written, the
11726 second operand is a compile time constant to write into that
11727 register. Generates:
11728 @example
11729 mov r@var{regno}, @var{val}
11730 @end example
11731 @end deftypefn
11732
11733 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11734 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11735 Generates:
11736 @example
11737 divaw @var{dest}, @var{a}, @var{b}
11738 @end example
11739 where the value in @var{dest} will be the result returned from the
11740 built-in.
11741 @end deftypefn
11742
11743 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11744 Generates
11745 @example
11746 flag @var{a}
11747 @end example
11748 @end deftypefn
11749
11750 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11751 The operand, @var{auxv}, is the address of an auxiliary register and
11752 must be a compile time constant. Generates:
11753 @example
11754 lr @var{dest}, [@var{auxr}]
11755 @end example
11756 Where the value in @var{dest} will be the result returned from the
11757 built-in.
11758 @end deftypefn
11759
11760 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11761 Only available with @option{-mmul64}. Generates:
11762 @example
11763 mul64 @var{a}, @var{b}
11764 @end example
11765 @end deftypefn
11766
11767 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11768 Only available with @option{-mmul64}. Generates:
11769 @example
11770 mulu64 @var{a}, @var{b}
11771 @end example
11772 @end deftypefn
11773
11774 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11775 Generates:
11776 @example
11777 nop
11778 @end example
11779 @end deftypefn
11780
11781 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11782 Only valid if the @samp{norm} instruction is available through the
11783 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11784 Generates:
11785 @example
11786 norm @var{dest}, @var{src}
11787 @end example
11788 Where the value in @var{dest} will be the result returned from the
11789 built-in.
11790 @end deftypefn
11791
11792 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11793 Only valid if the @samp{normw} instruction is available through the
11794 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11795 Generates:
11796 @example
11797 normw @var{dest}, @var{src}
11798 @end example
11799 Where the value in @var{dest} will be the result returned from the
11800 built-in.
11801 @end deftypefn
11802
11803 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11804 Generates:
11805 @example
11806 rtie
11807 @end example
11808 @end deftypefn
11809
11810 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11811 Generates:
11812 @example
11813 sleep @var{a}
11814 @end example
11815 @end deftypefn
11816
11817 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11818 The first argument, @var{auxv}, is the address of an auxiliary
11819 register, the second argument, @var{val}, is a compile time constant
11820 to be written to the register. Generates:
11821 @example
11822 sr @var{auxr}, [@var{val}]
11823 @end example
11824 @end deftypefn
11825
11826 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11827 Only valid with @option{-mswap}. Generates:
11828 @example
11829 swap @var{dest}, @var{src}
11830 @end example
11831 Where the value in @var{dest} will be the result returned from the
11832 built-in.
11833 @end deftypefn
11834
11835 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11836 Generates:
11837 @example
11838 swi
11839 @end example
11840 @end deftypefn
11841
11842 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11843 Only available with @option{-mcpu=ARC700}. Generates:
11844 @example
11845 sync
11846 @end example
11847 @end deftypefn
11848
11849 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11850 Only available with @option{-mcpu=ARC700}. Generates:
11851 @example
11852 trap_s @var{c}
11853 @end example
11854 @end deftypefn
11855
11856 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11857 Only available with @option{-mcpu=ARC700}. Generates:
11858 @example
11859 unimp_s
11860 @end example
11861 @end deftypefn
11862
11863 The instructions generated by the following builtins are not
11864 considered as candidates for scheduling. They are not moved around by
11865 the compiler during scheduling, and thus can be expected to appear
11866 where they are put in the C code:
11867 @example
11868 __builtin_arc_brk()
11869 __builtin_arc_core_read()
11870 __builtin_arc_core_write()
11871 __builtin_arc_flag()
11872 __builtin_arc_lr()
11873 __builtin_arc_sleep()
11874 __builtin_arc_sr()
11875 __builtin_arc_swi()
11876 @end example
11877
11878 @node ARC SIMD Built-in Functions
11879 @subsection ARC SIMD Built-in Functions
11880
11881 SIMD builtins provided by the compiler can be used to generate the
11882 vector instructions. This section describes the available builtins
11883 and their usage in programs. With the @option{-msimd} option, the
11884 compiler provides 128-bit vector types, which can be specified using
11885 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11886 can be included to use the following predefined types:
11887 @example
11888 typedef int __v4si __attribute__((vector_size(16)));
11889 typedef short __v8hi __attribute__((vector_size(16)));
11890 @end example
11891
11892 These types can be used to define 128-bit variables. The built-in
11893 functions listed in the following section can be used on these
11894 variables to generate the vector operations.
11895
11896 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11897 @file{arc-simd.h} also provides equivalent macros called
11898 @code{_@var{someinsn}} that can be used for programming ease and
11899 improved readability. The following macros for DMA control are also
11900 provided:
11901 @example
11902 #define _setup_dma_in_channel_reg _vdiwr
11903 #define _setup_dma_out_channel_reg _vdowr
11904 @end example
11905
11906 The following is a complete list of all the SIMD built-ins provided
11907 for ARC, grouped by calling signature.
11908
11909 The following take two @code{__v8hi} arguments and return a
11910 @code{__v8hi} result:
11911 @example
11912 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11913 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11914 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11915 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11916 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11917 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11918 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11919 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11920 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11921 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11922 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11923 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11924 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11925 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11926 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11927 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11928 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11929 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11930 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11931 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11932 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11933 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11934 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11935 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11936 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11937 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11938 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11939 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11940 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11941 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11942 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11943 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11944 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11945 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11946 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11947 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11948 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11949 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11950 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11951 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11952 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11953 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11954 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11955 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11956 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11957 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11958 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11959 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11960 @end example
11961
11962 The following take one @code{__v8hi} and one @code{int} argument and return a
11963 @code{__v8hi} result:
11964
11965 @example
11966 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11967 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11968 __v8hi __builtin_arc_vbminw (__v8hi, int)
11969 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11970 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11971 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11972 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11973 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11974 @end example
11975
11976 The following take one @code{__v8hi} argument and one @code{int} argument which
11977 must be a 3-bit compile time constant indicating a register number
11978 I0-I7. They return a @code{__v8hi} result.
11979 @example
11980 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11981 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11982 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11983 @end example
11984
11985 The following take one @code{__v8hi} argument and one @code{int}
11986 argument which must be a 6-bit compile time constant. They return a
11987 @code{__v8hi} result.
11988 @example
11989 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11990 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11991 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11992 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11993 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11994 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11995 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11996 @end example
11997
11998 The following take one @code{__v8hi} argument and one @code{int} argument which
11999 must be a 8-bit compile time constant. They return a @code{__v8hi}
12000 result.
12001 @example
12002 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12003 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12004 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12005 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12006 @end example
12007
12008 The following take two @code{int} arguments, the second of which which
12009 must be a 8-bit compile time constant. They return a @code{__v8hi}
12010 result:
12011 @example
12012 __v8hi __builtin_arc_vmovaw (int, const int)
12013 __v8hi __builtin_arc_vmovw (int, const int)
12014 __v8hi __builtin_arc_vmovzw (int, const int)
12015 @end example
12016
12017 The following take a single @code{__v8hi} argument and return a
12018 @code{__v8hi} result:
12019 @example
12020 __v8hi __builtin_arc_vabsaw (__v8hi)
12021 __v8hi __builtin_arc_vabsw (__v8hi)
12022 __v8hi __builtin_arc_vaddsuw (__v8hi)
12023 __v8hi __builtin_arc_vexch1 (__v8hi)
12024 __v8hi __builtin_arc_vexch2 (__v8hi)
12025 __v8hi __builtin_arc_vexch4 (__v8hi)
12026 __v8hi __builtin_arc_vsignw (__v8hi)
12027 __v8hi __builtin_arc_vupbaw (__v8hi)
12028 __v8hi __builtin_arc_vupbw (__v8hi)
12029 __v8hi __builtin_arc_vupsbaw (__v8hi)
12030 __v8hi __builtin_arc_vupsbw (__v8hi)
12031 @end example
12032
12033 The following take two @code{int} arguments and return no result:
12034 @example
12035 void __builtin_arc_vdirun (int, int)
12036 void __builtin_arc_vdorun (int, int)
12037 @end example
12038
12039 The following take two @code{int} arguments and return no result. The
12040 first argument must a 3-bit compile time constant indicating one of
12041 the DR0-DR7 DMA setup channels:
12042 @example
12043 void __builtin_arc_vdiwr (const int, int)
12044 void __builtin_arc_vdowr (const int, int)
12045 @end example
12046
12047 The following take an @code{int} argument and return no result:
12048 @example
12049 void __builtin_arc_vendrec (int)
12050 void __builtin_arc_vrec (int)
12051 void __builtin_arc_vrecrun (int)
12052 void __builtin_arc_vrun (int)
12053 @end example
12054
12055 The following take a @code{__v8hi} argument and two @code{int}
12056 arguments and return a @code{__v8hi} result. The second argument must
12057 be a 3-bit compile time constants, indicating one the registers I0-I7,
12058 and the third argument must be an 8-bit compile time constant.
12059
12060 @emph{Note:} Although the equivalent hardware instructions do not take
12061 an SIMD register as an operand, these builtins overwrite the relevant
12062 bits of the @code{__v8hi} register provided as the first argument with
12063 the value loaded from the @code{[Ib, u8]} location in the SDM.
12064
12065 @example
12066 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12067 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12068 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12069 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12070 @end example
12071
12072 The following take two @code{int} arguments and return a @code{__v8hi}
12073 result. The first argument must be a 3-bit compile time constants,
12074 indicating one the registers I0-I7, and the second argument must be an
12075 8-bit compile time constant.
12076
12077 @example
12078 __v8hi __builtin_arc_vld128 (const int, const int)
12079 __v8hi __builtin_arc_vld64w (const int, const int)
12080 @end example
12081
12082 The following take a @code{__v8hi} argument and two @code{int}
12083 arguments and return no result. The second argument must be a 3-bit
12084 compile time constants, indicating one the registers I0-I7, and the
12085 third argument must be an 8-bit compile time constant.
12086
12087 @example
12088 void __builtin_arc_vst128 (__v8hi, const int, const int)
12089 void __builtin_arc_vst64 (__v8hi, const int, const int)
12090 @end example
12091
12092 The following take a @code{__v8hi} argument and three @code{int}
12093 arguments and return no result. The second argument must be a 3-bit
12094 compile-time constant, identifying the 16-bit sub-register to be
12095 stored, the third argument must be a 3-bit compile time constants,
12096 indicating one the registers I0-I7, and the fourth argument must be an
12097 8-bit compile time constant.
12098
12099 @example
12100 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12101 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12102 @end example
12103
12104 @node ARM iWMMXt Built-in Functions
12105 @subsection ARM iWMMXt Built-in Functions
12106
12107 These built-in functions are available for the ARM family of
12108 processors when the @option{-mcpu=iwmmxt} switch is used:
12109
12110 @smallexample
12111 typedef int v2si __attribute__ ((vector_size (8)));
12112 typedef short v4hi __attribute__ ((vector_size (8)));
12113 typedef char v8qi __attribute__ ((vector_size (8)));
12114
12115 int __builtin_arm_getwcgr0 (void)
12116 void __builtin_arm_setwcgr0 (int)
12117 int __builtin_arm_getwcgr1 (void)
12118 void __builtin_arm_setwcgr1 (int)
12119 int __builtin_arm_getwcgr2 (void)
12120 void __builtin_arm_setwcgr2 (int)
12121 int __builtin_arm_getwcgr3 (void)
12122 void __builtin_arm_setwcgr3 (int)
12123 int __builtin_arm_textrmsb (v8qi, int)
12124 int __builtin_arm_textrmsh (v4hi, int)
12125 int __builtin_arm_textrmsw (v2si, int)
12126 int __builtin_arm_textrmub (v8qi, int)
12127 int __builtin_arm_textrmuh (v4hi, int)
12128 int __builtin_arm_textrmuw (v2si, int)
12129 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12130 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12131 v2si __builtin_arm_tinsrw (v2si, int, int)
12132 long long __builtin_arm_tmia (long long, int, int)
12133 long long __builtin_arm_tmiabb (long long, int, int)
12134 long long __builtin_arm_tmiabt (long long, int, int)
12135 long long __builtin_arm_tmiaph (long long, int, int)
12136 long long __builtin_arm_tmiatb (long long, int, int)
12137 long long __builtin_arm_tmiatt (long long, int, int)
12138 int __builtin_arm_tmovmskb (v8qi)
12139 int __builtin_arm_tmovmskh (v4hi)
12140 int __builtin_arm_tmovmskw (v2si)
12141 long long __builtin_arm_waccb (v8qi)
12142 long long __builtin_arm_wacch (v4hi)
12143 long long __builtin_arm_waccw (v2si)
12144 v8qi __builtin_arm_waddb (v8qi, v8qi)
12145 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12146 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12147 v4hi __builtin_arm_waddh (v4hi, v4hi)
12148 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12149 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12150 v2si __builtin_arm_waddw (v2si, v2si)
12151 v2si __builtin_arm_waddwss (v2si, v2si)
12152 v2si __builtin_arm_waddwus (v2si, v2si)
12153 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12154 long long __builtin_arm_wand(long long, long long)
12155 long long __builtin_arm_wandn (long long, long long)
12156 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12157 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12158 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12159 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12160 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12161 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12162 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12163 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12164 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12165 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12166 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12167 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12168 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12169 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12170 long long __builtin_arm_wmacsz (v4hi, v4hi)
12171 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12172 long long __builtin_arm_wmacuz (v4hi, v4hi)
12173 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12174 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12175 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12176 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12177 v2si __builtin_arm_wmaxsw (v2si, v2si)
12178 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12179 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12180 v2si __builtin_arm_wmaxuw (v2si, v2si)
12181 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12182 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12183 v2si __builtin_arm_wminsw (v2si, v2si)
12184 v8qi __builtin_arm_wminub (v8qi, v8qi)
12185 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12186 v2si __builtin_arm_wminuw (v2si, v2si)
12187 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12188 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12189 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12190 long long __builtin_arm_wor (long long, long long)
12191 v2si __builtin_arm_wpackdss (long long, long long)
12192 v2si __builtin_arm_wpackdus (long long, long long)
12193 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12194 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12195 v4hi __builtin_arm_wpackwss (v2si, v2si)
12196 v4hi __builtin_arm_wpackwus (v2si, v2si)
12197 long long __builtin_arm_wrord (long long, long long)
12198 long long __builtin_arm_wrordi (long long, int)
12199 v4hi __builtin_arm_wrorh (v4hi, long long)
12200 v4hi __builtin_arm_wrorhi (v4hi, int)
12201 v2si __builtin_arm_wrorw (v2si, long long)
12202 v2si __builtin_arm_wrorwi (v2si, int)
12203 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12204 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12205 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12206 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12207 v4hi __builtin_arm_wshufh (v4hi, int)
12208 long long __builtin_arm_wslld (long long, long long)
12209 long long __builtin_arm_wslldi (long long, int)
12210 v4hi __builtin_arm_wsllh (v4hi, long long)
12211 v4hi __builtin_arm_wsllhi (v4hi, int)
12212 v2si __builtin_arm_wsllw (v2si, long long)
12213 v2si __builtin_arm_wsllwi (v2si, int)
12214 long long __builtin_arm_wsrad (long long, long long)
12215 long long __builtin_arm_wsradi (long long, int)
12216 v4hi __builtin_arm_wsrah (v4hi, long long)
12217 v4hi __builtin_arm_wsrahi (v4hi, int)
12218 v2si __builtin_arm_wsraw (v2si, long long)
12219 v2si __builtin_arm_wsrawi (v2si, int)
12220 long long __builtin_arm_wsrld (long long, long long)
12221 long long __builtin_arm_wsrldi (long long, int)
12222 v4hi __builtin_arm_wsrlh (v4hi, long long)
12223 v4hi __builtin_arm_wsrlhi (v4hi, int)
12224 v2si __builtin_arm_wsrlw (v2si, long long)
12225 v2si __builtin_arm_wsrlwi (v2si, int)
12226 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12227 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12228 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12229 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12230 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12231 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12232 v2si __builtin_arm_wsubw (v2si, v2si)
12233 v2si __builtin_arm_wsubwss (v2si, v2si)
12234 v2si __builtin_arm_wsubwus (v2si, v2si)
12235 v4hi __builtin_arm_wunpckehsb (v8qi)
12236 v2si __builtin_arm_wunpckehsh (v4hi)
12237 long long __builtin_arm_wunpckehsw (v2si)
12238 v4hi __builtin_arm_wunpckehub (v8qi)
12239 v2si __builtin_arm_wunpckehuh (v4hi)
12240 long long __builtin_arm_wunpckehuw (v2si)
12241 v4hi __builtin_arm_wunpckelsb (v8qi)
12242 v2si __builtin_arm_wunpckelsh (v4hi)
12243 long long __builtin_arm_wunpckelsw (v2si)
12244 v4hi __builtin_arm_wunpckelub (v8qi)
12245 v2si __builtin_arm_wunpckeluh (v4hi)
12246 long long __builtin_arm_wunpckeluw (v2si)
12247 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12248 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12249 v2si __builtin_arm_wunpckihw (v2si, v2si)
12250 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12251 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12252 v2si __builtin_arm_wunpckilw (v2si, v2si)
12253 long long __builtin_arm_wxor (long long, long long)
12254 long long __builtin_arm_wzero ()
12255 @end smallexample
12256
12257
12258 @node ARM C Language Extensions (ACLE)
12259 @subsection ARM C Language Extensions (ACLE)
12260
12261 GCC implements extensions for C as described in the ARM C Language
12262 Extensions (ACLE) specification, which can be found at
12263 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12264
12265 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12266 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12267 intrinsics can be found at
12268 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12269 The built-in intrinsics for the Advanced SIMD extension are available when
12270 NEON is enabled.
12271
12272 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12273 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12274 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12275 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12276 intrinsics yet.
12277
12278 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12279 availability of extensions.
12280
12281 @node ARM Floating Point Status and Control Intrinsics
12282 @subsection ARM Floating Point Status and Control Intrinsics
12283
12284 These built-in functions are available for the ARM family of
12285 processors with floating-point unit.
12286
12287 @smallexample
12288 unsigned int __builtin_arm_get_fpscr ()
12289 void __builtin_arm_set_fpscr (unsigned int)
12290 @end smallexample
12291
12292 @node AVR Built-in Functions
12293 @subsection AVR Built-in Functions
12294
12295 For each built-in function for AVR, there is an equally named,
12296 uppercase built-in macro defined. That way users can easily query if
12297 or if not a specific built-in is implemented or not. For example, if
12298 @code{__builtin_avr_nop} is available the macro
12299 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12300
12301 The following built-in functions map to the respective machine
12302 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12303 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12304 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12305 as library call if no hardware multiplier is available.
12306
12307 @smallexample
12308 void __builtin_avr_nop (void)
12309 void __builtin_avr_sei (void)
12310 void __builtin_avr_cli (void)
12311 void __builtin_avr_sleep (void)
12312 void __builtin_avr_wdr (void)
12313 unsigned char __builtin_avr_swap (unsigned char)
12314 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12315 int __builtin_avr_fmuls (char, char)
12316 int __builtin_avr_fmulsu (char, unsigned char)
12317 @end smallexample
12318
12319 In order to delay execution for a specific number of cycles, GCC
12320 implements
12321 @smallexample
12322 void __builtin_avr_delay_cycles (unsigned long ticks)
12323 @end smallexample
12324
12325 @noindent
12326 @code{ticks} is the number of ticks to delay execution. Note that this
12327 built-in does not take into account the effect of interrupts that
12328 might increase delay time. @code{ticks} must be a compile-time
12329 integer constant; delays with a variable number of cycles are not supported.
12330
12331 @smallexample
12332 char __builtin_avr_flash_segment (const __memx void*)
12333 @end smallexample
12334
12335 @noindent
12336 This built-in takes a byte address to the 24-bit
12337 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12338 the number of the flash segment (the 64 KiB chunk) where the address
12339 points to. Counting starts at @code{0}.
12340 If the address does not point to flash memory, return @code{-1}.
12341
12342 @smallexample
12343 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12344 @end smallexample
12345
12346 @noindent
12347 Insert bits from @var{bits} into @var{val} and return the resulting
12348 value. The nibbles of @var{map} determine how the insertion is
12349 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12350 @enumerate
12351 @item If @var{X} is @code{0xf},
12352 then the @var{n}-th bit of @var{val} is returned unaltered.
12353
12354 @item If X is in the range 0@dots{}7,
12355 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12356
12357 @item If X is in the range 8@dots{}@code{0xe},
12358 then the @var{n}-th result bit is undefined.
12359 @end enumerate
12360
12361 @noindent
12362 One typical use case for this built-in is adjusting input and
12363 output values to non-contiguous port layouts. Some examples:
12364
12365 @smallexample
12366 // same as val, bits is unused
12367 __builtin_avr_insert_bits (0xffffffff, bits, val)
12368 @end smallexample
12369
12370 @smallexample
12371 // same as bits, val is unused
12372 __builtin_avr_insert_bits (0x76543210, bits, val)
12373 @end smallexample
12374
12375 @smallexample
12376 // same as rotating bits by 4
12377 __builtin_avr_insert_bits (0x32107654, bits, 0)
12378 @end smallexample
12379
12380 @smallexample
12381 // high nibble of result is the high nibble of val
12382 // low nibble of result is the low nibble of bits
12383 __builtin_avr_insert_bits (0xffff3210, bits, val)
12384 @end smallexample
12385
12386 @smallexample
12387 // reverse the bit order of bits
12388 __builtin_avr_insert_bits (0x01234567, bits, 0)
12389 @end smallexample
12390
12391 @node Blackfin Built-in Functions
12392 @subsection Blackfin Built-in Functions
12393
12394 Currently, there are two Blackfin-specific built-in functions. These are
12395 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12396 using inline assembly; by using these built-in functions the compiler can
12397 automatically add workarounds for hardware errata involving these
12398 instructions. These functions are named as follows:
12399
12400 @smallexample
12401 void __builtin_bfin_csync (void)
12402 void __builtin_bfin_ssync (void)
12403 @end smallexample
12404
12405 @node FR-V Built-in Functions
12406 @subsection FR-V Built-in Functions
12407
12408 GCC provides many FR-V-specific built-in functions. In general,
12409 these functions are intended to be compatible with those described
12410 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12411 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12412 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12413 pointer rather than by value.
12414
12415 Most of the functions are named after specific FR-V instructions.
12416 Such functions are said to be ``directly mapped'' and are summarized
12417 here in tabular form.
12418
12419 @menu
12420 * Argument Types::
12421 * Directly-mapped Integer Functions::
12422 * Directly-mapped Media Functions::
12423 * Raw read/write Functions::
12424 * Other Built-in Functions::
12425 @end menu
12426
12427 @node Argument Types
12428 @subsubsection Argument Types
12429
12430 The arguments to the built-in functions can be divided into three groups:
12431 register numbers, compile-time constants and run-time values. In order
12432 to make this classification clear at a glance, the arguments and return
12433 values are given the following pseudo types:
12434
12435 @multitable @columnfractions .20 .30 .15 .35
12436 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12437 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12438 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12439 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12440 @item @code{uw2} @tab @code{unsigned long long} @tab No
12441 @tab an unsigned doubleword
12442 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12443 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12444 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12445 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12446 @end multitable
12447
12448 These pseudo types are not defined by GCC, they are simply a notational
12449 convenience used in this manual.
12450
12451 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12452 and @code{sw2} are evaluated at run time. They correspond to
12453 register operands in the underlying FR-V instructions.
12454
12455 @code{const} arguments represent immediate operands in the underlying
12456 FR-V instructions. They must be compile-time constants.
12457
12458 @code{acc} arguments are evaluated at compile time and specify the number
12459 of an accumulator register. For example, an @code{acc} argument of 2
12460 selects the ACC2 register.
12461
12462 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12463 number of an IACC register. See @pxref{Other Built-in Functions}
12464 for more details.
12465
12466 @node Directly-mapped Integer Functions
12467 @subsubsection Directly-Mapped Integer Functions
12468
12469 The functions listed below map directly to FR-V I-type instructions.
12470
12471 @multitable @columnfractions .45 .32 .23
12472 @item Function prototype @tab Example usage @tab Assembly output
12473 @item @code{sw1 __ADDSS (sw1, sw1)}
12474 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12475 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12476 @item @code{sw1 __SCAN (sw1, sw1)}
12477 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12478 @tab @code{SCAN @var{a},@var{b},@var{c}}
12479 @item @code{sw1 __SCUTSS (sw1)}
12480 @tab @code{@var{b} = __SCUTSS (@var{a})}
12481 @tab @code{SCUTSS @var{a},@var{b}}
12482 @item @code{sw1 __SLASS (sw1, sw1)}
12483 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12484 @tab @code{SLASS @var{a},@var{b},@var{c}}
12485 @item @code{void __SMASS (sw1, sw1)}
12486 @tab @code{__SMASS (@var{a}, @var{b})}
12487 @tab @code{SMASS @var{a},@var{b}}
12488 @item @code{void __SMSSS (sw1, sw1)}
12489 @tab @code{__SMSSS (@var{a}, @var{b})}
12490 @tab @code{SMSSS @var{a},@var{b}}
12491 @item @code{void __SMU (sw1, sw1)}
12492 @tab @code{__SMU (@var{a}, @var{b})}
12493 @tab @code{SMU @var{a},@var{b}}
12494 @item @code{sw2 __SMUL (sw1, sw1)}
12495 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12496 @tab @code{SMUL @var{a},@var{b},@var{c}}
12497 @item @code{sw1 __SUBSS (sw1, sw1)}
12498 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12499 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12500 @item @code{uw2 __UMUL (uw1, uw1)}
12501 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12502 @tab @code{UMUL @var{a},@var{b},@var{c}}
12503 @end multitable
12504
12505 @node Directly-mapped Media Functions
12506 @subsubsection Directly-Mapped Media Functions
12507
12508 The functions listed below map directly to FR-V M-type instructions.
12509
12510 @multitable @columnfractions .45 .32 .23
12511 @item Function prototype @tab Example usage @tab Assembly output
12512 @item @code{uw1 __MABSHS (sw1)}
12513 @tab @code{@var{b} = __MABSHS (@var{a})}
12514 @tab @code{MABSHS @var{a},@var{b}}
12515 @item @code{void __MADDACCS (acc, acc)}
12516 @tab @code{__MADDACCS (@var{b}, @var{a})}
12517 @tab @code{MADDACCS @var{a},@var{b}}
12518 @item @code{sw1 __MADDHSS (sw1, sw1)}
12519 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12520 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12521 @item @code{uw1 __MADDHUS (uw1, uw1)}
12522 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12523 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12524 @item @code{uw1 __MAND (uw1, uw1)}
12525 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12526 @tab @code{MAND @var{a},@var{b},@var{c}}
12527 @item @code{void __MASACCS (acc, acc)}
12528 @tab @code{__MASACCS (@var{b}, @var{a})}
12529 @tab @code{MASACCS @var{a},@var{b}}
12530 @item @code{uw1 __MAVEH (uw1, uw1)}
12531 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12532 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12533 @item @code{uw2 __MBTOH (uw1)}
12534 @tab @code{@var{b} = __MBTOH (@var{a})}
12535 @tab @code{MBTOH @var{a},@var{b}}
12536 @item @code{void __MBTOHE (uw1 *, uw1)}
12537 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12538 @tab @code{MBTOHE @var{a},@var{b}}
12539 @item @code{void __MCLRACC (acc)}
12540 @tab @code{__MCLRACC (@var{a})}
12541 @tab @code{MCLRACC @var{a}}
12542 @item @code{void __MCLRACCA (void)}
12543 @tab @code{__MCLRACCA ()}
12544 @tab @code{MCLRACCA}
12545 @item @code{uw1 __Mcop1 (uw1, uw1)}
12546 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12547 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12548 @item @code{uw1 __Mcop2 (uw1, uw1)}
12549 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12550 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12551 @item @code{uw1 __MCPLHI (uw2, const)}
12552 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12553 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12554 @item @code{uw1 __MCPLI (uw2, const)}
12555 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12556 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12557 @item @code{void __MCPXIS (acc, sw1, sw1)}
12558 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12559 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12560 @item @code{void __MCPXIU (acc, uw1, uw1)}
12561 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12562 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12563 @item @code{void __MCPXRS (acc, sw1, sw1)}
12564 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12565 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12566 @item @code{void __MCPXRU (acc, uw1, uw1)}
12567 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12568 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12569 @item @code{uw1 __MCUT (acc, uw1)}
12570 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12571 @tab @code{MCUT @var{a},@var{b},@var{c}}
12572 @item @code{uw1 __MCUTSS (acc, sw1)}
12573 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12574 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12575 @item @code{void __MDADDACCS (acc, acc)}
12576 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12577 @tab @code{MDADDACCS @var{a},@var{b}}
12578 @item @code{void __MDASACCS (acc, acc)}
12579 @tab @code{__MDASACCS (@var{b}, @var{a})}
12580 @tab @code{MDASACCS @var{a},@var{b}}
12581 @item @code{uw2 __MDCUTSSI (acc, const)}
12582 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12583 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12584 @item @code{uw2 __MDPACKH (uw2, uw2)}
12585 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12586 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12587 @item @code{uw2 __MDROTLI (uw2, const)}
12588 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12589 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12590 @item @code{void __MDSUBACCS (acc, acc)}
12591 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12592 @tab @code{MDSUBACCS @var{a},@var{b}}
12593 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12594 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12595 @tab @code{MDUNPACKH @var{a},@var{b}}
12596 @item @code{uw2 __MEXPDHD (uw1, const)}
12597 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12598 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12599 @item @code{uw1 __MEXPDHW (uw1, const)}
12600 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12601 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12602 @item @code{uw1 __MHDSETH (uw1, const)}
12603 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12604 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12605 @item @code{sw1 __MHDSETS (const)}
12606 @tab @code{@var{b} = __MHDSETS (@var{a})}
12607 @tab @code{MHDSETS #@var{a},@var{b}}
12608 @item @code{uw1 __MHSETHIH (uw1, const)}
12609 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12610 @tab @code{MHSETHIH #@var{a},@var{b}}
12611 @item @code{sw1 __MHSETHIS (sw1, const)}
12612 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12613 @tab @code{MHSETHIS #@var{a},@var{b}}
12614 @item @code{uw1 __MHSETLOH (uw1, const)}
12615 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12616 @tab @code{MHSETLOH #@var{a},@var{b}}
12617 @item @code{sw1 __MHSETLOS (sw1, const)}
12618 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12619 @tab @code{MHSETLOS #@var{a},@var{b}}
12620 @item @code{uw1 __MHTOB (uw2)}
12621 @tab @code{@var{b} = __MHTOB (@var{a})}
12622 @tab @code{MHTOB @var{a},@var{b}}
12623 @item @code{void __MMACHS (acc, sw1, sw1)}
12624 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12625 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12626 @item @code{void __MMACHU (acc, uw1, uw1)}
12627 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12628 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12629 @item @code{void __MMRDHS (acc, sw1, sw1)}
12630 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12631 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12632 @item @code{void __MMRDHU (acc, uw1, uw1)}
12633 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12634 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12635 @item @code{void __MMULHS (acc, sw1, sw1)}
12636 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12637 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12638 @item @code{void __MMULHU (acc, uw1, uw1)}
12639 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12640 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12641 @item @code{void __MMULXHS (acc, sw1, sw1)}
12642 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12643 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12644 @item @code{void __MMULXHU (acc, uw1, uw1)}
12645 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12646 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12647 @item @code{uw1 __MNOT (uw1)}
12648 @tab @code{@var{b} = __MNOT (@var{a})}
12649 @tab @code{MNOT @var{a},@var{b}}
12650 @item @code{uw1 __MOR (uw1, uw1)}
12651 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12652 @tab @code{MOR @var{a},@var{b},@var{c}}
12653 @item @code{uw1 __MPACKH (uh, uh)}
12654 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12655 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12656 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12657 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12658 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12659 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12660 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12661 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12662 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12663 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12664 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12665 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12666 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12667 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12668 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12669 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12670 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12671 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12672 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12673 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12674 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12675 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12676 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12677 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12678 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12679 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12680 @item @code{void __MQMACHS (acc, sw2, sw2)}
12681 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12682 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12683 @item @code{void __MQMACHU (acc, uw2, uw2)}
12684 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12685 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12686 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12687 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12688 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12689 @item @code{void __MQMULHS (acc, sw2, sw2)}
12690 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12691 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12692 @item @code{void __MQMULHU (acc, uw2, uw2)}
12693 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12694 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12695 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12696 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12697 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12698 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12699 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12700 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12701 @item @code{sw2 __MQSATHS (sw2, sw2)}
12702 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12703 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12704 @item @code{uw2 __MQSLLHI (uw2, int)}
12705 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12706 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12707 @item @code{sw2 __MQSRAHI (sw2, int)}
12708 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12709 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12710 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12711 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12712 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12713 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12714 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12715 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12716 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12717 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12718 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12719 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12720 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12721 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12722 @item @code{uw1 __MRDACC (acc)}
12723 @tab @code{@var{b} = __MRDACC (@var{a})}
12724 @tab @code{MRDACC @var{a},@var{b}}
12725 @item @code{uw1 __MRDACCG (acc)}
12726 @tab @code{@var{b} = __MRDACCG (@var{a})}
12727 @tab @code{MRDACCG @var{a},@var{b}}
12728 @item @code{uw1 __MROTLI (uw1, const)}
12729 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12730 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12731 @item @code{uw1 __MROTRI (uw1, const)}
12732 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12733 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12734 @item @code{sw1 __MSATHS (sw1, sw1)}
12735 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12736 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12737 @item @code{uw1 __MSATHU (uw1, uw1)}
12738 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12739 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12740 @item @code{uw1 __MSLLHI (uw1, const)}
12741 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12742 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12743 @item @code{sw1 __MSRAHI (sw1, const)}
12744 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12745 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12746 @item @code{uw1 __MSRLHI (uw1, const)}
12747 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12748 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12749 @item @code{void __MSUBACCS (acc, acc)}
12750 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12751 @tab @code{MSUBACCS @var{a},@var{b}}
12752 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12753 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12754 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12755 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12756 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12757 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12758 @item @code{void __MTRAP (void)}
12759 @tab @code{__MTRAP ()}
12760 @tab @code{MTRAP}
12761 @item @code{uw2 __MUNPACKH (uw1)}
12762 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12763 @tab @code{MUNPACKH @var{a},@var{b}}
12764 @item @code{uw1 __MWCUT (uw2, uw1)}
12765 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12766 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12767 @item @code{void __MWTACC (acc, uw1)}
12768 @tab @code{__MWTACC (@var{b}, @var{a})}
12769 @tab @code{MWTACC @var{a},@var{b}}
12770 @item @code{void __MWTACCG (acc, uw1)}
12771 @tab @code{__MWTACCG (@var{b}, @var{a})}
12772 @tab @code{MWTACCG @var{a},@var{b}}
12773 @item @code{uw1 __MXOR (uw1, uw1)}
12774 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12775 @tab @code{MXOR @var{a},@var{b},@var{c}}
12776 @end multitable
12777
12778 @node Raw read/write Functions
12779 @subsubsection Raw Read/Write Functions
12780
12781 This sections describes built-in functions related to read and write
12782 instructions to access memory. These functions generate
12783 @code{membar} instructions to flush the I/O load and stores where
12784 appropriate, as described in Fujitsu's manual described above.
12785
12786 @table @code
12787
12788 @item unsigned char __builtin_read8 (void *@var{data})
12789 @item unsigned short __builtin_read16 (void *@var{data})
12790 @item unsigned long __builtin_read32 (void *@var{data})
12791 @item unsigned long long __builtin_read64 (void *@var{data})
12792
12793 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12794 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12795 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12796 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12797 @end table
12798
12799 @node Other Built-in Functions
12800 @subsubsection Other Built-in Functions
12801
12802 This section describes built-in functions that are not named after
12803 a specific FR-V instruction.
12804
12805 @table @code
12806 @item sw2 __IACCreadll (iacc @var{reg})
12807 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12808 for future expansion and must be 0.
12809
12810 @item sw1 __IACCreadl (iacc @var{reg})
12811 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12812 Other values of @var{reg} are rejected as invalid.
12813
12814 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12815 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12816 is reserved for future expansion and must be 0.
12817
12818 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12819 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12820 is 1. Other values of @var{reg} are rejected as invalid.
12821
12822 @item void __data_prefetch0 (const void *@var{x})
12823 Use the @code{dcpl} instruction to load the contents of address @var{x}
12824 into the data cache.
12825
12826 @item void __data_prefetch (const void *@var{x})
12827 Use the @code{nldub} instruction to load the contents of address @var{x}
12828 into the data cache. The instruction is issued in slot I1@.
12829 @end table
12830
12831 @node MIPS DSP Built-in Functions
12832 @subsection MIPS DSP Built-in Functions
12833
12834 The MIPS DSP Application-Specific Extension (ASE) includes new
12835 instructions that are designed to improve the performance of DSP and
12836 media applications. It provides instructions that operate on packed
12837 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12838
12839 GCC supports MIPS DSP operations using both the generic
12840 vector extensions (@pxref{Vector Extensions}) and a collection of
12841 MIPS-specific built-in functions. Both kinds of support are
12842 enabled by the @option{-mdsp} command-line option.
12843
12844 Revision 2 of the ASE was introduced in the second half of 2006.
12845 This revision adds extra instructions to the original ASE, but is
12846 otherwise backwards-compatible with it. You can select revision 2
12847 using the command-line option @option{-mdspr2}; this option implies
12848 @option{-mdsp}.
12849
12850 The SCOUNT and POS bits of the DSP control register are global. The
12851 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12852 POS bits. During optimization, the compiler does not delete these
12853 instructions and it does not delete calls to functions containing
12854 these instructions.
12855
12856 At present, GCC only provides support for operations on 32-bit
12857 vectors. The vector type associated with 8-bit integer data is
12858 usually called @code{v4i8}, the vector type associated with Q7
12859 is usually called @code{v4q7}, the vector type associated with 16-bit
12860 integer data is usually called @code{v2i16}, and the vector type
12861 associated with Q15 is usually called @code{v2q15}. They can be
12862 defined in C as follows:
12863
12864 @smallexample
12865 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12866 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12867 typedef short v2i16 __attribute__ ((vector_size(4)));
12868 typedef short v2q15 __attribute__ ((vector_size(4)));
12869 @end smallexample
12870
12871 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12872 initialized in the same way as aggregates. For example:
12873
12874 @smallexample
12875 v4i8 a = @{1, 2, 3, 4@};
12876 v4i8 b;
12877 b = (v4i8) @{5, 6, 7, 8@};
12878
12879 v2q15 c = @{0x0fcb, 0x3a75@};
12880 v2q15 d;
12881 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12882 @end smallexample
12883
12884 @emph{Note:} The CPU's endianness determines the order in which values
12885 are packed. On little-endian targets, the first value is the least
12886 significant and the last value is the most significant. The opposite
12887 order applies to big-endian targets. For example, the code above
12888 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12889 and @code{4} on big-endian targets.
12890
12891 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12892 representation. As shown in this example, the integer representation
12893 of a Q7 value can be obtained by multiplying the fractional value by
12894 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12895 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12896 @code{0x1.0p31}.
12897
12898 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12899 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12900 and @code{c} and @code{d} are @code{v2q15} values.
12901
12902 @multitable @columnfractions .50 .50
12903 @item C code @tab MIPS instruction
12904 @item @code{a + b} @tab @code{addu.qb}
12905 @item @code{c + d} @tab @code{addq.ph}
12906 @item @code{a - b} @tab @code{subu.qb}
12907 @item @code{c - d} @tab @code{subq.ph}
12908 @end multitable
12909
12910 The table below lists the @code{v2i16} operation for which
12911 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12912 @code{v2i16} values.
12913
12914 @multitable @columnfractions .50 .50
12915 @item C code @tab MIPS instruction
12916 @item @code{e * f} @tab @code{mul.ph}
12917 @end multitable
12918
12919 It is easier to describe the DSP built-in functions if we first define
12920 the following types:
12921
12922 @smallexample
12923 typedef int q31;
12924 typedef int i32;
12925 typedef unsigned int ui32;
12926 typedef long long a64;
12927 @end smallexample
12928
12929 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12930 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12931 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12932 @code{long long}, but we use @code{a64} to indicate values that are
12933 placed in one of the four DSP accumulators (@code{$ac0},
12934 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12935
12936 Also, some built-in functions prefer or require immediate numbers as
12937 parameters, because the corresponding DSP instructions accept both immediate
12938 numbers and register operands, or accept immediate numbers only. The
12939 immediate parameters are listed as follows.
12940
12941 @smallexample
12942 imm0_3: 0 to 3.
12943 imm0_7: 0 to 7.
12944 imm0_15: 0 to 15.
12945 imm0_31: 0 to 31.
12946 imm0_63: 0 to 63.
12947 imm0_255: 0 to 255.
12948 imm_n32_31: -32 to 31.
12949 imm_n512_511: -512 to 511.
12950 @end smallexample
12951
12952 The following built-in functions map directly to a particular MIPS DSP
12953 instruction. Please refer to the architecture specification
12954 for details on what each instruction does.
12955
12956 @smallexample
12957 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12958 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12959 q31 __builtin_mips_addq_s_w (q31, q31)
12960 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12961 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12962 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12963 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12964 q31 __builtin_mips_subq_s_w (q31, q31)
12965 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12966 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12967 i32 __builtin_mips_addsc (i32, i32)
12968 i32 __builtin_mips_addwc (i32, i32)
12969 i32 __builtin_mips_modsub (i32, i32)
12970 i32 __builtin_mips_raddu_w_qb (v4i8)
12971 v2q15 __builtin_mips_absq_s_ph (v2q15)
12972 q31 __builtin_mips_absq_s_w (q31)
12973 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12974 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12975 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12976 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12977 q31 __builtin_mips_preceq_w_phl (v2q15)
12978 q31 __builtin_mips_preceq_w_phr (v2q15)
12979 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12980 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12981 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12982 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12983 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12984 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12985 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12986 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12987 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12988 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12989 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12990 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12991 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12992 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12993 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12994 q31 __builtin_mips_shll_s_w (q31, i32)
12995 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12996 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12997 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12998 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12999 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13000 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13001 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13002 q31 __builtin_mips_shra_r_w (q31, i32)
13003 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13004 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13005 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13006 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13007 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13008 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13009 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13010 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
13011 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
13012 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
13013 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
13014 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
13015 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
13016 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
13017 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
13018 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
13019 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
13020 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
13021 i32 __builtin_mips_bitrev (i32)
13022 i32 __builtin_mips_insv (i32, i32)
13023 v4i8 __builtin_mips_repl_qb (imm0_255)
13024 v4i8 __builtin_mips_repl_qb (i32)
13025 v2q15 __builtin_mips_repl_ph (imm_n512_511)
13026 v2q15 __builtin_mips_repl_ph (i32)
13027 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
13028 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
13029 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
13030 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
13031 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
13032 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
13033 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
13034 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
13035 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
13036 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
13037 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
13038 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
13039 i32 __builtin_mips_extr_w (a64, imm0_31)
13040 i32 __builtin_mips_extr_w (a64, i32)
13041 i32 __builtin_mips_extr_r_w (a64, imm0_31)
13042 i32 __builtin_mips_extr_s_h (a64, i32)
13043 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
13044 i32 __builtin_mips_extr_rs_w (a64, i32)
13045 i32 __builtin_mips_extr_s_h (a64, imm0_31)
13046 i32 __builtin_mips_extr_r_w (a64, i32)
13047 i32 __builtin_mips_extp (a64, imm0_31)
13048 i32 __builtin_mips_extp (a64, i32)
13049 i32 __builtin_mips_extpdp (a64, imm0_31)
13050 i32 __builtin_mips_extpdp (a64, i32)
13051 a64 __builtin_mips_shilo (a64, imm_n32_31)
13052 a64 __builtin_mips_shilo (a64, i32)
13053 a64 __builtin_mips_mthlip (a64, i32)
13054 void __builtin_mips_wrdsp (i32, imm0_63)
13055 i32 __builtin_mips_rddsp (imm0_63)
13056 i32 __builtin_mips_lbux (void *, i32)
13057 i32 __builtin_mips_lhx (void *, i32)
13058 i32 __builtin_mips_lwx (void *, i32)
13059 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
13060 i32 __builtin_mips_bposge32 (void)
13061 a64 __builtin_mips_madd (a64, i32, i32);
13062 a64 __builtin_mips_maddu (a64, ui32, ui32);
13063 a64 __builtin_mips_msub (a64, i32, i32);
13064 a64 __builtin_mips_msubu (a64, ui32, ui32);
13065 a64 __builtin_mips_mult (i32, i32);
13066 a64 __builtin_mips_multu (ui32, ui32);
13067 @end smallexample
13068
13069 The following built-in functions map directly to a particular MIPS DSP REV 2
13070 instruction. Please refer to the architecture specification
13071 for details on what each instruction does.
13072
13073 @smallexample
13074 v4q7 __builtin_mips_absq_s_qb (v4q7);
13075 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13076 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13077 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13078 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13079 i32 __builtin_mips_append (i32, i32, imm0_31);
13080 i32 __builtin_mips_balign (i32, i32, imm0_3);
13081 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13082 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13083 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13084 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13085 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13086 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13087 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13088 q31 __builtin_mips_mulq_rs_w (q31, q31);
13089 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13090 q31 __builtin_mips_mulq_s_w (q31, q31);
13091 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13092 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13093 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13094 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13095 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13096 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13097 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13098 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13099 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13100 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13101 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13102 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13103 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13104 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13105 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13106 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13107 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13108 q31 __builtin_mips_addqh_w (q31, q31);
13109 q31 __builtin_mips_addqh_r_w (q31, q31);
13110 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13111 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13112 q31 __builtin_mips_subqh_w (q31, q31);
13113 q31 __builtin_mips_subqh_r_w (q31, q31);
13114 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13115 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13116 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13117 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13118 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13119 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13120 @end smallexample
13121
13122
13123 @node MIPS Paired-Single Support
13124 @subsection MIPS Paired-Single Support
13125
13126 The MIPS64 architecture includes a number of instructions that
13127 operate on pairs of single-precision floating-point values.
13128 Each pair is packed into a 64-bit floating-point register,
13129 with one element being designated the ``upper half'' and
13130 the other being designated the ``lower half''.
13131
13132 GCC supports paired-single operations using both the generic
13133 vector extensions (@pxref{Vector Extensions}) and a collection of
13134 MIPS-specific built-in functions. Both kinds of support are
13135 enabled by the @option{-mpaired-single} command-line option.
13136
13137 The vector type associated with paired-single values is usually
13138 called @code{v2sf}. It can be defined in C as follows:
13139
13140 @smallexample
13141 typedef float v2sf __attribute__ ((vector_size (8)));
13142 @end smallexample
13143
13144 @code{v2sf} values are initialized in the same way as aggregates.
13145 For example:
13146
13147 @smallexample
13148 v2sf a = @{1.5, 9.1@};
13149 v2sf b;
13150 float e, f;
13151 b = (v2sf) @{e, f@};
13152 @end smallexample
13153
13154 @emph{Note:} The CPU's endianness determines which value is stored in
13155 the upper half of a register and which value is stored in the lower half.
13156 On little-endian targets, the first value is the lower one and the second
13157 value is the upper one. The opposite order applies to big-endian targets.
13158 For example, the code above sets the lower half of @code{a} to
13159 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13160
13161 @node MIPS Loongson Built-in Functions
13162 @subsection MIPS Loongson Built-in Functions
13163
13164 GCC provides intrinsics to access the SIMD instructions provided by the
13165 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13166 available after inclusion of the @code{loongson.h} header file,
13167 operate on the following 64-bit vector types:
13168
13169 @itemize
13170 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13171 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13172 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13173 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13174 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13175 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13176 @end itemize
13177
13178 The intrinsics provided are listed below; each is named after the
13179 machine instruction to which it corresponds, with suffixes added as
13180 appropriate to distinguish intrinsics that expand to the same machine
13181 instruction yet have different argument types. Refer to the architecture
13182 documentation for a description of the functionality of each
13183 instruction.
13184
13185 @smallexample
13186 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13187 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13188 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13189 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13190 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13191 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13192 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13193 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13194 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13195 uint64_t paddd_u (uint64_t s, uint64_t t);
13196 int64_t paddd_s (int64_t s, int64_t t);
13197 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13198 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13199 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13200 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13201 uint64_t pandn_ud (uint64_t s, uint64_t t);
13202 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13203 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13204 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13205 int64_t pandn_sd (int64_t s, int64_t t);
13206 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13207 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13208 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13209 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13210 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13211 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13212 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13213 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13214 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13215 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13216 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13217 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13218 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13219 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13220 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13221 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13222 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13223 uint16x4_t pextrh_u (uint16x4_t s, int field);
13224 int16x4_t pextrh_s (int16x4_t s, int field);
13225 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13226 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13227 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13228 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13229 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13230 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13231 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13232 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13233 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13234 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13235 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13236 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13237 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13238 uint8x8_t pmovmskb_u (uint8x8_t s);
13239 int8x8_t pmovmskb_s (int8x8_t s);
13240 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13241 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13242 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13243 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13244 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13245 uint16x4_t biadd (uint8x8_t s);
13246 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13247 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13248 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13249 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13250 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13251 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13252 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13253 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13254 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13255 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13256 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13257 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13258 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13259 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13260 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13261 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13262 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13263 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13264 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13265 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13266 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13267 uint64_t psubd_u (uint64_t s, uint64_t t);
13268 int64_t psubd_s (int64_t s, int64_t t);
13269 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13270 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13271 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13272 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13273 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13274 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13275 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13276 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13277 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13278 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13279 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13280 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13281 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13282 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13283 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13284 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13285 @end smallexample
13286
13287 @menu
13288 * Paired-Single Arithmetic::
13289 * Paired-Single Built-in Functions::
13290 * MIPS-3D Built-in Functions::
13291 @end menu
13292
13293 @node Paired-Single Arithmetic
13294 @subsubsection Paired-Single Arithmetic
13295
13296 The table below lists the @code{v2sf} operations for which hardware
13297 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13298 values and @code{x} is an integral value.
13299
13300 @multitable @columnfractions .50 .50
13301 @item C code @tab MIPS instruction
13302 @item @code{a + b} @tab @code{add.ps}
13303 @item @code{a - b} @tab @code{sub.ps}
13304 @item @code{-a} @tab @code{neg.ps}
13305 @item @code{a * b} @tab @code{mul.ps}
13306 @item @code{a * b + c} @tab @code{madd.ps}
13307 @item @code{a * b - c} @tab @code{msub.ps}
13308 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13309 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13310 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13311 @end multitable
13312
13313 Note that the multiply-accumulate instructions can be disabled
13314 using the command-line option @code{-mno-fused-madd}.
13315
13316 @node Paired-Single Built-in Functions
13317 @subsubsection Paired-Single Built-in Functions
13318
13319 The following paired-single functions map directly to a particular
13320 MIPS instruction. Please refer to the architecture specification
13321 for details on what each instruction does.
13322
13323 @table @code
13324 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13325 Pair lower lower (@code{pll.ps}).
13326
13327 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13328 Pair upper lower (@code{pul.ps}).
13329
13330 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13331 Pair lower upper (@code{plu.ps}).
13332
13333 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13334 Pair upper upper (@code{puu.ps}).
13335
13336 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13337 Convert pair to paired single (@code{cvt.ps.s}).
13338
13339 @item float __builtin_mips_cvt_s_pl (v2sf)
13340 Convert pair lower to single (@code{cvt.s.pl}).
13341
13342 @item float __builtin_mips_cvt_s_pu (v2sf)
13343 Convert pair upper to single (@code{cvt.s.pu}).
13344
13345 @item v2sf __builtin_mips_abs_ps (v2sf)
13346 Absolute value (@code{abs.ps}).
13347
13348 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13349 Align variable (@code{alnv.ps}).
13350
13351 @emph{Note:} The value of the third parameter must be 0 or 4
13352 modulo 8, otherwise the result is unpredictable. Please read the
13353 instruction description for details.
13354 @end table
13355
13356 The following multi-instruction functions are also available.
13357 In each case, @var{cond} can be any of the 16 floating-point conditions:
13358 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13359 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13360 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13361
13362 @table @code
13363 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13364 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13365 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13366 @code{movt.ps}/@code{movf.ps}).
13367
13368 The @code{movt} functions return the value @var{x} computed by:
13369
13370 @smallexample
13371 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13372 mov.ps @var{x},@var{c}
13373 movt.ps @var{x},@var{d},@var{cc}
13374 @end smallexample
13375
13376 The @code{movf} functions are similar but use @code{movf.ps} instead
13377 of @code{movt.ps}.
13378
13379 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13380 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13381 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13382 @code{bc1t}/@code{bc1f}).
13383
13384 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13385 and return either the upper or lower half of the result. For example:
13386
13387 @smallexample
13388 v2sf a, b;
13389 if (__builtin_mips_upper_c_eq_ps (a, b))
13390 upper_halves_are_equal ();
13391 else
13392 upper_halves_are_unequal ();
13393
13394 if (__builtin_mips_lower_c_eq_ps (a, b))
13395 lower_halves_are_equal ();
13396 else
13397 lower_halves_are_unequal ();
13398 @end smallexample
13399 @end table
13400
13401 @node MIPS-3D Built-in Functions
13402 @subsubsection MIPS-3D Built-in Functions
13403
13404 The MIPS-3D Application-Specific Extension (ASE) includes additional
13405 paired-single instructions that are designed to improve the performance
13406 of 3D graphics operations. Support for these instructions is controlled
13407 by the @option{-mips3d} command-line option.
13408
13409 The functions listed below map directly to a particular MIPS-3D
13410 instruction. Please refer to the architecture specification for
13411 more details on what each instruction does.
13412
13413 @table @code
13414 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13415 Reduction add (@code{addr.ps}).
13416
13417 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13418 Reduction multiply (@code{mulr.ps}).
13419
13420 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13421 Convert paired single to paired word (@code{cvt.pw.ps}).
13422
13423 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13424 Convert paired word to paired single (@code{cvt.ps.pw}).
13425
13426 @item float __builtin_mips_recip1_s (float)
13427 @itemx double __builtin_mips_recip1_d (double)
13428 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13429 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13430
13431 @item float __builtin_mips_recip2_s (float, float)
13432 @itemx double __builtin_mips_recip2_d (double, double)
13433 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13434 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13435
13436 @item float __builtin_mips_rsqrt1_s (float)
13437 @itemx double __builtin_mips_rsqrt1_d (double)
13438 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13439 Reduced-precision reciprocal square root (sequence step 1)
13440 (@code{rsqrt1.@var{fmt}}).
13441
13442 @item float __builtin_mips_rsqrt2_s (float, float)
13443 @itemx double __builtin_mips_rsqrt2_d (double, double)
13444 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13445 Reduced-precision reciprocal square root (sequence step 2)
13446 (@code{rsqrt2.@var{fmt}}).
13447 @end table
13448
13449 The following multi-instruction functions are also available.
13450 In each case, @var{cond} can be any of the 16 floating-point conditions:
13451 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13452 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13453 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13454
13455 @table @code
13456 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13457 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13458 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13459 @code{bc1t}/@code{bc1f}).
13460
13461 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13462 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13463 For example:
13464
13465 @smallexample
13466 float a, b;
13467 if (__builtin_mips_cabs_eq_s (a, b))
13468 true ();
13469 else
13470 false ();
13471 @end smallexample
13472
13473 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13474 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13475 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13476 @code{bc1t}/@code{bc1f}).
13477
13478 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13479 and return either the upper or lower half of the result. For example:
13480
13481 @smallexample
13482 v2sf a, b;
13483 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13484 upper_halves_are_equal ();
13485 else
13486 upper_halves_are_unequal ();
13487
13488 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13489 lower_halves_are_equal ();
13490 else
13491 lower_halves_are_unequal ();
13492 @end smallexample
13493
13494 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13495 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13496 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13497 @code{movt.ps}/@code{movf.ps}).
13498
13499 The @code{movt} functions return the value @var{x} computed by:
13500
13501 @smallexample
13502 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13503 mov.ps @var{x},@var{c}
13504 movt.ps @var{x},@var{d},@var{cc}
13505 @end smallexample
13506
13507 The @code{movf} functions are similar but use @code{movf.ps} instead
13508 of @code{movt.ps}.
13509
13510 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13511 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13512 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13513 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13514 Comparison of two paired-single values
13515 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13516 @code{bc1any2t}/@code{bc1any2f}).
13517
13518 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13519 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13520 result is true and the @code{all} forms return true if both results are true.
13521 For example:
13522
13523 @smallexample
13524 v2sf a, b;
13525 if (__builtin_mips_any_c_eq_ps (a, b))
13526 one_is_true ();
13527 else
13528 both_are_false ();
13529
13530 if (__builtin_mips_all_c_eq_ps (a, b))
13531 both_are_true ();
13532 else
13533 one_is_false ();
13534 @end smallexample
13535
13536 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13537 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13538 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13539 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13540 Comparison of four paired-single values
13541 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13542 @code{bc1any4t}/@code{bc1any4f}).
13543
13544 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13545 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13546 The @code{any} forms return true if any of the four results are true
13547 and the @code{all} forms return true if all four results are true.
13548 For example:
13549
13550 @smallexample
13551 v2sf a, b, c, d;
13552 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13553 some_are_true ();
13554 else
13555 all_are_false ();
13556
13557 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13558 all_are_true ();
13559 else
13560 some_are_false ();
13561 @end smallexample
13562 @end table
13563
13564 @node Other MIPS Built-in Functions
13565 @subsection Other MIPS Built-in Functions
13566
13567 GCC provides other MIPS-specific built-in functions:
13568
13569 @table @code
13570 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13571 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13572 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13573 when this function is available.
13574
13575 @item unsigned int __builtin_mips_get_fcsr (void)
13576 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13577 Get and set the contents of the floating-point control and status register
13578 (FPU control register 31). These functions are only available in hard-float
13579 code but can be called in both MIPS16 and non-MIPS16 contexts.
13580
13581 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13582 register except the condition codes, which GCC assumes are preserved.
13583 @end table
13584
13585 @node MSP430 Built-in Functions
13586 @subsection MSP430 Built-in Functions
13587
13588 GCC provides a couple of special builtin functions to aid in the
13589 writing of interrupt handlers in C.
13590
13591 @table @code
13592 @item __bic_SR_register_on_exit (int @var{mask})
13593 This clears the indicated bits in the saved copy of the status register
13594 currently residing on the stack. This only works inside interrupt
13595 handlers and the changes to the status register will only take affect
13596 once the handler returns.
13597
13598 @item __bis_SR_register_on_exit (int @var{mask})
13599 This sets the indicated bits in the saved copy of the status register
13600 currently residing on the stack. This only works inside interrupt
13601 handlers and the changes to the status register will only take affect
13602 once the handler returns.
13603
13604 @item __delay_cycles (long long @var{cycles})
13605 This inserts an instruction sequence that takes exactly @var{cycles}
13606 cycles (between 0 and about 17E9) to complete. The inserted sequence
13607 may use jumps, loops, or no-ops, and does not interfere with any other
13608 instructions. Note that @var{cycles} must be a compile-time constant
13609 integer - that is, you must pass a number, not a variable that may be
13610 optimized to a constant later. The number of cycles delayed by this
13611 builtin is exact.
13612 @end table
13613
13614 @node NDS32 Built-in Functions
13615 @subsection NDS32 Built-in Functions
13616
13617 These built-in functions are available for the NDS32 target:
13618
13619 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13620 Insert an ISYNC instruction into the instruction stream where
13621 @var{addr} is an instruction address for serialization.
13622 @end deftypefn
13623
13624 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13625 Insert an ISB instruction into the instruction stream.
13626 @end deftypefn
13627
13628 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13629 Return the content of a system register which is mapped by @var{sr}.
13630 @end deftypefn
13631
13632 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13633 Return the content of a user space register which is mapped by @var{usr}.
13634 @end deftypefn
13635
13636 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13637 Move the @var{value} to a system register which is mapped by @var{sr}.
13638 @end deftypefn
13639
13640 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13641 Move the @var{value} to a user space register which is mapped by @var{usr}.
13642 @end deftypefn
13643
13644 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13645 Enable global interrupt.
13646 @end deftypefn
13647
13648 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13649 Disable global interrupt.
13650 @end deftypefn
13651
13652 @node picoChip Built-in Functions
13653 @subsection picoChip Built-in Functions
13654
13655 GCC provides an interface to selected machine instructions from the
13656 picoChip instruction set.
13657
13658 @table @code
13659 @item int __builtin_sbc (int @var{value})
13660 Sign bit count. Return the number of consecutive bits in @var{value}
13661 that have the same value as the sign bit. The result is the number of
13662 leading sign bits minus one, giving the number of redundant sign bits in
13663 @var{value}.
13664
13665 @item int __builtin_byteswap (int @var{value})
13666 Byte swap. Return the result of swapping the upper and lower bytes of
13667 @var{value}.
13668
13669 @item int __builtin_brev (int @var{value})
13670 Bit reversal. Return the result of reversing the bits in
13671 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13672 and so on.
13673
13674 @item int __builtin_adds (int @var{x}, int @var{y})
13675 Saturating addition. Return the result of adding @var{x} and @var{y},
13676 storing the value 32767 if the result overflows.
13677
13678 @item int __builtin_subs (int @var{x}, int @var{y})
13679 Saturating subtraction. Return the result of subtracting @var{y} from
13680 @var{x}, storing the value @minus{}32768 if the result overflows.
13681
13682 @item void __builtin_halt (void)
13683 Halt. The processor stops execution. This built-in is useful for
13684 implementing assertions.
13685
13686 @end table
13687
13688 @node PowerPC Built-in Functions
13689 @subsection PowerPC Built-in Functions
13690
13691 The following built-in functions are always available and can be used to
13692 check the PowerPC target platform type:
13693
13694 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
13695 This function is a @code{nop} on the PowerPC platform and is included solely
13696 to maintain API compatibility with the x86 builtins.
13697 @end deftypefn
13698
13699 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
13700 This function returns a value of @code{1} if the run-time CPU is of type
13701 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
13702 detected:
13703
13704 @table @samp
13705 @item power9
13706 IBM POWER9 Server CPU.
13707 @item power8
13708 IBM POWER8 Server CPU.
13709 @item power7
13710 IBM POWER7 Server CPU.
13711 @item power6x
13712 IBM POWER6 Server CPU (RAW mode).
13713 @item power6
13714 IBM POWER6 Server CPU (Architected mode).
13715 @item power5+
13716 IBM POWER5+ Server CPU.
13717 @item power5
13718 IBM POWER5 Server CPU.
13719 @item ppc970
13720 IBM 970 Server CPU (ie, Apple G5).
13721 @item power4
13722 IBM POWER4 Server CPU.
13723 @item ppca2
13724 IBM A2 64-bit Embedded CPU
13725 @item ppc476
13726 IBM PowerPC 476FP 32-bit Embedded CPU.
13727 @item ppc464
13728 IBM PowerPC 464 32-bit Embedded CPU.
13729 @item ppc440
13730 PowerPC 440 32-bit Embedded CPU.
13731 @item ppc405
13732 PowerPC 405 32-bit Embedded CPU.
13733 @item ppc-cell-be
13734 IBM PowerPC Cell Broadband Engine Architecture CPU.
13735 @end table
13736
13737 Here is an example:
13738 @smallexample
13739 if (__builtin_cpu_is ("power8"))
13740 @{
13741 do_power8 (); // POWER8 specific implementation.
13742 @}
13743 else
13744 @{
13745 do_generic (); // Generic implementation.
13746 @}
13747 @end smallexample
13748 @end deftypefn
13749
13750 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
13751 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
13752 feature @var{feature} and returns @code{0} otherwise. The following features can be
13753 detected:
13754
13755 @table @samp
13756 @item 4xxmac
13757 4xx CPU has a Multiply Accumulator.
13758 @item altivec
13759 CPU has a SIMD/Vector Unit.
13760 @item arch_2_05
13761 CPU supports ISA 2.05 (eg, POWER6)
13762 @item arch_2_06
13763 CPU supports ISA 2.06 (eg, POWER7)
13764 @item arch_2_07
13765 CPU supports ISA 2.07 (eg, POWER8)
13766 @item arch_3_00
13767 CPU supports ISA 3.00 (eg, POWER9)
13768 @item archpmu
13769 CPU supports the set of compatible performance monitoring events.
13770 @item booke
13771 CPU supports the Embedded ISA category.
13772 @item cellbe
13773 CPU has a CELL broadband engine.
13774 @item dfp
13775 CPU has a decimal floating point unit.
13776 @item dscr
13777 CPU supports the data stream control register.
13778 @item ebb
13779 CPU supports event base branching.
13780 @item efpdouble
13781 CPU has a SPE double precision floating point unit.
13782 @item efpsingle
13783 CPU has a SPE single precision floating point unit.
13784 @item fpu
13785 CPU has a floating point unit.
13786 @item htm
13787 CPU has hardware transaction memory instructions.
13788 @item htm-nosc
13789 Kernel aborts hardware transactions when a syscall is made.
13790 @item ic_snoop
13791 CPU supports icache snooping capabilities.
13792 @item ieee128
13793 CPU supports 128-bit IEEE binary floating point instructions.
13794 @item isel
13795 CPU supports the integer select instruction.
13796 @item mmu
13797 CPU has a memory management unit.
13798 @item notb
13799 CPU does not have a timebase (eg, 601 and 403gx).
13800 @item pa6t
13801 CPU supports the PA Semi 6T CORE ISA.
13802 @item power4
13803 CPU supports ISA 2.00 (eg, POWER4)
13804 @item power5
13805 CPU supports ISA 2.02 (eg, POWER5)
13806 @item power5+
13807 CPU supports ISA 2.03 (eg, POWER5+)
13808 @item power6x
13809 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
13810 @item ppc32
13811 CPU supports 32-bit mode execution.
13812 @item ppc601
13813 CPU supports the old POWER ISA (eg, 601)
13814 @item ppc64
13815 CPU supports 64-bit mode execution.
13816 @item ppcle
13817 CPU supports a little-endian mode that uses address swizzling.
13818 @item smt
13819 CPU support simultaneous multi-threading.
13820 @item spe
13821 CPU has a signal processing extension unit.
13822 @item tar
13823 CPU supports the target address register.
13824 @item true_le
13825 CPU supports true little-endian mode.
13826 @item ucache
13827 CPU has unified I/D cache.
13828 @item vcrypto
13829 CPU supports the vector cryptography instructions.
13830 @item vsx
13831 CPU supports the vector-scalar extension.
13832 @end table
13833
13834 Here is an example:
13835 @smallexample
13836 if (__builtin_cpu_supports ("fpu"))
13837 @{
13838 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
13839 @}
13840 else
13841 @{
13842 dst = __fadd (src1, src2); // Software FP addition function.
13843 @}
13844 @end smallexample
13845 @end deftypefn
13846
13847 These built-in functions are available for the PowerPC family of
13848 processors:
13849 @smallexample
13850 float __builtin_recipdivf (float, float);
13851 float __builtin_rsqrtf (float);
13852 double __builtin_recipdiv (double, double);
13853 double __builtin_rsqrt (double);
13854 uint64_t __builtin_ppc_get_timebase ();
13855 unsigned long __builtin_ppc_mftb ();
13856 double __builtin_unpack_longdouble (long double, int);
13857 long double __builtin_pack_longdouble (double, double);
13858 @end smallexample
13859
13860 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13861 @code{__builtin_rsqrtf} functions generate multiple instructions to
13862 implement the reciprocal sqrt functionality using reciprocal sqrt
13863 estimate instructions.
13864
13865 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13866 functions generate multiple instructions to implement division using
13867 the reciprocal estimate instructions.
13868
13869 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13870 functions generate instructions to read the Time Base Register. The
13871 @code{__builtin_ppc_get_timebase} function may generate multiple
13872 instructions and always returns the 64 bits of the Time Base Register.
13873 The @code{__builtin_ppc_mftb} function always generates one instruction and
13874 returns the Time Base Register value as an unsigned long, throwing away
13875 the most significant word on 32-bit environments.
13876
13877 The following built-in functions are available for the PowerPC family
13878 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13879 or @option{-mpopcntd}):
13880 @smallexample
13881 long __builtin_bpermd (long, long);
13882 int __builtin_divwe (int, int);
13883 int __builtin_divweo (int, int);
13884 unsigned int __builtin_divweu (unsigned int, unsigned int);
13885 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13886 long __builtin_divde (long, long);
13887 long __builtin_divdeo (long, long);
13888 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13889 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13890 unsigned int cdtbcd (unsigned int);
13891 unsigned int cbcdtd (unsigned int);
13892 unsigned int addg6s (unsigned int, unsigned int);
13893 @end smallexample
13894
13895 The @code{__builtin_divde}, @code{__builtin_divdeo},
13896 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13897 64-bit environment support ISA 2.06 or later.
13898
13899 The following built-in functions are available for the PowerPC family
13900 of processors when hardware decimal floating point
13901 (@option{-mhard-dfp}) is available:
13902 @smallexample
13903 _Decimal64 __builtin_dxex (_Decimal64);
13904 _Decimal128 __builtin_dxexq (_Decimal128);
13905 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13906 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13907 _Decimal64 __builtin_denbcd (int, _Decimal64);
13908 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13909 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13910 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13911 _Decimal64 __builtin_dscli (_Decimal64, int);
13912 _Decimal128 __builtin_dscliq (_Decimal128, int);
13913 _Decimal64 __builtin_dscri (_Decimal64, int);
13914 _Decimal128 __builtin_dscriq (_Decimal128, int);
13915 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13916 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13917 @end smallexample
13918
13919 The following built-in functions are available for the PowerPC family
13920 of processors when the Vector Scalar (vsx) instruction set is
13921 available:
13922 @smallexample
13923 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13924 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13925 unsigned long long);
13926 @end smallexample
13927
13928 @node PowerPC AltiVec/VSX Built-in Functions
13929 @subsection PowerPC AltiVec Built-in Functions
13930
13931 GCC provides an interface for the PowerPC family of processors to access
13932 the AltiVec operations described in Motorola's AltiVec Programming
13933 Interface Manual. The interface is made available by including
13934 @code{<altivec.h>} and using @option{-maltivec} and
13935 @option{-mabi=altivec}. The interface supports the following vector
13936 types.
13937
13938 @smallexample
13939 vector unsigned char
13940 vector signed char
13941 vector bool char
13942
13943 vector unsigned short
13944 vector signed short
13945 vector bool short
13946 vector pixel
13947
13948 vector unsigned int
13949 vector signed int
13950 vector bool int
13951 vector float
13952 @end smallexample
13953
13954 If @option{-mvsx} is used the following additional vector types are
13955 implemented.
13956
13957 @smallexample
13958 vector unsigned long
13959 vector signed long
13960 vector double
13961 @end smallexample
13962
13963 The long types are only implemented for 64-bit code generation, and
13964 the long type is only used in the floating point/integer conversion
13965 instructions.
13966
13967 GCC's implementation of the high-level language interface available from
13968 C and C++ code differs from Motorola's documentation in several ways.
13969
13970 @itemize @bullet
13971
13972 @item
13973 A vector constant is a list of constant expressions within curly braces.
13974
13975 @item
13976 A vector initializer requires no cast if the vector constant is of the
13977 same type as the variable it is initializing.
13978
13979 @item
13980 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13981 vector type is the default signedness of the base type. The default
13982 varies depending on the operating system, so a portable program should
13983 always specify the signedness.
13984
13985 @item
13986 Compiling with @option{-maltivec} adds keywords @code{__vector},
13987 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13988 @code{bool}. When compiling ISO C, the context-sensitive substitution
13989 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13990 disabled. To use them, you must include @code{<altivec.h>} instead.
13991
13992 @item
13993 GCC allows using a @code{typedef} name as the type specifier for a
13994 vector type.
13995
13996 @item
13997 For C, overloaded functions are implemented with macros so the following
13998 does not work:
13999
14000 @smallexample
14001 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
14002 @end smallexample
14003
14004 @noindent
14005 Since @code{vec_add} is a macro, the vector constant in the example
14006 is treated as four separate arguments. Wrap the entire argument in
14007 parentheses for this to work.
14008 @end itemize
14009
14010 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
14011 Internally, GCC uses built-in functions to achieve the functionality in
14012 the aforementioned header file, but they are not supported and are
14013 subject to change without notice.
14014
14015 The following interfaces are supported for the generic and specific
14016 AltiVec operations and the AltiVec predicates. In cases where there
14017 is a direct mapping between generic and specific operations, only the
14018 generic names are shown here, although the specific operations can also
14019 be used.
14020
14021 Arguments that are documented as @code{const int} require literal
14022 integral values within the range required for that operation.
14023
14024 @smallexample
14025 vector signed char vec_abs (vector signed char);
14026 vector signed short vec_abs (vector signed short);
14027 vector signed int vec_abs (vector signed int);
14028 vector float vec_abs (vector float);
14029
14030 vector signed char vec_abss (vector signed char);
14031 vector signed short vec_abss (vector signed short);
14032 vector signed int vec_abss (vector signed int);
14033
14034 vector signed char vec_add (vector bool char, vector signed char);
14035 vector signed char vec_add (vector signed char, vector bool char);
14036 vector signed char vec_add (vector signed char, vector signed char);
14037 vector unsigned char vec_add (vector bool char, vector unsigned char);
14038 vector unsigned char vec_add (vector unsigned char, vector bool char);
14039 vector unsigned char vec_add (vector unsigned char,
14040 vector unsigned char);
14041 vector signed short vec_add (vector bool short, vector signed short);
14042 vector signed short vec_add (vector signed short, vector bool short);
14043 vector signed short vec_add (vector signed short, vector signed short);
14044 vector unsigned short vec_add (vector bool short,
14045 vector unsigned short);
14046 vector unsigned short vec_add (vector unsigned short,
14047 vector bool short);
14048 vector unsigned short vec_add (vector unsigned short,
14049 vector unsigned short);
14050 vector signed int vec_add (vector bool int, vector signed int);
14051 vector signed int vec_add (vector signed int, vector bool int);
14052 vector signed int vec_add (vector signed int, vector signed int);
14053 vector unsigned int vec_add (vector bool int, vector unsigned int);
14054 vector unsigned int vec_add (vector unsigned int, vector bool int);
14055 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
14056 vector float vec_add (vector float, vector float);
14057
14058 vector float vec_vaddfp (vector float, vector float);
14059
14060 vector signed int vec_vadduwm (vector bool int, vector signed int);
14061 vector signed int vec_vadduwm (vector signed int, vector bool int);
14062 vector signed int vec_vadduwm (vector signed int, vector signed int);
14063 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
14064 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14065 vector unsigned int vec_vadduwm (vector unsigned int,
14066 vector unsigned int);
14067
14068 vector signed short vec_vadduhm (vector bool short,
14069 vector signed short);
14070 vector signed short vec_vadduhm (vector signed short,
14071 vector bool short);
14072 vector signed short vec_vadduhm (vector signed short,
14073 vector signed short);
14074 vector unsigned short vec_vadduhm (vector bool short,
14075 vector unsigned short);
14076 vector unsigned short vec_vadduhm (vector unsigned short,
14077 vector bool short);
14078 vector unsigned short vec_vadduhm (vector unsigned short,
14079 vector unsigned short);
14080
14081 vector signed char vec_vaddubm (vector bool char, vector signed char);
14082 vector signed char vec_vaddubm (vector signed char, vector bool char);
14083 vector signed char vec_vaddubm (vector signed char, vector signed char);
14084 vector unsigned char vec_vaddubm (vector bool char,
14085 vector unsigned char);
14086 vector unsigned char vec_vaddubm (vector unsigned char,
14087 vector bool char);
14088 vector unsigned char vec_vaddubm (vector unsigned char,
14089 vector unsigned char);
14090
14091 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14092
14093 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14094 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14095 vector unsigned char vec_adds (vector unsigned char,
14096 vector unsigned char);
14097 vector signed char vec_adds (vector bool char, vector signed char);
14098 vector signed char vec_adds (vector signed char, vector bool char);
14099 vector signed char vec_adds (vector signed char, vector signed char);
14100 vector unsigned short vec_adds (vector bool short,
14101 vector unsigned short);
14102 vector unsigned short vec_adds (vector unsigned short,
14103 vector bool short);
14104 vector unsigned short vec_adds (vector unsigned short,
14105 vector unsigned short);
14106 vector signed short vec_adds (vector bool short, vector signed short);
14107 vector signed short vec_adds (vector signed short, vector bool short);
14108 vector signed short vec_adds (vector signed short, vector signed short);
14109 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14110 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14111 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14112 vector signed int vec_adds (vector bool int, vector signed int);
14113 vector signed int vec_adds (vector signed int, vector bool int);
14114 vector signed int vec_adds (vector signed int, vector signed int);
14115
14116 vector signed int vec_vaddsws (vector bool int, vector signed int);
14117 vector signed int vec_vaddsws (vector signed int, vector bool int);
14118 vector signed int vec_vaddsws (vector signed int, vector signed int);
14119
14120 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14121 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14122 vector unsigned int vec_vadduws (vector unsigned int,
14123 vector unsigned int);
14124
14125 vector signed short vec_vaddshs (vector bool short,
14126 vector signed short);
14127 vector signed short vec_vaddshs (vector signed short,
14128 vector bool short);
14129 vector signed short vec_vaddshs (vector signed short,
14130 vector signed short);
14131
14132 vector unsigned short vec_vadduhs (vector bool short,
14133 vector unsigned short);
14134 vector unsigned short vec_vadduhs (vector unsigned short,
14135 vector bool short);
14136 vector unsigned short vec_vadduhs (vector unsigned short,
14137 vector unsigned short);
14138
14139 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14140 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14141 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14142
14143 vector unsigned char vec_vaddubs (vector bool char,
14144 vector unsigned char);
14145 vector unsigned char vec_vaddubs (vector unsigned char,
14146 vector bool char);
14147 vector unsigned char vec_vaddubs (vector unsigned char,
14148 vector unsigned char);
14149
14150 vector float vec_and (vector float, vector float);
14151 vector float vec_and (vector float, vector bool int);
14152 vector float vec_and (vector bool int, vector float);
14153 vector bool int vec_and (vector bool int, vector bool int);
14154 vector signed int vec_and (vector bool int, vector signed int);
14155 vector signed int vec_and (vector signed int, vector bool int);
14156 vector signed int vec_and (vector signed int, vector signed int);
14157 vector unsigned int vec_and (vector bool int, vector unsigned int);
14158 vector unsigned int vec_and (vector unsigned int, vector bool int);
14159 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14160 vector bool short vec_and (vector bool short, vector bool short);
14161 vector signed short vec_and (vector bool short, vector signed short);
14162 vector signed short vec_and (vector signed short, vector bool short);
14163 vector signed short vec_and (vector signed short, vector signed short);
14164 vector unsigned short vec_and (vector bool short,
14165 vector unsigned short);
14166 vector unsigned short vec_and (vector unsigned short,
14167 vector bool short);
14168 vector unsigned short vec_and (vector unsigned short,
14169 vector unsigned short);
14170 vector signed char vec_and (vector bool char, vector signed char);
14171 vector bool char vec_and (vector bool char, vector bool char);
14172 vector signed char vec_and (vector signed char, vector bool char);
14173 vector signed char vec_and (vector signed char, vector signed char);
14174 vector unsigned char vec_and (vector bool char, vector unsigned char);
14175 vector unsigned char vec_and (vector unsigned char, vector bool char);
14176 vector unsigned char vec_and (vector unsigned char,
14177 vector unsigned char);
14178
14179 vector float vec_andc (vector float, vector float);
14180 vector float vec_andc (vector float, vector bool int);
14181 vector float vec_andc (vector bool int, vector float);
14182 vector bool int vec_andc (vector bool int, vector bool int);
14183 vector signed int vec_andc (vector bool int, vector signed int);
14184 vector signed int vec_andc (vector signed int, vector bool int);
14185 vector signed int vec_andc (vector signed int, vector signed int);
14186 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14187 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14188 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14189 vector bool short vec_andc (vector bool short, vector bool short);
14190 vector signed short vec_andc (vector bool short, vector signed short);
14191 vector signed short vec_andc (vector signed short, vector bool short);
14192 vector signed short vec_andc (vector signed short, vector signed short);
14193 vector unsigned short vec_andc (vector bool short,
14194 vector unsigned short);
14195 vector unsigned short vec_andc (vector unsigned short,
14196 vector bool short);
14197 vector unsigned short vec_andc (vector unsigned short,
14198 vector unsigned short);
14199 vector signed char vec_andc (vector bool char, vector signed char);
14200 vector bool char vec_andc (vector bool char, vector bool char);
14201 vector signed char vec_andc (vector signed char, vector bool char);
14202 vector signed char vec_andc (vector signed char, vector signed char);
14203 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14204 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14205 vector unsigned char vec_andc (vector unsigned char,
14206 vector unsigned char);
14207
14208 vector unsigned char vec_avg (vector unsigned char,
14209 vector unsigned char);
14210 vector signed char vec_avg (vector signed char, vector signed char);
14211 vector unsigned short vec_avg (vector unsigned short,
14212 vector unsigned short);
14213 vector signed short vec_avg (vector signed short, vector signed short);
14214 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14215 vector signed int vec_avg (vector signed int, vector signed int);
14216
14217 vector signed int vec_vavgsw (vector signed int, vector signed int);
14218
14219 vector unsigned int vec_vavguw (vector unsigned int,
14220 vector unsigned int);
14221
14222 vector signed short vec_vavgsh (vector signed short,
14223 vector signed short);
14224
14225 vector unsigned short vec_vavguh (vector unsigned short,
14226 vector unsigned short);
14227
14228 vector signed char vec_vavgsb (vector signed char, vector signed char);
14229
14230 vector unsigned char vec_vavgub (vector unsigned char,
14231 vector unsigned char);
14232
14233 vector float vec_copysign (vector float);
14234
14235 vector float vec_ceil (vector float);
14236
14237 vector signed int vec_cmpb (vector float, vector float);
14238
14239 vector bool char vec_cmpeq (vector signed char, vector signed char);
14240 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14241 vector bool short vec_cmpeq (vector signed short, vector signed short);
14242 vector bool short vec_cmpeq (vector unsigned short,
14243 vector unsigned short);
14244 vector bool int vec_cmpeq (vector signed int, vector signed int);
14245 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14246 vector bool int vec_cmpeq (vector float, vector float);
14247
14248 vector bool int vec_vcmpeqfp (vector float, vector float);
14249
14250 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14251 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14252
14253 vector bool short vec_vcmpequh (vector signed short,
14254 vector signed short);
14255 vector bool short vec_vcmpequh (vector unsigned short,
14256 vector unsigned short);
14257
14258 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14259 vector bool char vec_vcmpequb (vector unsigned char,
14260 vector unsigned char);
14261
14262 vector bool int vec_cmpge (vector float, vector float);
14263
14264 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14265 vector bool char vec_cmpgt (vector signed char, vector signed char);
14266 vector bool short vec_cmpgt (vector unsigned short,
14267 vector unsigned short);
14268 vector bool short vec_cmpgt (vector signed short, vector signed short);
14269 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14270 vector bool int vec_cmpgt (vector signed int, vector signed int);
14271 vector bool int vec_cmpgt (vector float, vector float);
14272
14273 vector bool int vec_vcmpgtfp (vector float, vector float);
14274
14275 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14276
14277 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14278
14279 vector bool short vec_vcmpgtsh (vector signed short,
14280 vector signed short);
14281
14282 vector bool short vec_vcmpgtuh (vector unsigned short,
14283 vector unsigned short);
14284
14285 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14286
14287 vector bool char vec_vcmpgtub (vector unsigned char,
14288 vector unsigned char);
14289
14290 vector bool int vec_cmple (vector float, vector float);
14291
14292 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14293 vector bool char vec_cmplt (vector signed char, vector signed char);
14294 vector bool short vec_cmplt (vector unsigned short,
14295 vector unsigned short);
14296 vector bool short vec_cmplt (vector signed short, vector signed short);
14297 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14298 vector bool int vec_cmplt (vector signed int, vector signed int);
14299 vector bool int vec_cmplt (vector float, vector float);
14300
14301 vector float vec_cpsgn (vector float, vector float);
14302
14303 vector float vec_ctf (vector unsigned int, const int);
14304 vector float vec_ctf (vector signed int, const int);
14305 vector double vec_ctf (vector unsigned long, const int);
14306 vector double vec_ctf (vector signed long, const int);
14307
14308 vector float vec_vcfsx (vector signed int, const int);
14309
14310 vector float vec_vcfux (vector unsigned int, const int);
14311
14312 vector signed int vec_cts (vector float, const int);
14313 vector signed long vec_cts (vector double, const int);
14314
14315 vector unsigned int vec_ctu (vector float, const int);
14316 vector unsigned long vec_ctu (vector double, const int);
14317
14318 void vec_dss (const int);
14319
14320 void vec_dssall (void);
14321
14322 void vec_dst (const vector unsigned char *, int, const int);
14323 void vec_dst (const vector signed char *, int, const int);
14324 void vec_dst (const vector bool char *, int, const int);
14325 void vec_dst (const vector unsigned short *, int, const int);
14326 void vec_dst (const vector signed short *, int, const int);
14327 void vec_dst (const vector bool short *, int, const int);
14328 void vec_dst (const vector pixel *, int, const int);
14329 void vec_dst (const vector unsigned int *, int, const int);
14330 void vec_dst (const vector signed int *, int, const int);
14331 void vec_dst (const vector bool int *, int, const int);
14332 void vec_dst (const vector float *, int, const int);
14333 void vec_dst (const unsigned char *, int, const int);
14334 void vec_dst (const signed char *, int, const int);
14335 void vec_dst (const unsigned short *, int, const int);
14336 void vec_dst (const short *, int, const int);
14337 void vec_dst (const unsigned int *, int, const int);
14338 void vec_dst (const int *, int, const int);
14339 void vec_dst (const unsigned long *, int, const int);
14340 void vec_dst (const long *, int, const int);
14341 void vec_dst (const float *, int, const int);
14342
14343 void vec_dstst (const vector unsigned char *, int, const int);
14344 void vec_dstst (const vector signed char *, int, const int);
14345 void vec_dstst (const vector bool char *, int, const int);
14346 void vec_dstst (const vector unsigned short *, int, const int);
14347 void vec_dstst (const vector signed short *, int, const int);
14348 void vec_dstst (const vector bool short *, int, const int);
14349 void vec_dstst (const vector pixel *, int, const int);
14350 void vec_dstst (const vector unsigned int *, int, const int);
14351 void vec_dstst (const vector signed int *, int, const int);
14352 void vec_dstst (const vector bool int *, int, const int);
14353 void vec_dstst (const vector float *, int, const int);
14354 void vec_dstst (const unsigned char *, int, const int);
14355 void vec_dstst (const signed char *, int, const int);
14356 void vec_dstst (const unsigned short *, int, const int);
14357 void vec_dstst (const short *, int, const int);
14358 void vec_dstst (const unsigned int *, int, const int);
14359 void vec_dstst (const int *, int, const int);
14360 void vec_dstst (const unsigned long *, int, const int);
14361 void vec_dstst (const long *, int, const int);
14362 void vec_dstst (const float *, int, const int);
14363
14364 void vec_dststt (const vector unsigned char *, int, const int);
14365 void vec_dststt (const vector signed char *, int, const int);
14366 void vec_dststt (const vector bool char *, int, const int);
14367 void vec_dststt (const vector unsigned short *, int, const int);
14368 void vec_dststt (const vector signed short *, int, const int);
14369 void vec_dststt (const vector bool short *, int, const int);
14370 void vec_dststt (const vector pixel *, int, const int);
14371 void vec_dststt (const vector unsigned int *, int, const int);
14372 void vec_dststt (const vector signed int *, int, const int);
14373 void vec_dststt (const vector bool int *, int, const int);
14374 void vec_dststt (const vector float *, int, const int);
14375 void vec_dststt (const unsigned char *, int, const int);
14376 void vec_dststt (const signed char *, int, const int);
14377 void vec_dststt (const unsigned short *, int, const int);
14378 void vec_dststt (const short *, int, const int);
14379 void vec_dststt (const unsigned int *, int, const int);
14380 void vec_dststt (const int *, int, const int);
14381 void vec_dststt (const unsigned long *, int, const int);
14382 void vec_dststt (const long *, int, const int);
14383 void vec_dststt (const float *, int, const int);
14384
14385 void vec_dstt (const vector unsigned char *, int, const int);
14386 void vec_dstt (const vector signed char *, int, const int);
14387 void vec_dstt (const vector bool char *, int, const int);
14388 void vec_dstt (const vector unsigned short *, int, const int);
14389 void vec_dstt (const vector signed short *, int, const int);
14390 void vec_dstt (const vector bool short *, int, const int);
14391 void vec_dstt (const vector pixel *, int, const int);
14392 void vec_dstt (const vector unsigned int *, int, const int);
14393 void vec_dstt (const vector signed int *, int, const int);
14394 void vec_dstt (const vector bool int *, int, const int);
14395 void vec_dstt (const vector float *, int, const int);
14396 void vec_dstt (const unsigned char *, int, const int);
14397 void vec_dstt (const signed char *, int, const int);
14398 void vec_dstt (const unsigned short *, int, const int);
14399 void vec_dstt (const short *, int, const int);
14400 void vec_dstt (const unsigned int *, int, const int);
14401 void vec_dstt (const int *, int, const int);
14402 void vec_dstt (const unsigned long *, int, const int);
14403 void vec_dstt (const long *, int, const int);
14404 void vec_dstt (const float *, int, const int);
14405
14406 vector float vec_expte (vector float);
14407
14408 vector float vec_floor (vector float);
14409
14410 vector float vec_ld (int, const vector float *);
14411 vector float vec_ld (int, const float *);
14412 vector bool int vec_ld (int, const vector bool int *);
14413 vector signed int vec_ld (int, const vector signed int *);
14414 vector signed int vec_ld (int, const int *);
14415 vector signed int vec_ld (int, const long *);
14416 vector unsigned int vec_ld (int, const vector unsigned int *);
14417 vector unsigned int vec_ld (int, const unsigned int *);
14418 vector unsigned int vec_ld (int, const unsigned long *);
14419 vector bool short vec_ld (int, const vector bool short *);
14420 vector pixel vec_ld (int, const vector pixel *);
14421 vector signed short vec_ld (int, const vector signed short *);
14422 vector signed short vec_ld (int, const short *);
14423 vector unsigned short vec_ld (int, const vector unsigned short *);
14424 vector unsigned short vec_ld (int, const unsigned short *);
14425 vector bool char vec_ld (int, const vector bool char *);
14426 vector signed char vec_ld (int, const vector signed char *);
14427 vector signed char vec_ld (int, const signed char *);
14428 vector unsigned char vec_ld (int, const vector unsigned char *);
14429 vector unsigned char vec_ld (int, const unsigned char *);
14430
14431 vector signed char vec_lde (int, const signed char *);
14432 vector unsigned char vec_lde (int, const unsigned char *);
14433 vector signed short vec_lde (int, const short *);
14434 vector unsigned short vec_lde (int, const unsigned short *);
14435 vector float vec_lde (int, const float *);
14436 vector signed int vec_lde (int, const int *);
14437 vector unsigned int vec_lde (int, const unsigned int *);
14438 vector signed int vec_lde (int, const long *);
14439 vector unsigned int vec_lde (int, const unsigned long *);
14440
14441 vector float vec_lvewx (int, float *);
14442 vector signed int vec_lvewx (int, int *);
14443 vector unsigned int vec_lvewx (int, unsigned int *);
14444 vector signed int vec_lvewx (int, long *);
14445 vector unsigned int vec_lvewx (int, unsigned long *);
14446
14447 vector signed short vec_lvehx (int, short *);
14448 vector unsigned short vec_lvehx (int, unsigned short *);
14449
14450 vector signed char vec_lvebx (int, char *);
14451 vector unsigned char vec_lvebx (int, unsigned char *);
14452
14453 vector float vec_ldl (int, const vector float *);
14454 vector float vec_ldl (int, const float *);
14455 vector bool int vec_ldl (int, const vector bool int *);
14456 vector signed int vec_ldl (int, const vector signed int *);
14457 vector signed int vec_ldl (int, const int *);
14458 vector signed int vec_ldl (int, const long *);
14459 vector unsigned int vec_ldl (int, const vector unsigned int *);
14460 vector unsigned int vec_ldl (int, const unsigned int *);
14461 vector unsigned int vec_ldl (int, const unsigned long *);
14462 vector bool short vec_ldl (int, const vector bool short *);
14463 vector pixel vec_ldl (int, const vector pixel *);
14464 vector signed short vec_ldl (int, const vector signed short *);
14465 vector signed short vec_ldl (int, const short *);
14466 vector unsigned short vec_ldl (int, const vector unsigned short *);
14467 vector unsigned short vec_ldl (int, const unsigned short *);
14468 vector bool char vec_ldl (int, const vector bool char *);
14469 vector signed char vec_ldl (int, const vector signed char *);
14470 vector signed char vec_ldl (int, const signed char *);
14471 vector unsigned char vec_ldl (int, const vector unsigned char *);
14472 vector unsigned char vec_ldl (int, const unsigned char *);
14473
14474 vector float vec_loge (vector float);
14475
14476 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14477 vector unsigned char vec_lvsl (int, const volatile signed char *);
14478 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14479 vector unsigned char vec_lvsl (int, const volatile short *);
14480 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14481 vector unsigned char vec_lvsl (int, const volatile int *);
14482 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14483 vector unsigned char vec_lvsl (int, const volatile long *);
14484 vector unsigned char vec_lvsl (int, const volatile float *);
14485
14486 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14487 vector unsigned char vec_lvsr (int, const volatile signed char *);
14488 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14489 vector unsigned char vec_lvsr (int, const volatile short *);
14490 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14491 vector unsigned char vec_lvsr (int, const volatile int *);
14492 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14493 vector unsigned char vec_lvsr (int, const volatile long *);
14494 vector unsigned char vec_lvsr (int, const volatile float *);
14495
14496 vector float vec_madd (vector float, vector float, vector float);
14497
14498 vector signed short vec_madds (vector signed short,
14499 vector signed short,
14500 vector signed short);
14501
14502 vector unsigned char vec_max (vector bool char, vector unsigned char);
14503 vector unsigned char vec_max (vector unsigned char, vector bool char);
14504 vector unsigned char vec_max (vector unsigned char,
14505 vector unsigned char);
14506 vector signed char vec_max (vector bool char, vector signed char);
14507 vector signed char vec_max (vector signed char, vector bool char);
14508 vector signed char vec_max (vector signed char, vector signed char);
14509 vector unsigned short vec_max (vector bool short,
14510 vector unsigned short);
14511 vector unsigned short vec_max (vector unsigned short,
14512 vector bool short);
14513 vector unsigned short vec_max (vector unsigned short,
14514 vector unsigned short);
14515 vector signed short vec_max (vector bool short, vector signed short);
14516 vector signed short vec_max (vector signed short, vector bool short);
14517 vector signed short vec_max (vector signed short, vector signed short);
14518 vector unsigned int vec_max (vector bool int, vector unsigned int);
14519 vector unsigned int vec_max (vector unsigned int, vector bool int);
14520 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14521 vector signed int vec_max (vector bool int, vector signed int);
14522 vector signed int vec_max (vector signed int, vector bool int);
14523 vector signed int vec_max (vector signed int, vector signed int);
14524 vector float vec_max (vector float, vector float);
14525
14526 vector float vec_vmaxfp (vector float, vector float);
14527
14528 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14529 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14530 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14531
14532 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14533 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14534 vector unsigned int vec_vmaxuw (vector unsigned int,
14535 vector unsigned int);
14536
14537 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14538 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14539 vector signed short vec_vmaxsh (vector signed short,
14540 vector signed short);
14541
14542 vector unsigned short vec_vmaxuh (vector bool short,
14543 vector unsigned short);
14544 vector unsigned short vec_vmaxuh (vector unsigned short,
14545 vector bool short);
14546 vector unsigned short vec_vmaxuh (vector unsigned short,
14547 vector unsigned short);
14548
14549 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14550 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14551 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14552
14553 vector unsigned char vec_vmaxub (vector bool char,
14554 vector unsigned char);
14555 vector unsigned char vec_vmaxub (vector unsigned char,
14556 vector bool char);
14557 vector unsigned char vec_vmaxub (vector unsigned char,
14558 vector unsigned char);
14559
14560 vector bool char vec_mergeh (vector bool char, vector bool char);
14561 vector signed char vec_mergeh (vector signed char, vector signed char);
14562 vector unsigned char vec_mergeh (vector unsigned char,
14563 vector unsigned char);
14564 vector bool short vec_mergeh (vector bool short, vector bool short);
14565 vector pixel vec_mergeh (vector pixel, vector pixel);
14566 vector signed short vec_mergeh (vector signed short,
14567 vector signed short);
14568 vector unsigned short vec_mergeh (vector unsigned short,
14569 vector unsigned short);
14570 vector float vec_mergeh (vector float, vector float);
14571 vector bool int vec_mergeh (vector bool int, vector bool int);
14572 vector signed int vec_mergeh (vector signed int, vector signed int);
14573 vector unsigned int vec_mergeh (vector unsigned int,
14574 vector unsigned int);
14575
14576 vector float vec_vmrghw (vector float, vector float);
14577 vector bool int vec_vmrghw (vector bool int, vector bool int);
14578 vector signed int vec_vmrghw (vector signed int, vector signed int);
14579 vector unsigned int vec_vmrghw (vector unsigned int,
14580 vector unsigned int);
14581
14582 vector bool short vec_vmrghh (vector bool short, vector bool short);
14583 vector signed short vec_vmrghh (vector signed short,
14584 vector signed short);
14585 vector unsigned short vec_vmrghh (vector unsigned short,
14586 vector unsigned short);
14587 vector pixel vec_vmrghh (vector pixel, vector pixel);
14588
14589 vector bool char vec_vmrghb (vector bool char, vector bool char);
14590 vector signed char vec_vmrghb (vector signed char, vector signed char);
14591 vector unsigned char vec_vmrghb (vector unsigned char,
14592 vector unsigned char);
14593
14594 vector bool char vec_mergel (vector bool char, vector bool char);
14595 vector signed char vec_mergel (vector signed char, vector signed char);
14596 vector unsigned char vec_mergel (vector unsigned char,
14597 vector unsigned char);
14598 vector bool short vec_mergel (vector bool short, vector bool short);
14599 vector pixel vec_mergel (vector pixel, vector pixel);
14600 vector signed short vec_mergel (vector signed short,
14601 vector signed short);
14602 vector unsigned short vec_mergel (vector unsigned short,
14603 vector unsigned short);
14604 vector float vec_mergel (vector float, vector float);
14605 vector bool int vec_mergel (vector bool int, vector bool int);
14606 vector signed int vec_mergel (vector signed int, vector signed int);
14607 vector unsigned int vec_mergel (vector unsigned int,
14608 vector unsigned int);
14609
14610 vector float vec_vmrglw (vector float, vector float);
14611 vector signed int vec_vmrglw (vector signed int, vector signed int);
14612 vector unsigned int vec_vmrglw (vector unsigned int,
14613 vector unsigned int);
14614 vector bool int vec_vmrglw (vector bool int, vector bool int);
14615
14616 vector bool short vec_vmrglh (vector bool short, vector bool short);
14617 vector signed short vec_vmrglh (vector signed short,
14618 vector signed short);
14619 vector unsigned short vec_vmrglh (vector unsigned short,
14620 vector unsigned short);
14621 vector pixel vec_vmrglh (vector pixel, vector pixel);
14622
14623 vector bool char vec_vmrglb (vector bool char, vector bool char);
14624 vector signed char vec_vmrglb (vector signed char, vector signed char);
14625 vector unsigned char vec_vmrglb (vector unsigned char,
14626 vector unsigned char);
14627
14628 vector unsigned short vec_mfvscr (void);
14629
14630 vector unsigned char vec_min (vector bool char, vector unsigned char);
14631 vector unsigned char vec_min (vector unsigned char, vector bool char);
14632 vector unsigned char vec_min (vector unsigned char,
14633 vector unsigned char);
14634 vector signed char vec_min (vector bool char, vector signed char);
14635 vector signed char vec_min (vector signed char, vector bool char);
14636 vector signed char vec_min (vector signed char, vector signed char);
14637 vector unsigned short vec_min (vector bool short,
14638 vector unsigned short);
14639 vector unsigned short vec_min (vector unsigned short,
14640 vector bool short);
14641 vector unsigned short vec_min (vector unsigned short,
14642 vector unsigned short);
14643 vector signed short vec_min (vector bool short, vector signed short);
14644 vector signed short vec_min (vector signed short, vector bool short);
14645 vector signed short vec_min (vector signed short, vector signed short);
14646 vector unsigned int vec_min (vector bool int, vector unsigned int);
14647 vector unsigned int vec_min (vector unsigned int, vector bool int);
14648 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14649 vector signed int vec_min (vector bool int, vector signed int);
14650 vector signed int vec_min (vector signed int, vector bool int);
14651 vector signed int vec_min (vector signed int, vector signed int);
14652 vector float vec_min (vector float, vector float);
14653
14654 vector float vec_vminfp (vector float, vector float);
14655
14656 vector signed int vec_vminsw (vector bool int, vector signed int);
14657 vector signed int vec_vminsw (vector signed int, vector bool int);
14658 vector signed int vec_vminsw (vector signed int, vector signed int);
14659
14660 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14661 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14662 vector unsigned int vec_vminuw (vector unsigned int,
14663 vector unsigned int);
14664
14665 vector signed short vec_vminsh (vector bool short, vector signed short);
14666 vector signed short vec_vminsh (vector signed short, vector bool short);
14667 vector signed short vec_vminsh (vector signed short,
14668 vector signed short);
14669
14670 vector unsigned short vec_vminuh (vector bool short,
14671 vector unsigned short);
14672 vector unsigned short vec_vminuh (vector unsigned short,
14673 vector bool short);
14674 vector unsigned short vec_vminuh (vector unsigned short,
14675 vector unsigned short);
14676
14677 vector signed char vec_vminsb (vector bool char, vector signed char);
14678 vector signed char vec_vminsb (vector signed char, vector bool char);
14679 vector signed char vec_vminsb (vector signed char, vector signed char);
14680
14681 vector unsigned char vec_vminub (vector bool char,
14682 vector unsigned char);
14683 vector unsigned char vec_vminub (vector unsigned char,
14684 vector bool char);
14685 vector unsigned char vec_vminub (vector unsigned char,
14686 vector unsigned char);
14687
14688 vector signed short vec_mladd (vector signed short,
14689 vector signed short,
14690 vector signed short);
14691 vector signed short vec_mladd (vector signed short,
14692 vector unsigned short,
14693 vector unsigned short);
14694 vector signed short vec_mladd (vector unsigned short,
14695 vector signed short,
14696 vector signed short);
14697 vector unsigned short vec_mladd (vector unsigned short,
14698 vector unsigned short,
14699 vector unsigned short);
14700
14701 vector signed short vec_mradds (vector signed short,
14702 vector signed short,
14703 vector signed short);
14704
14705 vector unsigned int vec_msum (vector unsigned char,
14706 vector unsigned char,
14707 vector unsigned int);
14708 vector signed int vec_msum (vector signed char,
14709 vector unsigned char,
14710 vector signed int);
14711 vector unsigned int vec_msum (vector unsigned short,
14712 vector unsigned short,
14713 vector unsigned int);
14714 vector signed int vec_msum (vector signed short,
14715 vector signed short,
14716 vector signed int);
14717
14718 vector signed int vec_vmsumshm (vector signed short,
14719 vector signed short,
14720 vector signed int);
14721
14722 vector unsigned int vec_vmsumuhm (vector unsigned short,
14723 vector unsigned short,
14724 vector unsigned int);
14725
14726 vector signed int vec_vmsummbm (vector signed char,
14727 vector unsigned char,
14728 vector signed int);
14729
14730 vector unsigned int vec_vmsumubm (vector unsigned char,
14731 vector unsigned char,
14732 vector unsigned int);
14733
14734 vector unsigned int vec_msums (vector unsigned short,
14735 vector unsigned short,
14736 vector unsigned int);
14737 vector signed int vec_msums (vector signed short,
14738 vector signed short,
14739 vector signed int);
14740
14741 vector signed int vec_vmsumshs (vector signed short,
14742 vector signed short,
14743 vector signed int);
14744
14745 vector unsigned int vec_vmsumuhs (vector unsigned short,
14746 vector unsigned short,
14747 vector unsigned int);
14748
14749 void vec_mtvscr (vector signed int);
14750 void vec_mtvscr (vector unsigned int);
14751 void vec_mtvscr (vector bool int);
14752 void vec_mtvscr (vector signed short);
14753 void vec_mtvscr (vector unsigned short);
14754 void vec_mtvscr (vector bool short);
14755 void vec_mtvscr (vector pixel);
14756 void vec_mtvscr (vector signed char);
14757 void vec_mtvscr (vector unsigned char);
14758 void vec_mtvscr (vector bool char);
14759
14760 vector unsigned short vec_mule (vector unsigned char,
14761 vector unsigned char);
14762 vector signed short vec_mule (vector signed char,
14763 vector signed char);
14764 vector unsigned int vec_mule (vector unsigned short,
14765 vector unsigned short);
14766 vector signed int vec_mule (vector signed short, vector signed short);
14767
14768 vector signed int vec_vmulesh (vector signed short,
14769 vector signed short);
14770
14771 vector unsigned int vec_vmuleuh (vector unsigned short,
14772 vector unsigned short);
14773
14774 vector signed short vec_vmulesb (vector signed char,
14775 vector signed char);
14776
14777 vector unsigned short vec_vmuleub (vector unsigned char,
14778 vector unsigned char);
14779
14780 vector unsigned short vec_mulo (vector unsigned char,
14781 vector unsigned char);
14782 vector signed short vec_mulo (vector signed char, vector signed char);
14783 vector unsigned int vec_mulo (vector unsigned short,
14784 vector unsigned short);
14785 vector signed int vec_mulo (vector signed short, vector signed short);
14786
14787 vector signed int vec_vmulosh (vector signed short,
14788 vector signed short);
14789
14790 vector unsigned int vec_vmulouh (vector unsigned short,
14791 vector unsigned short);
14792
14793 vector signed short vec_vmulosb (vector signed char,
14794 vector signed char);
14795
14796 vector unsigned short vec_vmuloub (vector unsigned char,
14797 vector unsigned char);
14798
14799 vector float vec_nmsub (vector float, vector float, vector float);
14800
14801 vector float vec_nor (vector float, vector float);
14802 vector signed int vec_nor (vector signed int, vector signed int);
14803 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14804 vector bool int vec_nor (vector bool int, vector bool int);
14805 vector signed short vec_nor (vector signed short, vector signed short);
14806 vector unsigned short vec_nor (vector unsigned short,
14807 vector unsigned short);
14808 vector bool short vec_nor (vector bool short, vector bool short);
14809 vector signed char vec_nor (vector signed char, vector signed char);
14810 vector unsigned char vec_nor (vector unsigned char,
14811 vector unsigned char);
14812 vector bool char vec_nor (vector bool char, vector bool char);
14813
14814 vector float vec_or (vector float, vector float);
14815 vector float vec_or (vector float, vector bool int);
14816 vector float vec_or (vector bool int, vector float);
14817 vector bool int vec_or (vector bool int, vector bool int);
14818 vector signed int vec_or (vector bool int, vector signed int);
14819 vector signed int vec_or (vector signed int, vector bool int);
14820 vector signed int vec_or (vector signed int, vector signed int);
14821 vector unsigned int vec_or (vector bool int, vector unsigned int);
14822 vector unsigned int vec_or (vector unsigned int, vector bool int);
14823 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14824 vector bool short vec_or (vector bool short, vector bool short);
14825 vector signed short vec_or (vector bool short, vector signed short);
14826 vector signed short vec_or (vector signed short, vector bool short);
14827 vector signed short vec_or (vector signed short, vector signed short);
14828 vector unsigned short vec_or (vector bool short, vector unsigned short);
14829 vector unsigned short vec_or (vector unsigned short, vector bool short);
14830 vector unsigned short vec_or (vector unsigned short,
14831 vector unsigned short);
14832 vector signed char vec_or (vector bool char, vector signed char);
14833 vector bool char vec_or (vector bool char, vector bool char);
14834 vector signed char vec_or (vector signed char, vector bool char);
14835 vector signed char vec_or (vector signed char, vector signed char);
14836 vector unsigned char vec_or (vector bool char, vector unsigned char);
14837 vector unsigned char vec_or (vector unsigned char, vector bool char);
14838 vector unsigned char vec_or (vector unsigned char,
14839 vector unsigned char);
14840
14841 vector signed char vec_pack (vector signed short, vector signed short);
14842 vector unsigned char vec_pack (vector unsigned short,
14843 vector unsigned short);
14844 vector bool char vec_pack (vector bool short, vector bool short);
14845 vector signed short vec_pack (vector signed int, vector signed int);
14846 vector unsigned short vec_pack (vector unsigned int,
14847 vector unsigned int);
14848 vector bool short vec_pack (vector bool int, vector bool int);
14849
14850 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14851 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14852 vector unsigned short vec_vpkuwum (vector unsigned int,
14853 vector unsigned int);
14854
14855 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14856 vector signed char vec_vpkuhum (vector signed short,
14857 vector signed short);
14858 vector unsigned char vec_vpkuhum (vector unsigned short,
14859 vector unsigned short);
14860
14861 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14862
14863 vector unsigned char vec_packs (vector unsigned short,
14864 vector unsigned short);
14865 vector signed char vec_packs (vector signed short, vector signed short);
14866 vector unsigned short vec_packs (vector unsigned int,
14867 vector unsigned int);
14868 vector signed short vec_packs (vector signed int, vector signed int);
14869
14870 vector signed short vec_vpkswss (vector signed int, vector signed int);
14871
14872 vector unsigned short vec_vpkuwus (vector unsigned int,
14873 vector unsigned int);
14874
14875 vector signed char vec_vpkshss (vector signed short,
14876 vector signed short);
14877
14878 vector unsigned char vec_vpkuhus (vector unsigned short,
14879 vector unsigned short);
14880
14881 vector unsigned char vec_packsu (vector unsigned short,
14882 vector unsigned short);
14883 vector unsigned char vec_packsu (vector signed short,
14884 vector signed short);
14885 vector unsigned short vec_packsu (vector unsigned int,
14886 vector unsigned int);
14887 vector unsigned short vec_packsu (vector signed int, vector signed int);
14888
14889 vector unsigned short vec_vpkswus (vector signed int,
14890 vector signed int);
14891
14892 vector unsigned char vec_vpkshus (vector signed short,
14893 vector signed short);
14894
14895 vector float vec_perm (vector float,
14896 vector float,
14897 vector unsigned char);
14898 vector signed int vec_perm (vector signed int,
14899 vector signed int,
14900 vector unsigned char);
14901 vector unsigned int vec_perm (vector unsigned int,
14902 vector unsigned int,
14903 vector unsigned char);
14904 vector bool int vec_perm (vector bool int,
14905 vector bool int,
14906 vector unsigned char);
14907 vector signed short vec_perm (vector signed short,
14908 vector signed short,
14909 vector unsigned char);
14910 vector unsigned short vec_perm (vector unsigned short,
14911 vector unsigned short,
14912 vector unsigned char);
14913 vector bool short vec_perm (vector bool short,
14914 vector bool short,
14915 vector unsigned char);
14916 vector pixel vec_perm (vector pixel,
14917 vector pixel,
14918 vector unsigned char);
14919 vector signed char vec_perm (vector signed char,
14920 vector signed char,
14921 vector unsigned char);
14922 vector unsigned char vec_perm (vector unsigned char,
14923 vector unsigned char,
14924 vector unsigned char);
14925 vector bool char vec_perm (vector bool char,
14926 vector bool char,
14927 vector unsigned char);
14928
14929 vector float vec_re (vector float);
14930
14931 vector signed char vec_rl (vector signed char,
14932 vector unsigned char);
14933 vector unsigned char vec_rl (vector unsigned char,
14934 vector unsigned char);
14935 vector signed short vec_rl (vector signed short, vector unsigned short);
14936 vector unsigned short vec_rl (vector unsigned short,
14937 vector unsigned short);
14938 vector signed int vec_rl (vector signed int, vector unsigned int);
14939 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14940
14941 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14942 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14943
14944 vector signed short vec_vrlh (vector signed short,
14945 vector unsigned short);
14946 vector unsigned short vec_vrlh (vector unsigned short,
14947 vector unsigned short);
14948
14949 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14950 vector unsigned char vec_vrlb (vector unsigned char,
14951 vector unsigned char);
14952
14953 vector float vec_round (vector float);
14954
14955 vector float vec_recip (vector float, vector float);
14956
14957 vector float vec_rsqrt (vector float);
14958
14959 vector float vec_rsqrte (vector float);
14960
14961 vector float vec_sel (vector float, vector float, vector bool int);
14962 vector float vec_sel (vector float, vector float, vector unsigned int);
14963 vector signed int vec_sel (vector signed int,
14964 vector signed int,
14965 vector bool int);
14966 vector signed int vec_sel (vector signed int,
14967 vector signed int,
14968 vector unsigned int);
14969 vector unsigned int vec_sel (vector unsigned int,
14970 vector unsigned int,
14971 vector bool int);
14972 vector unsigned int vec_sel (vector unsigned int,
14973 vector unsigned int,
14974 vector unsigned int);
14975 vector bool int vec_sel (vector bool int,
14976 vector bool int,
14977 vector bool int);
14978 vector bool int vec_sel (vector bool int,
14979 vector bool int,
14980 vector unsigned int);
14981 vector signed short vec_sel (vector signed short,
14982 vector signed short,
14983 vector bool short);
14984 vector signed short vec_sel (vector signed short,
14985 vector signed short,
14986 vector unsigned short);
14987 vector unsigned short vec_sel (vector unsigned short,
14988 vector unsigned short,
14989 vector bool short);
14990 vector unsigned short vec_sel (vector unsigned short,
14991 vector unsigned short,
14992 vector unsigned short);
14993 vector bool short vec_sel (vector bool short,
14994 vector bool short,
14995 vector bool short);
14996 vector bool short vec_sel (vector bool short,
14997 vector bool short,
14998 vector unsigned short);
14999 vector signed char vec_sel (vector signed char,
15000 vector signed char,
15001 vector bool char);
15002 vector signed char vec_sel (vector signed char,
15003 vector signed char,
15004 vector unsigned char);
15005 vector unsigned char vec_sel (vector unsigned char,
15006 vector unsigned char,
15007 vector bool char);
15008 vector unsigned char vec_sel (vector unsigned char,
15009 vector unsigned char,
15010 vector unsigned char);
15011 vector bool char vec_sel (vector bool char,
15012 vector bool char,
15013 vector bool char);
15014 vector bool char vec_sel (vector bool char,
15015 vector bool char,
15016 vector unsigned char);
15017
15018 vector signed char vec_sl (vector signed char,
15019 vector unsigned char);
15020 vector unsigned char vec_sl (vector unsigned char,
15021 vector unsigned char);
15022 vector signed short vec_sl (vector signed short, vector unsigned short);
15023 vector unsigned short vec_sl (vector unsigned short,
15024 vector unsigned short);
15025 vector signed int vec_sl (vector signed int, vector unsigned int);
15026 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
15027
15028 vector signed int vec_vslw (vector signed int, vector unsigned int);
15029 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
15030
15031 vector signed short vec_vslh (vector signed short,
15032 vector unsigned short);
15033 vector unsigned short vec_vslh (vector unsigned short,
15034 vector unsigned short);
15035
15036 vector signed char vec_vslb (vector signed char, vector unsigned char);
15037 vector unsigned char vec_vslb (vector unsigned char,
15038 vector unsigned char);
15039
15040 vector float vec_sld (vector float, vector float, const int);
15041 vector signed int vec_sld (vector signed int,
15042 vector signed int,
15043 const int);
15044 vector unsigned int vec_sld (vector unsigned int,
15045 vector unsigned int,
15046 const int);
15047 vector bool int vec_sld (vector bool int,
15048 vector bool int,
15049 const int);
15050 vector signed short vec_sld (vector signed short,
15051 vector signed short,
15052 const int);
15053 vector unsigned short vec_sld (vector unsigned short,
15054 vector unsigned short,
15055 const int);
15056 vector bool short vec_sld (vector bool short,
15057 vector bool short,
15058 const int);
15059 vector pixel vec_sld (vector pixel,
15060 vector pixel,
15061 const int);
15062 vector signed char vec_sld (vector signed char,
15063 vector signed char,
15064 const int);
15065 vector unsigned char vec_sld (vector unsigned char,
15066 vector unsigned char,
15067 const int);
15068 vector bool char vec_sld (vector bool char,
15069 vector bool char,
15070 const int);
15071
15072 vector signed int vec_sll (vector signed int,
15073 vector unsigned int);
15074 vector signed int vec_sll (vector signed int,
15075 vector unsigned short);
15076 vector signed int vec_sll (vector signed int,
15077 vector unsigned char);
15078 vector unsigned int vec_sll (vector unsigned int,
15079 vector unsigned int);
15080 vector unsigned int vec_sll (vector unsigned int,
15081 vector unsigned short);
15082 vector unsigned int vec_sll (vector unsigned int,
15083 vector unsigned char);
15084 vector bool int vec_sll (vector bool int,
15085 vector unsigned int);
15086 vector bool int vec_sll (vector bool int,
15087 vector unsigned short);
15088 vector bool int vec_sll (vector bool int,
15089 vector unsigned char);
15090 vector signed short vec_sll (vector signed short,
15091 vector unsigned int);
15092 vector signed short vec_sll (vector signed short,
15093 vector unsigned short);
15094 vector signed short vec_sll (vector signed short,
15095 vector unsigned char);
15096 vector unsigned short vec_sll (vector unsigned short,
15097 vector unsigned int);
15098 vector unsigned short vec_sll (vector unsigned short,
15099 vector unsigned short);
15100 vector unsigned short vec_sll (vector unsigned short,
15101 vector unsigned char);
15102 vector bool short vec_sll (vector bool short, vector unsigned int);
15103 vector bool short vec_sll (vector bool short, vector unsigned short);
15104 vector bool short vec_sll (vector bool short, vector unsigned char);
15105 vector pixel vec_sll (vector pixel, vector unsigned int);
15106 vector pixel vec_sll (vector pixel, vector unsigned short);
15107 vector pixel vec_sll (vector pixel, vector unsigned char);
15108 vector signed char vec_sll (vector signed char, vector unsigned int);
15109 vector signed char vec_sll (vector signed char, vector unsigned short);
15110 vector signed char vec_sll (vector signed char, vector unsigned char);
15111 vector unsigned char vec_sll (vector unsigned char,
15112 vector unsigned int);
15113 vector unsigned char vec_sll (vector unsigned char,
15114 vector unsigned short);
15115 vector unsigned char vec_sll (vector unsigned char,
15116 vector unsigned char);
15117 vector bool char vec_sll (vector bool char, vector unsigned int);
15118 vector bool char vec_sll (vector bool char, vector unsigned short);
15119 vector bool char vec_sll (vector bool char, vector unsigned char);
15120
15121 vector float vec_slo (vector float, vector signed char);
15122 vector float vec_slo (vector float, vector unsigned char);
15123 vector signed int vec_slo (vector signed int, vector signed char);
15124 vector signed int vec_slo (vector signed int, vector unsigned char);
15125 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15126 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15127 vector signed short vec_slo (vector signed short, vector signed char);
15128 vector signed short vec_slo (vector signed short, vector unsigned char);
15129 vector unsigned short vec_slo (vector unsigned short,
15130 vector signed char);
15131 vector unsigned short vec_slo (vector unsigned short,
15132 vector unsigned char);
15133 vector pixel vec_slo (vector pixel, vector signed char);
15134 vector pixel vec_slo (vector pixel, vector unsigned char);
15135 vector signed char vec_slo (vector signed char, vector signed char);
15136 vector signed char vec_slo (vector signed char, vector unsigned char);
15137 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15138 vector unsigned char vec_slo (vector unsigned char,
15139 vector unsigned char);
15140
15141 vector signed char vec_splat (vector signed char, const int);
15142 vector unsigned char vec_splat (vector unsigned char, const int);
15143 vector bool char vec_splat (vector bool char, const int);
15144 vector signed short vec_splat (vector signed short, const int);
15145 vector unsigned short vec_splat (vector unsigned short, const int);
15146 vector bool short vec_splat (vector bool short, const int);
15147 vector pixel vec_splat (vector pixel, const int);
15148 vector float vec_splat (vector float, const int);
15149 vector signed int vec_splat (vector signed int, const int);
15150 vector unsigned int vec_splat (vector unsigned int, const int);
15151 vector bool int vec_splat (vector bool int, const int);
15152 vector signed long vec_splat (vector signed long, const int);
15153 vector unsigned long vec_splat (vector unsigned long, const int);
15154
15155 vector signed char vec_splats (signed char);
15156 vector unsigned char vec_splats (unsigned char);
15157 vector signed short vec_splats (signed short);
15158 vector unsigned short vec_splats (unsigned short);
15159 vector signed int vec_splats (signed int);
15160 vector unsigned int vec_splats (unsigned int);
15161 vector float vec_splats (float);
15162
15163 vector float vec_vspltw (vector float, const int);
15164 vector signed int vec_vspltw (vector signed int, const int);
15165 vector unsigned int vec_vspltw (vector unsigned int, const int);
15166 vector bool int vec_vspltw (vector bool int, const int);
15167
15168 vector bool short vec_vsplth (vector bool short, const int);
15169 vector signed short vec_vsplth (vector signed short, const int);
15170 vector unsigned short vec_vsplth (vector unsigned short, const int);
15171 vector pixel vec_vsplth (vector pixel, const int);
15172
15173 vector signed char vec_vspltb (vector signed char, const int);
15174 vector unsigned char vec_vspltb (vector unsigned char, const int);
15175 vector bool char vec_vspltb (vector bool char, const int);
15176
15177 vector signed char vec_splat_s8 (const int);
15178
15179 vector signed short vec_splat_s16 (const int);
15180
15181 vector signed int vec_splat_s32 (const int);
15182
15183 vector unsigned char vec_splat_u8 (const int);
15184
15185 vector unsigned short vec_splat_u16 (const int);
15186
15187 vector unsigned int vec_splat_u32 (const int);
15188
15189 vector signed char vec_sr (vector signed char, vector unsigned char);
15190 vector unsigned char vec_sr (vector unsigned char,
15191 vector unsigned char);
15192 vector signed short vec_sr (vector signed short,
15193 vector unsigned short);
15194 vector unsigned short vec_sr (vector unsigned short,
15195 vector unsigned short);
15196 vector signed int vec_sr (vector signed int, vector unsigned int);
15197 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15198
15199 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15200 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15201
15202 vector signed short vec_vsrh (vector signed short,
15203 vector unsigned short);
15204 vector unsigned short vec_vsrh (vector unsigned short,
15205 vector unsigned short);
15206
15207 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15208 vector unsigned char vec_vsrb (vector unsigned char,
15209 vector unsigned char);
15210
15211 vector signed char vec_sra (vector signed char, vector unsigned char);
15212 vector unsigned char vec_sra (vector unsigned char,
15213 vector unsigned char);
15214 vector signed short vec_sra (vector signed short,
15215 vector unsigned short);
15216 vector unsigned short vec_sra (vector unsigned short,
15217 vector unsigned short);
15218 vector signed int vec_sra (vector signed int, vector unsigned int);
15219 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15220
15221 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15222 vector unsigned int vec_vsraw (vector unsigned int,
15223 vector unsigned int);
15224
15225 vector signed short vec_vsrah (vector signed short,
15226 vector unsigned short);
15227 vector unsigned short vec_vsrah (vector unsigned short,
15228 vector unsigned short);
15229
15230 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15231 vector unsigned char vec_vsrab (vector unsigned char,
15232 vector unsigned char);
15233
15234 vector signed int vec_srl (vector signed int, vector unsigned int);
15235 vector signed int vec_srl (vector signed int, vector unsigned short);
15236 vector signed int vec_srl (vector signed int, vector unsigned char);
15237 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15238 vector unsigned int vec_srl (vector unsigned int,
15239 vector unsigned short);
15240 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15241 vector bool int vec_srl (vector bool int, vector unsigned int);
15242 vector bool int vec_srl (vector bool int, vector unsigned short);
15243 vector bool int vec_srl (vector bool int, vector unsigned char);
15244 vector signed short vec_srl (vector signed short, vector unsigned int);
15245 vector signed short vec_srl (vector signed short,
15246 vector unsigned short);
15247 vector signed short vec_srl (vector signed short, vector unsigned char);
15248 vector unsigned short vec_srl (vector unsigned short,
15249 vector unsigned int);
15250 vector unsigned short vec_srl (vector unsigned short,
15251 vector unsigned short);
15252 vector unsigned short vec_srl (vector unsigned short,
15253 vector unsigned char);
15254 vector bool short vec_srl (vector bool short, vector unsigned int);
15255 vector bool short vec_srl (vector bool short, vector unsigned short);
15256 vector bool short vec_srl (vector bool short, vector unsigned char);
15257 vector pixel vec_srl (vector pixel, vector unsigned int);
15258 vector pixel vec_srl (vector pixel, vector unsigned short);
15259 vector pixel vec_srl (vector pixel, vector unsigned char);
15260 vector signed char vec_srl (vector signed char, vector unsigned int);
15261 vector signed char vec_srl (vector signed char, vector unsigned short);
15262 vector signed char vec_srl (vector signed char, vector unsigned char);
15263 vector unsigned char vec_srl (vector unsigned char,
15264 vector unsigned int);
15265 vector unsigned char vec_srl (vector unsigned char,
15266 vector unsigned short);
15267 vector unsigned char vec_srl (vector unsigned char,
15268 vector unsigned char);
15269 vector bool char vec_srl (vector bool char, vector unsigned int);
15270 vector bool char vec_srl (vector bool char, vector unsigned short);
15271 vector bool char vec_srl (vector bool char, vector unsigned char);
15272
15273 vector float vec_sro (vector float, vector signed char);
15274 vector float vec_sro (vector float, vector unsigned char);
15275 vector signed int vec_sro (vector signed int, vector signed char);
15276 vector signed int vec_sro (vector signed int, vector unsigned char);
15277 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15278 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15279 vector signed short vec_sro (vector signed short, vector signed char);
15280 vector signed short vec_sro (vector signed short, vector unsigned char);
15281 vector unsigned short vec_sro (vector unsigned short,
15282 vector signed char);
15283 vector unsigned short vec_sro (vector unsigned short,
15284 vector unsigned char);
15285 vector pixel vec_sro (vector pixel, vector signed char);
15286 vector pixel vec_sro (vector pixel, vector unsigned char);
15287 vector signed char vec_sro (vector signed char, vector signed char);
15288 vector signed char vec_sro (vector signed char, vector unsigned char);
15289 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15290 vector unsigned char vec_sro (vector unsigned char,
15291 vector unsigned char);
15292
15293 void vec_st (vector float, int, vector float *);
15294 void vec_st (vector float, int, float *);
15295 void vec_st (vector signed int, int, vector signed int *);
15296 void vec_st (vector signed int, int, int *);
15297 void vec_st (vector unsigned int, int, vector unsigned int *);
15298 void vec_st (vector unsigned int, int, unsigned int *);
15299 void vec_st (vector bool int, int, vector bool int *);
15300 void vec_st (vector bool int, int, unsigned int *);
15301 void vec_st (vector bool int, int, int *);
15302 void vec_st (vector signed short, int, vector signed short *);
15303 void vec_st (vector signed short, int, short *);
15304 void vec_st (vector unsigned short, int, vector unsigned short *);
15305 void vec_st (vector unsigned short, int, unsigned short *);
15306 void vec_st (vector bool short, int, vector bool short *);
15307 void vec_st (vector bool short, int, unsigned short *);
15308 void vec_st (vector pixel, int, vector pixel *);
15309 void vec_st (vector pixel, int, unsigned short *);
15310 void vec_st (vector pixel, int, short *);
15311 void vec_st (vector bool short, int, short *);
15312 void vec_st (vector signed char, int, vector signed char *);
15313 void vec_st (vector signed char, int, signed char *);
15314 void vec_st (vector unsigned char, int, vector unsigned char *);
15315 void vec_st (vector unsigned char, int, unsigned char *);
15316 void vec_st (vector bool char, int, vector bool char *);
15317 void vec_st (vector bool char, int, unsigned char *);
15318 void vec_st (vector bool char, int, signed char *);
15319
15320 void vec_ste (vector signed char, int, signed char *);
15321 void vec_ste (vector unsigned char, int, unsigned char *);
15322 void vec_ste (vector bool char, int, signed char *);
15323 void vec_ste (vector bool char, int, unsigned char *);
15324 void vec_ste (vector signed short, int, short *);
15325 void vec_ste (vector unsigned short, int, unsigned short *);
15326 void vec_ste (vector bool short, int, short *);
15327 void vec_ste (vector bool short, int, unsigned short *);
15328 void vec_ste (vector pixel, int, short *);
15329 void vec_ste (vector pixel, int, unsigned short *);
15330 void vec_ste (vector float, int, float *);
15331 void vec_ste (vector signed int, int, int *);
15332 void vec_ste (vector unsigned int, int, unsigned int *);
15333 void vec_ste (vector bool int, int, int *);
15334 void vec_ste (vector bool int, int, unsigned int *);
15335
15336 void vec_stvewx (vector float, int, float *);
15337 void vec_stvewx (vector signed int, int, int *);
15338 void vec_stvewx (vector unsigned int, int, unsigned int *);
15339 void vec_stvewx (vector bool int, int, int *);
15340 void vec_stvewx (vector bool int, int, unsigned int *);
15341
15342 void vec_stvehx (vector signed short, int, short *);
15343 void vec_stvehx (vector unsigned short, int, unsigned short *);
15344 void vec_stvehx (vector bool short, int, short *);
15345 void vec_stvehx (vector bool short, int, unsigned short *);
15346 void vec_stvehx (vector pixel, int, short *);
15347 void vec_stvehx (vector pixel, int, unsigned short *);
15348
15349 void vec_stvebx (vector signed char, int, signed char *);
15350 void vec_stvebx (vector unsigned char, int, unsigned char *);
15351 void vec_stvebx (vector bool char, int, signed char *);
15352 void vec_stvebx (vector bool char, int, unsigned char *);
15353
15354 void vec_stl (vector float, int, vector float *);
15355 void vec_stl (vector float, int, float *);
15356 void vec_stl (vector signed int, int, vector signed int *);
15357 void vec_stl (vector signed int, int, int *);
15358 void vec_stl (vector unsigned int, int, vector unsigned int *);
15359 void vec_stl (vector unsigned int, int, unsigned int *);
15360 void vec_stl (vector bool int, int, vector bool int *);
15361 void vec_stl (vector bool int, int, unsigned int *);
15362 void vec_stl (vector bool int, int, int *);
15363 void vec_stl (vector signed short, int, vector signed short *);
15364 void vec_stl (vector signed short, int, short *);
15365 void vec_stl (vector unsigned short, int, vector unsigned short *);
15366 void vec_stl (vector unsigned short, int, unsigned short *);
15367 void vec_stl (vector bool short, int, vector bool short *);
15368 void vec_stl (vector bool short, int, unsigned short *);
15369 void vec_stl (vector bool short, int, short *);
15370 void vec_stl (vector pixel, int, vector pixel *);
15371 void vec_stl (vector pixel, int, unsigned short *);
15372 void vec_stl (vector pixel, int, short *);
15373 void vec_stl (vector signed char, int, vector signed char *);
15374 void vec_stl (vector signed char, int, signed char *);
15375 void vec_stl (vector unsigned char, int, vector unsigned char *);
15376 void vec_stl (vector unsigned char, int, unsigned char *);
15377 void vec_stl (vector bool char, int, vector bool char *);
15378 void vec_stl (vector bool char, int, unsigned char *);
15379 void vec_stl (vector bool char, int, signed char *);
15380
15381 vector signed char vec_sub (vector bool char, vector signed char);
15382 vector signed char vec_sub (vector signed char, vector bool char);
15383 vector signed char vec_sub (vector signed char, vector signed char);
15384 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15385 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15386 vector unsigned char vec_sub (vector unsigned char,
15387 vector unsigned char);
15388 vector signed short vec_sub (vector bool short, vector signed short);
15389 vector signed short vec_sub (vector signed short, vector bool short);
15390 vector signed short vec_sub (vector signed short, vector signed short);
15391 vector unsigned short vec_sub (vector bool short,
15392 vector unsigned short);
15393 vector unsigned short vec_sub (vector unsigned short,
15394 vector bool short);
15395 vector unsigned short vec_sub (vector unsigned short,
15396 vector unsigned short);
15397 vector signed int vec_sub (vector bool int, vector signed int);
15398 vector signed int vec_sub (vector signed int, vector bool int);
15399 vector signed int vec_sub (vector signed int, vector signed int);
15400 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15401 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15402 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15403 vector float vec_sub (vector float, vector float);
15404
15405 vector float vec_vsubfp (vector float, vector float);
15406
15407 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15408 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15409 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15410 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15411 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15412 vector unsigned int vec_vsubuwm (vector unsigned int,
15413 vector unsigned int);
15414
15415 vector signed short vec_vsubuhm (vector bool short,
15416 vector signed short);
15417 vector signed short vec_vsubuhm (vector signed short,
15418 vector bool short);
15419 vector signed short vec_vsubuhm (vector signed short,
15420 vector signed short);
15421 vector unsigned short vec_vsubuhm (vector bool short,
15422 vector unsigned short);
15423 vector unsigned short vec_vsubuhm (vector unsigned short,
15424 vector bool short);
15425 vector unsigned short vec_vsubuhm (vector unsigned short,
15426 vector unsigned short);
15427
15428 vector signed char vec_vsububm (vector bool char, vector signed char);
15429 vector signed char vec_vsububm (vector signed char, vector bool char);
15430 vector signed char vec_vsububm (vector signed char, vector signed char);
15431 vector unsigned char vec_vsububm (vector bool char,
15432 vector unsigned char);
15433 vector unsigned char vec_vsububm (vector unsigned char,
15434 vector bool char);
15435 vector unsigned char vec_vsububm (vector unsigned char,
15436 vector unsigned char);
15437
15438 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15439
15440 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15441 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15442 vector unsigned char vec_subs (vector unsigned char,
15443 vector unsigned char);
15444 vector signed char vec_subs (vector bool char, vector signed char);
15445 vector signed char vec_subs (vector signed char, vector bool char);
15446 vector signed char vec_subs (vector signed char, vector signed char);
15447 vector unsigned short vec_subs (vector bool short,
15448 vector unsigned short);
15449 vector unsigned short vec_subs (vector unsigned short,
15450 vector bool short);
15451 vector unsigned short vec_subs (vector unsigned short,
15452 vector unsigned short);
15453 vector signed short vec_subs (vector bool short, vector signed short);
15454 vector signed short vec_subs (vector signed short, vector bool short);
15455 vector signed short vec_subs (vector signed short, vector signed short);
15456 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15457 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15458 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15459 vector signed int vec_subs (vector bool int, vector signed int);
15460 vector signed int vec_subs (vector signed int, vector bool int);
15461 vector signed int vec_subs (vector signed int, vector signed int);
15462
15463 vector signed int vec_vsubsws (vector bool int, vector signed int);
15464 vector signed int vec_vsubsws (vector signed int, vector bool int);
15465 vector signed int vec_vsubsws (vector signed int, vector signed int);
15466
15467 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15468 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15469 vector unsigned int vec_vsubuws (vector unsigned int,
15470 vector unsigned int);
15471
15472 vector signed short vec_vsubshs (vector bool short,
15473 vector signed short);
15474 vector signed short vec_vsubshs (vector signed short,
15475 vector bool short);
15476 vector signed short vec_vsubshs (vector signed short,
15477 vector signed short);
15478
15479 vector unsigned short vec_vsubuhs (vector bool short,
15480 vector unsigned short);
15481 vector unsigned short vec_vsubuhs (vector unsigned short,
15482 vector bool short);
15483 vector unsigned short vec_vsubuhs (vector unsigned short,
15484 vector unsigned short);
15485
15486 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15487 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15488 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15489
15490 vector unsigned char vec_vsububs (vector bool char,
15491 vector unsigned char);
15492 vector unsigned char vec_vsububs (vector unsigned char,
15493 vector bool char);
15494 vector unsigned char vec_vsububs (vector unsigned char,
15495 vector unsigned char);
15496
15497 vector unsigned int vec_sum4s (vector unsigned char,
15498 vector unsigned int);
15499 vector signed int vec_sum4s (vector signed char, vector signed int);
15500 vector signed int vec_sum4s (vector signed short, vector signed int);
15501
15502 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15503
15504 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15505
15506 vector unsigned int vec_vsum4ubs (vector unsigned char,
15507 vector unsigned int);
15508
15509 vector signed int vec_sum2s (vector signed int, vector signed int);
15510
15511 vector signed int vec_sums (vector signed int, vector signed int);
15512
15513 vector float vec_trunc (vector float);
15514
15515 vector signed short vec_unpackh (vector signed char);
15516 vector bool short vec_unpackh (vector bool char);
15517 vector signed int vec_unpackh (vector signed short);
15518 vector bool int vec_unpackh (vector bool short);
15519 vector unsigned int vec_unpackh (vector pixel);
15520
15521 vector bool int vec_vupkhsh (vector bool short);
15522 vector signed int vec_vupkhsh (vector signed short);
15523
15524 vector unsigned int vec_vupkhpx (vector pixel);
15525
15526 vector bool short vec_vupkhsb (vector bool char);
15527 vector signed short vec_vupkhsb (vector signed char);
15528
15529 vector signed short vec_unpackl (vector signed char);
15530 vector bool short vec_unpackl (vector bool char);
15531 vector unsigned int vec_unpackl (vector pixel);
15532 vector signed int vec_unpackl (vector signed short);
15533 vector bool int vec_unpackl (vector bool short);
15534
15535 vector unsigned int vec_vupklpx (vector pixel);
15536
15537 vector bool int vec_vupklsh (vector bool short);
15538 vector signed int vec_vupklsh (vector signed short);
15539
15540 vector bool short vec_vupklsb (vector bool char);
15541 vector signed short vec_vupklsb (vector signed char);
15542
15543 vector float vec_xor (vector float, vector float);
15544 vector float vec_xor (vector float, vector bool int);
15545 vector float vec_xor (vector bool int, vector float);
15546 vector bool int vec_xor (vector bool int, vector bool int);
15547 vector signed int vec_xor (vector bool int, vector signed int);
15548 vector signed int vec_xor (vector signed int, vector bool int);
15549 vector signed int vec_xor (vector signed int, vector signed int);
15550 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15551 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15552 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15553 vector bool short vec_xor (vector bool short, vector bool short);
15554 vector signed short vec_xor (vector bool short, vector signed short);
15555 vector signed short vec_xor (vector signed short, vector bool short);
15556 vector signed short vec_xor (vector signed short, vector signed short);
15557 vector unsigned short vec_xor (vector bool short,
15558 vector unsigned short);
15559 vector unsigned short vec_xor (vector unsigned short,
15560 vector bool short);
15561 vector unsigned short vec_xor (vector unsigned short,
15562 vector unsigned short);
15563 vector signed char vec_xor (vector bool char, vector signed char);
15564 vector bool char vec_xor (vector bool char, vector bool char);
15565 vector signed char vec_xor (vector signed char, vector bool char);
15566 vector signed char vec_xor (vector signed char, vector signed char);
15567 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15568 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15569 vector unsigned char vec_xor (vector unsigned char,
15570 vector unsigned char);
15571
15572 int vec_all_eq (vector signed char, vector bool char);
15573 int vec_all_eq (vector signed char, vector signed char);
15574 int vec_all_eq (vector unsigned char, vector bool char);
15575 int vec_all_eq (vector unsigned char, vector unsigned char);
15576 int vec_all_eq (vector bool char, vector bool char);
15577 int vec_all_eq (vector bool char, vector unsigned char);
15578 int vec_all_eq (vector bool char, vector signed char);
15579 int vec_all_eq (vector signed short, vector bool short);
15580 int vec_all_eq (vector signed short, vector signed short);
15581 int vec_all_eq (vector unsigned short, vector bool short);
15582 int vec_all_eq (vector unsigned short, vector unsigned short);
15583 int vec_all_eq (vector bool short, vector bool short);
15584 int vec_all_eq (vector bool short, vector unsigned short);
15585 int vec_all_eq (vector bool short, vector signed short);
15586 int vec_all_eq (vector pixel, vector pixel);
15587 int vec_all_eq (vector signed int, vector bool int);
15588 int vec_all_eq (vector signed int, vector signed int);
15589 int vec_all_eq (vector unsigned int, vector bool int);
15590 int vec_all_eq (vector unsigned int, vector unsigned int);
15591 int vec_all_eq (vector bool int, vector bool int);
15592 int vec_all_eq (vector bool int, vector unsigned int);
15593 int vec_all_eq (vector bool int, vector signed int);
15594 int vec_all_eq (vector float, vector float);
15595
15596 int vec_all_ge (vector bool char, vector unsigned char);
15597 int vec_all_ge (vector unsigned char, vector bool char);
15598 int vec_all_ge (vector unsigned char, vector unsigned char);
15599 int vec_all_ge (vector bool char, vector signed char);
15600 int vec_all_ge (vector signed char, vector bool char);
15601 int vec_all_ge (vector signed char, vector signed char);
15602 int vec_all_ge (vector bool short, vector unsigned short);
15603 int vec_all_ge (vector unsigned short, vector bool short);
15604 int vec_all_ge (vector unsigned short, vector unsigned short);
15605 int vec_all_ge (vector signed short, vector signed short);
15606 int vec_all_ge (vector bool short, vector signed short);
15607 int vec_all_ge (vector signed short, vector bool short);
15608 int vec_all_ge (vector bool int, vector unsigned int);
15609 int vec_all_ge (vector unsigned int, vector bool int);
15610 int vec_all_ge (vector unsigned int, vector unsigned int);
15611 int vec_all_ge (vector bool int, vector signed int);
15612 int vec_all_ge (vector signed int, vector bool int);
15613 int vec_all_ge (vector signed int, vector signed int);
15614 int vec_all_ge (vector float, vector float);
15615
15616 int vec_all_gt (vector bool char, vector unsigned char);
15617 int vec_all_gt (vector unsigned char, vector bool char);
15618 int vec_all_gt (vector unsigned char, vector unsigned char);
15619 int vec_all_gt (vector bool char, vector signed char);
15620 int vec_all_gt (vector signed char, vector bool char);
15621 int vec_all_gt (vector signed char, vector signed char);
15622 int vec_all_gt (vector bool short, vector unsigned short);
15623 int vec_all_gt (vector unsigned short, vector bool short);
15624 int vec_all_gt (vector unsigned short, vector unsigned short);
15625 int vec_all_gt (vector bool short, vector signed short);
15626 int vec_all_gt (vector signed short, vector bool short);
15627 int vec_all_gt (vector signed short, vector signed short);
15628 int vec_all_gt (vector bool int, vector unsigned int);
15629 int vec_all_gt (vector unsigned int, vector bool int);
15630 int vec_all_gt (vector unsigned int, vector unsigned int);
15631 int vec_all_gt (vector bool int, vector signed int);
15632 int vec_all_gt (vector signed int, vector bool int);
15633 int vec_all_gt (vector signed int, vector signed int);
15634 int vec_all_gt (vector float, vector float);
15635
15636 int vec_all_in (vector float, vector float);
15637
15638 int vec_all_le (vector bool char, vector unsigned char);
15639 int vec_all_le (vector unsigned char, vector bool char);
15640 int vec_all_le (vector unsigned char, vector unsigned char);
15641 int vec_all_le (vector bool char, vector signed char);
15642 int vec_all_le (vector signed char, vector bool char);
15643 int vec_all_le (vector signed char, vector signed char);
15644 int vec_all_le (vector bool short, vector unsigned short);
15645 int vec_all_le (vector unsigned short, vector bool short);
15646 int vec_all_le (vector unsigned short, vector unsigned short);
15647 int vec_all_le (vector bool short, vector signed short);
15648 int vec_all_le (vector signed short, vector bool short);
15649 int vec_all_le (vector signed short, vector signed short);
15650 int vec_all_le (vector bool int, vector unsigned int);
15651 int vec_all_le (vector unsigned int, vector bool int);
15652 int vec_all_le (vector unsigned int, vector unsigned int);
15653 int vec_all_le (vector bool int, vector signed int);
15654 int vec_all_le (vector signed int, vector bool int);
15655 int vec_all_le (vector signed int, vector signed int);
15656 int vec_all_le (vector float, vector float);
15657
15658 int vec_all_lt (vector bool char, vector unsigned char);
15659 int vec_all_lt (vector unsigned char, vector bool char);
15660 int vec_all_lt (vector unsigned char, vector unsigned char);
15661 int vec_all_lt (vector bool char, vector signed char);
15662 int vec_all_lt (vector signed char, vector bool char);
15663 int vec_all_lt (vector signed char, vector signed char);
15664 int vec_all_lt (vector bool short, vector unsigned short);
15665 int vec_all_lt (vector unsigned short, vector bool short);
15666 int vec_all_lt (vector unsigned short, vector unsigned short);
15667 int vec_all_lt (vector bool short, vector signed short);
15668 int vec_all_lt (vector signed short, vector bool short);
15669 int vec_all_lt (vector signed short, vector signed short);
15670 int vec_all_lt (vector bool int, vector unsigned int);
15671 int vec_all_lt (vector unsigned int, vector bool int);
15672 int vec_all_lt (vector unsigned int, vector unsigned int);
15673 int vec_all_lt (vector bool int, vector signed int);
15674 int vec_all_lt (vector signed int, vector bool int);
15675 int vec_all_lt (vector signed int, vector signed int);
15676 int vec_all_lt (vector float, vector float);
15677
15678 int vec_all_nan (vector float);
15679
15680 int vec_all_ne (vector signed char, vector bool char);
15681 int vec_all_ne (vector signed char, vector signed char);
15682 int vec_all_ne (vector unsigned char, vector bool char);
15683 int vec_all_ne (vector unsigned char, vector unsigned char);
15684 int vec_all_ne (vector bool char, vector bool char);
15685 int vec_all_ne (vector bool char, vector unsigned char);
15686 int vec_all_ne (vector bool char, vector signed char);
15687 int vec_all_ne (vector signed short, vector bool short);
15688 int vec_all_ne (vector signed short, vector signed short);
15689 int vec_all_ne (vector unsigned short, vector bool short);
15690 int vec_all_ne (vector unsigned short, vector unsigned short);
15691 int vec_all_ne (vector bool short, vector bool short);
15692 int vec_all_ne (vector bool short, vector unsigned short);
15693 int vec_all_ne (vector bool short, vector signed short);
15694 int vec_all_ne (vector pixel, vector pixel);
15695 int vec_all_ne (vector signed int, vector bool int);
15696 int vec_all_ne (vector signed int, vector signed int);
15697 int vec_all_ne (vector unsigned int, vector bool int);
15698 int vec_all_ne (vector unsigned int, vector unsigned int);
15699 int vec_all_ne (vector bool int, vector bool int);
15700 int vec_all_ne (vector bool int, vector unsigned int);
15701 int vec_all_ne (vector bool int, vector signed int);
15702 int vec_all_ne (vector float, vector float);
15703
15704 int vec_all_nge (vector float, vector float);
15705
15706 int vec_all_ngt (vector float, vector float);
15707
15708 int vec_all_nle (vector float, vector float);
15709
15710 int vec_all_nlt (vector float, vector float);
15711
15712 int vec_all_numeric (vector float);
15713
15714 int vec_any_eq (vector signed char, vector bool char);
15715 int vec_any_eq (vector signed char, vector signed char);
15716 int vec_any_eq (vector unsigned char, vector bool char);
15717 int vec_any_eq (vector unsigned char, vector unsigned char);
15718 int vec_any_eq (vector bool char, vector bool char);
15719 int vec_any_eq (vector bool char, vector unsigned char);
15720 int vec_any_eq (vector bool char, vector signed char);
15721 int vec_any_eq (vector signed short, vector bool short);
15722 int vec_any_eq (vector signed short, vector signed short);
15723 int vec_any_eq (vector unsigned short, vector bool short);
15724 int vec_any_eq (vector unsigned short, vector unsigned short);
15725 int vec_any_eq (vector bool short, vector bool short);
15726 int vec_any_eq (vector bool short, vector unsigned short);
15727 int vec_any_eq (vector bool short, vector signed short);
15728 int vec_any_eq (vector pixel, vector pixel);
15729 int vec_any_eq (vector signed int, vector bool int);
15730 int vec_any_eq (vector signed int, vector signed int);
15731 int vec_any_eq (vector unsigned int, vector bool int);
15732 int vec_any_eq (vector unsigned int, vector unsigned int);
15733 int vec_any_eq (vector bool int, vector bool int);
15734 int vec_any_eq (vector bool int, vector unsigned int);
15735 int vec_any_eq (vector bool int, vector signed int);
15736 int vec_any_eq (vector float, vector float);
15737
15738 int vec_any_ge (vector signed char, vector bool char);
15739 int vec_any_ge (vector unsigned char, vector bool char);
15740 int vec_any_ge (vector unsigned char, vector unsigned char);
15741 int vec_any_ge (vector signed char, vector signed char);
15742 int vec_any_ge (vector bool char, vector unsigned char);
15743 int vec_any_ge (vector bool char, vector signed char);
15744 int vec_any_ge (vector unsigned short, vector bool short);
15745 int vec_any_ge (vector unsigned short, vector unsigned short);
15746 int vec_any_ge (vector signed short, vector signed short);
15747 int vec_any_ge (vector signed short, vector bool short);
15748 int vec_any_ge (vector bool short, vector unsigned short);
15749 int vec_any_ge (vector bool short, vector signed short);
15750 int vec_any_ge (vector signed int, vector bool int);
15751 int vec_any_ge (vector unsigned int, vector bool int);
15752 int vec_any_ge (vector unsigned int, vector unsigned int);
15753 int vec_any_ge (vector signed int, vector signed int);
15754 int vec_any_ge (vector bool int, vector unsigned int);
15755 int vec_any_ge (vector bool int, vector signed int);
15756 int vec_any_ge (vector float, vector float);
15757
15758 int vec_any_gt (vector bool char, vector unsigned char);
15759 int vec_any_gt (vector unsigned char, vector bool char);
15760 int vec_any_gt (vector unsigned char, vector unsigned char);
15761 int vec_any_gt (vector bool char, vector signed char);
15762 int vec_any_gt (vector signed char, vector bool char);
15763 int vec_any_gt (vector signed char, vector signed char);
15764 int vec_any_gt (vector bool short, vector unsigned short);
15765 int vec_any_gt (vector unsigned short, vector bool short);
15766 int vec_any_gt (vector unsigned short, vector unsigned short);
15767 int vec_any_gt (vector bool short, vector signed short);
15768 int vec_any_gt (vector signed short, vector bool short);
15769 int vec_any_gt (vector signed short, vector signed short);
15770 int vec_any_gt (vector bool int, vector unsigned int);
15771 int vec_any_gt (vector unsigned int, vector bool int);
15772 int vec_any_gt (vector unsigned int, vector unsigned int);
15773 int vec_any_gt (vector bool int, vector signed int);
15774 int vec_any_gt (vector signed int, vector bool int);
15775 int vec_any_gt (vector signed int, vector signed int);
15776 int vec_any_gt (vector float, vector float);
15777
15778 int vec_any_le (vector bool char, vector unsigned char);
15779 int vec_any_le (vector unsigned char, vector bool char);
15780 int vec_any_le (vector unsigned char, vector unsigned char);
15781 int vec_any_le (vector bool char, vector signed char);
15782 int vec_any_le (vector signed char, vector bool char);
15783 int vec_any_le (vector signed char, vector signed char);
15784 int vec_any_le (vector bool short, vector unsigned short);
15785 int vec_any_le (vector unsigned short, vector bool short);
15786 int vec_any_le (vector unsigned short, vector unsigned short);
15787 int vec_any_le (vector bool short, vector signed short);
15788 int vec_any_le (vector signed short, vector bool short);
15789 int vec_any_le (vector signed short, vector signed short);
15790 int vec_any_le (vector bool int, vector unsigned int);
15791 int vec_any_le (vector unsigned int, vector bool int);
15792 int vec_any_le (vector unsigned int, vector unsigned int);
15793 int vec_any_le (vector bool int, vector signed int);
15794 int vec_any_le (vector signed int, vector bool int);
15795 int vec_any_le (vector signed int, vector signed int);
15796 int vec_any_le (vector float, vector float);
15797
15798 int vec_any_lt (vector bool char, vector unsigned char);
15799 int vec_any_lt (vector unsigned char, vector bool char);
15800 int vec_any_lt (vector unsigned char, vector unsigned char);
15801 int vec_any_lt (vector bool char, vector signed char);
15802 int vec_any_lt (vector signed char, vector bool char);
15803 int vec_any_lt (vector signed char, vector signed char);
15804 int vec_any_lt (vector bool short, vector unsigned short);
15805 int vec_any_lt (vector unsigned short, vector bool short);
15806 int vec_any_lt (vector unsigned short, vector unsigned short);
15807 int vec_any_lt (vector bool short, vector signed short);
15808 int vec_any_lt (vector signed short, vector bool short);
15809 int vec_any_lt (vector signed short, vector signed short);
15810 int vec_any_lt (vector bool int, vector unsigned int);
15811 int vec_any_lt (vector unsigned int, vector bool int);
15812 int vec_any_lt (vector unsigned int, vector unsigned int);
15813 int vec_any_lt (vector bool int, vector signed int);
15814 int vec_any_lt (vector signed int, vector bool int);
15815 int vec_any_lt (vector signed int, vector signed int);
15816 int vec_any_lt (vector float, vector float);
15817
15818 int vec_any_nan (vector float);
15819
15820 int vec_any_ne (vector signed char, vector bool char);
15821 int vec_any_ne (vector signed char, vector signed char);
15822 int vec_any_ne (vector unsigned char, vector bool char);
15823 int vec_any_ne (vector unsigned char, vector unsigned char);
15824 int vec_any_ne (vector bool char, vector bool char);
15825 int vec_any_ne (vector bool char, vector unsigned char);
15826 int vec_any_ne (vector bool char, vector signed char);
15827 int vec_any_ne (vector signed short, vector bool short);
15828 int vec_any_ne (vector signed short, vector signed short);
15829 int vec_any_ne (vector unsigned short, vector bool short);
15830 int vec_any_ne (vector unsigned short, vector unsigned short);
15831 int vec_any_ne (vector bool short, vector bool short);
15832 int vec_any_ne (vector bool short, vector unsigned short);
15833 int vec_any_ne (vector bool short, vector signed short);
15834 int vec_any_ne (vector pixel, vector pixel);
15835 int vec_any_ne (vector signed int, vector bool int);
15836 int vec_any_ne (vector signed int, vector signed int);
15837 int vec_any_ne (vector unsigned int, vector bool int);
15838 int vec_any_ne (vector unsigned int, vector unsigned int);
15839 int vec_any_ne (vector bool int, vector bool int);
15840 int vec_any_ne (vector bool int, vector unsigned int);
15841 int vec_any_ne (vector bool int, vector signed int);
15842 int vec_any_ne (vector float, vector float);
15843
15844 int vec_any_nge (vector float, vector float);
15845
15846 int vec_any_ngt (vector float, vector float);
15847
15848 int vec_any_nle (vector float, vector float);
15849
15850 int vec_any_nlt (vector float, vector float);
15851
15852 int vec_any_numeric (vector float);
15853
15854 int vec_any_out (vector float, vector float);
15855 @end smallexample
15856
15857 If the vector/scalar (VSX) instruction set is available, the following
15858 additional functions are available:
15859
15860 @smallexample
15861 vector double vec_abs (vector double);
15862 vector double vec_add (vector double, vector double);
15863 vector double vec_and (vector double, vector double);
15864 vector double vec_and (vector double, vector bool long);
15865 vector double vec_and (vector bool long, vector double);
15866 vector long vec_and (vector long, vector long);
15867 vector long vec_and (vector long, vector bool long);
15868 vector long vec_and (vector bool long, vector long);
15869 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15870 vector unsigned long vec_and (vector unsigned long, vector bool long);
15871 vector unsigned long vec_and (vector bool long, vector unsigned long);
15872 vector double vec_andc (vector double, vector double);
15873 vector double vec_andc (vector double, vector bool long);
15874 vector double vec_andc (vector bool long, vector double);
15875 vector long vec_andc (vector long, vector long);
15876 vector long vec_andc (vector long, vector bool long);
15877 vector long vec_andc (vector bool long, vector long);
15878 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15879 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15880 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15881 vector double vec_ceil (vector double);
15882 vector bool long vec_cmpeq (vector double, vector double);
15883 vector bool long vec_cmpge (vector double, vector double);
15884 vector bool long vec_cmpgt (vector double, vector double);
15885 vector bool long vec_cmple (vector double, vector double);
15886 vector bool long vec_cmplt (vector double, vector double);
15887 vector double vec_cpsgn (vector double, vector double);
15888 vector float vec_div (vector float, vector float);
15889 vector double vec_div (vector double, vector double);
15890 vector long vec_div (vector long, vector long);
15891 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15892 vector double vec_floor (vector double);
15893 vector double vec_ld (int, const vector double *);
15894 vector double vec_ld (int, const double *);
15895 vector double vec_ldl (int, const vector double *);
15896 vector double vec_ldl (int, const double *);
15897 vector unsigned char vec_lvsl (int, const volatile double *);
15898 vector unsigned char vec_lvsr (int, const volatile double *);
15899 vector double vec_madd (vector double, vector double, vector double);
15900 vector double vec_max (vector double, vector double);
15901 vector signed long vec_mergeh (vector signed long, vector signed long);
15902 vector signed long vec_mergeh (vector signed long, vector bool long);
15903 vector signed long vec_mergeh (vector bool long, vector signed long);
15904 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15905 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15906 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15907 vector signed long vec_mergel (vector signed long, vector signed long);
15908 vector signed long vec_mergel (vector signed long, vector bool long);
15909 vector signed long vec_mergel (vector bool long, vector signed long);
15910 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15911 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15912 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15913 vector double vec_min (vector double, vector double);
15914 vector float vec_msub (vector float, vector float, vector float);
15915 vector double vec_msub (vector double, vector double, vector double);
15916 vector float vec_mul (vector float, vector float);
15917 vector double vec_mul (vector double, vector double);
15918 vector long vec_mul (vector long, vector long);
15919 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15920 vector float vec_nearbyint (vector float);
15921 vector double vec_nearbyint (vector double);
15922 vector float vec_nmadd (vector float, vector float, vector float);
15923 vector double vec_nmadd (vector double, vector double, vector double);
15924 vector double vec_nmsub (vector double, vector double, vector double);
15925 vector double vec_nor (vector double, vector double);
15926 vector long vec_nor (vector long, vector long);
15927 vector long vec_nor (vector long, vector bool long);
15928 vector long vec_nor (vector bool long, vector long);
15929 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15930 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15931 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15932 vector double vec_or (vector double, vector double);
15933 vector double vec_or (vector double, vector bool long);
15934 vector double vec_or (vector bool long, vector double);
15935 vector long vec_or (vector long, vector long);
15936 vector long vec_or (vector long, vector bool long);
15937 vector long vec_or (vector bool long, vector long);
15938 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15939 vector unsigned long vec_or (vector unsigned long, vector bool long);
15940 vector unsigned long vec_or (vector bool long, vector unsigned long);
15941 vector double vec_perm (vector double, vector double, vector unsigned char);
15942 vector long vec_perm (vector long, vector long, vector unsigned char);
15943 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15944 vector unsigned char);
15945 vector double vec_rint (vector double);
15946 vector double vec_recip (vector double, vector double);
15947 vector double vec_rsqrt (vector double);
15948 vector double vec_rsqrte (vector double);
15949 vector double vec_sel (vector double, vector double, vector bool long);
15950 vector double vec_sel (vector double, vector double, vector unsigned long);
15951 vector long vec_sel (vector long, vector long, vector long);
15952 vector long vec_sel (vector long, vector long, vector unsigned long);
15953 vector long vec_sel (vector long, vector long, vector bool long);
15954 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15955 vector long);
15956 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15957 vector unsigned long);
15958 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15959 vector bool long);
15960 vector double vec_splats (double);
15961 vector signed long vec_splats (signed long);
15962 vector unsigned long vec_splats (unsigned long);
15963 vector float vec_sqrt (vector float);
15964 vector double vec_sqrt (vector double);
15965 void vec_st (vector double, int, vector double *);
15966 void vec_st (vector double, int, double *);
15967 vector double vec_sub (vector double, vector double);
15968 vector double vec_trunc (vector double);
15969 vector double vec_xor (vector double, vector double);
15970 vector double vec_xor (vector double, vector bool long);
15971 vector double vec_xor (vector bool long, vector double);
15972 vector long vec_xor (vector long, vector long);
15973 vector long vec_xor (vector long, vector bool long);
15974 vector long vec_xor (vector bool long, vector long);
15975 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15976 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15977 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15978 int vec_all_eq (vector double, vector double);
15979 int vec_all_ge (vector double, vector double);
15980 int vec_all_gt (vector double, vector double);
15981 int vec_all_le (vector double, vector double);
15982 int vec_all_lt (vector double, vector double);
15983 int vec_all_nan (vector double);
15984 int vec_all_ne (vector double, vector double);
15985 int vec_all_nge (vector double, vector double);
15986 int vec_all_ngt (vector double, vector double);
15987 int vec_all_nle (vector double, vector double);
15988 int vec_all_nlt (vector double, vector double);
15989 int vec_all_numeric (vector double);
15990 int vec_any_eq (vector double, vector double);
15991 int vec_any_ge (vector double, vector double);
15992 int vec_any_gt (vector double, vector double);
15993 int vec_any_le (vector double, vector double);
15994 int vec_any_lt (vector double, vector double);
15995 int vec_any_nan (vector double);
15996 int vec_any_ne (vector double, vector double);
15997 int vec_any_nge (vector double, vector double);
15998 int vec_any_ngt (vector double, vector double);
15999 int vec_any_nle (vector double, vector double);
16000 int vec_any_nlt (vector double, vector double);
16001 int vec_any_numeric (vector double);
16002
16003 vector double vec_vsx_ld (int, const vector double *);
16004 vector double vec_vsx_ld (int, const double *);
16005 vector float vec_vsx_ld (int, const vector float *);
16006 vector float vec_vsx_ld (int, const float *);
16007 vector bool int vec_vsx_ld (int, const vector bool int *);
16008 vector signed int vec_vsx_ld (int, const vector signed int *);
16009 vector signed int vec_vsx_ld (int, const int *);
16010 vector signed int vec_vsx_ld (int, const long *);
16011 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
16012 vector unsigned int vec_vsx_ld (int, const unsigned int *);
16013 vector unsigned int vec_vsx_ld (int, const unsigned long *);
16014 vector bool short vec_vsx_ld (int, const vector bool short *);
16015 vector pixel vec_vsx_ld (int, const vector pixel *);
16016 vector signed short vec_vsx_ld (int, const vector signed short *);
16017 vector signed short vec_vsx_ld (int, const short *);
16018 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
16019 vector unsigned short vec_vsx_ld (int, const unsigned short *);
16020 vector bool char vec_vsx_ld (int, const vector bool char *);
16021 vector signed char vec_vsx_ld (int, const vector signed char *);
16022 vector signed char vec_vsx_ld (int, const signed char *);
16023 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
16024 vector unsigned char vec_vsx_ld (int, const unsigned char *);
16025
16026 void vec_vsx_st (vector double, int, vector double *);
16027 void vec_vsx_st (vector double, int, double *);
16028 void vec_vsx_st (vector float, int, vector float *);
16029 void vec_vsx_st (vector float, int, float *);
16030 void vec_vsx_st (vector signed int, int, vector signed int *);
16031 void vec_vsx_st (vector signed int, int, int *);
16032 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
16033 void vec_vsx_st (vector unsigned int, int, unsigned int *);
16034 void vec_vsx_st (vector bool int, int, vector bool int *);
16035 void vec_vsx_st (vector bool int, int, unsigned int *);
16036 void vec_vsx_st (vector bool int, int, int *);
16037 void vec_vsx_st (vector signed short, int, vector signed short *);
16038 void vec_vsx_st (vector signed short, int, short *);
16039 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
16040 void vec_vsx_st (vector unsigned short, int, unsigned short *);
16041 void vec_vsx_st (vector bool short, int, vector bool short *);
16042 void vec_vsx_st (vector bool short, int, unsigned short *);
16043 void vec_vsx_st (vector pixel, int, vector pixel *);
16044 void vec_vsx_st (vector pixel, int, unsigned short *);
16045 void vec_vsx_st (vector pixel, int, short *);
16046 void vec_vsx_st (vector bool short, int, short *);
16047 void vec_vsx_st (vector signed char, int, vector signed char *);
16048 void vec_vsx_st (vector signed char, int, signed char *);
16049 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
16050 void vec_vsx_st (vector unsigned char, int, unsigned char *);
16051 void vec_vsx_st (vector bool char, int, vector bool char *);
16052 void vec_vsx_st (vector bool char, int, unsigned char *);
16053 void vec_vsx_st (vector bool char, int, signed char *);
16054
16055 vector double vec_xxpermdi (vector double, vector double, int);
16056 vector float vec_xxpermdi (vector float, vector float, int);
16057 vector long long vec_xxpermdi (vector long long, vector long long, int);
16058 vector unsigned long long vec_xxpermdi (vector unsigned long long,
16059 vector unsigned long long, int);
16060 vector int vec_xxpermdi (vector int, vector int, int);
16061 vector unsigned int vec_xxpermdi (vector unsigned int,
16062 vector unsigned int, int);
16063 vector short vec_xxpermdi (vector short, vector short, int);
16064 vector unsigned short vec_xxpermdi (vector unsigned short,
16065 vector unsigned short, int);
16066 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16067 vector unsigned char vec_xxpermdi (vector unsigned char,
16068 vector unsigned char, int);
16069
16070 vector double vec_xxsldi (vector double, vector double, int);
16071 vector float vec_xxsldi (vector float, vector float, int);
16072 vector long long vec_xxsldi (vector long long, vector long long, int);
16073 vector unsigned long long vec_xxsldi (vector unsigned long long,
16074 vector unsigned long long, int);
16075 vector int vec_xxsldi (vector int, vector int, int);
16076 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16077 vector short vec_xxsldi (vector short, vector short, int);
16078 vector unsigned short vec_xxsldi (vector unsigned short,
16079 vector unsigned short, int);
16080 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16081 vector unsigned char vec_xxsldi (vector unsigned char,
16082 vector unsigned char, int);
16083 @end smallexample
16084
16085 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16086 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16087 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16088 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16089 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16090
16091 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16092 instruction set is available, the following additional functions are
16093 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16094 can use @var{vector long} instead of @var{vector long long},
16095 @var{vector bool long} instead of @var{vector bool long long}, and
16096 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16097
16098 @smallexample
16099 vector long long vec_abs (vector long long);
16100
16101 vector long long vec_add (vector long long, vector long long);
16102 vector unsigned long long vec_add (vector unsigned long long,
16103 vector unsigned long long);
16104
16105 int vec_all_eq (vector long long, vector long long);
16106 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16107 int vec_all_ge (vector long long, vector long long);
16108 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16109 int vec_all_gt (vector long long, vector long long);
16110 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16111 int vec_all_le (vector long long, vector long long);
16112 int vec_all_le (vector unsigned long long, vector unsigned long long);
16113 int vec_all_lt (vector long long, vector long long);
16114 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16115 int vec_all_ne (vector long long, vector long long);
16116 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16117
16118 int vec_any_eq (vector long long, vector long long);
16119 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16120 int vec_any_ge (vector long long, vector long long);
16121 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16122 int vec_any_gt (vector long long, vector long long);
16123 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16124 int vec_any_le (vector long long, vector long long);
16125 int vec_any_le (vector unsigned long long, vector unsigned long long);
16126 int vec_any_lt (vector long long, vector long long);
16127 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16128 int vec_any_ne (vector long long, vector long long);
16129 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16130
16131 vector long long vec_eqv (vector long long, vector long long);
16132 vector long long vec_eqv (vector bool long long, vector long long);
16133 vector long long vec_eqv (vector long long, vector bool long long);
16134 vector unsigned long long vec_eqv (vector unsigned long long,
16135 vector unsigned long long);
16136 vector unsigned long long vec_eqv (vector bool long long,
16137 vector unsigned long long);
16138 vector unsigned long long vec_eqv (vector unsigned long long,
16139 vector bool long long);
16140 vector int vec_eqv (vector int, vector int);
16141 vector int vec_eqv (vector bool int, vector int);
16142 vector int vec_eqv (vector int, vector bool int);
16143 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16144 vector unsigned int vec_eqv (vector bool unsigned int,
16145 vector unsigned int);
16146 vector unsigned int vec_eqv (vector unsigned int,
16147 vector bool unsigned int);
16148 vector short vec_eqv (vector short, vector short);
16149 vector short vec_eqv (vector bool short, vector short);
16150 vector short vec_eqv (vector short, vector bool short);
16151 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16152 vector unsigned short vec_eqv (vector bool unsigned short,
16153 vector unsigned short);
16154 vector unsigned short vec_eqv (vector unsigned short,
16155 vector bool unsigned short);
16156 vector signed char vec_eqv (vector signed char, vector signed char);
16157 vector signed char vec_eqv (vector bool signed char, vector signed char);
16158 vector signed char vec_eqv (vector signed char, vector bool signed char);
16159 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16160 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16161 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16162
16163 vector long long vec_max (vector long long, vector long long);
16164 vector unsigned long long vec_max (vector unsigned long long,
16165 vector unsigned long long);
16166
16167 vector signed int vec_mergee (vector signed int, vector signed int);
16168 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16169 vector bool int vec_mergee (vector bool int, vector bool int);
16170
16171 vector signed int vec_mergeo (vector signed int, vector signed int);
16172 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16173 vector bool int vec_mergeo (vector bool int, vector bool int);
16174
16175 vector long long vec_min (vector long long, vector long long);
16176 vector unsigned long long vec_min (vector unsigned long long,
16177 vector unsigned long long);
16178
16179 vector long long vec_nand (vector long long, vector long long);
16180 vector long long vec_nand (vector bool long long, vector long long);
16181 vector long long vec_nand (vector long long, vector bool long long);
16182 vector unsigned long long vec_nand (vector unsigned long long,
16183 vector unsigned long long);
16184 vector unsigned long long vec_nand (vector bool long long,
16185 vector unsigned long long);
16186 vector unsigned long long vec_nand (vector unsigned long long,
16187 vector bool long long);
16188 vector int vec_nand (vector int, vector int);
16189 vector int vec_nand (vector bool int, vector int);
16190 vector int vec_nand (vector int, vector bool int);
16191 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16192 vector unsigned int vec_nand (vector bool unsigned int,
16193 vector unsigned int);
16194 vector unsigned int vec_nand (vector unsigned int,
16195 vector bool unsigned int);
16196 vector short vec_nand (vector short, vector short);
16197 vector short vec_nand (vector bool short, vector short);
16198 vector short vec_nand (vector short, vector bool short);
16199 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16200 vector unsigned short vec_nand (vector bool unsigned short,
16201 vector unsigned short);
16202 vector unsigned short vec_nand (vector unsigned short,
16203 vector bool unsigned short);
16204 vector signed char vec_nand (vector signed char, vector signed char);
16205 vector signed char vec_nand (vector bool signed char, vector signed char);
16206 vector signed char vec_nand (vector signed char, vector bool signed char);
16207 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16208 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16209 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16210
16211 vector long long vec_orc (vector long long, vector long long);
16212 vector long long vec_orc (vector bool long long, vector long long);
16213 vector long long vec_orc (vector long long, vector bool long long);
16214 vector unsigned long long vec_orc (vector unsigned long long,
16215 vector unsigned long long);
16216 vector unsigned long long vec_orc (vector bool long long,
16217 vector unsigned long long);
16218 vector unsigned long long vec_orc (vector unsigned long long,
16219 vector bool long long);
16220 vector int vec_orc (vector int, vector int);
16221 vector int vec_orc (vector bool int, vector int);
16222 vector int vec_orc (vector int, vector bool int);
16223 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16224 vector unsigned int vec_orc (vector bool unsigned int,
16225 vector unsigned int);
16226 vector unsigned int vec_orc (vector unsigned int,
16227 vector bool unsigned int);
16228 vector short vec_orc (vector short, vector short);
16229 vector short vec_orc (vector bool short, vector short);
16230 vector short vec_orc (vector short, vector bool short);
16231 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16232 vector unsigned short vec_orc (vector bool unsigned short,
16233 vector unsigned short);
16234 vector unsigned short vec_orc (vector unsigned short,
16235 vector bool unsigned short);
16236 vector signed char vec_orc (vector signed char, vector signed char);
16237 vector signed char vec_orc (vector bool signed char, vector signed char);
16238 vector signed char vec_orc (vector signed char, vector bool signed char);
16239 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16240 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16241 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16242
16243 vector int vec_pack (vector long long, vector long long);
16244 vector unsigned int vec_pack (vector unsigned long long,
16245 vector unsigned long long);
16246 vector bool int vec_pack (vector bool long long, vector bool long long);
16247
16248 vector int vec_packs (vector long long, vector long long);
16249 vector unsigned int vec_packs (vector unsigned long long,
16250 vector unsigned long long);
16251
16252 vector unsigned int vec_packsu (vector long long, vector long long);
16253 vector unsigned int vec_packsu (vector unsigned long long,
16254 vector unsigned long long);
16255
16256 vector long long vec_rl (vector long long,
16257 vector unsigned long long);
16258 vector long long vec_rl (vector unsigned long long,
16259 vector unsigned long long);
16260
16261 vector long long vec_sl (vector long long, vector unsigned long long);
16262 vector long long vec_sl (vector unsigned long long,
16263 vector unsigned long long);
16264
16265 vector long long vec_sr (vector long long, vector unsigned long long);
16266 vector unsigned long long char vec_sr (vector unsigned long long,
16267 vector unsigned long long);
16268
16269 vector long long vec_sra (vector long long, vector unsigned long long);
16270 vector unsigned long long vec_sra (vector unsigned long long,
16271 vector unsigned long long);
16272
16273 vector long long vec_sub (vector long long, vector long long);
16274 vector unsigned long long vec_sub (vector unsigned long long,
16275 vector unsigned long long);
16276
16277 vector long long vec_unpackh (vector int);
16278 vector unsigned long long vec_unpackh (vector unsigned int);
16279
16280 vector long long vec_unpackl (vector int);
16281 vector unsigned long long vec_unpackl (vector unsigned int);
16282
16283 vector long long vec_vaddudm (vector long long, vector long long);
16284 vector long long vec_vaddudm (vector bool long long, vector long long);
16285 vector long long vec_vaddudm (vector long long, vector bool long long);
16286 vector unsigned long long vec_vaddudm (vector unsigned long long,
16287 vector unsigned long long);
16288 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16289 vector unsigned long long);
16290 vector unsigned long long vec_vaddudm (vector unsigned long long,
16291 vector bool unsigned long long);
16292
16293 vector long long vec_vbpermq (vector signed char, vector signed char);
16294 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16295
16296 vector long long vec_cntlz (vector long long);
16297 vector unsigned long long vec_cntlz (vector unsigned long long);
16298 vector int vec_cntlz (vector int);
16299 vector unsigned int vec_cntlz (vector int);
16300 vector short vec_cntlz (vector short);
16301 vector unsigned short vec_cntlz (vector unsigned short);
16302 vector signed char vec_cntlz (vector signed char);
16303 vector unsigned char vec_cntlz (vector unsigned char);
16304
16305 vector long long vec_vclz (vector long long);
16306 vector unsigned long long vec_vclz (vector unsigned long long);
16307 vector int vec_vclz (vector int);
16308 vector unsigned int vec_vclz (vector int);
16309 vector short vec_vclz (vector short);
16310 vector unsigned short vec_vclz (vector unsigned short);
16311 vector signed char vec_vclz (vector signed char);
16312 vector unsigned char vec_vclz (vector unsigned char);
16313
16314 vector signed char vec_vclzb (vector signed char);
16315 vector unsigned char vec_vclzb (vector unsigned char);
16316
16317 vector long long vec_vclzd (vector long long);
16318 vector unsigned long long vec_vclzd (vector unsigned long long);
16319
16320 vector short vec_vclzh (vector short);
16321 vector unsigned short vec_vclzh (vector unsigned short);
16322
16323 vector int vec_vclzw (vector int);
16324 vector unsigned int vec_vclzw (vector int);
16325
16326 vector signed char vec_vgbbd (vector signed char);
16327 vector unsigned char vec_vgbbd (vector unsigned char);
16328
16329 vector long long vec_vmaxsd (vector long long, vector long long);
16330
16331 vector unsigned long long vec_vmaxud (vector unsigned long long,
16332 unsigned vector long long);
16333
16334 vector long long vec_vminsd (vector long long, vector long long);
16335
16336 vector unsigned long long vec_vminud (vector long long,
16337 vector long long);
16338
16339 vector int vec_vpksdss (vector long long, vector long long);
16340 vector unsigned int vec_vpksdss (vector long long, vector long long);
16341
16342 vector unsigned int vec_vpkudus (vector unsigned long long,
16343 vector unsigned long long);
16344
16345 vector int vec_vpkudum (vector long long, vector long long);
16346 vector unsigned int vec_vpkudum (vector unsigned long long,
16347 vector unsigned long long);
16348 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16349
16350 vector long long vec_vpopcnt (vector long long);
16351 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16352 vector int vec_vpopcnt (vector int);
16353 vector unsigned int vec_vpopcnt (vector int);
16354 vector short vec_vpopcnt (vector short);
16355 vector unsigned short vec_vpopcnt (vector unsigned short);
16356 vector signed char vec_vpopcnt (vector signed char);
16357 vector unsigned char vec_vpopcnt (vector unsigned char);
16358
16359 vector signed char vec_vpopcntb (vector signed char);
16360 vector unsigned char vec_vpopcntb (vector unsigned char);
16361
16362 vector long long vec_vpopcntd (vector long long);
16363 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16364
16365 vector short vec_vpopcnth (vector short);
16366 vector unsigned short vec_vpopcnth (vector unsigned short);
16367
16368 vector int vec_vpopcntw (vector int);
16369 vector unsigned int vec_vpopcntw (vector int);
16370
16371 vector long long vec_vrld (vector long long, vector unsigned long long);
16372 vector unsigned long long vec_vrld (vector unsigned long long,
16373 vector unsigned long long);
16374
16375 vector long long vec_vsld (vector long long, vector unsigned long long);
16376 vector long long vec_vsld (vector unsigned long long,
16377 vector unsigned long long);
16378
16379 vector long long vec_vsrad (vector long long, vector unsigned long long);
16380 vector unsigned long long vec_vsrad (vector unsigned long long,
16381 vector unsigned long long);
16382
16383 vector long long vec_vsrd (vector long long, vector unsigned long long);
16384 vector unsigned long long char vec_vsrd (vector unsigned long long,
16385 vector unsigned long long);
16386
16387 vector long long vec_vsubudm (vector long long, vector long long);
16388 vector long long vec_vsubudm (vector bool long long, vector long long);
16389 vector long long vec_vsubudm (vector long long, vector bool long long);
16390 vector unsigned long long vec_vsubudm (vector unsigned long long,
16391 vector unsigned long long);
16392 vector unsigned long long vec_vsubudm (vector bool long long,
16393 vector unsigned long long);
16394 vector unsigned long long vec_vsubudm (vector unsigned long long,
16395 vector bool long long);
16396
16397 vector long long vec_vupkhsw (vector int);
16398 vector unsigned long long vec_vupkhsw (vector unsigned int);
16399
16400 vector long long vec_vupklsw (vector int);
16401 vector unsigned long long vec_vupklsw (vector int);
16402 @end smallexample
16403
16404 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16405 instruction set is available, the following additional functions are
16406 available for 64-bit targets. New vector types
16407 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16408 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16409 builtins.
16410
16411 The normal vector extract, and set operations work on
16412 @var{vector __int128_t} and @var{vector __uint128_t} types,
16413 but the index value must be 0.
16414
16415 @smallexample
16416 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16417 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16418
16419 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16420 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16421
16422 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16423 vector __int128_t);
16424 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16425 vector __uint128_t);
16426
16427 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16428 vector __int128_t);
16429 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16430 vector __uint128_t);
16431
16432 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16433 vector __int128_t);
16434 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16435 vector __uint128_t);
16436
16437 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16438 vector __int128_t);
16439 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16440 vector __uint128_t);
16441
16442 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16443 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16444
16445 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16446 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16447
16448 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16449 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16450 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16451 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16452 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16453 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16454 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16455 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16456 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16457 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16458 @end smallexample
16459
16460 If the cryptographic instructions are enabled (@option{-mcrypto} or
16461 @option{-mcpu=power8}), the following builtins are enabled.
16462
16463 @smallexample
16464 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16465
16466 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16467 vector unsigned long long);
16468
16469 vector unsigned long long __builtin_crypto_vcipherlast
16470 (vector unsigned long long,
16471 vector unsigned long long);
16472
16473 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16474 vector unsigned long long);
16475
16476 vector unsigned long long __builtin_crypto_vncipherlast
16477 (vector unsigned long long,
16478 vector unsigned long long);
16479
16480 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16481 vector unsigned char,
16482 vector unsigned char);
16483
16484 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16485 vector unsigned short,
16486 vector unsigned short);
16487
16488 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16489 vector unsigned int,
16490 vector unsigned int);
16491
16492 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16493 vector unsigned long long,
16494 vector unsigned long long);
16495
16496 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16497 vector unsigned char);
16498
16499 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16500 vector unsigned short);
16501
16502 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16503 vector unsigned int);
16504
16505 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16506 vector unsigned long long);
16507
16508 vector unsigned long long __builtin_crypto_vshasigmad
16509 (vector unsigned long long, int, int);
16510
16511 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16512 int, int);
16513 @end smallexample
16514
16515 The second argument to the @var{__builtin_crypto_vshasigmad} and
16516 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16517 integer that is 0 or 1. The third argument to these builtin functions
16518 must be a constant integer in the range of 0 to 15.
16519
16520 @node PowerPC Hardware Transactional Memory Built-in Functions
16521 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16522 GCC provides two interfaces for accessing the Hardware Transactional
16523 Memory (HTM) instructions available on some of the PowerPC family
16524 of processors (eg, POWER8). The two interfaces come in a low level
16525 interface, consisting of built-in functions specific to PowerPC and a
16526 higher level interface consisting of inline functions that are common
16527 between PowerPC and S/390.
16528
16529 @subsubsection PowerPC HTM Low Level Built-in Functions
16530
16531 The following low level built-in functions are available with
16532 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16533 They all generate the machine instruction that is part of the name.
16534
16535 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16536 the full 4-bit condition register value set by their associated hardware
16537 instruction. The header file @code{htmintrin.h} defines some macros that can
16538 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16539 returns a simple true or false value depending on whether a transaction was
16540 successfully started or not. The arguments of the builtins match exactly the
16541 type and order of the associated hardware instruction's operands, except for
16542 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16543 Refer to the ISA manual for a description of each instruction's operands.
16544
16545 @smallexample
16546 unsigned int __builtin_tbegin (unsigned int)
16547 unsigned int __builtin_tend (unsigned int)
16548
16549 unsigned int __builtin_tabort (unsigned int)
16550 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16551 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16552 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16553 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16554
16555 unsigned int __builtin_tcheck (void)
16556 unsigned int __builtin_treclaim (unsigned int)
16557 unsigned int __builtin_trechkpt (void)
16558 unsigned int __builtin_tsr (unsigned int)
16559 @end smallexample
16560
16561 In addition to the above HTM built-ins, we have added built-ins for
16562 some common extended mnemonics of the HTM instructions:
16563
16564 @smallexample
16565 unsigned int __builtin_tendall (void)
16566 unsigned int __builtin_tresume (void)
16567 unsigned int __builtin_tsuspend (void)
16568 @end smallexample
16569
16570 Note that the semantics of the above HTM builtins are required to mimic
16571 the locking semantics used for critical sections. Builtins that are used
16572 to create a new transaction or restart a suspended transaction must have
16573 lock acquisition like semantics while those builtins that end or suspend a
16574 transaction must have lock release like semantics. Specifically, this must
16575 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16576 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16577 that returns 0, and lock release is as-if an execution of
16578 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16579 implicit implementation-defined lock used for all transactions. The HTM
16580 instructions associated with with the builtins inherently provide the
16581 correct acquisition and release hardware barriers required. However,
16582 the compiler must also be prohibited from moving loads and stores across
16583 the builtins in a way that would violate their semantics. This has been
16584 accomplished by adding memory barriers to the associated HTM instructions
16585 (which is a conservative approach to provide acquire and release semantics).
16586 Earlier versions of the compiler did not treat the HTM instructions as
16587 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16588 be used to determine whether the current compiler treats HTM instructions
16589 as memory barriers or not. This allows the user to explicitly add memory
16590 barriers to their code when using an older version of the compiler.
16591
16592 The following set of built-in functions are available to gain access
16593 to the HTM specific special purpose registers.
16594
16595 @smallexample
16596 unsigned long __builtin_get_texasr (void)
16597 unsigned long __builtin_get_texasru (void)
16598 unsigned long __builtin_get_tfhar (void)
16599 unsigned long __builtin_get_tfiar (void)
16600
16601 void __builtin_set_texasr (unsigned long);
16602 void __builtin_set_texasru (unsigned long);
16603 void __builtin_set_tfhar (unsigned long);
16604 void __builtin_set_tfiar (unsigned long);
16605 @end smallexample
16606
16607 Example usage of these low level built-in functions may look like:
16608
16609 @smallexample
16610 #include <htmintrin.h>
16611
16612 int num_retries = 10;
16613
16614 while (1)
16615 @{
16616 if (__builtin_tbegin (0))
16617 @{
16618 /* Transaction State Initiated. */
16619 if (is_locked (lock))
16620 __builtin_tabort (0);
16621 ... transaction code...
16622 __builtin_tend (0);
16623 break;
16624 @}
16625 else
16626 @{
16627 /* Transaction State Failed. Use locks if the transaction
16628 failure is "persistent" or we've tried too many times. */
16629 if (num_retries-- <= 0
16630 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16631 @{
16632 acquire_lock (lock);
16633 ... non transactional fallback path...
16634 release_lock (lock);
16635 break;
16636 @}
16637 @}
16638 @}
16639 @end smallexample
16640
16641 One final built-in function has been added that returns the value of
16642 the 2-bit Transaction State field of the Machine Status Register (MSR)
16643 as stored in @code{CR0}.
16644
16645 @smallexample
16646 unsigned long __builtin_ttest (void)
16647 @end smallexample
16648
16649 This built-in can be used to determine the current transaction state
16650 using the following code example:
16651
16652 @smallexample
16653 #include <htmintrin.h>
16654
16655 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16656
16657 if (tx_state == _HTM_TRANSACTIONAL)
16658 @{
16659 /* Code to use in transactional state. */
16660 @}
16661 else if (tx_state == _HTM_NONTRANSACTIONAL)
16662 @{
16663 /* Code to use in non-transactional state. */
16664 @}
16665 else if (tx_state == _HTM_SUSPENDED)
16666 @{
16667 /* Code to use in transaction suspended state. */
16668 @}
16669 @end smallexample
16670
16671 @subsubsection PowerPC HTM High Level Inline Functions
16672
16673 The following high level HTM interface is made available by including
16674 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16675 where CPU is `power8' or later. This interface is common between PowerPC
16676 and S/390, allowing users to write one HTM source implementation that
16677 can be compiled and executed on either system.
16678
16679 @smallexample
16680 long __TM_simple_begin (void)
16681 long __TM_begin (void* const TM_buff)
16682 long __TM_end (void)
16683 void __TM_abort (void)
16684 void __TM_named_abort (unsigned char const code)
16685 void __TM_resume (void)
16686 void __TM_suspend (void)
16687
16688 long __TM_is_user_abort (void* const TM_buff)
16689 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16690 long __TM_is_illegal (void* const TM_buff)
16691 long __TM_is_footprint_exceeded (void* const TM_buff)
16692 long __TM_nesting_depth (void* const TM_buff)
16693 long __TM_is_nested_too_deep(void* const TM_buff)
16694 long __TM_is_conflict(void* const TM_buff)
16695 long __TM_is_failure_persistent(void* const TM_buff)
16696 long __TM_failure_address(void* const TM_buff)
16697 long long __TM_failure_code(void* const TM_buff)
16698 @end smallexample
16699
16700 Using these common set of HTM inline functions, we can create
16701 a more portable version of the HTM example in the previous
16702 section that will work on either PowerPC or S/390:
16703
16704 @smallexample
16705 #include <htmxlintrin.h>
16706
16707 int num_retries = 10;
16708 TM_buff_type TM_buff;
16709
16710 while (1)
16711 @{
16712 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16713 @{
16714 /* Transaction State Initiated. */
16715 if (is_locked (lock))
16716 __TM_abort ();
16717 ... transaction code...
16718 __TM_end ();
16719 break;
16720 @}
16721 else
16722 @{
16723 /* Transaction State Failed. Use locks if the transaction
16724 failure is "persistent" or we've tried too many times. */
16725 if (num_retries-- <= 0
16726 || __TM_is_failure_persistent (TM_buff))
16727 @{
16728 acquire_lock (lock);
16729 ... non transactional fallback path...
16730 release_lock (lock);
16731 break;
16732 @}
16733 @}
16734 @}
16735 @end smallexample
16736
16737 @node RX Built-in Functions
16738 @subsection RX Built-in Functions
16739 GCC supports some of the RX instructions which cannot be expressed in
16740 the C programming language via the use of built-in functions. The
16741 following functions are supported:
16742
16743 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16744 Generates the @code{brk} machine instruction.
16745 @end deftypefn
16746
16747 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16748 Generates the @code{clrpsw} machine instruction to clear the specified
16749 bit in the processor status word.
16750 @end deftypefn
16751
16752 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16753 Generates the @code{int} machine instruction to generate an interrupt
16754 with the specified value.
16755 @end deftypefn
16756
16757 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16758 Generates the @code{machi} machine instruction to add the result of
16759 multiplying the top 16 bits of the two arguments into the
16760 accumulator.
16761 @end deftypefn
16762
16763 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16764 Generates the @code{maclo} machine instruction to add the result of
16765 multiplying the bottom 16 bits of the two arguments into the
16766 accumulator.
16767 @end deftypefn
16768
16769 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16770 Generates the @code{mulhi} machine instruction to place the result of
16771 multiplying the top 16 bits of the two arguments into the
16772 accumulator.
16773 @end deftypefn
16774
16775 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16776 Generates the @code{mullo} machine instruction to place the result of
16777 multiplying the bottom 16 bits of the two arguments into the
16778 accumulator.
16779 @end deftypefn
16780
16781 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16782 Generates the @code{mvfachi} machine instruction to read the top
16783 32 bits of the accumulator.
16784 @end deftypefn
16785
16786 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16787 Generates the @code{mvfacmi} machine instruction to read the middle
16788 32 bits of the accumulator.
16789 @end deftypefn
16790
16791 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16792 Generates the @code{mvfc} machine instruction which reads the control
16793 register specified in its argument and returns its value.
16794 @end deftypefn
16795
16796 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16797 Generates the @code{mvtachi} machine instruction to set the top
16798 32 bits of the accumulator.
16799 @end deftypefn
16800
16801 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16802 Generates the @code{mvtaclo} machine instruction to set the bottom
16803 32 bits of the accumulator.
16804 @end deftypefn
16805
16806 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16807 Generates the @code{mvtc} machine instruction which sets control
16808 register number @code{reg} to @code{val}.
16809 @end deftypefn
16810
16811 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16812 Generates the @code{mvtipl} machine instruction set the interrupt
16813 priority level.
16814 @end deftypefn
16815
16816 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16817 Generates the @code{racw} machine instruction to round the accumulator
16818 according to the specified mode.
16819 @end deftypefn
16820
16821 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16822 Generates the @code{revw} machine instruction which swaps the bytes in
16823 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16824 and also bits 16--23 occupy bits 24--31 and vice versa.
16825 @end deftypefn
16826
16827 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16828 Generates the @code{rmpa} machine instruction which initiates a
16829 repeated multiply and accumulate sequence.
16830 @end deftypefn
16831
16832 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16833 Generates the @code{round} machine instruction which returns the
16834 floating-point argument rounded according to the current rounding mode
16835 set in the floating-point status word register.
16836 @end deftypefn
16837
16838 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16839 Generates the @code{sat} machine instruction which returns the
16840 saturated value of the argument.
16841 @end deftypefn
16842
16843 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16844 Generates the @code{setpsw} machine instruction to set the specified
16845 bit in the processor status word.
16846 @end deftypefn
16847
16848 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16849 Generates the @code{wait} machine instruction.
16850 @end deftypefn
16851
16852 @node S/390 System z Built-in Functions
16853 @subsection S/390 System z Built-in Functions
16854 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16855 Generates the @code{tbegin} machine instruction starting a
16856 non-constrained hardware transaction. If the parameter is non-NULL the
16857 memory area is used to store the transaction diagnostic buffer and
16858 will be passed as first operand to @code{tbegin}. This buffer can be
16859 defined using the @code{struct __htm_tdb} C struct defined in
16860 @code{htmintrin.h} and must reside on a double-word boundary. The
16861 second tbegin operand is set to @code{0xff0c}. This enables
16862 save/restore of all GPRs and disables aborts for FPR and AR
16863 manipulations inside the transaction body. The condition code set by
16864 the tbegin instruction is returned as integer value. The tbegin
16865 instruction by definition overwrites the content of all FPRs. The
16866 compiler will generate code which saves and restores the FPRs. For
16867 soft-float code it is recommended to used the @code{*_nofloat}
16868 variant. In order to prevent a TDB from being written it is required
16869 to pass a constant zero value as parameter. Passing a zero value
16870 through a variable is not sufficient. Although modifications of
16871 access registers inside the transaction will not trigger an
16872 transaction abort it is not supported to actually modify them. Access
16873 registers do not get saved when entering a transaction. They will have
16874 undefined state when reaching the abort code.
16875 @end deftypefn
16876
16877 Macros for the possible return codes of tbegin are defined in the
16878 @code{htmintrin.h} header file:
16879
16880 @table @code
16881 @item _HTM_TBEGIN_STARTED
16882 @code{tbegin} has been executed as part of normal processing. The
16883 transaction body is supposed to be executed.
16884 @item _HTM_TBEGIN_INDETERMINATE
16885 The transaction was aborted due to an indeterminate condition which
16886 might be persistent.
16887 @item _HTM_TBEGIN_TRANSIENT
16888 The transaction aborted due to a transient failure. The transaction
16889 should be re-executed in that case.
16890 @item _HTM_TBEGIN_PERSISTENT
16891 The transaction aborted due to a persistent failure. Re-execution
16892 under same circumstances will not be productive.
16893 @end table
16894
16895 @defmac _HTM_FIRST_USER_ABORT_CODE
16896 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16897 specifies the first abort code which can be used for
16898 @code{__builtin_tabort}. Values below this threshold are reserved for
16899 machine use.
16900 @end defmac
16901
16902 @deftp {Data type} {struct __htm_tdb}
16903 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16904 the structure of the transaction diagnostic block as specified in the
16905 Principles of Operation manual chapter 5-91.
16906 @end deftp
16907
16908 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16909 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16910 Using this variant in code making use of FPRs will leave the FPRs in
16911 undefined state when entering the transaction abort handler code.
16912 @end deftypefn
16913
16914 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16915 In addition to @code{__builtin_tbegin} a loop for transient failures
16916 is generated. If tbegin returns a condition code of 2 the transaction
16917 will be retried as often as specified in the second argument. The
16918 perform processor assist instruction is used to tell the CPU about the
16919 number of fails so far.
16920 @end deftypefn
16921
16922 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16923 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16924 restores. Using this variant in code making use of FPRs will leave
16925 the FPRs in undefined state when entering the transaction abort
16926 handler code.
16927 @end deftypefn
16928
16929 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16930 Generates the @code{tbeginc} machine instruction starting a constrained
16931 hardware transaction. The second operand is set to @code{0xff08}.
16932 @end deftypefn
16933
16934 @deftypefn {Built-in Function} int __builtin_tend (void)
16935 Generates the @code{tend} machine instruction finishing a transaction
16936 and making the changes visible to other threads. The condition code
16937 generated by tend is returned as integer value.
16938 @end deftypefn
16939
16940 @deftypefn {Built-in Function} void __builtin_tabort (int)
16941 Generates the @code{tabort} machine instruction with the specified
16942 abort code. Abort codes from 0 through 255 are reserved and will
16943 result in an error message.
16944 @end deftypefn
16945
16946 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16947 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16948 integer parameter is loaded into rX and a value of zero is loaded into
16949 rY. The integer parameter specifies the number of times the
16950 transaction repeatedly aborted.
16951 @end deftypefn
16952
16953 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16954 Generates the @code{etnd} machine instruction. The current nesting
16955 depth is returned as integer value. For a nesting depth of 0 the code
16956 is not executed as part of an transaction.
16957 @end deftypefn
16958
16959 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16960
16961 Generates the @code{ntstg} machine instruction. The second argument
16962 is written to the first arguments location. The store operation will
16963 not be rolled-back in case of an transaction abort.
16964 @end deftypefn
16965
16966 @node SH Built-in Functions
16967 @subsection SH Built-in Functions
16968 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16969 families of processors:
16970
16971 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16972 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16973 used by system code that manages threads and execution contexts. The compiler
16974 normally does not generate code that modifies the contents of @samp{GBR} and
16975 thus the value is preserved across function calls. Changing the @samp{GBR}
16976 value in user code must be done with caution, since the compiler might use
16977 @samp{GBR} in order to access thread local variables.
16978
16979 @end deftypefn
16980
16981 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16982 Returns the value that is currently set in the @samp{GBR} register.
16983 Memory loads and stores that use the thread pointer as a base address are
16984 turned into @samp{GBR} based displacement loads and stores, if possible.
16985 For example:
16986 @smallexample
16987 struct my_tcb
16988 @{
16989 int a, b, c, d, e;
16990 @};
16991
16992 int get_tcb_value (void)
16993 @{
16994 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16995 return ((my_tcb*)__builtin_thread_pointer ())->c;
16996 @}
16997
16998 @end smallexample
16999 @end deftypefn
17000
17001 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
17002 Returns the value that is currently set in the @samp{FPSCR} register.
17003 @end deftypefn
17004
17005 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
17006 Sets the @samp{FPSCR} register to the specified value @var{val}, while
17007 preserving the current values of the FR, SZ and PR bits.
17008 @end deftypefn
17009
17010 @node SPARC VIS Built-in Functions
17011 @subsection SPARC VIS Built-in Functions
17012
17013 GCC supports SIMD operations on the SPARC using both the generic vector
17014 extensions (@pxref{Vector Extensions}) as well as built-in functions for
17015 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
17016 switch, the VIS extension is exposed as the following built-in functions:
17017
17018 @smallexample
17019 typedef int v1si __attribute__ ((vector_size (4)));
17020 typedef int v2si __attribute__ ((vector_size (8)));
17021 typedef short v4hi __attribute__ ((vector_size (8)));
17022 typedef short v2hi __attribute__ ((vector_size (4)));
17023 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
17024 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
17025
17026 void __builtin_vis_write_gsr (int64_t);
17027 int64_t __builtin_vis_read_gsr (void);
17028
17029 void * __builtin_vis_alignaddr (void *, long);
17030 void * __builtin_vis_alignaddrl (void *, long);
17031 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
17032 v2si __builtin_vis_faligndatav2si (v2si, v2si);
17033 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
17034 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
17035
17036 v4hi __builtin_vis_fexpand (v4qi);
17037
17038 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
17039 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
17040 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
17041 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
17042 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
17043 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
17044 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
17045
17046 v4qi __builtin_vis_fpack16 (v4hi);
17047 v8qi __builtin_vis_fpack32 (v2si, v8qi);
17048 v2hi __builtin_vis_fpackfix (v2si);
17049 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
17050
17051 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
17052
17053 long __builtin_vis_edge8 (void *, void *);
17054 long __builtin_vis_edge8l (void *, void *);
17055 long __builtin_vis_edge16 (void *, void *);
17056 long __builtin_vis_edge16l (void *, void *);
17057 long __builtin_vis_edge32 (void *, void *);
17058 long __builtin_vis_edge32l (void *, void *);
17059
17060 long __builtin_vis_fcmple16 (v4hi, v4hi);
17061 long __builtin_vis_fcmple32 (v2si, v2si);
17062 long __builtin_vis_fcmpne16 (v4hi, v4hi);
17063 long __builtin_vis_fcmpne32 (v2si, v2si);
17064 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
17065 long __builtin_vis_fcmpgt32 (v2si, v2si);
17066 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
17067 long __builtin_vis_fcmpeq32 (v2si, v2si);
17068
17069 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
17070 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
17071 v2si __builtin_vis_fpadd32 (v2si, v2si);
17072 v1si __builtin_vis_fpadd32s (v1si, v1si);
17073 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17074 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17075 v2si __builtin_vis_fpsub32 (v2si, v2si);
17076 v1si __builtin_vis_fpsub32s (v1si, v1si);
17077
17078 long __builtin_vis_array8 (long, long);
17079 long __builtin_vis_array16 (long, long);
17080 long __builtin_vis_array32 (long, long);
17081 @end smallexample
17082
17083 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17084 functions also become available:
17085
17086 @smallexample
17087 long __builtin_vis_bmask (long, long);
17088 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17089 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17090 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17091 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17092
17093 long __builtin_vis_edge8n (void *, void *);
17094 long __builtin_vis_edge8ln (void *, void *);
17095 long __builtin_vis_edge16n (void *, void *);
17096 long __builtin_vis_edge16ln (void *, void *);
17097 long __builtin_vis_edge32n (void *, void *);
17098 long __builtin_vis_edge32ln (void *, void *);
17099 @end smallexample
17100
17101 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17102 functions also become available:
17103
17104 @smallexample
17105 void __builtin_vis_cmask8 (long);
17106 void __builtin_vis_cmask16 (long);
17107 void __builtin_vis_cmask32 (long);
17108
17109 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17110
17111 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17112 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17113 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17114 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17115 v2si __builtin_vis_fsll16 (v2si, v2si);
17116 v2si __builtin_vis_fslas16 (v2si, v2si);
17117 v2si __builtin_vis_fsrl16 (v2si, v2si);
17118 v2si __builtin_vis_fsra16 (v2si, v2si);
17119
17120 long __builtin_vis_pdistn (v8qi, v8qi);
17121
17122 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17123
17124 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17125 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17126
17127 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17128 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17129 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17130 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17131 v2si __builtin_vis_fpadds32 (v2si, v2si);
17132 v1si __builtin_vis_fpadds32s (v1si, v1si);
17133 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17134 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17135
17136 long __builtin_vis_fucmple8 (v8qi, v8qi);
17137 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17138 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17139 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17140
17141 float __builtin_vis_fhadds (float, float);
17142 double __builtin_vis_fhaddd (double, double);
17143 float __builtin_vis_fhsubs (float, float);
17144 double __builtin_vis_fhsubd (double, double);
17145 float __builtin_vis_fnhadds (float, float);
17146 double __builtin_vis_fnhaddd (double, double);
17147
17148 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17149 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17150 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17151 @end smallexample
17152
17153 @node SPU Built-in Functions
17154 @subsection SPU Built-in Functions
17155
17156 GCC provides extensions for the SPU processor as described in the
17157 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17158 found at @uref{http://cell.scei.co.jp/} or
17159 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
17160 implementation differs in several ways.
17161
17162 @itemize @bullet
17163
17164 @item
17165 The optional extension of specifying vector constants in parentheses is
17166 not supported.
17167
17168 @item
17169 A vector initializer requires no cast if the vector constant is of the
17170 same type as the variable it is initializing.
17171
17172 @item
17173 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17174 vector type is the default signedness of the base type. The default
17175 varies depending on the operating system, so a portable program should
17176 always specify the signedness.
17177
17178 @item
17179 By default, the keyword @code{__vector} is added. The macro
17180 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17181 undefined.
17182
17183 @item
17184 GCC allows using a @code{typedef} name as the type specifier for a
17185 vector type.
17186
17187 @item
17188 For C, overloaded functions are implemented with macros so the following
17189 does not work:
17190
17191 @smallexample
17192 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17193 @end smallexample
17194
17195 @noindent
17196 Since @code{spu_add} is a macro, the vector constant in the example
17197 is treated as four separate arguments. Wrap the entire argument in
17198 parentheses for this to work.
17199
17200 @item
17201 The extended version of @code{__builtin_expect} is not supported.
17202
17203 @end itemize
17204
17205 @emph{Note:} Only the interface described in the aforementioned
17206 specification is supported. Internally, GCC uses built-in functions to
17207 implement the required functionality, but these are not supported and
17208 are subject to change without notice.
17209
17210 @node TI C6X Built-in Functions
17211 @subsection TI C6X Built-in Functions
17212
17213 GCC provides intrinsics to access certain instructions of the TI C6X
17214 processors. These intrinsics, listed below, are available after
17215 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
17216 to C6X instructions.
17217
17218 @smallexample
17219
17220 int _sadd (int, int)
17221 int _ssub (int, int)
17222 int _sadd2 (int, int)
17223 int _ssub2 (int, int)
17224 long long _mpy2 (int, int)
17225 long long _smpy2 (int, int)
17226 int _add4 (int, int)
17227 int _sub4 (int, int)
17228 int _saddu4 (int, int)
17229
17230 int _smpy (int, int)
17231 int _smpyh (int, int)
17232 int _smpyhl (int, int)
17233 int _smpylh (int, int)
17234
17235 int _sshl (int, int)
17236 int _subc (int, int)
17237
17238 int _avg2 (int, int)
17239 int _avgu4 (int, int)
17240
17241 int _clrr (int, int)
17242 int _extr (int, int)
17243 int _extru (int, int)
17244 int _abs (int)
17245 int _abs2 (int)
17246
17247 @end smallexample
17248
17249 @node TILE-Gx Built-in Functions
17250 @subsection TILE-Gx Built-in Functions
17251
17252 GCC provides intrinsics to access every instruction of the TILE-Gx
17253 processor. The intrinsics are of the form:
17254
17255 @smallexample
17256
17257 unsigned long long __insn_@var{op} (...)
17258
17259 @end smallexample
17260
17261 Where @var{op} is the name of the instruction. Refer to the ISA manual
17262 for the complete list of instructions.
17263
17264 GCC also provides intrinsics to directly access the network registers.
17265 The intrinsics are:
17266
17267 @smallexample
17268
17269 unsigned long long __tile_idn0_receive (void)
17270 unsigned long long __tile_idn1_receive (void)
17271 unsigned long long __tile_udn0_receive (void)
17272 unsigned long long __tile_udn1_receive (void)
17273 unsigned long long __tile_udn2_receive (void)
17274 unsigned long long __tile_udn3_receive (void)
17275 void __tile_idn_send (unsigned long long)
17276 void __tile_udn_send (unsigned long long)
17277
17278 @end smallexample
17279
17280 The intrinsic @code{void __tile_network_barrier (void)} is used to
17281 guarantee that no network operations before it are reordered with
17282 those after it.
17283
17284 @node TILEPro Built-in Functions
17285 @subsection TILEPro Built-in Functions
17286
17287 GCC provides intrinsics to access every instruction of the TILEPro
17288 processor. The intrinsics are of the form:
17289
17290 @smallexample
17291
17292 unsigned __insn_@var{op} (...)
17293
17294 @end smallexample
17295
17296 @noindent
17297 where @var{op} is the name of the instruction. Refer to the ISA manual
17298 for the complete list of instructions.
17299
17300 GCC also provides intrinsics to directly access the network registers.
17301 The intrinsics are:
17302
17303 @smallexample
17304
17305 unsigned __tile_idn0_receive (void)
17306 unsigned __tile_idn1_receive (void)
17307 unsigned __tile_sn_receive (void)
17308 unsigned __tile_udn0_receive (void)
17309 unsigned __tile_udn1_receive (void)
17310 unsigned __tile_udn2_receive (void)
17311 unsigned __tile_udn3_receive (void)
17312 void __tile_idn_send (unsigned)
17313 void __tile_sn_send (unsigned)
17314 void __tile_udn_send (unsigned)
17315
17316 @end smallexample
17317
17318 The intrinsic @code{void __tile_network_barrier (void)} is used to
17319 guarantee that no network operations before it are reordered with
17320 those after it.
17321
17322 @node x86 Built-in Functions
17323 @subsection x86 Built-in Functions
17324
17325 These built-in functions are available for the x86-32 and x86-64 family
17326 of computers, depending on the command-line switches used.
17327
17328 If you specify command-line switches such as @option{-msse},
17329 the compiler could use the extended instruction sets even if the built-ins
17330 are not used explicitly in the program. For this reason, applications
17331 that perform run-time CPU detection must compile separate files for each
17332 supported architecture, using the appropriate flags. In particular,
17333 the file containing the CPU detection code should be compiled without
17334 these options.
17335
17336 The following machine modes are available for use with MMX built-in functions
17337 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
17338 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
17339 vector of eight 8-bit integers. Some of the built-in functions operate on
17340 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
17341
17342 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
17343 of two 32-bit floating-point values.
17344
17345 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
17346 floating-point values. Some instructions use a vector of four 32-bit
17347 integers, these use @code{V4SI}. Finally, some instructions operate on an
17348 entire vector register, interpreting it as a 128-bit integer, these use mode
17349 @code{TI}.
17350
17351 In 64-bit mode, the x86-64 family of processors uses additional built-in
17352 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
17353 floating point and @code{TC} 128-bit complex floating-point values.
17354
17355 The following floating-point built-in functions are available in 64-bit
17356 mode. All of them implement the function that is part of the name.
17357
17358 @smallexample
17359 __float128 __builtin_fabsq (__float128)
17360 __float128 __builtin_copysignq (__float128, __float128)
17361 @end smallexample
17362
17363 The following built-in function is always available.
17364
17365 @table @code
17366 @item void __builtin_ia32_pause (void)
17367 Generates the @code{pause} machine instruction with a compiler memory
17368 barrier.
17369 @end table
17370
17371 The following floating-point built-in functions are made available in the
17372 64-bit mode.
17373
17374 @table @code
17375 @item __float128 __builtin_infq (void)
17376 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
17377 @findex __builtin_infq
17378
17379 @item __float128 __builtin_huge_valq (void)
17380 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
17381 @findex __builtin_huge_valq
17382 @end table
17383
17384 The following built-in functions are always available and can be used to
17385 check the target platform type.
17386
17387 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
17388 This function runs the CPU detection code to check the type of CPU and the
17389 features supported. This built-in function needs to be invoked along with the built-in functions
17390 to check CPU type and features, @code{__builtin_cpu_is} and
17391 @code{__builtin_cpu_supports}, only when used in a function that is
17392 executed before any constructors are called. The CPU detection code is
17393 automatically executed in a very high priority constructor.
17394
17395 For example, this function has to be used in @code{ifunc} resolvers that
17396 check for CPU type using the built-in functions @code{__builtin_cpu_is}
17397 and @code{__builtin_cpu_supports}, or in constructors on targets that
17398 don't support constructor priority.
17399 @smallexample
17400
17401 static void (*resolve_memcpy (void)) (void)
17402 @{
17403 // ifunc resolvers fire before constructors, explicitly call the init
17404 // function.
17405 __builtin_cpu_init ();
17406 if (__builtin_cpu_supports ("ssse3"))
17407 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
17408 else
17409 return default_memcpy;
17410 @}
17411
17412 void *memcpy (void *, const void *, size_t)
17413 __attribute__ ((ifunc ("resolve_memcpy")));
17414 @end smallexample
17415
17416 @end deftypefn
17417
17418 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
17419 This function returns a positive integer if the run-time CPU
17420 is of type @var{cpuname}
17421 and returns @code{0} otherwise. The following CPU names can be detected:
17422
17423 @table @samp
17424 @item intel
17425 Intel CPU.
17426
17427 @item atom
17428 Intel Atom CPU.
17429
17430 @item core2
17431 Intel Core 2 CPU.
17432
17433 @item corei7
17434 Intel Core i7 CPU.
17435
17436 @item nehalem
17437 Intel Core i7 Nehalem CPU.
17438
17439 @item westmere
17440 Intel Core i7 Westmere CPU.
17441
17442 @item sandybridge
17443 Intel Core i7 Sandy Bridge CPU.
17444
17445 @item amd
17446 AMD CPU.
17447
17448 @item amdfam10h
17449 AMD Family 10h CPU.
17450
17451 @item barcelona
17452 AMD Family 10h Barcelona CPU.
17453
17454 @item shanghai
17455 AMD Family 10h Shanghai CPU.
17456
17457 @item istanbul
17458 AMD Family 10h Istanbul CPU.
17459
17460 @item btver1
17461 AMD Family 14h CPU.
17462
17463 @item amdfam15h
17464 AMD Family 15h CPU.
17465
17466 @item bdver1
17467 AMD Family 15h Bulldozer version 1.
17468
17469 @item bdver2
17470 AMD Family 15h Bulldozer version 2.
17471
17472 @item bdver3
17473 AMD Family 15h Bulldozer version 3.
17474
17475 @item bdver4
17476 AMD Family 15h Bulldozer version 4.
17477
17478 @item btver2
17479 AMD Family 16h CPU.
17480
17481 @item znver1
17482 AMD Family 17h CPU.
17483 @end table
17484
17485 Here is an example:
17486 @smallexample
17487 if (__builtin_cpu_is ("corei7"))
17488 @{
17489 do_corei7 (); // Core i7 specific implementation.
17490 @}
17491 else
17492 @{
17493 do_generic (); // Generic implementation.
17494 @}
17495 @end smallexample
17496 @end deftypefn
17497
17498 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17499 This function returns a positive integer if the run-time CPU
17500 supports @var{feature}
17501 and returns @code{0} otherwise. The following features can be detected:
17502
17503 @table @samp
17504 @item cmov
17505 CMOV instruction.
17506 @item mmx
17507 MMX instructions.
17508 @item popcnt
17509 POPCNT instruction.
17510 @item sse
17511 SSE instructions.
17512 @item sse2
17513 SSE2 instructions.
17514 @item sse3
17515 SSE3 instructions.
17516 @item ssse3
17517 SSSE3 instructions.
17518 @item sse4.1
17519 SSE4.1 instructions.
17520 @item sse4.2
17521 SSE4.2 instructions.
17522 @item avx
17523 AVX instructions.
17524 @item avx2
17525 AVX2 instructions.
17526 @item avx512f
17527 AVX512F instructions.
17528 @end table
17529
17530 Here is an example:
17531 @smallexample
17532 if (__builtin_cpu_supports ("popcnt"))
17533 @{
17534 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17535 @}
17536 else
17537 @{
17538 count = generic_countbits (n); //generic implementation.
17539 @}
17540 @end smallexample
17541 @end deftypefn
17542
17543
17544 The following built-in functions are made available by @option{-mmmx}.
17545 All of them generate the machine instruction that is part of the name.
17546
17547 @smallexample
17548 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17549 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17550 v2si __builtin_ia32_paddd (v2si, v2si)
17551 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17552 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17553 v2si __builtin_ia32_psubd (v2si, v2si)
17554 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17555 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17556 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17557 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17558 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17559 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17560 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17561 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17562 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17563 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17564 di __builtin_ia32_pand (di, di)
17565 di __builtin_ia32_pandn (di,di)
17566 di __builtin_ia32_por (di, di)
17567 di __builtin_ia32_pxor (di, di)
17568 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17569 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17570 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17571 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17572 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17573 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17574 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17575 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17576 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17577 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17578 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17579 v2si __builtin_ia32_punpckldq (v2si, v2si)
17580 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17581 v4hi __builtin_ia32_packssdw (v2si, v2si)
17582 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17583
17584 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17585 v2si __builtin_ia32_pslld (v2si, v2si)
17586 v1di __builtin_ia32_psllq (v1di, v1di)
17587 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17588 v2si __builtin_ia32_psrld (v2si, v2si)
17589 v1di __builtin_ia32_psrlq (v1di, v1di)
17590 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17591 v2si __builtin_ia32_psrad (v2si, v2si)
17592 v4hi __builtin_ia32_psllwi (v4hi, int)
17593 v2si __builtin_ia32_pslldi (v2si, int)
17594 v1di __builtin_ia32_psllqi (v1di, int)
17595 v4hi __builtin_ia32_psrlwi (v4hi, int)
17596 v2si __builtin_ia32_psrldi (v2si, int)
17597 v1di __builtin_ia32_psrlqi (v1di, int)
17598 v4hi __builtin_ia32_psrawi (v4hi, int)
17599 v2si __builtin_ia32_psradi (v2si, int)
17600
17601 @end smallexample
17602
17603 The following built-in functions are made available either with
17604 @option{-msse}, or with a combination of @option{-m3dnow} and
17605 @option{-march=athlon}. All of them generate the machine
17606 instruction that is part of the name.
17607
17608 @smallexample
17609 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17610 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17611 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17612 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17613 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17614 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17615 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17616 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17617 int __builtin_ia32_pmovmskb (v8qi)
17618 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17619 void __builtin_ia32_movntq (di *, di)
17620 void __builtin_ia32_sfence (void)
17621 @end smallexample
17622
17623 The following built-in functions are available when @option{-msse} is used.
17624 All of them generate the machine instruction that is part of the name.
17625
17626 @smallexample
17627 int __builtin_ia32_comieq (v4sf, v4sf)
17628 int __builtin_ia32_comineq (v4sf, v4sf)
17629 int __builtin_ia32_comilt (v4sf, v4sf)
17630 int __builtin_ia32_comile (v4sf, v4sf)
17631 int __builtin_ia32_comigt (v4sf, v4sf)
17632 int __builtin_ia32_comige (v4sf, v4sf)
17633 int __builtin_ia32_ucomieq (v4sf, v4sf)
17634 int __builtin_ia32_ucomineq (v4sf, v4sf)
17635 int __builtin_ia32_ucomilt (v4sf, v4sf)
17636 int __builtin_ia32_ucomile (v4sf, v4sf)
17637 int __builtin_ia32_ucomigt (v4sf, v4sf)
17638 int __builtin_ia32_ucomige (v4sf, v4sf)
17639 v4sf __builtin_ia32_addps (v4sf, v4sf)
17640 v4sf __builtin_ia32_subps (v4sf, v4sf)
17641 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17642 v4sf __builtin_ia32_divps (v4sf, v4sf)
17643 v4sf __builtin_ia32_addss (v4sf, v4sf)
17644 v4sf __builtin_ia32_subss (v4sf, v4sf)
17645 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17646 v4sf __builtin_ia32_divss (v4sf, v4sf)
17647 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17648 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17649 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17650 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17651 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17652 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17653 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17654 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17655 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17656 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17657 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17658 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17659 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17660 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17661 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17662 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17663 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17664 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17665 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17666 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17667 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17668 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17669 v4sf __builtin_ia32_minps (v4sf, v4sf)
17670 v4sf __builtin_ia32_minss (v4sf, v4sf)
17671 v4sf __builtin_ia32_andps (v4sf, v4sf)
17672 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17673 v4sf __builtin_ia32_orps (v4sf, v4sf)
17674 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17675 v4sf __builtin_ia32_movss (v4sf, v4sf)
17676 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17677 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17678 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17679 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17680 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17681 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17682 v2si __builtin_ia32_cvtps2pi (v4sf)
17683 int __builtin_ia32_cvtss2si (v4sf)
17684 v2si __builtin_ia32_cvttps2pi (v4sf)
17685 int __builtin_ia32_cvttss2si (v4sf)
17686 v4sf __builtin_ia32_rcpps (v4sf)
17687 v4sf __builtin_ia32_rsqrtps (v4sf)
17688 v4sf __builtin_ia32_sqrtps (v4sf)
17689 v4sf __builtin_ia32_rcpss (v4sf)
17690 v4sf __builtin_ia32_rsqrtss (v4sf)
17691 v4sf __builtin_ia32_sqrtss (v4sf)
17692 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17693 void __builtin_ia32_movntps (float *, v4sf)
17694 int __builtin_ia32_movmskps (v4sf)
17695 @end smallexample
17696
17697 The following built-in functions are available when @option{-msse} is used.
17698
17699 @table @code
17700 @item v4sf __builtin_ia32_loadups (float *)
17701 Generates the @code{movups} machine instruction as a load from memory.
17702 @item void __builtin_ia32_storeups (float *, v4sf)
17703 Generates the @code{movups} machine instruction as a store to memory.
17704 @item v4sf __builtin_ia32_loadss (float *)
17705 Generates the @code{movss} machine instruction as a load from memory.
17706 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17707 Generates the @code{movhps} machine instruction as a load from memory.
17708 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17709 Generates the @code{movlps} machine instruction as a load from memory
17710 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17711 Generates the @code{movhps} machine instruction as a store to memory.
17712 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17713 Generates the @code{movlps} machine instruction as a store to memory.
17714 @end table
17715
17716 The following built-in functions are available when @option{-msse2} is used.
17717 All of them generate the machine instruction that is part of the name.
17718
17719 @smallexample
17720 int __builtin_ia32_comisdeq (v2df, v2df)
17721 int __builtin_ia32_comisdlt (v2df, v2df)
17722 int __builtin_ia32_comisdle (v2df, v2df)
17723 int __builtin_ia32_comisdgt (v2df, v2df)
17724 int __builtin_ia32_comisdge (v2df, v2df)
17725 int __builtin_ia32_comisdneq (v2df, v2df)
17726 int __builtin_ia32_ucomisdeq (v2df, v2df)
17727 int __builtin_ia32_ucomisdlt (v2df, v2df)
17728 int __builtin_ia32_ucomisdle (v2df, v2df)
17729 int __builtin_ia32_ucomisdgt (v2df, v2df)
17730 int __builtin_ia32_ucomisdge (v2df, v2df)
17731 int __builtin_ia32_ucomisdneq (v2df, v2df)
17732 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17733 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17734 v2df __builtin_ia32_cmplepd (v2df, v2df)
17735 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17736 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17737 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17738 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17739 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17740 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17741 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17742 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17743 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17744 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17745 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17746 v2df __builtin_ia32_cmplesd (v2df, v2df)
17747 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17748 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17749 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17750 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17751 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17752 v2di __builtin_ia32_paddq (v2di, v2di)
17753 v2di __builtin_ia32_psubq (v2di, v2di)
17754 v2df __builtin_ia32_addpd (v2df, v2df)
17755 v2df __builtin_ia32_subpd (v2df, v2df)
17756 v2df __builtin_ia32_mulpd (v2df, v2df)
17757 v2df __builtin_ia32_divpd (v2df, v2df)
17758 v2df __builtin_ia32_addsd (v2df, v2df)
17759 v2df __builtin_ia32_subsd (v2df, v2df)
17760 v2df __builtin_ia32_mulsd (v2df, v2df)
17761 v2df __builtin_ia32_divsd (v2df, v2df)
17762 v2df __builtin_ia32_minpd (v2df, v2df)
17763 v2df __builtin_ia32_maxpd (v2df, v2df)
17764 v2df __builtin_ia32_minsd (v2df, v2df)
17765 v2df __builtin_ia32_maxsd (v2df, v2df)
17766 v2df __builtin_ia32_andpd (v2df, v2df)
17767 v2df __builtin_ia32_andnpd (v2df, v2df)
17768 v2df __builtin_ia32_orpd (v2df, v2df)
17769 v2df __builtin_ia32_xorpd (v2df, v2df)
17770 v2df __builtin_ia32_movsd (v2df, v2df)
17771 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17772 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17773 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17774 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17775 v4si __builtin_ia32_paddd128 (v4si, v4si)
17776 v2di __builtin_ia32_paddq128 (v2di, v2di)
17777 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17778 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17779 v4si __builtin_ia32_psubd128 (v4si, v4si)
17780 v2di __builtin_ia32_psubq128 (v2di, v2di)
17781 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17782 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17783 v2di __builtin_ia32_pand128 (v2di, v2di)
17784 v2di __builtin_ia32_pandn128 (v2di, v2di)
17785 v2di __builtin_ia32_por128 (v2di, v2di)
17786 v2di __builtin_ia32_pxor128 (v2di, v2di)
17787 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17788 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17789 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17790 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17791 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17792 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17793 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17794 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17795 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17796 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17797 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17798 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17799 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17800 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17801 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17802 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17803 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17804 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17805 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17806 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17807 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17808 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17809 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17810 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17811 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17812 v2df __builtin_ia32_loadupd (double *)
17813 void __builtin_ia32_storeupd (double *, v2df)
17814 v2df __builtin_ia32_loadhpd (v2df, double const *)
17815 v2df __builtin_ia32_loadlpd (v2df, double const *)
17816 int __builtin_ia32_movmskpd (v2df)
17817 int __builtin_ia32_pmovmskb128 (v16qi)
17818 void __builtin_ia32_movnti (int *, int)
17819 void __builtin_ia32_movnti64 (long long int *, long long int)
17820 void __builtin_ia32_movntpd (double *, v2df)
17821 void __builtin_ia32_movntdq (v2df *, v2df)
17822 v4si __builtin_ia32_pshufd (v4si, int)
17823 v8hi __builtin_ia32_pshuflw (v8hi, int)
17824 v8hi __builtin_ia32_pshufhw (v8hi, int)
17825 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17826 v2df __builtin_ia32_sqrtpd (v2df)
17827 v2df __builtin_ia32_sqrtsd (v2df)
17828 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17829 v2df __builtin_ia32_cvtdq2pd (v4si)
17830 v4sf __builtin_ia32_cvtdq2ps (v4si)
17831 v4si __builtin_ia32_cvtpd2dq (v2df)
17832 v2si __builtin_ia32_cvtpd2pi (v2df)
17833 v4sf __builtin_ia32_cvtpd2ps (v2df)
17834 v4si __builtin_ia32_cvttpd2dq (v2df)
17835 v2si __builtin_ia32_cvttpd2pi (v2df)
17836 v2df __builtin_ia32_cvtpi2pd (v2si)
17837 int __builtin_ia32_cvtsd2si (v2df)
17838 int __builtin_ia32_cvttsd2si (v2df)
17839 long long __builtin_ia32_cvtsd2si64 (v2df)
17840 long long __builtin_ia32_cvttsd2si64 (v2df)
17841 v4si __builtin_ia32_cvtps2dq (v4sf)
17842 v2df __builtin_ia32_cvtps2pd (v4sf)
17843 v4si __builtin_ia32_cvttps2dq (v4sf)
17844 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17845 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17846 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17847 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17848 void __builtin_ia32_clflush (const void *)
17849 void __builtin_ia32_lfence (void)
17850 void __builtin_ia32_mfence (void)
17851 v16qi __builtin_ia32_loaddqu (const char *)
17852 void __builtin_ia32_storedqu (char *, v16qi)
17853 v1di __builtin_ia32_pmuludq (v2si, v2si)
17854 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17855 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17856 v4si __builtin_ia32_pslld128 (v4si, v4si)
17857 v2di __builtin_ia32_psllq128 (v2di, v2di)
17858 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17859 v4si __builtin_ia32_psrld128 (v4si, v4si)
17860 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17861 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17862 v4si __builtin_ia32_psrad128 (v4si, v4si)
17863 v2di __builtin_ia32_pslldqi128 (v2di, int)
17864 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17865 v4si __builtin_ia32_pslldi128 (v4si, int)
17866 v2di __builtin_ia32_psllqi128 (v2di, int)
17867 v2di __builtin_ia32_psrldqi128 (v2di, int)
17868 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17869 v4si __builtin_ia32_psrldi128 (v4si, int)
17870 v2di __builtin_ia32_psrlqi128 (v2di, int)
17871 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17872 v4si __builtin_ia32_psradi128 (v4si, int)
17873 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17874 v2di __builtin_ia32_movq128 (v2di)
17875 @end smallexample
17876
17877 The following built-in functions are available when @option{-msse3} is used.
17878 All of them generate the machine instruction that is part of the name.
17879
17880 @smallexample
17881 v2df __builtin_ia32_addsubpd (v2df, v2df)
17882 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17883 v2df __builtin_ia32_haddpd (v2df, v2df)
17884 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17885 v2df __builtin_ia32_hsubpd (v2df, v2df)
17886 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17887 v16qi __builtin_ia32_lddqu (char const *)
17888 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17889 v4sf __builtin_ia32_movshdup (v4sf)
17890 v4sf __builtin_ia32_movsldup (v4sf)
17891 void __builtin_ia32_mwait (unsigned int, unsigned int)
17892 @end smallexample
17893
17894 The following built-in functions are available when @option{-mssse3} is used.
17895 All of them generate the machine instruction that is part of the name.
17896
17897 @smallexample
17898 v2si __builtin_ia32_phaddd (v2si, v2si)
17899 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17900 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17901 v2si __builtin_ia32_phsubd (v2si, v2si)
17902 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17903 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17904 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17905 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17906 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17907 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17908 v2si __builtin_ia32_psignd (v2si, v2si)
17909 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17910 v1di __builtin_ia32_palignr (v1di, v1di, int)
17911 v8qi __builtin_ia32_pabsb (v8qi)
17912 v2si __builtin_ia32_pabsd (v2si)
17913 v4hi __builtin_ia32_pabsw (v4hi)
17914 @end smallexample
17915
17916 The following built-in functions are available when @option{-mssse3} is used.
17917 All of them generate the machine instruction that is part of the name.
17918
17919 @smallexample
17920 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17921 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17922 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17923 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17924 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17925 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17926 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17927 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17928 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17929 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17930 v4si __builtin_ia32_psignd128 (v4si, v4si)
17931 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17932 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17933 v16qi __builtin_ia32_pabsb128 (v16qi)
17934 v4si __builtin_ia32_pabsd128 (v4si)
17935 v8hi __builtin_ia32_pabsw128 (v8hi)
17936 @end smallexample
17937
17938 The following built-in functions are available when @option{-msse4.1} is
17939 used. All of them generate the machine instruction that is part of the
17940 name.
17941
17942 @smallexample
17943 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17944 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17945 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17946 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17947 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17948 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17949 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17950 v2di __builtin_ia32_movntdqa (v2di *);
17951 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17952 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17953 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17954 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17955 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17956 v8hi __builtin_ia32_phminposuw128 (v8hi)
17957 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17958 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17959 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17960 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17961 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17962 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17963 v4si __builtin_ia32_pminud128 (v4si, v4si)
17964 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17965 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17966 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17967 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17968 v2di __builtin_ia32_pmovsxdq128 (v4si)
17969 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17970 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17971 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17972 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17973 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17974 v2di __builtin_ia32_pmovzxdq128 (v4si)
17975 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17976 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17977 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17978 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17979 int __builtin_ia32_ptestc128 (v2di, v2di)
17980 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17981 int __builtin_ia32_ptestz128 (v2di, v2di)
17982 v2df __builtin_ia32_roundpd (v2df, const int)
17983 v4sf __builtin_ia32_roundps (v4sf, const int)
17984 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17985 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17986 @end smallexample
17987
17988 The following built-in functions are available when @option{-msse4.1} is
17989 used.
17990
17991 @table @code
17992 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17993 Generates the @code{insertps} machine instruction.
17994 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17995 Generates the @code{pextrb} machine instruction.
17996 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17997 Generates the @code{pinsrb} machine instruction.
17998 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17999 Generates the @code{pinsrd} machine instruction.
18000 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
18001 Generates the @code{pinsrq} machine instruction in 64bit mode.
18002 @end table
18003
18004 The following built-in functions are changed to generate new SSE4.1
18005 instructions when @option{-msse4.1} is used.
18006
18007 @table @code
18008 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
18009 Generates the @code{extractps} machine instruction.
18010 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
18011 Generates the @code{pextrd} machine instruction.
18012 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
18013 Generates the @code{pextrq} machine instruction in 64bit mode.
18014 @end table
18015
18016 The following built-in functions are available when @option{-msse4.2} is
18017 used. All of them generate the machine instruction that is part of the
18018 name.
18019
18020 @smallexample
18021 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
18022 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
18023 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
18024 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
18025 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
18026 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
18027 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
18028 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
18029 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
18030 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
18031 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
18032 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
18033 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
18034 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
18035 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
18036 @end smallexample
18037
18038 The following built-in functions are available when @option{-msse4.2} is
18039 used.
18040
18041 @table @code
18042 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
18043 Generates the @code{crc32b} machine instruction.
18044 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
18045 Generates the @code{crc32w} machine instruction.
18046 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
18047 Generates the @code{crc32l} machine instruction.
18048 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
18049 Generates the @code{crc32q} machine instruction.
18050 @end table
18051
18052 The following built-in functions are changed to generate new SSE4.2
18053 instructions when @option{-msse4.2} is used.
18054
18055 @table @code
18056 @item int __builtin_popcount (unsigned int)
18057 Generates the @code{popcntl} machine instruction.
18058 @item int __builtin_popcountl (unsigned long)
18059 Generates the @code{popcntl} or @code{popcntq} machine instruction,
18060 depending on the size of @code{unsigned long}.
18061 @item int __builtin_popcountll (unsigned long long)
18062 Generates the @code{popcntq} machine instruction.
18063 @end table
18064
18065 The following built-in functions are available when @option{-mavx} is
18066 used. All of them generate the machine instruction that is part of the
18067 name.
18068
18069 @smallexample
18070 v4df __builtin_ia32_addpd256 (v4df,v4df)
18071 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
18072 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
18073 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
18074 v4df __builtin_ia32_andnpd256 (v4df,v4df)
18075 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
18076 v4df __builtin_ia32_andpd256 (v4df,v4df)
18077 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
18078 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
18079 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
18080 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
18081 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
18082 v2df __builtin_ia32_cmppd (v2df,v2df,int)
18083 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
18084 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
18085 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
18086 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
18087 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
18088 v4df __builtin_ia32_cvtdq2pd256 (v4si)
18089 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
18090 v4si __builtin_ia32_cvtpd2dq256 (v4df)
18091 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
18092 v8si __builtin_ia32_cvtps2dq256 (v8sf)
18093 v4df __builtin_ia32_cvtps2pd256 (v4sf)
18094 v4si __builtin_ia32_cvttpd2dq256 (v4df)
18095 v8si __builtin_ia32_cvttps2dq256 (v8sf)
18096 v4df __builtin_ia32_divpd256 (v4df,v4df)
18097 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
18098 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
18099 v4df __builtin_ia32_haddpd256 (v4df,v4df)
18100 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
18101 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
18102 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
18103 v32qi __builtin_ia32_lddqu256 (pcchar)
18104 v32qi __builtin_ia32_loaddqu256 (pcchar)
18105 v4df __builtin_ia32_loadupd256 (pcdouble)
18106 v8sf __builtin_ia32_loadups256 (pcfloat)
18107 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
18108 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
18109 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
18110 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
18111 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
18112 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
18113 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
18114 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
18115 v4df __builtin_ia32_maxpd256 (v4df,v4df)
18116 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
18117 v4df __builtin_ia32_minpd256 (v4df,v4df)
18118 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
18119 v4df __builtin_ia32_movddup256 (v4df)
18120 int __builtin_ia32_movmskpd256 (v4df)
18121 int __builtin_ia32_movmskps256 (v8sf)
18122 v8sf __builtin_ia32_movshdup256 (v8sf)
18123 v8sf __builtin_ia32_movsldup256 (v8sf)
18124 v4df __builtin_ia32_mulpd256 (v4df,v4df)
18125 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
18126 v4df __builtin_ia32_orpd256 (v4df,v4df)
18127 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
18128 v2df __builtin_ia32_pd_pd256 (v4df)
18129 v4df __builtin_ia32_pd256_pd (v2df)
18130 v4sf __builtin_ia32_ps_ps256 (v8sf)
18131 v8sf __builtin_ia32_ps256_ps (v4sf)
18132 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
18133 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
18134 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
18135 v8sf __builtin_ia32_rcpps256 (v8sf)
18136 v4df __builtin_ia32_roundpd256 (v4df,int)
18137 v8sf __builtin_ia32_roundps256 (v8sf,int)
18138 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
18139 v8sf __builtin_ia32_rsqrtps256 (v8sf)
18140 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
18141 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
18142 v4si __builtin_ia32_si_si256 (v8si)
18143 v8si __builtin_ia32_si256_si (v4si)
18144 v4df __builtin_ia32_sqrtpd256 (v4df)
18145 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
18146 v8sf __builtin_ia32_sqrtps256 (v8sf)
18147 void __builtin_ia32_storedqu256 (pchar,v32qi)
18148 void __builtin_ia32_storeupd256 (pdouble,v4df)
18149 void __builtin_ia32_storeups256 (pfloat,v8sf)
18150 v4df __builtin_ia32_subpd256 (v4df,v4df)
18151 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
18152 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
18153 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
18154 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
18155 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
18156 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
18157 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
18158 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
18159 v4sf __builtin_ia32_vbroadcastss (pcfloat)
18160 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
18161 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
18162 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
18163 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
18164 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
18165 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
18166 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
18167 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
18168 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
18169 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
18170 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
18171 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
18172 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
18173 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
18174 v2df __builtin_ia32_vpermilpd (v2df,int)
18175 v4df __builtin_ia32_vpermilpd256 (v4df,int)
18176 v4sf __builtin_ia32_vpermilps (v4sf,int)
18177 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
18178 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
18179 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
18180 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
18181 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
18182 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
18183 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
18184 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
18185 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
18186 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
18187 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
18188 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
18189 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
18190 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
18191 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
18192 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
18193 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
18194 void __builtin_ia32_vzeroall (void)
18195 void __builtin_ia32_vzeroupper (void)
18196 v4df __builtin_ia32_xorpd256 (v4df,v4df)
18197 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
18198 @end smallexample
18199
18200 The following built-in functions are available when @option{-mavx2} is
18201 used. All of them generate the machine instruction that is part of the
18202 name.
18203
18204 @smallexample
18205 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
18206 v32qi __builtin_ia32_pabsb256 (v32qi)
18207 v16hi __builtin_ia32_pabsw256 (v16hi)
18208 v8si __builtin_ia32_pabsd256 (v8si)
18209 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
18210 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
18211 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
18212 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
18213 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
18214 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
18215 v8si __builtin_ia32_paddd256 (v8si,v8si)
18216 v4di __builtin_ia32_paddq256 (v4di,v4di)
18217 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
18218 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
18219 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
18220 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
18221 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
18222 v4di __builtin_ia32_andsi256 (v4di,v4di)
18223 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
18224 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
18225 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
18226 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
18227 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
18228 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
18229 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
18230 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
18231 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
18232 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
18233 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
18234 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
18235 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
18236 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
18237 v8si __builtin_ia32_phaddd256 (v8si,v8si)
18238 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
18239 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
18240 v8si __builtin_ia32_phsubd256 (v8si,v8si)
18241 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
18242 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
18243 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
18244 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
18245 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
18246 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
18247 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
18248 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
18249 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
18250 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
18251 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
18252 v8si __builtin_ia32_pminsd256 (v8si,v8si)
18253 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
18254 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
18255 v8si __builtin_ia32_pminud256 (v8si,v8si)
18256 int __builtin_ia32_pmovmskb256 (v32qi)
18257 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
18258 v8si __builtin_ia32_pmovsxbd256 (v16qi)
18259 v4di __builtin_ia32_pmovsxbq256 (v16qi)
18260 v8si __builtin_ia32_pmovsxwd256 (v8hi)
18261 v4di __builtin_ia32_pmovsxwq256 (v8hi)
18262 v4di __builtin_ia32_pmovsxdq256 (v4si)
18263 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
18264 v8si __builtin_ia32_pmovzxbd256 (v16qi)
18265 v4di __builtin_ia32_pmovzxbq256 (v16qi)
18266 v8si __builtin_ia32_pmovzxwd256 (v8hi)
18267 v4di __builtin_ia32_pmovzxwq256 (v8hi)
18268 v4di __builtin_ia32_pmovzxdq256 (v4si)
18269 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
18270 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
18271 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
18272 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
18273 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
18274 v8si __builtin_ia32_pmulld256 (v8si,v8si)
18275 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
18276 v4di __builtin_ia32_por256 (v4di,v4di)
18277 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
18278 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
18279 v8si __builtin_ia32_pshufd256 (v8si,int)
18280 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
18281 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
18282 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
18283 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
18284 v8si __builtin_ia32_psignd256 (v8si,v8si)
18285 v4di __builtin_ia32_pslldqi256 (v4di,int)
18286 v16hi __builtin_ia32_psllwi256 (16hi,int)
18287 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
18288 v8si __builtin_ia32_pslldi256 (v8si,int)
18289 v8si __builtin_ia32_pslld256(v8si,v4si)
18290 v4di __builtin_ia32_psllqi256 (v4di,int)
18291 v4di __builtin_ia32_psllq256(v4di,v2di)
18292 v16hi __builtin_ia32_psrawi256 (v16hi,int)
18293 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
18294 v8si __builtin_ia32_psradi256 (v8si,int)
18295 v8si __builtin_ia32_psrad256 (v8si,v4si)
18296 v4di __builtin_ia32_psrldqi256 (v4di, int)
18297 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
18298 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
18299 v8si __builtin_ia32_psrldi256 (v8si,int)
18300 v8si __builtin_ia32_psrld256 (v8si,v4si)
18301 v4di __builtin_ia32_psrlqi256 (v4di,int)
18302 v4di __builtin_ia32_psrlq256(v4di,v2di)
18303 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
18304 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
18305 v8si __builtin_ia32_psubd256 (v8si,v8si)
18306 v4di __builtin_ia32_psubq256 (v4di,v4di)
18307 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
18308 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
18309 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
18310 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
18311 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
18312 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
18313 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
18314 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
18315 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
18316 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
18317 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
18318 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
18319 v4di __builtin_ia32_pxor256 (v4di,v4di)
18320 v4di __builtin_ia32_movntdqa256 (pv4di)
18321 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
18322 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
18323 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
18324 v4di __builtin_ia32_vbroadcastsi256 (v2di)
18325 v4si __builtin_ia32_pblendd128 (v4si,v4si)
18326 v8si __builtin_ia32_pblendd256 (v8si,v8si)
18327 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
18328 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
18329 v8si __builtin_ia32_pbroadcastd256 (v4si)
18330 v4di __builtin_ia32_pbroadcastq256 (v2di)
18331 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
18332 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
18333 v4si __builtin_ia32_pbroadcastd128 (v4si)
18334 v2di __builtin_ia32_pbroadcastq128 (v2di)
18335 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
18336 v4df __builtin_ia32_permdf256 (v4df,int)
18337 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
18338 v4di __builtin_ia32_permdi256 (v4di,int)
18339 v4di __builtin_ia32_permti256 (v4di,v4di,int)
18340 v4di __builtin_ia32_extract128i256 (v4di,int)
18341 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
18342 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
18343 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
18344 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
18345 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
18346 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
18347 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
18348 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
18349 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
18350 v8si __builtin_ia32_psllv8si (v8si,v8si)
18351 v4si __builtin_ia32_psllv4si (v4si,v4si)
18352 v4di __builtin_ia32_psllv4di (v4di,v4di)
18353 v2di __builtin_ia32_psllv2di (v2di,v2di)
18354 v8si __builtin_ia32_psrav8si (v8si,v8si)
18355 v4si __builtin_ia32_psrav4si (v4si,v4si)
18356 v8si __builtin_ia32_psrlv8si (v8si,v8si)
18357 v4si __builtin_ia32_psrlv4si (v4si,v4si)
18358 v4di __builtin_ia32_psrlv4di (v4di,v4di)
18359 v2di __builtin_ia32_psrlv2di (v2di,v2di)
18360 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
18361 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
18362 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
18363 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
18364 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
18365 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
18366 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
18367 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
18368 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
18369 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
18370 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
18371 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
18372 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
18373 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
18374 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
18375 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
18376 @end smallexample
18377
18378 The following built-in functions are available when @option{-maes} is
18379 used. All of them generate the machine instruction that is part of the
18380 name.
18381
18382 @smallexample
18383 v2di __builtin_ia32_aesenc128 (v2di, v2di)
18384 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
18385 v2di __builtin_ia32_aesdec128 (v2di, v2di)
18386 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
18387 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
18388 v2di __builtin_ia32_aesimc128 (v2di)
18389 @end smallexample
18390
18391 The following built-in function is available when @option{-mpclmul} is
18392 used.
18393
18394 @table @code
18395 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
18396 Generates the @code{pclmulqdq} machine instruction.
18397 @end table
18398
18399 The following built-in function is available when @option{-mfsgsbase} is
18400 used. All of them generate the machine instruction that is part of the
18401 name.
18402
18403 @smallexample
18404 unsigned int __builtin_ia32_rdfsbase32 (void)
18405 unsigned long long __builtin_ia32_rdfsbase64 (void)
18406 unsigned int __builtin_ia32_rdgsbase32 (void)
18407 unsigned long long __builtin_ia32_rdgsbase64 (void)
18408 void _writefsbase_u32 (unsigned int)
18409 void _writefsbase_u64 (unsigned long long)
18410 void _writegsbase_u32 (unsigned int)
18411 void _writegsbase_u64 (unsigned long long)
18412 @end smallexample
18413
18414 The following built-in function is available when @option{-mrdrnd} is
18415 used. All of them generate the machine instruction that is part of the
18416 name.
18417
18418 @smallexample
18419 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
18420 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
18421 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
18422 @end smallexample
18423
18424 The following built-in functions are available when @option{-msse4a} is used.
18425 All of them generate the machine instruction that is part of the name.
18426
18427 @smallexample
18428 void __builtin_ia32_movntsd (double *, v2df)
18429 void __builtin_ia32_movntss (float *, v4sf)
18430 v2di __builtin_ia32_extrq (v2di, v16qi)
18431 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
18432 v2di __builtin_ia32_insertq (v2di, v2di)
18433 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
18434 @end smallexample
18435
18436 The following built-in functions are available when @option{-mxop} is used.
18437 @smallexample
18438 v2df __builtin_ia32_vfrczpd (v2df)
18439 v4sf __builtin_ia32_vfrczps (v4sf)
18440 v2df __builtin_ia32_vfrczsd (v2df)
18441 v4sf __builtin_ia32_vfrczss (v4sf)
18442 v4df __builtin_ia32_vfrczpd256 (v4df)
18443 v8sf __builtin_ia32_vfrczps256 (v8sf)
18444 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18445 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18446 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18447 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18448 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18449 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18450 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18451 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18452 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18453 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18454 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18455 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18456 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18457 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18458 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18459 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18460 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18461 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18462 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18463 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18464 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18465 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18466 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18467 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18468 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18469 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18470 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18471 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18472 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18473 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18474 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18475 v4si __builtin_ia32_vpcomged (v4si, v4si)
18476 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18477 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18478 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18479 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18480 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18481 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18482 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18483 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18484 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18485 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18486 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18487 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18488 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18489 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18490 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18491 v4si __builtin_ia32_vpcomled (v4si, v4si)
18492 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18493 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18494 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18495 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18496 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18497 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18498 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18499 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18500 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18501 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18502 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18503 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18504 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18505 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18506 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18507 v4si __builtin_ia32_vpcomned (v4si, v4si)
18508 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18509 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18510 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18511 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18512 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18513 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18514 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18515 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18516 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18517 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18518 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18519 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18520 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18521 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18522 v4si __builtin_ia32_vphaddbd (v16qi)
18523 v2di __builtin_ia32_vphaddbq (v16qi)
18524 v8hi __builtin_ia32_vphaddbw (v16qi)
18525 v2di __builtin_ia32_vphadddq (v4si)
18526 v4si __builtin_ia32_vphaddubd (v16qi)
18527 v2di __builtin_ia32_vphaddubq (v16qi)
18528 v8hi __builtin_ia32_vphaddubw (v16qi)
18529 v2di __builtin_ia32_vphaddudq (v4si)
18530 v4si __builtin_ia32_vphadduwd (v8hi)
18531 v2di __builtin_ia32_vphadduwq (v8hi)
18532 v4si __builtin_ia32_vphaddwd (v8hi)
18533 v2di __builtin_ia32_vphaddwq (v8hi)
18534 v8hi __builtin_ia32_vphsubbw (v16qi)
18535 v2di __builtin_ia32_vphsubdq (v4si)
18536 v4si __builtin_ia32_vphsubwd (v8hi)
18537 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18538 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18539 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18540 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18541 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18542 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18543 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18544 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18545 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18546 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18547 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18548 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18549 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18550 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18551 v4si __builtin_ia32_vprotd (v4si, v4si)
18552 v2di __builtin_ia32_vprotq (v2di, v2di)
18553 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18554 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18555 v4si __builtin_ia32_vpshad (v4si, v4si)
18556 v2di __builtin_ia32_vpshaq (v2di, v2di)
18557 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18558 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18559 v4si __builtin_ia32_vpshld (v4si, v4si)
18560 v2di __builtin_ia32_vpshlq (v2di, v2di)
18561 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18562 @end smallexample
18563
18564 The following built-in functions are available when @option{-mfma4} is used.
18565 All of them generate the machine instruction that is part of the name.
18566
18567 @smallexample
18568 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18569 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18570 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18571 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18572 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18573 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18574 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18575 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18576 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18577 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18578 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18579 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18580 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18581 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18582 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18583 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18584 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18585 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18586 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18587 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18588 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18589 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18590 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18591 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18592 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18593 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18594 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18595 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18596 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18597 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18598 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18599 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18600
18601 @end smallexample
18602
18603 The following built-in functions are available when @option{-mlwp} is used.
18604
18605 @smallexample
18606 void __builtin_ia32_llwpcb16 (void *);
18607 void __builtin_ia32_llwpcb32 (void *);
18608 void __builtin_ia32_llwpcb64 (void *);
18609 void * __builtin_ia32_llwpcb16 (void);
18610 void * __builtin_ia32_llwpcb32 (void);
18611 void * __builtin_ia32_llwpcb64 (void);
18612 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18613 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18614 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18615 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18616 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18617 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18618 @end smallexample
18619
18620 The following built-in functions are available when @option{-mbmi} is used.
18621 All of them generate the machine instruction that is part of the name.
18622 @smallexample
18623 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18624 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18625 @end smallexample
18626
18627 The following built-in functions are available when @option{-mbmi2} is used.
18628 All of them generate the machine instruction that is part of the name.
18629 @smallexample
18630 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18631 unsigned int _pdep_u32 (unsigned int, unsigned int)
18632 unsigned int _pext_u32 (unsigned int, unsigned int)
18633 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18634 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18635 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18636 @end smallexample
18637
18638 The following built-in functions are available when @option{-mlzcnt} is used.
18639 All of them generate the machine instruction that is part of the name.
18640 @smallexample
18641 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18642 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18643 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18644 @end smallexample
18645
18646 The following built-in functions are available when @option{-mfxsr} is used.
18647 All of them generate the machine instruction that is part of the name.
18648 @smallexample
18649 void __builtin_ia32_fxsave (void *)
18650 void __builtin_ia32_fxrstor (void *)
18651 void __builtin_ia32_fxsave64 (void *)
18652 void __builtin_ia32_fxrstor64 (void *)
18653 @end smallexample
18654
18655 The following built-in functions are available when @option{-mxsave} is used.
18656 All of them generate the machine instruction that is part of the name.
18657 @smallexample
18658 void __builtin_ia32_xsave (void *, long long)
18659 void __builtin_ia32_xrstor (void *, long long)
18660 void __builtin_ia32_xsave64 (void *, long long)
18661 void __builtin_ia32_xrstor64 (void *, long long)
18662 @end smallexample
18663
18664 The following built-in functions are available when @option{-mxsaveopt} is used.
18665 All of them generate the machine instruction that is part of the name.
18666 @smallexample
18667 void __builtin_ia32_xsaveopt (void *, long long)
18668 void __builtin_ia32_xsaveopt64 (void *, long long)
18669 @end smallexample
18670
18671 The following built-in functions are available when @option{-mtbm} is used.
18672 Both of them generate the immediate form of the bextr machine instruction.
18673 @smallexample
18674 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18675 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18676 @end smallexample
18677
18678
18679 The following built-in functions are available when @option{-m3dnow} is used.
18680 All of them generate the machine instruction that is part of the name.
18681
18682 @smallexample
18683 void __builtin_ia32_femms (void)
18684 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18685 v2si __builtin_ia32_pf2id (v2sf)
18686 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18687 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18688 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18689 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18690 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18691 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18692 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18693 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18694 v2sf __builtin_ia32_pfrcp (v2sf)
18695 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18696 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18697 v2sf __builtin_ia32_pfrsqrt (v2sf)
18698 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18699 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18700 v2sf __builtin_ia32_pi2fd (v2si)
18701 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18702 @end smallexample
18703
18704 The following built-in functions are available when both @option{-m3dnow}
18705 and @option{-march=athlon} are used. All of them generate the machine
18706 instruction that is part of the name.
18707
18708 @smallexample
18709 v2si __builtin_ia32_pf2iw (v2sf)
18710 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18711 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18712 v2sf __builtin_ia32_pi2fw (v2si)
18713 v2sf __builtin_ia32_pswapdsf (v2sf)
18714 v2si __builtin_ia32_pswapdsi (v2si)
18715 @end smallexample
18716
18717 The following built-in functions are available when @option{-mrtm} is used
18718 They are used for restricted transactional memory. These are the internal
18719 low level functions. Normally the functions in
18720 @ref{x86 transactional memory intrinsics} should be used instead.
18721
18722 @smallexample
18723 int __builtin_ia32_xbegin ()
18724 void __builtin_ia32_xend ()
18725 void __builtin_ia32_xabort (status)
18726 int __builtin_ia32_xtest ()
18727 @end smallexample
18728
18729 The following built-in functions are available when @option{-mmwaitx} is used.
18730 All of them generate the machine instruction that is part of the name.
18731 @smallexample
18732 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18733 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18734 @end smallexample
18735
18736 The following built-in functions are available when @option{-mclzero} is used.
18737 All of them generate the machine instruction that is part of the name.
18738 @smallexample
18739 void __builtin_i32_clzero (void *)
18740 @end smallexample
18741
18742 The following built-in functions are available when @option{-mpku} is used.
18743 They generate reads and writes to PKRU.
18744 @smallexample
18745 void __builtin_ia32_wrpkru (unsigned int)
18746 unsigned int __builtin_ia32_rdpkru ()
18747 @end smallexample
18748
18749 @node x86 transactional memory intrinsics
18750 @subsection x86 Transactional Memory Intrinsics
18751
18752 These hardware transactional memory intrinsics for x86 allow you to use
18753 memory transactions with RTM (Restricted Transactional Memory).
18754 This support is enabled with the @option{-mrtm} option.
18755 For using HLE (Hardware Lock Elision) see
18756 @ref{x86 specific memory model extensions for transactional memory} instead.
18757
18758 A memory transaction commits all changes to memory in an atomic way,
18759 as visible to other threads. If the transaction fails it is rolled back
18760 and all side effects discarded.
18761
18762 Generally there is no guarantee that a memory transaction ever succeeds
18763 and suitable fallback code always needs to be supplied.
18764
18765 @deftypefn {RTM Function} {unsigned} _xbegin ()
18766 Start a RTM (Restricted Transactional Memory) transaction.
18767 Returns @code{_XBEGIN_STARTED} when the transaction
18768 started successfully (note this is not 0, so the constant has to be
18769 explicitly tested).
18770
18771 If the transaction aborts, all side-effects
18772 are undone and an abort code encoded as a bit mask is returned.
18773 The following macros are defined:
18774
18775 @table @code
18776 @item _XABORT_EXPLICIT
18777 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18778 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18779 @item _XABORT_RETRY
18780 Transaction retry is possible.
18781 @item _XABORT_CONFLICT
18782 Transaction abort due to a memory conflict with another thread.
18783 @item _XABORT_CAPACITY
18784 Transaction abort due to the transaction using too much memory.
18785 @item _XABORT_DEBUG
18786 Transaction abort due to a debug trap.
18787 @item _XABORT_NESTED
18788 Transaction abort in an inner nested transaction.
18789 @end table
18790
18791 There is no guarantee
18792 any transaction ever succeeds, so there always needs to be a valid
18793 fallback path.
18794 @end deftypefn
18795
18796 @deftypefn {RTM Function} {void} _xend ()
18797 Commit the current transaction. When no transaction is active this faults.
18798 All memory side-effects of the transaction become visible
18799 to other threads in an atomic manner.
18800 @end deftypefn
18801
18802 @deftypefn {RTM Function} {int} _xtest ()
18803 Return a nonzero value if a transaction is currently active, otherwise 0.
18804 @end deftypefn
18805
18806 @deftypefn {RTM Function} {void} _xabort (status)
18807 Abort the current transaction. When no transaction is active this is a no-op.
18808 The @var{status} is an 8-bit constant; its value is encoded in the return
18809 value from @code{_xbegin}.
18810 @end deftypefn
18811
18812 Here is an example showing handling for @code{_XABORT_RETRY}
18813 and a fallback path for other failures:
18814
18815 @smallexample
18816 #include <immintrin.h>
18817
18818 int n_tries, max_tries;
18819 unsigned status = _XABORT_EXPLICIT;
18820 ...
18821
18822 for (n_tries = 0; n_tries < max_tries; n_tries++)
18823 @{
18824 status = _xbegin ();
18825 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18826 break;
18827 @}
18828 if (status == _XBEGIN_STARTED)
18829 @{
18830 ... transaction code...
18831 _xend ();
18832 @}
18833 else
18834 @{
18835 ... non-transactional fallback path...
18836 @}
18837 @end smallexample
18838
18839 @noindent
18840 Note that, in most cases, the transactional and non-transactional code
18841 must synchronize together to ensure consistency.
18842
18843 @node Target Format Checks
18844 @section Format Checks Specific to Particular Target Machines
18845
18846 For some target machines, GCC supports additional options to the
18847 format attribute
18848 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18849
18850 @menu
18851 * Solaris Format Checks::
18852 * Darwin Format Checks::
18853 @end menu
18854
18855 @node Solaris Format Checks
18856 @subsection Solaris Format Checks
18857
18858 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18859 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18860 conversions, and the two-argument @code{%b} conversion for displaying
18861 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18862
18863 @node Darwin Format Checks
18864 @subsection Darwin Format Checks
18865
18866 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18867 attribute context. Declarations made with such attribution are parsed for correct syntax
18868 and format argument types. However, parsing of the format string itself is currently undefined
18869 and is not carried out by this version of the compiler.
18870
18871 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18872 also be used as format arguments. Note that the relevant headers are only likely to be
18873 available on Darwin (OSX) installations. On such installations, the XCode and system
18874 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18875 associated functions.
18876
18877 @node Pragmas
18878 @section Pragmas Accepted by GCC
18879 @cindex pragmas
18880 @cindex @code{#pragma}
18881
18882 GCC supports several types of pragmas, primarily in order to compile
18883 code originally written for other compilers. Note that in general
18884 we do not recommend the use of pragmas; @xref{Function Attributes},
18885 for further explanation.
18886
18887 @menu
18888 * AArch64 Pragmas::
18889 * ARM Pragmas::
18890 * M32C Pragmas::
18891 * MeP Pragmas::
18892 * RS/6000 and PowerPC Pragmas::
18893 * S/390 Pragmas::
18894 * Darwin Pragmas::
18895 * Solaris Pragmas::
18896 * Symbol-Renaming Pragmas::
18897 * Structure-Layout Pragmas::
18898 * Weak Pragmas::
18899 * Diagnostic Pragmas::
18900 * Visibility Pragmas::
18901 * Push/Pop Macro Pragmas::
18902 * Function Specific Option Pragmas::
18903 * Loop-Specific Pragmas::
18904 @end menu
18905
18906 @node AArch64 Pragmas
18907 @subsection AArch64 Pragmas
18908
18909 The pragmas defined by the AArch64 target correspond to the AArch64
18910 target function attributes. They can be specified as below:
18911 @smallexample
18912 #pragma GCC target("string")
18913 @end smallexample
18914
18915 where @code{@var{string}} can be any string accepted as an AArch64 target
18916 attribute. @xref{AArch64 Function Attributes}, for more details
18917 on the permissible values of @code{string}.
18918
18919 @node ARM Pragmas
18920 @subsection ARM Pragmas
18921
18922 The ARM target defines pragmas for controlling the default addition of
18923 @code{long_call} and @code{short_call} attributes to functions.
18924 @xref{Function Attributes}, for information about the effects of these
18925 attributes.
18926
18927 @table @code
18928 @item long_calls
18929 @cindex pragma, long_calls
18930 Set all subsequent functions to have the @code{long_call} attribute.
18931
18932 @item no_long_calls
18933 @cindex pragma, no_long_calls
18934 Set all subsequent functions to have the @code{short_call} attribute.
18935
18936 @item long_calls_off
18937 @cindex pragma, long_calls_off
18938 Do not affect the @code{long_call} or @code{short_call} attributes of
18939 subsequent functions.
18940 @end table
18941
18942 @node M32C Pragmas
18943 @subsection M32C Pragmas
18944
18945 @table @code
18946 @item GCC memregs @var{number}
18947 @cindex pragma, memregs
18948 Overrides the command-line option @code{-memregs=} for the current
18949 file. Use with care! This pragma must be before any function in the
18950 file, and mixing different memregs values in different objects may
18951 make them incompatible. This pragma is useful when a
18952 performance-critical function uses a memreg for temporary values,
18953 as it may allow you to reduce the number of memregs used.
18954
18955 @item ADDRESS @var{name} @var{address}
18956 @cindex pragma, address
18957 For any declared symbols matching @var{name}, this does three things
18958 to that symbol: it forces the symbol to be located at the given
18959 address (a number), it forces the symbol to be volatile, and it
18960 changes the symbol's scope to be static. This pragma exists for
18961 compatibility with other compilers, but note that the common
18962 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18963 instead). Example:
18964
18965 @smallexample
18966 #pragma ADDRESS port3 0x103
18967 char port3;
18968 @end smallexample
18969
18970 @end table
18971
18972 @node MeP Pragmas
18973 @subsection MeP Pragmas
18974
18975 @table @code
18976
18977 @item custom io_volatile (on|off)
18978 @cindex pragma, custom io_volatile
18979 Overrides the command-line option @code{-mio-volatile} for the current
18980 file. Note that for compatibility with future GCC releases, this
18981 option should only be used once before any @code{io} variables in each
18982 file.
18983
18984 @item GCC coprocessor available @var{registers}
18985 @cindex pragma, coprocessor available
18986 Specifies which coprocessor registers are available to the register
18987 allocator. @var{registers} may be a single register, register range
18988 separated by ellipses, or comma-separated list of those. Example:
18989
18990 @smallexample
18991 #pragma GCC coprocessor available $c0...$c10, $c28
18992 @end smallexample
18993
18994 @item GCC coprocessor call_saved @var{registers}
18995 @cindex pragma, coprocessor call_saved
18996 Specifies which coprocessor registers are to be saved and restored by
18997 any function using them. @var{registers} may be a single register,
18998 register range separated by ellipses, or comma-separated list of
18999 those. Example:
19000
19001 @smallexample
19002 #pragma GCC coprocessor call_saved $c4...$c6, $c31
19003 @end smallexample
19004
19005 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
19006 @cindex pragma, coprocessor subclass
19007 Creates and defines a register class. These register classes can be
19008 used by inline @code{asm} constructs. @var{registers} may be a single
19009 register, register range separated by ellipses, or comma-separated
19010 list of those. Example:
19011
19012 @smallexample
19013 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
19014
19015 asm ("cpfoo %0" : "=B" (x));
19016 @end smallexample
19017
19018 @item GCC disinterrupt @var{name} , @var{name} @dots{}
19019 @cindex pragma, disinterrupt
19020 For the named functions, the compiler adds code to disable interrupts
19021 for the duration of those functions. If any functions so named
19022 are not encountered in the source, a warning is emitted that the pragma is
19023 not used. Examples:
19024
19025 @smallexample
19026 #pragma disinterrupt foo
19027 #pragma disinterrupt bar, grill
19028 int foo () @{ @dots{} @}
19029 @end smallexample
19030
19031 @item GCC call @var{name} , @var{name} @dots{}
19032 @cindex pragma, call
19033 For the named functions, the compiler always uses a register-indirect
19034 call model when calling the named functions. Examples:
19035
19036 @smallexample
19037 extern int foo ();
19038 #pragma call foo
19039 @end smallexample
19040
19041 @end table
19042
19043 @node RS/6000 and PowerPC Pragmas
19044 @subsection RS/6000 and PowerPC Pragmas
19045
19046 The RS/6000 and PowerPC targets define one pragma for controlling
19047 whether or not the @code{longcall} attribute is added to function
19048 declarations by default. This pragma overrides the @option{-mlongcall}
19049 option, but not the @code{longcall} and @code{shortcall} attributes.
19050 @xref{RS/6000 and PowerPC Options}, for more information about when long
19051 calls are and are not necessary.
19052
19053 @table @code
19054 @item longcall (1)
19055 @cindex pragma, longcall
19056 Apply the @code{longcall} attribute to all subsequent function
19057 declarations.
19058
19059 @item longcall (0)
19060 Do not apply the @code{longcall} attribute to subsequent function
19061 declarations.
19062 @end table
19063
19064 @c Describe h8300 pragmas here.
19065 @c Describe sh pragmas here.
19066 @c Describe v850 pragmas here.
19067
19068 @node S/390 Pragmas
19069 @subsection S/390 Pragmas
19070
19071 The pragmas defined by the S/390 target correspond to the S/390
19072 target function attributes and some the additional options:
19073
19074 @table @samp
19075 @item zvector
19076 @itemx no-zvector
19077 @end table
19078
19079 Note that options of the pragma, unlike options of the target
19080 attribute, do change the value of preprocessor macros like
19081 @code{__VEC__}. They can be specified as below:
19082
19083 @smallexample
19084 #pragma GCC target("string[,string]...")
19085 #pragma GCC target("string"[,"string"]...)
19086 @end smallexample
19087
19088 @node Darwin Pragmas
19089 @subsection Darwin Pragmas
19090
19091 The following pragmas are available for all architectures running the
19092 Darwin operating system. These are useful for compatibility with other
19093 Mac OS compilers.
19094
19095 @table @code
19096 @item mark @var{tokens}@dots{}
19097 @cindex pragma, mark
19098 This pragma is accepted, but has no effect.
19099
19100 @item options align=@var{alignment}
19101 @cindex pragma, options align
19102 This pragma sets the alignment of fields in structures. The values of
19103 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
19104 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
19105 properly; to restore the previous setting, use @code{reset} for the
19106 @var{alignment}.
19107
19108 @item segment @var{tokens}@dots{}
19109 @cindex pragma, segment
19110 This pragma is accepted, but has no effect.
19111
19112 @item unused (@var{var} [, @var{var}]@dots{})
19113 @cindex pragma, unused
19114 This pragma declares variables to be possibly unused. GCC does not
19115 produce warnings for the listed variables. The effect is similar to
19116 that of the @code{unused} attribute, except that this pragma may appear
19117 anywhere within the variables' scopes.
19118 @end table
19119
19120 @node Solaris Pragmas
19121 @subsection Solaris Pragmas
19122
19123 The Solaris target supports @code{#pragma redefine_extname}
19124 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
19125 @code{#pragma} directives for compatibility with the system compiler.
19126
19127 @table @code
19128 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
19129 @cindex pragma, align
19130
19131 Increase the minimum alignment of each @var{variable} to @var{alignment}.
19132 This is the same as GCC's @code{aligned} attribute @pxref{Variable
19133 Attributes}). Macro expansion occurs on the arguments to this pragma
19134 when compiling C and Objective-C@. It does not currently occur when
19135 compiling C++, but this is a bug which may be fixed in a future
19136 release.
19137
19138 @item fini (@var{function} [, @var{function}]...)
19139 @cindex pragma, fini
19140
19141 This pragma causes each listed @var{function} to be called after
19142 main, or during shared module unloading, by adding a call to the
19143 @code{.fini} section.
19144
19145 @item init (@var{function} [, @var{function}]...)
19146 @cindex pragma, init
19147
19148 This pragma causes each listed @var{function} to be called during
19149 initialization (before @code{main}) or during shared module loading, by
19150 adding a call to the @code{.init} section.
19151
19152 @end table
19153
19154 @node Symbol-Renaming Pragmas
19155 @subsection Symbol-Renaming Pragmas
19156
19157 GCC supports a @code{#pragma} directive that changes the name used in
19158 assembly for a given declaration. While this pragma is supported on all
19159 platforms, it is intended primarily to provide compatibility with the
19160 Solaris system headers. This effect can also be achieved using the asm
19161 labels extension (@pxref{Asm Labels}).
19162
19163 @table @code
19164 @item redefine_extname @var{oldname} @var{newname}
19165 @cindex pragma, redefine_extname
19166
19167 This pragma gives the C function @var{oldname} the assembly symbol
19168 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
19169 is defined if this pragma is available (currently on all platforms).
19170 @end table
19171
19172 This pragma and the asm labels extension interact in a complicated
19173 manner. Here are some corner cases you may want to be aware of:
19174
19175 @enumerate
19176 @item This pragma silently applies only to declarations with external
19177 linkage. Asm labels do not have this restriction.
19178
19179 @item In C++, this pragma silently applies only to declarations with
19180 ``C'' linkage. Again, asm labels do not have this restriction.
19181
19182 @item If either of the ways of changing the assembly name of a
19183 declaration are applied to a declaration whose assembly name has
19184 already been determined (either by a previous use of one of these
19185 features, or because the compiler needed the assembly name in order to
19186 generate code), and the new name is different, a warning issues and
19187 the name does not change.
19188
19189 @item The @var{oldname} used by @code{#pragma redefine_extname} is
19190 always the C-language name.
19191 @end enumerate
19192
19193 @node Structure-Layout Pragmas
19194 @subsection Structure-Layout Pragmas
19195
19196 For compatibility with Microsoft Windows compilers, GCC supports a
19197 set of @code{#pragma} directives that change the maximum alignment of
19198 members of structures (other than zero-width bit-fields), unions, and
19199 classes subsequently defined. The @var{n} value below always is required
19200 to be a small power of two and specifies the new alignment in bytes.
19201
19202 @enumerate
19203 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
19204 @item @code{#pragma pack()} sets the alignment to the one that was in
19205 effect when compilation started (see also command-line option
19206 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
19207 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
19208 setting on an internal stack and then optionally sets the new alignment.
19209 @item @code{#pragma pack(pop)} restores the alignment setting to the one
19210 saved at the top of the internal stack (and removes that stack entry).
19211 Note that @code{#pragma pack([@var{n}])} does not influence this internal
19212 stack; thus it is possible to have @code{#pragma pack(push)} followed by
19213 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
19214 @code{#pragma pack(pop)}.
19215 @end enumerate
19216
19217 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
19218 directive which lays out structures and unions subsequently defined as the
19219 documented @code{__attribute__ ((ms_struct))}.
19220
19221 @enumerate
19222 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
19223 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
19224 @item @code{#pragma ms_struct reset} goes back to the default layout.
19225 @end enumerate
19226
19227 Most targets also support the @code{#pragma scalar_storage_order} directive
19228 which lays out structures and unions subsequently defined as the documented
19229 @code{__attribute__ ((scalar_storage_order))}.
19230
19231 @enumerate
19232 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
19233 of the scalar fields to big-endian.
19234 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
19235 of the scalar fields to little-endian.
19236 @item @code{#pragma scalar_storage_order default} goes back to the endianness
19237 that was in effect when compilation started (see also command-line option
19238 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
19239 @end enumerate
19240
19241 @node Weak Pragmas
19242 @subsection Weak Pragmas
19243
19244 For compatibility with SVR4, GCC supports a set of @code{#pragma}
19245 directives for declaring symbols to be weak, and defining weak
19246 aliases.
19247
19248 @table @code
19249 @item #pragma weak @var{symbol}
19250 @cindex pragma, weak
19251 This pragma declares @var{symbol} to be weak, as if the declaration
19252 had the attribute of the same name. The pragma may appear before
19253 or after the declaration of @var{symbol}. It is not an error for
19254 @var{symbol} to never be defined at all.
19255
19256 @item #pragma weak @var{symbol1} = @var{symbol2}
19257 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
19258 It is an error if @var{symbol2} is not defined in the current
19259 translation unit.
19260 @end table
19261
19262 @node Diagnostic Pragmas
19263 @subsection Diagnostic Pragmas
19264
19265 GCC allows the user to selectively enable or disable certain types of
19266 diagnostics, and change the kind of the diagnostic. For example, a
19267 project's policy might require that all sources compile with
19268 @option{-Werror} but certain files might have exceptions allowing
19269 specific types of warnings. Or, a project might selectively enable
19270 diagnostics and treat them as errors depending on which preprocessor
19271 macros are defined.
19272
19273 @table @code
19274 @item #pragma GCC diagnostic @var{kind} @var{option}
19275 @cindex pragma, diagnostic
19276
19277 Modifies the disposition of a diagnostic. Note that not all
19278 diagnostics are modifiable; at the moment only warnings (normally
19279 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
19280 Use @option{-fdiagnostics-show-option} to determine which diagnostics
19281 are controllable and which option controls them.
19282
19283 @var{kind} is @samp{error} to treat this diagnostic as an error,
19284 @samp{warning} to treat it like a warning (even if @option{-Werror} is
19285 in effect), or @samp{ignored} if the diagnostic is to be ignored.
19286 @var{option} is a double quoted string that matches the command-line
19287 option.
19288
19289 @smallexample
19290 #pragma GCC diagnostic warning "-Wformat"
19291 #pragma GCC diagnostic error "-Wformat"
19292 #pragma GCC diagnostic ignored "-Wformat"
19293 @end smallexample
19294
19295 Note that these pragmas override any command-line options. GCC keeps
19296 track of the location of each pragma, and issues diagnostics according
19297 to the state as of that point in the source file. Thus, pragmas occurring
19298 after a line do not affect diagnostics caused by that line.
19299
19300 @item #pragma GCC diagnostic push
19301 @itemx #pragma GCC diagnostic pop
19302
19303 Causes GCC to remember the state of the diagnostics as of each
19304 @code{push}, and restore to that point at each @code{pop}. If a
19305 @code{pop} has no matching @code{push}, the command-line options are
19306 restored.
19307
19308 @smallexample
19309 #pragma GCC diagnostic error "-Wuninitialized"
19310 foo(a); /* error is given for this one */
19311 #pragma GCC diagnostic push
19312 #pragma GCC diagnostic ignored "-Wuninitialized"
19313 foo(b); /* no diagnostic for this one */
19314 #pragma GCC diagnostic pop
19315 foo(c); /* error is given for this one */
19316 #pragma GCC diagnostic pop
19317 foo(d); /* depends on command-line options */
19318 @end smallexample
19319
19320 @end table
19321
19322 GCC also offers a simple mechanism for printing messages during
19323 compilation.
19324
19325 @table @code
19326 @item #pragma message @var{string}
19327 @cindex pragma, diagnostic
19328
19329 Prints @var{string} as a compiler message on compilation. The message
19330 is informational only, and is neither a compilation warning nor an error.
19331
19332 @smallexample
19333 #pragma message "Compiling " __FILE__ "..."
19334 @end smallexample
19335
19336 @var{string} may be parenthesized, and is printed with location
19337 information. For example,
19338
19339 @smallexample
19340 #define DO_PRAGMA(x) _Pragma (#x)
19341 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
19342
19343 TODO(Remember to fix this)
19344 @end smallexample
19345
19346 @noindent
19347 prints @samp{/tmp/file.c:4: note: #pragma message:
19348 TODO - Remember to fix this}.
19349
19350 @end table
19351
19352 @node Visibility Pragmas
19353 @subsection Visibility Pragmas
19354
19355 @table @code
19356 @item #pragma GCC visibility push(@var{visibility})
19357 @itemx #pragma GCC visibility pop
19358 @cindex pragma, visibility
19359
19360 This pragma allows the user to set the visibility for multiple
19361 declarations without having to give each a visibility attribute
19362 (@pxref{Function Attributes}).
19363
19364 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
19365 declarations. Class members and template specializations are not
19366 affected; if you want to override the visibility for a particular
19367 member or instantiation, you must use an attribute.
19368
19369 @end table
19370
19371
19372 @node Push/Pop Macro Pragmas
19373 @subsection Push/Pop Macro Pragmas
19374
19375 For compatibility with Microsoft Windows compilers, GCC supports
19376 @samp{#pragma push_macro(@var{"macro_name"})}
19377 and @samp{#pragma pop_macro(@var{"macro_name"})}.
19378
19379 @table @code
19380 @item #pragma push_macro(@var{"macro_name"})
19381 @cindex pragma, push_macro
19382 This pragma saves the value of the macro named as @var{macro_name} to
19383 the top of the stack for this macro.
19384
19385 @item #pragma pop_macro(@var{"macro_name"})
19386 @cindex pragma, pop_macro
19387 This pragma sets the value of the macro named as @var{macro_name} to
19388 the value on top of the stack for this macro. If the stack for
19389 @var{macro_name} is empty, the value of the macro remains unchanged.
19390 @end table
19391
19392 For example:
19393
19394 @smallexample
19395 #define X 1
19396 #pragma push_macro("X")
19397 #undef X
19398 #define X -1
19399 #pragma pop_macro("X")
19400 int x [X];
19401 @end smallexample
19402
19403 @noindent
19404 In this example, the definition of X as 1 is saved by @code{#pragma
19405 push_macro} and restored by @code{#pragma pop_macro}.
19406
19407 @node Function Specific Option Pragmas
19408 @subsection Function Specific Option Pragmas
19409
19410 @table @code
19411 @item #pragma GCC target (@var{"string"}...)
19412 @cindex pragma GCC target
19413
19414 This pragma allows you to set target specific options for functions
19415 defined later in the source file. One or more strings can be
19416 specified. Each function that is defined after this point is as
19417 if @code{attribute((target("STRING")))} was specified for that
19418 function. The parenthesis around the options is optional.
19419 @xref{Function Attributes}, for more information about the
19420 @code{target} attribute and the attribute syntax.
19421
19422 The @code{#pragma GCC target} pragma is presently implemented for
19423 x86, PowerPC, and Nios II targets only.
19424 @end table
19425
19426 @table @code
19427 @item #pragma GCC optimize (@var{"string"}...)
19428 @cindex pragma GCC optimize
19429
19430 This pragma allows you to set global optimization options for functions
19431 defined later in the source file. One or more strings can be
19432 specified. Each function that is defined after this point is as
19433 if @code{attribute((optimize("STRING")))} was specified for that
19434 function. The parenthesis around the options is optional.
19435 @xref{Function Attributes}, for more information about the
19436 @code{optimize} attribute and the attribute syntax.
19437 @end table
19438
19439 @table @code
19440 @item #pragma GCC push_options
19441 @itemx #pragma GCC pop_options
19442 @cindex pragma GCC push_options
19443 @cindex pragma GCC pop_options
19444
19445 These pragmas maintain a stack of the current target and optimization
19446 options. It is intended for include files where you temporarily want
19447 to switch to using a different @samp{#pragma GCC target} or
19448 @samp{#pragma GCC optimize} and then to pop back to the previous
19449 options.
19450 @end table
19451
19452 @table @code
19453 @item #pragma GCC reset_options
19454 @cindex pragma GCC reset_options
19455
19456 This pragma clears the current @code{#pragma GCC target} and
19457 @code{#pragma GCC optimize} to use the default switches as specified
19458 on the command line.
19459 @end table
19460
19461 @node Loop-Specific Pragmas
19462 @subsection Loop-Specific Pragmas
19463
19464 @table @code
19465 @item #pragma GCC ivdep
19466 @cindex pragma GCC ivdep
19467 @end table
19468
19469 With this pragma, the programmer asserts that there are no loop-carried
19470 dependencies which would prevent consecutive iterations of
19471 the following loop from executing concurrently with SIMD
19472 (single instruction multiple data) instructions.
19473
19474 For example, the compiler can only unconditionally vectorize the following
19475 loop with the pragma:
19476
19477 @smallexample
19478 void foo (int n, int *a, int *b, int *c)
19479 @{
19480 int i, j;
19481 #pragma GCC ivdep
19482 for (i = 0; i < n; ++i)
19483 a[i] = b[i] + c[i];
19484 @}
19485 @end smallexample
19486
19487 @noindent
19488 In this example, using the @code{restrict} qualifier had the same
19489 effect. In the following example, that would not be possible. Assume
19490 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19491 that it can unconditionally vectorize the following loop:
19492
19493 @smallexample
19494 void ignore_vec_dep (int *a, int k, int c, int m)
19495 @{
19496 #pragma GCC ivdep
19497 for (int i = 0; i < m; i++)
19498 a[i] = a[i + k] * c;
19499 @}
19500 @end smallexample
19501
19502
19503 @node Unnamed Fields
19504 @section Unnamed Structure and Union Fields
19505 @cindex @code{struct}
19506 @cindex @code{union}
19507
19508 As permitted by ISO C11 and for compatibility with other compilers,
19509 GCC allows you to define
19510 a structure or union that contains, as fields, structures and unions
19511 without names. For example:
19512
19513 @smallexample
19514 struct @{
19515 int a;
19516 union @{
19517 int b;
19518 float c;
19519 @};
19520 int d;
19521 @} foo;
19522 @end smallexample
19523
19524 @noindent
19525 In this example, you are able to access members of the unnamed
19526 union with code like @samp{foo.b}. Note that only unnamed structs and
19527 unions are allowed, you may not have, for example, an unnamed
19528 @code{int}.
19529
19530 You must never create such structures that cause ambiguous field definitions.
19531 For example, in this structure:
19532
19533 @smallexample
19534 struct @{
19535 int a;
19536 struct @{
19537 int a;
19538 @};
19539 @} foo;
19540 @end smallexample
19541
19542 @noindent
19543 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19544 The compiler gives errors for such constructs.
19545
19546 @opindex fms-extensions
19547 Unless @option{-fms-extensions} is used, the unnamed field must be a
19548 structure or union definition without a tag (for example, @samp{struct
19549 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19550 also be a definition with a tag such as @samp{struct foo @{ int a;
19551 @};}, a reference to a previously defined structure or union such as
19552 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19553 previously defined structure or union type.
19554
19555 @opindex fplan9-extensions
19556 The option @option{-fplan9-extensions} enables
19557 @option{-fms-extensions} as well as two other extensions. First, a
19558 pointer to a structure is automatically converted to a pointer to an
19559 anonymous field for assignments and function calls. For example:
19560
19561 @smallexample
19562 struct s1 @{ int a; @};
19563 struct s2 @{ struct s1; @};
19564 extern void f1 (struct s1 *);
19565 void f2 (struct s2 *p) @{ f1 (p); @}
19566 @end smallexample
19567
19568 @noindent
19569 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19570 converted into a pointer to the anonymous field.
19571
19572 Second, when the type of an anonymous field is a @code{typedef} for a
19573 @code{struct} or @code{union}, code may refer to the field using the
19574 name of the @code{typedef}.
19575
19576 @smallexample
19577 typedef struct @{ int a; @} s1;
19578 struct s2 @{ s1; @};
19579 s1 f1 (struct s2 *p) @{ return p->s1; @}
19580 @end smallexample
19581
19582 These usages are only permitted when they are not ambiguous.
19583
19584 @node Thread-Local
19585 @section Thread-Local Storage
19586 @cindex Thread-Local Storage
19587 @cindex @acronym{TLS}
19588 @cindex @code{__thread}
19589
19590 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19591 are allocated such that there is one instance of the variable per extant
19592 thread. The runtime model GCC uses to implement this originates
19593 in the IA-64 processor-specific ABI, but has since been migrated
19594 to other processors as well. It requires significant support from
19595 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19596 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19597 is not available everywhere.
19598
19599 At the user level, the extension is visible with a new storage
19600 class keyword: @code{__thread}. For example:
19601
19602 @smallexample
19603 __thread int i;
19604 extern __thread struct state s;
19605 static __thread char *p;
19606 @end smallexample
19607
19608 The @code{__thread} specifier may be used alone, with the @code{extern}
19609 or @code{static} specifiers, but with no other storage class specifier.
19610 When used with @code{extern} or @code{static}, @code{__thread} must appear
19611 immediately after the other storage class specifier.
19612
19613 The @code{__thread} specifier may be applied to any global, file-scoped
19614 static, function-scoped static, or static data member of a class. It may
19615 not be applied to block-scoped automatic or non-static data member.
19616
19617 When the address-of operator is applied to a thread-local variable, it is
19618 evaluated at run time and returns the address of the current thread's
19619 instance of that variable. An address so obtained may be used by any
19620 thread. When a thread terminates, any pointers to thread-local variables
19621 in that thread become invalid.
19622
19623 No static initialization may refer to the address of a thread-local variable.
19624
19625 In C++, if an initializer is present for a thread-local variable, it must
19626 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19627 standard.
19628
19629 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19630 ELF Handling For Thread-Local Storage} for a detailed explanation of
19631 the four thread-local storage addressing models, and how the runtime
19632 is expected to function.
19633
19634 @menu
19635 * C99 Thread-Local Edits::
19636 * C++98 Thread-Local Edits::
19637 @end menu
19638
19639 @node C99 Thread-Local Edits
19640 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19641
19642 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19643 that document the exact semantics of the language extension.
19644
19645 @itemize @bullet
19646 @item
19647 @cite{5.1.2 Execution environments}
19648
19649 Add new text after paragraph 1
19650
19651 @quotation
19652 Within either execution environment, a @dfn{thread} is a flow of
19653 control within a program. It is implementation defined whether
19654 or not there may be more than one thread associated with a program.
19655 It is implementation defined how threads beyond the first are
19656 created, the name and type of the function called at thread
19657 startup, and how threads may be terminated. However, objects
19658 with thread storage duration shall be initialized before thread
19659 startup.
19660 @end quotation
19661
19662 @item
19663 @cite{6.2.4 Storage durations of objects}
19664
19665 Add new text before paragraph 3
19666
19667 @quotation
19668 An object whose identifier is declared with the storage-class
19669 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19670 Its lifetime is the entire execution of the thread, and its
19671 stored value is initialized only once, prior to thread startup.
19672 @end quotation
19673
19674 @item
19675 @cite{6.4.1 Keywords}
19676
19677 Add @code{__thread}.
19678
19679 @item
19680 @cite{6.7.1 Storage-class specifiers}
19681
19682 Add @code{__thread} to the list of storage class specifiers in
19683 paragraph 1.
19684
19685 Change paragraph 2 to
19686
19687 @quotation
19688 With the exception of @code{__thread}, at most one storage-class
19689 specifier may be given [@dots{}]. The @code{__thread} specifier may
19690 be used alone, or immediately following @code{extern} or
19691 @code{static}.
19692 @end quotation
19693
19694 Add new text after paragraph 6
19695
19696 @quotation
19697 The declaration of an identifier for a variable that has
19698 block scope that specifies @code{__thread} shall also
19699 specify either @code{extern} or @code{static}.
19700
19701 The @code{__thread} specifier shall be used only with
19702 variables.
19703 @end quotation
19704 @end itemize
19705
19706 @node C++98 Thread-Local Edits
19707 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19708
19709 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19710 that document the exact semantics of the language extension.
19711
19712 @itemize @bullet
19713 @item
19714 @b{[intro.execution]}
19715
19716 New text after paragraph 4
19717
19718 @quotation
19719 A @dfn{thread} is a flow of control within the abstract machine.
19720 It is implementation defined whether or not there may be more than
19721 one thread.
19722 @end quotation
19723
19724 New text after paragraph 7
19725
19726 @quotation
19727 It is unspecified whether additional action must be taken to
19728 ensure when and whether side effects are visible to other threads.
19729 @end quotation
19730
19731 @item
19732 @b{[lex.key]}
19733
19734 Add @code{__thread}.
19735
19736 @item
19737 @b{[basic.start.main]}
19738
19739 Add after paragraph 5
19740
19741 @quotation
19742 The thread that begins execution at the @code{main} function is called
19743 the @dfn{main thread}. It is implementation defined how functions
19744 beginning threads other than the main thread are designated or typed.
19745 A function so designated, as well as the @code{main} function, is called
19746 a @dfn{thread startup function}. It is implementation defined what
19747 happens if a thread startup function returns. It is implementation
19748 defined what happens to other threads when any thread calls @code{exit}.
19749 @end quotation
19750
19751 @item
19752 @b{[basic.start.init]}
19753
19754 Add after paragraph 4
19755
19756 @quotation
19757 The storage for an object of thread storage duration shall be
19758 statically initialized before the first statement of the thread startup
19759 function. An object of thread storage duration shall not require
19760 dynamic initialization.
19761 @end quotation
19762
19763 @item
19764 @b{[basic.start.term]}
19765
19766 Add after paragraph 3
19767
19768 @quotation
19769 The type of an object with thread storage duration shall not have a
19770 non-trivial destructor, nor shall it be an array type whose elements
19771 (directly or indirectly) have non-trivial destructors.
19772 @end quotation
19773
19774 @item
19775 @b{[basic.stc]}
19776
19777 Add ``thread storage duration'' to the list in paragraph 1.
19778
19779 Change paragraph 2
19780
19781 @quotation
19782 Thread, static, and automatic storage durations are associated with
19783 objects introduced by declarations [@dots{}].
19784 @end quotation
19785
19786 Add @code{__thread} to the list of specifiers in paragraph 3.
19787
19788 @item
19789 @b{[basic.stc.thread]}
19790
19791 New section before @b{[basic.stc.static]}
19792
19793 @quotation
19794 The keyword @code{__thread} applied to a non-local object gives the
19795 object thread storage duration.
19796
19797 A local variable or class data member declared both @code{static}
19798 and @code{__thread} gives the variable or member thread storage
19799 duration.
19800 @end quotation
19801
19802 @item
19803 @b{[basic.stc.static]}
19804
19805 Change paragraph 1
19806
19807 @quotation
19808 All objects that have neither thread storage duration, dynamic
19809 storage duration nor are local [@dots{}].
19810 @end quotation
19811
19812 @item
19813 @b{[dcl.stc]}
19814
19815 Add @code{__thread} to the list in paragraph 1.
19816
19817 Change paragraph 1
19818
19819 @quotation
19820 With the exception of @code{__thread}, at most one
19821 @var{storage-class-specifier} shall appear in a given
19822 @var{decl-specifier-seq}. The @code{__thread} specifier may
19823 be used alone, or immediately following the @code{extern} or
19824 @code{static} specifiers. [@dots{}]
19825 @end quotation
19826
19827 Add after paragraph 5
19828
19829 @quotation
19830 The @code{__thread} specifier can be applied only to the names of objects
19831 and to anonymous unions.
19832 @end quotation
19833
19834 @item
19835 @b{[class.mem]}
19836
19837 Add after paragraph 6
19838
19839 @quotation
19840 Non-@code{static} members shall not be @code{__thread}.
19841 @end quotation
19842 @end itemize
19843
19844 @node Binary constants
19845 @section Binary Constants using the @samp{0b} Prefix
19846 @cindex Binary constants using the @samp{0b} prefix
19847
19848 Integer constants can be written as binary constants, consisting of a
19849 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19850 @samp{0B}. This is particularly useful in environments that operate a
19851 lot on the bit level (like microcontrollers).
19852
19853 The following statements are identical:
19854
19855 @smallexample
19856 i = 42;
19857 i = 0x2a;
19858 i = 052;
19859 i = 0b101010;
19860 @end smallexample
19861
19862 The type of these constants follows the same rules as for octal or
19863 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19864 can be applied.
19865
19866 @node C++ Extensions
19867 @chapter Extensions to the C++ Language
19868 @cindex extensions, C++ language
19869 @cindex C++ language extensions
19870
19871 The GNU compiler provides these extensions to the C++ language (and you
19872 can also use most of the C language extensions in your C++ programs). If you
19873 want to write code that checks whether these features are available, you can
19874 test for the GNU compiler the same way as for C programs: check for a
19875 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19876 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19877 Predefined Macros,cpp,The GNU C Preprocessor}).
19878
19879 @menu
19880 * C++ Volatiles:: What constitutes an access to a volatile object.
19881 * Restricted Pointers:: C99 restricted pointers and references.
19882 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19883 * C++ Interface:: You can use a single C++ header file for both
19884 declarations and definitions.
19885 * Template Instantiation:: Methods for ensuring that exactly one copy of
19886 each needed template instantiation is emitted.
19887 * Bound member functions:: You can extract a function pointer to the
19888 method denoted by a @samp{->*} or @samp{.*} expression.
19889 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19890 * Function Multiversioning:: Declaring multiple function versions.
19891 * Namespace Association:: Strong using-directives for namespace association.
19892 * Type Traits:: Compiler support for type traits.
19893 * C++ Concepts:: Improved support for generic programming.
19894 * Java Exceptions:: Tweaking exception handling to work with Java.
19895 * Deprecated Features:: Things will disappear from G++.
19896 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19897 @end menu
19898
19899 @node C++ Volatiles
19900 @section When is a Volatile C++ Object Accessed?
19901 @cindex accessing volatiles
19902 @cindex volatile read
19903 @cindex volatile write
19904 @cindex volatile access
19905
19906 The C++ standard differs from the C standard in its treatment of
19907 volatile objects. It fails to specify what constitutes a volatile
19908 access, except to say that C++ should behave in a similar manner to C
19909 with respect to volatiles, where possible. However, the different
19910 lvalueness of expressions between C and C++ complicate the behavior.
19911 G++ behaves the same as GCC for volatile access, @xref{C
19912 Extensions,,Volatiles}, for a description of GCC's behavior.
19913
19914 The C and C++ language specifications differ when an object is
19915 accessed in a void context:
19916
19917 @smallexample
19918 volatile int *src = @var{somevalue};
19919 *src;
19920 @end smallexample
19921
19922 The C++ standard specifies that such expressions do not undergo lvalue
19923 to rvalue conversion, and that the type of the dereferenced object may
19924 be incomplete. The C++ standard does not specify explicitly that it
19925 is lvalue to rvalue conversion that is responsible for causing an
19926 access. There is reason to believe that it is, because otherwise
19927 certain simple expressions become undefined. However, because it
19928 would surprise most programmers, G++ treats dereferencing a pointer to
19929 volatile object of complete type as GCC would do for an equivalent
19930 type in C@. When the object has incomplete type, G++ issues a
19931 warning; if you wish to force an error, you must force a conversion to
19932 rvalue with, for instance, a static cast.
19933
19934 When using a reference to volatile, G++ does not treat equivalent
19935 expressions as accesses to volatiles, but instead issues a warning that
19936 no volatile is accessed. The rationale for this is that otherwise it
19937 becomes difficult to determine where volatile access occur, and not
19938 possible to ignore the return value from functions returning volatile
19939 references. Again, if you wish to force a read, cast the reference to
19940 an rvalue.
19941
19942 G++ implements the same behavior as GCC does when assigning to a
19943 volatile object---there is no reread of the assigned-to object, the
19944 assigned rvalue is reused. Note that in C++ assignment expressions
19945 are lvalues, and if used as an lvalue, the volatile object is
19946 referred to. For instance, @var{vref} refers to @var{vobj}, as
19947 expected, in the following example:
19948
19949 @smallexample
19950 volatile int vobj;
19951 volatile int &vref = vobj = @var{something};
19952 @end smallexample
19953
19954 @node Restricted Pointers
19955 @section Restricting Pointer Aliasing
19956 @cindex restricted pointers
19957 @cindex restricted references
19958 @cindex restricted this pointer
19959
19960 As with the C front end, G++ understands the C99 feature of restricted pointers,
19961 specified with the @code{__restrict__}, or @code{__restrict} type
19962 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19963 language flag, @code{restrict} is not a keyword in C++.
19964
19965 In addition to allowing restricted pointers, you can specify restricted
19966 references, which indicate that the reference is not aliased in the local
19967 context.
19968
19969 @smallexample
19970 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19971 @{
19972 /* @r{@dots{}} */
19973 @}
19974 @end smallexample
19975
19976 @noindent
19977 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19978 @var{rref} refers to a (different) unaliased integer.
19979
19980 You may also specify whether a member function's @var{this} pointer is
19981 unaliased by using @code{__restrict__} as a member function qualifier.
19982
19983 @smallexample
19984 void T::fn () __restrict__
19985 @{
19986 /* @r{@dots{}} */
19987 @}
19988 @end smallexample
19989
19990 @noindent
19991 Within the body of @code{T::fn}, @var{this} has the effective
19992 definition @code{T *__restrict__ const this}. Notice that the
19993 interpretation of a @code{__restrict__} member function qualifier is
19994 different to that of @code{const} or @code{volatile} qualifier, in that it
19995 is applied to the pointer rather than the object. This is consistent with
19996 other compilers that implement restricted pointers.
19997
19998 As with all outermost parameter qualifiers, @code{__restrict__} is
19999 ignored in function definition matching. This means you only need to
20000 specify @code{__restrict__} in a function definition, rather than
20001 in a function prototype as well.
20002
20003 @node Vague Linkage
20004 @section Vague Linkage
20005 @cindex vague linkage
20006
20007 There are several constructs in C++ that require space in the object
20008 file but are not clearly tied to a single translation unit. We say that
20009 these constructs have ``vague linkage''. Typically such constructs are
20010 emitted wherever they are needed, though sometimes we can be more
20011 clever.
20012
20013 @table @asis
20014 @item Inline Functions
20015 Inline functions are typically defined in a header file which can be
20016 included in many different compilations. Hopefully they can usually be
20017 inlined, but sometimes an out-of-line copy is necessary, if the address
20018 of the function is taken or if inlining fails. In general, we emit an
20019 out-of-line copy in all translation units where one is needed. As an
20020 exception, we only emit inline virtual functions with the vtable, since
20021 it always requires a copy.
20022
20023 Local static variables and string constants used in an inline function
20024 are also considered to have vague linkage, since they must be shared
20025 between all inlined and out-of-line instances of the function.
20026
20027 @item VTables
20028 @cindex vtable
20029 C++ virtual functions are implemented in most compilers using a lookup
20030 table, known as a vtable. The vtable contains pointers to the virtual
20031 functions provided by a class, and each object of the class contains a
20032 pointer to its vtable (or vtables, in some multiple-inheritance
20033 situations). If the class declares any non-inline, non-pure virtual
20034 functions, the first one is chosen as the ``key method'' for the class,
20035 and the vtable is only emitted in the translation unit where the key
20036 method is defined.
20037
20038 @emph{Note:} If the chosen key method is later defined as inline, the
20039 vtable is still emitted in every translation unit that defines it.
20040 Make sure that any inline virtuals are declared inline in the class
20041 body, even if they are not defined there.
20042
20043 @item @code{type_info} objects
20044 @cindex @code{type_info}
20045 @cindex RTTI
20046 C++ requires information about types to be written out in order to
20047 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
20048 For polymorphic classes (classes with virtual functions), the @samp{type_info}
20049 object is written out along with the vtable so that @samp{dynamic_cast}
20050 can determine the dynamic type of a class object at run time. For all
20051 other types, we write out the @samp{type_info} object when it is used: when
20052 applying @samp{typeid} to an expression, throwing an object, or
20053 referring to a type in a catch clause or exception specification.
20054
20055 @item Template Instantiations
20056 Most everything in this section also applies to template instantiations,
20057 but there are other options as well.
20058 @xref{Template Instantiation,,Where's the Template?}.
20059
20060 @end table
20061
20062 When used with GNU ld version 2.8 or later on an ELF system such as
20063 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
20064 these constructs will be discarded at link time. This is known as
20065 COMDAT support.
20066
20067 On targets that don't support COMDAT, but do support weak symbols, GCC
20068 uses them. This way one copy overrides all the others, but
20069 the unused copies still take up space in the executable.
20070
20071 For targets that do not support either COMDAT or weak symbols,
20072 most entities with vague linkage are emitted as local symbols to
20073 avoid duplicate definition errors from the linker. This does not happen
20074 for local statics in inlines, however, as having multiple copies
20075 almost certainly breaks things.
20076
20077 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
20078 another way to control placement of these constructs.
20079
20080 @node C++ Interface
20081 @section C++ Interface and Implementation Pragmas
20082
20083 @cindex interface and implementation headers, C++
20084 @cindex C++ interface and implementation headers
20085 @cindex pragmas, interface and implementation
20086
20087 @code{#pragma interface} and @code{#pragma implementation} provide the
20088 user with a way of explicitly directing the compiler to emit entities
20089 with vague linkage (and debugging information) in a particular
20090 translation unit.
20091
20092 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
20093 by COMDAT support and the ``key method'' heuristic
20094 mentioned in @ref{Vague Linkage}. Using them can actually cause your
20095 program to grow due to unnecessary out-of-line copies of inline
20096 functions.
20097
20098 @table @code
20099 @item #pragma interface
20100 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
20101 @kindex #pragma interface
20102 Use this directive in @emph{header files} that define object classes, to save
20103 space in most of the object files that use those classes. Normally,
20104 local copies of certain information (backup copies of inline member
20105 functions, debugging information, and the internal tables that implement
20106 virtual functions) must be kept in each object file that includes class
20107 definitions. You can use this pragma to avoid such duplication. When a
20108 header file containing @samp{#pragma interface} is included in a
20109 compilation, this auxiliary information is not generated (unless
20110 the main input source file itself uses @samp{#pragma implementation}).
20111 Instead, the object files contain references to be resolved at link
20112 time.
20113
20114 The second form of this directive is useful for the case where you have
20115 multiple headers with the same name in different directories. If you
20116 use this form, you must specify the same string to @samp{#pragma
20117 implementation}.
20118
20119 @item #pragma implementation
20120 @itemx #pragma implementation "@var{objects}.h"
20121 @kindex #pragma implementation
20122 Use this pragma in a @emph{main input file}, when you want full output from
20123 included header files to be generated (and made globally visible). The
20124 included header file, in turn, should use @samp{#pragma interface}.
20125 Backup copies of inline member functions, debugging information, and the
20126 internal tables used to implement virtual functions are all generated in
20127 implementation files.
20128
20129 @cindex implied @code{#pragma implementation}
20130 @cindex @code{#pragma implementation}, implied
20131 @cindex naming convention, implementation headers
20132 If you use @samp{#pragma implementation} with no argument, it applies to
20133 an include file with the same basename@footnote{A file's @dfn{basename}
20134 is the name stripped of all leading path information and of trailing
20135 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
20136 file. For example, in @file{allclass.cc}, giving just
20137 @samp{#pragma implementation}
20138 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
20139
20140 Use the string argument if you want a single implementation file to
20141 include code from multiple header files. (You must also use
20142 @samp{#include} to include the header file; @samp{#pragma
20143 implementation} only specifies how to use the file---it doesn't actually
20144 include it.)
20145
20146 There is no way to split up the contents of a single header file into
20147 multiple implementation files.
20148 @end table
20149
20150 @cindex inlining and C++ pragmas
20151 @cindex C++ pragmas, effect on inlining
20152 @cindex pragmas in C++, effect on inlining
20153 @samp{#pragma implementation} and @samp{#pragma interface} also have an
20154 effect on function inlining.
20155
20156 If you define a class in a header file marked with @samp{#pragma
20157 interface}, the effect on an inline function defined in that class is
20158 similar to an explicit @code{extern} declaration---the compiler emits
20159 no code at all to define an independent version of the function. Its
20160 definition is used only for inlining with its callers.
20161
20162 @opindex fno-implement-inlines
20163 Conversely, when you include the same header file in a main source file
20164 that declares it as @samp{#pragma implementation}, the compiler emits
20165 code for the function itself; this defines a version of the function
20166 that can be found via pointers (or by callers compiled without
20167 inlining). If all calls to the function can be inlined, you can avoid
20168 emitting the function by compiling with @option{-fno-implement-inlines}.
20169 If any calls are not inlined, you will get linker errors.
20170
20171 @node Template Instantiation
20172 @section Where's the Template?
20173 @cindex template instantiation
20174
20175 C++ templates were the first language feature to require more
20176 intelligence from the environment than was traditionally found on a UNIX
20177 system. Somehow the compiler and linker have to make sure that each
20178 template instance occurs exactly once in the executable if it is needed,
20179 and not at all otherwise. There are two basic approaches to this
20180 problem, which are referred to as the Borland model and the Cfront model.
20181
20182 @table @asis
20183 @item Borland model
20184 Borland C++ solved the template instantiation problem by adding the code
20185 equivalent of common blocks to their linker; the compiler emits template
20186 instances in each translation unit that uses them, and the linker
20187 collapses them together. The advantage of this model is that the linker
20188 only has to consider the object files themselves; there is no external
20189 complexity to worry about. The disadvantage is that compilation time
20190 is increased because the template code is being compiled repeatedly.
20191 Code written for this model tends to include definitions of all
20192 templates in the header file, since they must be seen to be
20193 instantiated.
20194
20195 @item Cfront model
20196 The AT&T C++ translator, Cfront, solved the template instantiation
20197 problem by creating the notion of a template repository, an
20198 automatically maintained place where template instances are stored. A
20199 more modern version of the repository works as follows: As individual
20200 object files are built, the compiler places any template definitions and
20201 instantiations encountered in the repository. At link time, the link
20202 wrapper adds in the objects in the repository and compiles any needed
20203 instances that were not previously emitted. The advantages of this
20204 model are more optimal compilation speed and the ability to use the
20205 system linker; to implement the Borland model a compiler vendor also
20206 needs to replace the linker. The disadvantages are vastly increased
20207 complexity, and thus potential for error; for some code this can be
20208 just as transparent, but in practice it can been very difficult to build
20209 multiple programs in one directory and one program in multiple
20210 directories. Code written for this model tends to separate definitions
20211 of non-inline member templates into a separate file, which should be
20212 compiled separately.
20213 @end table
20214
20215 G++ implements the Borland model on targets where the linker supports it,
20216 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
20217 Otherwise G++ implements neither automatic model.
20218
20219 You have the following options for dealing with template instantiations:
20220
20221 @enumerate
20222 @item
20223 Do nothing. Code written for the Borland model works fine, but
20224 each translation unit contains instances of each of the templates it
20225 uses. The duplicate instances will be discarded by the linker, but in
20226 a large program, this can lead to an unacceptable amount of code
20227 duplication in object files or shared libraries.
20228
20229 Duplicate instances of a template can be avoided by defining an explicit
20230 instantiation in one object file, and preventing the compiler from doing
20231 implicit instantiations in any other object files by using an explicit
20232 instantiation declaration, using the @code{extern template} syntax:
20233
20234 @smallexample
20235 extern template int max (int, int);
20236 @end smallexample
20237
20238 This syntax is defined in the C++ 2011 standard, but has been supported by
20239 G++ and other compilers since well before 2011.
20240
20241 Explicit instantiations can be used for the largest or most frequently
20242 duplicated instances, without having to know exactly which other instances
20243 are used in the rest of the program. You can scatter the explicit
20244 instantiations throughout your program, perhaps putting them in the
20245 translation units where the instances are used or the translation units
20246 that define the templates themselves; you can put all of the explicit
20247 instantiations you need into one big file; or you can create small files
20248 like
20249
20250 @smallexample
20251 #include "Foo.h"
20252 #include "Foo.cc"
20253
20254 template class Foo<int>;
20255 template ostream& operator <<
20256 (ostream&, const Foo<int>&);
20257 @end smallexample
20258
20259 @noindent
20260 for each of the instances you need, and create a template instantiation
20261 library from those.
20262
20263 This is the simplest option, but also offers flexibility and
20264 fine-grained control when necessary. It is also the most portable
20265 alternative and programs using this approach will work with most modern
20266 compilers.
20267
20268 @item
20269 @opindex frepo
20270 Compile your template-using code with @option{-frepo}. The compiler
20271 generates files with the extension @samp{.rpo} listing all of the
20272 template instantiations used in the corresponding object files that
20273 could be instantiated there; the link wrapper, @samp{collect2},
20274 then updates the @samp{.rpo} files to tell the compiler where to place
20275 those instantiations and rebuild any affected object files. The
20276 link-time overhead is negligible after the first pass, as the compiler
20277 continues to place the instantiations in the same files.
20278
20279 This can be a suitable option for application code written for the Borland
20280 model, as it usually just works. Code written for the Cfront model
20281 needs to be modified so that the template definitions are available at
20282 one or more points of instantiation; usually this is as simple as adding
20283 @code{#include <tmethods.cc>} to the end of each template header.
20284
20285 For library code, if you want the library to provide all of the template
20286 instantiations it needs, just try to link all of its object files
20287 together; the link will fail, but cause the instantiations to be
20288 generated as a side effect. Be warned, however, that this may cause
20289 conflicts if multiple libraries try to provide the same instantiations.
20290 For greater control, use explicit instantiation as described in the next
20291 option.
20292
20293 @item
20294 @opindex fno-implicit-templates
20295 Compile your code with @option{-fno-implicit-templates} to disable the
20296 implicit generation of template instances, and explicitly instantiate
20297 all the ones you use. This approach requires more knowledge of exactly
20298 which instances you need than do the others, but it's less
20299 mysterious and allows greater control if you want to ensure that only
20300 the intended instances are used.
20301
20302 If you are using Cfront-model code, you can probably get away with not
20303 using @option{-fno-implicit-templates} when compiling files that don't
20304 @samp{#include} the member template definitions.
20305
20306 If you use one big file to do the instantiations, you may want to
20307 compile it without @option{-fno-implicit-templates} so you get all of the
20308 instances required by your explicit instantiations (but not by any
20309 other files) without having to specify them as well.
20310
20311 In addition to forward declaration of explicit instantiations
20312 (with @code{extern}), G++ has extended the template instantiation
20313 syntax to support instantiation of the compiler support data for a
20314 template class (i.e.@: the vtable) without instantiating any of its
20315 members (with @code{inline}), and instantiation of only the static data
20316 members of a template class, without the support data or member
20317 functions (with @code{static}):
20318
20319 @smallexample
20320 inline template class Foo<int>;
20321 static template class Foo<int>;
20322 @end smallexample
20323 @end enumerate
20324
20325 @node Bound member functions
20326 @section Extracting the Function Pointer from a Bound Pointer to Member Function
20327 @cindex pmf
20328 @cindex pointer to member function
20329 @cindex bound pointer to member function
20330
20331 In C++, pointer to member functions (PMFs) are implemented using a wide
20332 pointer of sorts to handle all the possible call mechanisms; the PMF
20333 needs to store information about how to adjust the @samp{this} pointer,
20334 and if the function pointed to is virtual, where to find the vtable, and
20335 where in the vtable to look for the member function. If you are using
20336 PMFs in an inner loop, you should really reconsider that decision. If
20337 that is not an option, you can extract the pointer to the function that
20338 would be called for a given object/PMF pair and call it directly inside
20339 the inner loop, to save a bit of time.
20340
20341 Note that you still pay the penalty for the call through a
20342 function pointer; on most modern architectures, such a call defeats the
20343 branch prediction features of the CPU@. This is also true of normal
20344 virtual function calls.
20345
20346 The syntax for this extension is
20347
20348 @smallexample
20349 extern A a;
20350 extern int (A::*fp)();
20351 typedef int (*fptr)(A *);
20352
20353 fptr p = (fptr)(a.*fp);
20354 @end smallexample
20355
20356 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
20357 no object is needed to obtain the address of the function. They can be
20358 converted to function pointers directly:
20359
20360 @smallexample
20361 fptr p1 = (fptr)(&A::foo);
20362 @end smallexample
20363
20364 @opindex Wno-pmf-conversions
20365 You must specify @option{-Wno-pmf-conversions} to use this extension.
20366
20367 @node C++ Attributes
20368 @section C++-Specific Variable, Function, and Type Attributes
20369
20370 Some attributes only make sense for C++ programs.
20371
20372 @table @code
20373 @item abi_tag ("@var{tag}", ...)
20374 @cindex @code{abi_tag} function attribute
20375 @cindex @code{abi_tag} variable attribute
20376 @cindex @code{abi_tag} type attribute
20377 The @code{abi_tag} attribute can be applied to a function, variable, or class
20378 declaration. It modifies the mangled name of the entity to
20379 incorporate the tag name, in order to distinguish the function or
20380 class from an earlier version with a different ABI; perhaps the class
20381 has changed size, or the function has a different return type that is
20382 not encoded in the mangled name.
20383
20384 The attribute can also be applied to an inline namespace, but does not
20385 affect the mangled name of the namespace; in this case it is only used
20386 for @option{-Wabi-tag} warnings and automatic tagging of functions and
20387 variables. Tagging inline namespaces is generally preferable to
20388 tagging individual declarations, but the latter is sometimes
20389 necessary, such as when only certain members of a class need to be
20390 tagged.
20391
20392 The argument can be a list of strings of arbitrary length. The
20393 strings are sorted on output, so the order of the list is
20394 unimportant.
20395
20396 A redeclaration of an entity must not add new ABI tags,
20397 since doing so would change the mangled name.
20398
20399 The ABI tags apply to a name, so all instantiations and
20400 specializations of a template have the same tags. The attribute will
20401 be ignored if applied to an explicit specialization or instantiation.
20402
20403 The @option{-Wabi-tag} flag enables a warning about a class which does
20404 not have all the ABI tags used by its subobjects and virtual functions; for users with code
20405 that needs to coexist with an earlier ABI, using this option can help
20406 to find all affected types that need to be tagged.
20407
20408 When a type involving an ABI tag is used as the type of a variable or
20409 return type of a function where that tag is not already present in the
20410 signature of the function, the tag is automatically applied to the
20411 variable or function. @option{-Wabi-tag} also warns about this
20412 situation; this warning can be avoided by explicitly tagging the
20413 variable or function or moving it into a tagged inline namespace.
20414
20415 @item init_priority (@var{priority})
20416 @cindex @code{init_priority} variable attribute
20417
20418 In Standard C++, objects defined at namespace scope are guaranteed to be
20419 initialized in an order in strict accordance with that of their definitions
20420 @emph{in a given translation unit}. No guarantee is made for initializations
20421 across translation units. However, GNU C++ allows users to control the
20422 order of initialization of objects defined at namespace scope with the
20423 @code{init_priority} attribute by specifying a relative @var{priority},
20424 a constant integral expression currently bounded between 101 and 65535
20425 inclusive. Lower numbers indicate a higher priority.
20426
20427 In the following example, @code{A} would normally be created before
20428 @code{B}, but the @code{init_priority} attribute reverses that order:
20429
20430 @smallexample
20431 Some_Class A __attribute__ ((init_priority (2000)));
20432 Some_Class B __attribute__ ((init_priority (543)));
20433 @end smallexample
20434
20435 @noindent
20436 Note that the particular values of @var{priority} do not matter; only their
20437 relative ordering.
20438
20439 @item java_interface
20440 @cindex @code{java_interface} type attribute
20441
20442 This type attribute informs C++ that the class is a Java interface. It may
20443 only be applied to classes declared within an @code{extern "Java"} block.
20444 Calls to methods declared in this interface are dispatched using GCJ's
20445 interface table mechanism, instead of regular virtual table dispatch.
20446
20447 @item warn_unused
20448 @cindex @code{warn_unused} type attribute
20449
20450 For C++ types with non-trivial constructors and/or destructors it is
20451 impossible for the compiler to determine whether a variable of this
20452 type is truly unused if it is not referenced. This type attribute
20453 informs the compiler that variables of this type should be warned
20454 about if they appear to be unused, just like variables of fundamental
20455 types.
20456
20457 This attribute is appropriate for types which just represent a value,
20458 such as @code{std::string}; it is not appropriate for types which
20459 control a resource, such as @code{std::lock_guard}.
20460
20461 This attribute is also accepted in C, but it is unnecessary because C
20462 does not have constructors or destructors.
20463
20464 @end table
20465
20466 See also @ref{Namespace Association}.
20467
20468 @node Function Multiversioning
20469 @section Function Multiversioning
20470 @cindex function versions
20471
20472 With the GNU C++ front end, for x86 targets, you may specify multiple
20473 versions of a function, where each function is specialized for a
20474 specific target feature. At runtime, the appropriate version of the
20475 function is automatically executed depending on the characteristics of
20476 the execution platform. Here is an example.
20477
20478 @smallexample
20479 __attribute__ ((target ("default")))
20480 int foo ()
20481 @{
20482 // The default version of foo.
20483 return 0;
20484 @}
20485
20486 __attribute__ ((target ("sse4.2")))
20487 int foo ()
20488 @{
20489 // foo version for SSE4.2
20490 return 1;
20491 @}
20492
20493 __attribute__ ((target ("arch=atom")))
20494 int foo ()
20495 @{
20496 // foo version for the Intel ATOM processor
20497 return 2;
20498 @}
20499
20500 __attribute__ ((target ("arch=amdfam10")))
20501 int foo ()
20502 @{
20503 // foo version for the AMD Family 0x10 processors.
20504 return 3;
20505 @}
20506
20507 int main ()
20508 @{
20509 int (*p)() = &foo;
20510 assert ((*p) () == foo ());
20511 return 0;
20512 @}
20513 @end smallexample
20514
20515 In the above example, four versions of function foo are created. The
20516 first version of foo with the target attribute "default" is the default
20517 version. This version gets executed when no other target specific
20518 version qualifies for execution on a particular platform. A new version
20519 of foo is created by using the same function signature but with a
20520 different target string. Function foo is called or a pointer to it is
20521 taken just like a regular function. GCC takes care of doing the
20522 dispatching to call the right version at runtime. Refer to the
20523 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20524 Function Multiversioning} for more details.
20525
20526 @node Namespace Association
20527 @section Namespace Association
20528
20529 @strong{Caution:} The semantics of this extension are equivalent
20530 to C++ 2011 inline namespaces. Users should use inline namespaces
20531 instead as this extension will be removed in future versions of G++.
20532
20533 A using-directive with @code{__attribute ((strong))} is stronger
20534 than a normal using-directive in two ways:
20535
20536 @itemize @bullet
20537 @item
20538 Templates from the used namespace can be specialized and explicitly
20539 instantiated as though they were members of the using namespace.
20540
20541 @item
20542 The using namespace is considered an associated namespace of all
20543 templates in the used namespace for purposes of argument-dependent
20544 name lookup.
20545 @end itemize
20546
20547 The used namespace must be nested within the using namespace so that
20548 normal unqualified lookup works properly.
20549
20550 This is useful for composing a namespace transparently from
20551 implementation namespaces. For example:
20552
20553 @smallexample
20554 namespace std @{
20555 namespace debug @{
20556 template <class T> struct A @{ @};
20557 @}
20558 using namespace debug __attribute ((__strong__));
20559 template <> struct A<int> @{ @}; // @r{OK to specialize}
20560
20561 template <class T> void f (A<T>);
20562 @}
20563
20564 int main()
20565 @{
20566 f (std::A<float>()); // @r{lookup finds} std::f
20567 f (std::A<int>());
20568 @}
20569 @end smallexample
20570
20571 @node Type Traits
20572 @section Type Traits
20573
20574 The C++ front end implements syntactic extensions that allow
20575 compile-time determination of
20576 various characteristics of a type (or of a
20577 pair of types).
20578
20579 @table @code
20580 @item __has_nothrow_assign (type)
20581 If @code{type} is const qualified or is a reference type then the trait is
20582 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20583 is true, else if @code{type} is a cv class or union type with copy assignment
20584 operators that are known not to throw an exception then the trait is true,
20585 else it is false. Requires: @code{type} shall be a complete type,
20586 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20587
20588 @item __has_nothrow_copy (type)
20589 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20590 @code{type} is a cv class or union type with copy constructors that
20591 are known not to throw an exception then the trait is true, else it is false.
20592 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20593 @code{void}, or an array of unknown bound.
20594
20595 @item __has_nothrow_constructor (type)
20596 If @code{__has_trivial_constructor (type)} is true then the trait is
20597 true, else if @code{type} is a cv class or union type (or array
20598 thereof) with a default constructor that is known not to throw an
20599 exception then the trait is true, else it is false. Requires:
20600 @code{type} shall be a complete type, (possibly cv-qualified)
20601 @code{void}, or an array of unknown bound.
20602
20603 @item __has_trivial_assign (type)
20604 If @code{type} is const qualified or is a reference type then the trait is
20605 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20606 true, else if @code{type} is a cv class or union type with a trivial
20607 copy assignment ([class.copy]) then the trait is true, else it is
20608 false. Requires: @code{type} shall be a complete type, (possibly
20609 cv-qualified) @code{void}, or an array of unknown bound.
20610
20611 @item __has_trivial_copy (type)
20612 If @code{__is_pod (type)} is true or @code{type} is a reference type
20613 then the trait is true, else if @code{type} is a cv class or union type
20614 with a trivial copy constructor ([class.copy]) then the trait
20615 is true, else it is false. Requires: @code{type} shall be a complete
20616 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20617
20618 @item __has_trivial_constructor (type)
20619 If @code{__is_pod (type)} is true then the trait is true, else if
20620 @code{type} is a cv class or union type (or array thereof) with a
20621 trivial default constructor ([class.ctor]) then the trait is true,
20622 else it is false. Requires: @code{type} shall be a complete
20623 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20624
20625 @item __has_trivial_destructor (type)
20626 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20627 the trait is true, else if @code{type} is a cv class or union type (or
20628 array thereof) with a trivial destructor ([class.dtor]) then the trait
20629 is true, else it is false. Requires: @code{type} shall be a complete
20630 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20631
20632 @item __has_virtual_destructor (type)
20633 If @code{type} is a class type with a virtual destructor
20634 ([class.dtor]) then the trait is true, else it is false. Requires:
20635 @code{type} shall be a complete type, (possibly cv-qualified)
20636 @code{void}, or an array of unknown bound.
20637
20638 @item __is_abstract (type)
20639 If @code{type} is an abstract class ([class.abstract]) then the trait
20640 is true, else it is false. Requires: @code{type} shall be a complete
20641 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20642
20643 @item __is_base_of (base_type, derived_type)
20644 If @code{base_type} is a base class of @code{derived_type}
20645 ([class.derived]) then the trait is true, otherwise it is false.
20646 Top-level cv qualifications of @code{base_type} and
20647 @code{derived_type} are ignored. For the purposes of this trait, a
20648 class type is considered is own base. Requires: if @code{__is_class
20649 (base_type)} and @code{__is_class (derived_type)} are true and
20650 @code{base_type} and @code{derived_type} are not the same type
20651 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20652 type. A diagnostic is produced if this requirement is not met.
20653
20654 @item __is_class (type)
20655 If @code{type} is a cv class type, and not a union type
20656 ([basic.compound]) the trait is true, else it is false.
20657
20658 @item __is_empty (type)
20659 If @code{__is_class (type)} is false then the trait is false.
20660 Otherwise @code{type} is considered empty if and only if: @code{type}
20661 has no non-static data members, or all non-static data members, if
20662 any, are bit-fields of length 0, and @code{type} has no virtual
20663 members, and @code{type} has no virtual base classes, and @code{type}
20664 has no base classes @code{base_type} for which
20665 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20666 be a complete type, (possibly cv-qualified) @code{void}, or an array
20667 of unknown bound.
20668
20669 @item __is_enum (type)
20670 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20671 true, else it is false.
20672
20673 @item __is_literal_type (type)
20674 If @code{type} is a literal type ([basic.types]) the trait is
20675 true, else it is false. Requires: @code{type} shall be a complete type,
20676 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20677
20678 @item __is_pod (type)
20679 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20680 else it is false. Requires: @code{type} shall be a complete type,
20681 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20682
20683 @item __is_polymorphic (type)
20684 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20685 is true, else it is false. Requires: @code{type} shall be a complete
20686 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20687
20688 @item __is_standard_layout (type)
20689 If @code{type} is a standard-layout type ([basic.types]) the trait is
20690 true, else it is false. Requires: @code{type} shall be a complete
20691 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20692
20693 @item __is_trivial (type)
20694 If @code{type} is a trivial type ([basic.types]) the trait is
20695 true, else it is false. Requires: @code{type} shall be a complete
20696 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20697
20698 @item __is_union (type)
20699 If @code{type} is a cv union type ([basic.compound]) the trait is
20700 true, else it is false.
20701
20702 @item __underlying_type (type)
20703 The underlying type of @code{type}. Requires: @code{type} shall be
20704 an enumeration type ([dcl.enum]).
20705
20706 @end table
20707
20708
20709 @node C++ Concepts
20710 @section C++ Concepts
20711
20712 C++ concepts provide much-improved support for generic programming. In
20713 particular, they allow the specification of constraints on template arguments.
20714 The constraints are used to extend the usual overloading and partial
20715 specialization capabilities of the language, allowing generic data structures
20716 and algorithms to be ``refined'' based on their properties rather than their
20717 type names.
20718
20719 The following keywords are reserved for concepts.
20720
20721 @table @code
20722 @item assumes
20723 States an expression as an assumption, and if possible, verifies that the
20724 assumption is valid. For example, @code{assume(n > 0)}.
20725
20726 @item axiom
20727 Introduces an axiom definition. Axioms introduce requirements on values.
20728
20729 @item forall
20730 Introduces a universally quantified object in an axiom. For example,
20731 @code{forall (int n) n + 0 == n}).
20732
20733 @item concept
20734 Introduces a concept definition. Concepts are sets of syntactic and semantic
20735 requirements on types and their values.
20736
20737 @item requires
20738 Introduces constraints on template arguments or requirements for a member
20739 function of a class template.
20740
20741 @end table
20742
20743 The front end also exposes a number of internal mechanism that can be used
20744 to simplify the writing of type traits. Note that some of these traits are
20745 likely to be removed in the future.
20746
20747 @table @code
20748 @item __is_same (type1, type2)
20749 A binary type trait: true whenever the type arguments are the same.
20750
20751 @end table
20752
20753
20754 @node Java Exceptions
20755 @section Java Exceptions
20756
20757 The Java language uses a slightly different exception handling model
20758 from C++. Normally, GNU C++ automatically detects when you are
20759 writing C++ code that uses Java exceptions, and handle them
20760 appropriately. However, if C++ code only needs to execute destructors
20761 when Java exceptions are thrown through it, GCC guesses incorrectly.
20762 Sample problematic code is:
20763
20764 @smallexample
20765 struct S @{ ~S(); @};
20766 extern void bar(); // @r{is written in Java, and may throw exceptions}
20767 void foo()
20768 @{
20769 S s;
20770 bar();
20771 @}
20772 @end smallexample
20773
20774 @noindent
20775 The usual effect of an incorrect guess is a link failure, complaining of
20776 a missing routine called @samp{__gxx_personality_v0}.
20777
20778 You can inform the compiler that Java exceptions are to be used in a
20779 translation unit, irrespective of what it might think, by writing
20780 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20781 @samp{#pragma} must appear before any functions that throw or catch
20782 exceptions, or run destructors when exceptions are thrown through them.
20783
20784 You cannot mix Java and C++ exceptions in the same translation unit. It
20785 is believed to be safe to throw a C++ exception from one file through
20786 another file compiled for the Java exception model, or vice versa, but
20787 there may be bugs in this area.
20788
20789 @node Deprecated Features
20790 @section Deprecated Features
20791
20792 In the past, the GNU C++ compiler was extended to experiment with new
20793 features, at a time when the C++ language was still evolving. Now that
20794 the C++ standard is complete, some of those features are superseded by
20795 superior alternatives. Using the old features might cause a warning in
20796 some cases that the feature will be dropped in the future. In other
20797 cases, the feature might be gone already.
20798
20799 While the list below is not exhaustive, it documents some of the options
20800 that are now deprecated:
20801
20802 @table @code
20803 @item -fexternal-templates
20804 @itemx -falt-external-templates
20805 These are two of the many ways for G++ to implement template
20806 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20807 defines how template definitions have to be organized across
20808 implementation units. G++ has an implicit instantiation mechanism that
20809 should work just fine for standard-conforming code.
20810
20811 @item -fstrict-prototype
20812 @itemx -fno-strict-prototype
20813 Previously it was possible to use an empty prototype parameter list to
20814 indicate an unspecified number of parameters (like C), rather than no
20815 parameters, as C++ demands. This feature has been removed, except where
20816 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20817 @end table
20818
20819 G++ allows a virtual function returning @samp{void *} to be overridden
20820 by one returning a different pointer type. This extension to the
20821 covariant return type rules is now deprecated and will be removed from a
20822 future version.
20823
20824 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20825 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20826 and are now removed from G++. Code using these operators should be
20827 modified to use @code{std::min} and @code{std::max} instead.
20828
20829 The named return value extension has been deprecated, and is now
20830 removed from G++.
20831
20832 The use of initializer lists with new expressions has been deprecated,
20833 and is now removed from G++.
20834
20835 Floating and complex non-type template parameters have been deprecated,
20836 and are now removed from G++.
20837
20838 The implicit typename extension has been deprecated and is now
20839 removed from G++.
20840
20841 The use of default arguments in function pointers, function typedefs
20842 and other places where they are not permitted by the standard is
20843 deprecated and will be removed from a future version of G++.
20844
20845 G++ allows floating-point literals to appear in integral constant expressions,
20846 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20847 This extension is deprecated and will be removed from a future version.
20848
20849 G++ allows static data members of const floating-point type to be declared
20850 with an initializer in a class definition. The standard only allows
20851 initializers for static members of const integral types and const
20852 enumeration types so this extension has been deprecated and will be removed
20853 from a future version.
20854
20855 @node Backwards Compatibility
20856 @section Backwards Compatibility
20857 @cindex Backwards Compatibility
20858 @cindex ARM [Annotated C++ Reference Manual]
20859
20860 Now that there is a definitive ISO standard C++, G++ has a specification
20861 to adhere to. The C++ language evolved over time, and features that
20862 used to be acceptable in previous drafts of the standard, such as the ARM
20863 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20864 compilation of C++ written to such drafts, G++ contains some backwards
20865 compatibilities. @emph{All such backwards compatibility features are
20866 liable to disappear in future versions of G++.} They should be considered
20867 deprecated. @xref{Deprecated Features}.
20868
20869 @table @code
20870 @item For scope
20871 If a variable is declared at for scope, it used to remain in scope until
20872 the end of the scope that contained the for statement (rather than just
20873 within the for scope). G++ retains this, but issues a warning, if such a
20874 variable is accessed outside the for scope.
20875
20876 @item Implicit C language
20877 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20878 scope to set the language. On such systems, all header files are
20879 implicitly scoped inside a C language scope. Also, an empty prototype
20880 @code{()} is treated as an unspecified number of arguments, rather
20881 than no arguments, as C++ demands.
20882 @end table
20883
20884 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20885 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr