Mention clog10{,f,l} in documentation (Builtins section)
[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 On PowerPC 64-bit Linux systems there are currently problems in using
958 the complex @code{__float128} type. When these problems are fixed,
959 you would use:
960
961 @smallexample
962 typedef _Complex float __attribute__((mode(KC))) _Complex128;
963 @end smallexample
964
965 Not all targets support additional floating-point types.
966 @code{__float80} and @code{__float128} types are supported on x86 and
967 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
968 The @code{__float128} type is supported on PowerPC 64-bit Linux
969 systems by default if the vector scalar instruction set (VSX) is
970 enabled.
971
972 On the PowerPC, @code{__ibm128} provides access to the IBM extended
973 double format, and it is intended to be used by the library functions
974 that handle conversions if/when long double is changed to be IEEE
975 128-bit floating point.
976
977 @node Half-Precision
978 @section Half-Precision Floating Point
979 @cindex half-precision floating point
980 @cindex @code{__fp16} data type
981
982 On ARM targets, GCC supports half-precision (16-bit) floating point via
983 the @code{__fp16} type. You must enable this type explicitly
984 with the @option{-mfp16-format} command-line option in order to use it.
985
986 ARM supports two incompatible representations for half-precision
987 floating-point values. You must choose one of the representations and
988 use it consistently in your program.
989
990 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
991 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
992 There are 11 bits of significand precision, approximately 3
993 decimal digits.
994
995 Specifying @option{-mfp16-format=alternative} selects the ARM
996 alternative format. This representation is similar to the IEEE
997 format, but does not support infinities or NaNs. Instead, the range
998 of exponents is extended, so that this format can represent normalized
999 values in the range of @math{2^{-14}} to 131008.
1000
1001 The @code{__fp16} type is a storage format only. For purposes
1002 of arithmetic and other operations, @code{__fp16} values in C or C++
1003 expressions are automatically promoted to @code{float}. In addition,
1004 you cannot declare a function with a return value or parameters
1005 of type @code{__fp16}.
1006
1007 Note that conversions from @code{double} to @code{__fp16}
1008 involve an intermediate conversion to @code{float}. Because
1009 of rounding, this can sometimes produce a different result than a
1010 direct conversion.
1011
1012 ARM provides hardware support for conversions between
1013 @code{__fp16} and @code{float} values
1014 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1015 code using these hardware instructions if you compile with
1016 options to select an FPU that provides them;
1017 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1018 in addition to the @option{-mfp16-format} option to select
1019 a half-precision format.
1020
1021 Language-level support for the @code{__fp16} data type is
1022 independent of whether GCC generates code using hardware floating-point
1023 instructions. In cases where hardware support is not specified, GCC
1024 implements conversions between @code{__fp16} and @code{float} values
1025 as library calls.
1026
1027 @node Decimal Float
1028 @section Decimal Floating Types
1029 @cindex decimal floating types
1030 @cindex @code{_Decimal32} data type
1031 @cindex @code{_Decimal64} data type
1032 @cindex @code{_Decimal128} data type
1033 @cindex @code{df} integer suffix
1034 @cindex @code{dd} integer suffix
1035 @cindex @code{dl} integer suffix
1036 @cindex @code{DF} integer suffix
1037 @cindex @code{DD} integer suffix
1038 @cindex @code{DL} integer suffix
1039
1040 As an extension, GNU C supports decimal floating types as
1041 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1042 floating types in GCC will evolve as the draft technical report changes.
1043 Calling conventions for any target might also change. Not all targets
1044 support decimal floating types.
1045
1046 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1047 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1048 @code{float}, @code{double}, and @code{long double} whose radix is not
1049 specified by the C standard but is usually two.
1050
1051 Support for decimal floating types includes the arithmetic operators
1052 add, subtract, multiply, divide; unary arithmetic operators;
1053 relational operators; equality operators; and conversions to and from
1054 integer and other floating types. Use a suffix @samp{df} or
1055 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1056 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1057 @code{_Decimal128}.
1058
1059 GCC support of decimal float as specified by the draft technical report
1060 is incomplete:
1061
1062 @itemize @bullet
1063 @item
1064 When the value of a decimal floating type cannot be represented in the
1065 integer type to which it is being converted, the result is undefined
1066 rather than the result value specified by the draft technical report.
1067
1068 @item
1069 GCC does not provide the C library functionality associated with
1070 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1071 @file{wchar.h}, which must come from a separate C library implementation.
1072 Because of this the GNU C compiler does not define macro
1073 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1074 the technical report.
1075 @end itemize
1076
1077 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1078 are supported by the DWARF debug information format.
1079
1080 @node Hex Floats
1081 @section Hex Floats
1082 @cindex hex floats
1083
1084 ISO C99 supports floating-point numbers written not only in the usual
1085 decimal notation, such as @code{1.55e1}, but also numbers such as
1086 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1087 supports this in C90 mode (except in some cases when strictly
1088 conforming) and in C++. In that format the
1089 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1090 mandatory. The exponent is a decimal number that indicates the power of
1091 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1092 @tex
1093 $1 {15\over16}$,
1094 @end tex
1095 @ifnottex
1096 1 15/16,
1097 @end ifnottex
1098 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1099 is the same as @code{1.55e1}.
1100
1101 Unlike for floating-point numbers in the decimal notation the exponent
1102 is always required in the hexadecimal notation. Otherwise the compiler
1103 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1104 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1105 extension for floating-point constants of type @code{float}.
1106
1107 @node Fixed-Point
1108 @section Fixed-Point Types
1109 @cindex fixed-point types
1110 @cindex @code{_Fract} data type
1111 @cindex @code{_Accum} data type
1112 @cindex @code{_Sat} data type
1113 @cindex @code{hr} fixed-suffix
1114 @cindex @code{r} fixed-suffix
1115 @cindex @code{lr} fixed-suffix
1116 @cindex @code{llr} fixed-suffix
1117 @cindex @code{uhr} fixed-suffix
1118 @cindex @code{ur} fixed-suffix
1119 @cindex @code{ulr} fixed-suffix
1120 @cindex @code{ullr} fixed-suffix
1121 @cindex @code{hk} fixed-suffix
1122 @cindex @code{k} fixed-suffix
1123 @cindex @code{lk} fixed-suffix
1124 @cindex @code{llk} fixed-suffix
1125 @cindex @code{uhk} fixed-suffix
1126 @cindex @code{uk} fixed-suffix
1127 @cindex @code{ulk} fixed-suffix
1128 @cindex @code{ullk} fixed-suffix
1129 @cindex @code{HR} fixed-suffix
1130 @cindex @code{R} fixed-suffix
1131 @cindex @code{LR} fixed-suffix
1132 @cindex @code{LLR} fixed-suffix
1133 @cindex @code{UHR} fixed-suffix
1134 @cindex @code{UR} fixed-suffix
1135 @cindex @code{ULR} fixed-suffix
1136 @cindex @code{ULLR} fixed-suffix
1137 @cindex @code{HK} fixed-suffix
1138 @cindex @code{K} fixed-suffix
1139 @cindex @code{LK} fixed-suffix
1140 @cindex @code{LLK} fixed-suffix
1141 @cindex @code{UHK} fixed-suffix
1142 @cindex @code{UK} fixed-suffix
1143 @cindex @code{ULK} fixed-suffix
1144 @cindex @code{ULLK} fixed-suffix
1145
1146 As an extension, GNU C supports fixed-point types as
1147 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1148 types in GCC will evolve as the draft technical report changes.
1149 Calling conventions for any target might also change. Not all targets
1150 support fixed-point types.
1151
1152 The fixed-point types are
1153 @code{short _Fract},
1154 @code{_Fract},
1155 @code{long _Fract},
1156 @code{long long _Fract},
1157 @code{unsigned short _Fract},
1158 @code{unsigned _Fract},
1159 @code{unsigned long _Fract},
1160 @code{unsigned long long _Fract},
1161 @code{_Sat short _Fract},
1162 @code{_Sat _Fract},
1163 @code{_Sat long _Fract},
1164 @code{_Sat long long _Fract},
1165 @code{_Sat unsigned short _Fract},
1166 @code{_Sat unsigned _Fract},
1167 @code{_Sat unsigned long _Fract},
1168 @code{_Sat unsigned long long _Fract},
1169 @code{short _Accum},
1170 @code{_Accum},
1171 @code{long _Accum},
1172 @code{long long _Accum},
1173 @code{unsigned short _Accum},
1174 @code{unsigned _Accum},
1175 @code{unsigned long _Accum},
1176 @code{unsigned long long _Accum},
1177 @code{_Sat short _Accum},
1178 @code{_Sat _Accum},
1179 @code{_Sat long _Accum},
1180 @code{_Sat long long _Accum},
1181 @code{_Sat unsigned short _Accum},
1182 @code{_Sat unsigned _Accum},
1183 @code{_Sat unsigned long _Accum},
1184 @code{_Sat unsigned long long _Accum}.
1185
1186 Fixed-point data values contain fractional and optional integral parts.
1187 The format of fixed-point data varies and depends on the target machine.
1188
1189 Support for fixed-point types includes:
1190 @itemize @bullet
1191 @item
1192 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1193 @item
1194 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1195 @item
1196 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1197 @item
1198 binary shift operators (@code{<<}, @code{>>})
1199 @item
1200 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1201 @item
1202 equality operators (@code{==}, @code{!=})
1203 @item
1204 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1205 @code{<<=}, @code{>>=})
1206 @item
1207 conversions to and from integer, floating-point, or fixed-point types
1208 @end itemize
1209
1210 Use a suffix in a fixed-point literal constant:
1211 @itemize
1212 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1213 @code{_Sat short _Fract}
1214 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1215 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1216 @code{_Sat long _Fract}
1217 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1218 @code{_Sat long long _Fract}
1219 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1220 @code{_Sat unsigned short _Fract}
1221 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1222 @code{_Sat unsigned _Fract}
1223 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1224 @code{_Sat unsigned long _Fract}
1225 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1226 and @code{_Sat unsigned long long _Fract}
1227 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1228 @code{_Sat short _Accum}
1229 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1230 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1231 @code{_Sat long _Accum}
1232 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1233 @code{_Sat long long _Accum}
1234 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1235 @code{_Sat unsigned short _Accum}
1236 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1237 @code{_Sat unsigned _Accum}
1238 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1239 @code{_Sat unsigned long _Accum}
1240 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1241 and @code{_Sat unsigned long long _Accum}
1242 @end itemize
1243
1244 GCC support of fixed-point types as specified by the draft technical report
1245 is incomplete:
1246
1247 @itemize @bullet
1248 @item
1249 Pragmas to control overflow and rounding behaviors are not implemented.
1250 @end itemize
1251
1252 Fixed-point types are supported by the DWARF debug information format.
1253
1254 @node Named Address Spaces
1255 @section Named Address Spaces
1256 @cindex Named Address Spaces
1257
1258 As an extension, GNU C supports named address spaces as
1259 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1260 address spaces in GCC will evolve as the draft technical report
1261 changes. Calling conventions for any target might also change. At
1262 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1263 address spaces other than the generic address space.
1264
1265 Address space identifiers may be used exactly like any other C type
1266 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1267 document for more details.
1268
1269 @anchor{AVR Named Address Spaces}
1270 @subsection AVR Named Address Spaces
1271
1272 On the AVR target, there are several address spaces that can be used
1273 in order to put read-only data into the flash memory and access that
1274 data by means of the special instructions @code{LPM} or @code{ELPM}
1275 needed to read from flash.
1276
1277 Per default, any data including read-only data is located in RAM
1278 (the generic address space) so that non-generic address spaces are
1279 needed to locate read-only data in flash memory
1280 @emph{and} to generate the right instructions to access this data
1281 without using (inline) assembler code.
1282
1283 @table @code
1284 @item __flash
1285 @cindex @code{__flash} AVR Named Address Spaces
1286 The @code{__flash} qualifier locates data in the
1287 @code{.progmem.data} section. Data is read using the @code{LPM}
1288 instruction. Pointers to this address space are 16 bits wide.
1289
1290 @item __flash1
1291 @itemx __flash2
1292 @itemx __flash3
1293 @itemx __flash4
1294 @itemx __flash5
1295 @cindex @code{__flash1} AVR Named Address Spaces
1296 @cindex @code{__flash2} AVR Named Address Spaces
1297 @cindex @code{__flash3} AVR Named Address Spaces
1298 @cindex @code{__flash4} AVR Named Address Spaces
1299 @cindex @code{__flash5} AVR Named Address Spaces
1300 These are 16-bit address spaces locating data in section
1301 @code{.progmem@var{N}.data} where @var{N} refers to
1302 address space @code{__flash@var{N}}.
1303 The compiler sets the @code{RAMPZ} segment register appropriately
1304 before reading data by means of the @code{ELPM} instruction.
1305
1306 @item __memx
1307 @cindex @code{__memx} AVR Named Address Spaces
1308 This is a 24-bit address space that linearizes flash and RAM:
1309 If the high bit of the address is set, data is read from
1310 RAM using the lower two bytes as RAM address.
1311 If the high bit of the address is clear, data is read from flash
1312 with @code{RAMPZ} set according to the high byte of the address.
1313 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1314
1315 Objects in this address space are located in @code{.progmemx.data}.
1316 @end table
1317
1318 @b{Example}
1319
1320 @smallexample
1321 char my_read (const __flash char ** p)
1322 @{
1323 /* p is a pointer to RAM that points to a pointer to flash.
1324 The first indirection of p reads that flash pointer
1325 from RAM and the second indirection reads a char from this
1326 flash address. */
1327
1328 return **p;
1329 @}
1330
1331 /* Locate array[] in flash memory */
1332 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1333
1334 int i = 1;
1335
1336 int main (void)
1337 @{
1338 /* Return 17 by reading from flash memory */
1339 return array[array[i]];
1340 @}
1341 @end smallexample
1342
1343 @noindent
1344 For each named address space supported by avr-gcc there is an equally
1345 named but uppercase built-in macro defined.
1346 The purpose is to facilitate testing if respective address space
1347 support is available or not:
1348
1349 @smallexample
1350 #ifdef __FLASH
1351 const __flash int var = 1;
1352
1353 int read_var (void)
1354 @{
1355 return var;
1356 @}
1357 #else
1358 #include <avr/pgmspace.h> /* From AVR-LibC */
1359
1360 const int var PROGMEM = 1;
1361
1362 int read_var (void)
1363 @{
1364 return (int) pgm_read_word (&var);
1365 @}
1366 #endif /* __FLASH */
1367 @end smallexample
1368
1369 @noindent
1370 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1371 locates data in flash but
1372 accesses to these data read from generic address space, i.e.@:
1373 from RAM,
1374 so that you need special accessors like @code{pgm_read_byte}
1375 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1376 together with attribute @code{progmem}.
1377
1378 @noindent
1379 @b{Limitations and caveats}
1380
1381 @itemize
1382 @item
1383 Reading across the 64@tie{}KiB section boundary of
1384 the @code{__flash} or @code{__flash@var{N}} address spaces
1385 shows undefined behavior. The only address space that
1386 supports reading across the 64@tie{}KiB flash segment boundaries is
1387 @code{__memx}.
1388
1389 @item
1390 If you use one of the @code{__flash@var{N}} address spaces
1391 you must arrange your linker script to locate the
1392 @code{.progmem@var{N}.data} sections according to your needs.
1393
1394 @item
1395 Any data or pointers to the non-generic address spaces must
1396 be qualified as @code{const}, i.e.@: as read-only data.
1397 This still applies if the data in one of these address
1398 spaces like software version number or calibration lookup table are intended to
1399 be changed after load time by, say, a boot loader. In this case
1400 the right qualification is @code{const} @code{volatile} so that the compiler
1401 must not optimize away known values or insert them
1402 as immediates into operands of instructions.
1403
1404 @item
1405 The following code initializes a variable @code{pfoo}
1406 located in static storage with a 24-bit address:
1407 @smallexample
1408 extern const __memx char foo;
1409 const __memx void *pfoo = &foo;
1410 @end smallexample
1411
1412 @noindent
1413 Such code requires at least binutils 2.23, see
1414 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1415
1416 @end itemize
1417
1418 @subsection M32C Named Address Spaces
1419 @cindex @code{__far} M32C Named Address Spaces
1420
1421 On the M32C target, with the R8C and M16C CPU variants, variables
1422 qualified with @code{__far} are accessed using 32-bit addresses in
1423 order to access memory beyond the first 64@tie{}Ki bytes. If
1424 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1425 effect.
1426
1427 @subsection RL78 Named Address Spaces
1428 @cindex @code{__far} RL78 Named Address Spaces
1429
1430 On the RL78 target, variables qualified with @code{__far} are accessed
1431 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1432 addresses. Non-far variables are assumed to appear in the topmost
1433 64@tie{}KiB of the address space.
1434
1435 @subsection SPU Named Address Spaces
1436 @cindex @code{__ea} SPU Named Address Spaces
1437
1438 On the SPU target variables may be declared as
1439 belonging to another address space by qualifying the type with the
1440 @code{__ea} address space identifier:
1441
1442 @smallexample
1443 extern int __ea i;
1444 @end smallexample
1445
1446 @noindent
1447 The compiler generates special code to access the variable @code{i}.
1448 It may use runtime library
1449 support, or generate special machine instructions to access that address
1450 space.
1451
1452 @subsection x86 Named Address Spaces
1453 @cindex x86 named address spaces
1454
1455 On the x86 target, variables may be declared as being relative
1456 to the @code{%fs} or @code{%gs} segments.
1457
1458 @table @code
1459 @item __seg_fs
1460 @itemx __seg_gs
1461 @cindex @code{__seg_fs} x86 named address space
1462 @cindex @code{__seg_gs} x86 named address space
1463 The object is accessed with the respective segment override prefix.
1464
1465 The respective segment base must be set via some method specific to
1466 the operating system. Rather than require an expensive system call
1467 to retrieve the segment base, these address spaces are not considered
1468 to be subspaces of the generic (flat) address space. This means that
1469 explicit casts are required to convert pointers between these address
1470 spaces and the generic address space. In practice the application
1471 should cast to @code{uintptr_t} and apply the segment base offset
1472 that it installed previously.
1473
1474 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1475 defined when these address spaces are supported.
1476 @end table
1477
1478 @node Zero Length
1479 @section Arrays of Length Zero
1480 @cindex arrays of length zero
1481 @cindex zero-length arrays
1482 @cindex length-zero arrays
1483 @cindex flexible array members
1484
1485 Zero-length arrays are allowed in GNU C@. They are very useful as the
1486 last element of a structure that is really a header for a variable-length
1487 object:
1488
1489 @smallexample
1490 struct line @{
1491 int length;
1492 char contents[0];
1493 @};
1494
1495 struct line *thisline = (struct line *)
1496 malloc (sizeof (struct line) + this_length);
1497 thisline->length = this_length;
1498 @end smallexample
1499
1500 In ISO C90, you would have to give @code{contents} a length of 1, which
1501 means either you waste space or complicate the argument to @code{malloc}.
1502
1503 In ISO C99, you would use a @dfn{flexible array member}, which is
1504 slightly different in syntax and semantics:
1505
1506 @itemize @bullet
1507 @item
1508 Flexible array members are written as @code{contents[]} without
1509 the @code{0}.
1510
1511 @item
1512 Flexible array members have incomplete type, and so the @code{sizeof}
1513 operator may not be applied. As a quirk of the original implementation
1514 of zero-length arrays, @code{sizeof} evaluates to zero.
1515
1516 @item
1517 Flexible array members may only appear as the last member of a
1518 @code{struct} that is otherwise non-empty.
1519
1520 @item
1521 A structure containing a flexible array member, or a union containing
1522 such a structure (possibly recursively), may not be a member of a
1523 structure or an element of an array. (However, these uses are
1524 permitted by GCC as extensions.)
1525 @end itemize
1526
1527 Non-empty initialization of zero-length
1528 arrays is treated like any case where there are more initializer
1529 elements than the array holds, in that a suitable warning about ``excess
1530 elements in array'' is given, and the excess elements (all of them, in
1531 this case) are ignored.
1532
1533 GCC allows static initialization of flexible array members.
1534 This is equivalent to defining a new structure containing the original
1535 structure followed by an array of sufficient size to contain the data.
1536 E.g.@: in the following, @code{f1} is constructed as if it were declared
1537 like @code{f2}.
1538
1539 @smallexample
1540 struct f1 @{
1541 int x; int y[];
1542 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1543
1544 struct f2 @{
1545 struct f1 f1; int data[3];
1546 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1547 @end smallexample
1548
1549 @noindent
1550 The convenience of this extension is that @code{f1} has the desired
1551 type, eliminating the need to consistently refer to @code{f2.f1}.
1552
1553 This has symmetry with normal static arrays, in that an array of
1554 unknown size is also written with @code{[]}.
1555
1556 Of course, this extension only makes sense if the extra data comes at
1557 the end of a top-level object, as otherwise we would be overwriting
1558 data at subsequent offsets. To avoid undue complication and confusion
1559 with initialization of deeply nested arrays, we simply disallow any
1560 non-empty initialization except when the structure is the top-level
1561 object. For example:
1562
1563 @smallexample
1564 struct foo @{ int x; int y[]; @};
1565 struct bar @{ struct foo z; @};
1566
1567 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1568 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1569 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1570 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1571 @end smallexample
1572
1573 @node Empty Structures
1574 @section Structures with No Members
1575 @cindex empty structures
1576 @cindex zero-size structures
1577
1578 GCC permits a C structure to have no members:
1579
1580 @smallexample
1581 struct empty @{
1582 @};
1583 @end smallexample
1584
1585 The structure has size zero. In C++, empty structures are part
1586 of the language. G++ treats empty structures as if they had a single
1587 member of type @code{char}.
1588
1589 @node Variable Length
1590 @section Arrays of Variable Length
1591 @cindex variable-length arrays
1592 @cindex arrays of variable length
1593 @cindex VLAs
1594
1595 Variable-length automatic arrays are allowed in ISO C99, and as an
1596 extension GCC accepts them in C90 mode and in C++. These arrays are
1597 declared like any other automatic arrays, but with a length that is not
1598 a constant expression. The storage is allocated at the point of
1599 declaration and deallocated when the block scope containing the declaration
1600 exits. For
1601 example:
1602
1603 @smallexample
1604 FILE *
1605 concat_fopen (char *s1, char *s2, char *mode)
1606 @{
1607 char str[strlen (s1) + strlen (s2) + 1];
1608 strcpy (str, s1);
1609 strcat (str, s2);
1610 return fopen (str, mode);
1611 @}
1612 @end smallexample
1613
1614 @cindex scope of a variable length array
1615 @cindex variable-length array scope
1616 @cindex deallocating variable length arrays
1617 Jumping or breaking out of the scope of the array name deallocates the
1618 storage. Jumping into the scope is not allowed; you get an error
1619 message for it.
1620
1621 @cindex variable-length array in a structure
1622 As an extension, GCC accepts variable-length arrays as a member of
1623 a structure or a union. For example:
1624
1625 @smallexample
1626 void
1627 foo (int n)
1628 @{
1629 struct S @{ int x[n]; @};
1630 @}
1631 @end smallexample
1632
1633 @cindex @code{alloca} vs variable-length arrays
1634 You can use the function @code{alloca} to get an effect much like
1635 variable-length arrays. The function @code{alloca} is available in
1636 many other C implementations (but not in all). On the other hand,
1637 variable-length arrays are more elegant.
1638
1639 There are other differences between these two methods. Space allocated
1640 with @code{alloca} exists until the containing @emph{function} returns.
1641 The space for a variable-length array is deallocated as soon as the array
1642 name's scope ends, unless you also use @code{alloca} in this scope.
1643
1644 You can also use variable-length arrays as arguments to functions:
1645
1646 @smallexample
1647 struct entry
1648 tester (int len, char data[len][len])
1649 @{
1650 /* @r{@dots{}} */
1651 @}
1652 @end smallexample
1653
1654 The length of an array is computed once when the storage is allocated
1655 and is remembered for the scope of the array in case you access it with
1656 @code{sizeof}.
1657
1658 If you want to pass the array first and the length afterward, you can
1659 use a forward declaration in the parameter list---another GNU extension.
1660
1661 @smallexample
1662 struct entry
1663 tester (int len; char data[len][len], int len)
1664 @{
1665 /* @r{@dots{}} */
1666 @}
1667 @end smallexample
1668
1669 @cindex parameter forward declaration
1670 The @samp{int len} before the semicolon is a @dfn{parameter forward
1671 declaration}, and it serves the purpose of making the name @code{len}
1672 known when the declaration of @code{data} is parsed.
1673
1674 You can write any number of such parameter forward declarations in the
1675 parameter list. They can be separated by commas or semicolons, but the
1676 last one must end with a semicolon, which is followed by the ``real''
1677 parameter declarations. Each forward declaration must match a ``real''
1678 declaration in parameter name and data type. ISO C99 does not support
1679 parameter forward declarations.
1680
1681 @node Variadic Macros
1682 @section Macros with a Variable Number of Arguments.
1683 @cindex variable number of arguments
1684 @cindex macro with variable arguments
1685 @cindex rest argument (in macro)
1686 @cindex variadic macros
1687
1688 In the ISO C standard of 1999, a macro can be declared to accept a
1689 variable number of arguments much as a function can. The syntax for
1690 defining the macro is similar to that of a function. Here is an
1691 example:
1692
1693 @smallexample
1694 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1695 @end smallexample
1696
1697 @noindent
1698 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1699 such a macro, it represents the zero or more tokens until the closing
1700 parenthesis that ends the invocation, including any commas. This set of
1701 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1702 wherever it appears. See the CPP manual for more information.
1703
1704 GCC has long supported variadic macros, and used a different syntax that
1705 allowed you to give a name to the variable arguments just like any other
1706 argument. Here is an example:
1707
1708 @smallexample
1709 #define debug(format, args...) fprintf (stderr, format, args)
1710 @end smallexample
1711
1712 @noindent
1713 This is in all ways equivalent to the ISO C example above, but arguably
1714 more readable and descriptive.
1715
1716 GNU CPP has two further variadic macro extensions, and permits them to
1717 be used with either of the above forms of macro definition.
1718
1719 In standard C, you are not allowed to leave the variable argument out
1720 entirely; but you are allowed to pass an empty argument. For example,
1721 this invocation is invalid in ISO C, because there is no comma after
1722 the string:
1723
1724 @smallexample
1725 debug ("A message")
1726 @end smallexample
1727
1728 GNU CPP permits you to completely omit the variable arguments in this
1729 way. In the above examples, the compiler would complain, though since
1730 the expansion of the macro still has the extra comma after the format
1731 string.
1732
1733 To help solve this problem, CPP behaves specially for variable arguments
1734 used with the token paste operator, @samp{##}. If instead you write
1735
1736 @smallexample
1737 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1738 @end smallexample
1739
1740 @noindent
1741 and if the variable arguments are omitted or empty, the @samp{##}
1742 operator causes the preprocessor to remove the comma before it. If you
1743 do provide some variable arguments in your macro invocation, GNU CPP
1744 does not complain about the paste operation and instead places the
1745 variable arguments after the comma. Just like any other pasted macro
1746 argument, these arguments are not macro expanded.
1747
1748 @node Escaped Newlines
1749 @section Slightly Looser Rules for Escaped Newlines
1750 @cindex escaped newlines
1751 @cindex newlines (escaped)
1752
1753 The preprocessor treatment of escaped newlines is more relaxed
1754 than that specified by the C90 standard, which requires the newline
1755 to immediately follow a backslash.
1756 GCC's implementation allows whitespace in the form
1757 of spaces, horizontal and vertical tabs, and form feeds between the
1758 backslash and the subsequent newline. The preprocessor issues a
1759 warning, but treats it as a valid escaped newline and combines the two
1760 lines to form a single logical line. This works within comments and
1761 tokens, as well as between tokens. Comments are @emph{not} treated as
1762 whitespace for the purposes of this relaxation, since they have not
1763 yet been replaced with spaces.
1764
1765 @node Subscripting
1766 @section Non-Lvalue Arrays May Have Subscripts
1767 @cindex subscripting
1768 @cindex arrays, non-lvalue
1769
1770 @cindex subscripting and function values
1771 In ISO C99, arrays that are not lvalues still decay to pointers, and
1772 may be subscripted, although they may not be modified or used after
1773 the next sequence point and the unary @samp{&} operator may not be
1774 applied to them. As an extension, GNU C allows such arrays to be
1775 subscripted in C90 mode, though otherwise they do not decay to
1776 pointers outside C99 mode. For example,
1777 this is valid in GNU C though not valid in C90:
1778
1779 @smallexample
1780 @group
1781 struct foo @{int a[4];@};
1782
1783 struct foo f();
1784
1785 bar (int index)
1786 @{
1787 return f().a[index];
1788 @}
1789 @end group
1790 @end smallexample
1791
1792 @node Pointer Arith
1793 @section Arithmetic on @code{void}- and Function-Pointers
1794 @cindex void pointers, arithmetic
1795 @cindex void, size of pointer to
1796 @cindex function pointers, arithmetic
1797 @cindex function, size of pointer to
1798
1799 In GNU C, addition and subtraction operations are supported on pointers to
1800 @code{void} and on pointers to functions. This is done by treating the
1801 size of a @code{void} or of a function as 1.
1802
1803 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1804 and on function types, and returns 1.
1805
1806 @opindex Wpointer-arith
1807 The option @option{-Wpointer-arith} requests a warning if these extensions
1808 are used.
1809
1810 @node Pointers to Arrays
1811 @section Pointers to Arrays with Qualifiers Work as Expected
1812 @cindex pointers to arrays
1813 @cindex const qualifier
1814
1815 In GNU C, pointers to arrays with qualifiers work similar to pointers
1816 to other qualified types. For example, a value of type @code{int (*)[5]}
1817 can be used to initialize a variable of type @code{const int (*)[5]}.
1818 These types are incompatible in ISO C because the @code{const} qualifier
1819 is formally attached to the element type of the array and not the
1820 array itself.
1821
1822 @smallexample
1823 extern void
1824 transpose (int N, int M, double out[M][N], const double in[N][M]);
1825 double x[3][2];
1826 double y[2][3];
1827 @r{@dots{}}
1828 transpose(3, 2, y, x);
1829 @end smallexample
1830
1831 @node Initializers
1832 @section Non-Constant Initializers
1833 @cindex initializers, non-constant
1834 @cindex non-constant initializers
1835
1836 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1837 automatic variable are not required to be constant expressions in GNU C@.
1838 Here is an example of an initializer with run-time varying elements:
1839
1840 @smallexample
1841 foo (float f, float g)
1842 @{
1843 float beat_freqs[2] = @{ f-g, f+g @};
1844 /* @r{@dots{}} */
1845 @}
1846 @end smallexample
1847
1848 @node Compound Literals
1849 @section Compound Literals
1850 @cindex constructor expressions
1851 @cindex initializations in expressions
1852 @cindex structures, constructor expression
1853 @cindex expressions, constructor
1854 @cindex compound literals
1855 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1856
1857 ISO C99 supports compound literals. A compound literal looks like
1858 a cast containing an initializer. Its value is an object of the
1859 type specified in the cast, containing the elements specified in
1860 the initializer; it is an lvalue. As an extension, GCC supports
1861 compound literals in C90 mode and in C++, though the semantics are
1862 somewhat different in C++.
1863
1864 Usually, the specified type is a structure. Assume that
1865 @code{struct foo} and @code{structure} are declared as shown:
1866
1867 @smallexample
1868 struct foo @{int a; char b[2];@} structure;
1869 @end smallexample
1870
1871 @noindent
1872 Here is an example of constructing a @code{struct foo} with a compound literal:
1873
1874 @smallexample
1875 structure = ((struct foo) @{x + y, 'a', 0@});
1876 @end smallexample
1877
1878 @noindent
1879 This is equivalent to writing the following:
1880
1881 @smallexample
1882 @{
1883 struct foo temp = @{x + y, 'a', 0@};
1884 structure = temp;
1885 @}
1886 @end smallexample
1887
1888 You can also construct an array, though this is dangerous in C++, as
1889 explained below. If all the elements of the compound literal are
1890 (made up of) simple constant expressions, suitable for use in
1891 initializers of objects of static storage duration, then the compound
1892 literal can be coerced to a pointer to its first element and used in
1893 such an initializer, as shown here:
1894
1895 @smallexample
1896 char **foo = (char *[]) @{ "x", "y", "z" @};
1897 @end smallexample
1898
1899 Compound literals for scalar types and union types are
1900 also allowed, but then the compound literal is equivalent
1901 to a cast.
1902
1903 As a GNU extension, GCC allows initialization of objects with static storage
1904 duration by compound literals (which is not possible in ISO C99, because
1905 the initializer is not a constant).
1906 It is handled as if the object is initialized only with the bracket
1907 enclosed list if the types of the compound literal and the object match.
1908 The initializer list of the compound literal must be constant.
1909 If the object being initialized has array type of unknown size, the size is
1910 determined by compound literal size.
1911
1912 @smallexample
1913 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1914 static int y[] = (int []) @{1, 2, 3@};
1915 static int z[] = (int [3]) @{1@};
1916 @end smallexample
1917
1918 @noindent
1919 The above lines are equivalent to the following:
1920 @smallexample
1921 static struct foo x = @{1, 'a', 'b'@};
1922 static int y[] = @{1, 2, 3@};
1923 static int z[] = @{1, 0, 0@};
1924 @end smallexample
1925
1926 In C, a compound literal designates an unnamed object with static or
1927 automatic storage duration. In C++, a compound literal designates a
1928 temporary object, which only lives until the end of its
1929 full-expression. As a result, well-defined C code that takes the
1930 address of a subobject of a compound literal can be undefined in C++,
1931 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1932 For instance, if the array compound literal example above appeared
1933 inside a function, any subsequent use of @samp{foo} in C++ has
1934 undefined behavior because the lifetime of the array ends after the
1935 declaration of @samp{foo}.
1936
1937 As an optimization, the C++ compiler sometimes gives array compound
1938 literals longer lifetimes: when the array either appears outside a
1939 function or has const-qualified type. If @samp{foo} and its
1940 initializer had elements of @samp{char *const} type rather than
1941 @samp{char *}, or if @samp{foo} were a global variable, the array
1942 would have static storage duration. But it is probably safest just to
1943 avoid the use of array compound literals in code compiled as C++.
1944
1945 @node Designated Inits
1946 @section Designated Initializers
1947 @cindex initializers with labeled elements
1948 @cindex labeled elements in initializers
1949 @cindex case labels in initializers
1950 @cindex designated initializers
1951
1952 Standard C90 requires the elements of an initializer to appear in a fixed
1953 order, the same as the order of the elements in the array or structure
1954 being initialized.
1955
1956 In ISO C99 you can give the elements in any order, specifying the array
1957 indices or structure field names they apply to, and GNU C allows this as
1958 an extension in C90 mode as well. This extension is not
1959 implemented in GNU C++.
1960
1961 To specify an array index, write
1962 @samp{[@var{index}] =} before the element value. For example,
1963
1964 @smallexample
1965 int a[6] = @{ [4] = 29, [2] = 15 @};
1966 @end smallexample
1967
1968 @noindent
1969 is equivalent to
1970
1971 @smallexample
1972 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1973 @end smallexample
1974
1975 @noindent
1976 The index values must be constant expressions, even if the array being
1977 initialized is automatic.
1978
1979 An alternative syntax for this that has been obsolete since GCC 2.5 but
1980 GCC still accepts is to write @samp{[@var{index}]} before the element
1981 value, with no @samp{=}.
1982
1983 To initialize a range of elements to the same value, write
1984 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
1985 extension. For example,
1986
1987 @smallexample
1988 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
1989 @end smallexample
1990
1991 @noindent
1992 If the value in it has side-effects, the side-effects happen only once,
1993 not for each initialized field by the range initializer.
1994
1995 @noindent
1996 Note that the length of the array is the highest value specified
1997 plus one.
1998
1999 In a structure initializer, specify the name of a field to initialize
2000 with @samp{.@var{fieldname} =} before the element value. For example,
2001 given the following structure,
2002
2003 @smallexample
2004 struct point @{ int x, y; @};
2005 @end smallexample
2006
2007 @noindent
2008 the following initialization
2009
2010 @smallexample
2011 struct point p = @{ .y = yvalue, .x = xvalue @};
2012 @end smallexample
2013
2014 @noindent
2015 is equivalent to
2016
2017 @smallexample
2018 struct point p = @{ xvalue, yvalue @};
2019 @end smallexample
2020
2021 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2022 @samp{@var{fieldname}:}, as shown here:
2023
2024 @smallexample
2025 struct point p = @{ y: yvalue, x: xvalue @};
2026 @end smallexample
2027
2028 Omitted field members are implicitly initialized the same as objects
2029 that have static storage duration.
2030
2031 @cindex designators
2032 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2033 @dfn{designator}. You can also use a designator (or the obsolete colon
2034 syntax) when initializing a union, to specify which element of the union
2035 should be used. For example,
2036
2037 @smallexample
2038 union foo @{ int i; double d; @};
2039
2040 union foo f = @{ .d = 4 @};
2041 @end smallexample
2042
2043 @noindent
2044 converts 4 to a @code{double} to store it in the union using
2045 the second element. By contrast, casting 4 to type @code{union foo}
2046 stores it into the union as the integer @code{i}, since it is
2047 an integer. (@xref{Cast to Union}.)
2048
2049 You can combine this technique of naming elements with ordinary C
2050 initialization of successive elements. Each initializer element that
2051 does not have a designator applies to the next consecutive element of the
2052 array or structure. For example,
2053
2054 @smallexample
2055 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2056 @end smallexample
2057
2058 @noindent
2059 is equivalent to
2060
2061 @smallexample
2062 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2063 @end smallexample
2064
2065 Labeling the elements of an array initializer is especially useful
2066 when the indices are characters or belong to an @code{enum} type.
2067 For example:
2068
2069 @smallexample
2070 int whitespace[256]
2071 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2072 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2073 @end smallexample
2074
2075 @cindex designator lists
2076 You can also write a series of @samp{.@var{fieldname}} and
2077 @samp{[@var{index}]} designators before an @samp{=} to specify a
2078 nested subobject to initialize; the list is taken relative to the
2079 subobject corresponding to the closest surrounding brace pair. For
2080 example, with the @samp{struct point} declaration above:
2081
2082 @smallexample
2083 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2084 @end smallexample
2085
2086 @noindent
2087 If the same field is initialized multiple times, it has the value from
2088 the last initialization. If any such overridden initialization has
2089 side-effect, it is unspecified whether the side-effect happens or not.
2090 Currently, GCC discards them and issues a warning.
2091
2092 @node Case Ranges
2093 @section Case Ranges
2094 @cindex case ranges
2095 @cindex ranges in case statements
2096
2097 You can specify a range of consecutive values in a single @code{case} label,
2098 like this:
2099
2100 @smallexample
2101 case @var{low} ... @var{high}:
2102 @end smallexample
2103
2104 @noindent
2105 This has the same effect as the proper number of individual @code{case}
2106 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2107
2108 This feature is especially useful for ranges of ASCII character codes:
2109
2110 @smallexample
2111 case 'A' ... 'Z':
2112 @end smallexample
2113
2114 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2115 it may be parsed wrong when you use it with integer values. For example,
2116 write this:
2117
2118 @smallexample
2119 case 1 ... 5:
2120 @end smallexample
2121
2122 @noindent
2123 rather than this:
2124
2125 @smallexample
2126 case 1...5:
2127 @end smallexample
2128
2129 @node Cast to Union
2130 @section Cast to a Union Type
2131 @cindex cast to a union
2132 @cindex union, casting to a
2133
2134 A cast to union type is similar to other casts, except that the type
2135 specified is a union type. You can specify the type either with
2136 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2137 a constructor, not a cast, and hence does not yield an lvalue like
2138 normal casts. (@xref{Compound Literals}.)
2139
2140 The types that may be cast to the union type are those of the members
2141 of the union. Thus, given the following union and variables:
2142
2143 @smallexample
2144 union foo @{ int i; double d; @};
2145 int x;
2146 double y;
2147 @end smallexample
2148
2149 @noindent
2150 both @code{x} and @code{y} can be cast to type @code{union foo}.
2151
2152 Using the cast as the right-hand side of an assignment to a variable of
2153 union type is equivalent to storing in a member of the union:
2154
2155 @smallexample
2156 union foo u;
2157 /* @r{@dots{}} */
2158 u = (union foo) x @equiv{} u.i = x
2159 u = (union foo) y @equiv{} u.d = y
2160 @end smallexample
2161
2162 You can also use the union cast as a function argument:
2163
2164 @smallexample
2165 void hack (union foo);
2166 /* @r{@dots{}} */
2167 hack ((union foo) x);
2168 @end smallexample
2169
2170 @node Mixed Declarations
2171 @section Mixed Declarations and Code
2172 @cindex mixed declarations and code
2173 @cindex declarations, mixed with code
2174 @cindex code, mixed with declarations
2175
2176 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2177 within compound statements. As an extension, GNU C also allows this in
2178 C90 mode. For example, you could do:
2179
2180 @smallexample
2181 int i;
2182 /* @r{@dots{}} */
2183 i++;
2184 int j = i + 2;
2185 @end smallexample
2186
2187 Each identifier is visible from where it is declared until the end of
2188 the enclosing block.
2189
2190 @node Function Attributes
2191 @section Declaring Attributes of Functions
2192 @cindex function attributes
2193 @cindex declaring attributes of functions
2194 @cindex @code{volatile} applied to function
2195 @cindex @code{const} applied to function
2196
2197 In GNU C, you can use function attributes to declare certain things
2198 about functions called in your program which help the compiler
2199 optimize calls and check your code more carefully. For example, you
2200 can use attributes to declare that a function never returns
2201 (@code{noreturn}), returns a value depending only on its arguments
2202 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2203
2204 You can also use attributes to control memory placement, code
2205 generation options or call/return conventions within the function
2206 being annotated. Many of these attributes are target-specific. For
2207 example, many targets support attributes for defining interrupt
2208 handler functions, which typically must follow special register usage
2209 and return conventions.
2210
2211 Function attributes are introduced by the @code{__attribute__} keyword
2212 on a declaration, followed by an attribute specification inside double
2213 parentheses. You can specify multiple attributes in a declaration by
2214 separating them by commas within the double parentheses or by
2215 immediately following an attribute declaration with another attribute
2216 declaration. @xref{Attribute Syntax}, for the exact rules on
2217 attribute syntax and placement.
2218
2219 GCC also supports attributes on
2220 variable declarations (@pxref{Variable Attributes}),
2221 labels (@pxref{Label Attributes}),
2222 enumerators (@pxref{Enumerator Attributes}),
2223 and types (@pxref{Type Attributes}).
2224
2225 There is some overlap between the purposes of attributes and pragmas
2226 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2227 found convenient to use @code{__attribute__} to achieve a natural
2228 attachment of attributes to their corresponding declarations, whereas
2229 @code{#pragma} is of use for compatibility with other compilers
2230 or constructs that do not naturally form part of the grammar.
2231
2232 In addition to the attributes documented here,
2233 GCC plugins may provide their own attributes.
2234
2235 @menu
2236 * Common Function Attributes::
2237 * AArch64 Function Attributes::
2238 * ARC Function Attributes::
2239 * ARM Function Attributes::
2240 * AVR Function Attributes::
2241 * Blackfin Function Attributes::
2242 * CR16 Function Attributes::
2243 * Epiphany Function Attributes::
2244 * H8/300 Function Attributes::
2245 * IA-64 Function Attributes::
2246 * M32C Function Attributes::
2247 * M32R/D Function Attributes::
2248 * m68k Function Attributes::
2249 * MCORE Function Attributes::
2250 * MeP Function Attributes::
2251 * MicroBlaze Function Attributes::
2252 * Microsoft Windows Function Attributes::
2253 * MIPS Function Attributes::
2254 * MSP430 Function Attributes::
2255 * NDS32 Function Attributes::
2256 * Nios II Function Attributes::
2257 * Nvidia PTX Function Attributes::
2258 * PowerPC Function Attributes::
2259 * RL78 Function Attributes::
2260 * RX Function Attributes::
2261 * S/390 Function Attributes::
2262 * SH Function Attributes::
2263 * SPU Function Attributes::
2264 * Symbian OS Function Attributes::
2265 * V850 Function Attributes::
2266 * Visium Function Attributes::
2267 * x86 Function Attributes::
2268 * Xstormy16 Function Attributes::
2269 @end menu
2270
2271 @node Common Function Attributes
2272 @subsection Common Function Attributes
2273
2274 The following attributes are supported on most targets.
2275
2276 @table @code
2277 @c Keep this table alphabetized by attribute name. Treat _ as space.
2278
2279 @item alias ("@var{target}")
2280 @cindex @code{alias} function attribute
2281 The @code{alias} attribute causes the declaration to be emitted as an
2282 alias for another symbol, which must be specified. For instance,
2283
2284 @smallexample
2285 void __f () @{ /* @r{Do something.} */; @}
2286 void f () __attribute__ ((weak, alias ("__f")));
2287 @end smallexample
2288
2289 @noindent
2290 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2291 mangled name for the target must be used. It is an error if @samp{__f}
2292 is not defined in the same translation unit.
2293
2294 This attribute requires assembler and object file support,
2295 and may not be available on all targets.
2296
2297 @item aligned (@var{alignment})
2298 @cindex @code{aligned} function attribute
2299 This attribute specifies a minimum alignment for the function,
2300 measured in bytes.
2301
2302 You cannot use this attribute to decrease the alignment of a function,
2303 only to increase it. However, when you explicitly specify a function
2304 alignment this overrides the effect of the
2305 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2306 function.
2307
2308 Note that the effectiveness of @code{aligned} attributes may be
2309 limited by inherent limitations in your linker. On many systems, the
2310 linker is only able to arrange for functions to be aligned up to a
2311 certain maximum alignment. (For some linkers, the maximum supported
2312 alignment may be very very small.) See your linker documentation for
2313 further information.
2314
2315 The @code{aligned} attribute can also be used for variables and fields
2316 (@pxref{Variable Attributes}.)
2317
2318 @item alloc_align
2319 @cindex @code{alloc_align} function attribute
2320 The @code{alloc_align} attribute is used to tell the compiler that the
2321 function return value points to memory, where the returned pointer minimum
2322 alignment is given by one of the functions parameters. GCC uses this
2323 information to improve pointer alignment analysis.
2324
2325 The function parameter denoting the allocated alignment is specified by
2326 one integer argument, whose number is the argument of the attribute.
2327 Argument numbering starts at one.
2328
2329 For instance,
2330
2331 @smallexample
2332 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2333 @end smallexample
2334
2335 @noindent
2336 declares that @code{my_memalign} returns memory with minimum alignment
2337 given by parameter 1.
2338
2339 @item alloc_size
2340 @cindex @code{alloc_size} function attribute
2341 The @code{alloc_size} attribute is used to tell the compiler that the
2342 function return value points to memory, where the size is given by
2343 one or two of the functions parameters. GCC uses this
2344 information to improve the correctness of @code{__builtin_object_size}.
2345
2346 The function parameter(s) denoting the allocated size are specified by
2347 one or two integer arguments supplied to the attribute. The allocated size
2348 is either the value of the single function argument specified or the product
2349 of the two function arguments specified. Argument numbering starts at
2350 one.
2351
2352 For instance,
2353
2354 @smallexample
2355 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2356 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2357 @end smallexample
2358
2359 @noindent
2360 declares that @code{my_calloc} returns memory of the size given by
2361 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2362 of the size given by parameter 2.
2363
2364 @item always_inline
2365 @cindex @code{always_inline} function attribute
2366 Generally, functions are not inlined unless optimization is specified.
2367 For functions declared inline, this attribute inlines the function
2368 independent of any restrictions that otherwise apply to inlining.
2369 Failure to inline such a function is diagnosed as an error.
2370 Note that if such a function is called indirectly the compiler may
2371 or may not inline it depending on optimization level and a failure
2372 to inline an indirect call may or may not be diagnosed.
2373
2374 @item artificial
2375 @cindex @code{artificial} function attribute
2376 This attribute is useful for small inline wrappers that if possible
2377 should appear during debugging as a unit. Depending on the debug
2378 info format it either means marking the function as artificial
2379 or using the caller location for all instructions within the inlined
2380 body.
2381
2382 @item assume_aligned
2383 @cindex @code{assume_aligned} function attribute
2384 The @code{assume_aligned} attribute is used to tell the compiler that the
2385 function return value points to memory, where the returned pointer minimum
2386 alignment is given by the first argument.
2387 If the attribute has two arguments, the second argument is misalignment offset.
2388
2389 For instance
2390
2391 @smallexample
2392 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2393 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2394 @end smallexample
2395
2396 @noindent
2397 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2398 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2399 to 8.
2400
2401 @item bnd_instrument
2402 @cindex @code{bnd_instrument} function attribute
2403 The @code{bnd_instrument} attribute on functions is used to inform the
2404 compiler that the function should be instrumented when compiled
2405 with the @option{-fchkp-instrument-marked-only} option.
2406
2407 @item bnd_legacy
2408 @cindex @code{bnd_legacy} function attribute
2409 @cindex Pointer Bounds Checker attributes
2410 The @code{bnd_legacy} attribute on functions is used to inform the
2411 compiler that the function should not be instrumented when compiled
2412 with the @option{-fcheck-pointer-bounds} option.
2413
2414 @item cold
2415 @cindex @code{cold} function attribute
2416 The @code{cold} attribute on functions is used to inform the compiler that
2417 the function is unlikely to be executed. The function is optimized for
2418 size rather than speed and on many targets it is placed into a special
2419 subsection of the text section so all cold functions appear close together,
2420 improving code locality of non-cold parts of program. The paths leading
2421 to calls of cold functions within code are marked as unlikely by the branch
2422 prediction mechanism. It is thus useful to mark functions used to handle
2423 unlikely conditions, such as @code{perror}, as cold to improve optimization
2424 of hot functions that do call marked functions in rare occasions.
2425
2426 When profile feedback is available, via @option{-fprofile-use}, cold functions
2427 are automatically detected and this attribute is ignored.
2428
2429 @item const
2430 @cindex @code{const} function attribute
2431 @cindex functions that have no side effects
2432 Many functions do not examine any values except their arguments, and
2433 have no effects except the return value. Basically this is just slightly
2434 more strict class than the @code{pure} attribute below, since function is not
2435 allowed to read global memory.
2436
2437 @cindex pointer arguments
2438 Note that a function that has pointer arguments and examines the data
2439 pointed to must @emph{not} be declared @code{const}. Likewise, a
2440 function that calls a non-@code{const} function usually must not be
2441 @code{const}. It does not make sense for a @code{const} function to
2442 return @code{void}.
2443
2444 @item constructor
2445 @itemx destructor
2446 @itemx constructor (@var{priority})
2447 @itemx destructor (@var{priority})
2448 @cindex @code{constructor} function attribute
2449 @cindex @code{destructor} function attribute
2450 The @code{constructor} attribute causes the function to be called
2451 automatically before execution enters @code{main ()}. Similarly, the
2452 @code{destructor} attribute causes the function to be called
2453 automatically after @code{main ()} completes or @code{exit ()} is
2454 called. Functions with these attributes are useful for
2455 initializing data that is used implicitly during the execution of
2456 the program.
2457
2458 You may provide an optional integer priority to control the order in
2459 which constructor and destructor functions are run. A constructor
2460 with a smaller priority number runs before a constructor with a larger
2461 priority number; the opposite relationship holds for destructors. So,
2462 if you have a constructor that allocates a resource and a destructor
2463 that deallocates the same resource, both functions typically have the
2464 same priority. The priorities for constructor and destructor
2465 functions are the same as those specified for namespace-scope C++
2466 objects (@pxref{C++ Attributes}).
2467
2468 These attributes are not currently implemented for Objective-C@.
2469
2470 @item deprecated
2471 @itemx deprecated (@var{msg})
2472 @cindex @code{deprecated} function attribute
2473 The @code{deprecated} attribute results in a warning if the function
2474 is used anywhere in the source file. This is useful when identifying
2475 functions that are expected to be removed in a future version of a
2476 program. The warning also includes the location of the declaration
2477 of the deprecated function, to enable users to easily find further
2478 information about why the function is deprecated, or what they should
2479 do instead. Note that the warnings only occurs for uses:
2480
2481 @smallexample
2482 int old_fn () __attribute__ ((deprecated));
2483 int old_fn ();
2484 int (*fn_ptr)() = old_fn;
2485 @end smallexample
2486
2487 @noindent
2488 results in a warning on line 3 but not line 2. The optional @var{msg}
2489 argument, which must be a string, is printed in the warning if
2490 present.
2491
2492 The @code{deprecated} attribute can also be used for variables and
2493 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2494
2495 @item error ("@var{message}")
2496 @itemx warning ("@var{message}")
2497 @cindex @code{error} function attribute
2498 @cindex @code{warning} function attribute
2499 If the @code{error} or @code{warning} attribute
2500 is used on a function declaration and a call to such a function
2501 is not eliminated through dead code elimination or other optimizations,
2502 an error or warning (respectively) that includes @var{message} is diagnosed.
2503 This is useful
2504 for compile-time checking, especially together with @code{__builtin_constant_p}
2505 and inline functions where checking the inline function arguments is not
2506 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2507
2508 While it is possible to leave the function undefined and thus invoke
2509 a link failure (to define the function with
2510 a message in @code{.gnu.warning*} section),
2511 when using these attributes the problem is diagnosed
2512 earlier and with exact location of the call even in presence of inline
2513 functions or when not emitting debugging information.
2514
2515 @item externally_visible
2516 @cindex @code{externally_visible} function attribute
2517 This attribute, attached to a global variable or function, nullifies
2518 the effect of the @option{-fwhole-program} command-line option, so the
2519 object remains visible outside the current compilation unit.
2520
2521 If @option{-fwhole-program} is used together with @option{-flto} and
2522 @command{gold} is used as the linker plugin,
2523 @code{externally_visible} attributes are automatically added to functions
2524 (not variable yet due to a current @command{gold} issue)
2525 that are accessed outside of LTO objects according to resolution file
2526 produced by @command{gold}.
2527 For other linkers that cannot generate resolution file,
2528 explicit @code{externally_visible} attributes are still necessary.
2529
2530 @item flatten
2531 @cindex @code{flatten} function attribute
2532 Generally, inlining into a function is limited. For a function marked with
2533 this attribute, every call inside this function is inlined, if possible.
2534 Whether the function itself is considered for inlining depends on its size and
2535 the current inlining parameters.
2536
2537 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2538 @cindex @code{format} function attribute
2539 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2540 @opindex Wformat
2541 The @code{format} attribute specifies that a function takes @code{printf},
2542 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2543 should be type-checked against a format string. For example, the
2544 declaration:
2545
2546 @smallexample
2547 extern int
2548 my_printf (void *my_object, const char *my_format, ...)
2549 __attribute__ ((format (printf, 2, 3)));
2550 @end smallexample
2551
2552 @noindent
2553 causes the compiler to check the arguments in calls to @code{my_printf}
2554 for consistency with the @code{printf} style format string argument
2555 @code{my_format}.
2556
2557 The parameter @var{archetype} determines how the format string is
2558 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2559 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2560 @code{strfmon}. (You can also use @code{__printf__},
2561 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2562 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2563 @code{ms_strftime} are also present.
2564 @var{archetype} values such as @code{printf} refer to the formats accepted
2565 by the system's C runtime library,
2566 while values prefixed with @samp{gnu_} always refer
2567 to the formats accepted by the GNU C Library. On Microsoft Windows
2568 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2569 @file{msvcrt.dll} library.
2570 The parameter @var{string-index}
2571 specifies which argument is the format string argument (starting
2572 from 1), while @var{first-to-check} is the number of the first
2573 argument to check against the format string. For functions
2574 where the arguments are not available to be checked (such as
2575 @code{vprintf}), specify the third parameter as zero. In this case the
2576 compiler only checks the format string for consistency. For
2577 @code{strftime} formats, the third parameter is required to be zero.
2578 Since non-static C++ methods have an implicit @code{this} argument, the
2579 arguments of such methods should be counted from two, not one, when
2580 giving values for @var{string-index} and @var{first-to-check}.
2581
2582 In the example above, the format string (@code{my_format}) is the second
2583 argument of the function @code{my_print}, and the arguments to check
2584 start with the third argument, so the correct parameters for the format
2585 attribute are 2 and 3.
2586
2587 @opindex ffreestanding
2588 @opindex fno-builtin
2589 The @code{format} attribute allows you to identify your own functions
2590 that take format strings as arguments, so that GCC can check the
2591 calls to these functions for errors. The compiler always (unless
2592 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2593 for the standard library functions @code{printf}, @code{fprintf},
2594 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2595 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2596 warnings are requested (using @option{-Wformat}), so there is no need to
2597 modify the header file @file{stdio.h}. In C99 mode, the functions
2598 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2599 @code{vsscanf} are also checked. Except in strictly conforming C
2600 standard modes, the X/Open function @code{strfmon} is also checked as
2601 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2602 @xref{C Dialect Options,,Options Controlling C Dialect}.
2603
2604 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2605 recognized in the same context. Declarations including these format attributes
2606 are parsed for correct syntax, however the result of checking of such format
2607 strings is not yet defined, and is not carried out by this version of the
2608 compiler.
2609
2610 The target may also provide additional types of format checks.
2611 @xref{Target Format Checks,,Format Checks Specific to Particular
2612 Target Machines}.
2613
2614 @item format_arg (@var{string-index})
2615 @cindex @code{format_arg} function attribute
2616 @opindex Wformat-nonliteral
2617 The @code{format_arg} attribute specifies that a function takes a format
2618 string for a @code{printf}, @code{scanf}, @code{strftime} or
2619 @code{strfmon} style function and modifies it (for example, to translate
2620 it into another language), so the result can be passed to a
2621 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2622 function (with the remaining arguments to the format function the same
2623 as they would have been for the unmodified string). For example, the
2624 declaration:
2625
2626 @smallexample
2627 extern char *
2628 my_dgettext (char *my_domain, const char *my_format)
2629 __attribute__ ((format_arg (2)));
2630 @end smallexample
2631
2632 @noindent
2633 causes the compiler to check the arguments in calls to a @code{printf},
2634 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2635 format string argument is a call to the @code{my_dgettext} function, for
2636 consistency with the format string argument @code{my_format}. If the
2637 @code{format_arg} attribute had not been specified, all the compiler
2638 could tell in such calls to format functions would be that the format
2639 string argument is not constant; this would generate a warning when
2640 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2641 without the attribute.
2642
2643 The parameter @var{string-index} specifies which argument is the format
2644 string argument (starting from one). Since non-static C++ methods have
2645 an implicit @code{this} argument, the arguments of such methods should
2646 be counted from two.
2647
2648 The @code{format_arg} attribute allows you to identify your own
2649 functions that modify format strings, so that GCC can check the
2650 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2651 type function whose operands are a call to one of your own function.
2652 The compiler always treats @code{gettext}, @code{dgettext}, and
2653 @code{dcgettext} in this manner except when strict ISO C support is
2654 requested by @option{-ansi} or an appropriate @option{-std} option, or
2655 @option{-ffreestanding} or @option{-fno-builtin}
2656 is used. @xref{C Dialect Options,,Options
2657 Controlling C Dialect}.
2658
2659 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2660 @code{NSString} reference for compatibility with the @code{format} attribute
2661 above.
2662
2663 The target may also allow additional types in @code{format-arg} attributes.
2664 @xref{Target Format Checks,,Format Checks Specific to Particular
2665 Target Machines}.
2666
2667 @item gnu_inline
2668 @cindex @code{gnu_inline} function attribute
2669 This attribute should be used with a function that is also declared
2670 with the @code{inline} keyword. It directs GCC to treat the function
2671 as if it were defined in gnu90 mode even when compiling in C99 or
2672 gnu99 mode.
2673
2674 If the function is declared @code{extern}, then this definition of the
2675 function is used only for inlining. In no case is the function
2676 compiled as a standalone function, not even if you take its address
2677 explicitly. Such an address becomes an external reference, as if you
2678 had only declared the function, and had not defined it. This has
2679 almost the effect of a macro. The way to use this is to put a
2680 function definition in a header file with this attribute, and put
2681 another copy of the function, without @code{extern}, in a library
2682 file. The definition in the header file causes most calls to the
2683 function to be inlined. If any uses of the function remain, they
2684 refer to the single copy in the library. Note that the two
2685 definitions of the functions need not be precisely the same, although
2686 if they do not have the same effect your program may behave oddly.
2687
2688 In C, if the function is neither @code{extern} nor @code{static}, then
2689 the function is compiled as a standalone function, as well as being
2690 inlined where possible.
2691
2692 This is how GCC traditionally handled functions declared
2693 @code{inline}. Since ISO C99 specifies a different semantics for
2694 @code{inline}, this function attribute is provided as a transition
2695 measure and as a useful feature in its own right. This attribute is
2696 available in GCC 4.1.3 and later. It is available if either of the
2697 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2698 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2699 Function is As Fast As a Macro}.
2700
2701 In C++, this attribute does not depend on @code{extern} in any way,
2702 but it still requires the @code{inline} keyword to enable its special
2703 behavior.
2704
2705 @item hot
2706 @cindex @code{hot} function attribute
2707 The @code{hot} attribute on a function is used to inform the compiler that
2708 the function is a hot spot of the compiled program. The function is
2709 optimized more aggressively and on many targets it is placed into a special
2710 subsection of the text section so all hot functions appear close together,
2711 improving locality.
2712
2713 When profile feedback is available, via @option{-fprofile-use}, hot functions
2714 are automatically detected and this attribute is ignored.
2715
2716 @item ifunc ("@var{resolver}")
2717 @cindex @code{ifunc} function attribute
2718 @cindex indirect functions
2719 @cindex functions that are dynamically resolved
2720 The @code{ifunc} attribute is used to mark a function as an indirect
2721 function using the STT_GNU_IFUNC symbol type extension to the ELF
2722 standard. This allows the resolution of the symbol value to be
2723 determined dynamically at load time, and an optimized version of the
2724 routine can be selected for the particular processor or other system
2725 characteristics determined then. To use this attribute, first define
2726 the implementation functions available, and a resolver function that
2727 returns a pointer to the selected implementation function. The
2728 implementation functions' declarations must match the API of the
2729 function being implemented, the resolver's declaration is be a
2730 function returning pointer to void function returning void:
2731
2732 @smallexample
2733 void *my_memcpy (void *dst, const void *src, size_t len)
2734 @{
2735 @dots{}
2736 @}
2737
2738 static void (*resolve_memcpy (void)) (void)
2739 @{
2740 return my_memcpy; // we'll just always select this routine
2741 @}
2742 @end smallexample
2743
2744 @noindent
2745 The exported header file declaring the function the user calls would
2746 contain:
2747
2748 @smallexample
2749 extern void *memcpy (void *, const void *, size_t);
2750 @end smallexample
2751
2752 @noindent
2753 allowing the user to call this as a regular function, unaware of the
2754 implementation. Finally, the indirect function needs to be defined in
2755 the same translation unit as the resolver function:
2756
2757 @smallexample
2758 void *memcpy (void *, const void *, size_t)
2759 __attribute__ ((ifunc ("resolve_memcpy")));
2760 @end smallexample
2761
2762 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2763 and GNU C Library version 2.11.1 are required to use this feature.
2764
2765 @item interrupt
2766 @itemx interrupt_handler
2767 Many GCC back ends support attributes to indicate that a function is
2768 an interrupt handler, which tells the compiler to generate function
2769 entry and exit sequences that differ from those from regular
2770 functions. The exact syntax and behavior are target-specific;
2771 refer to the following subsections for details.
2772
2773 @item leaf
2774 @cindex @code{leaf} function attribute
2775 Calls to external functions with this attribute must return to the current
2776 compilation unit only by return or by exception handling. In particular, leaf
2777 functions are not allowed to call callback function passed to it from the current
2778 compilation unit or directly call functions exported by the unit or longjmp
2779 into the unit. Leaf function might still call functions from other compilation
2780 units and thus they are not necessarily leaf in the sense that they contain no
2781 function calls at all.
2782
2783 The attribute is intended for library functions to improve dataflow analysis.
2784 The compiler takes the hint that any data not escaping the current compilation unit can
2785 not be used or modified by the leaf function. For example, the @code{sin} function
2786 is a leaf function, but @code{qsort} is not.
2787
2788 Note that leaf functions might invoke signals and signal handlers might be
2789 defined in the current compilation unit and use static variables. The only
2790 compliant way to write such a signal handler is to declare such variables
2791 @code{volatile}.
2792
2793 The attribute has no effect on functions defined within the current compilation
2794 unit. This is to allow easy merging of multiple compilation units into one,
2795 for example, by using the link-time optimization. For this reason the
2796 attribute is not allowed on types to annotate indirect calls.
2797
2798
2799 @item malloc
2800 @cindex @code{malloc} function attribute
2801 @cindex functions that behave like malloc
2802 This tells the compiler that a function is @code{malloc}-like, i.e.,
2803 that the pointer @var{P} returned by the function cannot alias any
2804 other pointer valid when the function returns, and moreover no
2805 pointers to valid objects occur in any storage addressed by @var{P}.
2806
2807 Using this attribute can improve optimization. Functions like
2808 @code{malloc} and @code{calloc} have this property because they return
2809 a pointer to uninitialized or zeroed-out storage. However, functions
2810 like @code{realloc} do not have this property, as they can return a
2811 pointer to storage containing pointers.
2812
2813 @item no_icf
2814 @cindex @code{no_icf} function attribute
2815 This function attribute prevents a functions from being merged with another
2816 semantically equivalent function.
2817
2818 @item no_instrument_function
2819 @cindex @code{no_instrument_function} function attribute
2820 @opindex finstrument-functions
2821 If @option{-finstrument-functions} is given, profiling function calls are
2822 generated at entry and exit of most user-compiled functions.
2823 Functions with this attribute are not so instrumented.
2824
2825 @item no_reorder
2826 @cindex @code{no_reorder} function attribute
2827 Do not reorder functions or variables marked @code{no_reorder}
2828 against each other or top level assembler statements the executable.
2829 The actual order in the program will depend on the linker command
2830 line. Static variables marked like this are also not removed.
2831 This has a similar effect
2832 as the @option{-fno-toplevel-reorder} option, but only applies to the
2833 marked symbols.
2834
2835 @item no_sanitize_address
2836 @itemx no_address_safety_analysis
2837 @cindex @code{no_sanitize_address} function attribute
2838 The @code{no_sanitize_address} attribute on functions is used
2839 to inform the compiler that it should not instrument memory accesses
2840 in the function when compiling with the @option{-fsanitize=address} option.
2841 The @code{no_address_safety_analysis} is a deprecated alias of the
2842 @code{no_sanitize_address} attribute, new code should use
2843 @code{no_sanitize_address}.
2844
2845 @item no_sanitize_thread
2846 @cindex @code{no_sanitize_thread} function attribute
2847 The @code{no_sanitize_thread} attribute on functions is used
2848 to inform the compiler that it should not instrument memory accesses
2849 in the function when compiling with the @option{-fsanitize=thread} option.
2850
2851 @item no_sanitize_undefined
2852 @cindex @code{no_sanitize_undefined} function attribute
2853 The @code{no_sanitize_undefined} attribute on functions is used
2854 to inform the compiler that it should not check for undefined behavior
2855 in the function when compiling with the @option{-fsanitize=undefined} option.
2856
2857 @item no_split_stack
2858 @cindex @code{no_split_stack} function attribute
2859 @opindex fsplit-stack
2860 If @option{-fsplit-stack} is given, functions have a small
2861 prologue which decides whether to split the stack. Functions with the
2862 @code{no_split_stack} attribute do not have that prologue, and thus
2863 may run with only a small amount of stack space available.
2864
2865 @item no_stack_limit
2866 @cindex @code{no_stack_limit} function attribute
2867 This attribute locally overrides the @option{-fstack-limit-register}
2868 and @option{-fstack-limit-symbol} command-line options; it has the effect
2869 of disabling stack limit checking in the function it applies to.
2870
2871 @item noclone
2872 @cindex @code{noclone} function attribute
2873 This function attribute prevents a function from being considered for
2874 cloning---a mechanism that produces specialized copies of functions
2875 and which is (currently) performed by interprocedural constant
2876 propagation.
2877
2878 @item noinline
2879 @cindex @code{noinline} function attribute
2880 This function attribute prevents a function from being considered for
2881 inlining.
2882 @c Don't enumerate the optimizations by name here; we try to be
2883 @c future-compatible with this mechanism.
2884 If the function does not have side-effects, there are optimizations
2885 other than inlining that cause function calls to be optimized away,
2886 although the function call is live. To keep such calls from being
2887 optimized away, put
2888 @smallexample
2889 asm ("");
2890 @end smallexample
2891
2892 @noindent
2893 (@pxref{Extended Asm}) in the called function, to serve as a special
2894 side-effect.
2895
2896 @item nonnull (@var{arg-index}, @dots{})
2897 @cindex @code{nonnull} function attribute
2898 @cindex functions with non-null pointer arguments
2899 The @code{nonnull} attribute specifies that some function parameters should
2900 be non-null pointers. For instance, the declaration:
2901
2902 @smallexample
2903 extern void *
2904 my_memcpy (void *dest, const void *src, size_t len)
2905 __attribute__((nonnull (1, 2)));
2906 @end smallexample
2907
2908 @noindent
2909 causes the compiler to check that, in calls to @code{my_memcpy},
2910 arguments @var{dest} and @var{src} are non-null. If the compiler
2911 determines that a null pointer is passed in an argument slot marked
2912 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2913 is issued. The compiler may also choose to make optimizations based
2914 on the knowledge that certain function arguments will never be null.
2915
2916 If no argument index list is given to the @code{nonnull} attribute,
2917 all pointer arguments are marked as non-null. To illustrate, the
2918 following declaration is equivalent to the previous example:
2919
2920 @smallexample
2921 extern void *
2922 my_memcpy (void *dest, const void *src, size_t len)
2923 __attribute__((nonnull));
2924 @end smallexample
2925
2926 @item noplt
2927 @cindex @code{noplt} function attribute
2928 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2929 Calls to functions marked with this attribute in position-independent code
2930 do not use the PLT.
2931
2932 @smallexample
2933 @group
2934 /* Externally defined function foo. */
2935 int foo () __attribute__ ((noplt));
2936
2937 int
2938 main (/* @r{@dots{}} */)
2939 @{
2940 /* @r{@dots{}} */
2941 foo ();
2942 /* @r{@dots{}} */
2943 @}
2944 @end group
2945 @end smallexample
2946
2947 The @code{noplt} attribute on function @code{foo}
2948 tells the compiler to assume that
2949 the function @code{foo} is externally defined and that the call to
2950 @code{foo} must avoid the PLT
2951 in position-independent code.
2952
2953 In position-dependent code, a few targets also convert calls to
2954 functions that are marked to not use the PLT to use the GOT instead.
2955
2956 @item noreturn
2957 @cindex @code{noreturn} function attribute
2958 @cindex functions that never return
2959 A few standard library functions, such as @code{abort} and @code{exit},
2960 cannot return. GCC knows this automatically. Some programs define
2961 their own functions that never return. You can declare them
2962 @code{noreturn} to tell the compiler this fact. For example,
2963
2964 @smallexample
2965 @group
2966 void fatal () __attribute__ ((noreturn));
2967
2968 void
2969 fatal (/* @r{@dots{}} */)
2970 @{
2971 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2972 exit (1);
2973 @}
2974 @end group
2975 @end smallexample
2976
2977 The @code{noreturn} keyword tells the compiler to assume that
2978 @code{fatal} cannot return. It can then optimize without regard to what
2979 would happen if @code{fatal} ever did return. This makes slightly
2980 better code. More importantly, it helps avoid spurious warnings of
2981 uninitialized variables.
2982
2983 The @code{noreturn} keyword does not affect the exceptional path when that
2984 applies: a @code{noreturn}-marked function may still return to the caller
2985 by throwing an exception or calling @code{longjmp}.
2986
2987 Do not assume that registers saved by the calling function are
2988 restored before calling the @code{noreturn} function.
2989
2990 It does not make sense for a @code{noreturn} function to have a return
2991 type other than @code{void}.
2992
2993 @item nothrow
2994 @cindex @code{nothrow} function attribute
2995 The @code{nothrow} attribute is used to inform the compiler that a
2996 function cannot throw an exception. For example, most functions in
2997 the standard C library can be guaranteed not to throw an exception
2998 with the notable exceptions of @code{qsort} and @code{bsearch} that
2999 take function pointer arguments.
3000
3001 @item optimize
3002 @cindex @code{optimize} function attribute
3003 The @code{optimize} attribute is used to specify that a function is to
3004 be compiled with different optimization options than specified on the
3005 command line. Arguments can either be numbers or strings. Numbers
3006 are assumed to be an optimization level. Strings that begin with
3007 @code{O} are assumed to be an optimization option, while other options
3008 are assumed to be used with a @code{-f} prefix. You can also use the
3009 @samp{#pragma GCC optimize} pragma to set the optimization options
3010 that affect more than one function.
3011 @xref{Function Specific Option Pragmas}, for details about the
3012 @samp{#pragma GCC optimize} pragma.
3013
3014 This can be used for instance to have frequently-executed functions
3015 compiled with more aggressive optimization options that produce faster
3016 and larger code, while other functions can be compiled with less
3017 aggressive options.
3018
3019 @item pure
3020 @cindex @code{pure} function attribute
3021 @cindex functions that have no side effects
3022 Many functions have no effects except the return value and their
3023 return value depends only on the parameters and/or global variables.
3024 Such a function can be subject
3025 to common subexpression elimination and loop optimization just as an
3026 arithmetic operator would be. These functions should be declared
3027 with the attribute @code{pure}. For example,
3028
3029 @smallexample
3030 int square (int) __attribute__ ((pure));
3031 @end smallexample
3032
3033 @noindent
3034 says that the hypothetical function @code{square} is safe to call
3035 fewer times than the program says.
3036
3037 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3038 Interesting non-pure functions are functions with infinite loops or those
3039 depending on volatile memory or other system resource, that may change between
3040 two consecutive calls (such as @code{feof} in a multithreading environment).
3041
3042 @item returns_nonnull
3043 @cindex @code{returns_nonnull} function attribute
3044 The @code{returns_nonnull} attribute specifies that the function
3045 return value should be a non-null pointer. For instance, the declaration:
3046
3047 @smallexample
3048 extern void *
3049 mymalloc (size_t len) __attribute__((returns_nonnull));
3050 @end smallexample
3051
3052 @noindent
3053 lets the compiler optimize callers based on the knowledge
3054 that the return value will never be null.
3055
3056 @item returns_twice
3057 @cindex @code{returns_twice} function attribute
3058 @cindex functions that return more than once
3059 The @code{returns_twice} attribute tells the compiler that a function may
3060 return more than one time. The compiler ensures that all registers
3061 are dead before calling such a function and emits a warning about
3062 the variables that may be clobbered after the second return from the
3063 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3064 The @code{longjmp}-like counterpart of such function, if any, might need
3065 to be marked with the @code{noreturn} attribute.
3066
3067 @item section ("@var{section-name}")
3068 @cindex @code{section} function attribute
3069 @cindex functions in arbitrary sections
3070 Normally, the compiler places the code it generates in the @code{text} section.
3071 Sometimes, however, you need additional sections, or you need certain
3072 particular functions to appear in special sections. The @code{section}
3073 attribute specifies that a function lives in a particular section.
3074 For example, the declaration:
3075
3076 @smallexample
3077 extern void foobar (void) __attribute__ ((section ("bar")));
3078 @end smallexample
3079
3080 @noindent
3081 puts the function @code{foobar} in the @code{bar} section.
3082
3083 Some file formats do not support arbitrary sections so the @code{section}
3084 attribute is not available on all platforms.
3085 If you need to map the entire contents of a module to a particular
3086 section, consider using the facilities of the linker instead.
3087
3088 @item sentinel
3089 @cindex @code{sentinel} function attribute
3090 This function attribute ensures that a parameter in a function call is
3091 an explicit @code{NULL}. The attribute is only valid on variadic
3092 functions. By default, the sentinel is located at position zero, the
3093 last parameter of the function call. If an optional integer position
3094 argument P is supplied to the attribute, the sentinel must be located at
3095 position P counting backwards from the end of the argument list.
3096
3097 @smallexample
3098 __attribute__ ((sentinel))
3099 is equivalent to
3100 __attribute__ ((sentinel(0)))
3101 @end smallexample
3102
3103 The attribute is automatically set with a position of 0 for the built-in
3104 functions @code{execl} and @code{execlp}. The built-in function
3105 @code{execle} has the attribute set with a position of 1.
3106
3107 A valid @code{NULL} in this context is defined as zero with any pointer
3108 type. If your system defines the @code{NULL} macro with an integer type
3109 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3110 with a copy that redefines NULL appropriately.
3111
3112 The warnings for missing or incorrect sentinels are enabled with
3113 @option{-Wformat}.
3114
3115 @item simd
3116 @itemx simd("@var{mask}")
3117 @cindex @code{simd} function attribute
3118 This attribute enables creation of one or more function versions that
3119 can process multiple arguments using SIMD instructions from a
3120 single invocation. Specifying this attribute allows compiler to
3121 assume that such versions are available at link time (provided
3122 in the same or another translation unit). Generated versions are
3123 target-dependent and described in the corresponding Vector ABI document. For
3124 x86_64 target this document can be found
3125 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3126
3127 The optional argument @var{mask} may have the value
3128 @code{notinbranch} or @code{inbranch},
3129 and instructs the compiler to generate non-masked or masked
3130 clones correspondingly. By default, all clones are generated.
3131
3132 The attribute should not be used together with Cilk Plus @code{vector}
3133 attribute on the same function.
3134
3135 If the attribute is specified and @code{#pragma omp declare simd} is
3136 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3137 switch is specified, then the attribute is ignored.
3138
3139 @item stack_protect
3140 @cindex @code{stack_protect} function attribute
3141 This attribute adds stack protection code to the function if
3142 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3143 or @option{-fstack-protector-explicit} are set.
3144
3145 @item target (@var{options})
3146 @cindex @code{target} function attribute
3147 Multiple target back ends implement the @code{target} attribute
3148 to specify that a function is to
3149 be compiled with different target options than specified on the
3150 command line. This can be used for instance to have functions
3151 compiled with a different ISA (instruction set architecture) than the
3152 default. You can also use the @samp{#pragma GCC target} pragma to set
3153 more than one function to be compiled with specific target options.
3154 @xref{Function Specific Option Pragmas}, for details about the
3155 @samp{#pragma GCC target} pragma.
3156
3157 For instance, on an x86, you could declare one function with the
3158 @code{target("sse4.1,arch=core2")} attribute and another with
3159 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3160 compiling the first function with @option{-msse4.1} and
3161 @option{-march=core2} options, and the second function with
3162 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3163 to make sure that a function is only invoked on a machine that
3164 supports the particular ISA it is compiled for (for example by using
3165 @code{cpuid} on x86 to determine what feature bits and architecture
3166 family are used).
3167
3168 @smallexample
3169 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3170 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3171 @end smallexample
3172
3173 You can either use multiple
3174 strings separated by commas to specify multiple options,
3175 or separate the options with a comma (@samp{,}) within a single string.
3176
3177 The options supported are specific to each target; refer to @ref{x86
3178 Function Attributes}, @ref{PowerPC Function Attributes},
3179 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3180 for details.
3181
3182 @item target_clones (@var{options})
3183 @cindex @code{target_clones} function attribute
3184 The @code{target_clones} attribute is used to specify that a function
3185 be cloned into multiple versions compiled with different target options
3186 than specified on the command line. The supported options and restrictions
3187 are the same as for @code{target} attribute.
3188
3189 For instance, on an x86, you could compile a function with
3190 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3191 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3192 It also creates a resolver function (see the @code{ifunc} attribute
3193 above) that dynamically selects a clone suitable for current architecture.
3194
3195 @item unused
3196 @cindex @code{unused} function attribute
3197 This attribute, attached to a function, means that the function is meant
3198 to be possibly unused. GCC does not produce a warning for this
3199 function.
3200
3201 @item used
3202 @cindex @code{used} function attribute
3203 This attribute, attached to a function, means that code must be emitted
3204 for the function even if it appears that the function is not referenced.
3205 This is useful, for example, when the function is referenced only in
3206 inline assembly.
3207
3208 When applied to a member function of a C++ class template, the
3209 attribute also means that the function is instantiated if the
3210 class itself is instantiated.
3211
3212 @item visibility ("@var{visibility_type}")
3213 @cindex @code{visibility} function attribute
3214 This attribute affects the linkage of the declaration to which it is attached.
3215 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3216 (@pxref{Common Type Attributes}) as well as functions.
3217
3218 There are four supported @var{visibility_type} values: default,
3219 hidden, protected or internal visibility.
3220
3221 @smallexample
3222 void __attribute__ ((visibility ("protected")))
3223 f () @{ /* @r{Do something.} */; @}
3224 int i __attribute__ ((visibility ("hidden")));
3225 @end smallexample
3226
3227 The possible values of @var{visibility_type} correspond to the
3228 visibility settings in the ELF gABI.
3229
3230 @table @code
3231 @c keep this list of visibilities in alphabetical order.
3232
3233 @item default
3234 Default visibility is the normal case for the object file format.
3235 This value is available for the visibility attribute to override other
3236 options that may change the assumed visibility of entities.
3237
3238 On ELF, default visibility means that the declaration is visible to other
3239 modules and, in shared libraries, means that the declared entity may be
3240 overridden.
3241
3242 On Darwin, default visibility means that the declaration is visible to
3243 other modules.
3244
3245 Default visibility corresponds to ``external linkage'' in the language.
3246
3247 @item hidden
3248 Hidden visibility indicates that the entity declared has a new
3249 form of linkage, which we call ``hidden linkage''. Two
3250 declarations of an object with hidden linkage refer to the same object
3251 if they are in the same shared object.
3252
3253 @item internal
3254 Internal visibility is like hidden visibility, but with additional
3255 processor specific semantics. Unless otherwise specified by the
3256 psABI, GCC defines internal visibility to mean that a function is
3257 @emph{never} called from another module. Compare this with hidden
3258 functions which, while they cannot be referenced directly by other
3259 modules, can be referenced indirectly via function pointers. By
3260 indicating that a function cannot be called from outside the module,
3261 GCC may for instance omit the load of a PIC register since it is known
3262 that the calling function loaded the correct value.
3263
3264 @item protected
3265 Protected visibility is like default visibility except that it
3266 indicates that references within the defining module bind to the
3267 definition in that module. That is, the declared entity cannot be
3268 overridden by another module.
3269
3270 @end table
3271
3272 All visibilities are supported on many, but not all, ELF targets
3273 (supported when the assembler supports the @samp{.visibility}
3274 pseudo-op). Default visibility is supported everywhere. Hidden
3275 visibility is supported on Darwin targets.
3276
3277 The visibility attribute should be applied only to declarations that
3278 would otherwise have external linkage. The attribute should be applied
3279 consistently, so that the same entity should not be declared with
3280 different settings of the attribute.
3281
3282 In C++, the visibility attribute applies to types as well as functions
3283 and objects, because in C++ types have linkage. A class must not have
3284 greater visibility than its non-static data member types and bases,
3285 and class members default to the visibility of their class. Also, a
3286 declaration without explicit visibility is limited to the visibility
3287 of its type.
3288
3289 In C++, you can mark member functions and static member variables of a
3290 class with the visibility attribute. This is useful if you know a
3291 particular method or static member variable should only be used from
3292 one shared object; then you can mark it hidden while the rest of the
3293 class has default visibility. Care must be taken to avoid breaking
3294 the One Definition Rule; for example, it is usually not useful to mark
3295 an inline method as hidden without marking the whole class as hidden.
3296
3297 A C++ namespace declaration can also have the visibility attribute.
3298
3299 @smallexample
3300 namespace nspace1 __attribute__ ((visibility ("protected")))
3301 @{ /* @r{Do something.} */; @}
3302 @end smallexample
3303
3304 This attribute applies only to the particular namespace body, not to
3305 other definitions of the same namespace; it is equivalent to using
3306 @samp{#pragma GCC visibility} before and after the namespace
3307 definition (@pxref{Visibility Pragmas}).
3308
3309 In C++, if a template argument has limited visibility, this
3310 restriction is implicitly propagated to the template instantiation.
3311 Otherwise, template instantiations and specializations default to the
3312 visibility of their template.
3313
3314 If both the template and enclosing class have explicit visibility, the
3315 visibility from the template is used.
3316
3317 @item warn_unused_result
3318 @cindex @code{warn_unused_result} function attribute
3319 The @code{warn_unused_result} attribute causes a warning to be emitted
3320 if a caller of the function with this attribute does not use its
3321 return value. This is useful for functions where not checking
3322 the result is either a security problem or always a bug, such as
3323 @code{realloc}.
3324
3325 @smallexample
3326 int fn () __attribute__ ((warn_unused_result));
3327 int foo ()
3328 @{
3329 if (fn () < 0) return -1;
3330 fn ();
3331 return 0;
3332 @}
3333 @end smallexample
3334
3335 @noindent
3336 results in warning on line 5.
3337
3338 @item weak
3339 @cindex @code{weak} function attribute
3340 The @code{weak} attribute causes the declaration to be emitted as a weak
3341 symbol rather than a global. This is primarily useful in defining
3342 library functions that can be overridden in user code, though it can
3343 also be used with non-function declarations. Weak symbols are supported
3344 for ELF targets, and also for a.out targets when using the GNU assembler
3345 and linker.
3346
3347 @item weakref
3348 @itemx weakref ("@var{target}")
3349 @cindex @code{weakref} function attribute
3350 The @code{weakref} attribute marks a declaration as a weak reference.
3351 Without arguments, it should be accompanied by an @code{alias} attribute
3352 naming the target symbol. Optionally, the @var{target} may be given as
3353 an argument to @code{weakref} itself. In either case, @code{weakref}
3354 implicitly marks the declaration as @code{weak}. Without a
3355 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3356 @code{weakref} is equivalent to @code{weak}.
3357
3358 @smallexample
3359 static int x() __attribute__ ((weakref ("y")));
3360 /* is equivalent to... */
3361 static int x() __attribute__ ((weak, weakref, alias ("y")));
3362 /* and to... */
3363 static int x() __attribute__ ((weakref));
3364 static int x() __attribute__ ((alias ("y")));
3365 @end smallexample
3366
3367 A weak reference is an alias that does not by itself require a
3368 definition to be given for the target symbol. If the target symbol is
3369 only referenced through weak references, then it becomes a @code{weak}
3370 undefined symbol. If it is directly referenced, however, then such
3371 strong references prevail, and a definition is required for the
3372 symbol, not necessarily in the same translation unit.
3373
3374 The effect is equivalent to moving all references to the alias to a
3375 separate translation unit, renaming the alias to the aliased symbol,
3376 declaring it as weak, compiling the two separate translation units and
3377 performing a reloadable link on them.
3378
3379 At present, a declaration to which @code{weakref} is attached can
3380 only be @code{static}.
3381
3382
3383 @end table
3384
3385 @c This is the end of the target-independent attribute table
3386
3387 @node AArch64 Function Attributes
3388 @subsection AArch64 Function Attributes
3389
3390 The following target-specific function attributes are available for the
3391 AArch64 target. For the most part, these options mirror the behavior of
3392 similar command-line options (@pxref{AArch64 Options}), but on a
3393 per-function basis.
3394
3395 @table @code
3396 @item general-regs-only
3397 @cindex @code{general-regs-only} function attribute, AArch64
3398 Indicates that no floating-point or Advanced SIMD registers should be
3399 used when generating code for this function. If the function explicitly
3400 uses floating-point code, then the compiler gives an error. This is
3401 the same behavior as that of the command-line option
3402 @option{-mgeneral-regs-only}.
3403
3404 @item fix-cortex-a53-835769
3405 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3406 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3407 applied to this function. To explicitly disable the workaround for this
3408 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3409 This corresponds to the behavior of the command line options
3410 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3411
3412 @item cmodel=
3413 @cindex @code{cmodel=} function attribute, AArch64
3414 Indicates that code should be generated for a particular code model for
3415 this function. The behavior and permissible arguments are the same as
3416 for the command line option @option{-mcmodel=}.
3417
3418 @item strict-align
3419 @cindex @code{strict-align} function attribute, AArch64
3420 Indicates that the compiler should not assume that unaligned memory references
3421 are handled by the system. The behavior is the same as for the command-line
3422 option @option{-mstrict-align}.
3423
3424 @item omit-leaf-frame-pointer
3425 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3426 Indicates that the frame pointer should be omitted for a leaf function call.
3427 To keep the frame pointer, the inverse attribute
3428 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3429 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3430 and @option{-mno-omit-leaf-frame-pointer}.
3431
3432 @item tls-dialect=
3433 @cindex @code{tls-dialect=} function attribute, AArch64
3434 Specifies the TLS dialect to use for this function. The behavior and
3435 permissible arguments are the same as for the command-line option
3436 @option{-mtls-dialect=}.
3437
3438 @item arch=
3439 @cindex @code{arch=} function attribute, AArch64
3440 Specifies the architecture version and architectural extensions to use
3441 for this function. The behavior and permissible arguments are the same as
3442 for the @option{-march=} command-line option.
3443
3444 @item tune=
3445 @cindex @code{tune=} function attribute, AArch64
3446 Specifies the core for which to tune the performance of this function.
3447 The behavior and permissible arguments are the same as for the @option{-mtune=}
3448 command-line option.
3449
3450 @item cpu=
3451 @cindex @code{cpu=} function attribute, AArch64
3452 Specifies the core for which to tune the performance of this function and also
3453 whose architectural features to use. The behavior and valid arguments are the
3454 same as for the @option{-mcpu=} command-line option.
3455
3456 @end table
3457
3458 The above target attributes can be specified as follows:
3459
3460 @smallexample
3461 __attribute__((target("@var{attr-string}")))
3462 int
3463 f (int a)
3464 @{
3465 return a + 5;
3466 @}
3467 @end smallexample
3468
3469 where @code{@var{attr-string}} is one of the attribute strings specified above.
3470
3471 Additionally, the architectural extension string may be specified on its
3472 own. This can be used to turn on and off particular architectural extensions
3473 without having to specify a particular architecture version or core. Example:
3474
3475 @smallexample
3476 __attribute__((target("+crc+nocrypto")))
3477 int
3478 foo (int a)
3479 @{
3480 return a + 5;
3481 @}
3482 @end smallexample
3483
3484 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3485 extension and disables the @code{crypto} extension for the function @code{foo}
3486 without modifying an existing @option{-march=} or @option{-mcpu} option.
3487
3488 Multiple target function attributes can be specified by separating them with
3489 a comma. For example:
3490 @smallexample
3491 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3492 int
3493 foo (int a)
3494 @{
3495 return a + 5;
3496 @}
3497 @end smallexample
3498
3499 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3500 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3501
3502 @subsubsection Inlining rules
3503 Specifying target attributes on individual functions or performing link-time
3504 optimization across translation units compiled with different target options
3505 can affect function inlining rules:
3506
3507 In particular, a caller function can inline a callee function only if the
3508 architectural features available to the callee are a subset of the features
3509 available to the caller.
3510 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3511 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3512 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3513 because the all the architectural features that function @code{bar} requires
3514 are available to function @code{foo}. Conversely, function @code{bar} cannot
3515 inline function @code{foo}.
3516
3517 Additionally inlining a function compiled with @option{-mstrict-align} into a
3518 function compiled without @code{-mstrict-align} is not allowed.
3519 However, inlining a function compiled without @option{-mstrict-align} into a
3520 function compiled with @option{-mstrict-align} is allowed.
3521
3522 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3523 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3524 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3525 architectural feature rules specified above.
3526
3527 @node ARC Function Attributes
3528 @subsection ARC Function Attributes
3529
3530 These function attributes are supported by the ARC back end:
3531
3532 @table @code
3533 @item interrupt
3534 @cindex @code{interrupt} function attribute, ARC
3535 Use this attribute to indicate
3536 that the specified function is an interrupt handler. The compiler generates
3537 function entry and exit sequences suitable for use in an interrupt handler
3538 when this attribute is present.
3539
3540 On the ARC, you must specify the kind of interrupt to be handled
3541 in a parameter to the interrupt attribute like this:
3542
3543 @smallexample
3544 void f () __attribute__ ((interrupt ("ilink1")));
3545 @end smallexample
3546
3547 Permissible values for this parameter are: @w{@code{ilink1}} and
3548 @w{@code{ilink2}}.
3549
3550 @item long_call
3551 @itemx medium_call
3552 @itemx short_call
3553 @cindex @code{long_call} function attribute, ARC
3554 @cindex @code{medium_call} function attribute, ARC
3555 @cindex @code{short_call} function attribute, ARC
3556 @cindex indirect calls, ARC
3557 These attributes specify how a particular function is called.
3558 These attributes override the
3559 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3560 command-line switches and @code{#pragma long_calls} settings.
3561
3562 For ARC, a function marked with the @code{long_call} attribute is
3563 always called using register-indirect jump-and-link instructions,
3564 thereby enabling the called function to be placed anywhere within the
3565 32-bit address space. A function marked with the @code{medium_call}
3566 attribute will always be close enough to be called with an unconditional
3567 branch-and-link instruction, which has a 25-bit offset from
3568 the call site. A function marked with the @code{short_call}
3569 attribute will always be close enough to be called with a conditional
3570 branch-and-link instruction, which has a 21-bit offset from
3571 the call site.
3572 @end table
3573
3574 @node ARM Function Attributes
3575 @subsection ARM Function Attributes
3576
3577 These function attributes are supported for ARM targets:
3578
3579 @table @code
3580 @item interrupt
3581 @cindex @code{interrupt} function attribute, ARM
3582 Use this attribute to indicate
3583 that the specified function is an interrupt handler. The compiler generates
3584 function entry and exit sequences suitable for use in an interrupt handler
3585 when this attribute is present.
3586
3587 You can specify the kind of interrupt to be handled by
3588 adding an optional parameter to the interrupt attribute like this:
3589
3590 @smallexample
3591 void f () __attribute__ ((interrupt ("IRQ")));
3592 @end smallexample
3593
3594 @noindent
3595 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3596 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3597
3598 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3599 may be called with a word-aligned stack pointer.
3600
3601 @item isr
3602 @cindex @code{isr} function attribute, ARM
3603 Use this attribute on ARM to write Interrupt Service Routines. This is an
3604 alias to the @code{interrupt} attribute above.
3605
3606 @item long_call
3607 @itemx short_call
3608 @cindex @code{long_call} function attribute, ARM
3609 @cindex @code{short_call} function attribute, ARM
3610 @cindex indirect calls, ARM
3611 These attributes specify how a particular function is called.
3612 These attributes override the
3613 @option{-mlong-calls} (@pxref{ARM Options})
3614 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3615 @code{long_call} attribute indicates that the function might be far
3616 away from the call site and require a different (more expensive)
3617 calling sequence. The @code{short_call} attribute always places
3618 the offset to the function from the call site into the @samp{BL}
3619 instruction directly.
3620
3621 @item naked
3622 @cindex @code{naked} function attribute, ARM
3623 This attribute allows the compiler to construct the
3624 requisite function declaration, while allowing the body of the
3625 function to be assembly code. The specified function will not have
3626 prologue/epilogue sequences generated by the compiler. Only basic
3627 @code{asm} statements can safely be included in naked functions
3628 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3629 basic @code{asm} and C code may appear to work, they cannot be
3630 depended upon to work reliably and are not supported.
3631
3632 @item pcs
3633 @cindex @code{pcs} function attribute, ARM
3634
3635 The @code{pcs} attribute can be used to control the calling convention
3636 used for a function on ARM. The attribute takes an argument that specifies
3637 the calling convention to use.
3638
3639 When compiling using the AAPCS ABI (or a variant of it) then valid
3640 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3641 order to use a variant other than @code{"aapcs"} then the compiler must
3642 be permitted to use the appropriate co-processor registers (i.e., the
3643 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3644 For example,
3645
3646 @smallexample
3647 /* Argument passed in r0, and result returned in r0+r1. */
3648 double f2d (float) __attribute__((pcs("aapcs")));
3649 @end smallexample
3650
3651 Variadic functions always use the @code{"aapcs"} calling convention and
3652 the compiler rejects attempts to specify an alternative.
3653
3654 @item target (@var{options})
3655 @cindex @code{target} function attribute
3656 As discussed in @ref{Common Function Attributes}, this attribute
3657 allows specification of target-specific compilation options.
3658
3659 On ARM, the following options are allowed:
3660
3661 @table @samp
3662 @item thumb
3663 @cindex @code{target("thumb")} function attribute, ARM
3664 Force code generation in the Thumb (T16/T32) ISA, depending on the
3665 architecture level.
3666
3667 @item arm
3668 @cindex @code{target("arm")} function attribute, ARM
3669 Force code generation in the ARM (A32) ISA.
3670
3671 Functions from different modes can be inlined in the caller's mode.
3672
3673 @item fpu=
3674 @cindex @code{target("fpu=")} function attribute, ARM
3675 Specifies the fpu for which to tune the performance of this function.
3676 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3677 command-line option.
3678
3679 @end table
3680
3681 @end table
3682
3683 @node AVR Function Attributes
3684 @subsection AVR Function Attributes
3685
3686 These function attributes are supported by the AVR back end:
3687
3688 @table @code
3689 @item interrupt
3690 @cindex @code{interrupt} function attribute, AVR
3691 Use this attribute to indicate
3692 that the specified function is an interrupt handler. The compiler generates
3693 function entry and exit sequences suitable for use in an interrupt handler
3694 when this attribute is present.
3695
3696 On the AVR, the hardware globally disables interrupts when an
3697 interrupt is executed. The first instruction of an interrupt handler
3698 declared with this attribute is a @code{SEI} instruction to
3699 re-enable interrupts. See also the @code{signal} function attribute
3700 that does not insert a @code{SEI} instruction. If both @code{signal} and
3701 @code{interrupt} are specified for the same function, @code{signal}
3702 is silently ignored.
3703
3704 @item naked
3705 @cindex @code{naked} function attribute, AVR
3706 This attribute allows the compiler to construct the
3707 requisite function declaration, while allowing the body of the
3708 function to be assembly code. The specified function will not have
3709 prologue/epilogue sequences generated by the compiler. Only basic
3710 @code{asm} statements can safely be included in naked functions
3711 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3712 basic @code{asm} and C code may appear to work, they cannot be
3713 depended upon to work reliably and are not supported.
3714
3715 @item OS_main
3716 @itemx OS_task
3717 @cindex @code{OS_main} function attribute, AVR
3718 @cindex @code{OS_task} function attribute, AVR
3719 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3720 do not save/restore any call-saved register in their prologue/epilogue.
3721
3722 The @code{OS_main} attribute can be used when there @emph{is
3723 guarantee} that interrupts are disabled at the time when the function
3724 is entered. This saves resources when the stack pointer has to be
3725 changed to set up a frame for local variables.
3726
3727 The @code{OS_task} attribute can be used when there is @emph{no
3728 guarantee} that interrupts are disabled at that time when the function
3729 is entered like for, e@.g@. task functions in a multi-threading operating
3730 system. In that case, changing the stack pointer register is
3731 guarded by save/clear/restore of the global interrupt enable flag.
3732
3733 The differences to the @code{naked} function attribute are:
3734 @itemize @bullet
3735 @item @code{naked} functions do not have a return instruction whereas
3736 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3737 @code{RETI} return instruction.
3738 @item @code{naked} functions do not set up a frame for local variables
3739 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3740 as needed.
3741 @end itemize
3742
3743 @item signal
3744 @cindex @code{signal} function attribute, AVR
3745 Use this attribute on the AVR to indicate that the specified
3746 function is an interrupt handler. The compiler generates function
3747 entry and exit sequences suitable for use in an interrupt handler when this
3748 attribute is present.
3749
3750 See also the @code{interrupt} function attribute.
3751
3752 The AVR hardware globally disables interrupts when an interrupt is executed.
3753 Interrupt handler functions defined with the @code{signal} attribute
3754 do not re-enable interrupts. It is save to enable interrupts in a
3755 @code{signal} handler. This ``save'' only applies to the code
3756 generated by the compiler and not to the IRQ layout of the
3757 application which is responsibility of the application.
3758
3759 If both @code{signal} and @code{interrupt} are specified for the same
3760 function, @code{signal} is silently ignored.
3761 @end table
3762
3763 @node Blackfin Function Attributes
3764 @subsection Blackfin Function Attributes
3765
3766 These function attributes are supported by the Blackfin back end:
3767
3768 @table @code
3769
3770 @item exception_handler
3771 @cindex @code{exception_handler} function attribute
3772 @cindex exception handler functions, Blackfin
3773 Use this attribute on the Blackfin to indicate that the specified function
3774 is an exception handler. The compiler generates function entry and
3775 exit sequences suitable for use in an exception handler when this
3776 attribute is present.
3777
3778 @item interrupt_handler
3779 @cindex @code{interrupt_handler} function attribute, Blackfin
3780 Use this attribute to
3781 indicate that the specified function is an interrupt handler. The compiler
3782 generates function entry and exit sequences suitable for use in an
3783 interrupt handler when this attribute is present.
3784
3785 @item kspisusp
3786 @cindex @code{kspisusp} function attribute, Blackfin
3787 @cindex User stack pointer in interrupts on the Blackfin
3788 When used together with @code{interrupt_handler}, @code{exception_handler}
3789 or @code{nmi_handler}, code is generated to load the stack pointer
3790 from the USP register in the function prologue.
3791
3792 @item l1_text
3793 @cindex @code{l1_text} function attribute, Blackfin
3794 This attribute specifies a function to be placed into L1 Instruction
3795 SRAM@. The function is put into a specific section named @code{.l1.text}.
3796 With @option{-mfdpic}, function calls with a such function as the callee
3797 or caller uses inlined PLT.
3798
3799 @item l2
3800 @cindex @code{l2} function attribute, Blackfin
3801 This attribute specifies a function to be placed into L2
3802 SRAM. The function is put into a specific section named
3803 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3804 an inlined PLT.
3805
3806 @item longcall
3807 @itemx shortcall
3808 @cindex indirect calls, Blackfin
3809 @cindex @code{longcall} function attribute, Blackfin
3810 @cindex @code{shortcall} function attribute, Blackfin
3811 The @code{longcall} attribute
3812 indicates that the function might be far away from the call site and
3813 require a different (more expensive) calling sequence. The
3814 @code{shortcall} attribute indicates that the function is always close
3815 enough for the shorter calling sequence to be used. These attributes
3816 override the @option{-mlongcall} switch.
3817
3818 @item nesting
3819 @cindex @code{nesting} function attribute, Blackfin
3820 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3821 Use this attribute together with @code{interrupt_handler},
3822 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3823 entry code should enable nested interrupts or exceptions.
3824
3825 @item nmi_handler
3826 @cindex @code{nmi_handler} function attribute, Blackfin
3827 @cindex NMI handler functions on the Blackfin processor
3828 Use this attribute on the Blackfin to indicate that the specified function
3829 is an NMI handler. The compiler generates function entry and
3830 exit sequences suitable for use in an NMI handler when this
3831 attribute is present.
3832
3833 @item saveall
3834 @cindex @code{saveall} function attribute, Blackfin
3835 @cindex save all registers on the Blackfin
3836 Use this attribute to indicate that
3837 all registers except the stack pointer should be saved in the prologue
3838 regardless of whether they are used or not.
3839 @end table
3840
3841 @node CR16 Function Attributes
3842 @subsection CR16 Function Attributes
3843
3844 These function attributes are supported by the CR16 back end:
3845
3846 @table @code
3847 @item interrupt
3848 @cindex @code{interrupt} function attribute, CR16
3849 Use this attribute to indicate
3850 that the specified function is an interrupt handler. The compiler generates
3851 function entry and exit sequences suitable for use in an interrupt handler
3852 when this attribute is present.
3853 @end table
3854
3855 @node Epiphany Function Attributes
3856 @subsection Epiphany Function Attributes
3857
3858 These function attributes are supported by the Epiphany back end:
3859
3860 @table @code
3861 @item disinterrupt
3862 @cindex @code{disinterrupt} function attribute, Epiphany
3863 This attribute causes the compiler to emit
3864 instructions to disable interrupts for the duration of the given
3865 function.
3866
3867 @item forwarder_section
3868 @cindex @code{forwarder_section} function attribute, Epiphany
3869 This attribute modifies the behavior of an interrupt handler.
3870 The interrupt handler may be in external memory which cannot be
3871 reached by a branch instruction, so generate a local memory trampoline
3872 to transfer control. The single parameter identifies the section where
3873 the trampoline is placed.
3874
3875 @item interrupt
3876 @cindex @code{interrupt} function attribute, Epiphany
3877 Use this attribute to indicate
3878 that the specified function is an interrupt handler. The compiler generates
3879 function entry and exit sequences suitable for use in an interrupt handler
3880 when this attribute is present. It may also generate
3881 a special section with code to initialize the interrupt vector table.
3882
3883 On Epiphany targets one or more optional parameters can be added like this:
3884
3885 @smallexample
3886 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3887 @end smallexample
3888
3889 Permissible values for these parameters are: @w{@code{reset}},
3890 @w{@code{software_exception}}, @w{@code{page_miss}},
3891 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3892 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3893 Multiple parameters indicate that multiple entries in the interrupt
3894 vector table should be initialized for this function, i.e.@: for each
3895 parameter @w{@var{name}}, a jump to the function is emitted in
3896 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3897 entirely, in which case no interrupt vector table entry is provided.
3898
3899 Note that interrupts are enabled inside the function
3900 unless the @code{disinterrupt} attribute is also specified.
3901
3902 The following examples are all valid uses of these attributes on
3903 Epiphany targets:
3904 @smallexample
3905 void __attribute__ ((interrupt)) universal_handler ();
3906 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3907 void __attribute__ ((interrupt ("dma0, dma1")))
3908 universal_dma_handler ();
3909 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3910 fast_timer_handler ();
3911 void __attribute__ ((interrupt ("dma0, dma1"),
3912 forwarder_section ("tramp")))
3913 external_dma_handler ();
3914 @end smallexample
3915
3916 @item long_call
3917 @itemx short_call
3918 @cindex @code{long_call} function attribute, Epiphany
3919 @cindex @code{short_call} function attribute, Epiphany
3920 @cindex indirect calls, Epiphany
3921 These attributes specify how a particular function is called.
3922 These attributes override the
3923 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3924 command-line switch and @code{#pragma long_calls} settings.
3925 @end table
3926
3927
3928 @node H8/300 Function Attributes
3929 @subsection H8/300 Function Attributes
3930
3931 These function attributes are available for H8/300 targets:
3932
3933 @table @code
3934 @item function_vector
3935 @cindex @code{function_vector} function attribute, H8/300
3936 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3937 that the specified function should be called through the function vector.
3938 Calling a function through the function vector reduces code size; however,
3939 the function vector has a limited size (maximum 128 entries on the H8/300
3940 and 64 entries on the H8/300H and H8S)
3941 and shares space with the interrupt vector.
3942
3943 @item interrupt_handler
3944 @cindex @code{interrupt_handler} function attribute, H8/300
3945 Use this attribute on the H8/300, H8/300H, and H8S to
3946 indicate that the specified function is an interrupt handler. The compiler
3947 generates function entry and exit sequences suitable for use in an
3948 interrupt handler when this attribute is present.
3949
3950 @item saveall
3951 @cindex @code{saveall} function attribute, H8/300
3952 @cindex save all registers on the H8/300, H8/300H, and H8S
3953 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3954 all registers except the stack pointer should be saved in the prologue
3955 regardless of whether they are used or not.
3956 @end table
3957
3958 @node IA-64 Function Attributes
3959 @subsection IA-64 Function Attributes
3960
3961 These function attributes are supported on IA-64 targets:
3962
3963 @table @code
3964 @item syscall_linkage
3965 @cindex @code{syscall_linkage} function attribute, IA-64
3966 This attribute is used to modify the IA-64 calling convention by marking
3967 all input registers as live at all function exits. This makes it possible
3968 to restart a system call after an interrupt without having to save/restore
3969 the input registers. This also prevents kernel data from leaking into
3970 application code.
3971
3972 @item version_id
3973 @cindex @code{version_id} function attribute, IA-64
3974 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3975 symbol to contain a version string, thus allowing for function level
3976 versioning. HP-UX system header files may use function level versioning
3977 for some system calls.
3978
3979 @smallexample
3980 extern int foo () __attribute__((version_id ("20040821")));
3981 @end smallexample
3982
3983 @noindent
3984 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
3985 @end table
3986
3987 @node M32C Function Attributes
3988 @subsection M32C Function Attributes
3989
3990 These function attributes are supported by the M32C back end:
3991
3992 @table @code
3993 @item bank_switch
3994 @cindex @code{bank_switch} function attribute, M32C
3995 When added to an interrupt handler with the M32C port, causes the
3996 prologue and epilogue to use bank switching to preserve the registers
3997 rather than saving them on the stack.
3998
3999 @item fast_interrupt
4000 @cindex @code{fast_interrupt} function attribute, M32C
4001 Use this attribute on the M32C port to indicate that the specified
4002 function is a fast interrupt handler. This is just like the
4003 @code{interrupt} attribute, except that @code{freit} is used to return
4004 instead of @code{reit}.
4005
4006 @item function_vector
4007 @cindex @code{function_vector} function attribute, M16C/M32C
4008 On M16C/M32C targets, the @code{function_vector} attribute declares a
4009 special page subroutine call function. Use of this attribute reduces
4010 the code size by 2 bytes for each call generated to the
4011 subroutine. The argument to the attribute is the vector number entry
4012 from the special page vector table which contains the 16 low-order
4013 bits of the subroutine's entry address. Each vector table has special
4014 page number (18 to 255) that is used in @code{jsrs} instructions.
4015 Jump addresses of the routines are generated by adding 0x0F0000 (in
4016 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4017 2-byte addresses set in the vector table. Therefore you need to ensure
4018 that all the special page vector routines should get mapped within the
4019 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4020 (for M32C).
4021
4022 In the following example 2 bytes are saved for each call to
4023 function @code{foo}.
4024
4025 @smallexample
4026 void foo (void) __attribute__((function_vector(0x18)));
4027 void foo (void)
4028 @{
4029 @}
4030
4031 void bar (void)
4032 @{
4033 foo();
4034 @}
4035 @end smallexample
4036
4037 If functions are defined in one file and are called in another file,
4038 then be sure to write this declaration in both files.
4039
4040 This attribute is ignored for R8C target.
4041
4042 @item interrupt
4043 @cindex @code{interrupt} function attribute, M32C
4044 Use this attribute to indicate
4045 that the specified function is an interrupt handler. The compiler generates
4046 function entry and exit sequences suitable for use in an interrupt handler
4047 when this attribute is present.
4048 @end table
4049
4050 @node M32R/D Function Attributes
4051 @subsection M32R/D Function Attributes
4052
4053 These function attributes are supported by the M32R/D back end:
4054
4055 @table @code
4056 @item interrupt
4057 @cindex @code{interrupt} function attribute, M32R/D
4058 Use this attribute to indicate
4059 that the specified function is an interrupt handler. The compiler generates
4060 function entry and exit sequences suitable for use in an interrupt handler
4061 when this attribute is present.
4062
4063 @item model (@var{model-name})
4064 @cindex @code{model} function attribute, M32R/D
4065 @cindex function addressability on the M32R/D
4066
4067 On the M32R/D, use this attribute to set the addressability of an
4068 object, and of the code generated for a function. The identifier
4069 @var{model-name} is one of @code{small}, @code{medium}, or
4070 @code{large}, representing each of the code models.
4071
4072 Small model objects live in the lower 16MB of memory (so that their
4073 addresses can be loaded with the @code{ld24} instruction), and are
4074 callable with the @code{bl} instruction.
4075
4076 Medium model objects may live anywhere in the 32-bit address space (the
4077 compiler generates @code{seth/add3} instructions to load their addresses),
4078 and are callable with the @code{bl} instruction.
4079
4080 Large model objects may live anywhere in the 32-bit address space (the
4081 compiler generates @code{seth/add3} instructions to load their addresses),
4082 and may not be reachable with the @code{bl} instruction (the compiler
4083 generates the much slower @code{seth/add3/jl} instruction sequence).
4084 @end table
4085
4086 @node m68k Function Attributes
4087 @subsection m68k Function Attributes
4088
4089 These function attributes are supported by the m68k back end:
4090
4091 @table @code
4092 @item interrupt
4093 @itemx interrupt_handler
4094 @cindex @code{interrupt} function attribute, m68k
4095 @cindex @code{interrupt_handler} function attribute, m68k
4096 Use this attribute to
4097 indicate that the specified function is an interrupt handler. The compiler
4098 generates function entry and exit sequences suitable for use in an
4099 interrupt handler when this attribute is present. Either name may be used.
4100
4101 @item interrupt_thread
4102 @cindex @code{interrupt_thread} function attribute, fido
4103 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4104 that the specified function is an interrupt handler that is designed
4105 to run as a thread. The compiler omits generate prologue/epilogue
4106 sequences and replaces the return instruction with a @code{sleep}
4107 instruction. This attribute is available only on fido.
4108 @end table
4109
4110 @node MCORE Function Attributes
4111 @subsection MCORE Function Attributes
4112
4113 These function attributes are supported by the MCORE back end:
4114
4115 @table @code
4116 @item naked
4117 @cindex @code{naked} function attribute, MCORE
4118 This attribute allows the compiler to construct the
4119 requisite function declaration, while allowing the body of the
4120 function to be assembly code. The specified function will not have
4121 prologue/epilogue sequences generated by the compiler. Only basic
4122 @code{asm} statements can safely be included in naked functions
4123 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4124 basic @code{asm} and C code may appear to work, they cannot be
4125 depended upon to work reliably and are not supported.
4126 @end table
4127
4128 @node MeP Function Attributes
4129 @subsection MeP Function Attributes
4130
4131 These function attributes are supported by the MeP back end:
4132
4133 @table @code
4134 @item disinterrupt
4135 @cindex @code{disinterrupt} function attribute, MeP
4136 On MeP targets, this attribute causes the compiler to emit
4137 instructions to disable interrupts for the duration of the given
4138 function.
4139
4140 @item interrupt
4141 @cindex @code{interrupt} function attribute, MeP
4142 Use this attribute to indicate
4143 that the specified function is an interrupt handler. The compiler generates
4144 function entry and exit sequences suitable for use in an interrupt handler
4145 when this attribute is present.
4146
4147 @item near
4148 @cindex @code{near} function attribute, MeP
4149 This attribute causes the compiler to assume the called
4150 function is close enough to use the normal calling convention,
4151 overriding the @option{-mtf} command-line option.
4152
4153 @item far
4154 @cindex @code{far} function attribute, MeP
4155 On MeP targets this causes the compiler to use a calling convention
4156 that assumes the called function is too far away for the built-in
4157 addressing modes.
4158
4159 @item vliw
4160 @cindex @code{vliw} function attribute, MeP
4161 The @code{vliw} attribute tells the compiler to emit
4162 instructions in VLIW mode instead of core mode. Note that this
4163 attribute is not allowed unless a VLIW coprocessor has been configured
4164 and enabled through command-line options.
4165 @end table
4166
4167 @node MicroBlaze Function Attributes
4168 @subsection MicroBlaze Function Attributes
4169
4170 These function attributes are supported on MicroBlaze targets:
4171
4172 @table @code
4173 @item save_volatiles
4174 @cindex @code{save_volatiles} function attribute, MicroBlaze
4175 Use this attribute to indicate that the function is
4176 an interrupt handler. All volatile registers (in addition to non-volatile
4177 registers) are saved in the function prologue. If the function is a leaf
4178 function, only volatiles used by the function are saved. A normal function
4179 return is generated instead of a return from interrupt.
4180
4181 @item break_handler
4182 @cindex @code{break_handler} function attribute, MicroBlaze
4183 @cindex break handler functions
4184 Use this attribute to indicate that
4185 the specified function is a break handler. The compiler generates function
4186 entry and exit sequences suitable for use in an break handler when this
4187 attribute is present. The return from @code{break_handler} is done through
4188 the @code{rtbd} instead of @code{rtsd}.
4189
4190 @smallexample
4191 void f () __attribute__ ((break_handler));
4192 @end smallexample
4193
4194 @item interrupt_handler
4195 @itemx fast_interrupt
4196 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4197 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4198 These attributes indicate that the specified function is an interrupt
4199 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4200 used in low-latency interrupt mode, and @code{interrupt_handler} for
4201 interrupts that do not use low-latency handlers. In both cases, GCC
4202 emits appropriate prologue code and generates a return from the handler
4203 using @code{rtid} instead of @code{rtsd}.
4204 @end table
4205
4206 @node Microsoft Windows Function Attributes
4207 @subsection Microsoft Windows Function Attributes
4208
4209 The following attributes are available on Microsoft Windows and Symbian OS
4210 targets.
4211
4212 @table @code
4213 @item dllexport
4214 @cindex @code{dllexport} function attribute
4215 @cindex @code{__declspec(dllexport)}
4216 On Microsoft Windows targets and Symbian OS targets the
4217 @code{dllexport} attribute causes the compiler to provide a global
4218 pointer to a pointer in a DLL, so that it can be referenced with the
4219 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4220 name is formed by combining @code{_imp__} and the function or variable
4221 name.
4222
4223 You can use @code{__declspec(dllexport)} as a synonym for
4224 @code{__attribute__ ((dllexport))} for compatibility with other
4225 compilers.
4226
4227 On systems that support the @code{visibility} attribute, this
4228 attribute also implies ``default'' visibility. It is an error to
4229 explicitly specify any other visibility.
4230
4231 GCC's default behavior is to emit all inline functions with the
4232 @code{dllexport} attribute. Since this can cause object file-size bloat,
4233 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4234 ignore the attribute for inlined functions unless the
4235 @option{-fkeep-inline-functions} flag is used instead.
4236
4237 The attribute is ignored for undefined symbols.
4238
4239 When applied to C++ classes, the attribute marks defined non-inlined
4240 member functions and static data members as exports. Static consts
4241 initialized in-class are not marked unless they are also defined
4242 out-of-class.
4243
4244 For Microsoft Windows targets there are alternative methods for
4245 including the symbol in the DLL's export table such as using a
4246 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4247 the @option{--export-all} linker flag.
4248
4249 @item dllimport
4250 @cindex @code{dllimport} function attribute
4251 @cindex @code{__declspec(dllimport)}
4252 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4253 attribute causes the compiler to reference a function or variable via
4254 a global pointer to a pointer that is set up by the DLL exporting the
4255 symbol. The attribute implies @code{extern}. On Microsoft Windows
4256 targets, the pointer name is formed by combining @code{_imp__} and the
4257 function or variable name.
4258
4259 You can use @code{__declspec(dllimport)} as a synonym for
4260 @code{__attribute__ ((dllimport))} for compatibility with other
4261 compilers.
4262
4263 On systems that support the @code{visibility} attribute, this
4264 attribute also implies ``default'' visibility. It is an error to
4265 explicitly specify any other visibility.
4266
4267 Currently, the attribute is ignored for inlined functions. If the
4268 attribute is applied to a symbol @emph{definition}, an error is reported.
4269 If a symbol previously declared @code{dllimport} is later defined, the
4270 attribute is ignored in subsequent references, and a warning is emitted.
4271 The attribute is also overridden by a subsequent declaration as
4272 @code{dllexport}.
4273
4274 When applied to C++ classes, the attribute marks non-inlined
4275 member functions and static data members as imports. However, the
4276 attribute is ignored for virtual methods to allow creation of vtables
4277 using thunks.
4278
4279 On the SH Symbian OS target the @code{dllimport} attribute also has
4280 another affect---it can cause the vtable and run-time type information
4281 for a class to be exported. This happens when the class has a
4282 dllimported constructor or a non-inline, non-pure virtual function
4283 and, for either of those two conditions, the class also has an inline
4284 constructor or destructor and has a key function that is defined in
4285 the current translation unit.
4286
4287 For Microsoft Windows targets the use of the @code{dllimport}
4288 attribute on functions is not necessary, but provides a small
4289 performance benefit by eliminating a thunk in the DLL@. The use of the
4290 @code{dllimport} attribute on imported variables can be avoided by passing the
4291 @option{--enable-auto-import} switch to the GNU linker. As with
4292 functions, using the attribute for a variable eliminates a thunk in
4293 the DLL@.
4294
4295 One drawback to using this attribute is that a pointer to a
4296 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4297 address. However, a pointer to a @emph{function} with the
4298 @code{dllimport} attribute can be used as a constant initializer; in
4299 this case, the address of a stub function in the import lib is
4300 referenced. On Microsoft Windows targets, the attribute can be disabled
4301 for functions by setting the @option{-mnop-fun-dllimport} flag.
4302 @end table
4303
4304 @node MIPS Function Attributes
4305 @subsection MIPS Function Attributes
4306
4307 These function attributes are supported by the MIPS back end:
4308
4309 @table @code
4310 @item interrupt
4311 @cindex @code{interrupt} function attribute, MIPS
4312 Use this attribute to indicate that the specified function is an interrupt
4313 handler. The compiler generates function entry and exit sequences suitable
4314 for use in an interrupt handler when this attribute is present.
4315 An optional argument is supported for the interrupt attribute which allows
4316 the interrupt mode to be described. By default GCC assumes the external
4317 interrupt controller (EIC) mode is in use, this can be explicitly set using
4318 @code{eic}. When interrupts are non-masked then the requested Interrupt
4319 Priority Level (IPL) is copied to the current IPL which has the effect of only
4320 enabling higher priority interrupts. To use vectored interrupt mode use
4321 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4322 the behavior of the non-masked interrupt support and GCC will arrange to mask
4323 all interrupts from sw0 up to and including the specified interrupt vector.
4324
4325 You can use the following attributes to modify the behavior
4326 of an interrupt handler:
4327 @table @code
4328 @item use_shadow_register_set
4329 @cindex @code{use_shadow_register_set} function attribute, MIPS
4330 Assume that the handler uses a shadow register set, instead of
4331 the main general-purpose registers. An optional argument @code{intstack} is
4332 supported to indicate that the shadow register set contains a valid stack
4333 pointer.
4334
4335 @item keep_interrupts_masked
4336 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4337 Keep interrupts masked for the whole function. Without this attribute,
4338 GCC tries to reenable interrupts for as much of the function as it can.
4339
4340 @item use_debug_exception_return
4341 @cindex @code{use_debug_exception_return} function attribute, MIPS
4342 Return using the @code{deret} instruction. Interrupt handlers that don't
4343 have this attribute return using @code{eret} instead.
4344 @end table
4345
4346 You can use any combination of these attributes, as shown below:
4347 @smallexample
4348 void __attribute__ ((interrupt)) v0 ();
4349 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4350 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4351 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4352 void __attribute__ ((interrupt, use_shadow_register_set,
4353 keep_interrupts_masked)) v4 ();
4354 void __attribute__ ((interrupt, use_shadow_register_set,
4355 use_debug_exception_return)) v5 ();
4356 void __attribute__ ((interrupt, keep_interrupts_masked,
4357 use_debug_exception_return)) v6 ();
4358 void __attribute__ ((interrupt, use_shadow_register_set,
4359 keep_interrupts_masked,
4360 use_debug_exception_return)) v7 ();
4361 void __attribute__ ((interrupt("eic"))) v8 ();
4362 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4363 @end smallexample
4364
4365 @item long_call
4366 @itemx near
4367 @itemx far
4368 @cindex indirect calls, MIPS
4369 @cindex @code{long_call} function attribute, MIPS
4370 @cindex @code{near} function attribute, MIPS
4371 @cindex @code{far} function attribute, MIPS
4372 These attributes specify how a particular function is called on MIPS@.
4373 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4374 command-line switch. The @code{long_call} and @code{far} attributes are
4375 synonyms, and cause the compiler to always call
4376 the function by first loading its address into a register, and then using
4377 the contents of that register. The @code{near} attribute has the opposite
4378 effect; it specifies that non-PIC calls should be made using the more
4379 efficient @code{jal} instruction.
4380
4381 @item mips16
4382 @itemx nomips16
4383 @cindex @code{mips16} function attribute, MIPS
4384 @cindex @code{nomips16} function attribute, MIPS
4385
4386 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4387 function attributes to locally select or turn off MIPS16 code generation.
4388 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4389 while MIPS16 code generation is disabled for functions with the
4390 @code{nomips16} attribute. These attributes override the
4391 @option{-mips16} and @option{-mno-mips16} options on the command line
4392 (@pxref{MIPS Options}).
4393
4394 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4395 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4396 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4397 may interact badly with some GCC extensions such as @code{__builtin_apply}
4398 (@pxref{Constructing Calls}).
4399
4400 @item micromips, MIPS
4401 @itemx nomicromips, MIPS
4402 @cindex @code{micromips} function attribute
4403 @cindex @code{nomicromips} function attribute
4404
4405 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4406 function attributes to locally select or turn off microMIPS code generation.
4407 A function with the @code{micromips} attribute is emitted as microMIPS code,
4408 while microMIPS code generation is disabled for functions with the
4409 @code{nomicromips} attribute. These attributes override the
4410 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4411 (@pxref{MIPS Options}).
4412
4413 When compiling files containing mixed microMIPS and non-microMIPS code, the
4414 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4415 command line,
4416 not that within individual functions. Mixed microMIPS and non-microMIPS code
4417 may interact badly with some GCC extensions such as @code{__builtin_apply}
4418 (@pxref{Constructing Calls}).
4419
4420 @item nocompression
4421 @cindex @code{nocompression} function attribute, MIPS
4422 On MIPS targets, you can use the @code{nocompression} function attribute
4423 to locally turn off MIPS16 and microMIPS code generation. This attribute
4424 overrides the @option{-mips16} and @option{-mmicromips} options on the
4425 command line (@pxref{MIPS Options}).
4426 @end table
4427
4428 @node MSP430 Function Attributes
4429 @subsection MSP430 Function Attributes
4430
4431 These function attributes are supported by the MSP430 back end:
4432
4433 @table @code
4434 @item critical
4435 @cindex @code{critical} function attribute, MSP430
4436 Critical functions disable interrupts upon entry and restore the
4437 previous interrupt state upon exit. Critical functions cannot also
4438 have the @code{naked} or @code{reentrant} attributes. They can have
4439 the @code{interrupt} attribute.
4440
4441 @item interrupt
4442 @cindex @code{interrupt} function attribute, MSP430
4443 Use this attribute to indicate
4444 that the specified function is an interrupt handler. The compiler generates
4445 function entry and exit sequences suitable for use in an interrupt handler
4446 when this attribute is present.
4447
4448 You can provide an argument to the interrupt
4449 attribute which specifies a name or number. If the argument is a
4450 number it indicates the slot in the interrupt vector table (0 - 31) to
4451 which this handler should be assigned. If the argument is a name it
4452 is treated as a symbolic name for the vector slot. These names should
4453 match up with appropriate entries in the linker script. By default
4454 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4455 @code{reset} for vector 31 are recognized.
4456
4457 @item naked
4458 @cindex @code{naked} function attribute, MSP430
4459 This attribute allows the compiler to construct the
4460 requisite function declaration, while allowing the body of the
4461 function to be assembly code. The specified function will not have
4462 prologue/epilogue sequences generated by the compiler. Only basic
4463 @code{asm} statements can safely be included in naked functions
4464 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4465 basic @code{asm} and C code may appear to work, they cannot be
4466 depended upon to work reliably and are not supported.
4467
4468 @item reentrant
4469 @cindex @code{reentrant} function attribute, MSP430
4470 Reentrant functions disable interrupts upon entry and enable them
4471 upon exit. Reentrant functions cannot also have the @code{naked}
4472 or @code{critical} attributes. They can have the @code{interrupt}
4473 attribute.
4474
4475 @item wakeup
4476 @cindex @code{wakeup} function attribute, MSP430
4477 This attribute only applies to interrupt functions. It is silently
4478 ignored if applied to a non-interrupt function. A wakeup interrupt
4479 function will rouse the processor from any low-power state that it
4480 might be in when the function exits.
4481
4482 @item lower
4483 @itemx upper
4484 @itemx either
4485 @cindex @code{lower} function attribute, MSP430
4486 @cindex @code{upper} function attribute, MSP430
4487 @cindex @code{either} function attribute, MSP430
4488 On the MSP430 target these attributes can be used to specify whether
4489 the function or variable should be placed into low memory, high
4490 memory, or the placement should be left to the linker to decide. The
4491 attributes are only significant if compiling for the MSP430X
4492 architecture.
4493
4494 The attributes work in conjunction with a linker script that has been
4495 augmented to specify where to place sections with a @code{.lower} and
4496 a @code{.upper} prefix. So, for example, as well as placing the
4497 @code{.data} section, the script also specifies the placement of a
4498 @code{.lower.data} and a @code{.upper.data} section. The intention
4499 is that @code{lower} sections are placed into a small but easier to
4500 access memory region and the upper sections are placed into a larger, but
4501 slower to access, region.
4502
4503 The @code{either} attribute is special. It tells the linker to place
4504 the object into the corresponding @code{lower} section if there is
4505 room for it. If there is insufficient room then the object is placed
4506 into the corresponding @code{upper} section instead. Note that the
4507 placement algorithm is not very sophisticated. It does not attempt to
4508 find an optimal packing of the @code{lower} sections. It just makes
4509 one pass over the objects and does the best that it can. Using the
4510 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4511 options can help the packing, however, since they produce smaller,
4512 easier to pack regions.
4513 @end table
4514
4515 @node NDS32 Function Attributes
4516 @subsection NDS32 Function Attributes
4517
4518 These function attributes are supported by the NDS32 back end:
4519
4520 @table @code
4521 @item exception
4522 @cindex @code{exception} function attribute
4523 @cindex exception handler functions, NDS32
4524 Use this attribute on the NDS32 target to indicate that the specified function
4525 is an exception handler. The compiler will generate corresponding sections
4526 for use in an exception handler.
4527
4528 @item interrupt
4529 @cindex @code{interrupt} function attribute, NDS32
4530 On NDS32 target, this attribute indicates that the specified function
4531 is an interrupt handler. The compiler generates corresponding sections
4532 for use in an interrupt handler. You can use the following attributes
4533 to modify the behavior:
4534 @table @code
4535 @item nested
4536 @cindex @code{nested} function attribute, NDS32
4537 This interrupt service routine is interruptible.
4538 @item not_nested
4539 @cindex @code{not_nested} function attribute, NDS32
4540 This interrupt service routine is not interruptible.
4541 @item nested_ready
4542 @cindex @code{nested_ready} function attribute, NDS32
4543 This interrupt service routine is interruptible after @code{PSW.GIE}
4544 (global interrupt enable) is set. This allows interrupt service routine to
4545 finish some short critical code before enabling interrupts.
4546 @item save_all
4547 @cindex @code{save_all} function attribute, NDS32
4548 The system will help save all registers into stack before entering
4549 interrupt handler.
4550 @item partial_save
4551 @cindex @code{partial_save} function attribute, NDS32
4552 The system will help save caller registers into stack before entering
4553 interrupt handler.
4554 @end table
4555
4556 @item naked
4557 @cindex @code{naked} function attribute, NDS32
4558 This attribute allows the compiler to construct the
4559 requisite function declaration, while allowing the body of the
4560 function to be assembly code. The specified function will not have
4561 prologue/epilogue sequences generated by the compiler. Only basic
4562 @code{asm} statements can safely be included in naked functions
4563 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4564 basic @code{asm} and C code may appear to work, they cannot be
4565 depended upon to work reliably and are not supported.
4566
4567 @item reset
4568 @cindex @code{reset} function attribute, NDS32
4569 @cindex reset handler functions
4570 Use this attribute on the NDS32 target to indicate that the specified function
4571 is a reset handler. The compiler will generate corresponding sections
4572 for use in a reset handler. You can use the following attributes
4573 to provide extra exception handling:
4574 @table @code
4575 @item nmi
4576 @cindex @code{nmi} function attribute, NDS32
4577 Provide a user-defined function to handle NMI exception.
4578 @item warm
4579 @cindex @code{warm} function attribute, NDS32
4580 Provide a user-defined function to handle warm reset exception.
4581 @end table
4582 @end table
4583
4584 @node Nios II Function Attributes
4585 @subsection Nios II Function Attributes
4586
4587 These function attributes are supported by the Nios II back end:
4588
4589 @table @code
4590 @item target (@var{options})
4591 @cindex @code{target} function attribute
4592 As discussed in @ref{Common Function Attributes}, this attribute
4593 allows specification of target-specific compilation options.
4594
4595 When compiling for Nios II, the following options are allowed:
4596
4597 @table @samp
4598 @item custom-@var{insn}=@var{N}
4599 @itemx no-custom-@var{insn}
4600 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4601 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4602 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4603 custom instruction with encoding @var{N} when generating code that uses
4604 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4605 the custom instruction @var{insn}.
4606 These target attributes correspond to the
4607 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4608 command-line options, and support the same set of @var{insn} keywords.
4609 @xref{Nios II Options}, for more information.
4610
4611 @item custom-fpu-cfg=@var{name}
4612 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4613 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4614 command-line option, to select a predefined set of custom instructions
4615 named @var{name}.
4616 @xref{Nios II Options}, for more information.
4617 @end table
4618 @end table
4619
4620 @node Nvidia PTX Function Attributes
4621 @subsection Nvidia PTX Function Attributes
4622
4623 These function attributes are supported by the Nvidia PTX back end:
4624
4625 @table @code
4626 @item kernel
4627 @cindex @code{kernel} attribute, Nvidia PTX
4628 This attribute indicates that the corresponding function should be compiled
4629 as a kernel function, which can be invoked from the host via the CUDA RT
4630 library.
4631 By default functions are only callable only from other PTX functions.
4632
4633 Kernel functions must have @code{void} return type.
4634 @end table
4635
4636 @node PowerPC Function Attributes
4637 @subsection PowerPC Function Attributes
4638
4639 These function attributes are supported by the PowerPC back end:
4640
4641 @table @code
4642 @item longcall
4643 @itemx shortcall
4644 @cindex indirect calls, PowerPC
4645 @cindex @code{longcall} function attribute, PowerPC
4646 @cindex @code{shortcall} function attribute, PowerPC
4647 The @code{longcall} attribute
4648 indicates that the function might be far away from the call site and
4649 require a different (more expensive) calling sequence. The
4650 @code{shortcall} attribute indicates that the function is always close
4651 enough for the shorter calling sequence to be used. These attributes
4652 override both the @option{-mlongcall} switch and
4653 the @code{#pragma longcall} setting.
4654
4655 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4656 calls are necessary.
4657
4658 @item target (@var{options})
4659 @cindex @code{target} function attribute
4660 As discussed in @ref{Common Function Attributes}, this attribute
4661 allows specification of target-specific compilation options.
4662
4663 On the PowerPC, the following options are allowed:
4664
4665 @table @samp
4666 @item altivec
4667 @itemx no-altivec
4668 @cindex @code{target("altivec")} function attribute, PowerPC
4669 Generate code that uses (does not use) AltiVec instructions. In
4670 32-bit code, you cannot enable AltiVec instructions unless
4671 @option{-mabi=altivec} is used on the command line.
4672
4673 @item cmpb
4674 @itemx no-cmpb
4675 @cindex @code{target("cmpb")} function attribute, PowerPC
4676 Generate code that uses (does not use) the compare bytes instruction
4677 implemented on the POWER6 processor and other processors that support
4678 the PowerPC V2.05 architecture.
4679
4680 @item dlmzb
4681 @itemx no-dlmzb
4682 @cindex @code{target("dlmzb")} function attribute, PowerPC
4683 Generate code that uses (does not use) the string-search @samp{dlmzb}
4684 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4685 generated by default when targeting those processors.
4686
4687 @item fprnd
4688 @itemx no-fprnd
4689 @cindex @code{target("fprnd")} function attribute, PowerPC
4690 Generate code that uses (does not use) the FP round to integer
4691 instructions implemented on the POWER5+ processor and other processors
4692 that support the PowerPC V2.03 architecture.
4693
4694 @item hard-dfp
4695 @itemx no-hard-dfp
4696 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4697 Generate code that uses (does not use) the decimal floating-point
4698 instructions implemented on some POWER processors.
4699
4700 @item isel
4701 @itemx no-isel
4702 @cindex @code{target("isel")} function attribute, PowerPC
4703 Generate code that uses (does not use) ISEL instruction.
4704
4705 @item mfcrf
4706 @itemx no-mfcrf
4707 @cindex @code{target("mfcrf")} function attribute, PowerPC
4708 Generate code that uses (does not use) the move from condition
4709 register field instruction implemented on the POWER4 processor and
4710 other processors that support the PowerPC V2.01 architecture.
4711
4712 @item mfpgpr
4713 @itemx no-mfpgpr
4714 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4715 Generate code that uses (does not use) the FP move to/from general
4716 purpose register instructions implemented on the POWER6X processor and
4717 other processors that support the extended PowerPC V2.05 architecture.
4718
4719 @item mulhw
4720 @itemx no-mulhw
4721 @cindex @code{target("mulhw")} function attribute, PowerPC
4722 Generate code that uses (does not use) the half-word multiply and
4723 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4724 These instructions are generated by default when targeting those
4725 processors.
4726
4727 @item multiple
4728 @itemx no-multiple
4729 @cindex @code{target("multiple")} function attribute, PowerPC
4730 Generate code that uses (does not use) the load multiple word
4731 instructions and the store multiple word instructions.
4732
4733 @item update
4734 @itemx no-update
4735 @cindex @code{target("update")} function attribute, PowerPC
4736 Generate code that uses (does not use) the load or store instructions
4737 that update the base register to the address of the calculated memory
4738 location.
4739
4740 @item popcntb
4741 @itemx no-popcntb
4742 @cindex @code{target("popcntb")} function attribute, PowerPC
4743 Generate code that uses (does not use) the popcount and double-precision
4744 FP reciprocal estimate instruction implemented on the POWER5
4745 processor and other processors that support the PowerPC V2.02
4746 architecture.
4747
4748 @item popcntd
4749 @itemx no-popcntd
4750 @cindex @code{target("popcntd")} function attribute, PowerPC
4751 Generate code that uses (does not use) the popcount instruction
4752 implemented on the POWER7 processor and other processors that support
4753 the PowerPC V2.06 architecture.
4754
4755 @item powerpc-gfxopt
4756 @itemx no-powerpc-gfxopt
4757 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4758 Generate code that uses (does not use) the optional PowerPC
4759 architecture instructions in the Graphics group, including
4760 floating-point select.
4761
4762 @item powerpc-gpopt
4763 @itemx no-powerpc-gpopt
4764 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4765 Generate code that uses (does not use) the optional PowerPC
4766 architecture instructions in the General Purpose group, including
4767 floating-point square root.
4768
4769 @item recip-precision
4770 @itemx no-recip-precision
4771 @cindex @code{target("recip-precision")} function attribute, PowerPC
4772 Assume (do not assume) that the reciprocal estimate instructions
4773 provide higher-precision estimates than is mandated by the PowerPC
4774 ABI.
4775
4776 @item string
4777 @itemx no-string
4778 @cindex @code{target("string")} function attribute, PowerPC
4779 Generate code that uses (does not use) the load string instructions
4780 and the store string word instructions to save multiple registers and
4781 do small block moves.
4782
4783 @item vsx
4784 @itemx no-vsx
4785 @cindex @code{target("vsx")} function attribute, PowerPC
4786 Generate code that uses (does not use) vector/scalar (VSX)
4787 instructions, and also enable the use of built-in functions that allow
4788 more direct access to the VSX instruction set. In 32-bit code, you
4789 cannot enable VSX or AltiVec instructions unless
4790 @option{-mabi=altivec} is used on the command line.
4791
4792 @item friz
4793 @itemx no-friz
4794 @cindex @code{target("friz")} function attribute, PowerPC
4795 Generate (do not generate) the @code{friz} instruction when the
4796 @option{-funsafe-math-optimizations} option is used to optimize
4797 rounding a floating-point value to 64-bit integer and back to floating
4798 point. The @code{friz} instruction does not return the same value if
4799 the floating-point number is too large to fit in an integer.
4800
4801 @item avoid-indexed-addresses
4802 @itemx no-avoid-indexed-addresses
4803 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4804 Generate code that tries to avoid (not avoid) the use of indexed load
4805 or store instructions.
4806
4807 @item paired
4808 @itemx no-paired
4809 @cindex @code{target("paired")} function attribute, PowerPC
4810 Generate code that uses (does not use) the generation of PAIRED simd
4811 instructions.
4812
4813 @item longcall
4814 @itemx no-longcall
4815 @cindex @code{target("longcall")} function attribute, PowerPC
4816 Generate code that assumes (does not assume) that all calls are far
4817 away so that a longer more expensive calling sequence is required.
4818
4819 @item cpu=@var{CPU}
4820 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4821 Specify the architecture to generate code for when compiling the
4822 function. If you select the @code{target("cpu=power7")} attribute when
4823 generating 32-bit code, VSX and AltiVec instructions are not generated
4824 unless you use the @option{-mabi=altivec} option on the command line.
4825
4826 @item tune=@var{TUNE}
4827 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4828 Specify the architecture to tune for when compiling the function. If
4829 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4830 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4831 compilation tunes for the @var{CPU} architecture, and not the
4832 default tuning specified on the command line.
4833 @end table
4834
4835 On the PowerPC, the inliner does not inline a
4836 function that has different target options than the caller, unless the
4837 callee has a subset of the target options of the caller.
4838 @end table
4839
4840 @node RL78 Function Attributes
4841 @subsection RL78 Function Attributes
4842
4843 These function attributes are supported by the RL78 back end:
4844
4845 @table @code
4846 @item interrupt
4847 @itemx brk_interrupt
4848 @cindex @code{interrupt} function attribute, RL78
4849 @cindex @code{brk_interrupt} function attribute, RL78
4850 These attributes indicate
4851 that the specified function is an interrupt handler. The compiler generates
4852 function entry and exit sequences suitable for use in an interrupt handler
4853 when this attribute is present.
4854
4855 Use @code{brk_interrupt} instead of @code{interrupt} for
4856 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4857 that must end with @code{RETB} instead of @code{RETI}).
4858
4859 @item naked
4860 @cindex @code{naked} function attribute, RL78
4861 This attribute allows the compiler to construct the
4862 requisite function declaration, while allowing the body of the
4863 function to be assembly code. The specified function will not have
4864 prologue/epilogue sequences generated by the compiler. Only basic
4865 @code{asm} statements can safely be included in naked functions
4866 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4867 basic @code{asm} and C code may appear to work, they cannot be
4868 depended upon to work reliably and are not supported.
4869 @end table
4870
4871 @node RX Function Attributes
4872 @subsection RX Function Attributes
4873
4874 These function attributes are supported by the RX back end:
4875
4876 @table @code
4877 @item fast_interrupt
4878 @cindex @code{fast_interrupt} function attribute, RX
4879 Use this attribute on the RX port to indicate that the specified
4880 function is a fast interrupt handler. This is just like the
4881 @code{interrupt} attribute, except that @code{freit} is used to return
4882 instead of @code{reit}.
4883
4884 @item interrupt
4885 @cindex @code{interrupt} function attribute, RX
4886 Use this attribute to indicate
4887 that the specified function is an interrupt handler. The compiler generates
4888 function entry and exit sequences suitable for use in an interrupt handler
4889 when this attribute is present.
4890
4891 On RX targets, you may specify one or more vector numbers as arguments
4892 to the attribute, as well as naming an alternate table name.
4893 Parameters are handled sequentially, so one handler can be assigned to
4894 multiple entries in multiple tables. One may also pass the magic
4895 string @code{"$default"} which causes the function to be used for any
4896 unfilled slots in the current table.
4897
4898 This example shows a simple assignment of a function to one vector in
4899 the default table (note that preprocessor macros may be used for
4900 chip-specific symbolic vector names):
4901 @smallexample
4902 void __attribute__ ((interrupt (5))) txd1_handler ();
4903 @end smallexample
4904
4905 This example assigns a function to two slots in the default table
4906 (using preprocessor macros defined elsewhere) and makes it the default
4907 for the @code{dct} table:
4908 @smallexample
4909 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4910 txd1_handler ();
4911 @end smallexample
4912
4913 @item naked
4914 @cindex @code{naked} function attribute, RX
4915 This attribute allows the compiler to construct the
4916 requisite function declaration, while allowing the body of the
4917 function to be assembly code. The specified function will not have
4918 prologue/epilogue sequences generated by the compiler. Only basic
4919 @code{asm} statements can safely be included in naked functions
4920 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4921 basic @code{asm} and C code may appear to work, they cannot be
4922 depended upon to work reliably and are not supported.
4923
4924 @item vector
4925 @cindex @code{vector} function attribute, RX
4926 This RX attribute is similar to the @code{interrupt} attribute, including its
4927 parameters, but does not make the function an interrupt-handler type
4928 function (i.e. it retains the normal C function calling ABI). See the
4929 @code{interrupt} attribute for a description of its arguments.
4930 @end table
4931
4932 @node S/390 Function Attributes
4933 @subsection S/390 Function Attributes
4934
4935 These function attributes are supported on the S/390:
4936
4937 @table @code
4938 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4939 @cindex @code{hotpatch} function attribute, S/390
4940
4941 On S/390 System z targets, you can use this function attribute to
4942 make GCC generate a ``hot-patching'' function prologue. If the
4943 @option{-mhotpatch=} command-line option is used at the same time,
4944 the @code{hotpatch} attribute takes precedence. The first of the
4945 two arguments specifies the number of halfwords to be added before
4946 the function label. A second argument can be used to specify the
4947 number of halfwords to be added after the function label. For
4948 both arguments the maximum allowed value is 1000000.
4949
4950 If both arguments are zero, hotpatching is disabled.
4951
4952 @item target (@var{options})
4953 @cindex @code{target} function attribute
4954 As discussed in @ref{Common Function Attributes}, this attribute
4955 allows specification of target-specific compilation options.
4956
4957 On S/390, the following options are supported:
4958
4959 @table @samp
4960 @item arch=
4961 @item tune=
4962 @item stack-guard=
4963 @item stack-size=
4964 @item branch-cost=
4965 @item warn-framesize=
4966 @item backchain
4967 @itemx no-backchain
4968 @item hard-dfp
4969 @itemx no-hard-dfp
4970 @item hard-float
4971 @itemx soft-float
4972 @item htm
4973 @itemx no-htm
4974 @item vx
4975 @itemx no-vx
4976 @item packed-stack
4977 @itemx no-packed-stack
4978 @item small-exec
4979 @itemx no-small-exec
4980 @item mvcle
4981 @itemx no-mvcle
4982 @item warn-dynamicstack
4983 @itemx no-warn-dynamicstack
4984 @end table
4985
4986 The options work exactly like the S/390 specific command line
4987 options (without the prefix @option{-m}) except that they do not
4988 change any feature macros. For example,
4989
4990 @smallexample
4991 @code{target("no-vx")}
4992 @end smallexample
4993
4994 does not undefine the @code{__VEC__} macro.
4995 @end table
4996
4997 @node SH Function Attributes
4998 @subsection SH Function Attributes
4999
5000 These function attributes are supported on the SH family of processors:
5001
5002 @table @code
5003 @item function_vector
5004 @cindex @code{function_vector} function attribute, SH
5005 @cindex calling functions through the function vector on SH2A
5006 On SH2A targets, this attribute declares a function to be called using the
5007 TBR relative addressing mode. The argument to this attribute is the entry
5008 number of the same function in a vector table containing all the TBR
5009 relative addressable functions. For correct operation the TBR must be setup
5010 accordingly to point to the start of the vector table before any functions with
5011 this attribute are invoked. Usually a good place to do the initialization is
5012 the startup routine. The TBR relative vector table can have at max 256 function
5013 entries. The jumps to these functions are generated using a SH2A specific,
5014 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5015 from GNU binutils version 2.7 or later for this attribute to work correctly.
5016
5017 In an application, for a function being called once, this attribute
5018 saves at least 8 bytes of code; and if other successive calls are being
5019 made to the same function, it saves 2 bytes of code per each of these
5020 calls.
5021
5022 @item interrupt_handler
5023 @cindex @code{interrupt_handler} function attribute, SH
5024 Use this attribute to
5025 indicate that the specified function is an interrupt handler. The compiler
5026 generates function entry and exit sequences suitable for use in an
5027 interrupt handler when this attribute is present.
5028
5029 @item nosave_low_regs
5030 @cindex @code{nosave_low_regs} function attribute, SH
5031 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5032 function should not save and restore registers R0..R7. This can be used on SH3*
5033 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5034 interrupt handlers.
5035
5036 @item renesas
5037 @cindex @code{renesas} function attribute, SH
5038 On SH targets this attribute specifies that the function or struct follows the
5039 Renesas ABI.
5040
5041 @item resbank
5042 @cindex @code{resbank} function attribute, SH
5043 On the SH2A target, this attribute enables the high-speed register
5044 saving and restoration using a register bank for @code{interrupt_handler}
5045 routines. Saving to the bank is performed automatically after the CPU
5046 accepts an interrupt that uses a register bank.
5047
5048 The nineteen 32-bit registers comprising general register R0 to R14,
5049 control register GBR, and system registers MACH, MACL, and PR and the
5050 vector table address offset are saved into a register bank. Register
5051 banks are stacked in first-in last-out (FILO) sequence. Restoration
5052 from the bank is executed by issuing a RESBANK instruction.
5053
5054 @item sp_switch
5055 @cindex @code{sp_switch} function attribute, SH
5056 Use this attribute on the SH to indicate an @code{interrupt_handler}
5057 function should switch to an alternate stack. It expects a string
5058 argument that names a global variable holding the address of the
5059 alternate stack.
5060
5061 @smallexample
5062 void *alt_stack;
5063 void f () __attribute__ ((interrupt_handler,
5064 sp_switch ("alt_stack")));
5065 @end smallexample
5066
5067 @item trap_exit
5068 @cindex @code{trap_exit} function attribute, SH
5069 Use this attribute on the SH for an @code{interrupt_handler} to return using
5070 @code{trapa} instead of @code{rte}. This attribute expects an integer
5071 argument specifying the trap number to be used.
5072
5073 @item trapa_handler
5074 @cindex @code{trapa_handler} function attribute, SH
5075 On SH targets this function attribute is similar to @code{interrupt_handler}
5076 but it does not save and restore all registers.
5077 @end table
5078
5079 @node SPU Function Attributes
5080 @subsection SPU Function Attributes
5081
5082 These function attributes are supported by the SPU back end:
5083
5084 @table @code
5085 @item naked
5086 @cindex @code{naked} function attribute, SPU
5087 This attribute allows the compiler to construct the
5088 requisite function declaration, while allowing the body of the
5089 function to be assembly code. The specified function will not have
5090 prologue/epilogue sequences generated by the compiler. Only basic
5091 @code{asm} statements can safely be included in naked functions
5092 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5093 basic @code{asm} and C code may appear to work, they cannot be
5094 depended upon to work reliably and are not supported.
5095 @end table
5096
5097 @node Symbian OS Function Attributes
5098 @subsection Symbian OS Function Attributes
5099
5100 @xref{Microsoft Windows Function Attributes}, for discussion of the
5101 @code{dllexport} and @code{dllimport} attributes.
5102
5103 @node V850 Function Attributes
5104 @subsection V850 Function Attributes
5105
5106 The V850 back end supports these function attributes:
5107
5108 @table @code
5109 @item interrupt
5110 @itemx interrupt_handler
5111 @cindex @code{interrupt} function attribute, V850
5112 @cindex @code{interrupt_handler} function attribute, V850
5113 Use these attributes to indicate
5114 that the specified function is an interrupt handler. The compiler generates
5115 function entry and exit sequences suitable for use in an interrupt handler
5116 when either attribute is present.
5117 @end table
5118
5119 @node Visium Function Attributes
5120 @subsection Visium Function Attributes
5121
5122 These function attributes are supported by the Visium back end:
5123
5124 @table @code
5125 @item interrupt
5126 @cindex @code{interrupt} function attribute, Visium
5127 Use this attribute to indicate
5128 that the specified function is an interrupt handler. The compiler generates
5129 function entry and exit sequences suitable for use in an interrupt handler
5130 when this attribute is present.
5131 @end table
5132
5133 @node x86 Function Attributes
5134 @subsection x86 Function Attributes
5135
5136 These function attributes are supported by the x86 back end:
5137
5138 @table @code
5139 @item cdecl
5140 @cindex @code{cdecl} function attribute, x86-32
5141 @cindex functions that pop the argument stack on x86-32
5142 @opindex mrtd
5143 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5144 assume that the calling function pops off the stack space used to
5145 pass arguments. This is
5146 useful to override the effects of the @option{-mrtd} switch.
5147
5148 @item fastcall
5149 @cindex @code{fastcall} function attribute, x86-32
5150 @cindex functions that pop the argument stack on x86-32
5151 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5152 pass the first argument (if of integral type) in the register ECX and
5153 the second argument (if of integral type) in the register EDX@. Subsequent
5154 and other typed arguments are passed on the stack. The called function
5155 pops the arguments off the stack. If the number of arguments is variable all
5156 arguments are pushed on the stack.
5157
5158 @item thiscall
5159 @cindex @code{thiscall} function attribute, x86-32
5160 @cindex functions that pop the argument stack on x86-32
5161 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5162 pass the first argument (if of integral type) in the register ECX.
5163 Subsequent and other typed arguments are passed on the stack. The called
5164 function pops the arguments off the stack.
5165 If the number of arguments is variable all arguments are pushed on the
5166 stack.
5167 The @code{thiscall} attribute is intended for C++ non-static member functions.
5168 As a GCC extension, this calling convention can be used for C functions
5169 and for static member methods.
5170
5171 @item ms_abi
5172 @itemx sysv_abi
5173 @cindex @code{ms_abi} function attribute, x86
5174 @cindex @code{sysv_abi} function attribute, x86
5175
5176 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5177 to indicate which calling convention should be used for a function. The
5178 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5179 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5180 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5181 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5182
5183 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5184 requires the @option{-maccumulate-outgoing-args} option.
5185
5186 @item callee_pop_aggregate_return (@var{number})
5187 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5188
5189 On x86-32 targets, you can use this attribute to control how
5190 aggregates are returned in memory. If the caller is responsible for
5191 popping the hidden pointer together with the rest of the arguments, specify
5192 @var{number} equal to zero. If callee is responsible for popping the
5193 hidden pointer, specify @var{number} equal to one.
5194
5195 The default x86-32 ABI assumes that the callee pops the
5196 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5197 the compiler assumes that the
5198 caller pops the stack for hidden pointer.
5199
5200 @item ms_hook_prologue
5201 @cindex @code{ms_hook_prologue} function attribute, x86
5202
5203 On 32-bit and 64-bit x86 targets, you can use
5204 this function attribute to make GCC generate the ``hot-patching'' function
5205 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5206 and newer.
5207
5208 @item regparm (@var{number})
5209 @cindex @code{regparm} function attribute, x86
5210 @cindex functions that are passed arguments in registers on x86-32
5211 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5212 pass arguments number one to @var{number} if they are of integral type
5213 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5214 take a variable number of arguments continue to be passed all of their
5215 arguments on the stack.
5216
5217 Beware that on some ELF systems this attribute is unsuitable for
5218 global functions in shared libraries with lazy binding (which is the
5219 default). Lazy binding sends the first call via resolving code in
5220 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5221 per the standard calling conventions. Solaris 8 is affected by this.
5222 Systems with the GNU C Library version 2.1 or higher
5223 and FreeBSD are believed to be
5224 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5225 disabled with the linker or the loader if desired, to avoid the
5226 problem.)
5227
5228 @item sseregparm
5229 @cindex @code{sseregparm} function attribute, x86
5230 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5231 causes the compiler to pass up to 3 floating-point arguments in
5232 SSE registers instead of on the stack. Functions that take a
5233 variable number of arguments continue to pass all of their
5234 floating-point arguments on the stack.
5235
5236 @item force_align_arg_pointer
5237 @cindex @code{force_align_arg_pointer} function attribute, x86
5238 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5239 applied to individual function definitions, generating an alternate
5240 prologue and epilogue that realigns the run-time stack if necessary.
5241 This supports mixing legacy codes that run with a 4-byte aligned stack
5242 with modern codes that keep a 16-byte stack for SSE compatibility.
5243
5244 @item stdcall
5245 @cindex @code{stdcall} function attribute, x86-32
5246 @cindex functions that pop the argument stack on x86-32
5247 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5248 assume that the called function pops off the stack space used to
5249 pass arguments, unless it takes a variable number of arguments.
5250
5251 @item target (@var{options})
5252 @cindex @code{target} function attribute
5253 As discussed in @ref{Common Function Attributes}, this attribute
5254 allows specification of target-specific compilation options.
5255
5256 On the x86, the following options are allowed:
5257 @table @samp
5258 @item abm
5259 @itemx no-abm
5260 @cindex @code{target("abm")} function attribute, x86
5261 Enable/disable the generation of the advanced bit instructions.
5262
5263 @item aes
5264 @itemx no-aes
5265 @cindex @code{target("aes")} function attribute, x86
5266 Enable/disable the generation of the AES instructions.
5267
5268 @item default
5269 @cindex @code{target("default")} function attribute, x86
5270 @xref{Function Multiversioning}, where it is used to specify the
5271 default function version.
5272
5273 @item mmx
5274 @itemx no-mmx
5275 @cindex @code{target("mmx")} function attribute, x86
5276 Enable/disable the generation of the MMX instructions.
5277
5278 @item pclmul
5279 @itemx no-pclmul
5280 @cindex @code{target("pclmul")} function attribute, x86
5281 Enable/disable the generation of the PCLMUL instructions.
5282
5283 @item popcnt
5284 @itemx no-popcnt
5285 @cindex @code{target("popcnt")} function attribute, x86
5286 Enable/disable the generation of the POPCNT instruction.
5287
5288 @item sse
5289 @itemx no-sse
5290 @cindex @code{target("sse")} function attribute, x86
5291 Enable/disable the generation of the SSE instructions.
5292
5293 @item sse2
5294 @itemx no-sse2
5295 @cindex @code{target("sse2")} function attribute, x86
5296 Enable/disable the generation of the SSE2 instructions.
5297
5298 @item sse3
5299 @itemx no-sse3
5300 @cindex @code{target("sse3")} function attribute, x86
5301 Enable/disable the generation of the SSE3 instructions.
5302
5303 @item sse4
5304 @itemx no-sse4
5305 @cindex @code{target("sse4")} function attribute, x86
5306 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5307 and SSE4.2).
5308
5309 @item sse4.1
5310 @itemx no-sse4.1
5311 @cindex @code{target("sse4.1")} function attribute, x86
5312 Enable/disable the generation of the sse4.1 instructions.
5313
5314 @item sse4.2
5315 @itemx no-sse4.2
5316 @cindex @code{target("sse4.2")} function attribute, x86
5317 Enable/disable the generation of the sse4.2 instructions.
5318
5319 @item sse4a
5320 @itemx no-sse4a
5321 @cindex @code{target("sse4a")} function attribute, x86
5322 Enable/disable the generation of the SSE4A instructions.
5323
5324 @item fma4
5325 @itemx no-fma4
5326 @cindex @code{target("fma4")} function attribute, x86
5327 Enable/disable the generation of the FMA4 instructions.
5328
5329 @item xop
5330 @itemx no-xop
5331 @cindex @code{target("xop")} function attribute, x86
5332 Enable/disable the generation of the XOP instructions.
5333
5334 @item lwp
5335 @itemx no-lwp
5336 @cindex @code{target("lwp")} function attribute, x86
5337 Enable/disable the generation of the LWP instructions.
5338
5339 @item ssse3
5340 @itemx no-ssse3
5341 @cindex @code{target("ssse3")} function attribute, x86
5342 Enable/disable the generation of the SSSE3 instructions.
5343
5344 @item cld
5345 @itemx no-cld
5346 @cindex @code{target("cld")} function attribute, x86
5347 Enable/disable the generation of the CLD before string moves.
5348
5349 @item fancy-math-387
5350 @itemx no-fancy-math-387
5351 @cindex @code{target("fancy-math-387")} function attribute, x86
5352 Enable/disable the generation of the @code{sin}, @code{cos}, and
5353 @code{sqrt} instructions on the 387 floating-point unit.
5354
5355 @item fused-madd
5356 @itemx no-fused-madd
5357 @cindex @code{target("fused-madd")} function attribute, x86
5358 Enable/disable the generation of the fused multiply/add instructions.
5359
5360 @item ieee-fp
5361 @itemx no-ieee-fp
5362 @cindex @code{target("ieee-fp")} function attribute, x86
5363 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5364
5365 @item inline-all-stringops
5366 @itemx no-inline-all-stringops
5367 @cindex @code{target("inline-all-stringops")} function attribute, x86
5368 Enable/disable inlining of string operations.
5369
5370 @item inline-stringops-dynamically
5371 @itemx no-inline-stringops-dynamically
5372 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5373 Enable/disable the generation of the inline code to do small string
5374 operations and calling the library routines for large operations.
5375
5376 @item align-stringops
5377 @itemx no-align-stringops
5378 @cindex @code{target("align-stringops")} function attribute, x86
5379 Do/do not align destination of inlined string operations.
5380
5381 @item recip
5382 @itemx no-recip
5383 @cindex @code{target("recip")} function attribute, x86
5384 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5385 instructions followed an additional Newton-Raphson step instead of
5386 doing a floating-point division.
5387
5388 @item arch=@var{ARCH}
5389 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5390 Specify the architecture to generate code for in compiling the function.
5391
5392 @item tune=@var{TUNE}
5393 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5394 Specify the architecture to tune for in compiling the function.
5395
5396 @item fpmath=@var{FPMATH}
5397 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5398 Specify which floating-point unit to use. You must specify the
5399 @code{target("fpmath=sse,387")} option as
5400 @code{target("fpmath=sse+387")} because the comma would separate
5401 different options.
5402 @end table
5403
5404 On the x86, the inliner does not inline a
5405 function that has different target options than the caller, unless the
5406 callee has a subset of the target options of the caller. For example
5407 a function declared with @code{target("sse3")} can inline a function
5408 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5409 @end table
5410
5411 @node Xstormy16 Function Attributes
5412 @subsection Xstormy16 Function Attributes
5413
5414 These function attributes are supported by the Xstormy16 back end:
5415
5416 @table @code
5417 @item interrupt
5418 @cindex @code{interrupt} function attribute, Xstormy16
5419 Use this attribute to indicate
5420 that the specified function is an interrupt handler. The compiler generates
5421 function entry and exit sequences suitable for use in an interrupt handler
5422 when this attribute is present.
5423 @end table
5424
5425 @node Variable Attributes
5426 @section Specifying Attributes of Variables
5427 @cindex attribute of variables
5428 @cindex variable attributes
5429
5430 The keyword @code{__attribute__} allows you to specify special
5431 attributes of variables or structure fields. This keyword is followed
5432 by an attribute specification inside double parentheses. Some
5433 attributes are currently defined generically for variables.
5434 Other attributes are defined for variables on particular target
5435 systems. Other attributes are available for functions
5436 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5437 enumerators (@pxref{Enumerator Attributes}), and for types
5438 (@pxref{Type Attributes}).
5439 Other front ends might define more attributes
5440 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5441
5442 @xref{Attribute Syntax}, for details of the exact syntax for using
5443 attributes.
5444
5445 @menu
5446 * Common Variable Attributes::
5447 * AVR Variable Attributes::
5448 * Blackfin Variable Attributes::
5449 * H8/300 Variable Attributes::
5450 * IA-64 Variable Attributes::
5451 * M32R/D Variable Attributes::
5452 * MeP Variable Attributes::
5453 * Microsoft Windows Variable Attributes::
5454 * MSP430 Variable Attributes::
5455 * PowerPC Variable Attributes::
5456 * RL78 Variable Attributes::
5457 * SPU Variable Attributes::
5458 * V850 Variable Attributes::
5459 * x86 Variable Attributes::
5460 * Xstormy16 Variable Attributes::
5461 @end menu
5462
5463 @node Common Variable Attributes
5464 @subsection Common Variable Attributes
5465
5466 The following attributes are supported on most targets.
5467
5468 @table @code
5469 @cindex @code{aligned} variable attribute
5470 @item aligned (@var{alignment})
5471 This attribute specifies a minimum alignment for the variable or
5472 structure field, measured in bytes. For example, the declaration:
5473
5474 @smallexample
5475 int x __attribute__ ((aligned (16))) = 0;
5476 @end smallexample
5477
5478 @noindent
5479 causes the compiler to allocate the global variable @code{x} on a
5480 16-byte boundary. On a 68040, this could be used in conjunction with
5481 an @code{asm} expression to access the @code{move16} instruction which
5482 requires 16-byte aligned operands.
5483
5484 You can also specify the alignment of structure fields. For example, to
5485 create a double-word aligned @code{int} pair, you could write:
5486
5487 @smallexample
5488 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5489 @end smallexample
5490
5491 @noindent
5492 This is an alternative to creating a union with a @code{double} member,
5493 which forces the union to be double-word aligned.
5494
5495 As in the preceding examples, you can explicitly specify the alignment
5496 (in bytes) that you wish the compiler to use for a given variable or
5497 structure field. Alternatively, you can leave out the alignment factor
5498 and just ask the compiler to align a variable or field to the
5499 default alignment for the target architecture you are compiling for.
5500 The default alignment is sufficient for all scalar types, but may not be
5501 enough for all vector types on a target that supports vector operations.
5502 The default alignment is fixed for a particular target ABI.
5503
5504 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5505 which is the largest alignment ever used for any data type on the
5506 target machine you are compiling for. For example, you could write:
5507
5508 @smallexample
5509 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5510 @end smallexample
5511
5512 The compiler automatically sets the alignment for the declared
5513 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5514 often make copy operations more efficient, because the compiler can
5515 use whatever instructions copy the biggest chunks of memory when
5516 performing copies to or from the variables or fields that you have
5517 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5518 may change depending on command-line options.
5519
5520 When used on a struct, or struct member, the @code{aligned} attribute can
5521 only increase the alignment; in order to decrease it, the @code{packed}
5522 attribute must be specified as well. When used as part of a typedef, the
5523 @code{aligned} attribute can both increase and decrease alignment, and
5524 specifying the @code{packed} attribute generates a warning.
5525
5526 Note that the effectiveness of @code{aligned} attributes may be limited
5527 by inherent limitations in your linker. On many systems, the linker is
5528 only able to arrange for variables to be aligned up to a certain maximum
5529 alignment. (For some linkers, the maximum supported alignment may
5530 be very very small.) If your linker is only able to align variables
5531 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5532 in an @code{__attribute__} still only provides you with 8-byte
5533 alignment. See your linker documentation for further information.
5534
5535 The @code{aligned} attribute can also be used for functions
5536 (@pxref{Common Function Attributes}.)
5537
5538 @item cleanup (@var{cleanup_function})
5539 @cindex @code{cleanup} variable attribute
5540 The @code{cleanup} attribute runs a function when the variable goes
5541 out of scope. This attribute can only be applied to auto function
5542 scope variables; it may not be applied to parameters or variables
5543 with static storage duration. The function must take one parameter,
5544 a pointer to a type compatible with the variable. The return value
5545 of the function (if any) is ignored.
5546
5547 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5548 is run during the stack unwinding that happens during the
5549 processing of the exception. Note that the @code{cleanup} attribute
5550 does not allow the exception to be caught, only to perform an action.
5551 It is undefined what happens if @var{cleanup_function} does not
5552 return normally.
5553
5554 @item common
5555 @itemx nocommon
5556 @cindex @code{common} variable attribute
5557 @cindex @code{nocommon} variable attribute
5558 @opindex fcommon
5559 @opindex fno-common
5560 The @code{common} attribute requests GCC to place a variable in
5561 ``common'' storage. The @code{nocommon} attribute requests the
5562 opposite---to allocate space for it directly.
5563
5564 These attributes override the default chosen by the
5565 @option{-fno-common} and @option{-fcommon} flags respectively.
5566
5567 @item deprecated
5568 @itemx deprecated (@var{msg})
5569 @cindex @code{deprecated} variable attribute
5570 The @code{deprecated} attribute results in a warning if the variable
5571 is used anywhere in the source file. This is useful when identifying
5572 variables that are expected to be removed in a future version of a
5573 program. The warning also includes the location of the declaration
5574 of the deprecated variable, to enable users to easily find further
5575 information about why the variable is deprecated, or what they should
5576 do instead. Note that the warning only occurs for uses:
5577
5578 @smallexample
5579 extern int old_var __attribute__ ((deprecated));
5580 extern int old_var;
5581 int new_fn () @{ return old_var; @}
5582 @end smallexample
5583
5584 @noindent
5585 results in a warning on line 3 but not line 2. The optional @var{msg}
5586 argument, which must be a string, is printed in the warning if
5587 present.
5588
5589 The @code{deprecated} attribute can also be used for functions and
5590 types (@pxref{Common Function Attributes},
5591 @pxref{Common Type Attributes}).
5592
5593 @item mode (@var{mode})
5594 @cindex @code{mode} variable attribute
5595 This attribute specifies the data type for the declaration---whichever
5596 type corresponds to the mode @var{mode}. This in effect lets you
5597 request an integer or floating-point type according to its width.
5598
5599 You may also specify a mode of @code{byte} or @code{__byte__} to
5600 indicate the mode corresponding to a one-byte integer, @code{word} or
5601 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5602 or @code{__pointer__} for the mode used to represent pointers.
5603
5604 @item packed
5605 @cindex @code{packed} variable attribute
5606 The @code{packed} attribute specifies that a variable or structure field
5607 should have the smallest possible alignment---one byte for a variable,
5608 and one bit for a field, unless you specify a larger value with the
5609 @code{aligned} attribute.
5610
5611 Here is a structure in which the field @code{x} is packed, so that it
5612 immediately follows @code{a}:
5613
5614 @smallexample
5615 struct foo
5616 @{
5617 char a;
5618 int x[2] __attribute__ ((packed));
5619 @};
5620 @end smallexample
5621
5622 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5623 @code{packed} attribute on bit-fields of type @code{char}. This has
5624 been fixed in GCC 4.4 but the change can lead to differences in the
5625 structure layout. See the documentation of
5626 @option{-Wpacked-bitfield-compat} for more information.
5627
5628 @item section ("@var{section-name}")
5629 @cindex @code{section} variable attribute
5630 Normally, the compiler places the objects it generates in sections like
5631 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5632 or you need certain particular variables to appear in special sections,
5633 for example to map to special hardware. The @code{section}
5634 attribute specifies that a variable (or function) lives in a particular
5635 section. For example, this small program uses several specific section names:
5636
5637 @smallexample
5638 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5639 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5640 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5641 int init_data __attribute__ ((section ("INITDATA")));
5642
5643 main()
5644 @{
5645 /* @r{Initialize stack pointer} */
5646 init_sp (stack + sizeof (stack));
5647
5648 /* @r{Initialize initialized data} */
5649 memcpy (&init_data, &data, &edata - &data);
5650
5651 /* @r{Turn on the serial ports} */
5652 init_duart (&a);
5653 init_duart (&b);
5654 @}
5655 @end smallexample
5656
5657 @noindent
5658 Use the @code{section} attribute with
5659 @emph{global} variables and not @emph{local} variables,
5660 as shown in the example.
5661
5662 You may use the @code{section} attribute with initialized or
5663 uninitialized global variables but the linker requires
5664 each object be defined once, with the exception that uninitialized
5665 variables tentatively go in the @code{common} (or @code{bss}) section
5666 and can be multiply ``defined''. Using the @code{section} attribute
5667 changes what section the variable goes into and may cause the
5668 linker to issue an error if an uninitialized variable has multiple
5669 definitions. You can force a variable to be initialized with the
5670 @option{-fno-common} flag or the @code{nocommon} attribute.
5671
5672 Some file formats do not support arbitrary sections so the @code{section}
5673 attribute is not available on all platforms.
5674 If you need to map the entire contents of a module to a particular
5675 section, consider using the facilities of the linker instead.
5676
5677 @item tls_model ("@var{tls_model}")
5678 @cindex @code{tls_model} variable attribute
5679 The @code{tls_model} attribute sets thread-local storage model
5680 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5681 overriding @option{-ftls-model=} command-line switch on a per-variable
5682 basis.
5683 The @var{tls_model} argument should be one of @code{global-dynamic},
5684 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5685
5686 Not all targets support this attribute.
5687
5688 @item unused
5689 @cindex @code{unused} variable attribute
5690 This attribute, attached to a variable, means that the variable is meant
5691 to be possibly unused. GCC does not produce a warning for this
5692 variable.
5693
5694 @item used
5695 @cindex @code{used} variable attribute
5696 This attribute, attached to a variable with static storage, means that
5697 the variable must be emitted even if it appears that the variable is not
5698 referenced.
5699
5700 When applied to a static data member of a C++ class template, the
5701 attribute also means that the member is instantiated if the
5702 class itself is instantiated.
5703
5704 @item vector_size (@var{bytes})
5705 @cindex @code{vector_size} variable attribute
5706 This attribute specifies the vector size for the variable, measured in
5707 bytes. For example, the declaration:
5708
5709 @smallexample
5710 int foo __attribute__ ((vector_size (16)));
5711 @end smallexample
5712
5713 @noindent
5714 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5715 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5716 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5717
5718 This attribute is only applicable to integral and float scalars,
5719 although arrays, pointers, and function return values are allowed in
5720 conjunction with this construct.
5721
5722 Aggregates with this attribute are invalid, even if they are of the same
5723 size as a corresponding scalar. For example, the declaration:
5724
5725 @smallexample
5726 struct S @{ int a; @};
5727 struct S __attribute__ ((vector_size (16))) foo;
5728 @end smallexample
5729
5730 @noindent
5731 is invalid even if the size of the structure is the same as the size of
5732 the @code{int}.
5733
5734 @item visibility ("@var{visibility_type}")
5735 @cindex @code{visibility} variable attribute
5736 This attribute affects the linkage of the declaration to which it is attached.
5737 The @code{visibility} attribute is described in
5738 @ref{Common Function Attributes}.
5739
5740 @item weak
5741 @cindex @code{weak} variable attribute
5742 The @code{weak} attribute is described in
5743 @ref{Common Function Attributes}.
5744
5745 @end table
5746
5747 @node AVR Variable Attributes
5748 @subsection AVR Variable Attributes
5749
5750 @table @code
5751 @item progmem
5752 @cindex @code{progmem} variable attribute, AVR
5753 The @code{progmem} attribute is used on the AVR to place read-only
5754 data in the non-volatile program memory (flash). The @code{progmem}
5755 attribute accomplishes this by putting respective variables into a
5756 section whose name starts with @code{.progmem}.
5757
5758 This attribute works similar to the @code{section} attribute
5759 but adds additional checking. Notice that just like the
5760 @code{section} attribute, @code{progmem} affects the location
5761 of the data but not how this data is accessed.
5762
5763 In order to read data located with the @code{progmem} attribute
5764 (inline) assembler must be used.
5765 @smallexample
5766 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5767 #include <avr/pgmspace.h>
5768
5769 /* Locate var in flash memory */
5770 const int var[2] PROGMEM = @{ 1, 2 @};
5771
5772 int read_var (int i)
5773 @{
5774 /* Access var[] by accessor macro from avr/pgmspace.h */
5775 return (int) pgm_read_word (& var[i]);
5776 @}
5777 @end smallexample
5778
5779 AVR is a Harvard architecture processor and data and read-only data
5780 normally resides in the data memory (RAM).
5781
5782 See also the @ref{AVR Named Address Spaces} section for
5783 an alternate way to locate and access data in flash memory.
5784
5785 @item io
5786 @itemx io (@var{addr})
5787 @cindex @code{io} variable attribute, AVR
5788 Variables with the @code{io} attribute are used to address
5789 memory-mapped peripherals in the io address range.
5790 If an address is specified, the variable
5791 is assigned that address, and the value is interpreted as an
5792 address in the data address space.
5793 Example:
5794
5795 @smallexample
5796 volatile int porta __attribute__((io (0x22)));
5797 @end smallexample
5798
5799 The address specified in the address in the data address range.
5800
5801 Otherwise, the variable it is not assigned an address, but the
5802 compiler will still use in/out instructions where applicable,
5803 assuming some other module assigns an address in the io address range.
5804 Example:
5805
5806 @smallexample
5807 extern volatile int porta __attribute__((io));
5808 @end smallexample
5809
5810 @item io_low
5811 @itemx io_low (@var{addr})
5812 @cindex @code{io_low} variable attribute, AVR
5813 This is like the @code{io} attribute, but additionally it informs the
5814 compiler that the object lies in the lower half of the I/O area,
5815 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5816 instructions.
5817
5818 @item address
5819 @itemx address (@var{addr})
5820 @cindex @code{address} variable attribute, AVR
5821 Variables with the @code{address} attribute are used to address
5822 memory-mapped peripherals that may lie outside the io address range.
5823
5824 @smallexample
5825 volatile int porta __attribute__((address (0x600)));
5826 @end smallexample
5827
5828 @end table
5829
5830 @node Blackfin Variable Attributes
5831 @subsection Blackfin Variable Attributes
5832
5833 Three attributes are currently defined for the Blackfin.
5834
5835 @table @code
5836 @item l1_data
5837 @itemx l1_data_A
5838 @itemx l1_data_B
5839 @cindex @code{l1_data} variable attribute, Blackfin
5840 @cindex @code{l1_data_A} variable attribute, Blackfin
5841 @cindex @code{l1_data_B} variable attribute, Blackfin
5842 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5843 Variables with @code{l1_data} attribute are put into the specific section
5844 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5845 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5846 attribute are put into the specific section named @code{.l1.data.B}.
5847
5848 @item l2
5849 @cindex @code{l2} variable attribute, Blackfin
5850 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5851 Variables with @code{l2} attribute are put into the specific section
5852 named @code{.l2.data}.
5853 @end table
5854
5855 @node H8/300 Variable Attributes
5856 @subsection H8/300 Variable Attributes
5857
5858 These variable attributes are available for H8/300 targets:
5859
5860 @table @code
5861 @item eightbit_data
5862 @cindex @code{eightbit_data} variable attribute, H8/300
5863 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5864 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5865 variable should be placed into the eight-bit data section.
5866 The compiler generates more efficient code for certain operations
5867 on data in the eight-bit data area. Note the eight-bit data area is limited to
5868 256 bytes of data.
5869
5870 You must use GAS and GLD from GNU binutils version 2.7 or later for
5871 this attribute to work correctly.
5872
5873 @item tiny_data
5874 @cindex @code{tiny_data} variable attribute, H8/300
5875 @cindex tiny data section on the H8/300H and H8S
5876 Use this attribute on the H8/300H and H8S to indicate that the specified
5877 variable should be placed into the tiny data section.
5878 The compiler generates more efficient code for loads and stores
5879 on data in the tiny data section. Note the tiny data area is limited to
5880 slightly under 32KB of data.
5881
5882 @end table
5883
5884 @node IA-64 Variable Attributes
5885 @subsection IA-64 Variable Attributes
5886
5887 The IA-64 back end supports the following variable attribute:
5888
5889 @table @code
5890 @item model (@var{model-name})
5891 @cindex @code{model} variable attribute, IA-64
5892
5893 On IA-64, use this attribute to set the addressability of an object.
5894 At present, the only supported identifier for @var{model-name} is
5895 @code{small}, indicating addressability via ``small'' (22-bit)
5896 addresses (so that their addresses can be loaded with the @code{addl}
5897 instruction). Caveat: such addressing is by definition not position
5898 independent and hence this attribute must not be used for objects
5899 defined by shared libraries.
5900
5901 @end table
5902
5903 @node M32R/D Variable Attributes
5904 @subsection M32R/D Variable Attributes
5905
5906 One attribute is currently defined for the M32R/D@.
5907
5908 @table @code
5909 @item model (@var{model-name})
5910 @cindex @code{model-name} variable attribute, M32R/D
5911 @cindex variable addressability on the M32R/D
5912 Use this attribute on the M32R/D to set the addressability of an object.
5913 The identifier @var{model-name} is one of @code{small}, @code{medium},
5914 or @code{large}, representing each of the code models.
5915
5916 Small model objects live in the lower 16MB of memory (so that their
5917 addresses can be loaded with the @code{ld24} instruction).
5918
5919 Medium and large model objects may live anywhere in the 32-bit address space
5920 (the compiler generates @code{seth/add3} instructions to load their
5921 addresses).
5922 @end table
5923
5924 @node MeP Variable Attributes
5925 @subsection MeP Variable Attributes
5926
5927 The MeP target has a number of addressing modes and busses. The
5928 @code{near} space spans the standard memory space's first 16 megabytes
5929 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5930 The @code{based} space is a 128-byte region in the memory space that
5931 is addressed relative to the @code{$tp} register. The @code{tiny}
5932 space is a 65536-byte region relative to the @code{$gp} register. In
5933 addition to these memory regions, the MeP target has a separate 16-bit
5934 control bus which is specified with @code{cb} attributes.
5935
5936 @table @code
5937
5938 @item based
5939 @cindex @code{based} variable attribute, MeP
5940 Any variable with the @code{based} attribute is assigned to the
5941 @code{.based} section, and is accessed with relative to the
5942 @code{$tp} register.
5943
5944 @item tiny
5945 @cindex @code{tiny} variable attribute, MeP
5946 Likewise, the @code{tiny} attribute assigned variables to the
5947 @code{.tiny} section, relative to the @code{$gp} register.
5948
5949 @item near
5950 @cindex @code{near} variable attribute, MeP
5951 Variables with the @code{near} attribute are assumed to have addresses
5952 that fit in a 24-bit addressing mode. This is the default for large
5953 variables (@code{-mtiny=4} is the default) but this attribute can
5954 override @code{-mtiny=} for small variables, or override @code{-ml}.
5955
5956 @item far
5957 @cindex @code{far} variable attribute, MeP
5958 Variables with the @code{far} attribute are addressed using a full
5959 32-bit address. Since this covers the entire memory space, this
5960 allows modules to make no assumptions about where variables might be
5961 stored.
5962
5963 @item io
5964 @cindex @code{io} variable attribute, MeP
5965 @itemx io (@var{addr})
5966 Variables with the @code{io} attribute are used to address
5967 memory-mapped peripherals. If an address is specified, the variable
5968 is assigned that address, else it is not assigned an address (it is
5969 assumed some other module assigns an address). Example:
5970
5971 @smallexample
5972 int timer_count __attribute__((io(0x123)));
5973 @end smallexample
5974
5975 @item cb
5976 @itemx cb (@var{addr})
5977 @cindex @code{cb} variable attribute, MeP
5978 Variables with the @code{cb} attribute are used to access the control
5979 bus, using special instructions. @code{addr} indicates the control bus
5980 address. Example:
5981
5982 @smallexample
5983 int cpu_clock __attribute__((cb(0x123)));
5984 @end smallexample
5985
5986 @end table
5987
5988 @node Microsoft Windows Variable Attributes
5989 @subsection Microsoft Windows Variable Attributes
5990
5991 You can use these attributes on Microsoft Windows targets.
5992 @ref{x86 Variable Attributes} for additional Windows compatibility
5993 attributes available on all x86 targets.
5994
5995 @table @code
5996 @item dllimport
5997 @itemx dllexport
5998 @cindex @code{dllimport} variable attribute
5999 @cindex @code{dllexport} variable attribute
6000 The @code{dllimport} and @code{dllexport} attributes are described in
6001 @ref{Microsoft Windows Function Attributes}.
6002
6003 @item selectany
6004 @cindex @code{selectany} variable attribute
6005 The @code{selectany} attribute causes an initialized global variable to
6006 have link-once semantics. When multiple definitions of the variable are
6007 encountered by the linker, the first is selected and the remainder are
6008 discarded. Following usage by the Microsoft compiler, the linker is told
6009 @emph{not} to warn about size or content differences of the multiple
6010 definitions.
6011
6012 Although the primary usage of this attribute is for POD types, the
6013 attribute can also be applied to global C++ objects that are initialized
6014 by a constructor. In this case, the static initialization and destruction
6015 code for the object is emitted in each translation defining the object,
6016 but the calls to the constructor and destructor are protected by a
6017 link-once guard variable.
6018
6019 The @code{selectany} attribute is only available on Microsoft Windows
6020 targets. You can use @code{__declspec (selectany)} as a synonym for
6021 @code{__attribute__ ((selectany))} for compatibility with other
6022 compilers.
6023
6024 @item shared
6025 @cindex @code{shared} variable attribute
6026 On Microsoft Windows, in addition to putting variable definitions in a named
6027 section, the section can also be shared among all running copies of an
6028 executable or DLL@. For example, this small program defines shared data
6029 by putting it in a named section @code{shared} and marking the section
6030 shareable:
6031
6032 @smallexample
6033 int foo __attribute__((section ("shared"), shared)) = 0;
6034
6035 int
6036 main()
6037 @{
6038 /* @r{Read and write foo. All running
6039 copies see the same value.} */
6040 return 0;
6041 @}
6042 @end smallexample
6043
6044 @noindent
6045 You may only use the @code{shared} attribute along with @code{section}
6046 attribute with a fully-initialized global definition because of the way
6047 linkers work. See @code{section} attribute for more information.
6048
6049 The @code{shared} attribute is only available on Microsoft Windows@.
6050
6051 @end table
6052
6053 @node MSP430 Variable Attributes
6054 @subsection MSP430 Variable Attributes
6055
6056 @table @code
6057 @item noinit
6058 @cindex @code{noinit} variable attribute, MSP430
6059 Any data with the @code{noinit} attribute will not be initialised by
6060 the C runtime startup code, or the program loader. Not initialising
6061 data in this way can reduce program startup times.
6062
6063 @item persistent
6064 @cindex @code{persistent} variable attribute, MSP430
6065 Any variable with the @code{persistent} attribute will not be
6066 initialised by the C runtime startup code. Instead its value will be
6067 set once, when the application is loaded, and then never initialised
6068 again, even if the processor is reset or the program restarts.
6069 Persistent data is intended to be placed into FLASH RAM, where its
6070 value will be retained across resets. The linker script being used to
6071 create the application should ensure that persistent data is correctly
6072 placed.
6073
6074 @item lower
6075 @itemx upper
6076 @itemx either
6077 @cindex @code{lower} variable attribute, MSP430
6078 @cindex @code{upper} variable attribute, MSP430
6079 @cindex @code{either} variable attribute, MSP430
6080 These attributes are the same as the MSP430 function attributes of the
6081 same name (@pxref{MSP430 Function Attributes}).
6082 These attributes can be applied to both functions and variables.
6083 @end table
6084
6085 @node PowerPC Variable Attributes
6086 @subsection PowerPC Variable Attributes
6087
6088 Three attributes currently are defined for PowerPC configurations:
6089 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6090
6091 @cindex @code{ms_struct} variable attribute, PowerPC
6092 @cindex @code{gcc_struct} variable attribute, PowerPC
6093 For full documentation of the struct attributes please see the
6094 documentation in @ref{x86 Variable Attributes}.
6095
6096 @cindex @code{altivec} variable attribute, PowerPC
6097 For documentation of @code{altivec} attribute please see the
6098 documentation in @ref{PowerPC Type Attributes}.
6099
6100 @node RL78 Variable Attributes
6101 @subsection RL78 Variable Attributes
6102
6103 @cindex @code{saddr} variable attribute, RL78
6104 The RL78 back end supports the @code{saddr} variable attribute. This
6105 specifies placement of the corresponding variable in the SADDR area,
6106 which can be accessed more efficiently than the default memory region.
6107
6108 @node SPU Variable Attributes
6109 @subsection SPU Variable Attributes
6110
6111 @cindex @code{spu_vector} variable attribute, SPU
6112 The SPU supports the @code{spu_vector} attribute for variables. For
6113 documentation of this attribute please see the documentation in
6114 @ref{SPU Type Attributes}.
6115
6116 @node V850 Variable Attributes
6117 @subsection V850 Variable Attributes
6118
6119 These variable attributes are supported by the V850 back end:
6120
6121 @table @code
6122
6123 @item sda
6124 @cindex @code{sda} variable attribute, V850
6125 Use this attribute to explicitly place a variable in the small data area,
6126 which can hold up to 64 kilobytes.
6127
6128 @item tda
6129 @cindex @code{tda} variable attribute, V850
6130 Use this attribute to explicitly place a variable in the tiny data area,
6131 which can hold up to 256 bytes in total.
6132
6133 @item zda
6134 @cindex @code{zda} variable attribute, V850
6135 Use this attribute to explicitly place a variable in the first 32 kilobytes
6136 of memory.
6137 @end table
6138
6139 @node x86 Variable Attributes
6140 @subsection x86 Variable Attributes
6141
6142 Two attributes are currently defined for x86 configurations:
6143 @code{ms_struct} and @code{gcc_struct}.
6144
6145 @table @code
6146 @item ms_struct
6147 @itemx gcc_struct
6148 @cindex @code{ms_struct} variable attribute, x86
6149 @cindex @code{gcc_struct} variable attribute, x86
6150
6151 If @code{packed} is used on a structure, or if bit-fields are used,
6152 it may be that the Microsoft ABI lays out the structure differently
6153 than the way GCC normally does. Particularly when moving packed
6154 data between functions compiled with GCC and the native Microsoft compiler
6155 (either via function call or as data in a file), it may be necessary to access
6156 either format.
6157
6158 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6159 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6160 command-line options, respectively;
6161 see @ref{x86 Options}, for details of how structure layout is affected.
6162 @xref{x86 Type Attributes}, for information about the corresponding
6163 attributes on types.
6164
6165 @end table
6166
6167 @node Xstormy16 Variable Attributes
6168 @subsection Xstormy16 Variable Attributes
6169
6170 One attribute is currently defined for xstormy16 configurations:
6171 @code{below100}.
6172
6173 @table @code
6174 @item below100
6175 @cindex @code{below100} variable attribute, Xstormy16
6176
6177 If a variable has the @code{below100} attribute (@code{BELOW100} is
6178 allowed also), GCC places the variable in the first 0x100 bytes of
6179 memory and use special opcodes to access it. Such variables are
6180 placed in either the @code{.bss_below100} section or the
6181 @code{.data_below100} section.
6182
6183 @end table
6184
6185 @node Type Attributes
6186 @section Specifying Attributes of Types
6187 @cindex attribute of types
6188 @cindex type attributes
6189
6190 The keyword @code{__attribute__} allows you to specify special
6191 attributes of types. Some type attributes apply only to @code{struct}
6192 and @code{union} types, while others can apply to any type defined
6193 via a @code{typedef} declaration. Other attributes are defined for
6194 functions (@pxref{Function Attributes}), labels (@pxref{Label
6195 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6196 variables (@pxref{Variable Attributes}).
6197
6198 The @code{__attribute__} keyword is followed by an attribute specification
6199 inside double parentheses.
6200
6201 You may specify type attributes in an enum, struct or union type
6202 declaration or definition by placing them immediately after the
6203 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6204 syntax is to place them just past the closing curly brace of the
6205 definition.
6206
6207 You can also include type attributes in a @code{typedef} declaration.
6208 @xref{Attribute Syntax}, for details of the exact syntax for using
6209 attributes.
6210
6211 @menu
6212 * Common Type Attributes::
6213 * ARM Type Attributes::
6214 * MeP Type Attributes::
6215 * PowerPC Type Attributes::
6216 * SPU Type Attributes::
6217 * x86 Type Attributes::
6218 @end menu
6219
6220 @node Common Type Attributes
6221 @subsection Common Type Attributes
6222
6223 The following type attributes are supported on most targets.
6224
6225 @table @code
6226 @cindex @code{aligned} type attribute
6227 @item aligned (@var{alignment})
6228 This attribute specifies a minimum alignment (in bytes) for variables
6229 of the specified type. For example, the declarations:
6230
6231 @smallexample
6232 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6233 typedef int more_aligned_int __attribute__ ((aligned (8)));
6234 @end smallexample
6235
6236 @noindent
6237 force the compiler to ensure (as far as it can) that each variable whose
6238 type is @code{struct S} or @code{more_aligned_int} is allocated and
6239 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6240 variables of type @code{struct S} aligned to 8-byte boundaries allows
6241 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6242 store) instructions when copying one variable of type @code{struct S} to
6243 another, thus improving run-time efficiency.
6244
6245 Note that the alignment of any given @code{struct} or @code{union} type
6246 is required by the ISO C standard to be at least a perfect multiple of
6247 the lowest common multiple of the alignments of all of the members of
6248 the @code{struct} or @code{union} in question. This means that you @emph{can}
6249 effectively adjust the alignment of a @code{struct} or @code{union}
6250 type by attaching an @code{aligned} attribute to any one of the members
6251 of such a type, but the notation illustrated in the example above is a
6252 more obvious, intuitive, and readable way to request the compiler to
6253 adjust the alignment of an entire @code{struct} or @code{union} type.
6254
6255 As in the preceding example, you can explicitly specify the alignment
6256 (in bytes) that you wish the compiler to use for a given @code{struct}
6257 or @code{union} type. Alternatively, you can leave out the alignment factor
6258 and just ask the compiler to align a type to the maximum
6259 useful alignment for the target machine you are compiling for. For
6260 example, you could write:
6261
6262 @smallexample
6263 struct S @{ short f[3]; @} __attribute__ ((aligned));
6264 @end smallexample
6265
6266 Whenever you leave out the alignment factor in an @code{aligned}
6267 attribute specification, the compiler automatically sets the alignment
6268 for the type to the largest alignment that is ever used for any data
6269 type on the target machine you are compiling for. Doing this can often
6270 make copy operations more efficient, because the compiler can use
6271 whatever instructions copy the biggest chunks of memory when performing
6272 copies to or from the variables that have types that you have aligned
6273 this way.
6274
6275 In the example above, if the size of each @code{short} is 2 bytes, then
6276 the size of the entire @code{struct S} type is 6 bytes. The smallest
6277 power of two that is greater than or equal to that is 8, so the
6278 compiler sets the alignment for the entire @code{struct S} type to 8
6279 bytes.
6280
6281 Note that although you can ask the compiler to select a time-efficient
6282 alignment for a given type and then declare only individual stand-alone
6283 objects of that type, the compiler's ability to select a time-efficient
6284 alignment is primarily useful only when you plan to create arrays of
6285 variables having the relevant (efficiently aligned) type. If you
6286 declare or use arrays of variables of an efficiently-aligned type, then
6287 it is likely that your program also does pointer arithmetic (or
6288 subscripting, which amounts to the same thing) on pointers to the
6289 relevant type, and the code that the compiler generates for these
6290 pointer arithmetic operations is often more efficient for
6291 efficiently-aligned types than for other types.
6292
6293 Note that the effectiveness of @code{aligned} attributes may be limited
6294 by inherent limitations in your linker. On many systems, the linker is
6295 only able to arrange for variables to be aligned up to a certain maximum
6296 alignment. (For some linkers, the maximum supported alignment may
6297 be very very small.) If your linker is only able to align variables
6298 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6299 in an @code{__attribute__} still only provides you with 8-byte
6300 alignment. See your linker documentation for further information.
6301
6302 The @code{aligned} attribute can only increase alignment. Alignment
6303 can be decreased by specifying the @code{packed} attribute. See below.
6304
6305 @item bnd_variable_size
6306 @cindex @code{bnd_variable_size} type attribute
6307 @cindex Pointer Bounds Checker attributes
6308 When applied to a structure field, this attribute tells Pointer
6309 Bounds Checker that the size of this field should not be computed
6310 using static type information. It may be used to mark variably-sized
6311 static array fields placed at the end of a structure.
6312
6313 @smallexample
6314 struct S
6315 @{
6316 int size;
6317 char data[1];
6318 @}
6319 S *p = (S *)malloc (sizeof(S) + 100);
6320 p->data[10] = 0; //Bounds violation
6321 @end smallexample
6322
6323 @noindent
6324 By using an attribute for the field we may avoid unwanted bound
6325 violation checks:
6326
6327 @smallexample
6328 struct S
6329 @{
6330 int size;
6331 char data[1] __attribute__((bnd_variable_size));
6332 @}
6333 S *p = (S *)malloc (sizeof(S) + 100);
6334 p->data[10] = 0; //OK
6335 @end smallexample
6336
6337 @item deprecated
6338 @itemx deprecated (@var{msg})
6339 @cindex @code{deprecated} type attribute
6340 The @code{deprecated} attribute results in a warning if the type
6341 is used anywhere in the source file. This is useful when identifying
6342 types that are expected to be removed in a future version of a program.
6343 If possible, the warning also includes the location of the declaration
6344 of the deprecated type, to enable users to easily find further
6345 information about why the type is deprecated, or what they should do
6346 instead. Note that the warnings only occur for uses and then only
6347 if the type is being applied to an identifier that itself is not being
6348 declared as deprecated.
6349
6350 @smallexample
6351 typedef int T1 __attribute__ ((deprecated));
6352 T1 x;
6353 typedef T1 T2;
6354 T2 y;
6355 typedef T1 T3 __attribute__ ((deprecated));
6356 T3 z __attribute__ ((deprecated));
6357 @end smallexample
6358
6359 @noindent
6360 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6361 warning is issued for line 4 because T2 is not explicitly
6362 deprecated. Line 5 has no warning because T3 is explicitly
6363 deprecated. Similarly for line 6. The optional @var{msg}
6364 argument, which must be a string, is printed in the warning if
6365 present.
6366
6367 The @code{deprecated} attribute can also be used for functions and
6368 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6369
6370 @item designated_init
6371 @cindex @code{designated_init} type attribute
6372 This attribute may only be applied to structure types. It indicates
6373 that any initialization of an object of this type must use designated
6374 initializers rather than positional initializers. The intent of this
6375 attribute is to allow the programmer to indicate that a structure's
6376 layout may change, and that therefore relying on positional
6377 initialization will result in future breakage.
6378
6379 GCC emits warnings based on this attribute by default; use
6380 @option{-Wno-designated-init} to suppress them.
6381
6382 @item may_alias
6383 @cindex @code{may_alias} type attribute
6384 Accesses through pointers to types with this attribute are not subject
6385 to type-based alias analysis, but are instead assumed to be able to alias
6386 any other type of objects.
6387 In the context of section 6.5 paragraph 7 of the C99 standard,
6388 an lvalue expression
6389 dereferencing such a pointer is treated like having a character type.
6390 See @option{-fstrict-aliasing} for more information on aliasing issues.
6391 This extension exists to support some vector APIs, in which pointers to
6392 one vector type are permitted to alias pointers to a different vector type.
6393
6394 Note that an object of a type with this attribute does not have any
6395 special semantics.
6396
6397 Example of use:
6398
6399 @smallexample
6400 typedef short __attribute__((__may_alias__)) short_a;
6401
6402 int
6403 main (void)
6404 @{
6405 int a = 0x12345678;
6406 short_a *b = (short_a *) &a;
6407
6408 b[1] = 0;
6409
6410 if (a == 0x12345678)
6411 abort();
6412
6413 exit(0);
6414 @}
6415 @end smallexample
6416
6417 @noindent
6418 If you replaced @code{short_a} with @code{short} in the variable
6419 declaration, the above program would abort when compiled with
6420 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6421 above.
6422
6423 @item packed
6424 @cindex @code{packed} type attribute
6425 This attribute, attached to @code{struct} or @code{union} type
6426 definition, specifies that each member (other than zero-width bit-fields)
6427 of the structure or union is placed to minimize the memory required. When
6428 attached to an @code{enum} definition, it indicates that the smallest
6429 integral type should be used.
6430
6431 @opindex fshort-enums
6432 Specifying the @code{packed} attribute for @code{struct} and @code{union}
6433 types is equivalent to specifying the @code{packed} attribute on each
6434 of the structure or union members. Specifying the @option{-fshort-enums}
6435 flag on the command line is equivalent to specifying the @code{packed}
6436 attribute on all @code{enum} definitions.
6437
6438 In the following example @code{struct my_packed_struct}'s members are
6439 packed closely together, but the internal layout of its @code{s} member
6440 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6441 be packed too.
6442
6443 @smallexample
6444 struct my_unpacked_struct
6445 @{
6446 char c;
6447 int i;
6448 @};
6449
6450 struct __attribute__ ((__packed__)) my_packed_struct
6451 @{
6452 char c;
6453 int i;
6454 struct my_unpacked_struct s;
6455 @};
6456 @end smallexample
6457
6458 You may only specify the @code{packed} attribute attribute on the definition
6459 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
6460 that does not also define the enumerated type, structure or union.
6461
6462 @item scalar_storage_order ("@var{endianness}")
6463 @cindex @code{scalar_storage_order} type attribute
6464 When attached to a @code{union} or a @code{struct}, this attribute sets
6465 the storage order, aka endianness, of the scalar fields of the type, as
6466 well as the array fields whose component is scalar. The supported
6467 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
6468 has no effects on fields which are themselves a @code{union}, a @code{struct}
6469 or an array whose component is a @code{union} or a @code{struct}, and it is
6470 possible for these fields to have a different scalar storage order than the
6471 enclosing type.
6472
6473 This attribute is supported only for targets that use a uniform default
6474 scalar storage order (fortunately, most of them), i.e. targets that store
6475 the scalars either all in big-endian or all in little-endian.
6476
6477 Additional restrictions are enforced for types with the reverse scalar
6478 storage order with regard to the scalar storage order of the target:
6479
6480 @itemize
6481 @item Taking the address of a scalar field of a @code{union} or a
6482 @code{struct} with reverse scalar storage order is not permitted and yields
6483 an error.
6484 @item Taking the address of an array field, whose component is scalar, of
6485 a @code{union} or a @code{struct} with reverse scalar storage order is
6486 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
6487 is specified.
6488 @item Taking the address of a @code{union} or a @code{struct} with reverse
6489 scalar storage order is permitted.
6490 @end itemize
6491
6492 These restrictions exist because the storage order attribute is lost when
6493 the address of a scalar or the address of an array with scalar component is
6494 taken, so storing indirectly through this address generally does not work.
6495 The second case is nevertheless allowed to be able to perform a block copy
6496 from or to the array.
6497
6498 Moreover, the use of type punning or aliasing to toggle the storage order
6499 is not supported; that is to say, a given scalar object cannot be accessed
6500 through distinct types that assign a different storage order to it.
6501
6502 @item transparent_union
6503 @cindex @code{transparent_union} type attribute
6504
6505 This attribute, attached to a @code{union} type definition, indicates
6506 that any function parameter having that union type causes calls to that
6507 function to be treated in a special way.
6508
6509 First, the argument corresponding to a transparent union type can be of
6510 any type in the union; no cast is required. Also, if the union contains
6511 a pointer type, the corresponding argument can be a null pointer
6512 constant or a void pointer expression; and if the union contains a void
6513 pointer type, the corresponding argument can be any pointer expression.
6514 If the union member type is a pointer, qualifiers like @code{const} on
6515 the referenced type must be respected, just as with normal pointer
6516 conversions.
6517
6518 Second, the argument is passed to the function using the calling
6519 conventions of the first member of the transparent union, not the calling
6520 conventions of the union itself. All members of the union must have the
6521 same machine representation; this is necessary for this argument passing
6522 to work properly.
6523
6524 Transparent unions are designed for library functions that have multiple
6525 interfaces for compatibility reasons. For example, suppose the
6526 @code{wait} function must accept either a value of type @code{int *} to
6527 comply with POSIX, or a value of type @code{union wait *} to comply with
6528 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6529 @code{wait} would accept both kinds of arguments, but it would also
6530 accept any other pointer type and this would make argument type checking
6531 less useful. Instead, @code{<sys/wait.h>} might define the interface
6532 as follows:
6533
6534 @smallexample
6535 typedef union __attribute__ ((__transparent_union__))
6536 @{
6537 int *__ip;
6538 union wait *__up;
6539 @} wait_status_ptr_t;
6540
6541 pid_t wait (wait_status_ptr_t);
6542 @end smallexample
6543
6544 @noindent
6545 This interface allows either @code{int *} or @code{union wait *}
6546 arguments to be passed, using the @code{int *} calling convention.
6547 The program can call @code{wait} with arguments of either type:
6548
6549 @smallexample
6550 int w1 () @{ int w; return wait (&w); @}
6551 int w2 () @{ union wait w; return wait (&w); @}
6552 @end smallexample
6553
6554 @noindent
6555 With this interface, @code{wait}'s implementation might look like this:
6556
6557 @smallexample
6558 pid_t wait (wait_status_ptr_t p)
6559 @{
6560 return waitpid (-1, p.__ip, 0);
6561 @}
6562 @end smallexample
6563
6564 @item unused
6565 @cindex @code{unused} type attribute
6566 When attached to a type (including a @code{union} or a @code{struct}),
6567 this attribute means that variables of that type are meant to appear
6568 possibly unused. GCC does not produce a warning for any variables of
6569 that type, even if the variable appears to do nothing. This is often
6570 the case with lock or thread classes, which are usually defined and then
6571 not referenced, but contain constructors and destructors that have
6572 nontrivial bookkeeping functions.
6573
6574 @item visibility
6575 @cindex @code{visibility} type attribute
6576 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6577 applied to class, struct, union and enum types. Unlike other type
6578 attributes, the attribute must appear between the initial keyword and
6579 the name of the type; it cannot appear after the body of the type.
6580
6581 Note that the type visibility is applied to vague linkage entities
6582 associated with the class (vtable, typeinfo node, etc.). In
6583 particular, if a class is thrown as an exception in one shared object
6584 and caught in another, the class must have default visibility.
6585 Otherwise the two shared objects are unable to use the same
6586 typeinfo node and exception handling will break.
6587
6588 @end table
6589
6590 To specify multiple attributes, separate them by commas within the
6591 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6592 packed))}.
6593
6594 @node ARM Type Attributes
6595 @subsection ARM Type Attributes
6596
6597 @cindex @code{notshared} type attribute, ARM
6598 On those ARM targets that support @code{dllimport} (such as Symbian
6599 OS), you can use the @code{notshared} attribute to indicate that the
6600 virtual table and other similar data for a class should not be
6601 exported from a DLL@. For example:
6602
6603 @smallexample
6604 class __declspec(notshared) C @{
6605 public:
6606 __declspec(dllimport) C();
6607 virtual void f();
6608 @}
6609
6610 __declspec(dllexport)
6611 C::C() @{@}
6612 @end smallexample
6613
6614 @noindent
6615 In this code, @code{C::C} is exported from the current DLL, but the
6616 virtual table for @code{C} is not exported. (You can use
6617 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6618 most Symbian OS code uses @code{__declspec}.)
6619
6620 @node MeP Type Attributes
6621 @subsection MeP Type Attributes
6622
6623 @cindex @code{based} type attribute, MeP
6624 @cindex @code{tiny} type attribute, MeP
6625 @cindex @code{near} type attribute, MeP
6626 @cindex @code{far} type attribute, MeP
6627 Many of the MeP variable attributes may be applied to types as well.
6628 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6629 @code{far} attributes may be applied to either. The @code{io} and
6630 @code{cb} attributes may not be applied to types.
6631
6632 @node PowerPC Type Attributes
6633 @subsection PowerPC Type Attributes
6634
6635 Three attributes currently are defined for PowerPC configurations:
6636 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6637
6638 @cindex @code{ms_struct} type attribute, PowerPC
6639 @cindex @code{gcc_struct} type attribute, PowerPC
6640 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6641 attributes please see the documentation in @ref{x86 Type Attributes}.
6642
6643 @cindex @code{altivec} type attribute, PowerPC
6644 The @code{altivec} attribute allows one to declare AltiVec vector data
6645 types supported by the AltiVec Programming Interface Manual. The
6646 attribute requires an argument to specify one of three vector types:
6647 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6648 and @code{bool__} (always followed by unsigned).
6649
6650 @smallexample
6651 __attribute__((altivec(vector__)))
6652 __attribute__((altivec(pixel__))) unsigned short
6653 __attribute__((altivec(bool__))) unsigned
6654 @end smallexample
6655
6656 These attributes mainly are intended to support the @code{__vector},
6657 @code{__pixel}, and @code{__bool} AltiVec keywords.
6658
6659 @node SPU Type Attributes
6660 @subsection SPU Type Attributes
6661
6662 @cindex @code{spu_vector} type attribute, SPU
6663 The SPU supports the @code{spu_vector} attribute for types. This attribute
6664 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6665 Language Extensions Specification. It is intended to support the
6666 @code{__vector} keyword.
6667
6668 @node x86 Type Attributes
6669 @subsection x86 Type Attributes
6670
6671 Two attributes are currently defined for x86 configurations:
6672 @code{ms_struct} and @code{gcc_struct}.
6673
6674 @table @code
6675
6676 @item ms_struct
6677 @itemx gcc_struct
6678 @cindex @code{ms_struct} type attribute, x86
6679 @cindex @code{gcc_struct} type attribute, x86
6680
6681 If @code{packed} is used on a structure, or if bit-fields are used
6682 it may be that the Microsoft ABI packs them differently
6683 than GCC normally packs them. Particularly when moving packed
6684 data between functions compiled with GCC and the native Microsoft compiler
6685 (either via function call or as data in a file), it may be necessary to access
6686 either format.
6687
6688 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6689 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6690 command-line options, respectively;
6691 see @ref{x86 Options}, for details of how structure layout is affected.
6692 @xref{x86 Variable Attributes}, for information about the corresponding
6693 attributes on variables.
6694
6695 @end table
6696
6697 @node Label Attributes
6698 @section Label Attributes
6699 @cindex Label Attributes
6700
6701 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6702 details of the exact syntax for using attributes. Other attributes are
6703 available for functions (@pxref{Function Attributes}), variables
6704 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6705 and for types (@pxref{Type Attributes}).
6706
6707 This example uses the @code{cold} label attribute to indicate the
6708 @code{ErrorHandling} branch is unlikely to be taken and that the
6709 @code{ErrorHandling} label is unused:
6710
6711 @smallexample
6712
6713 asm goto ("some asm" : : : : NoError);
6714
6715 /* This branch (the fall-through from the asm) is less commonly used */
6716 ErrorHandling:
6717 __attribute__((cold, unused)); /* Semi-colon is required here */
6718 printf("error\n");
6719 return 0;
6720
6721 NoError:
6722 printf("no error\n");
6723 return 1;
6724 @end smallexample
6725
6726 @table @code
6727 @item unused
6728 @cindex @code{unused} label attribute
6729 This feature is intended for program-generated code that may contain
6730 unused labels, but which is compiled with @option{-Wall}. It is
6731 not normally appropriate to use in it human-written code, though it
6732 could be useful in cases where the code that jumps to the label is
6733 contained within an @code{#ifdef} conditional.
6734
6735 @item hot
6736 @cindex @code{hot} label attribute
6737 The @code{hot} attribute on a label is used to inform the compiler that
6738 the path following the label is more likely than paths that are not so
6739 annotated. This attribute is used in cases where @code{__builtin_expect}
6740 cannot be used, for instance with computed goto or @code{asm goto}.
6741
6742 @item cold
6743 @cindex @code{cold} label attribute
6744 The @code{cold} attribute on labels is used to inform the compiler that
6745 the path following the label is unlikely to be executed. This attribute
6746 is used in cases where @code{__builtin_expect} cannot be used, for instance
6747 with computed goto or @code{asm goto}.
6748
6749 @end table
6750
6751 @node Enumerator Attributes
6752 @section Enumerator Attributes
6753 @cindex Enumerator Attributes
6754
6755 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6756 details of the exact syntax for using attributes. Other attributes are
6757 available for functions (@pxref{Function Attributes}), variables
6758 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6759 and for types (@pxref{Type Attributes}).
6760
6761 This example uses the @code{deprecated} enumerator attribute to indicate the
6762 @code{oldval} enumerator is deprecated:
6763
6764 @smallexample
6765 enum E @{
6766 oldval __attribute__((deprecated)),
6767 newval
6768 @};
6769
6770 int
6771 fn (void)
6772 @{
6773 return oldval;
6774 @}
6775 @end smallexample
6776
6777 @table @code
6778 @item deprecated
6779 @cindex @code{deprecated} enumerator attribute
6780 The @code{deprecated} attribute results in a warning if the enumerator
6781 is used anywhere in the source file. This is useful when identifying
6782 enumerators that are expected to be removed in a future version of a
6783 program. The warning also includes the location of the declaration
6784 of the deprecated enumerator, to enable users to easily find further
6785 information about why the enumerator is deprecated, or what they should
6786 do instead. Note that the warnings only occurs for uses.
6787
6788 @end table
6789
6790 @node Attribute Syntax
6791 @section Attribute Syntax
6792 @cindex attribute syntax
6793
6794 This section describes the syntax with which @code{__attribute__} may be
6795 used, and the constructs to which attribute specifiers bind, for the C
6796 language. Some details may vary for C++ and Objective-C@. Because of
6797 infelicities in the grammar for attributes, some forms described here
6798 may not be successfully parsed in all cases.
6799
6800 There are some problems with the semantics of attributes in C++. For
6801 example, there are no manglings for attributes, although they may affect
6802 code generation, so problems may arise when attributed types are used in
6803 conjunction with templates or overloading. Similarly, @code{typeid}
6804 does not distinguish between types with different attributes. Support
6805 for attributes in C++ may be restricted in future to attributes on
6806 declarations only, but not on nested declarators.
6807
6808 @xref{Function Attributes}, for details of the semantics of attributes
6809 applying to functions. @xref{Variable Attributes}, for details of the
6810 semantics of attributes applying to variables. @xref{Type Attributes},
6811 for details of the semantics of attributes applying to structure, union
6812 and enumerated types.
6813 @xref{Label Attributes}, for details of the semantics of attributes
6814 applying to labels.
6815 @xref{Enumerator Attributes}, for details of the semantics of attributes
6816 applying to enumerators.
6817
6818 An @dfn{attribute specifier} is of the form
6819 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6820 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6821 each attribute is one of the following:
6822
6823 @itemize @bullet
6824 @item
6825 Empty. Empty attributes are ignored.
6826
6827 @item
6828 An attribute name
6829 (which may be an identifier such as @code{unused}, or a reserved
6830 word such as @code{const}).
6831
6832 @item
6833 An attribute name followed by a parenthesized list of
6834 parameters for the attribute.
6835 These parameters take one of the following forms:
6836
6837 @itemize @bullet
6838 @item
6839 An identifier. For example, @code{mode} attributes use this form.
6840
6841 @item
6842 An identifier followed by a comma and a non-empty comma-separated list
6843 of expressions. For example, @code{format} attributes use this form.
6844
6845 @item
6846 A possibly empty comma-separated list of expressions. For example,
6847 @code{format_arg} attributes use this form with the list being a single
6848 integer constant expression, and @code{alias} attributes use this form
6849 with the list being a single string constant.
6850 @end itemize
6851 @end itemize
6852
6853 An @dfn{attribute specifier list} is a sequence of one or more attribute
6854 specifiers, not separated by any other tokens.
6855
6856 You may optionally specify attribute names with @samp{__}
6857 preceding and following the name.
6858 This allows you to use them in header files without
6859 being concerned about a possible macro of the same name. For example,
6860 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6861
6862
6863 @subsubheading Label Attributes
6864
6865 In GNU C, an attribute specifier list may appear after the colon following a
6866 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6867 attributes on labels if the attribute specifier is immediately
6868 followed by a semicolon (i.e., the label applies to an empty
6869 statement). If the semicolon is missing, C++ label attributes are
6870 ambiguous, as it is permissible for a declaration, which could begin
6871 with an attribute list, to be labelled in C++. Declarations cannot be
6872 labelled in C90 or C99, so the ambiguity does not arise there.
6873
6874 @subsubheading Enumerator Attributes
6875
6876 In GNU C, an attribute specifier list may appear as part of an enumerator.
6877 The attribute goes after the enumeration constant, before @code{=}, if
6878 present. The optional attribute in the enumerator appertains to the
6879 enumeration constant. It is not possible to place the attribute after
6880 the constant expression, if present.
6881
6882 @subsubheading Type Attributes
6883
6884 An attribute specifier list may appear as part of a @code{struct},
6885 @code{union} or @code{enum} specifier. It may go either immediately
6886 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6887 the closing brace. The former syntax is preferred.
6888 Where attribute specifiers follow the closing brace, they are considered
6889 to relate to the structure, union or enumerated type defined, not to any
6890 enclosing declaration the type specifier appears in, and the type
6891 defined is not complete until after the attribute specifiers.
6892 @c Otherwise, there would be the following problems: a shift/reduce
6893 @c conflict between attributes binding the struct/union/enum and
6894 @c binding to the list of specifiers/qualifiers; and "aligned"
6895 @c attributes could use sizeof for the structure, but the size could be
6896 @c changed later by "packed" attributes.
6897
6898
6899 @subsubheading All other attributes
6900
6901 Otherwise, an attribute specifier appears as part of a declaration,
6902 counting declarations of unnamed parameters and type names, and relates
6903 to that declaration (which may be nested in another declaration, for
6904 example in the case of a parameter declaration), or to a particular declarator
6905 within a declaration. Where an
6906 attribute specifier is applied to a parameter declared as a function or
6907 an array, it should apply to the function or array rather than the
6908 pointer to which the parameter is implicitly converted, but this is not
6909 yet correctly implemented.
6910
6911 Any list of specifiers and qualifiers at the start of a declaration may
6912 contain attribute specifiers, whether or not such a list may in that
6913 context contain storage class specifiers. (Some attributes, however,
6914 are essentially in the nature of storage class specifiers, and only make
6915 sense where storage class specifiers may be used; for example,
6916 @code{section}.) There is one necessary limitation to this syntax: the
6917 first old-style parameter declaration in a function definition cannot
6918 begin with an attribute specifier, because such an attribute applies to
6919 the function instead by syntax described below (which, however, is not
6920 yet implemented in this case). In some other cases, attribute
6921 specifiers are permitted by this grammar but not yet supported by the
6922 compiler. All attribute specifiers in this place relate to the
6923 declaration as a whole. In the obsolescent usage where a type of
6924 @code{int} is implied by the absence of type specifiers, such a list of
6925 specifiers and qualifiers may be an attribute specifier list with no
6926 other specifiers or qualifiers.
6927
6928 At present, the first parameter in a function prototype must have some
6929 type specifier that is not an attribute specifier; this resolves an
6930 ambiguity in the interpretation of @code{void f(int
6931 (__attribute__((foo)) x))}, but is subject to change. At present, if
6932 the parentheses of a function declarator contain only attributes then
6933 those attributes are ignored, rather than yielding an error or warning
6934 or implying a single parameter of type int, but this is subject to
6935 change.
6936
6937 An attribute specifier list may appear immediately before a declarator
6938 (other than the first) in a comma-separated list of declarators in a
6939 declaration of more than one identifier using a single list of
6940 specifiers and qualifiers. Such attribute specifiers apply
6941 only to the identifier before whose declarator they appear. For
6942 example, in
6943
6944 @smallexample
6945 __attribute__((noreturn)) void d0 (void),
6946 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6947 d2 (void);
6948 @end smallexample
6949
6950 @noindent
6951 the @code{noreturn} attribute applies to all the functions
6952 declared; the @code{format} attribute only applies to @code{d1}.
6953
6954 An attribute specifier list may appear immediately before the comma,
6955 @code{=} or semicolon terminating the declaration of an identifier other
6956 than a function definition. Such attribute specifiers apply
6957 to the declared object or function. Where an
6958 assembler name for an object or function is specified (@pxref{Asm
6959 Labels}), the attribute must follow the @code{asm}
6960 specification.
6961
6962 An attribute specifier list may, in future, be permitted to appear after
6963 the declarator in a function definition (before any old-style parameter
6964 declarations or the function body).
6965
6966 Attribute specifiers may be mixed with type qualifiers appearing inside
6967 the @code{[]} of a parameter array declarator, in the C99 construct by
6968 which such qualifiers are applied to the pointer to which the array is
6969 implicitly converted. Such attribute specifiers apply to the pointer,
6970 not to the array, but at present this is not implemented and they are
6971 ignored.
6972
6973 An attribute specifier list may appear at the start of a nested
6974 declarator. At present, there are some limitations in this usage: the
6975 attributes correctly apply to the declarator, but for most individual
6976 attributes the semantics this implies are not implemented.
6977 When attribute specifiers follow the @code{*} of a pointer
6978 declarator, they may be mixed with any type qualifiers present.
6979 The following describes the formal semantics of this syntax. It makes the
6980 most sense if you are familiar with the formal specification of
6981 declarators in the ISO C standard.
6982
6983 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6984 D1}, where @code{T} contains declaration specifiers that specify a type
6985 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6986 contains an identifier @var{ident}. The type specified for @var{ident}
6987 for derived declarators whose type does not include an attribute
6988 specifier is as in the ISO C standard.
6989
6990 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
6991 and the declaration @code{T D} specifies the type
6992 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6993 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6994 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
6995
6996 If @code{D1} has the form @code{*
6997 @var{type-qualifier-and-attribute-specifier-list} D}, and the
6998 declaration @code{T D} specifies the type
6999 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7000 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7001 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7002 @var{ident}.
7003
7004 For example,
7005
7006 @smallexample
7007 void (__attribute__((noreturn)) ****f) (void);
7008 @end smallexample
7009
7010 @noindent
7011 specifies the type ``pointer to pointer to pointer to pointer to
7012 non-returning function returning @code{void}''. As another example,
7013
7014 @smallexample
7015 char *__attribute__((aligned(8))) *f;
7016 @end smallexample
7017
7018 @noindent
7019 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7020 Note again that this does not work with most attributes; for example,
7021 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7022 is not yet supported.
7023
7024 For compatibility with existing code written for compiler versions that
7025 did not implement attributes on nested declarators, some laxity is
7026 allowed in the placing of attributes. If an attribute that only applies
7027 to types is applied to a declaration, it is treated as applying to
7028 the type of that declaration. If an attribute that only applies to
7029 declarations is applied to the type of a declaration, it is treated
7030 as applying to that declaration; and, for compatibility with code
7031 placing the attributes immediately before the identifier declared, such
7032 an attribute applied to a function return type is treated as
7033 applying to the function type, and such an attribute applied to an array
7034 element type is treated as applying to the array type. If an
7035 attribute that only applies to function types is applied to a
7036 pointer-to-function type, it is treated as applying to the pointer
7037 target type; if such an attribute is applied to a function return type
7038 that is not a pointer-to-function type, it is treated as applying
7039 to the function type.
7040
7041 @node Function Prototypes
7042 @section Prototypes and Old-Style Function Definitions
7043 @cindex function prototype declarations
7044 @cindex old-style function definitions
7045 @cindex promotion of formal parameters
7046
7047 GNU C extends ISO C to allow a function prototype to override a later
7048 old-style non-prototype definition. Consider the following example:
7049
7050 @smallexample
7051 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7052 #ifdef __STDC__
7053 #define P(x) x
7054 #else
7055 #define P(x) ()
7056 #endif
7057
7058 /* @r{Prototype function declaration.} */
7059 int isroot P((uid_t));
7060
7061 /* @r{Old-style function definition.} */
7062 int
7063 isroot (x) /* @r{??? lossage here ???} */
7064 uid_t x;
7065 @{
7066 return x == 0;
7067 @}
7068 @end smallexample
7069
7070 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7071 not allow this example, because subword arguments in old-style
7072 non-prototype definitions are promoted. Therefore in this example the
7073 function definition's argument is really an @code{int}, which does not
7074 match the prototype argument type of @code{short}.
7075
7076 This restriction of ISO C makes it hard to write code that is portable
7077 to traditional C compilers, because the programmer does not know
7078 whether the @code{uid_t} type is @code{short}, @code{int}, or
7079 @code{long}. Therefore, in cases like these GNU C allows a prototype
7080 to override a later old-style definition. More precisely, in GNU C, a
7081 function prototype argument type overrides the argument type specified
7082 by a later old-style definition if the former type is the same as the
7083 latter type before promotion. Thus in GNU C the above example is
7084 equivalent to the following:
7085
7086 @smallexample
7087 int isroot (uid_t);
7088
7089 int
7090 isroot (uid_t x)
7091 @{
7092 return x == 0;
7093 @}
7094 @end smallexample
7095
7096 @noindent
7097 GNU C++ does not support old-style function definitions, so this
7098 extension is irrelevant.
7099
7100 @node C++ Comments
7101 @section C++ Style Comments
7102 @cindex @code{//}
7103 @cindex C++ comments
7104 @cindex comments, C++ style
7105
7106 In GNU C, you may use C++ style comments, which start with @samp{//} and
7107 continue until the end of the line. Many other C implementations allow
7108 such comments, and they are included in the 1999 C standard. However,
7109 C++ style comments are not recognized if you specify an @option{-std}
7110 option specifying a version of ISO C before C99, or @option{-ansi}
7111 (equivalent to @option{-std=c90}).
7112
7113 @node Dollar Signs
7114 @section Dollar Signs in Identifier Names
7115 @cindex $
7116 @cindex dollar signs in identifier names
7117 @cindex identifier names, dollar signs in
7118
7119 In GNU C, you may normally use dollar signs in identifier names.
7120 This is because many traditional C implementations allow such identifiers.
7121 However, dollar signs in identifiers are not supported on a few target
7122 machines, typically because the target assembler does not allow them.
7123
7124 @node Character Escapes
7125 @section The Character @key{ESC} in Constants
7126
7127 You can use the sequence @samp{\e} in a string or character constant to
7128 stand for the ASCII character @key{ESC}.
7129
7130 @node Alignment
7131 @section Inquiring on Alignment of Types or Variables
7132 @cindex alignment
7133 @cindex type alignment
7134 @cindex variable alignment
7135
7136 The keyword @code{__alignof__} allows you to inquire about how an object
7137 is aligned, or the minimum alignment usually required by a type. Its
7138 syntax is just like @code{sizeof}.
7139
7140 For example, if the target machine requires a @code{double} value to be
7141 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7142 This is true on many RISC machines. On more traditional machine
7143 designs, @code{__alignof__ (double)} is 4 or even 2.
7144
7145 Some machines never actually require alignment; they allow reference to any
7146 data type even at an odd address. For these machines, @code{__alignof__}
7147 reports the smallest alignment that GCC gives the data type, usually as
7148 mandated by the target ABI.
7149
7150 If the operand of @code{__alignof__} is an lvalue rather than a type,
7151 its value is the required alignment for its type, taking into account
7152 any minimum alignment specified with GCC's @code{__attribute__}
7153 extension (@pxref{Variable Attributes}). For example, after this
7154 declaration:
7155
7156 @smallexample
7157 struct foo @{ int x; char y; @} foo1;
7158 @end smallexample
7159
7160 @noindent
7161 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7162 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7163
7164 It is an error to ask for the alignment of an incomplete type.
7165
7166
7167 @node Inline
7168 @section An Inline Function is As Fast As a Macro
7169 @cindex inline functions
7170 @cindex integrating function code
7171 @cindex open coding
7172 @cindex macros, inline alternative
7173
7174 By declaring a function inline, you can direct GCC to make
7175 calls to that function faster. One way GCC can achieve this is to
7176 integrate that function's code into the code for its callers. This
7177 makes execution faster by eliminating the function-call overhead; in
7178 addition, if any of the actual argument values are constant, their
7179 known values may permit simplifications at compile time so that not
7180 all of the inline function's code needs to be included. The effect on
7181 code size is less predictable; object code may be larger or smaller
7182 with function inlining, depending on the particular case. You can
7183 also direct GCC to try to integrate all ``simple enough'' functions
7184 into their callers with the option @option{-finline-functions}.
7185
7186 GCC implements three different semantics of declaring a function
7187 inline. One is available with @option{-std=gnu89} or
7188 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7189 on all inline declarations, another when
7190 @option{-std=c99}, @option{-std=c11},
7191 @option{-std=gnu99} or @option{-std=gnu11}
7192 (without @option{-fgnu89-inline}), and the third
7193 is used when compiling C++.
7194
7195 To declare a function inline, use the @code{inline} keyword in its
7196 declaration, like this:
7197
7198 @smallexample
7199 static inline int
7200 inc (int *a)
7201 @{
7202 return (*a)++;
7203 @}
7204 @end smallexample
7205
7206 If you are writing a header file to be included in ISO C90 programs, write
7207 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7208
7209 The three types of inlining behave similarly in two important cases:
7210 when the @code{inline} keyword is used on a @code{static} function,
7211 like the example above, and when a function is first declared without
7212 using the @code{inline} keyword and then is defined with
7213 @code{inline}, like this:
7214
7215 @smallexample
7216 extern int inc (int *a);
7217 inline int
7218 inc (int *a)
7219 @{
7220 return (*a)++;
7221 @}
7222 @end smallexample
7223
7224 In both of these common cases, the program behaves the same as if you
7225 had not used the @code{inline} keyword, except for its speed.
7226
7227 @cindex inline functions, omission of
7228 @opindex fkeep-inline-functions
7229 When a function is both inline and @code{static}, if all calls to the
7230 function are integrated into the caller, and the function's address is
7231 never used, then the function's own assembler code is never referenced.
7232 In this case, GCC does not actually output assembler code for the
7233 function, unless you specify the option @option{-fkeep-inline-functions}.
7234 If there is a nonintegrated call, then the function is compiled to
7235 assembler code as usual. The function must also be compiled as usual if
7236 the program refers to its address, because that can't be inlined.
7237
7238 @opindex Winline
7239 Note that certain usages in a function definition can make it unsuitable
7240 for inline substitution. Among these usages are: variadic functions,
7241 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7242 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7243 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7244 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7245 function marked @code{inline} could not be substituted, and gives the
7246 reason for the failure.
7247
7248 @cindex automatic @code{inline} for C++ member fns
7249 @cindex @code{inline} automatic for C++ member fns
7250 @cindex member fns, automatically @code{inline}
7251 @cindex C++ member fns, automatically @code{inline}
7252 @opindex fno-default-inline
7253 As required by ISO C++, GCC considers member functions defined within
7254 the body of a class to be marked inline even if they are
7255 not explicitly declared with the @code{inline} keyword. You can
7256 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7257 Options,,Options Controlling C++ Dialect}.
7258
7259 GCC does not inline any functions when not optimizing unless you specify
7260 the @samp{always_inline} attribute for the function, like this:
7261
7262 @smallexample
7263 /* @r{Prototype.} */
7264 inline void foo (const char) __attribute__((always_inline));
7265 @end smallexample
7266
7267 The remainder of this section is specific to GNU C90 inlining.
7268
7269 @cindex non-static inline function
7270 When an inline function is not @code{static}, then the compiler must assume
7271 that there may be calls from other source files; since a global symbol can
7272 be defined only once in any program, the function must not be defined in
7273 the other source files, so the calls therein cannot be integrated.
7274 Therefore, a non-@code{static} inline function is always compiled on its
7275 own in the usual fashion.
7276
7277 If you specify both @code{inline} and @code{extern} in the function
7278 definition, then the definition is used only for inlining. In no case
7279 is the function compiled on its own, not even if you refer to its
7280 address explicitly. Such an address becomes an external reference, as
7281 if you had only declared the function, and had not defined it.
7282
7283 This combination of @code{inline} and @code{extern} has almost the
7284 effect of a macro. The way to use it is to put a function definition in
7285 a header file with these keywords, and put another copy of the
7286 definition (lacking @code{inline} and @code{extern}) in a library file.
7287 The definition in the header file causes most calls to the function
7288 to be inlined. If any uses of the function remain, they refer to
7289 the single copy in the library.
7290
7291 @node Volatiles
7292 @section When is a Volatile Object Accessed?
7293 @cindex accessing volatiles
7294 @cindex volatile read
7295 @cindex volatile write
7296 @cindex volatile access
7297
7298 C has the concept of volatile objects. These are normally accessed by
7299 pointers and used for accessing hardware or inter-thread
7300 communication. The standard encourages compilers to refrain from
7301 optimizations concerning accesses to volatile objects, but leaves it
7302 implementation defined as to what constitutes a volatile access. The
7303 minimum requirement is that at a sequence point all previous accesses
7304 to volatile objects have stabilized and no subsequent accesses have
7305 occurred. Thus an implementation is free to reorder and combine
7306 volatile accesses that occur between sequence points, but cannot do
7307 so for accesses across a sequence point. The use of volatile does
7308 not allow you to violate the restriction on updating objects multiple
7309 times between two sequence points.
7310
7311 Accesses to non-volatile objects are not ordered with respect to
7312 volatile accesses. You cannot use a volatile object as a memory
7313 barrier to order a sequence of writes to non-volatile memory. For
7314 instance:
7315
7316 @smallexample
7317 int *ptr = @var{something};
7318 volatile int vobj;
7319 *ptr = @var{something};
7320 vobj = 1;
7321 @end smallexample
7322
7323 @noindent
7324 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7325 that the write to @var{*ptr} occurs by the time the update
7326 of @var{vobj} happens. If you need this guarantee, you must use
7327 a stronger memory barrier such as:
7328
7329 @smallexample
7330 int *ptr = @var{something};
7331 volatile int vobj;
7332 *ptr = @var{something};
7333 asm volatile ("" : : : "memory");
7334 vobj = 1;
7335 @end smallexample
7336
7337 A scalar volatile object is read when it is accessed in a void context:
7338
7339 @smallexample
7340 volatile int *src = @var{somevalue};
7341 *src;
7342 @end smallexample
7343
7344 Such expressions are rvalues, and GCC implements this as a
7345 read of the volatile object being pointed to.
7346
7347 Assignments are also expressions and have an rvalue. However when
7348 assigning to a scalar volatile, the volatile object is not reread,
7349 regardless of whether the assignment expression's rvalue is used or
7350 not. If the assignment's rvalue is used, the value is that assigned
7351 to the volatile object. For instance, there is no read of @var{vobj}
7352 in all the following cases:
7353
7354 @smallexample
7355 int obj;
7356 volatile int vobj;
7357 vobj = @var{something};
7358 obj = vobj = @var{something};
7359 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7360 obj = (@var{something}, vobj = @var{anotherthing});
7361 @end smallexample
7362
7363 If you need to read the volatile object after an assignment has
7364 occurred, you must use a separate expression with an intervening
7365 sequence point.
7366
7367 As bit-fields are not individually addressable, volatile bit-fields may
7368 be implicitly read when written to, or when adjacent bit-fields are
7369 accessed. Bit-field operations may be optimized such that adjacent
7370 bit-fields are only partially accessed, if they straddle a storage unit
7371 boundary. For these reasons it is unwise to use volatile bit-fields to
7372 access hardware.
7373
7374 @node Using Assembly Language with C
7375 @section How to Use Inline Assembly Language in C Code
7376 @cindex @code{asm} keyword
7377 @cindex assembly language in C
7378 @cindex inline assembly language
7379 @cindex mixing assembly language and C
7380
7381 The @code{asm} keyword allows you to embed assembler instructions
7382 within C code. GCC provides two forms of inline @code{asm}
7383 statements. A @dfn{basic @code{asm}} statement is one with no
7384 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7385 statement (@pxref{Extended Asm}) includes one or more operands.
7386 The extended form is preferred for mixing C and assembly language
7387 within a function, but to include assembly language at
7388 top level you must use basic @code{asm}.
7389
7390 You can also use the @code{asm} keyword to override the assembler name
7391 for a C symbol, or to place a C variable in a specific register.
7392
7393 @menu
7394 * Basic Asm:: Inline assembler without operands.
7395 * Extended Asm:: Inline assembler with operands.
7396 * Constraints:: Constraints for @code{asm} operands
7397 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7398 * Explicit Register Variables:: Defining variables residing in specified
7399 registers.
7400 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7401 @end menu
7402
7403 @node Basic Asm
7404 @subsection Basic Asm --- Assembler Instructions Without Operands
7405 @cindex basic @code{asm}
7406 @cindex assembly language in C, basic
7407
7408 A basic @code{asm} statement has the following syntax:
7409
7410 @example
7411 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7412 @end example
7413
7414 The @code{asm} keyword is a GNU extension.
7415 When writing code that can be compiled with @option{-ansi} and the
7416 various @option{-std} options, use @code{__asm__} instead of
7417 @code{asm} (@pxref{Alternate Keywords}).
7418
7419 @subsubheading Qualifiers
7420 @table @code
7421 @item volatile
7422 The optional @code{volatile} qualifier has no effect.
7423 All basic @code{asm} blocks are implicitly volatile.
7424 @end table
7425
7426 @subsubheading Parameters
7427 @table @var
7428
7429 @item AssemblerInstructions
7430 This is a literal string that specifies the assembler code. The string can
7431 contain any instructions recognized by the assembler, including directives.
7432 GCC does not parse the assembler instructions themselves and
7433 does not know what they mean or even whether they are valid assembler input.
7434
7435 You may place multiple assembler instructions together in a single @code{asm}
7436 string, separated by the characters normally used in assembly code for the
7437 system. A combination that works in most places is a newline to break the
7438 line, plus a tab character (written as @samp{\n\t}).
7439 Some assemblers allow semicolons as a line separator. However,
7440 note that some assembler dialects use semicolons to start a comment.
7441 @end table
7442
7443 @subsubheading Remarks
7444 Using extended @code{asm} typically produces smaller, safer, and more
7445 efficient code, and in most cases it is a better solution than basic
7446 @code{asm}. However, there are two situations where only basic @code{asm}
7447 can be used:
7448
7449 @itemize @bullet
7450 @item
7451 Extended @code{asm} statements have to be inside a C
7452 function, so to write inline assembly language at file scope (``top-level''),
7453 outside of C functions, you must use basic @code{asm}.
7454 You can use this technique to emit assembler directives,
7455 define assembly language macros that can be invoked elsewhere in the file,
7456 or write entire functions in assembly language.
7457
7458 @item
7459 Functions declared
7460 with the @code{naked} attribute also require basic @code{asm}
7461 (@pxref{Function Attributes}).
7462 @end itemize
7463
7464 Safely accessing C data and calling functions from basic @code{asm} is more
7465 complex than it may appear. To access C data, it is better to use extended
7466 @code{asm}.
7467
7468 Do not expect a sequence of @code{asm} statements to remain perfectly
7469 consecutive after compilation. If certain instructions need to remain
7470 consecutive in the output, put them in a single multi-instruction @code{asm}
7471 statement. Note that GCC's optimizers can move @code{asm} statements
7472 relative to other code, including across jumps.
7473
7474 @code{asm} statements may not perform jumps into other @code{asm} statements.
7475 GCC does not know about these jumps, and therefore cannot take
7476 account of them when deciding how to optimize. Jumps from @code{asm} to C
7477 labels are only supported in extended @code{asm}.
7478
7479 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7480 assembly code when optimizing. This can lead to unexpected duplicate
7481 symbol errors during compilation if your assembly code defines symbols or
7482 labels.
7483
7484 Since GCC does not parse the @var{AssemblerInstructions}, it has no
7485 visibility of any symbols it references. This may result in GCC discarding
7486 those symbols as unreferenced.
7487
7488 The compiler copies the assembler instructions in a basic @code{asm}
7489 verbatim to the assembly language output file, without
7490 processing dialects or any of the @samp{%} operators that are available with
7491 extended @code{asm}. This results in minor differences between basic
7492 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7493 registers you might use @samp{%eax} in basic @code{asm} and
7494 @samp{%%eax} in extended @code{asm}.
7495
7496 On targets such as x86 that support multiple assembler dialects,
7497 all basic @code{asm} blocks use the assembler dialect specified by the
7498 @option{-masm} command-line option (@pxref{x86 Options}).
7499 Basic @code{asm} provides no
7500 mechanism to provide different assembler strings for different dialects.
7501
7502 Here is an example of basic @code{asm} for i386:
7503
7504 @example
7505 /* Note that this code will not compile with -masm=intel */
7506 #define DebugBreak() asm("int $3")
7507 @end example
7508
7509 @node Extended Asm
7510 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7511 @cindex extended @code{asm}
7512 @cindex assembly language in C, extended
7513
7514 With extended @code{asm} you can read and write C variables from
7515 assembler and perform jumps from assembler code to C labels.
7516 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7517 the operand parameters after the assembler template:
7518
7519 @example
7520 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7521 : @var{OutputOperands}
7522 @r{[} : @var{InputOperands}
7523 @r{[} : @var{Clobbers} @r{]} @r{]})
7524
7525 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7526 :
7527 : @var{InputOperands}
7528 : @var{Clobbers}
7529 : @var{GotoLabels})
7530 @end example
7531
7532 The @code{asm} keyword is a GNU extension.
7533 When writing code that can be compiled with @option{-ansi} and the
7534 various @option{-std} options, use @code{__asm__} instead of
7535 @code{asm} (@pxref{Alternate Keywords}).
7536
7537 @subsubheading Qualifiers
7538 @table @code
7539
7540 @item volatile
7541 The typical use of extended @code{asm} statements is to manipulate input
7542 values to produce output values. However, your @code{asm} statements may
7543 also produce side effects. If so, you may need to use the @code{volatile}
7544 qualifier to disable certain optimizations. @xref{Volatile}.
7545
7546 @item goto
7547 This qualifier informs the compiler that the @code{asm} statement may
7548 perform a jump to one of the labels listed in the @var{GotoLabels}.
7549 @xref{GotoLabels}.
7550 @end table
7551
7552 @subsubheading Parameters
7553 @table @var
7554 @item AssemblerTemplate
7555 This is a literal string that is the template for the assembler code. It is a
7556 combination of fixed text and tokens that refer to the input, output,
7557 and goto parameters. @xref{AssemblerTemplate}.
7558
7559 @item OutputOperands
7560 A comma-separated list of the C variables modified by the instructions in the
7561 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7562
7563 @item InputOperands
7564 A comma-separated list of C expressions read by the instructions in the
7565 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7566
7567 @item Clobbers
7568 A comma-separated list of registers or other values changed by the
7569 @var{AssemblerTemplate}, beyond those listed as outputs.
7570 An empty list is permitted. @xref{Clobbers}.
7571
7572 @item GotoLabels
7573 When you are using the @code{goto} form of @code{asm}, this section contains
7574 the list of all C labels to which the code in the
7575 @var{AssemblerTemplate} may jump.
7576 @xref{GotoLabels}.
7577
7578 @code{asm} statements may not perform jumps into other @code{asm} statements,
7579 only to the listed @var{GotoLabels}.
7580 GCC's optimizers do not know about other jumps; therefore they cannot take
7581 account of them when deciding how to optimize.
7582 @end table
7583
7584 The total number of input + output + goto operands is limited to 30.
7585
7586 @subsubheading Remarks
7587 The @code{asm} statement allows you to include assembly instructions directly
7588 within C code. This may help you to maximize performance in time-sensitive
7589 code or to access assembly instructions that are not readily available to C
7590 programs.
7591
7592 Note that extended @code{asm} statements must be inside a function. Only
7593 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7594 Functions declared with the @code{naked} attribute also require basic
7595 @code{asm} (@pxref{Function Attributes}).
7596
7597 While the uses of @code{asm} are many and varied, it may help to think of an
7598 @code{asm} statement as a series of low-level instructions that convert input
7599 parameters to output parameters. So a simple (if not particularly useful)
7600 example for i386 using @code{asm} might look like this:
7601
7602 @example
7603 int src = 1;
7604 int dst;
7605
7606 asm ("mov %1, %0\n\t"
7607 "add $1, %0"
7608 : "=r" (dst)
7609 : "r" (src));
7610
7611 printf("%d\n", dst);
7612 @end example
7613
7614 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7615
7616 @anchor{Volatile}
7617 @subsubsection Volatile
7618 @cindex volatile @code{asm}
7619 @cindex @code{asm} volatile
7620
7621 GCC's optimizers sometimes discard @code{asm} statements if they determine
7622 there is no need for the output variables. Also, the optimizers may move
7623 code out of loops if they believe that the code will always return the same
7624 result (i.e. none of its input values change between calls). Using the
7625 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7626 that have no output operands, including @code{asm goto} statements,
7627 are implicitly volatile.
7628
7629 This i386 code demonstrates a case that does not use (or require) the
7630 @code{volatile} qualifier. If it is performing assertion checking, this code
7631 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7632 unreferenced by any code. As a result, the optimizers can discard the
7633 @code{asm} statement, which in turn removes the need for the entire
7634 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7635 isn't needed you allow the optimizers to produce the most efficient code
7636 possible.
7637
7638 @example
7639 void DoCheck(uint32_t dwSomeValue)
7640 @{
7641 uint32_t dwRes;
7642
7643 // Assumes dwSomeValue is not zero.
7644 asm ("bsfl %1,%0"
7645 : "=r" (dwRes)
7646 : "r" (dwSomeValue)
7647 : "cc");
7648
7649 assert(dwRes > 3);
7650 @}
7651 @end example
7652
7653 The next example shows a case where the optimizers can recognize that the input
7654 (@code{dwSomeValue}) never changes during the execution of the function and can
7655 therefore move the @code{asm} outside the loop to produce more efficient code.
7656 Again, using @code{volatile} disables this type of optimization.
7657
7658 @example
7659 void do_print(uint32_t dwSomeValue)
7660 @{
7661 uint32_t dwRes;
7662
7663 for (uint32_t x=0; x < 5; x++)
7664 @{
7665 // Assumes dwSomeValue is not zero.
7666 asm ("bsfl %1,%0"
7667 : "=r" (dwRes)
7668 : "r" (dwSomeValue)
7669 : "cc");
7670
7671 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7672 @}
7673 @}
7674 @end example
7675
7676 The following example demonstrates a case where you need to use the
7677 @code{volatile} qualifier.
7678 It uses the x86 @code{rdtsc} instruction, which reads
7679 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7680 the optimizers might assume that the @code{asm} block will always return the
7681 same value and therefore optimize away the second call.
7682
7683 @example
7684 uint64_t msr;
7685
7686 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7687 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7688 "or %%rdx, %0" // 'Or' in the lower bits.
7689 : "=a" (msr)
7690 :
7691 : "rdx");
7692
7693 printf("msr: %llx\n", msr);
7694
7695 // Do other work...
7696
7697 // Reprint the timestamp
7698 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7699 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7700 "or %%rdx, %0" // 'Or' in the lower bits.
7701 : "=a" (msr)
7702 :
7703 : "rdx");
7704
7705 printf("msr: %llx\n", msr);
7706 @end example
7707
7708 GCC's optimizers do not treat this code like the non-volatile code in the
7709 earlier examples. They do not move it out of loops or omit it on the
7710 assumption that the result from a previous call is still valid.
7711
7712 Note that the compiler can move even volatile @code{asm} instructions relative
7713 to other code, including across jump instructions. For example, on many
7714 targets there is a system register that controls the rounding mode of
7715 floating-point operations. Setting it with a volatile @code{asm}, as in the
7716 following PowerPC example, does not work reliably.
7717
7718 @example
7719 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7720 sum = x + y;
7721 @end example
7722
7723 The compiler may move the addition back before the volatile @code{asm}. To
7724 make it work as expected, add an artificial dependency to the @code{asm} by
7725 referencing a variable in the subsequent code, for example:
7726
7727 @example
7728 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7729 sum = x + y;
7730 @end example
7731
7732 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7733 assembly code when optimizing. This can lead to unexpected duplicate symbol
7734 errors during compilation if your asm code defines symbols or labels.
7735 Using @samp{%=}
7736 (@pxref{AssemblerTemplate}) may help resolve this problem.
7737
7738 @anchor{AssemblerTemplate}
7739 @subsubsection Assembler Template
7740 @cindex @code{asm} assembler template
7741
7742 An assembler template is a literal string containing assembler instructions.
7743 The compiler replaces tokens in the template that refer
7744 to inputs, outputs, and goto labels,
7745 and then outputs the resulting string to the assembler. The
7746 string can contain any instructions recognized by the assembler, including
7747 directives. GCC does not parse the assembler instructions
7748 themselves and does not know what they mean or even whether they are valid
7749 assembler input. However, it does count the statements
7750 (@pxref{Size of an asm}).
7751
7752 You may place multiple assembler instructions together in a single @code{asm}
7753 string, separated by the characters normally used in assembly code for the
7754 system. A combination that works in most places is a newline to break the
7755 line, plus a tab character to move to the instruction field (written as
7756 @samp{\n\t}).
7757 Some assemblers allow semicolons as a line separator. However, note
7758 that some assembler dialects use semicolons to start a comment.
7759
7760 Do not expect a sequence of @code{asm} statements to remain perfectly
7761 consecutive after compilation, even when you are using the @code{volatile}
7762 qualifier. If certain instructions need to remain consecutive in the output,
7763 put them in a single multi-instruction asm statement.
7764
7765 Accessing data from C programs without using input/output operands (such as
7766 by using global symbols directly from the assembler template) may not work as
7767 expected. Similarly, calling functions directly from an assembler template
7768 requires a detailed understanding of the target assembler and ABI.
7769
7770 Since GCC does not parse the assembler template,
7771 it has no visibility of any
7772 symbols it references. This may result in GCC discarding those symbols as
7773 unreferenced unless they are also listed as input, output, or goto operands.
7774
7775 @subsubheading Special format strings
7776
7777 In addition to the tokens described by the input, output, and goto operands,
7778 these tokens have special meanings in the assembler template:
7779
7780 @table @samp
7781 @item %%
7782 Outputs a single @samp{%} into the assembler code.
7783
7784 @item %=
7785 Outputs a number that is unique to each instance of the @code{asm}
7786 statement in the entire compilation. This option is useful when creating local
7787 labels and referring to them multiple times in a single template that
7788 generates multiple assembler instructions.
7789
7790 @item %@{
7791 @itemx %|
7792 @itemx %@}
7793 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7794 into the assembler code. When unescaped, these characters have special
7795 meaning to indicate multiple assembler dialects, as described below.
7796 @end table
7797
7798 @subsubheading Multiple assembler dialects in @code{asm} templates
7799
7800 On targets such as x86, GCC supports multiple assembler dialects.
7801 The @option{-masm} option controls which dialect GCC uses as its
7802 default for inline assembler. The target-specific documentation for the
7803 @option{-masm} option contains the list of supported dialects, as well as the
7804 default dialect if the option is not specified. This information may be
7805 important to understand, since assembler code that works correctly when
7806 compiled using one dialect will likely fail if compiled using another.
7807 @xref{x86 Options}.
7808
7809 If your code needs to support multiple assembler dialects (for example, if
7810 you are writing public headers that need to support a variety of compilation
7811 options), use constructs of this form:
7812
7813 @example
7814 @{ dialect0 | dialect1 | dialect2... @}
7815 @end example
7816
7817 This construct outputs @code{dialect0}
7818 when using dialect #0 to compile the code,
7819 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7820 braces than the number of dialects the compiler supports, the construct
7821 outputs nothing.
7822
7823 For example, if an x86 compiler supports two dialects
7824 (@samp{att}, @samp{intel}), an
7825 assembler template such as this:
7826
7827 @example
7828 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7829 @end example
7830
7831 @noindent
7832 is equivalent to one of
7833
7834 @example
7835 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7836 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7837 @end example
7838
7839 Using that same compiler, this code:
7840
7841 @example
7842 "xchg@{l@}\t@{%%@}ebx, %1"
7843 @end example
7844
7845 @noindent
7846 corresponds to either
7847
7848 @example
7849 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7850 "xchg\tebx, %1" @r{/* intel dialect */}
7851 @end example
7852
7853 There is no support for nesting dialect alternatives.
7854
7855 @anchor{OutputOperands}
7856 @subsubsection Output Operands
7857 @cindex @code{asm} output operands
7858
7859 An @code{asm} statement has zero or more output operands indicating the names
7860 of C variables modified by the assembler code.
7861
7862 In this i386 example, @code{old} (referred to in the template string as
7863 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7864 (@code{%2}) is an input:
7865
7866 @example
7867 bool old;
7868
7869 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7870 "sbb %0,%0" // Use the CF to calculate old.
7871 : "=r" (old), "+rm" (*Base)
7872 : "Ir" (Offset)
7873 : "cc");
7874
7875 return old;
7876 @end example
7877
7878 Operands are separated by commas. Each operand has this format:
7879
7880 @example
7881 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7882 @end example
7883
7884 @table @var
7885 @item asmSymbolicName
7886 Specifies a symbolic name for the operand.
7887 Reference the name in the assembler template
7888 by enclosing it in square brackets
7889 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7890 that contains the definition. Any valid C variable name is acceptable,
7891 including names already defined in the surrounding code. No two operands
7892 within the same @code{asm} statement can use the same symbolic name.
7893
7894 When not using an @var{asmSymbolicName}, use the (zero-based) position
7895 of the operand
7896 in the list of operands in the assembler template. For example if there are
7897 three output operands, use @samp{%0} in the template to refer to the first,
7898 @samp{%1} for the second, and @samp{%2} for the third.
7899
7900 @item constraint
7901 A string constant specifying constraints on the placement of the operand;
7902 @xref{Constraints}, for details.
7903
7904 Output constraints must begin with either @samp{=} (a variable overwriting an
7905 existing value) or @samp{+} (when reading and writing). When using
7906 @samp{=}, do not assume the location contains the existing value
7907 on entry to the @code{asm}, except
7908 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7909
7910 After the prefix, there must be one or more additional constraints
7911 (@pxref{Constraints}) that describe where the value resides. Common
7912 constraints include @samp{r} for register and @samp{m} for memory.
7913 When you list more than one possible location (for example, @code{"=rm"}),
7914 the compiler chooses the most efficient one based on the current context.
7915 If you list as many alternates as the @code{asm} statement allows, you permit
7916 the optimizers to produce the best possible code.
7917 If you must use a specific register, but your Machine Constraints do not
7918 provide sufficient control to select the specific register you want,
7919 local register variables may provide a solution (@pxref{Local Register
7920 Variables}).
7921
7922 @item cvariablename
7923 Specifies a C lvalue expression to hold the output, typically a variable name.
7924 The enclosing parentheses are a required part of the syntax.
7925
7926 @end table
7927
7928 When the compiler selects the registers to use to
7929 represent the output operands, it does not use any of the clobbered registers
7930 (@pxref{Clobbers}).
7931
7932 Output operand expressions must be lvalues. The compiler cannot check whether
7933 the operands have data types that are reasonable for the instruction being
7934 executed. For output expressions that are not directly addressable (for
7935 example a bit-field), the constraint must allow a register. In that case, GCC
7936 uses the register as the output of the @code{asm}, and then stores that
7937 register into the output.
7938
7939 Operands using the @samp{+} constraint modifier count as two operands
7940 (that is, both as input and output) towards the total maximum of 30 operands
7941 per @code{asm} statement.
7942
7943 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7944 operands that must not overlap an input. Otherwise,
7945 GCC may allocate the output operand in the same register as an unrelated
7946 input operand, on the assumption that the assembler code consumes its
7947 inputs before producing outputs. This assumption may be false if the assembler
7948 code actually consists of more than one instruction.
7949
7950 The same problem can occur if one output parameter (@var{a}) allows a register
7951 constraint and another output parameter (@var{b}) allows a memory constraint.
7952 The code generated by GCC to access the memory address in @var{b} can contain
7953 registers which @emph{might} be shared by @var{a}, and GCC considers those
7954 registers to be inputs to the asm. As above, GCC assumes that such input
7955 registers are consumed before any outputs are written. This assumption may
7956 result in incorrect behavior if the asm writes to @var{a} before using
7957 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7958 ensures that modifying @var{a} does not affect the address referenced by
7959 @var{b}. Otherwise, the location of @var{b}
7960 is undefined if @var{a} is modified before using @var{b}.
7961
7962 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
7963 instead of simply @samp{%2}). Typically these qualifiers are hardware
7964 dependent. The list of supported modifiers for x86 is found at
7965 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7966
7967 If the C code that follows the @code{asm} makes no use of any of the output
7968 operands, use @code{volatile} for the @code{asm} statement to prevent the
7969 optimizers from discarding the @code{asm} statement as unneeded
7970 (see @ref{Volatile}).
7971
7972 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
7973 references the first output operand as @code{%0} (were there a second, it
7974 would be @code{%1}, etc). The number of the first input operand is one greater
7975 than that of the last output operand. In this i386 example, that makes
7976 @code{Mask} referenced as @code{%1}:
7977
7978 @example
7979 uint32_t Mask = 1234;
7980 uint32_t Index;
7981
7982 asm ("bsfl %1, %0"
7983 : "=r" (Index)
7984 : "r" (Mask)
7985 : "cc");
7986 @end example
7987
7988 That code overwrites the variable @code{Index} (@samp{=}),
7989 placing the value in a register (@samp{r}).
7990 Using the generic @samp{r} constraint instead of a constraint for a specific
7991 register allows the compiler to pick the register to use, which can result
7992 in more efficient code. This may not be possible if an assembler instruction
7993 requires a specific register.
7994
7995 The following i386 example uses the @var{asmSymbolicName} syntax.
7996 It produces the
7997 same result as the code above, but some may consider it more readable or more
7998 maintainable since reordering index numbers is not necessary when adding or
7999 removing operands. The names @code{aIndex} and @code{aMask}
8000 are only used in this example to emphasize which
8001 names get used where.
8002 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8003
8004 @example
8005 uint32_t Mask = 1234;
8006 uint32_t Index;
8007
8008 asm ("bsfl %[aMask], %[aIndex]"
8009 : [aIndex] "=r" (Index)
8010 : [aMask] "r" (Mask)
8011 : "cc");
8012 @end example
8013
8014 Here are some more examples of output operands.
8015
8016 @example
8017 uint32_t c = 1;
8018 uint32_t d;
8019 uint32_t *e = &c;
8020
8021 asm ("mov %[e], %[d]"
8022 : [d] "=rm" (d)
8023 : [e] "rm" (*e));
8024 @end example
8025
8026 Here, @code{d} may either be in a register or in memory. Since the compiler
8027 might already have the current value of the @code{uint32_t} location
8028 pointed to by @code{e}
8029 in a register, you can enable it to choose the best location
8030 for @code{d} by specifying both constraints.
8031
8032 @anchor{FlagOutputOperands}
8033 @subsubsection Flag Output Operands
8034 @cindex @code{asm} flag output operands
8035
8036 Some targets have a special register that holds the ``flags'' for the
8037 result of an operation or comparison. Normally, the contents of that
8038 register are either unmodifed by the asm, or the asm is considered to
8039 clobber the contents.
8040
8041 On some targets, a special form of output operand exists by which
8042 conditions in the flags register may be outputs of the asm. The set of
8043 conditions supported are target specific, but the general rule is that
8044 the output variable must be a scalar integer, and the value is boolean.
8045 When supported, the target defines the preprocessor symbol
8046 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8047
8048 Because of the special nature of the flag output operands, the constraint
8049 may not include alternatives.
8050
8051 Most often, the target has only one flags register, and thus is an implied
8052 operand of many instructions. In this case, the operand should not be
8053 referenced within the assembler template via @code{%0} etc, as there's
8054 no corresponding text in the assembly language.
8055
8056 @table @asis
8057 @item x86 family
8058 The flag output constraints for the x86 family are of the form
8059 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8060 conditions defined in the ISA manual for @code{j@var{cc}} or
8061 @code{set@var{cc}}.
8062
8063 @table @code
8064 @item a
8065 ``above'' or unsigned greater than
8066 @item ae
8067 ``above or equal'' or unsigned greater than or equal
8068 @item b
8069 ``below'' or unsigned less than
8070 @item be
8071 ``below or equal'' or unsigned less than or equal
8072 @item c
8073 carry flag set
8074 @item e
8075 @itemx z
8076 ``equal'' or zero flag set
8077 @item g
8078 signed greater than
8079 @item ge
8080 signed greater than or equal
8081 @item l
8082 signed less than
8083 @item le
8084 signed less than or equal
8085 @item o
8086 overflow flag set
8087 @item p
8088 parity flag set
8089 @item s
8090 sign flag set
8091 @item na
8092 @itemx nae
8093 @itemx nb
8094 @itemx nbe
8095 @itemx nc
8096 @itemx ne
8097 @itemx ng
8098 @itemx nge
8099 @itemx nl
8100 @itemx nle
8101 @itemx no
8102 @itemx np
8103 @itemx ns
8104 @itemx nz
8105 ``not'' @var{flag}, or inverted versions of those above
8106 @end table
8107
8108 @end table
8109
8110 @anchor{InputOperands}
8111 @subsubsection Input Operands
8112 @cindex @code{asm} input operands
8113 @cindex @code{asm} expressions
8114
8115 Input operands make values from C variables and expressions available to the
8116 assembly code.
8117
8118 Operands are separated by commas. Each operand has this format:
8119
8120 @example
8121 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8122 @end example
8123
8124 @table @var
8125 @item asmSymbolicName
8126 Specifies a symbolic name for the operand.
8127 Reference the name in the assembler template
8128 by enclosing it in square brackets
8129 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8130 that contains the definition. Any valid C variable name is acceptable,
8131 including names already defined in the surrounding code. No two operands
8132 within the same @code{asm} statement can use the same symbolic name.
8133
8134 When not using an @var{asmSymbolicName}, use the (zero-based) position
8135 of the operand
8136 in the list of operands in the assembler template. For example if there are
8137 two output operands and three inputs,
8138 use @samp{%2} in the template to refer to the first input operand,
8139 @samp{%3} for the second, and @samp{%4} for the third.
8140
8141 @item constraint
8142 A string constant specifying constraints on the placement of the operand;
8143 @xref{Constraints}, for details.
8144
8145 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8146 When you list more than one possible location (for example, @samp{"irm"}),
8147 the compiler chooses the most efficient one based on the current context.
8148 If you must use a specific register, but your Machine Constraints do not
8149 provide sufficient control to select the specific register you want,
8150 local register variables may provide a solution (@pxref{Local Register
8151 Variables}).
8152
8153 Input constraints can also be digits (for example, @code{"0"}). This indicates
8154 that the specified input must be in the same place as the output constraint
8155 at the (zero-based) index in the output constraint list.
8156 When using @var{asmSymbolicName} syntax for the output operands,
8157 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8158
8159 @item cexpression
8160 This is the C variable or expression being passed to the @code{asm} statement
8161 as input. The enclosing parentheses are a required part of the syntax.
8162
8163 @end table
8164
8165 When the compiler selects the registers to use to represent the input
8166 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8167
8168 If there are no output operands but there are input operands, place two
8169 consecutive colons where the output operands would go:
8170
8171 @example
8172 __asm__ ("some instructions"
8173 : /* No outputs. */
8174 : "r" (Offset / 8));
8175 @end example
8176
8177 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8178 (except for inputs tied to outputs). The compiler assumes that on exit from
8179 the @code{asm} statement these operands contain the same values as they
8180 had before executing the statement.
8181 It is @emph{not} possible to use clobbers
8182 to inform the compiler that the values in these inputs are changing. One
8183 common work-around is to tie the changing input variable to an output variable
8184 that never gets used. Note, however, that if the code that follows the
8185 @code{asm} statement makes no use of any of the output operands, the GCC
8186 optimizers may discard the @code{asm} statement as unneeded
8187 (see @ref{Volatile}).
8188
8189 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8190 instead of simply @samp{%2}). Typically these qualifiers are hardware
8191 dependent. The list of supported modifiers for x86 is found at
8192 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8193
8194 In this example using the fictitious @code{combine} instruction, the
8195 constraint @code{"0"} for input operand 1 says that it must occupy the same
8196 location as output operand 0. Only input operands may use numbers in
8197 constraints, and they must each refer to an output operand. Only a number (or
8198 the symbolic assembler name) in the constraint can guarantee that one operand
8199 is in the same place as another. The mere fact that @code{foo} is the value of
8200 both operands is not enough to guarantee that they are in the same place in
8201 the generated assembler code.
8202
8203 @example
8204 asm ("combine %2, %0"
8205 : "=r" (foo)
8206 : "0" (foo), "g" (bar));
8207 @end example
8208
8209 Here is an example using symbolic names.
8210
8211 @example
8212 asm ("cmoveq %1, %2, %[result]"
8213 : [result] "=r"(result)
8214 : "r" (test), "r" (new), "[result]" (old));
8215 @end example
8216
8217 @anchor{Clobbers}
8218 @subsubsection Clobbers
8219 @cindex @code{asm} clobbers
8220
8221 While the compiler is aware of changes to entries listed in the output
8222 operands, the inline @code{asm} code may modify more than just the outputs. For
8223 example, calculations may require additional registers, or the processor may
8224 overwrite a register as a side effect of a particular assembler instruction.
8225 In order to inform the compiler of these changes, list them in the clobber
8226 list. Clobber list items are either register names or the special clobbers
8227 (listed below). Each clobber list item is a string constant
8228 enclosed in double quotes and separated by commas.
8229
8230 Clobber descriptions may not in any way overlap with an input or output
8231 operand. For example, you may not have an operand describing a register class
8232 with one member when listing that register in the clobber list. Variables
8233 declared to live in specific registers (@pxref{Explicit Register
8234 Variables}) and used
8235 as @code{asm} input or output operands must have no part mentioned in the
8236 clobber description. In particular, there is no way to specify that input
8237 operands get modified without also specifying them as output operands.
8238
8239 When the compiler selects which registers to use to represent input and output
8240 operands, it does not use any of the clobbered registers. As a result,
8241 clobbered registers are available for any use in the assembler code.
8242
8243 Here is a realistic example for the VAX showing the use of clobbered
8244 registers:
8245
8246 @example
8247 asm volatile ("movc3 %0, %1, %2"
8248 : /* No outputs. */
8249 : "g" (from), "g" (to), "g" (count)
8250 : "r0", "r1", "r2", "r3", "r4", "r5");
8251 @end example
8252
8253 Also, there are two special clobber arguments:
8254
8255 @table @code
8256 @item "cc"
8257 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8258 register. On some machines, GCC represents the condition codes as a specific
8259 hardware register; @code{"cc"} serves to name this register.
8260 On other machines, condition code handling is different,
8261 and specifying @code{"cc"} has no effect. But
8262 it is valid no matter what the target.
8263
8264 @item "memory"
8265 The @code{"memory"} clobber tells the compiler that the assembly code
8266 performs memory
8267 reads or writes to items other than those listed in the input and output
8268 operands (for example, accessing the memory pointed to by one of the input
8269 parameters). To ensure memory contains correct values, GCC may need to flush
8270 specific register values to memory before executing the @code{asm}. Further,
8271 the compiler does not assume that any values read from memory before an
8272 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8273 needed.
8274 Using the @code{"memory"} clobber effectively forms a read/write
8275 memory barrier for the compiler.
8276
8277 Note that this clobber does not prevent the @emph{processor} from doing
8278 speculative reads past the @code{asm} statement. To prevent that, you need
8279 processor-specific fence instructions.
8280
8281 Flushing registers to memory has performance implications and may be an issue
8282 for time-sensitive code. You can use a trick to avoid this if the size of
8283 the memory being accessed is known at compile time. For example, if accessing
8284 ten bytes of a string, use a memory input like:
8285
8286 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8287
8288 @end table
8289
8290 @anchor{GotoLabels}
8291 @subsubsection Goto Labels
8292 @cindex @code{asm} goto labels
8293
8294 @code{asm goto} allows assembly code to jump to one or more C labels. The
8295 @var{GotoLabels} section in an @code{asm goto} statement contains
8296 a comma-separated
8297 list of all C labels to which the assembler code may jump. GCC assumes that
8298 @code{asm} execution falls through to the next statement (if this is not the
8299 case, consider using the @code{__builtin_unreachable} intrinsic after the
8300 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8301 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8302 Attributes}).
8303
8304 An @code{asm goto} statement cannot have outputs.
8305 This is due to an internal restriction of
8306 the compiler: control transfer instructions cannot have outputs.
8307 If the assembler code does modify anything, use the @code{"memory"} clobber
8308 to force the
8309 optimizers to flush all register values to memory and reload them if
8310 necessary after the @code{asm} statement.
8311
8312 Also note that an @code{asm goto} statement is always implicitly
8313 considered volatile.
8314
8315 To reference a label in the assembler template,
8316 prefix it with @samp{%l} (lowercase @samp{L}) followed
8317 by its (zero-based) position in @var{GotoLabels} plus the number of input
8318 operands. For example, if the @code{asm} has three inputs and references two
8319 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8320
8321 Alternately, you can reference labels using the actual C label name enclosed
8322 in brackets. For example, to reference a label named @code{carry}, you can
8323 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8324 section when using this approach.
8325
8326 Here is an example of @code{asm goto} for i386:
8327
8328 @example
8329 asm goto (
8330 "btl %1, %0\n\t"
8331 "jc %l2"
8332 : /* No outputs. */
8333 : "r" (p1), "r" (p2)
8334 : "cc"
8335 : carry);
8336
8337 return 0;
8338
8339 carry:
8340 return 1;
8341 @end example
8342
8343 The following example shows an @code{asm goto} that uses a memory clobber.
8344
8345 @example
8346 int frob(int x)
8347 @{
8348 int y;
8349 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8350 : /* No outputs. */
8351 : "r"(x), "r"(&y)
8352 : "r5", "memory"
8353 : error);
8354 return y;
8355 error:
8356 return -1;
8357 @}
8358 @end example
8359
8360 @anchor{x86Operandmodifiers}
8361 @subsubsection x86 Operand Modifiers
8362
8363 References to input, output, and goto operands in the assembler template
8364 of extended @code{asm} statements can use
8365 modifiers to affect the way the operands are formatted in
8366 the code output to the assembler. For example, the
8367 following code uses the @samp{h} and @samp{b} modifiers for x86:
8368
8369 @example
8370 uint16_t num;
8371 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8372 @end example
8373
8374 @noindent
8375 These modifiers generate this assembler code:
8376
8377 @example
8378 xchg %ah, %al
8379 @end example
8380
8381 The rest of this discussion uses the following code for illustrative purposes.
8382
8383 @example
8384 int main()
8385 @{
8386 int iInt = 1;
8387
8388 top:
8389
8390 asm volatile goto ("some assembler instructions here"
8391 : /* No outputs. */
8392 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8393 : /* No clobbers. */
8394 : top);
8395 @}
8396 @end example
8397
8398 With no modifiers, this is what the output from the operands would be for the
8399 @samp{att} and @samp{intel} dialects of assembler:
8400
8401 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8402 @headitem Operand @tab masm=att @tab masm=intel
8403 @item @code{%0}
8404 @tab @code{%eax}
8405 @tab @code{eax}
8406 @item @code{%1}
8407 @tab @code{$2}
8408 @tab @code{2}
8409 @item @code{%2}
8410 @tab @code{$.L2}
8411 @tab @code{OFFSET FLAT:.L2}
8412 @end multitable
8413
8414 The table below shows the list of supported modifiers and their effects.
8415
8416 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8417 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8418 @item @code{z}
8419 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8420 @tab @code{%z0}
8421 @tab @code{l}
8422 @tab
8423 @item @code{b}
8424 @tab Print the QImode name of the register.
8425 @tab @code{%b0}
8426 @tab @code{%al}
8427 @tab @code{al}
8428 @item @code{h}
8429 @tab Print the QImode name for a ``high'' register.
8430 @tab @code{%h0}
8431 @tab @code{%ah}
8432 @tab @code{ah}
8433 @item @code{w}
8434 @tab Print the HImode name of the register.
8435 @tab @code{%w0}
8436 @tab @code{%ax}
8437 @tab @code{ax}
8438 @item @code{k}
8439 @tab Print the SImode name of the register.
8440 @tab @code{%k0}
8441 @tab @code{%eax}
8442 @tab @code{eax}
8443 @item @code{q}
8444 @tab Print the DImode name of the register.
8445 @tab @code{%q0}
8446 @tab @code{%rax}
8447 @tab @code{rax}
8448 @item @code{l}
8449 @tab Print the label name with no punctuation.
8450 @tab @code{%l2}
8451 @tab @code{.L2}
8452 @tab @code{.L2}
8453 @item @code{c}
8454 @tab Require a constant operand and print the constant expression with no punctuation.
8455 @tab @code{%c1}
8456 @tab @code{2}
8457 @tab @code{2}
8458 @end multitable
8459
8460 @anchor{x86floatingpointasmoperands}
8461 @subsubsection x86 Floating-Point @code{asm} Operands
8462
8463 On x86 targets, there are several rules on the usage of stack-like registers
8464 in the operands of an @code{asm}. These rules apply only to the operands
8465 that are stack-like registers:
8466
8467 @enumerate
8468 @item
8469 Given a set of input registers that die in an @code{asm}, it is
8470 necessary to know which are implicitly popped by the @code{asm}, and
8471 which must be explicitly popped by GCC@.
8472
8473 An input register that is implicitly popped by the @code{asm} must be
8474 explicitly clobbered, unless it is constrained to match an
8475 output operand.
8476
8477 @item
8478 For any input register that is implicitly popped by an @code{asm}, it is
8479 necessary to know how to adjust the stack to compensate for the pop.
8480 If any non-popped input is closer to the top of the reg-stack than
8481 the implicitly popped register, it would not be possible to know what the
8482 stack looked like---it's not clear how the rest of the stack ``slides
8483 up''.
8484
8485 All implicitly popped input registers must be closer to the top of
8486 the reg-stack than any input that is not implicitly popped.
8487
8488 It is possible that if an input dies in an @code{asm}, the compiler might
8489 use the input register for an output reload. Consider this example:
8490
8491 @smallexample
8492 asm ("foo" : "=t" (a) : "f" (b));
8493 @end smallexample
8494
8495 @noindent
8496 This code says that input @code{b} is not popped by the @code{asm}, and that
8497 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8498 deeper after the @code{asm} than it was before. But, it is possible that
8499 reload may think that it can use the same register for both the input and
8500 the output.
8501
8502 To prevent this from happening,
8503 if any input operand uses the @samp{f} constraint, all output register
8504 constraints must use the @samp{&} early-clobber modifier.
8505
8506 The example above is correctly written as:
8507
8508 @smallexample
8509 asm ("foo" : "=&t" (a) : "f" (b));
8510 @end smallexample
8511
8512 @item
8513 Some operands need to be in particular places on the stack. All
8514 output operands fall in this category---GCC has no other way to
8515 know which registers the outputs appear in unless you indicate
8516 this in the constraints.
8517
8518 Output operands must specifically indicate which register an output
8519 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8520 constraints must select a class with a single register.
8521
8522 @item
8523 Output operands may not be ``inserted'' between existing stack registers.
8524 Since no 387 opcode uses a read/write operand, all output operands
8525 are dead before the @code{asm}, and are pushed by the @code{asm}.
8526 It makes no sense to push anywhere but the top of the reg-stack.
8527
8528 Output operands must start at the top of the reg-stack: output
8529 operands may not ``skip'' a register.
8530
8531 @item
8532 Some @code{asm} statements may need extra stack space for internal
8533 calculations. This can be guaranteed by clobbering stack registers
8534 unrelated to the inputs and outputs.
8535
8536 @end enumerate
8537
8538 This @code{asm}
8539 takes one input, which is internally popped, and produces two outputs.
8540
8541 @smallexample
8542 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8543 @end smallexample
8544
8545 @noindent
8546 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8547 and replaces them with one output. The @code{st(1)} clobber is necessary
8548 for the compiler to know that @code{fyl2xp1} pops both inputs.
8549
8550 @smallexample
8551 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8552 @end smallexample
8553
8554 @lowersections
8555 @include md.texi
8556 @raisesections
8557
8558 @node Asm Labels
8559 @subsection Controlling Names Used in Assembler Code
8560 @cindex assembler names for identifiers
8561 @cindex names used in assembler code
8562 @cindex identifiers, names in assembler code
8563
8564 You can specify the name to be used in the assembler code for a C
8565 function or variable by writing the @code{asm} (or @code{__asm__})
8566 keyword after the declarator.
8567 It is up to you to make sure that the assembler names you choose do not
8568 conflict with any other assembler symbols, or reference registers.
8569
8570 @subsubheading Assembler names for data:
8571
8572 This sample shows how to specify the assembler name for data:
8573
8574 @smallexample
8575 int foo asm ("myfoo") = 2;
8576 @end smallexample
8577
8578 @noindent
8579 This specifies that the name to be used for the variable @code{foo} in
8580 the assembler code should be @samp{myfoo} rather than the usual
8581 @samp{_foo}.
8582
8583 On systems where an underscore is normally prepended to the name of a C
8584 variable, this feature allows you to define names for the
8585 linker that do not start with an underscore.
8586
8587 GCC does not support using this feature with a non-static local variable
8588 since such variables do not have assembler names. If you are
8589 trying to put the variable in a particular register, see
8590 @ref{Explicit Register Variables}.
8591
8592 @subsubheading Assembler names for functions:
8593
8594 To specify the assembler name for functions, write a declaration for the
8595 function before its definition and put @code{asm} there, like this:
8596
8597 @smallexample
8598 int func (int x, int y) asm ("MYFUNC");
8599
8600 int func (int x, int y)
8601 @{
8602 /* @r{@dots{}} */
8603 @end smallexample
8604
8605 @noindent
8606 This specifies that the name to be used for the function @code{func} in
8607 the assembler code should be @code{MYFUNC}.
8608
8609 @node Explicit Register Variables
8610 @subsection Variables in Specified Registers
8611 @anchor{Explicit Reg Vars}
8612 @cindex explicit register variables
8613 @cindex variables in specified registers
8614 @cindex specified registers
8615
8616 GNU C allows you to associate specific hardware registers with C
8617 variables. In almost all cases, allowing the compiler to assign
8618 registers produces the best code. However under certain unusual
8619 circumstances, more precise control over the variable storage is
8620 required.
8621
8622 Both global and local variables can be associated with a register. The
8623 consequences of performing this association are very different between
8624 the two, as explained in the sections below.
8625
8626 @menu
8627 * Global Register Variables:: Variables declared at global scope.
8628 * Local Register Variables:: Variables declared within a function.
8629 @end menu
8630
8631 @node Global Register Variables
8632 @subsubsection Defining Global Register Variables
8633 @anchor{Global Reg Vars}
8634 @cindex global register variables
8635 @cindex registers, global variables in
8636 @cindex registers, global allocation
8637
8638 You can define a global register variable and associate it with a specified
8639 register like this:
8640
8641 @smallexample
8642 register int *foo asm ("r12");
8643 @end smallexample
8644
8645 @noindent
8646 Here @code{r12} is the name of the register that should be used. Note that
8647 this is the same syntax used for defining local register variables, but for
8648 a global variable the declaration appears outside a function. The
8649 @code{register} keyword is required, and cannot be combined with
8650 @code{static}. The register name must be a valid register name for the
8651 target platform.
8652
8653 Registers are a scarce resource on most systems and allowing the
8654 compiler to manage their usage usually results in the best code. However,
8655 under special circumstances it can make sense to reserve some globally.
8656 For example this may be useful in programs such as programming language
8657 interpreters that have a couple of global variables that are accessed
8658 very often.
8659
8660 After defining a global register variable, for the current compilation
8661 unit:
8662
8663 @itemize @bullet
8664 @item The register is reserved entirely for this use, and will not be
8665 allocated for any other purpose.
8666 @item The register is not saved and restored by any functions.
8667 @item Stores into this register are never deleted even if they appear to be
8668 dead, but references may be deleted, moved or simplified.
8669 @end itemize
8670
8671 Note that these points @emph{only} apply to code that is compiled with the
8672 definition. The behavior of code that is merely linked in (for example
8673 code from libraries) is not affected.
8674
8675 If you want to recompile source files that do not actually use your global
8676 register variable so they do not use the specified register for any other
8677 purpose, you need not actually add the global register declaration to
8678 their source code. It suffices to specify the compiler option
8679 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8680 register.
8681
8682 @subsubheading Declaring the variable
8683
8684 Global register variables can not have initial values, because an
8685 executable file has no means to supply initial contents for a register.
8686
8687 When selecting a register, choose one that is normally saved and
8688 restored by function calls on your machine. This ensures that code
8689 which is unaware of this reservation (such as library routines) will
8690 restore it before returning.
8691
8692 On machines with register windows, be sure to choose a global
8693 register that is not affected magically by the function call mechanism.
8694
8695 @subsubheading Using the variable
8696
8697 @cindex @code{qsort}, and global register variables
8698 When calling routines that are not aware of the reservation, be
8699 cautious if those routines call back into code which uses them. As an
8700 example, if you call the system library version of @code{qsort}, it may
8701 clobber your registers during execution, but (if you have selected
8702 appropriate registers) it will restore them before returning. However
8703 it will @emph{not} restore them before calling @code{qsort}'s comparison
8704 function. As a result, global values will not reliably be available to
8705 the comparison function unless the @code{qsort} function itself is rebuilt.
8706
8707 Similarly, it is not safe to access the global register variables from signal
8708 handlers or from more than one thread of control. Unless you recompile
8709 them specially for the task at hand, the system library routines may
8710 temporarily use the register for other things.
8711
8712 @cindex register variable after @code{longjmp}
8713 @cindex global register after @code{longjmp}
8714 @cindex value after @code{longjmp}
8715 @findex longjmp
8716 @findex setjmp
8717 On most machines, @code{longjmp} restores to each global register
8718 variable the value it had at the time of the @code{setjmp}. On some
8719 machines, however, @code{longjmp} does not change the value of global
8720 register variables. To be portable, the function that called @code{setjmp}
8721 should make other arrangements to save the values of the global register
8722 variables, and to restore them in a @code{longjmp}. This way, the same
8723 thing happens regardless of what @code{longjmp} does.
8724
8725 Eventually there may be a way of asking the compiler to choose a register
8726 automatically, but first we need to figure out how it should choose and
8727 how to enable you to guide the choice. No solution is evident.
8728
8729 @node Local Register Variables
8730 @subsubsection Specifying Registers for Local Variables
8731 @anchor{Local Reg Vars}
8732 @cindex local variables, specifying registers
8733 @cindex specifying registers for local variables
8734 @cindex registers for local variables
8735
8736 You can define a local register variable and associate it with a specified
8737 register like this:
8738
8739 @smallexample
8740 register int *foo asm ("r12");
8741 @end smallexample
8742
8743 @noindent
8744 Here @code{r12} is the name of the register that should be used. Note
8745 that this is the same syntax used for defining global register variables,
8746 but for a local variable the declaration appears within a function. The
8747 @code{register} keyword is required, and cannot be combined with
8748 @code{static}. The register name must be a valid register name for the
8749 target platform.
8750
8751 As with global register variables, it is recommended that you choose
8752 a register that is normally saved and restored by function calls on your
8753 machine, so that calls to library routines will not clobber it.
8754
8755 The only supported use for this feature is to specify registers
8756 for input and output operands when calling Extended @code{asm}
8757 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8758 particular machine don't provide sufficient control to select the desired
8759 register. To force an operand into a register, create a local variable
8760 and specify the register name after the variable's declaration. Then use
8761 the local variable for the @code{asm} operand and specify any constraint
8762 letter that matches the register:
8763
8764 @smallexample
8765 register int *p1 asm ("r0") = @dots{};
8766 register int *p2 asm ("r1") = @dots{};
8767 register int *result asm ("r0");
8768 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8769 @end smallexample
8770
8771 @emph{Warning:} In the above example, be aware that a register (for example
8772 @code{r0}) can be call-clobbered by subsequent code, including function
8773 calls and library calls for arithmetic operators on other variables (for
8774 example the initialization of @code{p2}). In this case, use temporary
8775 variables for expressions between the register assignments:
8776
8777 @smallexample
8778 int t1 = @dots{};
8779 register int *p1 asm ("r0") = @dots{};
8780 register int *p2 asm ("r1") = t1;
8781 register int *result asm ("r0");
8782 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8783 @end smallexample
8784
8785 Defining a register variable does not reserve the register. Other than
8786 when invoking the Extended @code{asm}, the contents of the specified
8787 register are not guaranteed. For this reason, the following uses
8788 are explicitly @emph{not} supported. If they appear to work, it is only
8789 happenstance, and may stop working as intended due to (seemingly)
8790 unrelated changes in surrounding code, or even minor changes in the
8791 optimization of a future version of gcc:
8792
8793 @itemize @bullet
8794 @item Passing parameters to or from Basic @code{asm}
8795 @item Passing parameters to or from Extended @code{asm} without using input
8796 or output operands.
8797 @item Passing parameters to or from routines written in assembler (or
8798 other languages) using non-standard calling conventions.
8799 @end itemize
8800
8801 Some developers use Local Register Variables in an attempt to improve
8802 gcc's allocation of registers, especially in large functions. In this
8803 case the register name is essentially a hint to the register allocator.
8804 While in some instances this can generate better code, improvements are
8805 subject to the whims of the allocator/optimizers. Since there are no
8806 guarantees that your improvements won't be lost, this usage of Local
8807 Register Variables is discouraged.
8808
8809 On the MIPS platform, there is related use for local register variables
8810 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8811 Defining coprocessor specifics for MIPS targets, gccint,
8812 GNU Compiler Collection (GCC) Internals}).
8813
8814 @node Size of an asm
8815 @subsection Size of an @code{asm}
8816
8817 Some targets require that GCC track the size of each instruction used
8818 in order to generate correct code. Because the final length of the
8819 code produced by an @code{asm} statement is only known by the
8820 assembler, GCC must make an estimate as to how big it will be. It
8821 does this by counting the number of instructions in the pattern of the
8822 @code{asm} and multiplying that by the length of the longest
8823 instruction supported by that processor. (When working out the number
8824 of instructions, it assumes that any occurrence of a newline or of
8825 whatever statement separator character is supported by the assembler --
8826 typically @samp{;} --- indicates the end of an instruction.)
8827
8828 Normally, GCC's estimate is adequate to ensure that correct
8829 code is generated, but it is possible to confuse the compiler if you use
8830 pseudo instructions or assembler macros that expand into multiple real
8831 instructions, or if you use assembler directives that expand to more
8832 space in the object file than is needed for a single instruction.
8833 If this happens then the assembler may produce a diagnostic saying that
8834 a label is unreachable.
8835
8836 @node Alternate Keywords
8837 @section Alternate Keywords
8838 @cindex alternate keywords
8839 @cindex keywords, alternate
8840
8841 @option{-ansi} and the various @option{-std} options disable certain
8842 keywords. This causes trouble when you want to use GNU C extensions, or
8843 a general-purpose header file that should be usable by all programs,
8844 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8845 @code{inline} are not available in programs compiled with
8846 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8847 program compiled with @option{-std=c99} or @option{-std=c11}). The
8848 ISO C99 keyword
8849 @code{restrict} is only available when @option{-std=gnu99} (which will
8850 eventually be the default) or @option{-std=c99} (or the equivalent
8851 @option{-std=iso9899:1999}), or an option for a later standard
8852 version, is used.
8853
8854 The way to solve these problems is to put @samp{__} at the beginning and
8855 end of each problematical keyword. For example, use @code{__asm__}
8856 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8857
8858 Other C compilers won't accept these alternative keywords; if you want to
8859 compile with another compiler, you can define the alternate keywords as
8860 macros to replace them with the customary keywords. It looks like this:
8861
8862 @smallexample
8863 #ifndef __GNUC__
8864 #define __asm__ asm
8865 #endif
8866 @end smallexample
8867
8868 @findex __extension__
8869 @opindex pedantic
8870 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8871 You can
8872 prevent such warnings within one expression by writing
8873 @code{__extension__} before the expression. @code{__extension__} has no
8874 effect aside from this.
8875
8876 @node Incomplete Enums
8877 @section Incomplete @code{enum} Types
8878
8879 You can define an @code{enum} tag without specifying its possible values.
8880 This results in an incomplete type, much like what you get if you write
8881 @code{struct foo} without describing the elements. A later declaration
8882 that does specify the possible values completes the type.
8883
8884 You can't allocate variables or storage using the type while it is
8885 incomplete. However, you can work with pointers to that type.
8886
8887 This extension may not be very useful, but it makes the handling of
8888 @code{enum} more consistent with the way @code{struct} and @code{union}
8889 are handled.
8890
8891 This extension is not supported by GNU C++.
8892
8893 @node Function Names
8894 @section Function Names as Strings
8895 @cindex @code{__func__} identifier
8896 @cindex @code{__FUNCTION__} identifier
8897 @cindex @code{__PRETTY_FUNCTION__} identifier
8898
8899 GCC provides three magic variables that hold the name of the current
8900 function, as a string. The first of these is @code{__func__}, which
8901 is part of the C99 standard:
8902
8903 The identifier @code{__func__} is implicitly declared by the translator
8904 as if, immediately following the opening brace of each function
8905 definition, the declaration
8906
8907 @smallexample
8908 static const char __func__[] = "function-name";
8909 @end smallexample
8910
8911 @noindent
8912 appeared, where function-name is the name of the lexically-enclosing
8913 function. This name is the unadorned name of the function.
8914
8915 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8916 backward compatibility with old versions of GCC.
8917
8918 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8919 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8920 the type signature of the function as well as its bare name. For
8921 example, this program:
8922
8923 @smallexample
8924 extern "C" @{
8925 extern int printf (char *, ...);
8926 @}
8927
8928 class a @{
8929 public:
8930 void sub (int i)
8931 @{
8932 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8933 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8934 @}
8935 @};
8936
8937 int
8938 main (void)
8939 @{
8940 a ax;
8941 ax.sub (0);
8942 return 0;
8943 @}
8944 @end smallexample
8945
8946 @noindent
8947 gives this output:
8948
8949 @smallexample
8950 __FUNCTION__ = sub
8951 __PRETTY_FUNCTION__ = void a::sub(int)
8952 @end smallexample
8953
8954 These identifiers are variables, not preprocessor macros, and may not
8955 be used to initialize @code{char} arrays or be concatenated with other string
8956 literals.
8957
8958 @node Return Address
8959 @section Getting the Return or Frame Address of a Function
8960
8961 These functions may be used to get information about the callers of a
8962 function.
8963
8964 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8965 This function returns the return address of the current function, or of
8966 one of its callers. The @var{level} argument is number of frames to
8967 scan up the call stack. A value of @code{0} yields the return address
8968 of the current function, a value of @code{1} yields the return address
8969 of the caller of the current function, and so forth. When inlining
8970 the expected behavior is that the function returns the address of
8971 the function that is returned to. To work around this behavior use
8972 the @code{noinline} function attribute.
8973
8974 The @var{level} argument must be a constant integer.
8975
8976 On some machines it may be impossible to determine the return address of
8977 any function other than the current one; in such cases, or when the top
8978 of the stack has been reached, this function returns @code{0} or a
8979 random value. In addition, @code{__builtin_frame_address} may be used
8980 to determine if the top of the stack has been reached.
8981
8982 Additional post-processing of the returned value may be needed, see
8983 @code{__builtin_extract_return_addr}.
8984
8985 Calling this function with a nonzero argument can have unpredictable
8986 effects, including crashing the calling program. As a result, calls
8987 that are considered unsafe are diagnosed when the @option{-Wframe-address}
8988 option is in effect. Such calls should only be made in debugging
8989 situations.
8990 @end deftypefn
8991
8992 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8993 The address as returned by @code{__builtin_return_address} may have to be fed
8994 through this function to get the actual encoded address. For example, on the
8995 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8996 platforms an offset has to be added for the true next instruction to be
8997 executed.
8998
8999 If no fixup is needed, this function simply passes through @var{addr}.
9000 @end deftypefn
9001
9002 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9003 This function does the reverse of @code{__builtin_extract_return_addr}.
9004 @end deftypefn
9005
9006 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9007 This function is similar to @code{__builtin_return_address}, but it
9008 returns the address of the function frame rather than the return address
9009 of the function. Calling @code{__builtin_frame_address} with a value of
9010 @code{0} yields the frame address of the current function, a value of
9011 @code{1} yields the frame address of the caller of the current function,
9012 and so forth.
9013
9014 The frame is the area on the stack that holds local variables and saved
9015 registers. The frame address is normally the address of the first word
9016 pushed on to the stack by the function. However, the exact definition
9017 depends upon the processor and the calling convention. If the processor
9018 has a dedicated frame pointer register, and the function has a frame,
9019 then @code{__builtin_frame_address} returns the value of the frame
9020 pointer register.
9021
9022 On some machines it may be impossible to determine the frame address of
9023 any function other than the current one; in such cases, or when the top
9024 of the stack has been reached, this function returns @code{0} if
9025 the first frame pointer is properly initialized by the startup code.
9026
9027 Calling this function with a nonzero argument can have unpredictable
9028 effects, including crashing the calling program. As a result, calls
9029 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9030 option is in effect. Such calls should only be made in debugging
9031 situations.
9032 @end deftypefn
9033
9034 @node Vector Extensions
9035 @section Using Vector Instructions through Built-in Functions
9036
9037 On some targets, the instruction set contains SIMD vector instructions which
9038 operate on multiple values contained in one large register at the same time.
9039 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9040 this way.
9041
9042 The first step in using these extensions is to provide the necessary data
9043 types. This should be done using an appropriate @code{typedef}:
9044
9045 @smallexample
9046 typedef int v4si __attribute__ ((vector_size (16)));
9047 @end smallexample
9048
9049 @noindent
9050 The @code{int} type specifies the base type, while the attribute specifies
9051 the vector size for the variable, measured in bytes. For example, the
9052 declaration above causes the compiler to set the mode for the @code{v4si}
9053 type to be 16 bytes wide and divided into @code{int} sized units. For
9054 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9055 corresponding mode of @code{foo} is @acronym{V4SI}.
9056
9057 The @code{vector_size} attribute is only applicable to integral and
9058 float scalars, although arrays, pointers, and function return values
9059 are allowed in conjunction with this construct. Only sizes that are
9060 a power of two are currently allowed.
9061
9062 All the basic integer types can be used as base types, both as signed
9063 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9064 @code{long long}. In addition, @code{float} and @code{double} can be
9065 used to build floating-point vector types.
9066
9067 Specifying a combination that is not valid for the current architecture
9068 causes GCC to synthesize the instructions using a narrower mode.
9069 For example, if you specify a variable of type @code{V4SI} and your
9070 architecture does not allow for this specific SIMD type, GCC
9071 produces code that uses 4 @code{SIs}.
9072
9073 The types defined in this manner can be used with a subset of normal C
9074 operations. Currently, GCC allows using the following operators
9075 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9076
9077 The operations behave like C++ @code{valarrays}. Addition is defined as
9078 the addition of the corresponding elements of the operands. For
9079 example, in the code below, each of the 4 elements in @var{a} is
9080 added to the corresponding 4 elements in @var{b} and the resulting
9081 vector is stored in @var{c}.
9082
9083 @smallexample
9084 typedef int v4si __attribute__ ((vector_size (16)));
9085
9086 v4si a, b, c;
9087
9088 c = a + b;
9089 @end smallexample
9090
9091 Subtraction, multiplication, division, and the logical operations
9092 operate in a similar manner. Likewise, the result of using the unary
9093 minus or complement operators on a vector type is a vector whose
9094 elements are the negative or complemented values of the corresponding
9095 elements in the operand.
9096
9097 It is possible to use shifting operators @code{<<}, @code{>>} on
9098 integer-type vectors. The operation is defined as following: @code{@{a0,
9099 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9100 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9101 elements.
9102
9103 For convenience, it is allowed to use a binary vector operation
9104 where one operand is a scalar. In that case the compiler transforms
9105 the scalar operand into a vector where each element is the scalar from
9106 the operation. The transformation happens only if the scalar could be
9107 safely converted to the vector-element type.
9108 Consider the following code.
9109
9110 @smallexample
9111 typedef int v4si __attribute__ ((vector_size (16)));
9112
9113 v4si a, b, c;
9114 long l;
9115
9116 a = b + 1; /* a = b + @{1,1,1,1@}; */
9117 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9118
9119 a = l + a; /* Error, cannot convert long to int. */
9120 @end smallexample
9121
9122 Vectors can be subscripted as if the vector were an array with
9123 the same number of elements and base type. Out of bound accesses
9124 invoke undefined behavior at run time. Warnings for out of bound
9125 accesses for vector subscription can be enabled with
9126 @option{-Warray-bounds}.
9127
9128 Vector comparison is supported with standard comparison
9129 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9130 vector expressions of integer-type or real-type. Comparison between
9131 integer-type vectors and real-type vectors are not supported. The
9132 result of the comparison is a vector of the same width and number of
9133 elements as the comparison operands with a signed integral element
9134 type.
9135
9136 Vectors are compared element-wise producing 0 when comparison is false
9137 and -1 (constant of the appropriate type where all bits are set)
9138 otherwise. Consider the following example.
9139
9140 @smallexample
9141 typedef int v4si __attribute__ ((vector_size (16)));
9142
9143 v4si a = @{1,2,3,4@};
9144 v4si b = @{3,2,1,4@};
9145 v4si c;
9146
9147 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9148 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9149 @end smallexample
9150
9151 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9152 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9153 integer vector with the same number of elements of the same size as @code{b}
9154 and @code{c}, computes all three arguments and creates a vector
9155 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9156 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9157 As in the case of binary operations, this syntax is also accepted when
9158 one of @code{b} or @code{c} is a scalar that is then transformed into a
9159 vector. If both @code{b} and @code{c} are scalars and the type of
9160 @code{true?b:c} has the same size as the element type of @code{a}, then
9161 @code{b} and @code{c} are converted to a vector type whose elements have
9162 this type and with the same number of elements as @code{a}.
9163
9164 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9165 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9166 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9167 For mixed operations between a scalar @code{s} and a vector @code{v},
9168 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9169 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9170
9171 Vector shuffling is available using functions
9172 @code{__builtin_shuffle (vec, mask)} and
9173 @code{__builtin_shuffle (vec0, vec1, mask)}.
9174 Both functions construct a permutation of elements from one or two
9175 vectors and return a vector of the same type as the input vector(s).
9176 The @var{mask} is an integral vector with the same width (@var{W})
9177 and element count (@var{N}) as the output vector.
9178
9179 The elements of the input vectors are numbered in memory ordering of
9180 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9181 elements of @var{mask} are considered modulo @var{N} in the single-operand
9182 case and modulo @math{2*@var{N}} in the two-operand case.
9183
9184 Consider the following example,
9185
9186 @smallexample
9187 typedef int v4si __attribute__ ((vector_size (16)));
9188
9189 v4si a = @{1,2,3,4@};
9190 v4si b = @{5,6,7,8@};
9191 v4si mask1 = @{0,1,1,3@};
9192 v4si mask2 = @{0,4,2,5@};
9193 v4si res;
9194
9195 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9196 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9197 @end smallexample
9198
9199 Note that @code{__builtin_shuffle} is intentionally semantically
9200 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9201
9202 You can declare variables and use them in function calls and returns, as
9203 well as in assignments and some casts. You can specify a vector type as
9204 a return type for a function. Vector types can also be used as function
9205 arguments. It is possible to cast from one vector type to another,
9206 provided they are of the same size (in fact, you can also cast vectors
9207 to and from other datatypes of the same size).
9208
9209 You cannot operate between vectors of different lengths or different
9210 signedness without a cast.
9211
9212 @node Offsetof
9213 @section Support for @code{offsetof}
9214 @findex __builtin_offsetof
9215
9216 GCC implements for both C and C++ a syntactic extension to implement
9217 the @code{offsetof} macro.
9218
9219 @smallexample
9220 primary:
9221 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9222
9223 offsetof_member_designator:
9224 @code{identifier}
9225 | offsetof_member_designator "." @code{identifier}
9226 | offsetof_member_designator "[" @code{expr} "]"
9227 @end smallexample
9228
9229 This extension is sufficient such that
9230
9231 @smallexample
9232 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9233 @end smallexample
9234
9235 @noindent
9236 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9237 may be dependent. In either case, @var{member} may consist of a single
9238 identifier, or a sequence of member accesses and array references.
9239
9240 @node __sync Builtins
9241 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9242
9243 The following built-in functions
9244 are intended to be compatible with those described
9245 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9246 section 7.4. As such, they depart from normal GCC practice by not using
9247 the @samp{__builtin_} prefix and also by being overloaded so that they
9248 work on multiple types.
9249
9250 The definition given in the Intel documentation allows only for the use of
9251 the types @code{int}, @code{long}, @code{long long} or their unsigned
9252 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
9253 size other than the C type @code{_Bool} or the C++ type @code{bool}.
9254 Operations on pointer arguments are performed as if the operands were
9255 of the @code{uintptr_t} type. That is, they are not scaled by the size
9256 of the type to which the pointer points.
9257
9258 These functions are implemented in terms of the @samp{__atomic}
9259 builtins (@pxref{__atomic Builtins}). They should not be used for new
9260 code which should use the @samp{__atomic} builtins instead.
9261
9262 Not all operations are supported by all target processors. If a particular
9263 operation cannot be implemented on the target processor, a warning is
9264 generated and a call to an external function is generated. The external
9265 function carries the same name as the built-in version,
9266 with an additional suffix
9267 @samp{_@var{n}} where @var{n} is the size of the data type.
9268
9269 @c ??? Should we have a mechanism to suppress this warning? This is almost
9270 @c useful for implementing the operation under the control of an external
9271 @c mutex.
9272
9273 In most cases, these built-in functions are considered a @dfn{full barrier}.
9274 That is,
9275 no memory operand is moved across the operation, either forward or
9276 backward. Further, instructions are issued as necessary to prevent the
9277 processor from speculating loads across the operation and from queuing stores
9278 after the operation.
9279
9280 All of the routines are described in the Intel documentation to take
9281 ``an optional list of variables protected by the memory barrier''. It's
9282 not clear what is meant by that; it could mean that @emph{only} the
9283 listed variables are protected, or it could mean a list of additional
9284 variables to be protected. The list is ignored by GCC which treats it as
9285 empty. GCC interprets an empty list as meaning that all globally
9286 accessible variables should be protected.
9287
9288 @table @code
9289 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9290 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9291 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9292 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9293 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9294 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9295 @findex __sync_fetch_and_add
9296 @findex __sync_fetch_and_sub
9297 @findex __sync_fetch_and_or
9298 @findex __sync_fetch_and_and
9299 @findex __sync_fetch_and_xor
9300 @findex __sync_fetch_and_nand
9301 These built-in functions perform the operation suggested by the name, and
9302 returns the value that had previously been in memory. That is, operations
9303 on integer operands have the following semantics. Operations on pointer
9304 arguments are performed as if the operands were of the @code{uintptr_t}
9305 type. That is, they are not scaled by the size of the type to which
9306 the pointer points.
9307
9308 @smallexample
9309 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9310 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9311 @end smallexample
9312
9313 The object pointed to by the first argument must be of integer or pointer
9314 type. It must not be a Boolean type.
9315
9316 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9317 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9318
9319 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9320 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9321 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9322 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9323 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9324 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9325 @findex __sync_add_and_fetch
9326 @findex __sync_sub_and_fetch
9327 @findex __sync_or_and_fetch
9328 @findex __sync_and_and_fetch
9329 @findex __sync_xor_and_fetch
9330 @findex __sync_nand_and_fetch
9331 These built-in functions perform the operation suggested by the name, and
9332 return the new value. That is, operations on integer operands have
9333 the following semantics. Operations on pointer operands are performed as
9334 if the operand's type were @code{uintptr_t}.
9335
9336 @smallexample
9337 @{ *ptr @var{op}= value; return *ptr; @}
9338 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9339 @end smallexample
9340
9341 The same constraints on arguments apply as for the corresponding
9342 @code{__sync_op_and_fetch} built-in functions.
9343
9344 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9345 as @code{*ptr = ~(*ptr & value)} instead of
9346 @code{*ptr = ~*ptr & value}.
9347
9348 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9349 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9350 @findex __sync_bool_compare_and_swap
9351 @findex __sync_val_compare_and_swap
9352 These built-in functions perform an atomic compare and swap.
9353 That is, if the current
9354 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9355 @code{*@var{ptr}}.
9356
9357 The ``bool'' version returns true if the comparison is successful and
9358 @var{newval} is written. The ``val'' version returns the contents
9359 of @code{*@var{ptr}} before the operation.
9360
9361 @item __sync_synchronize (...)
9362 @findex __sync_synchronize
9363 This built-in function issues a full memory barrier.
9364
9365 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9366 @findex __sync_lock_test_and_set
9367 This built-in function, as described by Intel, is not a traditional test-and-set
9368 operation, but rather an atomic exchange operation. It writes @var{value}
9369 into @code{*@var{ptr}}, and returns the previous contents of
9370 @code{*@var{ptr}}.
9371
9372 Many targets have only minimal support for such locks, and do not support
9373 a full exchange operation. In this case, a target may support reduced
9374 functionality here by which the @emph{only} valid value to store is the
9375 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9376 is implementation defined.
9377
9378 This built-in function is not a full barrier,
9379 but rather an @dfn{acquire barrier}.
9380 This means that references after the operation cannot move to (or be
9381 speculated to) before the operation, but previous memory stores may not
9382 be globally visible yet, and previous memory loads may not yet be
9383 satisfied.
9384
9385 @item void __sync_lock_release (@var{type} *ptr, ...)
9386 @findex __sync_lock_release
9387 This built-in function releases the lock acquired by
9388 @code{__sync_lock_test_and_set}.
9389 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9390
9391 This built-in function is not a full barrier,
9392 but rather a @dfn{release barrier}.
9393 This means that all previous memory stores are globally visible, and all
9394 previous memory loads have been satisfied, but following memory reads
9395 are not prevented from being speculated to before the barrier.
9396 @end table
9397
9398 @node __atomic Builtins
9399 @section Built-in Functions for Memory Model Aware Atomic Operations
9400
9401 The following built-in functions approximately match the requirements
9402 for the C++11 memory model. They are all
9403 identified by being prefixed with @samp{__atomic} and most are
9404 overloaded so that they work with multiple types.
9405
9406 These functions are intended to replace the legacy @samp{__sync}
9407 builtins. The main difference is that the memory order that is requested
9408 is a parameter to the functions. New code should always use the
9409 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9410
9411 Note that the @samp{__atomic} builtins assume that programs will
9412 conform to the C++11 memory model. In particular, they assume
9413 that programs are free of data races. See the C++11 standard for
9414 detailed requirements.
9415
9416 The @samp{__atomic} builtins can be used with any integral scalar or
9417 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9418 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9419 supported by the architecture.
9420
9421 The four non-arithmetic functions (load, store, exchange, and
9422 compare_exchange) all have a generic version as well. This generic
9423 version works on any data type. It uses the lock-free built-in function
9424 if the specific data type size makes that possible; otherwise, an
9425 external call is left to be resolved at run time. This external call is
9426 the same format with the addition of a @samp{size_t} parameter inserted
9427 as the first parameter indicating the size of the object being pointed to.
9428 All objects must be the same size.
9429
9430 There are 6 different memory orders that can be specified. These map
9431 to the C++11 memory orders with the same names, see the C++11 standard
9432 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9433 on atomic synchronization} for detailed definitions. Individual
9434 targets may also support additional memory orders for use on specific
9435 architectures. Refer to the target documentation for details of
9436 these.
9437
9438 An atomic operation can both constrain code motion and
9439 be mapped to hardware instructions for synchronization between threads
9440 (e.g., a fence). To which extent this happens is controlled by the
9441 memory orders, which are listed here in approximately ascending order of
9442 strength. The description of each memory order is only meant to roughly
9443 illustrate the effects and is not a specification; see the C++11
9444 memory model for precise semantics.
9445
9446 @table @code
9447 @item __ATOMIC_RELAXED
9448 Implies no inter-thread ordering constraints.
9449 @item __ATOMIC_CONSUME
9450 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9451 memory order because of a deficiency in C++11's semantics for
9452 @code{memory_order_consume}.
9453 @item __ATOMIC_ACQUIRE
9454 Creates an inter-thread happens-before constraint from the release (or
9455 stronger) semantic store to this acquire load. Can prevent hoisting
9456 of code to before the operation.
9457 @item __ATOMIC_RELEASE
9458 Creates an inter-thread happens-before constraint to acquire (or stronger)
9459 semantic loads that read from this release store. Can prevent sinking
9460 of code to after the operation.
9461 @item __ATOMIC_ACQ_REL
9462 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9463 @code{__ATOMIC_RELEASE}.
9464 @item __ATOMIC_SEQ_CST
9465 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9466 @end table
9467
9468 Note that in the C++11 memory model, @emph{fences} (e.g.,
9469 @samp{__atomic_thread_fence}) take effect in combination with other
9470 atomic operations on specific memory locations (e.g., atomic loads);
9471 operations on specific memory locations do not necessarily affect other
9472 operations in the same way.
9473
9474 Target architectures are encouraged to provide their own patterns for
9475 each of the atomic built-in functions. If no target is provided, the original
9476 non-memory model set of @samp{__sync} atomic built-in functions are
9477 used, along with any required synchronization fences surrounding it in
9478 order to achieve the proper behavior. Execution in this case is subject
9479 to the same restrictions as those built-in functions.
9480
9481 If there is no pattern or mechanism to provide a lock-free instruction
9482 sequence, a call is made to an external routine with the same parameters
9483 to be resolved at run time.
9484
9485 When implementing patterns for these built-in functions, the memory order
9486 parameter can be ignored as long as the pattern implements the most
9487 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9488 orders execute correctly with this memory order but they may not execute as
9489 efficiently as they could with a more appropriate implementation of the
9490 relaxed requirements.
9491
9492 Note that the C++11 standard allows for the memory order parameter to be
9493 determined at run time rather than at compile time. These built-in
9494 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9495 than invoke a runtime library call or inline a switch statement. This is
9496 standard compliant, safe, and the simplest approach for now.
9497
9498 The memory order parameter is a signed int, but only the lower 16 bits are
9499 reserved for the memory order. The remainder of the signed int is reserved
9500 for target use and should be 0. Use of the predefined atomic values
9501 ensures proper usage.
9502
9503 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9504 This built-in function implements an atomic load operation. It returns the
9505 contents of @code{*@var{ptr}}.
9506
9507 The valid memory order variants are
9508 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9509 and @code{__ATOMIC_CONSUME}.
9510
9511 @end deftypefn
9512
9513 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9514 This is the generic version of an atomic load. It returns the
9515 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9516
9517 @end deftypefn
9518
9519 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9520 This built-in function implements an atomic store operation. It writes
9521 @code{@var{val}} into @code{*@var{ptr}}.
9522
9523 The valid memory order variants are
9524 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9525
9526 @end deftypefn
9527
9528 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9529 This is the generic version of an atomic store. It stores the value
9530 of @code{*@var{val}} into @code{*@var{ptr}}.
9531
9532 @end deftypefn
9533
9534 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9535 This built-in function implements an atomic exchange operation. It writes
9536 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9537 @code{*@var{ptr}}.
9538
9539 The valid memory order variants are
9540 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9541 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9542
9543 @end deftypefn
9544
9545 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9546 This is the generic version of an atomic exchange. It stores the
9547 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9548 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9549
9550 @end deftypefn
9551
9552 @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)
9553 This built-in function implements an atomic compare and exchange operation.
9554 This compares the contents of @code{*@var{ptr}} with the contents of
9555 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9556 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9557 equal, the operation is a @emph{read} and the current contents of
9558 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9559 for weak compare_exchange, which may fail spuriously, and false for
9560 the strong variation, which never fails spuriously. Many targets
9561 only offer the strong variation and ignore the parameter. When in doubt, use
9562 the strong variation.
9563
9564 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9565 and memory is affected according to the
9566 memory order specified by @var{success_memorder}. There are no
9567 restrictions on what memory order can be used here.
9568
9569 Otherwise, false is returned and memory is affected according
9570 to @var{failure_memorder}. This memory order cannot be
9571 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9572 stronger order than that specified by @var{success_memorder}.
9573
9574 @end deftypefn
9575
9576 @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)
9577 This built-in function implements the generic version of
9578 @code{__atomic_compare_exchange}. The function is virtually identical to
9579 @code{__atomic_compare_exchange_n}, except the desired value is also a
9580 pointer.
9581
9582 @end deftypefn
9583
9584 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9585 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9586 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9587 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9588 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9589 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9590 These built-in functions perform the operation suggested by the name, and
9591 return the result of the operation. Operations on pointer arguments are
9592 performed as if the operands were of the @code{uintptr_t} type. That is,
9593 they are not scaled by the size of the type to which the pointer points.
9594
9595 @smallexample
9596 @{ *ptr @var{op}= val; return *ptr; @}
9597 @end smallexample
9598
9599 The object pointed to by the first argument must be of integer or pointer
9600 type. It must not be a Boolean type. All memory orders are valid.
9601
9602 @end deftypefn
9603
9604 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9605 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9606 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9607 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9608 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9609 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9610 These built-in functions perform the operation suggested by the name, and
9611 return the value that had previously been in @code{*@var{ptr}}. Operations
9612 on pointer arguments are performed as if the operands were of
9613 the @code{uintptr_t} type. That is, they are not scaled by the size of
9614 the type to which the pointer points.
9615
9616 @smallexample
9617 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9618 @end smallexample
9619
9620 The same constraints on arguments apply as for the corresponding
9621 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9622
9623 @end deftypefn
9624
9625 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9626
9627 This built-in function performs an atomic test-and-set operation on
9628 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9629 defined nonzero ``set'' value and the return value is @code{true} if and only
9630 if the previous contents were ``set''.
9631 It should be only used for operands of type @code{bool} or @code{char}. For
9632 other types only part of the value may be set.
9633
9634 All memory orders are valid.
9635
9636 @end deftypefn
9637
9638 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9639
9640 This built-in function performs an atomic clear operation on
9641 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9642 It should be only used for operands of type @code{bool} or @code{char} and
9643 in conjunction with @code{__atomic_test_and_set}.
9644 For other types it may only clear partially. If the type is not @code{bool}
9645 prefer using @code{__atomic_store}.
9646
9647 The valid memory order variants are
9648 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9649 @code{__ATOMIC_RELEASE}.
9650
9651 @end deftypefn
9652
9653 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9654
9655 This built-in function acts as a synchronization fence between threads
9656 based on the specified memory order.
9657
9658 All memory orders are valid.
9659
9660 @end deftypefn
9661
9662 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9663
9664 This built-in function acts as a synchronization fence between a thread
9665 and signal handlers based in the same thread.
9666
9667 All memory orders are valid.
9668
9669 @end deftypefn
9670
9671 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9672
9673 This built-in function returns true if objects of @var{size} bytes always
9674 generate lock-free atomic instructions for the target architecture.
9675 @var{size} must resolve to a compile-time constant and the result also
9676 resolves to a compile-time constant.
9677
9678 @var{ptr} is an optional pointer to the object that may be used to determine
9679 alignment. A value of 0 indicates typical alignment should be used. The
9680 compiler may also ignore this parameter.
9681
9682 @smallexample
9683 if (__atomic_always_lock_free (sizeof (long long), 0))
9684 @end smallexample
9685
9686 @end deftypefn
9687
9688 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9689
9690 This built-in function returns true if objects of @var{size} bytes always
9691 generate lock-free atomic instructions for the target architecture. If
9692 the built-in function is not known to be lock-free, a call is made to a
9693 runtime routine named @code{__atomic_is_lock_free}.
9694
9695 @var{ptr} is an optional pointer to the object that may be used to determine
9696 alignment. A value of 0 indicates typical alignment should be used. The
9697 compiler may also ignore this parameter.
9698 @end deftypefn
9699
9700 @node Integer Overflow Builtins
9701 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9702
9703 The following built-in functions allow performing simple arithmetic operations
9704 together with checking whether the operations overflowed.
9705
9706 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9707 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9708 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9709 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9710 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9711 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9712 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9713
9714 These built-in functions promote the first two operands into infinite precision signed
9715 type and perform addition on those promoted operands. The result is then
9716 cast to the type the third pointer argument points to and stored there.
9717 If the stored result is equal to the infinite precision result, the built-in
9718 functions return false, otherwise they return true. As the addition is
9719 performed in infinite signed precision, these built-in functions have fully defined
9720 behavior for all argument values.
9721
9722 The first built-in function allows arbitrary integral types for operands and
9723 the result type must be pointer to some integer type, the rest of the built-in
9724 functions have explicit integer types.
9725
9726 The compiler will attempt to use hardware instructions to implement
9727 these built-in functions where possible, like conditional jump on overflow
9728 after addition, conditional jump on carry etc.
9729
9730 @end deftypefn
9731
9732 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9733 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9734 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9735 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9736 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9737 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9738 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9739
9740 These built-in functions are similar to the add overflow checking built-in
9741 functions above, except they perform subtraction, subtract the second argument
9742 from the first one, instead of addition.
9743
9744 @end deftypefn
9745
9746 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9747 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9748 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9749 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9750 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9751 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9752 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9753
9754 These built-in functions are similar to the add overflow checking built-in
9755 functions above, except they perform multiplication, instead of addition.
9756
9757 @end deftypefn
9758
9759 @node x86 specific memory model extensions for transactional memory
9760 @section x86-Specific Memory Model Extensions for Transactional Memory
9761
9762 The x86 architecture supports additional memory ordering flags
9763 to mark lock critical sections for hardware lock elision.
9764 These must be specified in addition to an existing memory order to
9765 atomic intrinsics.
9766
9767 @table @code
9768 @item __ATOMIC_HLE_ACQUIRE
9769 Start lock elision on a lock variable.
9770 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9771 @item __ATOMIC_HLE_RELEASE
9772 End lock elision on a lock variable.
9773 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9774 @end table
9775
9776 When a lock acquire fails, it is required for good performance to abort
9777 the transaction quickly. This can be done with a @code{_mm_pause}.
9778
9779 @smallexample
9780 #include <immintrin.h> // For _mm_pause
9781
9782 int lockvar;
9783
9784 /* Acquire lock with lock elision */
9785 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9786 _mm_pause(); /* Abort failed transaction */
9787 ...
9788 /* Free lock with lock elision */
9789 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9790 @end smallexample
9791
9792 @node Object Size Checking
9793 @section Object Size Checking Built-in Functions
9794 @findex __builtin_object_size
9795 @findex __builtin___memcpy_chk
9796 @findex __builtin___mempcpy_chk
9797 @findex __builtin___memmove_chk
9798 @findex __builtin___memset_chk
9799 @findex __builtin___strcpy_chk
9800 @findex __builtin___stpcpy_chk
9801 @findex __builtin___strncpy_chk
9802 @findex __builtin___strcat_chk
9803 @findex __builtin___strncat_chk
9804 @findex __builtin___sprintf_chk
9805 @findex __builtin___snprintf_chk
9806 @findex __builtin___vsprintf_chk
9807 @findex __builtin___vsnprintf_chk
9808 @findex __builtin___printf_chk
9809 @findex __builtin___vprintf_chk
9810 @findex __builtin___fprintf_chk
9811 @findex __builtin___vfprintf_chk
9812
9813 GCC implements a limited buffer overflow protection mechanism
9814 that can prevent some buffer overflow attacks.
9815
9816 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9817 is a built-in construct that returns a constant number of bytes from
9818 @var{ptr} to the end of the object @var{ptr} pointer points to
9819 (if known at compile time). @code{__builtin_object_size} never evaluates
9820 its arguments for side-effects. If there are any side-effects in them, it
9821 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9822 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9823 point to and all of them are known at compile time, the returned number
9824 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9825 0 and minimum if nonzero. If it is not possible to determine which objects
9826 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9827 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9828 for @var{type} 2 or 3.
9829
9830 @var{type} is an integer constant from 0 to 3. If the least significant
9831 bit is clear, objects are whole variables, if it is set, a closest
9832 surrounding subobject is considered the object a pointer points to.
9833 The second bit determines if maximum or minimum of remaining bytes
9834 is computed.
9835
9836 @smallexample
9837 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9838 char *p = &var.buf1[1], *q = &var.b;
9839
9840 /* Here the object p points to is var. */
9841 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9842 /* The subobject p points to is var.buf1. */
9843 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9844 /* The object q points to is var. */
9845 assert (__builtin_object_size (q, 0)
9846 == (char *) (&var + 1) - (char *) &var.b);
9847 /* The subobject q points to is var.b. */
9848 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9849 @end smallexample
9850 @end deftypefn
9851
9852 There are built-in functions added for many common string operation
9853 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9854 built-in is provided. This built-in has an additional last argument,
9855 which is the number of bytes remaining in object the @var{dest}
9856 argument points to or @code{(size_t) -1} if the size is not known.
9857
9858 The built-in functions are optimized into the normal string functions
9859 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9860 it is known at compile time that the destination object will not
9861 be overflown. If the compiler can determine at compile time the
9862 object will be always overflown, it issues a warning.
9863
9864 The intended use can be e.g.@:
9865
9866 @smallexample
9867 #undef memcpy
9868 #define bos0(dest) __builtin_object_size (dest, 0)
9869 #define memcpy(dest, src, n) \
9870 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9871
9872 char *volatile p;
9873 char buf[10];
9874 /* It is unknown what object p points to, so this is optimized
9875 into plain memcpy - no checking is possible. */
9876 memcpy (p, "abcde", n);
9877 /* Destination is known and length too. It is known at compile
9878 time there will be no overflow. */
9879 memcpy (&buf[5], "abcde", 5);
9880 /* Destination is known, but the length is not known at compile time.
9881 This will result in __memcpy_chk call that can check for overflow
9882 at run time. */
9883 memcpy (&buf[5], "abcde", n);
9884 /* Destination is known and it is known at compile time there will
9885 be overflow. There will be a warning and __memcpy_chk call that
9886 will abort the program at run time. */
9887 memcpy (&buf[6], "abcde", 5);
9888 @end smallexample
9889
9890 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9891 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9892 @code{strcat} and @code{strncat}.
9893
9894 There are also checking built-in functions for formatted output functions.
9895 @smallexample
9896 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9897 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9898 const char *fmt, ...);
9899 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9900 va_list ap);
9901 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9902 const char *fmt, va_list ap);
9903 @end smallexample
9904
9905 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9906 etc.@: functions and can contain implementation specific flags on what
9907 additional security measures the checking function might take, such as
9908 handling @code{%n} differently.
9909
9910 The @var{os} argument is the object size @var{s} points to, like in the
9911 other built-in functions. There is a small difference in the behavior
9912 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9913 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9914 the checking function is called with @var{os} argument set to
9915 @code{(size_t) -1}.
9916
9917 In addition to this, there are checking built-in functions
9918 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9919 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9920 These have just one additional argument, @var{flag}, right before
9921 format string @var{fmt}. If the compiler is able to optimize them to
9922 @code{fputc} etc.@: functions, it does, otherwise the checking function
9923 is called and the @var{flag} argument passed to it.
9924
9925 @node Pointer Bounds Checker builtins
9926 @section Pointer Bounds Checker Built-in Functions
9927 @cindex Pointer Bounds Checker builtins
9928 @findex __builtin___bnd_set_ptr_bounds
9929 @findex __builtin___bnd_narrow_ptr_bounds
9930 @findex __builtin___bnd_copy_ptr_bounds
9931 @findex __builtin___bnd_init_ptr_bounds
9932 @findex __builtin___bnd_null_ptr_bounds
9933 @findex __builtin___bnd_store_ptr_bounds
9934 @findex __builtin___bnd_chk_ptr_lbounds
9935 @findex __builtin___bnd_chk_ptr_ubounds
9936 @findex __builtin___bnd_chk_ptr_bounds
9937 @findex __builtin___bnd_get_ptr_lbound
9938 @findex __builtin___bnd_get_ptr_ubound
9939
9940 GCC provides a set of built-in functions to control Pointer Bounds Checker
9941 instrumentation. Note that all Pointer Bounds Checker builtins can be used
9942 even if you compile with Pointer Bounds Checker off
9943 (@option{-fno-check-pointer-bounds}).
9944 The behavior may differ in such case as documented below.
9945
9946 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9947
9948 This built-in function returns a new pointer with the value of @var{q}, and
9949 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
9950 Bounds Checker off, the built-in function just returns the first argument.
9951
9952 @smallexample
9953 extern void *__wrap_malloc (size_t n)
9954 @{
9955 void *p = (void *)__real_malloc (n);
9956 if (!p) return __builtin___bnd_null_ptr_bounds (p);
9957 return __builtin___bnd_set_ptr_bounds (p, n);
9958 @}
9959 @end smallexample
9960
9961 @end deftypefn
9962
9963 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
9964
9965 This built-in function returns a new pointer with the value of @var{p}
9966 and associates it with the narrowed bounds formed by the intersection
9967 of bounds associated with @var{q} and the bounds
9968 [@var{p}, @var{p} + @var{size} - 1].
9969 With Pointer Bounds Checker off, the built-in function just returns the first
9970 argument.
9971
9972 @smallexample
9973 void init_objects (object *objs, size_t size)
9974 @{
9975 size_t i;
9976 /* Initialize objects one-by-one passing pointers with bounds of
9977 an object, not the full array of objects. */
9978 for (i = 0; i < size; i++)
9979 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9980 sizeof(object)));
9981 @}
9982 @end smallexample
9983
9984 @end deftypefn
9985
9986 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9987
9988 This built-in function returns a new pointer with the value of @var{q},
9989 and associates it with the bounds already associated with pointer @var{r}.
9990 With Pointer Bounds Checker off, the built-in function just returns the first
9991 argument.
9992
9993 @smallexample
9994 /* Here is a way to get pointer to object's field but
9995 still with the full object's bounds. */
9996 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
9997 objptr);
9998 @end smallexample
9999
10000 @end deftypefn
10001
10002 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10003
10004 This built-in function returns a new pointer with the value of @var{q}, and
10005 associates it with INIT (allowing full memory access) bounds. With Pointer
10006 Bounds Checker off, the built-in function just returns the first argument.
10007
10008 @end deftypefn
10009
10010 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10011
10012 This built-in function returns a new pointer with the value of @var{q}, and
10013 associates it with NULL (allowing no memory access) bounds. With Pointer
10014 Bounds Checker off, the built-in function just returns the first argument.
10015
10016 @end deftypefn
10017
10018 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10019
10020 This built-in function stores the bounds associated with pointer @var{ptr_val}
10021 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10022 bounds from legacy code without touching the associated pointer's memory when
10023 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10024 function call is ignored.
10025
10026 @end deftypefn
10027
10028 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10029
10030 This built-in function checks if the pointer @var{q} is within the lower
10031 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10032 function call is ignored.
10033
10034 @smallexample
10035 extern void *__wrap_memset (void *dst, int c, size_t len)
10036 @{
10037 if (len > 0)
10038 @{
10039 __builtin___bnd_chk_ptr_lbounds (dst);
10040 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10041 __real_memset (dst, c, len);
10042 @}
10043 return dst;
10044 @}
10045 @end smallexample
10046
10047 @end deftypefn
10048
10049 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10050
10051 This built-in function checks if the pointer @var{q} is within the upper
10052 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10053 function call is ignored.
10054
10055 @end deftypefn
10056
10057 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10058
10059 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10060 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10061 off, the built-in function call is ignored.
10062
10063 @smallexample
10064 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10065 @{
10066 if (n > 0)
10067 @{
10068 __bnd_chk_ptr_bounds (dst, n);
10069 __bnd_chk_ptr_bounds (src, n);
10070 __real_memcpy (dst, src, n);
10071 @}
10072 return dst;
10073 @}
10074 @end smallexample
10075
10076 @end deftypefn
10077
10078 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10079
10080 This built-in function returns the lower bound associated
10081 with the pointer @var{q}, as a pointer value.
10082 This is useful for debugging using @code{printf}.
10083 With Pointer Bounds Checker off, the built-in function returns 0.
10084
10085 @smallexample
10086 void *lb = __builtin___bnd_get_ptr_lbound (q);
10087 void *ub = __builtin___bnd_get_ptr_ubound (q);
10088 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10089 @end smallexample
10090
10091 @end deftypefn
10092
10093 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10094
10095 This built-in function returns the upper bound (which is a pointer) associated
10096 with the pointer @var{q}. With Pointer Bounds Checker off,
10097 the built-in function returns -1.
10098
10099 @end deftypefn
10100
10101 @node Cilk Plus Builtins
10102 @section Cilk Plus C/C++ Language Extension Built-in Functions
10103
10104 GCC provides support for the following built-in reduction functions if Cilk Plus
10105 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10106
10107 @itemize @bullet
10108 @item @code{__sec_implicit_index}
10109 @item @code{__sec_reduce}
10110 @item @code{__sec_reduce_add}
10111 @item @code{__sec_reduce_all_nonzero}
10112 @item @code{__sec_reduce_all_zero}
10113 @item @code{__sec_reduce_any_nonzero}
10114 @item @code{__sec_reduce_any_zero}
10115 @item @code{__sec_reduce_max}
10116 @item @code{__sec_reduce_min}
10117 @item @code{__sec_reduce_max_ind}
10118 @item @code{__sec_reduce_min_ind}
10119 @item @code{__sec_reduce_mul}
10120 @item @code{__sec_reduce_mutating}
10121 @end itemize
10122
10123 Further details and examples about these built-in functions are described
10124 in the Cilk Plus language manual which can be found at
10125 @uref{http://www.cilkplus.org}.
10126
10127 @node Other Builtins
10128 @section Other Built-in Functions Provided by GCC
10129 @cindex built-in functions
10130 @findex __builtin_alloca
10131 @findex __builtin_alloca_with_align
10132 @findex __builtin_call_with_static_chain
10133 @findex __builtin_fpclassify
10134 @findex __builtin_isfinite
10135 @findex __builtin_isnormal
10136 @findex __builtin_isgreater
10137 @findex __builtin_isgreaterequal
10138 @findex __builtin_isinf_sign
10139 @findex __builtin_isless
10140 @findex __builtin_islessequal
10141 @findex __builtin_islessgreater
10142 @findex __builtin_isunordered
10143 @findex __builtin_powi
10144 @findex __builtin_powif
10145 @findex __builtin_powil
10146 @findex _Exit
10147 @findex _exit
10148 @findex abort
10149 @findex abs
10150 @findex acos
10151 @findex acosf
10152 @findex acosh
10153 @findex acoshf
10154 @findex acoshl
10155 @findex acosl
10156 @findex alloca
10157 @findex asin
10158 @findex asinf
10159 @findex asinh
10160 @findex asinhf
10161 @findex asinhl
10162 @findex asinl
10163 @findex atan
10164 @findex atan2
10165 @findex atan2f
10166 @findex atan2l
10167 @findex atanf
10168 @findex atanh
10169 @findex atanhf
10170 @findex atanhl
10171 @findex atanl
10172 @findex bcmp
10173 @findex bzero
10174 @findex cabs
10175 @findex cabsf
10176 @findex cabsl
10177 @findex cacos
10178 @findex cacosf
10179 @findex cacosh
10180 @findex cacoshf
10181 @findex cacoshl
10182 @findex cacosl
10183 @findex calloc
10184 @findex carg
10185 @findex cargf
10186 @findex cargl
10187 @findex casin
10188 @findex casinf
10189 @findex casinh
10190 @findex casinhf
10191 @findex casinhl
10192 @findex casinl
10193 @findex catan
10194 @findex catanf
10195 @findex catanh
10196 @findex catanhf
10197 @findex catanhl
10198 @findex catanl
10199 @findex cbrt
10200 @findex cbrtf
10201 @findex cbrtl
10202 @findex ccos
10203 @findex ccosf
10204 @findex ccosh
10205 @findex ccoshf
10206 @findex ccoshl
10207 @findex ccosl
10208 @findex ceil
10209 @findex ceilf
10210 @findex ceill
10211 @findex cexp
10212 @findex cexpf
10213 @findex cexpl
10214 @findex cimag
10215 @findex cimagf
10216 @findex cimagl
10217 @findex clog
10218 @findex clogf
10219 @findex clogl
10220 @findex clog10
10221 @findex clog10f
10222 @findex clog10l
10223 @findex conj
10224 @findex conjf
10225 @findex conjl
10226 @findex copysign
10227 @findex copysignf
10228 @findex copysignl
10229 @findex cos
10230 @findex cosf
10231 @findex cosh
10232 @findex coshf
10233 @findex coshl
10234 @findex cosl
10235 @findex cpow
10236 @findex cpowf
10237 @findex cpowl
10238 @findex cproj
10239 @findex cprojf
10240 @findex cprojl
10241 @findex creal
10242 @findex crealf
10243 @findex creall
10244 @findex csin
10245 @findex csinf
10246 @findex csinh
10247 @findex csinhf
10248 @findex csinhl
10249 @findex csinl
10250 @findex csqrt
10251 @findex csqrtf
10252 @findex csqrtl
10253 @findex ctan
10254 @findex ctanf
10255 @findex ctanh
10256 @findex ctanhf
10257 @findex ctanhl
10258 @findex ctanl
10259 @findex dcgettext
10260 @findex dgettext
10261 @findex drem
10262 @findex dremf
10263 @findex dreml
10264 @findex erf
10265 @findex erfc
10266 @findex erfcf
10267 @findex erfcl
10268 @findex erff
10269 @findex erfl
10270 @findex exit
10271 @findex exp
10272 @findex exp10
10273 @findex exp10f
10274 @findex exp10l
10275 @findex exp2
10276 @findex exp2f
10277 @findex exp2l
10278 @findex expf
10279 @findex expl
10280 @findex expm1
10281 @findex expm1f
10282 @findex expm1l
10283 @findex fabs
10284 @findex fabsf
10285 @findex fabsl
10286 @findex fdim
10287 @findex fdimf
10288 @findex fdiml
10289 @findex ffs
10290 @findex floor
10291 @findex floorf
10292 @findex floorl
10293 @findex fma
10294 @findex fmaf
10295 @findex fmal
10296 @findex fmax
10297 @findex fmaxf
10298 @findex fmaxl
10299 @findex fmin
10300 @findex fminf
10301 @findex fminl
10302 @findex fmod
10303 @findex fmodf
10304 @findex fmodl
10305 @findex fprintf
10306 @findex fprintf_unlocked
10307 @findex fputs
10308 @findex fputs_unlocked
10309 @findex frexp
10310 @findex frexpf
10311 @findex frexpl
10312 @findex fscanf
10313 @findex gamma
10314 @findex gammaf
10315 @findex gammal
10316 @findex gamma_r
10317 @findex gammaf_r
10318 @findex gammal_r
10319 @findex gettext
10320 @findex hypot
10321 @findex hypotf
10322 @findex hypotl
10323 @findex ilogb
10324 @findex ilogbf
10325 @findex ilogbl
10326 @findex imaxabs
10327 @findex index
10328 @findex isalnum
10329 @findex isalpha
10330 @findex isascii
10331 @findex isblank
10332 @findex iscntrl
10333 @findex isdigit
10334 @findex isgraph
10335 @findex islower
10336 @findex isprint
10337 @findex ispunct
10338 @findex isspace
10339 @findex isupper
10340 @findex iswalnum
10341 @findex iswalpha
10342 @findex iswblank
10343 @findex iswcntrl
10344 @findex iswdigit
10345 @findex iswgraph
10346 @findex iswlower
10347 @findex iswprint
10348 @findex iswpunct
10349 @findex iswspace
10350 @findex iswupper
10351 @findex iswxdigit
10352 @findex isxdigit
10353 @findex j0
10354 @findex j0f
10355 @findex j0l
10356 @findex j1
10357 @findex j1f
10358 @findex j1l
10359 @findex jn
10360 @findex jnf
10361 @findex jnl
10362 @findex labs
10363 @findex ldexp
10364 @findex ldexpf
10365 @findex ldexpl
10366 @findex lgamma
10367 @findex lgammaf
10368 @findex lgammal
10369 @findex lgamma_r
10370 @findex lgammaf_r
10371 @findex lgammal_r
10372 @findex llabs
10373 @findex llrint
10374 @findex llrintf
10375 @findex llrintl
10376 @findex llround
10377 @findex llroundf
10378 @findex llroundl
10379 @findex log
10380 @findex log10
10381 @findex log10f
10382 @findex log10l
10383 @findex log1p
10384 @findex log1pf
10385 @findex log1pl
10386 @findex log2
10387 @findex log2f
10388 @findex log2l
10389 @findex logb
10390 @findex logbf
10391 @findex logbl
10392 @findex logf
10393 @findex logl
10394 @findex lrint
10395 @findex lrintf
10396 @findex lrintl
10397 @findex lround
10398 @findex lroundf
10399 @findex lroundl
10400 @findex malloc
10401 @findex memchr
10402 @findex memcmp
10403 @findex memcpy
10404 @findex mempcpy
10405 @findex memset
10406 @findex modf
10407 @findex modff
10408 @findex modfl
10409 @findex nearbyint
10410 @findex nearbyintf
10411 @findex nearbyintl
10412 @findex nextafter
10413 @findex nextafterf
10414 @findex nextafterl
10415 @findex nexttoward
10416 @findex nexttowardf
10417 @findex nexttowardl
10418 @findex pow
10419 @findex pow10
10420 @findex pow10f
10421 @findex pow10l
10422 @findex powf
10423 @findex powl
10424 @findex printf
10425 @findex printf_unlocked
10426 @findex putchar
10427 @findex puts
10428 @findex remainder
10429 @findex remainderf
10430 @findex remainderl
10431 @findex remquo
10432 @findex remquof
10433 @findex remquol
10434 @findex rindex
10435 @findex rint
10436 @findex rintf
10437 @findex rintl
10438 @findex round
10439 @findex roundf
10440 @findex roundl
10441 @findex scalb
10442 @findex scalbf
10443 @findex scalbl
10444 @findex scalbln
10445 @findex scalblnf
10446 @findex scalblnf
10447 @findex scalbn
10448 @findex scalbnf
10449 @findex scanfnl
10450 @findex signbit
10451 @findex signbitf
10452 @findex signbitl
10453 @findex signbitd32
10454 @findex signbitd64
10455 @findex signbitd128
10456 @findex significand
10457 @findex significandf
10458 @findex significandl
10459 @findex sin
10460 @findex sincos
10461 @findex sincosf
10462 @findex sincosl
10463 @findex sinf
10464 @findex sinh
10465 @findex sinhf
10466 @findex sinhl
10467 @findex sinl
10468 @findex snprintf
10469 @findex sprintf
10470 @findex sqrt
10471 @findex sqrtf
10472 @findex sqrtl
10473 @findex sscanf
10474 @findex stpcpy
10475 @findex stpncpy
10476 @findex strcasecmp
10477 @findex strcat
10478 @findex strchr
10479 @findex strcmp
10480 @findex strcpy
10481 @findex strcspn
10482 @findex strdup
10483 @findex strfmon
10484 @findex strftime
10485 @findex strlen
10486 @findex strncasecmp
10487 @findex strncat
10488 @findex strncmp
10489 @findex strncpy
10490 @findex strndup
10491 @findex strpbrk
10492 @findex strrchr
10493 @findex strspn
10494 @findex strstr
10495 @findex tan
10496 @findex tanf
10497 @findex tanh
10498 @findex tanhf
10499 @findex tanhl
10500 @findex tanl
10501 @findex tgamma
10502 @findex tgammaf
10503 @findex tgammal
10504 @findex toascii
10505 @findex tolower
10506 @findex toupper
10507 @findex towlower
10508 @findex towupper
10509 @findex trunc
10510 @findex truncf
10511 @findex truncl
10512 @findex vfprintf
10513 @findex vfscanf
10514 @findex vprintf
10515 @findex vscanf
10516 @findex vsnprintf
10517 @findex vsprintf
10518 @findex vsscanf
10519 @findex y0
10520 @findex y0f
10521 @findex y0l
10522 @findex y1
10523 @findex y1f
10524 @findex y1l
10525 @findex yn
10526 @findex ynf
10527 @findex ynl
10528
10529 GCC provides a large number of built-in functions other than the ones
10530 mentioned above. Some of these are for internal use in the processing
10531 of exceptions or variable-length argument lists and are not
10532 documented here because they may change from time to time; we do not
10533 recommend general use of these functions.
10534
10535 The remaining functions are provided for optimization purposes.
10536
10537 With the exception of built-ins that have library equivalents such as
10538 the standard C library functions discussed below, or that expand to
10539 library calls, GCC built-in functions are always expanded inline and
10540 thus do not have corresponding entry points and their address cannot
10541 be obtained. Attempting to use them in an expression other than
10542 a function call results in a compile-time error.
10543
10544 @opindex fno-builtin
10545 GCC includes built-in versions of many of the functions in the standard
10546 C library. These functions come in two forms: one whose names start with
10547 the @code{__builtin_} prefix, and the other without. Both forms have the
10548 same type (including prototype), the same address (when their address is
10549 taken), and the same meaning as the C library functions even if you specify
10550 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10551 functions are only optimized in certain cases; if they are not optimized in
10552 a particular case, a call to the library function is emitted.
10553
10554 @opindex ansi
10555 @opindex std
10556 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10557 @option{-std=c99} or @option{-std=c11}), the functions
10558 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10559 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10560 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10561 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10562 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10563 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10564 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10565 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10566 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10567 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10568 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10569 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10570 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10571 @code{significandl}, @code{significand}, @code{sincosf},
10572 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10573 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10574 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10575 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10576 @code{yn}
10577 may be handled as built-in functions.
10578 All these functions have corresponding versions
10579 prefixed with @code{__builtin_}, which may be used even in strict C90
10580 mode.
10581
10582 The ISO C99 functions
10583 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10584 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10585 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10586 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10587 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10588 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10589 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10590 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10591 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10592 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10593 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10594 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10595 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10596 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10597 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10598 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10599 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10600 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10601 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10602 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10603 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10604 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10605 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10606 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10607 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10608 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10609 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10610 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10611 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10612 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10613 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10614 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10615 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10616 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10617 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10618 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10619 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10620 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10621 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10622 are handled as built-in functions
10623 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10624
10625 There are also built-in versions of the ISO C99 functions
10626 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10627 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10628 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10629 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10630 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10631 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10632 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10633 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10634 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10635 that are recognized in any mode since ISO C90 reserves these names for
10636 the purpose to which ISO C99 puts them. All these functions have
10637 corresponding versions prefixed with @code{__builtin_}.
10638
10639 There are also GNU extension functions @code{clog10}, @code{clog10f} and
10640 @code{clog10l} which names are reserved by ISO C99 for future use.
10641 All these functions have versions prefixed with @code{__builtin_}.
10642
10643 The ISO C94 functions
10644 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10645 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10646 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10647 @code{towupper}
10648 are handled as built-in functions
10649 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10650
10651 The ISO C90 functions
10652 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10653 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10654 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10655 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10656 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10657 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10658 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10659 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10660 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10661 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10662 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10663 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10664 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10665 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10666 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10667 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10668 are all recognized as built-in functions unless
10669 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10670 is specified for an individual function). All of these functions have
10671 corresponding versions prefixed with @code{__builtin_}.
10672
10673 GCC provides built-in versions of the ISO C99 floating-point comparison
10674 macros that avoid raising exceptions for unordered operands. They have
10675 the same names as the standard macros ( @code{isgreater},
10676 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10677 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10678 prefixed. We intend for a library implementor to be able to simply
10679 @code{#define} each standard macro to its built-in equivalent.
10680 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10681 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10682 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10683 built-in functions appear both with and without the @code{__builtin_} prefix.
10684
10685 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
10686 The @code{__builtin_alloca} function must be called at block scope.
10687 The function allocates an object @var{size} bytes large on the stack
10688 of the calling function. The object is aligned on the default stack
10689 alignment boundary for the target determined by the
10690 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
10691 function returns a pointer to the first byte of the allocated object.
10692 The lifetime of the allocated object ends just before the calling
10693 function returns to its caller. This is so even when
10694 @code{__builtin_alloca} is called within a nested block.
10695
10696 For example, the following function allocates eight objects of @code{n}
10697 bytes each on the stack, storing a pointer to each in consecutive elements
10698 of the array @code{a}. It then passes the array to function @code{g}
10699 which can safely use the storage pointed to by each of the array elements.
10700
10701 @smallexample
10702 void f (unsigned n)
10703 @{
10704 void *a [8];
10705 for (int i = 0; i != 8; ++i)
10706 a [i] = __builtin_alloca (n);
10707
10708 g (a, n); // @r{safe}
10709 @}
10710 @end smallexample
10711
10712 Since the @code{__builtin_alloca} function doesn't validate its argument
10713 it is the responsibility of its caller to make sure the argument doesn't
10714 cause it to exceed the stack size limit.
10715 The @code{__builtin_alloca} function is provided to make it possible to
10716 allocate on the stack arrays of bytes with an upper bound that may be
10717 computed at run time. Since C99 @xref{Variable Length} Arrays offer
10718 similar functionality under a portable, more convenient, and safer
10719 interface they are recommended instead, in both C99 and C++ programs
10720 where GCC provides them as an extension.
10721
10722 @end deftypefn
10723
10724 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
10725 The @code{__builtin_alloca_with_align} function must be called at block
10726 scope. The function allocates an object @var{size} bytes large on
10727 the stack of the calling function. The allocated object is aligned on
10728 the boundary specified by the argument @var{alignment} whose unit is given
10729 in bits (not bytes). The @var{size} argument must be positive and not
10730 exceed the stack size limit. The @var{alignment} argument must be a constant
10731 integer expression that evaluates to a power of 2 greater than or equal to
10732 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
10733 with other values are rejected with an error indicating the valid bounds.
10734 The function returns a pointer to the first byte of the allocated object.
10735 The lifetime of the allocated object ends at the end of the block in which
10736 the function was called. The allocated storage is released no later than
10737 just before the calling function returns to its caller, but may be released
10738 at the end of the block in which the function was called.
10739
10740 For example, in the following function the call to @code{g} is unsafe
10741 because when @code{overalign} is non-zero, the space allocated by
10742 @code{__builtin_alloca_with_align} may have been released at the end
10743 of the @code{if} statement in which it was called.
10744
10745 @smallexample
10746 void f (unsigned n, bool overalign)
10747 @{
10748 void *p;
10749 if (overalign)
10750 p = __builtin_alloca_with_align (n, 64 /* bits */);
10751 else
10752 p = __builtin_alloc (n);
10753
10754 g (p, n); // @r{unsafe}
10755 @}
10756 @end smallexample
10757
10758 Since the @code{__builtin_alloca_with_align} function doesn't validate its
10759 @var{size} argument it is the responsibility of its caller to make sure
10760 the argument doesn't cause it to exceed the stack size limit.
10761 The @code{__builtin_alloca_with_align} function is provided to make
10762 it possible to allocate on the stack overaligned arrays of bytes with
10763 an upper bound that may be computed at run time. Since C99
10764 @xref{Variable Length} Arrays offer the same functionality under
10765 a portable, more convenient, and safer interface they are recommended
10766 instead, in both C99 and C++ programs where GCC provides them as
10767 an extension.
10768
10769 @end deftypefn
10770
10771 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10772
10773 You can use the built-in function @code{__builtin_types_compatible_p} to
10774 determine whether two types are the same.
10775
10776 This built-in function returns 1 if the unqualified versions of the
10777 types @var{type1} and @var{type2} (which are types, not expressions) are
10778 compatible, 0 otherwise. The result of this built-in function can be
10779 used in integer constant expressions.
10780
10781 This built-in function ignores top level qualifiers (e.g., @code{const},
10782 @code{volatile}). For example, @code{int} is equivalent to @code{const
10783 int}.
10784
10785 The type @code{int[]} and @code{int[5]} are compatible. On the other
10786 hand, @code{int} and @code{char *} are not compatible, even if the size
10787 of their types, on the particular architecture are the same. Also, the
10788 amount of pointer indirection is taken into account when determining
10789 similarity. Consequently, @code{short *} is not similar to
10790 @code{short **}. Furthermore, two types that are typedefed are
10791 considered compatible if their underlying types are compatible.
10792
10793 An @code{enum} type is not considered to be compatible with another
10794 @code{enum} type even if both are compatible with the same integer
10795 type; this is what the C standard specifies.
10796 For example, @code{enum @{foo, bar@}} is not similar to
10797 @code{enum @{hot, dog@}}.
10798
10799 You typically use this function in code whose execution varies
10800 depending on the arguments' types. For example:
10801
10802 @smallexample
10803 #define foo(x) \
10804 (@{ \
10805 typeof (x) tmp = (x); \
10806 if (__builtin_types_compatible_p (typeof (x), long double)) \
10807 tmp = foo_long_double (tmp); \
10808 else if (__builtin_types_compatible_p (typeof (x), double)) \
10809 tmp = foo_double (tmp); \
10810 else if (__builtin_types_compatible_p (typeof (x), float)) \
10811 tmp = foo_float (tmp); \
10812 else \
10813 abort (); \
10814 tmp; \
10815 @})
10816 @end smallexample
10817
10818 @emph{Note:} This construct is only available for C@.
10819
10820 @end deftypefn
10821
10822 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10823
10824 The @var{call_exp} expression must be a function call, and the
10825 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10826 is passed to the function call in the target's static chain location.
10827 The result of builtin is the result of the function call.
10828
10829 @emph{Note:} This builtin is only available for C@.
10830 This builtin can be used to call Go closures from C.
10831
10832 @end deftypefn
10833
10834 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10835
10836 You can use the built-in function @code{__builtin_choose_expr} to
10837 evaluate code depending on the value of a constant expression. This
10838 built-in function returns @var{exp1} if @var{const_exp}, which is an
10839 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10840
10841 This built-in function is analogous to the @samp{? :} operator in C,
10842 except that the expression returned has its type unaltered by promotion
10843 rules. Also, the built-in function does not evaluate the expression
10844 that is not chosen. For example, if @var{const_exp} evaluates to true,
10845 @var{exp2} is not evaluated even if it has side-effects.
10846
10847 This built-in function can return an lvalue if the chosen argument is an
10848 lvalue.
10849
10850 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10851 type. Similarly, if @var{exp2} is returned, its return type is the same
10852 as @var{exp2}.
10853
10854 Example:
10855
10856 @smallexample
10857 #define foo(x) \
10858 __builtin_choose_expr ( \
10859 __builtin_types_compatible_p (typeof (x), double), \
10860 foo_double (x), \
10861 __builtin_choose_expr ( \
10862 __builtin_types_compatible_p (typeof (x), float), \
10863 foo_float (x), \
10864 /* @r{The void expression results in a compile-time error} \
10865 @r{when assigning the result to something.} */ \
10866 (void)0))
10867 @end smallexample
10868
10869 @emph{Note:} This construct is only available for C@. Furthermore, the
10870 unused expression (@var{exp1} or @var{exp2} depending on the value of
10871 @var{const_exp}) may still generate syntax errors. This may change in
10872 future revisions.
10873
10874 @end deftypefn
10875
10876 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10877
10878 The built-in function @code{__builtin_complex} is provided for use in
10879 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10880 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10881 real binary floating-point type, and the result has the corresponding
10882 complex type with real and imaginary parts @var{real} and @var{imag}.
10883 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10884 infinities, NaNs and negative zeros are involved.
10885
10886 @end deftypefn
10887
10888 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10889 You can use the built-in function @code{__builtin_constant_p} to
10890 determine if a value is known to be constant at compile time and hence
10891 that GCC can perform constant-folding on expressions involving that
10892 value. The argument of the function is the value to test. The function
10893 returns the integer 1 if the argument is known to be a compile-time
10894 constant and 0 if it is not known to be a compile-time constant. A
10895 return of 0 does not indicate that the value is @emph{not} a constant,
10896 but merely that GCC cannot prove it is a constant with the specified
10897 value of the @option{-O} option.
10898
10899 You typically use this function in an embedded application where
10900 memory is a critical resource. If you have some complex calculation,
10901 you may want it to be folded if it involves constants, but need to call
10902 a function if it does not. For example:
10903
10904 @smallexample
10905 #define Scale_Value(X) \
10906 (__builtin_constant_p (X) \
10907 ? ((X) * SCALE + OFFSET) : Scale (X))
10908 @end smallexample
10909
10910 You may use this built-in function in either a macro or an inline
10911 function. However, if you use it in an inlined function and pass an
10912 argument of the function as the argument to the built-in, GCC
10913 never returns 1 when you call the inline function with a string constant
10914 or compound literal (@pxref{Compound Literals}) and does not return 1
10915 when you pass a constant numeric value to the inline function unless you
10916 specify the @option{-O} option.
10917
10918 You may also use @code{__builtin_constant_p} in initializers for static
10919 data. For instance, you can write
10920
10921 @smallexample
10922 static const int table[] = @{
10923 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10924 /* @r{@dots{}} */
10925 @};
10926 @end smallexample
10927
10928 @noindent
10929 This is an acceptable initializer even if @var{EXPRESSION} is not a
10930 constant expression, including the case where
10931 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10932 folded to a constant but @var{EXPRESSION} contains operands that are
10933 not otherwise permitted in a static initializer (for example,
10934 @code{0 && foo ()}). GCC must be more conservative about evaluating the
10935 built-in in this case, because it has no opportunity to perform
10936 optimization.
10937 @end deftypefn
10938
10939 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10940 @opindex fprofile-arcs
10941 You may use @code{__builtin_expect} to provide the compiler with
10942 branch prediction information. In general, you should prefer to
10943 use actual profile feedback for this (@option{-fprofile-arcs}), as
10944 programmers are notoriously bad at predicting how their programs
10945 actually perform. However, there are applications in which this
10946 data is hard to collect.
10947
10948 The return value is the value of @var{exp}, which should be an integral
10949 expression. The semantics of the built-in are that it is expected that
10950 @var{exp} == @var{c}. For example:
10951
10952 @smallexample
10953 if (__builtin_expect (x, 0))
10954 foo ();
10955 @end smallexample
10956
10957 @noindent
10958 indicates that we do not expect to call @code{foo}, since
10959 we expect @code{x} to be zero. Since you are limited to integral
10960 expressions for @var{exp}, you should use constructions such as
10961
10962 @smallexample
10963 if (__builtin_expect (ptr != NULL, 1))
10964 foo (*ptr);
10965 @end smallexample
10966
10967 @noindent
10968 when testing pointer or floating-point values.
10969 @end deftypefn
10970
10971 @deftypefn {Built-in Function} void __builtin_trap (void)
10972 This function causes the program to exit abnormally. GCC implements
10973 this function by using a target-dependent mechanism (such as
10974 intentionally executing an illegal instruction) or by calling
10975 @code{abort}. The mechanism used may vary from release to release so
10976 you should not rely on any particular implementation.
10977 @end deftypefn
10978
10979 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10980 If control flow reaches the point of the @code{__builtin_unreachable},
10981 the program is undefined. It is useful in situations where the
10982 compiler cannot deduce the unreachability of the code.
10983
10984 One such case is immediately following an @code{asm} statement that
10985 either never terminates, or one that transfers control elsewhere
10986 and never returns. In this example, without the
10987 @code{__builtin_unreachable}, GCC issues a warning that control
10988 reaches the end of a non-void function. It also generates code
10989 to return after the @code{asm}.
10990
10991 @smallexample
10992 int f (int c, int v)
10993 @{
10994 if (c)
10995 @{
10996 return v;
10997 @}
10998 else
10999 @{
11000 asm("jmp error_handler");
11001 __builtin_unreachable ();
11002 @}
11003 @}
11004 @end smallexample
11005
11006 @noindent
11007 Because the @code{asm} statement unconditionally transfers control out
11008 of the function, control never reaches the end of the function
11009 body. The @code{__builtin_unreachable} is in fact unreachable and
11010 communicates this fact to the compiler.
11011
11012 Another use for @code{__builtin_unreachable} is following a call a
11013 function that never returns but that is not declared
11014 @code{__attribute__((noreturn))}, as in this example:
11015
11016 @smallexample
11017 void function_that_never_returns (void);
11018
11019 int g (int c)
11020 @{
11021 if (c)
11022 @{
11023 return 1;
11024 @}
11025 else
11026 @{
11027 function_that_never_returns ();
11028 __builtin_unreachable ();
11029 @}
11030 @}
11031 @end smallexample
11032
11033 @end deftypefn
11034
11035 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11036 This function returns its first argument, and allows the compiler
11037 to assume that the returned pointer is at least @var{align} bytes
11038 aligned. This built-in can have either two or three arguments,
11039 if it has three, the third argument should have integer type, and
11040 if it is nonzero means misalignment offset. For example:
11041
11042 @smallexample
11043 void *x = __builtin_assume_aligned (arg, 16);
11044 @end smallexample
11045
11046 @noindent
11047 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11048 16-byte aligned, while:
11049
11050 @smallexample
11051 void *x = __builtin_assume_aligned (arg, 32, 8);
11052 @end smallexample
11053
11054 @noindent
11055 means that the compiler can assume for @code{x}, set to @code{arg}, that
11056 @code{(char *) x - 8} is 32-byte aligned.
11057 @end deftypefn
11058
11059 @deftypefn {Built-in Function} int __builtin_LINE ()
11060 This function is the equivalent to the preprocessor @code{__LINE__}
11061 macro and returns the line number of the invocation of the built-in.
11062 In a C++ default argument for a function @var{F}, it gets the line number of
11063 the call to @var{F}.
11064 @end deftypefn
11065
11066 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
11067 This function is the equivalent to the preprocessor @code{__FUNCTION__}
11068 macro and returns the function name the invocation of the built-in is in.
11069 @end deftypefn
11070
11071 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
11072 This function is the equivalent to the preprocessor @code{__FILE__}
11073 macro and returns the file name the invocation of the built-in is in.
11074 In a C++ default argument for a function @var{F}, it gets the file name of
11075 the call to @var{F}.
11076 @end deftypefn
11077
11078 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
11079 This function is used to flush the processor's instruction cache for
11080 the region of memory between @var{begin} inclusive and @var{end}
11081 exclusive. Some targets require that the instruction cache be
11082 flushed, after modifying memory containing code, in order to obtain
11083 deterministic behavior.
11084
11085 If the target does not require instruction cache flushes,
11086 @code{__builtin___clear_cache} has no effect. Otherwise either
11087 instructions are emitted in-line to clear the instruction cache or a
11088 call to the @code{__clear_cache} function in libgcc is made.
11089 @end deftypefn
11090
11091 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
11092 This function is used to minimize cache-miss latency by moving data into
11093 a cache before it is accessed.
11094 You can insert calls to @code{__builtin_prefetch} into code for which
11095 you know addresses of data in memory that is likely to be accessed soon.
11096 If the target supports them, data prefetch instructions are generated.
11097 If the prefetch is done early enough before the access then the data will
11098 be in the cache by the time it is accessed.
11099
11100 The value of @var{addr} is the address of the memory to prefetch.
11101 There are two optional arguments, @var{rw} and @var{locality}.
11102 The value of @var{rw} is a compile-time constant one or zero; one
11103 means that the prefetch is preparing for a write to the memory address
11104 and zero, the default, means that the prefetch is preparing for a read.
11105 The value @var{locality} must be a compile-time constant integer between
11106 zero and three. A value of zero means that the data has no temporal
11107 locality, so it need not be left in the cache after the access. A value
11108 of three means that the data has a high degree of temporal locality and
11109 should be left in all levels of cache possible. Values of one and two
11110 mean, respectively, a low or moderate degree of temporal locality. The
11111 default is three.
11112
11113 @smallexample
11114 for (i = 0; i < n; i++)
11115 @{
11116 a[i] = a[i] + b[i];
11117 __builtin_prefetch (&a[i+j], 1, 1);
11118 __builtin_prefetch (&b[i+j], 0, 1);
11119 /* @r{@dots{}} */
11120 @}
11121 @end smallexample
11122
11123 Data prefetch does not generate faults if @var{addr} is invalid, but
11124 the address expression itself must be valid. For example, a prefetch
11125 of @code{p->next} does not fault if @code{p->next} is not a valid
11126 address, but evaluation faults if @code{p} is not a valid address.
11127
11128 If the target does not support data prefetch, the address expression
11129 is evaluated if it includes side effects but no other code is generated
11130 and GCC does not issue a warning.
11131 @end deftypefn
11132
11133 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11134 Returns a positive infinity, if supported by the floating-point format,
11135 else @code{DBL_MAX}. This function is suitable for implementing the
11136 ISO C macro @code{HUGE_VAL}.
11137 @end deftypefn
11138
11139 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11140 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11141 @end deftypefn
11142
11143 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11144 Similar to @code{__builtin_huge_val}, except the return
11145 type is @code{long double}.
11146 @end deftypefn
11147
11148 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11149 This built-in implements the C99 fpclassify functionality. The first
11150 five int arguments should be the target library's notion of the
11151 possible FP classes and are used for return values. They must be
11152 constant values and they must appear in this order: @code{FP_NAN},
11153 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11154 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11155 to classify. GCC treats the last argument as type-generic, which
11156 means it does not do default promotion from float to double.
11157 @end deftypefn
11158
11159 @deftypefn {Built-in Function} double __builtin_inf (void)
11160 Similar to @code{__builtin_huge_val}, except a warning is generated
11161 if the target floating-point format does not support infinities.
11162 @end deftypefn
11163
11164 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11165 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11166 @end deftypefn
11167
11168 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11169 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11170 @end deftypefn
11171
11172 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11173 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11174 @end deftypefn
11175
11176 @deftypefn {Built-in Function} float __builtin_inff (void)
11177 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11178 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11179 @end deftypefn
11180
11181 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11182 Similar to @code{__builtin_inf}, except the return
11183 type is @code{long double}.
11184 @end deftypefn
11185
11186 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11187 Similar to @code{isinf}, except the return value is -1 for
11188 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11189 Note while the parameter list is an
11190 ellipsis, this function only accepts exactly one floating-point
11191 argument. GCC treats this parameter as type-generic, which means it
11192 does not do default promotion from float to double.
11193 @end deftypefn
11194
11195 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11196 This is an implementation of the ISO C99 function @code{nan}.
11197
11198 Since ISO C99 defines this function in terms of @code{strtod}, which we
11199 do not implement, a description of the parsing is in order. The string
11200 is parsed as by @code{strtol}; that is, the base is recognized by
11201 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11202 in the significand such that the least significant bit of the number
11203 is at the least significant bit of the significand. The number is
11204 truncated to fit the significand field provided. The significand is
11205 forced to be a quiet NaN@.
11206
11207 This function, if given a string literal all of which would have been
11208 consumed by @code{strtol}, is evaluated early enough that it is considered a
11209 compile-time constant.
11210 @end deftypefn
11211
11212 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11213 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11214 @end deftypefn
11215
11216 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11217 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11218 @end deftypefn
11219
11220 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11221 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11222 @end deftypefn
11223
11224 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11225 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11226 @end deftypefn
11227
11228 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11229 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11230 @end deftypefn
11231
11232 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11233 Similar to @code{__builtin_nan}, except the significand is forced
11234 to be a signaling NaN@. The @code{nans} function is proposed by
11235 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11236 @end deftypefn
11237
11238 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11239 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11240 @end deftypefn
11241
11242 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11243 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11244 @end deftypefn
11245
11246 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11247 Returns one plus the index of the least significant 1-bit of @var{x}, or
11248 if @var{x} is zero, returns zero.
11249 @end deftypefn
11250
11251 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11252 Returns the number of leading 0-bits in @var{x}, starting at the most
11253 significant bit position. If @var{x} is 0, the result is undefined.
11254 @end deftypefn
11255
11256 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11257 Returns the number of trailing 0-bits in @var{x}, starting at the least
11258 significant bit position. If @var{x} is 0, the result is undefined.
11259 @end deftypefn
11260
11261 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11262 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11263 number of bits following the most significant bit that are identical
11264 to it. There are no special cases for 0 or other values.
11265 @end deftypefn
11266
11267 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11268 Returns the number of 1-bits in @var{x}.
11269 @end deftypefn
11270
11271 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11272 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11273 modulo 2.
11274 @end deftypefn
11275
11276 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11277 Similar to @code{__builtin_ffs}, except the argument type is
11278 @code{long}.
11279 @end deftypefn
11280
11281 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11282 Similar to @code{__builtin_clz}, except the argument type is
11283 @code{unsigned long}.
11284 @end deftypefn
11285
11286 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11287 Similar to @code{__builtin_ctz}, except the argument type is
11288 @code{unsigned long}.
11289 @end deftypefn
11290
11291 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11292 Similar to @code{__builtin_clrsb}, except the argument type is
11293 @code{long}.
11294 @end deftypefn
11295
11296 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11297 Similar to @code{__builtin_popcount}, except the argument type is
11298 @code{unsigned long}.
11299 @end deftypefn
11300
11301 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11302 Similar to @code{__builtin_parity}, except the argument type is
11303 @code{unsigned long}.
11304 @end deftypefn
11305
11306 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11307 Similar to @code{__builtin_ffs}, except the argument type is
11308 @code{long long}.
11309 @end deftypefn
11310
11311 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11312 Similar to @code{__builtin_clz}, except the argument type is
11313 @code{unsigned long long}.
11314 @end deftypefn
11315
11316 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11317 Similar to @code{__builtin_ctz}, except the argument type is
11318 @code{unsigned long long}.
11319 @end deftypefn
11320
11321 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11322 Similar to @code{__builtin_clrsb}, except the argument type is
11323 @code{long long}.
11324 @end deftypefn
11325
11326 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11327 Similar to @code{__builtin_popcount}, except the argument type is
11328 @code{unsigned long long}.
11329 @end deftypefn
11330
11331 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11332 Similar to @code{__builtin_parity}, except the argument type is
11333 @code{unsigned long long}.
11334 @end deftypefn
11335
11336 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11337 Returns the first argument raised to the power of the second. Unlike the
11338 @code{pow} function no guarantees about precision and rounding are made.
11339 @end deftypefn
11340
11341 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11342 Similar to @code{__builtin_powi}, except the argument and return types
11343 are @code{float}.
11344 @end deftypefn
11345
11346 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11347 Similar to @code{__builtin_powi}, except the argument and return types
11348 are @code{long double}.
11349 @end deftypefn
11350
11351 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11352 Returns @var{x} with the order of the bytes reversed; for example,
11353 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11354 exactly 8 bits.
11355 @end deftypefn
11356
11357 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11358 Similar to @code{__builtin_bswap16}, except the argument and return types
11359 are 32 bit.
11360 @end deftypefn
11361
11362 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11363 Similar to @code{__builtin_bswap32}, except the argument and return types
11364 are 64 bit.
11365 @end deftypefn
11366
11367 @node Target Builtins
11368 @section Built-in Functions Specific to Particular Target Machines
11369
11370 On some target machines, GCC supports many built-in functions specific
11371 to those machines. Generally these generate calls to specific machine
11372 instructions, but allow the compiler to schedule those calls.
11373
11374 @menu
11375 * AArch64 Built-in Functions::
11376 * Alpha Built-in Functions::
11377 * Altera Nios II Built-in Functions::
11378 * ARC Built-in Functions::
11379 * ARC SIMD Built-in Functions::
11380 * ARM iWMMXt Built-in Functions::
11381 * ARM C Language Extensions (ACLE)::
11382 * ARM Floating Point Status and Control Intrinsics::
11383 * AVR Built-in Functions::
11384 * Blackfin Built-in Functions::
11385 * FR-V Built-in Functions::
11386 * MIPS DSP Built-in Functions::
11387 * MIPS Paired-Single Support::
11388 * MIPS Loongson Built-in Functions::
11389 * Other MIPS Built-in Functions::
11390 * MSP430 Built-in Functions::
11391 * NDS32 Built-in Functions::
11392 * picoChip Built-in Functions::
11393 * PowerPC Built-in Functions::
11394 * PowerPC AltiVec/VSX Built-in Functions::
11395 * PowerPC Hardware Transactional Memory Built-in Functions::
11396 * RX Built-in Functions::
11397 * S/390 System z Built-in Functions::
11398 * SH Built-in Functions::
11399 * SPARC VIS Built-in Functions::
11400 * SPU Built-in Functions::
11401 * TI C6X Built-in Functions::
11402 * TILE-Gx Built-in Functions::
11403 * TILEPro Built-in Functions::
11404 * x86 Built-in Functions::
11405 * x86 transactional memory intrinsics::
11406 @end menu
11407
11408 @node AArch64 Built-in Functions
11409 @subsection AArch64 Built-in Functions
11410
11411 These built-in functions are available for the AArch64 family of
11412 processors.
11413 @smallexample
11414 unsigned int __builtin_aarch64_get_fpcr ()
11415 void __builtin_aarch64_set_fpcr (unsigned int)
11416 unsigned int __builtin_aarch64_get_fpsr ()
11417 void __builtin_aarch64_set_fpsr (unsigned int)
11418 @end smallexample
11419
11420 @node Alpha Built-in Functions
11421 @subsection Alpha Built-in Functions
11422
11423 These built-in functions are available for the Alpha family of
11424 processors, depending on the command-line switches used.
11425
11426 The following built-in functions are always available. They
11427 all generate the machine instruction that is part of the name.
11428
11429 @smallexample
11430 long __builtin_alpha_implver (void)
11431 long __builtin_alpha_rpcc (void)
11432 long __builtin_alpha_amask (long)
11433 long __builtin_alpha_cmpbge (long, long)
11434 long __builtin_alpha_extbl (long, long)
11435 long __builtin_alpha_extwl (long, long)
11436 long __builtin_alpha_extll (long, long)
11437 long __builtin_alpha_extql (long, long)
11438 long __builtin_alpha_extwh (long, long)
11439 long __builtin_alpha_extlh (long, long)
11440 long __builtin_alpha_extqh (long, long)
11441 long __builtin_alpha_insbl (long, long)
11442 long __builtin_alpha_inswl (long, long)
11443 long __builtin_alpha_insll (long, long)
11444 long __builtin_alpha_insql (long, long)
11445 long __builtin_alpha_inswh (long, long)
11446 long __builtin_alpha_inslh (long, long)
11447 long __builtin_alpha_insqh (long, long)
11448 long __builtin_alpha_mskbl (long, long)
11449 long __builtin_alpha_mskwl (long, long)
11450 long __builtin_alpha_mskll (long, long)
11451 long __builtin_alpha_mskql (long, long)
11452 long __builtin_alpha_mskwh (long, long)
11453 long __builtin_alpha_msklh (long, long)
11454 long __builtin_alpha_mskqh (long, long)
11455 long __builtin_alpha_umulh (long, long)
11456 long __builtin_alpha_zap (long, long)
11457 long __builtin_alpha_zapnot (long, long)
11458 @end smallexample
11459
11460 The following built-in functions are always with @option{-mmax}
11461 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11462 later. They all generate the machine instruction that is part
11463 of the name.
11464
11465 @smallexample
11466 long __builtin_alpha_pklb (long)
11467 long __builtin_alpha_pkwb (long)
11468 long __builtin_alpha_unpkbl (long)
11469 long __builtin_alpha_unpkbw (long)
11470 long __builtin_alpha_minub8 (long, long)
11471 long __builtin_alpha_minsb8 (long, long)
11472 long __builtin_alpha_minuw4 (long, long)
11473 long __builtin_alpha_minsw4 (long, long)
11474 long __builtin_alpha_maxub8 (long, long)
11475 long __builtin_alpha_maxsb8 (long, long)
11476 long __builtin_alpha_maxuw4 (long, long)
11477 long __builtin_alpha_maxsw4 (long, long)
11478 long __builtin_alpha_perr (long, long)
11479 @end smallexample
11480
11481 The following built-in functions are always with @option{-mcix}
11482 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11483 later. They all generate the machine instruction that is part
11484 of the name.
11485
11486 @smallexample
11487 long __builtin_alpha_cttz (long)
11488 long __builtin_alpha_ctlz (long)
11489 long __builtin_alpha_ctpop (long)
11490 @end smallexample
11491
11492 The following built-in functions are available on systems that use the OSF/1
11493 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11494 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11495 @code{rdval} and @code{wrval}.
11496
11497 @smallexample
11498 void *__builtin_thread_pointer (void)
11499 void __builtin_set_thread_pointer (void *)
11500 @end smallexample
11501
11502 @node Altera Nios II Built-in Functions
11503 @subsection Altera Nios II Built-in Functions
11504
11505 These built-in functions are available for the Altera Nios II
11506 family of processors.
11507
11508 The following built-in functions are always available. They
11509 all generate the machine instruction that is part of the name.
11510
11511 @example
11512 int __builtin_ldbio (volatile const void *)
11513 int __builtin_ldbuio (volatile const void *)
11514 int __builtin_ldhio (volatile const void *)
11515 int __builtin_ldhuio (volatile const void *)
11516 int __builtin_ldwio (volatile const void *)
11517 void __builtin_stbio (volatile void *, int)
11518 void __builtin_sthio (volatile void *, int)
11519 void __builtin_stwio (volatile void *, int)
11520 void __builtin_sync (void)
11521 int __builtin_rdctl (int)
11522 int __builtin_rdprs (int, int)
11523 void __builtin_wrctl (int, int)
11524 void __builtin_flushd (volatile void *)
11525 void __builtin_flushda (volatile void *)
11526 int __builtin_wrpie (int);
11527 void __builtin_eni (int);
11528 int __builtin_ldex (volatile const void *)
11529 int __builtin_stex (volatile void *, int)
11530 int __builtin_ldsex (volatile const void *)
11531 int __builtin_stsex (volatile void *, int)
11532 @end example
11533
11534 The following built-in functions are always available. They
11535 all generate a Nios II Custom Instruction. The name of the
11536 function represents the types that the function takes and
11537 returns. The letter before the @code{n} is the return type
11538 or void if absent. The @code{n} represents the first parameter
11539 to all the custom instructions, the custom instruction number.
11540 The two letters after the @code{n} represent the up to two
11541 parameters to the function.
11542
11543 The letters represent the following data types:
11544 @table @code
11545 @item <no letter>
11546 @code{void} for return type and no parameter for parameter types.
11547
11548 @item i
11549 @code{int} for return type and parameter type
11550
11551 @item f
11552 @code{float} for return type and parameter type
11553
11554 @item p
11555 @code{void *} for return type and parameter type
11556
11557 @end table
11558
11559 And the function names are:
11560 @example
11561 void __builtin_custom_n (void)
11562 void __builtin_custom_ni (int)
11563 void __builtin_custom_nf (float)
11564 void __builtin_custom_np (void *)
11565 void __builtin_custom_nii (int, int)
11566 void __builtin_custom_nif (int, float)
11567 void __builtin_custom_nip (int, void *)
11568 void __builtin_custom_nfi (float, int)
11569 void __builtin_custom_nff (float, float)
11570 void __builtin_custom_nfp (float, void *)
11571 void __builtin_custom_npi (void *, int)
11572 void __builtin_custom_npf (void *, float)
11573 void __builtin_custom_npp (void *, void *)
11574 int __builtin_custom_in (void)
11575 int __builtin_custom_ini (int)
11576 int __builtin_custom_inf (float)
11577 int __builtin_custom_inp (void *)
11578 int __builtin_custom_inii (int, int)
11579 int __builtin_custom_inif (int, float)
11580 int __builtin_custom_inip (int, void *)
11581 int __builtin_custom_infi (float, int)
11582 int __builtin_custom_inff (float, float)
11583 int __builtin_custom_infp (float, void *)
11584 int __builtin_custom_inpi (void *, int)
11585 int __builtin_custom_inpf (void *, float)
11586 int __builtin_custom_inpp (void *, void *)
11587 float __builtin_custom_fn (void)
11588 float __builtin_custom_fni (int)
11589 float __builtin_custom_fnf (float)
11590 float __builtin_custom_fnp (void *)
11591 float __builtin_custom_fnii (int, int)
11592 float __builtin_custom_fnif (int, float)
11593 float __builtin_custom_fnip (int, void *)
11594 float __builtin_custom_fnfi (float, int)
11595 float __builtin_custom_fnff (float, float)
11596 float __builtin_custom_fnfp (float, void *)
11597 float __builtin_custom_fnpi (void *, int)
11598 float __builtin_custom_fnpf (void *, float)
11599 float __builtin_custom_fnpp (void *, void *)
11600 void * __builtin_custom_pn (void)
11601 void * __builtin_custom_pni (int)
11602 void * __builtin_custom_pnf (float)
11603 void * __builtin_custom_pnp (void *)
11604 void * __builtin_custom_pnii (int, int)
11605 void * __builtin_custom_pnif (int, float)
11606 void * __builtin_custom_pnip (int, void *)
11607 void * __builtin_custom_pnfi (float, int)
11608 void * __builtin_custom_pnff (float, float)
11609 void * __builtin_custom_pnfp (float, void *)
11610 void * __builtin_custom_pnpi (void *, int)
11611 void * __builtin_custom_pnpf (void *, float)
11612 void * __builtin_custom_pnpp (void *, void *)
11613 @end example
11614
11615 @node ARC Built-in Functions
11616 @subsection ARC Built-in Functions
11617
11618 The following built-in functions are provided for ARC targets. The
11619 built-ins generate the corresponding assembly instructions. In the
11620 examples given below, the generated code often requires an operand or
11621 result to be in a register. Where necessary further code will be
11622 generated to ensure this is true, but for brevity this is not
11623 described in each case.
11624
11625 @emph{Note:} Using a built-in to generate an instruction not supported
11626 by a target may cause problems. At present the compiler is not
11627 guaranteed to detect such misuse, and as a result an internal compiler
11628 error may be generated.
11629
11630 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11631 Return 1 if @var{val} is known to have the byte alignment given
11632 by @var{alignval}, otherwise return 0.
11633 Note that this is different from
11634 @smallexample
11635 __alignof__(*(char *)@var{val}) >= alignval
11636 @end smallexample
11637 because __alignof__ sees only the type of the dereference, whereas
11638 __builtin_arc_align uses alignment information from the pointer
11639 as well as from the pointed-to type.
11640 The information available will depend on optimization level.
11641 @end deftypefn
11642
11643 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11644 Generates
11645 @example
11646 brk
11647 @end example
11648 @end deftypefn
11649
11650 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11651 The operand is the number of a register to be read. Generates:
11652 @example
11653 mov @var{dest}, r@var{regno}
11654 @end example
11655 where the value in @var{dest} will be the result returned from the
11656 built-in.
11657 @end deftypefn
11658
11659 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11660 The first operand is the number of a register to be written, the
11661 second operand is a compile time constant to write into that
11662 register. Generates:
11663 @example
11664 mov r@var{regno}, @var{val}
11665 @end example
11666 @end deftypefn
11667
11668 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11669 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11670 Generates:
11671 @example
11672 divaw @var{dest}, @var{a}, @var{b}
11673 @end example
11674 where the value in @var{dest} will be the result returned from the
11675 built-in.
11676 @end deftypefn
11677
11678 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11679 Generates
11680 @example
11681 flag @var{a}
11682 @end example
11683 @end deftypefn
11684
11685 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11686 The operand, @var{auxv}, is the address of an auxiliary register and
11687 must be a compile time constant. Generates:
11688 @example
11689 lr @var{dest}, [@var{auxr}]
11690 @end example
11691 Where the value in @var{dest} will be the result returned from the
11692 built-in.
11693 @end deftypefn
11694
11695 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11696 Only available with @option{-mmul64}. Generates:
11697 @example
11698 mul64 @var{a}, @var{b}
11699 @end example
11700 @end deftypefn
11701
11702 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11703 Only available with @option{-mmul64}. Generates:
11704 @example
11705 mulu64 @var{a}, @var{b}
11706 @end example
11707 @end deftypefn
11708
11709 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11710 Generates:
11711 @example
11712 nop
11713 @end example
11714 @end deftypefn
11715
11716 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11717 Only valid if the @samp{norm} instruction is available through the
11718 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11719 Generates:
11720 @example
11721 norm @var{dest}, @var{src}
11722 @end example
11723 Where the value in @var{dest} will be the result returned from the
11724 built-in.
11725 @end deftypefn
11726
11727 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11728 Only valid if the @samp{normw} instruction is available through the
11729 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11730 Generates:
11731 @example
11732 normw @var{dest}, @var{src}
11733 @end example
11734 Where the value in @var{dest} will be the result returned from the
11735 built-in.
11736 @end deftypefn
11737
11738 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11739 Generates:
11740 @example
11741 rtie
11742 @end example
11743 @end deftypefn
11744
11745 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11746 Generates:
11747 @example
11748 sleep @var{a}
11749 @end example
11750 @end deftypefn
11751
11752 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11753 The first argument, @var{auxv}, is the address of an auxiliary
11754 register, the second argument, @var{val}, is a compile time constant
11755 to be written to the register. Generates:
11756 @example
11757 sr @var{auxr}, [@var{val}]
11758 @end example
11759 @end deftypefn
11760
11761 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11762 Only valid with @option{-mswap}. Generates:
11763 @example
11764 swap @var{dest}, @var{src}
11765 @end example
11766 Where the value in @var{dest} will be the result returned from the
11767 built-in.
11768 @end deftypefn
11769
11770 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11771 Generates:
11772 @example
11773 swi
11774 @end example
11775 @end deftypefn
11776
11777 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11778 Only available with @option{-mcpu=ARC700}. Generates:
11779 @example
11780 sync
11781 @end example
11782 @end deftypefn
11783
11784 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11785 Only available with @option{-mcpu=ARC700}. Generates:
11786 @example
11787 trap_s @var{c}
11788 @end example
11789 @end deftypefn
11790
11791 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11792 Only available with @option{-mcpu=ARC700}. Generates:
11793 @example
11794 unimp_s
11795 @end example
11796 @end deftypefn
11797
11798 The instructions generated by the following builtins are not
11799 considered as candidates for scheduling. They are not moved around by
11800 the compiler during scheduling, and thus can be expected to appear
11801 where they are put in the C code:
11802 @example
11803 __builtin_arc_brk()
11804 __builtin_arc_core_read()
11805 __builtin_arc_core_write()
11806 __builtin_arc_flag()
11807 __builtin_arc_lr()
11808 __builtin_arc_sleep()
11809 __builtin_arc_sr()
11810 __builtin_arc_swi()
11811 @end example
11812
11813 @node ARC SIMD Built-in Functions
11814 @subsection ARC SIMD Built-in Functions
11815
11816 SIMD builtins provided by the compiler can be used to generate the
11817 vector instructions. This section describes the available builtins
11818 and their usage in programs. With the @option{-msimd} option, the
11819 compiler provides 128-bit vector types, which can be specified using
11820 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11821 can be included to use the following predefined types:
11822 @example
11823 typedef int __v4si __attribute__((vector_size(16)));
11824 typedef short __v8hi __attribute__((vector_size(16)));
11825 @end example
11826
11827 These types can be used to define 128-bit variables. The built-in
11828 functions listed in the following section can be used on these
11829 variables to generate the vector operations.
11830
11831 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11832 @file{arc-simd.h} also provides equivalent macros called
11833 @code{_@var{someinsn}} that can be used for programming ease and
11834 improved readability. The following macros for DMA control are also
11835 provided:
11836 @example
11837 #define _setup_dma_in_channel_reg _vdiwr
11838 #define _setup_dma_out_channel_reg _vdowr
11839 @end example
11840
11841 The following is a complete list of all the SIMD built-ins provided
11842 for ARC, grouped by calling signature.
11843
11844 The following take two @code{__v8hi} arguments and return a
11845 @code{__v8hi} result:
11846 @example
11847 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11848 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11849 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11850 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11851 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11852 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11853 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11854 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11855 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11856 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11857 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11858 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11859 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11860 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11861 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11862 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11863 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11864 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11865 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11866 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11867 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11868 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11869 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11870 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11871 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11872 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11873 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11874 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11875 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11876 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11877 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11878 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11879 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11880 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11881 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11882 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11883 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11884 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11885 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11886 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11887 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11888 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11889 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11890 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11891 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11892 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11893 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11894 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11895 @end example
11896
11897 The following take one @code{__v8hi} and one @code{int} argument and return a
11898 @code{__v8hi} result:
11899
11900 @example
11901 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11902 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11903 __v8hi __builtin_arc_vbminw (__v8hi, int)
11904 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11905 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11906 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11907 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11908 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11909 @end example
11910
11911 The following take one @code{__v8hi} argument and one @code{int} argument which
11912 must be a 3-bit compile time constant indicating a register number
11913 I0-I7. They return a @code{__v8hi} result.
11914 @example
11915 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11916 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11917 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11918 @end example
11919
11920 The following take one @code{__v8hi} argument and one @code{int}
11921 argument which must be a 6-bit compile time constant. They return a
11922 @code{__v8hi} result.
11923 @example
11924 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11925 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11926 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11927 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11928 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11929 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11930 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11931 @end example
11932
11933 The following take one @code{__v8hi} argument and one @code{int} argument which
11934 must be a 8-bit compile time constant. They return a @code{__v8hi}
11935 result.
11936 @example
11937 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11938 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11939 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11940 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11941 @end example
11942
11943 The following take two @code{int} arguments, the second of which which
11944 must be a 8-bit compile time constant. They return a @code{__v8hi}
11945 result:
11946 @example
11947 __v8hi __builtin_arc_vmovaw (int, const int)
11948 __v8hi __builtin_arc_vmovw (int, const int)
11949 __v8hi __builtin_arc_vmovzw (int, const int)
11950 @end example
11951
11952 The following take a single @code{__v8hi} argument and return a
11953 @code{__v8hi} result:
11954 @example
11955 __v8hi __builtin_arc_vabsaw (__v8hi)
11956 __v8hi __builtin_arc_vabsw (__v8hi)
11957 __v8hi __builtin_arc_vaddsuw (__v8hi)
11958 __v8hi __builtin_arc_vexch1 (__v8hi)
11959 __v8hi __builtin_arc_vexch2 (__v8hi)
11960 __v8hi __builtin_arc_vexch4 (__v8hi)
11961 __v8hi __builtin_arc_vsignw (__v8hi)
11962 __v8hi __builtin_arc_vupbaw (__v8hi)
11963 __v8hi __builtin_arc_vupbw (__v8hi)
11964 __v8hi __builtin_arc_vupsbaw (__v8hi)
11965 __v8hi __builtin_arc_vupsbw (__v8hi)
11966 @end example
11967
11968 The following take two @code{int} arguments and return no result:
11969 @example
11970 void __builtin_arc_vdirun (int, int)
11971 void __builtin_arc_vdorun (int, int)
11972 @end example
11973
11974 The following take two @code{int} arguments and return no result. The
11975 first argument must a 3-bit compile time constant indicating one of
11976 the DR0-DR7 DMA setup channels:
11977 @example
11978 void __builtin_arc_vdiwr (const int, int)
11979 void __builtin_arc_vdowr (const int, int)
11980 @end example
11981
11982 The following take an @code{int} argument and return no result:
11983 @example
11984 void __builtin_arc_vendrec (int)
11985 void __builtin_arc_vrec (int)
11986 void __builtin_arc_vrecrun (int)
11987 void __builtin_arc_vrun (int)
11988 @end example
11989
11990 The following take a @code{__v8hi} argument and two @code{int}
11991 arguments and return a @code{__v8hi} result. The second argument must
11992 be a 3-bit compile time constants, indicating one the registers I0-I7,
11993 and the third argument must be an 8-bit compile time constant.
11994
11995 @emph{Note:} Although the equivalent hardware instructions do not take
11996 an SIMD register as an operand, these builtins overwrite the relevant
11997 bits of the @code{__v8hi} register provided as the first argument with
11998 the value loaded from the @code{[Ib, u8]} location in the SDM.
11999
12000 @example
12001 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
12002 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
12003 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
12004 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
12005 @end example
12006
12007 The following take two @code{int} arguments and return a @code{__v8hi}
12008 result. The first argument must be a 3-bit compile time constants,
12009 indicating one the registers I0-I7, and the second argument must be an
12010 8-bit compile time constant.
12011
12012 @example
12013 __v8hi __builtin_arc_vld128 (const int, const int)
12014 __v8hi __builtin_arc_vld64w (const int, const int)
12015 @end example
12016
12017 The following take a @code{__v8hi} argument and two @code{int}
12018 arguments and return no result. The second argument must be a 3-bit
12019 compile time constants, indicating one the registers I0-I7, and the
12020 third argument must be an 8-bit compile time constant.
12021
12022 @example
12023 void __builtin_arc_vst128 (__v8hi, const int, const int)
12024 void __builtin_arc_vst64 (__v8hi, const int, const int)
12025 @end example
12026
12027 The following take a @code{__v8hi} argument and three @code{int}
12028 arguments and return no result. The second argument must be a 3-bit
12029 compile-time constant, identifying the 16-bit sub-register to be
12030 stored, the third argument must be a 3-bit compile time constants,
12031 indicating one the registers I0-I7, and the fourth argument must be an
12032 8-bit compile time constant.
12033
12034 @example
12035 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
12036 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
12037 @end example
12038
12039 @node ARM iWMMXt Built-in Functions
12040 @subsection ARM iWMMXt Built-in Functions
12041
12042 These built-in functions are available for the ARM family of
12043 processors when the @option{-mcpu=iwmmxt} switch is used:
12044
12045 @smallexample
12046 typedef int v2si __attribute__ ((vector_size (8)));
12047 typedef short v4hi __attribute__ ((vector_size (8)));
12048 typedef char v8qi __attribute__ ((vector_size (8)));
12049
12050 int __builtin_arm_getwcgr0 (void)
12051 void __builtin_arm_setwcgr0 (int)
12052 int __builtin_arm_getwcgr1 (void)
12053 void __builtin_arm_setwcgr1 (int)
12054 int __builtin_arm_getwcgr2 (void)
12055 void __builtin_arm_setwcgr2 (int)
12056 int __builtin_arm_getwcgr3 (void)
12057 void __builtin_arm_setwcgr3 (int)
12058 int __builtin_arm_textrmsb (v8qi, int)
12059 int __builtin_arm_textrmsh (v4hi, int)
12060 int __builtin_arm_textrmsw (v2si, int)
12061 int __builtin_arm_textrmub (v8qi, int)
12062 int __builtin_arm_textrmuh (v4hi, int)
12063 int __builtin_arm_textrmuw (v2si, int)
12064 v8qi __builtin_arm_tinsrb (v8qi, int, int)
12065 v4hi __builtin_arm_tinsrh (v4hi, int, int)
12066 v2si __builtin_arm_tinsrw (v2si, int, int)
12067 long long __builtin_arm_tmia (long long, int, int)
12068 long long __builtin_arm_tmiabb (long long, int, int)
12069 long long __builtin_arm_tmiabt (long long, int, int)
12070 long long __builtin_arm_tmiaph (long long, int, int)
12071 long long __builtin_arm_tmiatb (long long, int, int)
12072 long long __builtin_arm_tmiatt (long long, int, int)
12073 int __builtin_arm_tmovmskb (v8qi)
12074 int __builtin_arm_tmovmskh (v4hi)
12075 int __builtin_arm_tmovmskw (v2si)
12076 long long __builtin_arm_waccb (v8qi)
12077 long long __builtin_arm_wacch (v4hi)
12078 long long __builtin_arm_waccw (v2si)
12079 v8qi __builtin_arm_waddb (v8qi, v8qi)
12080 v8qi __builtin_arm_waddbss (v8qi, v8qi)
12081 v8qi __builtin_arm_waddbus (v8qi, v8qi)
12082 v4hi __builtin_arm_waddh (v4hi, v4hi)
12083 v4hi __builtin_arm_waddhss (v4hi, v4hi)
12084 v4hi __builtin_arm_waddhus (v4hi, v4hi)
12085 v2si __builtin_arm_waddw (v2si, v2si)
12086 v2si __builtin_arm_waddwss (v2si, v2si)
12087 v2si __builtin_arm_waddwus (v2si, v2si)
12088 v8qi __builtin_arm_walign (v8qi, v8qi, int)
12089 long long __builtin_arm_wand(long long, long long)
12090 long long __builtin_arm_wandn (long long, long long)
12091 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
12092 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
12093 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
12094 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
12095 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12096 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12097 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12098 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12099 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12100 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12101 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12102 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12103 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12104 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12105 long long __builtin_arm_wmacsz (v4hi, v4hi)
12106 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12107 long long __builtin_arm_wmacuz (v4hi, v4hi)
12108 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12109 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12110 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12111 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12112 v2si __builtin_arm_wmaxsw (v2si, v2si)
12113 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12114 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12115 v2si __builtin_arm_wmaxuw (v2si, v2si)
12116 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12117 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12118 v2si __builtin_arm_wminsw (v2si, v2si)
12119 v8qi __builtin_arm_wminub (v8qi, v8qi)
12120 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12121 v2si __builtin_arm_wminuw (v2si, v2si)
12122 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12123 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12124 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12125 long long __builtin_arm_wor (long long, long long)
12126 v2si __builtin_arm_wpackdss (long long, long long)
12127 v2si __builtin_arm_wpackdus (long long, long long)
12128 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12129 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12130 v4hi __builtin_arm_wpackwss (v2si, v2si)
12131 v4hi __builtin_arm_wpackwus (v2si, v2si)
12132 long long __builtin_arm_wrord (long long, long long)
12133 long long __builtin_arm_wrordi (long long, int)
12134 v4hi __builtin_arm_wrorh (v4hi, long long)
12135 v4hi __builtin_arm_wrorhi (v4hi, int)
12136 v2si __builtin_arm_wrorw (v2si, long long)
12137 v2si __builtin_arm_wrorwi (v2si, int)
12138 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12139 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12140 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12141 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12142 v4hi __builtin_arm_wshufh (v4hi, int)
12143 long long __builtin_arm_wslld (long long, long long)
12144 long long __builtin_arm_wslldi (long long, int)
12145 v4hi __builtin_arm_wsllh (v4hi, long long)
12146 v4hi __builtin_arm_wsllhi (v4hi, int)
12147 v2si __builtin_arm_wsllw (v2si, long long)
12148 v2si __builtin_arm_wsllwi (v2si, int)
12149 long long __builtin_arm_wsrad (long long, long long)
12150 long long __builtin_arm_wsradi (long long, int)
12151 v4hi __builtin_arm_wsrah (v4hi, long long)
12152 v4hi __builtin_arm_wsrahi (v4hi, int)
12153 v2si __builtin_arm_wsraw (v2si, long long)
12154 v2si __builtin_arm_wsrawi (v2si, int)
12155 long long __builtin_arm_wsrld (long long, long long)
12156 long long __builtin_arm_wsrldi (long long, int)
12157 v4hi __builtin_arm_wsrlh (v4hi, long long)
12158 v4hi __builtin_arm_wsrlhi (v4hi, int)
12159 v2si __builtin_arm_wsrlw (v2si, long long)
12160 v2si __builtin_arm_wsrlwi (v2si, int)
12161 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12162 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12163 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12164 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12165 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12166 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12167 v2si __builtin_arm_wsubw (v2si, v2si)
12168 v2si __builtin_arm_wsubwss (v2si, v2si)
12169 v2si __builtin_arm_wsubwus (v2si, v2si)
12170 v4hi __builtin_arm_wunpckehsb (v8qi)
12171 v2si __builtin_arm_wunpckehsh (v4hi)
12172 long long __builtin_arm_wunpckehsw (v2si)
12173 v4hi __builtin_arm_wunpckehub (v8qi)
12174 v2si __builtin_arm_wunpckehuh (v4hi)
12175 long long __builtin_arm_wunpckehuw (v2si)
12176 v4hi __builtin_arm_wunpckelsb (v8qi)
12177 v2si __builtin_arm_wunpckelsh (v4hi)
12178 long long __builtin_arm_wunpckelsw (v2si)
12179 v4hi __builtin_arm_wunpckelub (v8qi)
12180 v2si __builtin_arm_wunpckeluh (v4hi)
12181 long long __builtin_arm_wunpckeluw (v2si)
12182 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12183 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12184 v2si __builtin_arm_wunpckihw (v2si, v2si)
12185 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12186 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12187 v2si __builtin_arm_wunpckilw (v2si, v2si)
12188 long long __builtin_arm_wxor (long long, long long)
12189 long long __builtin_arm_wzero ()
12190 @end smallexample
12191
12192
12193 @node ARM C Language Extensions (ACLE)
12194 @subsection ARM C Language Extensions (ACLE)
12195
12196 GCC implements extensions for C as described in the ARM C Language
12197 Extensions (ACLE) specification, which can be found at
12198 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12199
12200 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12201 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12202 intrinsics can be found at
12203 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12204 The built-in intrinsics for the Advanced SIMD extension are available when
12205 NEON is enabled.
12206
12207 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12208 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12209 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12210 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12211 intrinsics yet.
12212
12213 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12214 availability of extensions.
12215
12216 @node ARM Floating Point Status and Control Intrinsics
12217 @subsection ARM Floating Point Status and Control Intrinsics
12218
12219 These built-in functions are available for the ARM family of
12220 processors with floating-point unit.
12221
12222 @smallexample
12223 unsigned int __builtin_arm_get_fpscr ()
12224 void __builtin_arm_set_fpscr (unsigned int)
12225 @end smallexample
12226
12227 @node AVR Built-in Functions
12228 @subsection AVR Built-in Functions
12229
12230 For each built-in function for AVR, there is an equally named,
12231 uppercase built-in macro defined. That way users can easily query if
12232 or if not a specific built-in is implemented or not. For example, if
12233 @code{__builtin_avr_nop} is available the macro
12234 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12235
12236 The following built-in functions map to the respective machine
12237 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12238 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12239 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12240 as library call if no hardware multiplier is available.
12241
12242 @smallexample
12243 void __builtin_avr_nop (void)
12244 void __builtin_avr_sei (void)
12245 void __builtin_avr_cli (void)
12246 void __builtin_avr_sleep (void)
12247 void __builtin_avr_wdr (void)
12248 unsigned char __builtin_avr_swap (unsigned char)
12249 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12250 int __builtin_avr_fmuls (char, char)
12251 int __builtin_avr_fmulsu (char, unsigned char)
12252 @end smallexample
12253
12254 In order to delay execution for a specific number of cycles, GCC
12255 implements
12256 @smallexample
12257 void __builtin_avr_delay_cycles (unsigned long ticks)
12258 @end smallexample
12259
12260 @noindent
12261 @code{ticks} is the number of ticks to delay execution. Note that this
12262 built-in does not take into account the effect of interrupts that
12263 might increase delay time. @code{ticks} must be a compile-time
12264 integer constant; delays with a variable number of cycles are not supported.
12265
12266 @smallexample
12267 char __builtin_avr_flash_segment (const __memx void*)
12268 @end smallexample
12269
12270 @noindent
12271 This built-in takes a byte address to the 24-bit
12272 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12273 the number of the flash segment (the 64 KiB chunk) where the address
12274 points to. Counting starts at @code{0}.
12275 If the address does not point to flash memory, return @code{-1}.
12276
12277 @smallexample
12278 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12279 @end smallexample
12280
12281 @noindent
12282 Insert bits from @var{bits} into @var{val} and return the resulting
12283 value. The nibbles of @var{map} determine how the insertion is
12284 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12285 @enumerate
12286 @item If @var{X} is @code{0xf},
12287 then the @var{n}-th bit of @var{val} is returned unaltered.
12288
12289 @item If X is in the range 0@dots{}7,
12290 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12291
12292 @item If X is in the range 8@dots{}@code{0xe},
12293 then the @var{n}-th result bit is undefined.
12294 @end enumerate
12295
12296 @noindent
12297 One typical use case for this built-in is adjusting input and
12298 output values to non-contiguous port layouts. Some examples:
12299
12300 @smallexample
12301 // same as val, bits is unused
12302 __builtin_avr_insert_bits (0xffffffff, bits, val)
12303 @end smallexample
12304
12305 @smallexample
12306 // same as bits, val is unused
12307 __builtin_avr_insert_bits (0x76543210, bits, val)
12308 @end smallexample
12309
12310 @smallexample
12311 // same as rotating bits by 4
12312 __builtin_avr_insert_bits (0x32107654, bits, 0)
12313 @end smallexample
12314
12315 @smallexample
12316 // high nibble of result is the high nibble of val
12317 // low nibble of result is the low nibble of bits
12318 __builtin_avr_insert_bits (0xffff3210, bits, val)
12319 @end smallexample
12320
12321 @smallexample
12322 // reverse the bit order of bits
12323 __builtin_avr_insert_bits (0x01234567, bits, 0)
12324 @end smallexample
12325
12326 @node Blackfin Built-in Functions
12327 @subsection Blackfin Built-in Functions
12328
12329 Currently, there are two Blackfin-specific built-in functions. These are
12330 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12331 using inline assembly; by using these built-in functions the compiler can
12332 automatically add workarounds for hardware errata involving these
12333 instructions. These functions are named as follows:
12334
12335 @smallexample
12336 void __builtin_bfin_csync (void)
12337 void __builtin_bfin_ssync (void)
12338 @end smallexample
12339
12340 @node FR-V Built-in Functions
12341 @subsection FR-V Built-in Functions
12342
12343 GCC provides many FR-V-specific built-in functions. In general,
12344 these functions are intended to be compatible with those described
12345 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12346 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12347 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12348 pointer rather than by value.
12349
12350 Most of the functions are named after specific FR-V instructions.
12351 Such functions are said to be ``directly mapped'' and are summarized
12352 here in tabular form.
12353
12354 @menu
12355 * Argument Types::
12356 * Directly-mapped Integer Functions::
12357 * Directly-mapped Media Functions::
12358 * Raw read/write Functions::
12359 * Other Built-in Functions::
12360 @end menu
12361
12362 @node Argument Types
12363 @subsubsection Argument Types
12364
12365 The arguments to the built-in functions can be divided into three groups:
12366 register numbers, compile-time constants and run-time values. In order
12367 to make this classification clear at a glance, the arguments and return
12368 values are given the following pseudo types:
12369
12370 @multitable @columnfractions .20 .30 .15 .35
12371 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12372 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12373 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12374 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12375 @item @code{uw2} @tab @code{unsigned long long} @tab No
12376 @tab an unsigned doubleword
12377 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12378 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12379 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12380 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12381 @end multitable
12382
12383 These pseudo types are not defined by GCC, they are simply a notational
12384 convenience used in this manual.
12385
12386 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12387 and @code{sw2} are evaluated at run time. They correspond to
12388 register operands in the underlying FR-V instructions.
12389
12390 @code{const} arguments represent immediate operands in the underlying
12391 FR-V instructions. They must be compile-time constants.
12392
12393 @code{acc} arguments are evaluated at compile time and specify the number
12394 of an accumulator register. For example, an @code{acc} argument of 2
12395 selects the ACC2 register.
12396
12397 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12398 number of an IACC register. See @pxref{Other Built-in Functions}
12399 for more details.
12400
12401 @node Directly-mapped Integer Functions
12402 @subsubsection Directly-Mapped Integer Functions
12403
12404 The functions listed below map directly to FR-V I-type instructions.
12405
12406 @multitable @columnfractions .45 .32 .23
12407 @item Function prototype @tab Example usage @tab Assembly output
12408 @item @code{sw1 __ADDSS (sw1, sw1)}
12409 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12410 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12411 @item @code{sw1 __SCAN (sw1, sw1)}
12412 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12413 @tab @code{SCAN @var{a},@var{b},@var{c}}
12414 @item @code{sw1 __SCUTSS (sw1)}
12415 @tab @code{@var{b} = __SCUTSS (@var{a})}
12416 @tab @code{SCUTSS @var{a},@var{b}}
12417 @item @code{sw1 __SLASS (sw1, sw1)}
12418 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12419 @tab @code{SLASS @var{a},@var{b},@var{c}}
12420 @item @code{void __SMASS (sw1, sw1)}
12421 @tab @code{__SMASS (@var{a}, @var{b})}
12422 @tab @code{SMASS @var{a},@var{b}}
12423 @item @code{void __SMSSS (sw1, sw1)}
12424 @tab @code{__SMSSS (@var{a}, @var{b})}
12425 @tab @code{SMSSS @var{a},@var{b}}
12426 @item @code{void __SMU (sw1, sw1)}
12427 @tab @code{__SMU (@var{a}, @var{b})}
12428 @tab @code{SMU @var{a},@var{b}}
12429 @item @code{sw2 __SMUL (sw1, sw1)}
12430 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12431 @tab @code{SMUL @var{a},@var{b},@var{c}}
12432 @item @code{sw1 __SUBSS (sw1, sw1)}
12433 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12434 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12435 @item @code{uw2 __UMUL (uw1, uw1)}
12436 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12437 @tab @code{UMUL @var{a},@var{b},@var{c}}
12438 @end multitable
12439
12440 @node Directly-mapped Media Functions
12441 @subsubsection Directly-Mapped Media Functions
12442
12443 The functions listed below map directly to FR-V M-type instructions.
12444
12445 @multitable @columnfractions .45 .32 .23
12446 @item Function prototype @tab Example usage @tab Assembly output
12447 @item @code{uw1 __MABSHS (sw1)}
12448 @tab @code{@var{b} = __MABSHS (@var{a})}
12449 @tab @code{MABSHS @var{a},@var{b}}
12450 @item @code{void __MADDACCS (acc, acc)}
12451 @tab @code{__MADDACCS (@var{b}, @var{a})}
12452 @tab @code{MADDACCS @var{a},@var{b}}
12453 @item @code{sw1 __MADDHSS (sw1, sw1)}
12454 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12455 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12456 @item @code{uw1 __MADDHUS (uw1, uw1)}
12457 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12458 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12459 @item @code{uw1 __MAND (uw1, uw1)}
12460 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12461 @tab @code{MAND @var{a},@var{b},@var{c}}
12462 @item @code{void __MASACCS (acc, acc)}
12463 @tab @code{__MASACCS (@var{b}, @var{a})}
12464 @tab @code{MASACCS @var{a},@var{b}}
12465 @item @code{uw1 __MAVEH (uw1, uw1)}
12466 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12467 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12468 @item @code{uw2 __MBTOH (uw1)}
12469 @tab @code{@var{b} = __MBTOH (@var{a})}
12470 @tab @code{MBTOH @var{a},@var{b}}
12471 @item @code{void __MBTOHE (uw1 *, uw1)}
12472 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12473 @tab @code{MBTOHE @var{a},@var{b}}
12474 @item @code{void __MCLRACC (acc)}
12475 @tab @code{__MCLRACC (@var{a})}
12476 @tab @code{MCLRACC @var{a}}
12477 @item @code{void __MCLRACCA (void)}
12478 @tab @code{__MCLRACCA ()}
12479 @tab @code{MCLRACCA}
12480 @item @code{uw1 __Mcop1 (uw1, uw1)}
12481 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12482 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12483 @item @code{uw1 __Mcop2 (uw1, uw1)}
12484 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12485 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12486 @item @code{uw1 __MCPLHI (uw2, const)}
12487 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12488 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12489 @item @code{uw1 __MCPLI (uw2, const)}
12490 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12491 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12492 @item @code{void __MCPXIS (acc, sw1, sw1)}
12493 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12494 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12495 @item @code{void __MCPXIU (acc, uw1, uw1)}
12496 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12497 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12498 @item @code{void __MCPXRS (acc, sw1, sw1)}
12499 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12500 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12501 @item @code{void __MCPXRU (acc, uw1, uw1)}
12502 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12503 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12504 @item @code{uw1 __MCUT (acc, uw1)}
12505 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12506 @tab @code{MCUT @var{a},@var{b},@var{c}}
12507 @item @code{uw1 __MCUTSS (acc, sw1)}
12508 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12509 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12510 @item @code{void __MDADDACCS (acc, acc)}
12511 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12512 @tab @code{MDADDACCS @var{a},@var{b}}
12513 @item @code{void __MDASACCS (acc, acc)}
12514 @tab @code{__MDASACCS (@var{b}, @var{a})}
12515 @tab @code{MDASACCS @var{a},@var{b}}
12516 @item @code{uw2 __MDCUTSSI (acc, const)}
12517 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12518 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12519 @item @code{uw2 __MDPACKH (uw2, uw2)}
12520 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12521 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12522 @item @code{uw2 __MDROTLI (uw2, const)}
12523 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12524 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12525 @item @code{void __MDSUBACCS (acc, acc)}
12526 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12527 @tab @code{MDSUBACCS @var{a},@var{b}}
12528 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12529 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12530 @tab @code{MDUNPACKH @var{a},@var{b}}
12531 @item @code{uw2 __MEXPDHD (uw1, const)}
12532 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12533 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12534 @item @code{uw1 __MEXPDHW (uw1, const)}
12535 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12536 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12537 @item @code{uw1 __MHDSETH (uw1, const)}
12538 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12539 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12540 @item @code{sw1 __MHDSETS (const)}
12541 @tab @code{@var{b} = __MHDSETS (@var{a})}
12542 @tab @code{MHDSETS #@var{a},@var{b}}
12543 @item @code{uw1 __MHSETHIH (uw1, const)}
12544 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12545 @tab @code{MHSETHIH #@var{a},@var{b}}
12546 @item @code{sw1 __MHSETHIS (sw1, const)}
12547 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12548 @tab @code{MHSETHIS #@var{a},@var{b}}
12549 @item @code{uw1 __MHSETLOH (uw1, const)}
12550 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12551 @tab @code{MHSETLOH #@var{a},@var{b}}
12552 @item @code{sw1 __MHSETLOS (sw1, const)}
12553 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12554 @tab @code{MHSETLOS #@var{a},@var{b}}
12555 @item @code{uw1 __MHTOB (uw2)}
12556 @tab @code{@var{b} = __MHTOB (@var{a})}
12557 @tab @code{MHTOB @var{a},@var{b}}
12558 @item @code{void __MMACHS (acc, sw1, sw1)}
12559 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12560 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12561 @item @code{void __MMACHU (acc, uw1, uw1)}
12562 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12563 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12564 @item @code{void __MMRDHS (acc, sw1, sw1)}
12565 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12566 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12567 @item @code{void __MMRDHU (acc, uw1, uw1)}
12568 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12569 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12570 @item @code{void __MMULHS (acc, sw1, sw1)}
12571 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12572 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12573 @item @code{void __MMULHU (acc, uw1, uw1)}
12574 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12575 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12576 @item @code{void __MMULXHS (acc, sw1, sw1)}
12577 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12578 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12579 @item @code{void __MMULXHU (acc, uw1, uw1)}
12580 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12581 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12582 @item @code{uw1 __MNOT (uw1)}
12583 @tab @code{@var{b} = __MNOT (@var{a})}
12584 @tab @code{MNOT @var{a},@var{b}}
12585 @item @code{uw1 __MOR (uw1, uw1)}
12586 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12587 @tab @code{MOR @var{a},@var{b},@var{c}}
12588 @item @code{uw1 __MPACKH (uh, uh)}
12589 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12590 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12591 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12592 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12593 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12594 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12595 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12596 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12597 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12598 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12599 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12600 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12601 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12602 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12603 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12604 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12605 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12606 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12607 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12608 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12609 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12610 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12611 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12612 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12613 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12614 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12615 @item @code{void __MQMACHS (acc, sw2, sw2)}
12616 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12617 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12618 @item @code{void __MQMACHU (acc, uw2, uw2)}
12619 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12620 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12621 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12622 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12623 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12624 @item @code{void __MQMULHS (acc, sw2, sw2)}
12625 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12626 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12627 @item @code{void __MQMULHU (acc, uw2, uw2)}
12628 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12629 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12630 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12631 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12632 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12633 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12634 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12635 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12636 @item @code{sw2 __MQSATHS (sw2, sw2)}
12637 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12638 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12639 @item @code{uw2 __MQSLLHI (uw2, int)}
12640 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12641 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12642 @item @code{sw2 __MQSRAHI (sw2, int)}
12643 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12644 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12645 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12646 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12647 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12648 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12649 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12650 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12651 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12652 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12653 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12654 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12655 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12656 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12657 @item @code{uw1 __MRDACC (acc)}
12658 @tab @code{@var{b} = __MRDACC (@var{a})}
12659 @tab @code{MRDACC @var{a},@var{b}}
12660 @item @code{uw1 __MRDACCG (acc)}
12661 @tab @code{@var{b} = __MRDACCG (@var{a})}
12662 @tab @code{MRDACCG @var{a},@var{b}}
12663 @item @code{uw1 __MROTLI (uw1, const)}
12664 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12665 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12666 @item @code{uw1 __MROTRI (uw1, const)}
12667 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12668 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12669 @item @code{sw1 __MSATHS (sw1, sw1)}
12670 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12671 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12672 @item @code{uw1 __MSATHU (uw1, uw1)}
12673 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12674 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12675 @item @code{uw1 __MSLLHI (uw1, const)}
12676 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12677 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12678 @item @code{sw1 __MSRAHI (sw1, const)}
12679 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12680 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12681 @item @code{uw1 __MSRLHI (uw1, const)}
12682 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12683 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12684 @item @code{void __MSUBACCS (acc, acc)}
12685 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12686 @tab @code{MSUBACCS @var{a},@var{b}}
12687 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12688 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12689 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12690 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12691 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12692 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12693 @item @code{void __MTRAP (void)}
12694 @tab @code{__MTRAP ()}
12695 @tab @code{MTRAP}
12696 @item @code{uw2 __MUNPACKH (uw1)}
12697 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12698 @tab @code{MUNPACKH @var{a},@var{b}}
12699 @item @code{uw1 __MWCUT (uw2, uw1)}
12700 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12701 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12702 @item @code{void __MWTACC (acc, uw1)}
12703 @tab @code{__MWTACC (@var{b}, @var{a})}
12704 @tab @code{MWTACC @var{a},@var{b}}
12705 @item @code{void __MWTACCG (acc, uw1)}
12706 @tab @code{__MWTACCG (@var{b}, @var{a})}
12707 @tab @code{MWTACCG @var{a},@var{b}}
12708 @item @code{uw1 __MXOR (uw1, uw1)}
12709 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12710 @tab @code{MXOR @var{a},@var{b},@var{c}}
12711 @end multitable
12712
12713 @node Raw read/write Functions
12714 @subsubsection Raw Read/Write Functions
12715
12716 This sections describes built-in functions related to read and write
12717 instructions to access memory. These functions generate
12718 @code{membar} instructions to flush the I/O load and stores where
12719 appropriate, as described in Fujitsu's manual described above.
12720
12721 @table @code
12722
12723 @item unsigned char __builtin_read8 (void *@var{data})
12724 @item unsigned short __builtin_read16 (void *@var{data})
12725 @item unsigned long __builtin_read32 (void *@var{data})
12726 @item unsigned long long __builtin_read64 (void *@var{data})
12727
12728 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12729 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12730 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12731 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12732 @end table
12733
12734 @node Other Built-in Functions
12735 @subsubsection Other Built-in Functions
12736
12737 This section describes built-in functions that are not named after
12738 a specific FR-V instruction.
12739
12740 @table @code
12741 @item sw2 __IACCreadll (iacc @var{reg})
12742 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12743 for future expansion and must be 0.
12744
12745 @item sw1 __IACCreadl (iacc @var{reg})
12746 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12747 Other values of @var{reg} are rejected as invalid.
12748
12749 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12750 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12751 is reserved for future expansion and must be 0.
12752
12753 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12754 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12755 is 1. Other values of @var{reg} are rejected as invalid.
12756
12757 @item void __data_prefetch0 (const void *@var{x})
12758 Use the @code{dcpl} instruction to load the contents of address @var{x}
12759 into the data cache.
12760
12761 @item void __data_prefetch (const void *@var{x})
12762 Use the @code{nldub} instruction to load the contents of address @var{x}
12763 into the data cache. The instruction is issued in slot I1@.
12764 @end table
12765
12766 @node MIPS DSP Built-in Functions
12767 @subsection MIPS DSP Built-in Functions
12768
12769 The MIPS DSP Application-Specific Extension (ASE) includes new
12770 instructions that are designed to improve the performance of DSP and
12771 media applications. It provides instructions that operate on packed
12772 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12773
12774 GCC supports MIPS DSP operations using both the generic
12775 vector extensions (@pxref{Vector Extensions}) and a collection of
12776 MIPS-specific built-in functions. Both kinds of support are
12777 enabled by the @option{-mdsp} command-line option.
12778
12779 Revision 2 of the ASE was introduced in the second half of 2006.
12780 This revision adds extra instructions to the original ASE, but is
12781 otherwise backwards-compatible with it. You can select revision 2
12782 using the command-line option @option{-mdspr2}; this option implies
12783 @option{-mdsp}.
12784
12785 The SCOUNT and POS bits of the DSP control register are global. The
12786 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12787 POS bits. During optimization, the compiler does not delete these
12788 instructions and it does not delete calls to functions containing
12789 these instructions.
12790
12791 At present, GCC only provides support for operations on 32-bit
12792 vectors. The vector type associated with 8-bit integer data is
12793 usually called @code{v4i8}, the vector type associated with Q7
12794 is usually called @code{v4q7}, the vector type associated with 16-bit
12795 integer data is usually called @code{v2i16}, and the vector type
12796 associated with Q15 is usually called @code{v2q15}. They can be
12797 defined in C as follows:
12798
12799 @smallexample
12800 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12801 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12802 typedef short v2i16 __attribute__ ((vector_size(4)));
12803 typedef short v2q15 __attribute__ ((vector_size(4)));
12804 @end smallexample
12805
12806 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12807 initialized in the same way as aggregates. For example:
12808
12809 @smallexample
12810 v4i8 a = @{1, 2, 3, 4@};
12811 v4i8 b;
12812 b = (v4i8) @{5, 6, 7, 8@};
12813
12814 v2q15 c = @{0x0fcb, 0x3a75@};
12815 v2q15 d;
12816 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12817 @end smallexample
12818
12819 @emph{Note:} The CPU's endianness determines the order in which values
12820 are packed. On little-endian targets, the first value is the least
12821 significant and the last value is the most significant. The opposite
12822 order applies to big-endian targets. For example, the code above
12823 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12824 and @code{4} on big-endian targets.
12825
12826 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12827 representation. As shown in this example, the integer representation
12828 of a Q7 value can be obtained by multiplying the fractional value by
12829 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12830 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12831 @code{0x1.0p31}.
12832
12833 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12834 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12835 and @code{c} and @code{d} are @code{v2q15} values.
12836
12837 @multitable @columnfractions .50 .50
12838 @item C code @tab MIPS instruction
12839 @item @code{a + b} @tab @code{addu.qb}
12840 @item @code{c + d} @tab @code{addq.ph}
12841 @item @code{a - b} @tab @code{subu.qb}
12842 @item @code{c - d} @tab @code{subq.ph}
12843 @end multitable
12844
12845 The table below lists the @code{v2i16} operation for which
12846 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12847 @code{v2i16} values.
12848
12849 @multitable @columnfractions .50 .50
12850 @item C code @tab MIPS instruction
12851 @item @code{e * f} @tab @code{mul.ph}
12852 @end multitable
12853
12854 It is easier to describe the DSP built-in functions if we first define
12855 the following types:
12856
12857 @smallexample
12858 typedef int q31;
12859 typedef int i32;
12860 typedef unsigned int ui32;
12861 typedef long long a64;
12862 @end smallexample
12863
12864 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12865 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12866 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12867 @code{long long}, but we use @code{a64} to indicate values that are
12868 placed in one of the four DSP accumulators (@code{$ac0},
12869 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12870
12871 Also, some built-in functions prefer or require immediate numbers as
12872 parameters, because the corresponding DSP instructions accept both immediate
12873 numbers and register operands, or accept immediate numbers only. The
12874 immediate parameters are listed as follows.
12875
12876 @smallexample
12877 imm0_3: 0 to 3.
12878 imm0_7: 0 to 7.
12879 imm0_15: 0 to 15.
12880 imm0_31: 0 to 31.
12881 imm0_63: 0 to 63.
12882 imm0_255: 0 to 255.
12883 imm_n32_31: -32 to 31.
12884 imm_n512_511: -512 to 511.
12885 @end smallexample
12886
12887 The following built-in functions map directly to a particular MIPS DSP
12888 instruction. Please refer to the architecture specification
12889 for details on what each instruction does.
12890
12891 @smallexample
12892 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12893 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12894 q31 __builtin_mips_addq_s_w (q31, q31)
12895 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12896 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12897 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12898 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12899 q31 __builtin_mips_subq_s_w (q31, q31)
12900 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12901 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12902 i32 __builtin_mips_addsc (i32, i32)
12903 i32 __builtin_mips_addwc (i32, i32)
12904 i32 __builtin_mips_modsub (i32, i32)
12905 i32 __builtin_mips_raddu_w_qb (v4i8)
12906 v2q15 __builtin_mips_absq_s_ph (v2q15)
12907 q31 __builtin_mips_absq_s_w (q31)
12908 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12909 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12910 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12911 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12912 q31 __builtin_mips_preceq_w_phl (v2q15)
12913 q31 __builtin_mips_preceq_w_phr (v2q15)
12914 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12915 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12916 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12917 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12918 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12919 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12920 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12921 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12922 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12923 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12924 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12925 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12926 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12927 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12928 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12929 q31 __builtin_mips_shll_s_w (q31, i32)
12930 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12931 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12932 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12933 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12934 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12935 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12936 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12937 q31 __builtin_mips_shra_r_w (q31, i32)
12938 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12939 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12940 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12941 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12942 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12943 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12944 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12945 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12946 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12947 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12948 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12949 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12950 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12951 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12952 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12953 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12954 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12955 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12956 i32 __builtin_mips_bitrev (i32)
12957 i32 __builtin_mips_insv (i32, i32)
12958 v4i8 __builtin_mips_repl_qb (imm0_255)
12959 v4i8 __builtin_mips_repl_qb (i32)
12960 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12961 v2q15 __builtin_mips_repl_ph (i32)
12962 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12963 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12964 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12965 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12966 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12967 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12968 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12969 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12970 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12971 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12972 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12973 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12974 i32 __builtin_mips_extr_w (a64, imm0_31)
12975 i32 __builtin_mips_extr_w (a64, i32)
12976 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12977 i32 __builtin_mips_extr_s_h (a64, i32)
12978 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12979 i32 __builtin_mips_extr_rs_w (a64, i32)
12980 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12981 i32 __builtin_mips_extr_r_w (a64, i32)
12982 i32 __builtin_mips_extp (a64, imm0_31)
12983 i32 __builtin_mips_extp (a64, i32)
12984 i32 __builtin_mips_extpdp (a64, imm0_31)
12985 i32 __builtin_mips_extpdp (a64, i32)
12986 a64 __builtin_mips_shilo (a64, imm_n32_31)
12987 a64 __builtin_mips_shilo (a64, i32)
12988 a64 __builtin_mips_mthlip (a64, i32)
12989 void __builtin_mips_wrdsp (i32, imm0_63)
12990 i32 __builtin_mips_rddsp (imm0_63)
12991 i32 __builtin_mips_lbux (void *, i32)
12992 i32 __builtin_mips_lhx (void *, i32)
12993 i32 __builtin_mips_lwx (void *, i32)
12994 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12995 i32 __builtin_mips_bposge32 (void)
12996 a64 __builtin_mips_madd (a64, i32, i32);
12997 a64 __builtin_mips_maddu (a64, ui32, ui32);
12998 a64 __builtin_mips_msub (a64, i32, i32);
12999 a64 __builtin_mips_msubu (a64, ui32, ui32);
13000 a64 __builtin_mips_mult (i32, i32);
13001 a64 __builtin_mips_multu (ui32, ui32);
13002 @end smallexample
13003
13004 The following built-in functions map directly to a particular MIPS DSP REV 2
13005 instruction. Please refer to the architecture specification
13006 for details on what each instruction does.
13007
13008 @smallexample
13009 v4q7 __builtin_mips_absq_s_qb (v4q7);
13010 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
13011 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
13012 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
13013 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
13014 i32 __builtin_mips_append (i32, i32, imm0_31);
13015 i32 __builtin_mips_balign (i32, i32, imm0_3);
13016 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
13017 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
13018 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
13019 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
13020 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
13021 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
13022 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
13023 q31 __builtin_mips_mulq_rs_w (q31, q31);
13024 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
13025 q31 __builtin_mips_mulq_s_w (q31, q31);
13026 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
13027 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
13028 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
13029 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
13030 i32 __builtin_mips_prepend (i32, i32, imm0_31);
13031 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
13032 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
13033 v4i8 __builtin_mips_shra_qb (v4i8, i32);
13034 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
13035 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
13036 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
13037 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
13038 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
13039 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
13040 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
13041 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
13042 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
13043 q31 __builtin_mips_addqh_w (q31, q31);
13044 q31 __builtin_mips_addqh_r_w (q31, q31);
13045 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
13046 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
13047 q31 __builtin_mips_subqh_w (q31, q31);
13048 q31 __builtin_mips_subqh_r_w (q31, q31);
13049 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
13050 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
13051 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
13052 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
13053 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
13054 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
13055 @end smallexample
13056
13057
13058 @node MIPS Paired-Single Support
13059 @subsection MIPS Paired-Single Support
13060
13061 The MIPS64 architecture includes a number of instructions that
13062 operate on pairs of single-precision floating-point values.
13063 Each pair is packed into a 64-bit floating-point register,
13064 with one element being designated the ``upper half'' and
13065 the other being designated the ``lower half''.
13066
13067 GCC supports paired-single operations using both the generic
13068 vector extensions (@pxref{Vector Extensions}) and a collection of
13069 MIPS-specific built-in functions. Both kinds of support are
13070 enabled by the @option{-mpaired-single} command-line option.
13071
13072 The vector type associated with paired-single values is usually
13073 called @code{v2sf}. It can be defined in C as follows:
13074
13075 @smallexample
13076 typedef float v2sf __attribute__ ((vector_size (8)));
13077 @end smallexample
13078
13079 @code{v2sf} values are initialized in the same way as aggregates.
13080 For example:
13081
13082 @smallexample
13083 v2sf a = @{1.5, 9.1@};
13084 v2sf b;
13085 float e, f;
13086 b = (v2sf) @{e, f@};
13087 @end smallexample
13088
13089 @emph{Note:} The CPU's endianness determines which value is stored in
13090 the upper half of a register and which value is stored in the lower half.
13091 On little-endian targets, the first value is the lower one and the second
13092 value is the upper one. The opposite order applies to big-endian targets.
13093 For example, the code above sets the lower half of @code{a} to
13094 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
13095
13096 @node MIPS Loongson Built-in Functions
13097 @subsection MIPS Loongson Built-in Functions
13098
13099 GCC provides intrinsics to access the SIMD instructions provided by the
13100 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13101 available after inclusion of the @code{loongson.h} header file,
13102 operate on the following 64-bit vector types:
13103
13104 @itemize
13105 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13106 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13107 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13108 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13109 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13110 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13111 @end itemize
13112
13113 The intrinsics provided are listed below; each is named after the
13114 machine instruction to which it corresponds, with suffixes added as
13115 appropriate to distinguish intrinsics that expand to the same machine
13116 instruction yet have different argument types. Refer to the architecture
13117 documentation for a description of the functionality of each
13118 instruction.
13119
13120 @smallexample
13121 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13122 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13123 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13124 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13125 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13126 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13127 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13128 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13129 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13130 uint64_t paddd_u (uint64_t s, uint64_t t);
13131 int64_t paddd_s (int64_t s, int64_t t);
13132 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13133 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13134 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13135 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13136 uint64_t pandn_ud (uint64_t s, uint64_t t);
13137 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13138 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13139 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13140 int64_t pandn_sd (int64_t s, int64_t t);
13141 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13142 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13143 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13144 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13145 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13146 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13147 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13148 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13149 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13150 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13151 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13152 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13153 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13154 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13155 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13156 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13157 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13158 uint16x4_t pextrh_u (uint16x4_t s, int field);
13159 int16x4_t pextrh_s (int16x4_t s, int field);
13160 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13161 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13162 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13163 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13164 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13165 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13166 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13167 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13168 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13169 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13170 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13171 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13172 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13173 uint8x8_t pmovmskb_u (uint8x8_t s);
13174 int8x8_t pmovmskb_s (int8x8_t s);
13175 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13176 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13177 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13178 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13179 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13180 uint16x4_t biadd (uint8x8_t s);
13181 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13182 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13183 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13184 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13185 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13186 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13187 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13188 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13189 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13190 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13191 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13192 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13193 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13194 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13195 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13196 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13197 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13198 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13199 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13200 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13201 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13202 uint64_t psubd_u (uint64_t s, uint64_t t);
13203 int64_t psubd_s (int64_t s, int64_t t);
13204 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13205 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13206 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13207 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13208 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13209 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13210 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13211 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13212 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13213 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13214 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13215 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13216 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13217 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13218 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13219 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13220 @end smallexample
13221
13222 @menu
13223 * Paired-Single Arithmetic::
13224 * Paired-Single Built-in Functions::
13225 * MIPS-3D Built-in Functions::
13226 @end menu
13227
13228 @node Paired-Single Arithmetic
13229 @subsubsection Paired-Single Arithmetic
13230
13231 The table below lists the @code{v2sf} operations for which hardware
13232 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13233 values and @code{x} is an integral value.
13234
13235 @multitable @columnfractions .50 .50
13236 @item C code @tab MIPS instruction
13237 @item @code{a + b} @tab @code{add.ps}
13238 @item @code{a - b} @tab @code{sub.ps}
13239 @item @code{-a} @tab @code{neg.ps}
13240 @item @code{a * b} @tab @code{mul.ps}
13241 @item @code{a * b + c} @tab @code{madd.ps}
13242 @item @code{a * b - c} @tab @code{msub.ps}
13243 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13244 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13245 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13246 @end multitable
13247
13248 Note that the multiply-accumulate instructions can be disabled
13249 using the command-line option @code{-mno-fused-madd}.
13250
13251 @node Paired-Single Built-in Functions
13252 @subsubsection Paired-Single Built-in Functions
13253
13254 The following paired-single functions map directly to a particular
13255 MIPS instruction. Please refer to the architecture specification
13256 for details on what each instruction does.
13257
13258 @table @code
13259 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13260 Pair lower lower (@code{pll.ps}).
13261
13262 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13263 Pair upper lower (@code{pul.ps}).
13264
13265 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13266 Pair lower upper (@code{plu.ps}).
13267
13268 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13269 Pair upper upper (@code{puu.ps}).
13270
13271 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13272 Convert pair to paired single (@code{cvt.ps.s}).
13273
13274 @item float __builtin_mips_cvt_s_pl (v2sf)
13275 Convert pair lower to single (@code{cvt.s.pl}).
13276
13277 @item float __builtin_mips_cvt_s_pu (v2sf)
13278 Convert pair upper to single (@code{cvt.s.pu}).
13279
13280 @item v2sf __builtin_mips_abs_ps (v2sf)
13281 Absolute value (@code{abs.ps}).
13282
13283 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13284 Align variable (@code{alnv.ps}).
13285
13286 @emph{Note:} The value of the third parameter must be 0 or 4
13287 modulo 8, otherwise the result is unpredictable. Please read the
13288 instruction description for details.
13289 @end table
13290
13291 The following multi-instruction functions are also available.
13292 In each case, @var{cond} can be any of the 16 floating-point conditions:
13293 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13294 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13295 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13296
13297 @table @code
13298 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13299 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13300 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13301 @code{movt.ps}/@code{movf.ps}).
13302
13303 The @code{movt} functions return the value @var{x} computed by:
13304
13305 @smallexample
13306 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13307 mov.ps @var{x},@var{c}
13308 movt.ps @var{x},@var{d},@var{cc}
13309 @end smallexample
13310
13311 The @code{movf} functions are similar but use @code{movf.ps} instead
13312 of @code{movt.ps}.
13313
13314 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13315 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13316 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13317 @code{bc1t}/@code{bc1f}).
13318
13319 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13320 and return either the upper or lower half of the result. For example:
13321
13322 @smallexample
13323 v2sf a, b;
13324 if (__builtin_mips_upper_c_eq_ps (a, b))
13325 upper_halves_are_equal ();
13326 else
13327 upper_halves_are_unequal ();
13328
13329 if (__builtin_mips_lower_c_eq_ps (a, b))
13330 lower_halves_are_equal ();
13331 else
13332 lower_halves_are_unequal ();
13333 @end smallexample
13334 @end table
13335
13336 @node MIPS-3D Built-in Functions
13337 @subsubsection MIPS-3D Built-in Functions
13338
13339 The MIPS-3D Application-Specific Extension (ASE) includes additional
13340 paired-single instructions that are designed to improve the performance
13341 of 3D graphics operations. Support for these instructions is controlled
13342 by the @option{-mips3d} command-line option.
13343
13344 The functions listed below map directly to a particular MIPS-3D
13345 instruction. Please refer to the architecture specification for
13346 more details on what each instruction does.
13347
13348 @table @code
13349 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13350 Reduction add (@code{addr.ps}).
13351
13352 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13353 Reduction multiply (@code{mulr.ps}).
13354
13355 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13356 Convert paired single to paired word (@code{cvt.pw.ps}).
13357
13358 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13359 Convert paired word to paired single (@code{cvt.ps.pw}).
13360
13361 @item float __builtin_mips_recip1_s (float)
13362 @itemx double __builtin_mips_recip1_d (double)
13363 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13364 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13365
13366 @item float __builtin_mips_recip2_s (float, float)
13367 @itemx double __builtin_mips_recip2_d (double, double)
13368 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13369 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13370
13371 @item float __builtin_mips_rsqrt1_s (float)
13372 @itemx double __builtin_mips_rsqrt1_d (double)
13373 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13374 Reduced-precision reciprocal square root (sequence step 1)
13375 (@code{rsqrt1.@var{fmt}}).
13376
13377 @item float __builtin_mips_rsqrt2_s (float, float)
13378 @itemx double __builtin_mips_rsqrt2_d (double, double)
13379 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13380 Reduced-precision reciprocal square root (sequence step 2)
13381 (@code{rsqrt2.@var{fmt}}).
13382 @end table
13383
13384 The following multi-instruction functions are also available.
13385 In each case, @var{cond} can be any of the 16 floating-point conditions:
13386 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13387 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13388 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13389
13390 @table @code
13391 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13392 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13393 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13394 @code{bc1t}/@code{bc1f}).
13395
13396 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13397 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13398 For example:
13399
13400 @smallexample
13401 float a, b;
13402 if (__builtin_mips_cabs_eq_s (a, b))
13403 true ();
13404 else
13405 false ();
13406 @end smallexample
13407
13408 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13409 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13410 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13411 @code{bc1t}/@code{bc1f}).
13412
13413 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13414 and return either the upper or lower half of the result. For example:
13415
13416 @smallexample
13417 v2sf a, b;
13418 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13419 upper_halves_are_equal ();
13420 else
13421 upper_halves_are_unequal ();
13422
13423 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13424 lower_halves_are_equal ();
13425 else
13426 lower_halves_are_unequal ();
13427 @end smallexample
13428
13429 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13430 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13431 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13432 @code{movt.ps}/@code{movf.ps}).
13433
13434 The @code{movt} functions return the value @var{x} computed by:
13435
13436 @smallexample
13437 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13438 mov.ps @var{x},@var{c}
13439 movt.ps @var{x},@var{d},@var{cc}
13440 @end smallexample
13441
13442 The @code{movf} functions are similar but use @code{movf.ps} instead
13443 of @code{movt.ps}.
13444
13445 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13446 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13447 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13448 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13449 Comparison of two paired-single values
13450 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13451 @code{bc1any2t}/@code{bc1any2f}).
13452
13453 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13454 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13455 result is true and the @code{all} forms return true if both results are true.
13456 For example:
13457
13458 @smallexample
13459 v2sf a, b;
13460 if (__builtin_mips_any_c_eq_ps (a, b))
13461 one_is_true ();
13462 else
13463 both_are_false ();
13464
13465 if (__builtin_mips_all_c_eq_ps (a, b))
13466 both_are_true ();
13467 else
13468 one_is_false ();
13469 @end smallexample
13470
13471 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13472 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13473 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13474 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13475 Comparison of four paired-single values
13476 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13477 @code{bc1any4t}/@code{bc1any4f}).
13478
13479 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13480 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13481 The @code{any} forms return true if any of the four results are true
13482 and the @code{all} forms return true if all four results are true.
13483 For example:
13484
13485 @smallexample
13486 v2sf a, b, c, d;
13487 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13488 some_are_true ();
13489 else
13490 all_are_false ();
13491
13492 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13493 all_are_true ();
13494 else
13495 some_are_false ();
13496 @end smallexample
13497 @end table
13498
13499 @node Other MIPS Built-in Functions
13500 @subsection Other MIPS Built-in Functions
13501
13502 GCC provides other MIPS-specific built-in functions:
13503
13504 @table @code
13505 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13506 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13507 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13508 when this function is available.
13509
13510 @item unsigned int __builtin_mips_get_fcsr (void)
13511 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13512 Get and set the contents of the floating-point control and status register
13513 (FPU control register 31). These functions are only available in hard-float
13514 code but can be called in both MIPS16 and non-MIPS16 contexts.
13515
13516 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13517 register except the condition codes, which GCC assumes are preserved.
13518 @end table
13519
13520 @node MSP430 Built-in Functions
13521 @subsection MSP430 Built-in Functions
13522
13523 GCC provides a couple of special builtin functions to aid in the
13524 writing of interrupt handlers in C.
13525
13526 @table @code
13527 @item __bic_SR_register_on_exit (int @var{mask})
13528 This clears the indicated bits in the saved copy of the status register
13529 currently residing on the stack. This only works inside interrupt
13530 handlers and the changes to the status register will only take affect
13531 once the handler returns.
13532
13533 @item __bis_SR_register_on_exit (int @var{mask})
13534 This sets the indicated bits in the saved copy of the status register
13535 currently residing on the stack. This only works inside interrupt
13536 handlers and the changes to the status register will only take affect
13537 once the handler returns.
13538
13539 @item __delay_cycles (long long @var{cycles})
13540 This inserts an instruction sequence that takes exactly @var{cycles}
13541 cycles (between 0 and about 17E9) to complete. The inserted sequence
13542 may use jumps, loops, or no-ops, and does not interfere with any other
13543 instructions. Note that @var{cycles} must be a compile-time constant
13544 integer - that is, you must pass a number, not a variable that may be
13545 optimized to a constant later. The number of cycles delayed by this
13546 builtin is exact.
13547 @end table
13548
13549 @node NDS32 Built-in Functions
13550 @subsection NDS32 Built-in Functions
13551
13552 These built-in functions are available for the NDS32 target:
13553
13554 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13555 Insert an ISYNC instruction into the instruction stream where
13556 @var{addr} is an instruction address for serialization.
13557 @end deftypefn
13558
13559 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13560 Insert an ISB instruction into the instruction stream.
13561 @end deftypefn
13562
13563 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13564 Return the content of a system register which is mapped by @var{sr}.
13565 @end deftypefn
13566
13567 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13568 Return the content of a user space register which is mapped by @var{usr}.
13569 @end deftypefn
13570
13571 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13572 Move the @var{value} to a system register which is mapped by @var{sr}.
13573 @end deftypefn
13574
13575 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13576 Move the @var{value} to a user space register which is mapped by @var{usr}.
13577 @end deftypefn
13578
13579 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13580 Enable global interrupt.
13581 @end deftypefn
13582
13583 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13584 Disable global interrupt.
13585 @end deftypefn
13586
13587 @node picoChip Built-in Functions
13588 @subsection picoChip Built-in Functions
13589
13590 GCC provides an interface to selected machine instructions from the
13591 picoChip instruction set.
13592
13593 @table @code
13594 @item int __builtin_sbc (int @var{value})
13595 Sign bit count. Return the number of consecutive bits in @var{value}
13596 that have the same value as the sign bit. The result is the number of
13597 leading sign bits minus one, giving the number of redundant sign bits in
13598 @var{value}.
13599
13600 @item int __builtin_byteswap (int @var{value})
13601 Byte swap. Return the result of swapping the upper and lower bytes of
13602 @var{value}.
13603
13604 @item int __builtin_brev (int @var{value})
13605 Bit reversal. Return the result of reversing the bits in
13606 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13607 and so on.
13608
13609 @item int __builtin_adds (int @var{x}, int @var{y})
13610 Saturating addition. Return the result of adding @var{x} and @var{y},
13611 storing the value 32767 if the result overflows.
13612
13613 @item int __builtin_subs (int @var{x}, int @var{y})
13614 Saturating subtraction. Return the result of subtracting @var{y} from
13615 @var{x}, storing the value @minus{}32768 if the result overflows.
13616
13617 @item void __builtin_halt (void)
13618 Halt. The processor stops execution. This built-in is useful for
13619 implementing assertions.
13620
13621 @end table
13622
13623 @node PowerPC Built-in Functions
13624 @subsection PowerPC Built-in Functions
13625
13626 The following built-in functions are always available and can be used to
13627 check the PowerPC target platform type:
13628
13629 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
13630 This function is a @code{nop} on the PowerPC platform and is included solely
13631 to maintain API compatibility with the x86 builtins.
13632 @end deftypefn
13633
13634 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
13635 This function returns a value of @code{1} if the run-time CPU is of type
13636 @var{cpuname} and returns @code{0} otherwise. The following CPU names can be
13637 detected:
13638
13639 @table @samp
13640 @item power9
13641 IBM POWER9 Server CPU.
13642 @item power8
13643 IBM POWER8 Server CPU.
13644 @item power7
13645 IBM POWER7 Server CPU.
13646 @item power6x
13647 IBM POWER6 Server CPU (RAW mode).
13648 @item power6
13649 IBM POWER6 Server CPU (Architected mode).
13650 @item power5+
13651 IBM POWER5+ Server CPU.
13652 @item power5
13653 IBM POWER5 Server CPU.
13654 @item ppc970
13655 IBM 970 Server CPU (ie, Apple G5).
13656 @item power4
13657 IBM POWER4 Server CPU.
13658 @item ppca2
13659 IBM A2 64-bit Embedded CPU
13660 @item ppc476
13661 IBM PowerPC 476FP 32-bit Embedded CPU.
13662 @item ppc464
13663 IBM PowerPC 464 32-bit Embedded CPU.
13664 @item ppc440
13665 PowerPC 440 32-bit Embedded CPU.
13666 @item ppc405
13667 PowerPC 405 32-bit Embedded CPU.
13668 @item ppc-cell-be
13669 IBM PowerPC Cell Broadband Engine Architecture CPU.
13670 @end table
13671
13672 Here is an example:
13673 @smallexample
13674 if (__builtin_cpu_is ("power8"))
13675 @{
13676 do_power8 (); // POWER8 specific implementation.
13677 @}
13678 else
13679 @{
13680 do_generic (); // Generic implementation.
13681 @}
13682 @end smallexample
13683 @end deftypefn
13684
13685 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
13686 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
13687 feature @var{feature} and returns @code{0} otherwise. The following features can be
13688 detected:
13689
13690 @table @samp
13691 @item 4xxmac
13692 4xx CPU has a Multiply Accumulator.
13693 @item altivec
13694 CPU has a SIMD/Vector Unit.
13695 @item arch_2_05
13696 CPU supports ISA 2.05 (eg, POWER6)
13697 @item arch_2_06
13698 CPU supports ISA 2.06 (eg, POWER7)
13699 @item arch_2_07
13700 CPU supports ISA 2.07 (eg, POWER8)
13701 @item arch_3_00
13702 CPU supports ISA 3.00 (eg, POWER9)
13703 @item archpmu
13704 CPU supports the set of compatible performance monitoring events.
13705 @item booke
13706 CPU supports the Embedded ISA category.
13707 @item cellbe
13708 CPU has a CELL broadband engine.
13709 @item dfp
13710 CPU has a decimal floating point unit.
13711 @item dscr
13712 CPU supports the data stream control register.
13713 @item ebb
13714 CPU supports event base branching.
13715 @item efpdouble
13716 CPU has a SPE double precision floating point unit.
13717 @item efpsingle
13718 CPU has a SPE single precision floating point unit.
13719 @item fpu
13720 CPU has a floating point unit.
13721 @item htm
13722 CPU has hardware transaction memory instructions.
13723 @item htm-nosc
13724 Kernel aborts hardware transactions when a syscall is made.
13725 @item ic_snoop
13726 CPU supports icache snooping capabilities.
13727 @item ieee128
13728 CPU supports 128-bit IEEE binary floating point instructions.
13729 @item isel
13730 CPU supports the integer select instruction.
13731 @item mmu
13732 CPU has a memory management unit.
13733 @item notb
13734 CPU does not have a timebase (eg, 601 and 403gx).
13735 @item pa6t
13736 CPU supports the PA Semi 6T CORE ISA.
13737 @item power4
13738 CPU supports ISA 2.00 (eg, POWER4)
13739 @item power5
13740 CPU supports ISA 2.02 (eg, POWER5)
13741 @item power5+
13742 CPU supports ISA 2.03 (eg, POWER5+)
13743 @item power6x
13744 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
13745 @item ppc32
13746 CPU supports 32-bit mode execution.
13747 @item ppc601
13748 CPU supports the old POWER ISA (eg, 601)
13749 @item ppc64
13750 CPU supports 64-bit mode execution.
13751 @item ppcle
13752 CPU supports a little-endian mode that uses address swizzling.
13753 @item smt
13754 CPU support simultaneous multi-threading.
13755 @item spe
13756 CPU has a signal processing extension unit.
13757 @item tar
13758 CPU supports the target address register.
13759 @item true_le
13760 CPU supports true little-endian mode.
13761 @item ucache
13762 CPU has unified I/D cache.
13763 @item vcrypto
13764 CPU supports the vector cryptography instructions.
13765 @item vsx
13766 CPU supports the vector-scalar extension.
13767 @end table
13768
13769 Here is an example:
13770 @smallexample
13771 if (__builtin_cpu_supports ("fpu"))
13772 @{
13773 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
13774 @}
13775 else
13776 @{
13777 dst = __fadd (src1, src2); // Software FP addition function.
13778 @}
13779 @end smallexample
13780 @end deftypefn
13781
13782 These built-in functions are available for the PowerPC family of
13783 processors:
13784 @smallexample
13785 float __builtin_recipdivf (float, float);
13786 float __builtin_rsqrtf (float);
13787 double __builtin_recipdiv (double, double);
13788 double __builtin_rsqrt (double);
13789 uint64_t __builtin_ppc_get_timebase ();
13790 unsigned long __builtin_ppc_mftb ();
13791 double __builtin_unpack_longdouble (long double, int);
13792 long double __builtin_pack_longdouble (double, double);
13793 @end smallexample
13794
13795 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13796 @code{__builtin_rsqrtf} functions generate multiple instructions to
13797 implement the reciprocal sqrt functionality using reciprocal sqrt
13798 estimate instructions.
13799
13800 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13801 functions generate multiple instructions to implement division using
13802 the reciprocal estimate instructions.
13803
13804 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13805 functions generate instructions to read the Time Base Register. The
13806 @code{__builtin_ppc_get_timebase} function may generate multiple
13807 instructions and always returns the 64 bits of the Time Base Register.
13808 The @code{__builtin_ppc_mftb} function always generates one instruction and
13809 returns the Time Base Register value as an unsigned long, throwing away
13810 the most significant word on 32-bit environments.
13811
13812 The following built-in functions are available for the PowerPC family
13813 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13814 or @option{-mpopcntd}):
13815 @smallexample
13816 long __builtin_bpermd (long, long);
13817 int __builtin_divwe (int, int);
13818 int __builtin_divweo (int, int);
13819 unsigned int __builtin_divweu (unsigned int, unsigned int);
13820 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13821 long __builtin_divde (long, long);
13822 long __builtin_divdeo (long, long);
13823 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13824 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13825 unsigned int cdtbcd (unsigned int);
13826 unsigned int cbcdtd (unsigned int);
13827 unsigned int addg6s (unsigned int, unsigned int);
13828 @end smallexample
13829
13830 The @code{__builtin_divde}, @code{__builtin_divdeo},
13831 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13832 64-bit environment support ISA 2.06 or later.
13833
13834 The following built-in functions are available for the PowerPC family
13835 of processors when hardware decimal floating point
13836 (@option{-mhard-dfp}) is available:
13837 @smallexample
13838 _Decimal64 __builtin_dxex (_Decimal64);
13839 _Decimal128 __builtin_dxexq (_Decimal128);
13840 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13841 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13842 _Decimal64 __builtin_denbcd (int, _Decimal64);
13843 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13844 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13845 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13846 _Decimal64 __builtin_dscli (_Decimal64, int);
13847 _Decimal128 __builtin_dscliq (_Decimal128, int);
13848 _Decimal64 __builtin_dscri (_Decimal64, int);
13849 _Decimal128 __builtin_dscriq (_Decimal128, int);
13850 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13851 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13852 @end smallexample
13853
13854 The following built-in functions are available for the PowerPC family
13855 of processors when the Vector Scalar (vsx) instruction set is
13856 available:
13857 @smallexample
13858 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13859 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13860 unsigned long long);
13861 @end smallexample
13862
13863 @node PowerPC AltiVec/VSX Built-in Functions
13864 @subsection PowerPC AltiVec Built-in Functions
13865
13866 GCC provides an interface for the PowerPC family of processors to access
13867 the AltiVec operations described in Motorola's AltiVec Programming
13868 Interface Manual. The interface is made available by including
13869 @code{<altivec.h>} and using @option{-maltivec} and
13870 @option{-mabi=altivec}. The interface supports the following vector
13871 types.
13872
13873 @smallexample
13874 vector unsigned char
13875 vector signed char
13876 vector bool char
13877
13878 vector unsigned short
13879 vector signed short
13880 vector bool short
13881 vector pixel
13882
13883 vector unsigned int
13884 vector signed int
13885 vector bool int
13886 vector float
13887 @end smallexample
13888
13889 If @option{-mvsx} is used the following additional vector types are
13890 implemented.
13891
13892 @smallexample
13893 vector unsigned long
13894 vector signed long
13895 vector double
13896 @end smallexample
13897
13898 The long types are only implemented for 64-bit code generation, and
13899 the long type is only used in the floating point/integer conversion
13900 instructions.
13901
13902 GCC's implementation of the high-level language interface available from
13903 C and C++ code differs from Motorola's documentation in several ways.
13904
13905 @itemize @bullet
13906
13907 @item
13908 A vector constant is a list of constant expressions within curly braces.
13909
13910 @item
13911 A vector initializer requires no cast if the vector constant is of the
13912 same type as the variable it is initializing.
13913
13914 @item
13915 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13916 vector type is the default signedness of the base type. The default
13917 varies depending on the operating system, so a portable program should
13918 always specify the signedness.
13919
13920 @item
13921 Compiling with @option{-maltivec} adds keywords @code{__vector},
13922 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13923 @code{bool}. When compiling ISO C, the context-sensitive substitution
13924 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13925 disabled. To use them, you must include @code{<altivec.h>} instead.
13926
13927 @item
13928 GCC allows using a @code{typedef} name as the type specifier for a
13929 vector type.
13930
13931 @item
13932 For C, overloaded functions are implemented with macros so the following
13933 does not work:
13934
13935 @smallexample
13936 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13937 @end smallexample
13938
13939 @noindent
13940 Since @code{vec_add} is a macro, the vector constant in the example
13941 is treated as four separate arguments. Wrap the entire argument in
13942 parentheses for this to work.
13943 @end itemize
13944
13945 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13946 Internally, GCC uses built-in functions to achieve the functionality in
13947 the aforementioned header file, but they are not supported and are
13948 subject to change without notice.
13949
13950 The following interfaces are supported for the generic and specific
13951 AltiVec operations and the AltiVec predicates. In cases where there
13952 is a direct mapping between generic and specific operations, only the
13953 generic names are shown here, although the specific operations can also
13954 be used.
13955
13956 Arguments that are documented as @code{const int} require literal
13957 integral values within the range required for that operation.
13958
13959 @smallexample
13960 vector signed char vec_abs (vector signed char);
13961 vector signed short vec_abs (vector signed short);
13962 vector signed int vec_abs (vector signed int);
13963 vector float vec_abs (vector float);
13964
13965 vector signed char vec_abss (vector signed char);
13966 vector signed short vec_abss (vector signed short);
13967 vector signed int vec_abss (vector signed int);
13968
13969 vector signed char vec_add (vector bool char, vector signed char);
13970 vector signed char vec_add (vector signed char, vector bool char);
13971 vector signed char vec_add (vector signed char, vector signed char);
13972 vector unsigned char vec_add (vector bool char, vector unsigned char);
13973 vector unsigned char vec_add (vector unsigned char, vector bool char);
13974 vector unsigned char vec_add (vector unsigned char,
13975 vector unsigned char);
13976 vector signed short vec_add (vector bool short, vector signed short);
13977 vector signed short vec_add (vector signed short, vector bool short);
13978 vector signed short vec_add (vector signed short, vector signed short);
13979 vector unsigned short vec_add (vector bool short,
13980 vector unsigned short);
13981 vector unsigned short vec_add (vector unsigned short,
13982 vector bool short);
13983 vector unsigned short vec_add (vector unsigned short,
13984 vector unsigned short);
13985 vector signed int vec_add (vector bool int, vector signed int);
13986 vector signed int vec_add (vector signed int, vector bool int);
13987 vector signed int vec_add (vector signed int, vector signed int);
13988 vector unsigned int vec_add (vector bool int, vector unsigned int);
13989 vector unsigned int vec_add (vector unsigned int, vector bool int);
13990 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13991 vector float vec_add (vector float, vector float);
13992
13993 vector float vec_vaddfp (vector float, vector float);
13994
13995 vector signed int vec_vadduwm (vector bool int, vector signed int);
13996 vector signed int vec_vadduwm (vector signed int, vector bool int);
13997 vector signed int vec_vadduwm (vector signed int, vector signed int);
13998 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13999 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
14000 vector unsigned int vec_vadduwm (vector unsigned int,
14001 vector unsigned int);
14002
14003 vector signed short vec_vadduhm (vector bool short,
14004 vector signed short);
14005 vector signed short vec_vadduhm (vector signed short,
14006 vector bool short);
14007 vector signed short vec_vadduhm (vector signed short,
14008 vector signed short);
14009 vector unsigned short vec_vadduhm (vector bool short,
14010 vector unsigned short);
14011 vector unsigned short vec_vadduhm (vector unsigned short,
14012 vector bool short);
14013 vector unsigned short vec_vadduhm (vector unsigned short,
14014 vector unsigned short);
14015
14016 vector signed char vec_vaddubm (vector bool char, vector signed char);
14017 vector signed char vec_vaddubm (vector signed char, vector bool char);
14018 vector signed char vec_vaddubm (vector signed char, vector signed char);
14019 vector unsigned char vec_vaddubm (vector bool char,
14020 vector unsigned char);
14021 vector unsigned char vec_vaddubm (vector unsigned char,
14022 vector bool char);
14023 vector unsigned char vec_vaddubm (vector unsigned char,
14024 vector unsigned char);
14025
14026 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
14027
14028 vector unsigned char vec_adds (vector bool char, vector unsigned char);
14029 vector unsigned char vec_adds (vector unsigned char, vector bool char);
14030 vector unsigned char vec_adds (vector unsigned char,
14031 vector unsigned char);
14032 vector signed char vec_adds (vector bool char, vector signed char);
14033 vector signed char vec_adds (vector signed char, vector bool char);
14034 vector signed char vec_adds (vector signed char, vector signed char);
14035 vector unsigned short vec_adds (vector bool short,
14036 vector unsigned short);
14037 vector unsigned short vec_adds (vector unsigned short,
14038 vector bool short);
14039 vector unsigned short vec_adds (vector unsigned short,
14040 vector unsigned short);
14041 vector signed short vec_adds (vector bool short, vector signed short);
14042 vector signed short vec_adds (vector signed short, vector bool short);
14043 vector signed short vec_adds (vector signed short, vector signed short);
14044 vector unsigned int vec_adds (vector bool int, vector unsigned int);
14045 vector unsigned int vec_adds (vector unsigned int, vector bool int);
14046 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
14047 vector signed int vec_adds (vector bool int, vector signed int);
14048 vector signed int vec_adds (vector signed int, vector bool int);
14049 vector signed int vec_adds (vector signed int, vector signed int);
14050
14051 vector signed int vec_vaddsws (vector bool int, vector signed int);
14052 vector signed int vec_vaddsws (vector signed int, vector bool int);
14053 vector signed int vec_vaddsws (vector signed int, vector signed int);
14054
14055 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
14056 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
14057 vector unsigned int vec_vadduws (vector unsigned int,
14058 vector unsigned int);
14059
14060 vector signed short vec_vaddshs (vector bool short,
14061 vector signed short);
14062 vector signed short vec_vaddshs (vector signed short,
14063 vector bool short);
14064 vector signed short vec_vaddshs (vector signed short,
14065 vector signed short);
14066
14067 vector unsigned short vec_vadduhs (vector bool short,
14068 vector unsigned short);
14069 vector unsigned short vec_vadduhs (vector unsigned short,
14070 vector bool short);
14071 vector unsigned short vec_vadduhs (vector unsigned short,
14072 vector unsigned short);
14073
14074 vector signed char vec_vaddsbs (vector bool char, vector signed char);
14075 vector signed char vec_vaddsbs (vector signed char, vector bool char);
14076 vector signed char vec_vaddsbs (vector signed char, vector signed char);
14077
14078 vector unsigned char vec_vaddubs (vector bool char,
14079 vector unsigned char);
14080 vector unsigned char vec_vaddubs (vector unsigned char,
14081 vector bool char);
14082 vector unsigned char vec_vaddubs (vector unsigned char,
14083 vector unsigned char);
14084
14085 vector float vec_and (vector float, vector float);
14086 vector float vec_and (vector float, vector bool int);
14087 vector float vec_and (vector bool int, vector float);
14088 vector bool int vec_and (vector bool int, vector bool int);
14089 vector signed int vec_and (vector bool int, vector signed int);
14090 vector signed int vec_and (vector signed int, vector bool int);
14091 vector signed int vec_and (vector signed int, vector signed int);
14092 vector unsigned int vec_and (vector bool int, vector unsigned int);
14093 vector unsigned int vec_and (vector unsigned int, vector bool int);
14094 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
14095 vector bool short vec_and (vector bool short, vector bool short);
14096 vector signed short vec_and (vector bool short, vector signed short);
14097 vector signed short vec_and (vector signed short, vector bool short);
14098 vector signed short vec_and (vector signed short, vector signed short);
14099 vector unsigned short vec_and (vector bool short,
14100 vector unsigned short);
14101 vector unsigned short vec_and (vector unsigned short,
14102 vector bool short);
14103 vector unsigned short vec_and (vector unsigned short,
14104 vector unsigned short);
14105 vector signed char vec_and (vector bool char, vector signed char);
14106 vector bool char vec_and (vector bool char, vector bool char);
14107 vector signed char vec_and (vector signed char, vector bool char);
14108 vector signed char vec_and (vector signed char, vector signed char);
14109 vector unsigned char vec_and (vector bool char, vector unsigned char);
14110 vector unsigned char vec_and (vector unsigned char, vector bool char);
14111 vector unsigned char vec_and (vector unsigned char,
14112 vector unsigned char);
14113
14114 vector float vec_andc (vector float, vector float);
14115 vector float vec_andc (vector float, vector bool int);
14116 vector float vec_andc (vector bool int, vector float);
14117 vector bool int vec_andc (vector bool int, vector bool int);
14118 vector signed int vec_andc (vector bool int, vector signed int);
14119 vector signed int vec_andc (vector signed int, vector bool int);
14120 vector signed int vec_andc (vector signed int, vector signed int);
14121 vector unsigned int vec_andc (vector bool int, vector unsigned int);
14122 vector unsigned int vec_andc (vector unsigned int, vector bool int);
14123 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
14124 vector bool short vec_andc (vector bool short, vector bool short);
14125 vector signed short vec_andc (vector bool short, vector signed short);
14126 vector signed short vec_andc (vector signed short, vector bool short);
14127 vector signed short vec_andc (vector signed short, vector signed short);
14128 vector unsigned short vec_andc (vector bool short,
14129 vector unsigned short);
14130 vector unsigned short vec_andc (vector unsigned short,
14131 vector bool short);
14132 vector unsigned short vec_andc (vector unsigned short,
14133 vector unsigned short);
14134 vector signed char vec_andc (vector bool char, vector signed char);
14135 vector bool char vec_andc (vector bool char, vector bool char);
14136 vector signed char vec_andc (vector signed char, vector bool char);
14137 vector signed char vec_andc (vector signed char, vector signed char);
14138 vector unsigned char vec_andc (vector bool char, vector unsigned char);
14139 vector unsigned char vec_andc (vector unsigned char, vector bool char);
14140 vector unsigned char vec_andc (vector unsigned char,
14141 vector unsigned char);
14142
14143 vector unsigned char vec_avg (vector unsigned char,
14144 vector unsigned char);
14145 vector signed char vec_avg (vector signed char, vector signed char);
14146 vector unsigned short vec_avg (vector unsigned short,
14147 vector unsigned short);
14148 vector signed short vec_avg (vector signed short, vector signed short);
14149 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
14150 vector signed int vec_avg (vector signed int, vector signed int);
14151
14152 vector signed int vec_vavgsw (vector signed int, vector signed int);
14153
14154 vector unsigned int vec_vavguw (vector unsigned int,
14155 vector unsigned int);
14156
14157 vector signed short vec_vavgsh (vector signed short,
14158 vector signed short);
14159
14160 vector unsigned short vec_vavguh (vector unsigned short,
14161 vector unsigned short);
14162
14163 vector signed char vec_vavgsb (vector signed char, vector signed char);
14164
14165 vector unsigned char vec_vavgub (vector unsigned char,
14166 vector unsigned char);
14167
14168 vector float vec_copysign (vector float);
14169
14170 vector float vec_ceil (vector float);
14171
14172 vector signed int vec_cmpb (vector float, vector float);
14173
14174 vector bool char vec_cmpeq (vector signed char, vector signed char);
14175 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
14176 vector bool short vec_cmpeq (vector signed short, vector signed short);
14177 vector bool short vec_cmpeq (vector unsigned short,
14178 vector unsigned short);
14179 vector bool int vec_cmpeq (vector signed int, vector signed int);
14180 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
14181 vector bool int vec_cmpeq (vector float, vector float);
14182
14183 vector bool int vec_vcmpeqfp (vector float, vector float);
14184
14185 vector bool int vec_vcmpequw (vector signed int, vector signed int);
14186 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
14187
14188 vector bool short vec_vcmpequh (vector signed short,
14189 vector signed short);
14190 vector bool short vec_vcmpequh (vector unsigned short,
14191 vector unsigned short);
14192
14193 vector bool char vec_vcmpequb (vector signed char, vector signed char);
14194 vector bool char vec_vcmpequb (vector unsigned char,
14195 vector unsigned char);
14196
14197 vector bool int vec_cmpge (vector float, vector float);
14198
14199 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
14200 vector bool char vec_cmpgt (vector signed char, vector signed char);
14201 vector bool short vec_cmpgt (vector unsigned short,
14202 vector unsigned short);
14203 vector bool short vec_cmpgt (vector signed short, vector signed short);
14204 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
14205 vector bool int vec_cmpgt (vector signed int, vector signed int);
14206 vector bool int vec_cmpgt (vector float, vector float);
14207
14208 vector bool int vec_vcmpgtfp (vector float, vector float);
14209
14210 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
14211
14212 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
14213
14214 vector bool short vec_vcmpgtsh (vector signed short,
14215 vector signed short);
14216
14217 vector bool short vec_vcmpgtuh (vector unsigned short,
14218 vector unsigned short);
14219
14220 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
14221
14222 vector bool char vec_vcmpgtub (vector unsigned char,
14223 vector unsigned char);
14224
14225 vector bool int vec_cmple (vector float, vector float);
14226
14227 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
14228 vector bool char vec_cmplt (vector signed char, vector signed char);
14229 vector bool short vec_cmplt (vector unsigned short,
14230 vector unsigned short);
14231 vector bool short vec_cmplt (vector signed short, vector signed short);
14232 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
14233 vector bool int vec_cmplt (vector signed int, vector signed int);
14234 vector bool int vec_cmplt (vector float, vector float);
14235
14236 vector float vec_cpsgn (vector float, vector float);
14237
14238 vector float vec_ctf (vector unsigned int, const int);
14239 vector float vec_ctf (vector signed int, const int);
14240 vector double vec_ctf (vector unsigned long, const int);
14241 vector double vec_ctf (vector signed long, const int);
14242
14243 vector float vec_vcfsx (vector signed int, const int);
14244
14245 vector float vec_vcfux (vector unsigned int, const int);
14246
14247 vector signed int vec_cts (vector float, const int);
14248 vector signed long vec_cts (vector double, const int);
14249
14250 vector unsigned int vec_ctu (vector float, const int);
14251 vector unsigned long vec_ctu (vector double, const int);
14252
14253 void vec_dss (const int);
14254
14255 void vec_dssall (void);
14256
14257 void vec_dst (const vector unsigned char *, int, const int);
14258 void vec_dst (const vector signed char *, int, const int);
14259 void vec_dst (const vector bool char *, int, const int);
14260 void vec_dst (const vector unsigned short *, int, const int);
14261 void vec_dst (const vector signed short *, int, const int);
14262 void vec_dst (const vector bool short *, int, const int);
14263 void vec_dst (const vector pixel *, int, const int);
14264 void vec_dst (const vector unsigned int *, int, const int);
14265 void vec_dst (const vector signed int *, int, const int);
14266 void vec_dst (const vector bool int *, int, const int);
14267 void vec_dst (const vector float *, int, const int);
14268 void vec_dst (const unsigned char *, int, const int);
14269 void vec_dst (const signed char *, int, const int);
14270 void vec_dst (const unsigned short *, int, const int);
14271 void vec_dst (const short *, int, const int);
14272 void vec_dst (const unsigned int *, int, const int);
14273 void vec_dst (const int *, int, const int);
14274 void vec_dst (const unsigned long *, int, const int);
14275 void vec_dst (const long *, int, const int);
14276 void vec_dst (const float *, int, const int);
14277
14278 void vec_dstst (const vector unsigned char *, int, const int);
14279 void vec_dstst (const vector signed char *, int, const int);
14280 void vec_dstst (const vector bool char *, int, const int);
14281 void vec_dstst (const vector unsigned short *, int, const int);
14282 void vec_dstst (const vector signed short *, int, const int);
14283 void vec_dstst (const vector bool short *, int, const int);
14284 void vec_dstst (const vector pixel *, int, const int);
14285 void vec_dstst (const vector unsigned int *, int, const int);
14286 void vec_dstst (const vector signed int *, int, const int);
14287 void vec_dstst (const vector bool int *, int, const int);
14288 void vec_dstst (const vector float *, int, const int);
14289 void vec_dstst (const unsigned char *, int, const int);
14290 void vec_dstst (const signed char *, int, const int);
14291 void vec_dstst (const unsigned short *, int, const int);
14292 void vec_dstst (const short *, int, const int);
14293 void vec_dstst (const unsigned int *, int, const int);
14294 void vec_dstst (const int *, int, const int);
14295 void vec_dstst (const unsigned long *, int, const int);
14296 void vec_dstst (const long *, int, const int);
14297 void vec_dstst (const float *, int, const int);
14298
14299 void vec_dststt (const vector unsigned char *, int, const int);
14300 void vec_dststt (const vector signed char *, int, const int);
14301 void vec_dststt (const vector bool char *, int, const int);
14302 void vec_dststt (const vector unsigned short *, int, const int);
14303 void vec_dststt (const vector signed short *, int, const int);
14304 void vec_dststt (const vector bool short *, int, const int);
14305 void vec_dststt (const vector pixel *, int, const int);
14306 void vec_dststt (const vector unsigned int *, int, const int);
14307 void vec_dststt (const vector signed int *, int, const int);
14308 void vec_dststt (const vector bool int *, int, const int);
14309 void vec_dststt (const vector float *, int, const int);
14310 void vec_dststt (const unsigned char *, int, const int);
14311 void vec_dststt (const signed char *, int, const int);
14312 void vec_dststt (const unsigned short *, int, const int);
14313 void vec_dststt (const short *, int, const int);
14314 void vec_dststt (const unsigned int *, int, const int);
14315 void vec_dststt (const int *, int, const int);
14316 void vec_dststt (const unsigned long *, int, const int);
14317 void vec_dststt (const long *, int, const int);
14318 void vec_dststt (const float *, int, const int);
14319
14320 void vec_dstt (const vector unsigned char *, int, const int);
14321 void vec_dstt (const vector signed char *, int, const int);
14322 void vec_dstt (const vector bool char *, int, const int);
14323 void vec_dstt (const vector unsigned short *, int, const int);
14324 void vec_dstt (const vector signed short *, int, const int);
14325 void vec_dstt (const vector bool short *, int, const int);
14326 void vec_dstt (const vector pixel *, int, const int);
14327 void vec_dstt (const vector unsigned int *, int, const int);
14328 void vec_dstt (const vector signed int *, int, const int);
14329 void vec_dstt (const vector bool int *, int, const int);
14330 void vec_dstt (const vector float *, int, const int);
14331 void vec_dstt (const unsigned char *, int, const int);
14332 void vec_dstt (const signed char *, int, const int);
14333 void vec_dstt (const unsigned short *, int, const int);
14334 void vec_dstt (const short *, int, const int);
14335 void vec_dstt (const unsigned int *, int, const int);
14336 void vec_dstt (const int *, int, const int);
14337 void vec_dstt (const unsigned long *, int, const int);
14338 void vec_dstt (const long *, int, const int);
14339 void vec_dstt (const float *, int, const int);
14340
14341 vector float vec_expte (vector float);
14342
14343 vector float vec_floor (vector float);
14344
14345 vector float vec_ld (int, const vector float *);
14346 vector float vec_ld (int, const float *);
14347 vector bool int vec_ld (int, const vector bool int *);
14348 vector signed int vec_ld (int, const vector signed int *);
14349 vector signed int vec_ld (int, const int *);
14350 vector signed int vec_ld (int, const long *);
14351 vector unsigned int vec_ld (int, const vector unsigned int *);
14352 vector unsigned int vec_ld (int, const unsigned int *);
14353 vector unsigned int vec_ld (int, const unsigned long *);
14354 vector bool short vec_ld (int, const vector bool short *);
14355 vector pixel vec_ld (int, const vector pixel *);
14356 vector signed short vec_ld (int, const vector signed short *);
14357 vector signed short vec_ld (int, const short *);
14358 vector unsigned short vec_ld (int, const vector unsigned short *);
14359 vector unsigned short vec_ld (int, const unsigned short *);
14360 vector bool char vec_ld (int, const vector bool char *);
14361 vector signed char vec_ld (int, const vector signed char *);
14362 vector signed char vec_ld (int, const signed char *);
14363 vector unsigned char vec_ld (int, const vector unsigned char *);
14364 vector unsigned char vec_ld (int, const unsigned char *);
14365
14366 vector signed char vec_lde (int, const signed char *);
14367 vector unsigned char vec_lde (int, const unsigned char *);
14368 vector signed short vec_lde (int, const short *);
14369 vector unsigned short vec_lde (int, const unsigned short *);
14370 vector float vec_lde (int, const float *);
14371 vector signed int vec_lde (int, const int *);
14372 vector unsigned int vec_lde (int, const unsigned int *);
14373 vector signed int vec_lde (int, const long *);
14374 vector unsigned int vec_lde (int, const unsigned long *);
14375
14376 vector float vec_lvewx (int, float *);
14377 vector signed int vec_lvewx (int, int *);
14378 vector unsigned int vec_lvewx (int, unsigned int *);
14379 vector signed int vec_lvewx (int, long *);
14380 vector unsigned int vec_lvewx (int, unsigned long *);
14381
14382 vector signed short vec_lvehx (int, short *);
14383 vector unsigned short vec_lvehx (int, unsigned short *);
14384
14385 vector signed char vec_lvebx (int, char *);
14386 vector unsigned char vec_lvebx (int, unsigned char *);
14387
14388 vector float vec_ldl (int, const vector float *);
14389 vector float vec_ldl (int, const float *);
14390 vector bool int vec_ldl (int, const vector bool int *);
14391 vector signed int vec_ldl (int, const vector signed int *);
14392 vector signed int vec_ldl (int, const int *);
14393 vector signed int vec_ldl (int, const long *);
14394 vector unsigned int vec_ldl (int, const vector unsigned int *);
14395 vector unsigned int vec_ldl (int, const unsigned int *);
14396 vector unsigned int vec_ldl (int, const unsigned long *);
14397 vector bool short vec_ldl (int, const vector bool short *);
14398 vector pixel vec_ldl (int, const vector pixel *);
14399 vector signed short vec_ldl (int, const vector signed short *);
14400 vector signed short vec_ldl (int, const short *);
14401 vector unsigned short vec_ldl (int, const vector unsigned short *);
14402 vector unsigned short vec_ldl (int, const unsigned short *);
14403 vector bool char vec_ldl (int, const vector bool char *);
14404 vector signed char vec_ldl (int, const vector signed char *);
14405 vector signed char vec_ldl (int, const signed char *);
14406 vector unsigned char vec_ldl (int, const vector unsigned char *);
14407 vector unsigned char vec_ldl (int, const unsigned char *);
14408
14409 vector float vec_loge (vector float);
14410
14411 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14412 vector unsigned char vec_lvsl (int, const volatile signed char *);
14413 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14414 vector unsigned char vec_lvsl (int, const volatile short *);
14415 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14416 vector unsigned char vec_lvsl (int, const volatile int *);
14417 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14418 vector unsigned char vec_lvsl (int, const volatile long *);
14419 vector unsigned char vec_lvsl (int, const volatile float *);
14420
14421 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14422 vector unsigned char vec_lvsr (int, const volatile signed char *);
14423 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14424 vector unsigned char vec_lvsr (int, const volatile short *);
14425 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14426 vector unsigned char vec_lvsr (int, const volatile int *);
14427 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14428 vector unsigned char vec_lvsr (int, const volatile long *);
14429 vector unsigned char vec_lvsr (int, const volatile float *);
14430
14431 vector float vec_madd (vector float, vector float, vector float);
14432
14433 vector signed short vec_madds (vector signed short,
14434 vector signed short,
14435 vector signed short);
14436
14437 vector unsigned char vec_max (vector bool char, vector unsigned char);
14438 vector unsigned char vec_max (vector unsigned char, vector bool char);
14439 vector unsigned char vec_max (vector unsigned char,
14440 vector unsigned char);
14441 vector signed char vec_max (vector bool char, vector signed char);
14442 vector signed char vec_max (vector signed char, vector bool char);
14443 vector signed char vec_max (vector signed char, vector signed char);
14444 vector unsigned short vec_max (vector bool short,
14445 vector unsigned short);
14446 vector unsigned short vec_max (vector unsigned short,
14447 vector bool short);
14448 vector unsigned short vec_max (vector unsigned short,
14449 vector unsigned short);
14450 vector signed short vec_max (vector bool short, vector signed short);
14451 vector signed short vec_max (vector signed short, vector bool short);
14452 vector signed short vec_max (vector signed short, vector signed short);
14453 vector unsigned int vec_max (vector bool int, vector unsigned int);
14454 vector unsigned int vec_max (vector unsigned int, vector bool int);
14455 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14456 vector signed int vec_max (vector bool int, vector signed int);
14457 vector signed int vec_max (vector signed int, vector bool int);
14458 vector signed int vec_max (vector signed int, vector signed int);
14459 vector float vec_max (vector float, vector float);
14460
14461 vector float vec_vmaxfp (vector float, vector float);
14462
14463 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14464 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14465 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14466
14467 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14468 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14469 vector unsigned int vec_vmaxuw (vector unsigned int,
14470 vector unsigned int);
14471
14472 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14473 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14474 vector signed short vec_vmaxsh (vector signed short,
14475 vector signed short);
14476
14477 vector unsigned short vec_vmaxuh (vector bool short,
14478 vector unsigned short);
14479 vector unsigned short vec_vmaxuh (vector unsigned short,
14480 vector bool short);
14481 vector unsigned short vec_vmaxuh (vector unsigned short,
14482 vector unsigned short);
14483
14484 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14485 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14486 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14487
14488 vector unsigned char vec_vmaxub (vector bool char,
14489 vector unsigned char);
14490 vector unsigned char vec_vmaxub (vector unsigned char,
14491 vector bool char);
14492 vector unsigned char vec_vmaxub (vector unsigned char,
14493 vector unsigned char);
14494
14495 vector bool char vec_mergeh (vector bool char, vector bool char);
14496 vector signed char vec_mergeh (vector signed char, vector signed char);
14497 vector unsigned char vec_mergeh (vector unsigned char,
14498 vector unsigned char);
14499 vector bool short vec_mergeh (vector bool short, vector bool short);
14500 vector pixel vec_mergeh (vector pixel, vector pixel);
14501 vector signed short vec_mergeh (vector signed short,
14502 vector signed short);
14503 vector unsigned short vec_mergeh (vector unsigned short,
14504 vector unsigned short);
14505 vector float vec_mergeh (vector float, vector float);
14506 vector bool int vec_mergeh (vector bool int, vector bool int);
14507 vector signed int vec_mergeh (vector signed int, vector signed int);
14508 vector unsigned int vec_mergeh (vector unsigned int,
14509 vector unsigned int);
14510
14511 vector float vec_vmrghw (vector float, vector float);
14512 vector bool int vec_vmrghw (vector bool int, vector bool int);
14513 vector signed int vec_vmrghw (vector signed int, vector signed int);
14514 vector unsigned int vec_vmrghw (vector unsigned int,
14515 vector unsigned int);
14516
14517 vector bool short vec_vmrghh (vector bool short, vector bool short);
14518 vector signed short vec_vmrghh (vector signed short,
14519 vector signed short);
14520 vector unsigned short vec_vmrghh (vector unsigned short,
14521 vector unsigned short);
14522 vector pixel vec_vmrghh (vector pixel, vector pixel);
14523
14524 vector bool char vec_vmrghb (vector bool char, vector bool char);
14525 vector signed char vec_vmrghb (vector signed char, vector signed char);
14526 vector unsigned char vec_vmrghb (vector unsigned char,
14527 vector unsigned char);
14528
14529 vector bool char vec_mergel (vector bool char, vector bool char);
14530 vector signed char vec_mergel (vector signed char, vector signed char);
14531 vector unsigned char vec_mergel (vector unsigned char,
14532 vector unsigned char);
14533 vector bool short vec_mergel (vector bool short, vector bool short);
14534 vector pixel vec_mergel (vector pixel, vector pixel);
14535 vector signed short vec_mergel (vector signed short,
14536 vector signed short);
14537 vector unsigned short vec_mergel (vector unsigned short,
14538 vector unsigned short);
14539 vector float vec_mergel (vector float, vector float);
14540 vector bool int vec_mergel (vector bool int, vector bool int);
14541 vector signed int vec_mergel (vector signed int, vector signed int);
14542 vector unsigned int vec_mergel (vector unsigned int,
14543 vector unsigned int);
14544
14545 vector float vec_vmrglw (vector float, vector float);
14546 vector signed int vec_vmrglw (vector signed int, vector signed int);
14547 vector unsigned int vec_vmrglw (vector unsigned int,
14548 vector unsigned int);
14549 vector bool int vec_vmrglw (vector bool int, vector bool int);
14550
14551 vector bool short vec_vmrglh (vector bool short, vector bool short);
14552 vector signed short vec_vmrglh (vector signed short,
14553 vector signed short);
14554 vector unsigned short vec_vmrglh (vector unsigned short,
14555 vector unsigned short);
14556 vector pixel vec_vmrglh (vector pixel, vector pixel);
14557
14558 vector bool char vec_vmrglb (vector bool char, vector bool char);
14559 vector signed char vec_vmrglb (vector signed char, vector signed char);
14560 vector unsigned char vec_vmrglb (vector unsigned char,
14561 vector unsigned char);
14562
14563 vector unsigned short vec_mfvscr (void);
14564
14565 vector unsigned char vec_min (vector bool char, vector unsigned char);
14566 vector unsigned char vec_min (vector unsigned char, vector bool char);
14567 vector unsigned char vec_min (vector unsigned char,
14568 vector unsigned char);
14569 vector signed char vec_min (vector bool char, vector signed char);
14570 vector signed char vec_min (vector signed char, vector bool char);
14571 vector signed char vec_min (vector signed char, vector signed char);
14572 vector unsigned short vec_min (vector bool short,
14573 vector unsigned short);
14574 vector unsigned short vec_min (vector unsigned short,
14575 vector bool short);
14576 vector unsigned short vec_min (vector unsigned short,
14577 vector unsigned short);
14578 vector signed short vec_min (vector bool short, vector signed short);
14579 vector signed short vec_min (vector signed short, vector bool short);
14580 vector signed short vec_min (vector signed short, vector signed short);
14581 vector unsigned int vec_min (vector bool int, vector unsigned int);
14582 vector unsigned int vec_min (vector unsigned int, vector bool int);
14583 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14584 vector signed int vec_min (vector bool int, vector signed int);
14585 vector signed int vec_min (vector signed int, vector bool int);
14586 vector signed int vec_min (vector signed int, vector signed int);
14587 vector float vec_min (vector float, vector float);
14588
14589 vector float vec_vminfp (vector float, vector float);
14590
14591 vector signed int vec_vminsw (vector bool int, vector signed int);
14592 vector signed int vec_vminsw (vector signed int, vector bool int);
14593 vector signed int vec_vminsw (vector signed int, vector signed int);
14594
14595 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14596 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14597 vector unsigned int vec_vminuw (vector unsigned int,
14598 vector unsigned int);
14599
14600 vector signed short vec_vminsh (vector bool short, vector signed short);
14601 vector signed short vec_vminsh (vector signed short, vector bool short);
14602 vector signed short vec_vminsh (vector signed short,
14603 vector signed short);
14604
14605 vector unsigned short vec_vminuh (vector bool short,
14606 vector unsigned short);
14607 vector unsigned short vec_vminuh (vector unsigned short,
14608 vector bool short);
14609 vector unsigned short vec_vminuh (vector unsigned short,
14610 vector unsigned short);
14611
14612 vector signed char vec_vminsb (vector bool char, vector signed char);
14613 vector signed char vec_vminsb (vector signed char, vector bool char);
14614 vector signed char vec_vminsb (vector signed char, vector signed char);
14615
14616 vector unsigned char vec_vminub (vector bool char,
14617 vector unsigned char);
14618 vector unsigned char vec_vminub (vector unsigned char,
14619 vector bool char);
14620 vector unsigned char vec_vminub (vector unsigned char,
14621 vector unsigned char);
14622
14623 vector signed short vec_mladd (vector signed short,
14624 vector signed short,
14625 vector signed short);
14626 vector signed short vec_mladd (vector signed short,
14627 vector unsigned short,
14628 vector unsigned short);
14629 vector signed short vec_mladd (vector unsigned short,
14630 vector signed short,
14631 vector signed short);
14632 vector unsigned short vec_mladd (vector unsigned short,
14633 vector unsigned short,
14634 vector unsigned short);
14635
14636 vector signed short vec_mradds (vector signed short,
14637 vector signed short,
14638 vector signed short);
14639
14640 vector unsigned int vec_msum (vector unsigned char,
14641 vector unsigned char,
14642 vector unsigned int);
14643 vector signed int vec_msum (vector signed char,
14644 vector unsigned char,
14645 vector signed int);
14646 vector unsigned int vec_msum (vector unsigned short,
14647 vector unsigned short,
14648 vector unsigned int);
14649 vector signed int vec_msum (vector signed short,
14650 vector signed short,
14651 vector signed int);
14652
14653 vector signed int vec_vmsumshm (vector signed short,
14654 vector signed short,
14655 vector signed int);
14656
14657 vector unsigned int vec_vmsumuhm (vector unsigned short,
14658 vector unsigned short,
14659 vector unsigned int);
14660
14661 vector signed int vec_vmsummbm (vector signed char,
14662 vector unsigned char,
14663 vector signed int);
14664
14665 vector unsigned int vec_vmsumubm (vector unsigned char,
14666 vector unsigned char,
14667 vector unsigned int);
14668
14669 vector unsigned int vec_msums (vector unsigned short,
14670 vector unsigned short,
14671 vector unsigned int);
14672 vector signed int vec_msums (vector signed short,
14673 vector signed short,
14674 vector signed int);
14675
14676 vector signed int vec_vmsumshs (vector signed short,
14677 vector signed short,
14678 vector signed int);
14679
14680 vector unsigned int vec_vmsumuhs (vector unsigned short,
14681 vector unsigned short,
14682 vector unsigned int);
14683
14684 void vec_mtvscr (vector signed int);
14685 void vec_mtvscr (vector unsigned int);
14686 void vec_mtvscr (vector bool int);
14687 void vec_mtvscr (vector signed short);
14688 void vec_mtvscr (vector unsigned short);
14689 void vec_mtvscr (vector bool short);
14690 void vec_mtvscr (vector pixel);
14691 void vec_mtvscr (vector signed char);
14692 void vec_mtvscr (vector unsigned char);
14693 void vec_mtvscr (vector bool char);
14694
14695 vector unsigned short vec_mule (vector unsigned char,
14696 vector unsigned char);
14697 vector signed short vec_mule (vector signed char,
14698 vector signed char);
14699 vector unsigned int vec_mule (vector unsigned short,
14700 vector unsigned short);
14701 vector signed int vec_mule (vector signed short, vector signed short);
14702
14703 vector signed int vec_vmulesh (vector signed short,
14704 vector signed short);
14705
14706 vector unsigned int vec_vmuleuh (vector unsigned short,
14707 vector unsigned short);
14708
14709 vector signed short vec_vmulesb (vector signed char,
14710 vector signed char);
14711
14712 vector unsigned short vec_vmuleub (vector unsigned char,
14713 vector unsigned char);
14714
14715 vector unsigned short vec_mulo (vector unsigned char,
14716 vector unsigned char);
14717 vector signed short vec_mulo (vector signed char, vector signed char);
14718 vector unsigned int vec_mulo (vector unsigned short,
14719 vector unsigned short);
14720 vector signed int vec_mulo (vector signed short, vector signed short);
14721
14722 vector signed int vec_vmulosh (vector signed short,
14723 vector signed short);
14724
14725 vector unsigned int vec_vmulouh (vector unsigned short,
14726 vector unsigned short);
14727
14728 vector signed short vec_vmulosb (vector signed char,
14729 vector signed char);
14730
14731 vector unsigned short vec_vmuloub (vector unsigned char,
14732 vector unsigned char);
14733
14734 vector float vec_nmsub (vector float, vector float, vector float);
14735
14736 vector float vec_nor (vector float, vector float);
14737 vector signed int vec_nor (vector signed int, vector signed int);
14738 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14739 vector bool int vec_nor (vector bool int, vector bool int);
14740 vector signed short vec_nor (vector signed short, vector signed short);
14741 vector unsigned short vec_nor (vector unsigned short,
14742 vector unsigned short);
14743 vector bool short vec_nor (vector bool short, vector bool short);
14744 vector signed char vec_nor (vector signed char, vector signed char);
14745 vector unsigned char vec_nor (vector unsigned char,
14746 vector unsigned char);
14747 vector bool char vec_nor (vector bool char, vector bool char);
14748
14749 vector float vec_or (vector float, vector float);
14750 vector float vec_or (vector float, vector bool int);
14751 vector float vec_or (vector bool int, vector float);
14752 vector bool int vec_or (vector bool int, vector bool int);
14753 vector signed int vec_or (vector bool int, vector signed int);
14754 vector signed int vec_or (vector signed int, vector bool int);
14755 vector signed int vec_or (vector signed int, vector signed int);
14756 vector unsigned int vec_or (vector bool int, vector unsigned int);
14757 vector unsigned int vec_or (vector unsigned int, vector bool int);
14758 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14759 vector bool short vec_or (vector bool short, vector bool short);
14760 vector signed short vec_or (vector bool short, vector signed short);
14761 vector signed short vec_or (vector signed short, vector bool short);
14762 vector signed short vec_or (vector signed short, vector signed short);
14763 vector unsigned short vec_or (vector bool short, vector unsigned short);
14764 vector unsigned short vec_or (vector unsigned short, vector bool short);
14765 vector unsigned short vec_or (vector unsigned short,
14766 vector unsigned short);
14767 vector signed char vec_or (vector bool char, vector signed char);
14768 vector bool char vec_or (vector bool char, vector bool char);
14769 vector signed char vec_or (vector signed char, vector bool char);
14770 vector signed char vec_or (vector signed char, vector signed char);
14771 vector unsigned char vec_or (vector bool char, vector unsigned char);
14772 vector unsigned char vec_or (vector unsigned char, vector bool char);
14773 vector unsigned char vec_or (vector unsigned char,
14774 vector unsigned char);
14775
14776 vector signed char vec_pack (vector signed short, vector signed short);
14777 vector unsigned char vec_pack (vector unsigned short,
14778 vector unsigned short);
14779 vector bool char vec_pack (vector bool short, vector bool short);
14780 vector signed short vec_pack (vector signed int, vector signed int);
14781 vector unsigned short vec_pack (vector unsigned int,
14782 vector unsigned int);
14783 vector bool short vec_pack (vector bool int, vector bool int);
14784
14785 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14786 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14787 vector unsigned short vec_vpkuwum (vector unsigned int,
14788 vector unsigned int);
14789
14790 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14791 vector signed char vec_vpkuhum (vector signed short,
14792 vector signed short);
14793 vector unsigned char vec_vpkuhum (vector unsigned short,
14794 vector unsigned short);
14795
14796 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14797
14798 vector unsigned char vec_packs (vector unsigned short,
14799 vector unsigned short);
14800 vector signed char vec_packs (vector signed short, vector signed short);
14801 vector unsigned short vec_packs (vector unsigned int,
14802 vector unsigned int);
14803 vector signed short vec_packs (vector signed int, vector signed int);
14804
14805 vector signed short vec_vpkswss (vector signed int, vector signed int);
14806
14807 vector unsigned short vec_vpkuwus (vector unsigned int,
14808 vector unsigned int);
14809
14810 vector signed char vec_vpkshss (vector signed short,
14811 vector signed short);
14812
14813 vector unsigned char vec_vpkuhus (vector unsigned short,
14814 vector unsigned short);
14815
14816 vector unsigned char vec_packsu (vector unsigned short,
14817 vector unsigned short);
14818 vector unsigned char vec_packsu (vector signed short,
14819 vector signed short);
14820 vector unsigned short vec_packsu (vector unsigned int,
14821 vector unsigned int);
14822 vector unsigned short vec_packsu (vector signed int, vector signed int);
14823
14824 vector unsigned short vec_vpkswus (vector signed int,
14825 vector signed int);
14826
14827 vector unsigned char vec_vpkshus (vector signed short,
14828 vector signed short);
14829
14830 vector float vec_perm (vector float,
14831 vector float,
14832 vector unsigned char);
14833 vector signed int vec_perm (vector signed int,
14834 vector signed int,
14835 vector unsigned char);
14836 vector unsigned int vec_perm (vector unsigned int,
14837 vector unsigned int,
14838 vector unsigned char);
14839 vector bool int vec_perm (vector bool int,
14840 vector bool int,
14841 vector unsigned char);
14842 vector signed short vec_perm (vector signed short,
14843 vector signed short,
14844 vector unsigned char);
14845 vector unsigned short vec_perm (vector unsigned short,
14846 vector unsigned short,
14847 vector unsigned char);
14848 vector bool short vec_perm (vector bool short,
14849 vector bool short,
14850 vector unsigned char);
14851 vector pixel vec_perm (vector pixel,
14852 vector pixel,
14853 vector unsigned char);
14854 vector signed char vec_perm (vector signed char,
14855 vector signed char,
14856 vector unsigned char);
14857 vector unsigned char vec_perm (vector unsigned char,
14858 vector unsigned char,
14859 vector unsigned char);
14860 vector bool char vec_perm (vector bool char,
14861 vector bool char,
14862 vector unsigned char);
14863
14864 vector float vec_re (vector float);
14865
14866 vector signed char vec_rl (vector signed char,
14867 vector unsigned char);
14868 vector unsigned char vec_rl (vector unsigned char,
14869 vector unsigned char);
14870 vector signed short vec_rl (vector signed short, vector unsigned short);
14871 vector unsigned short vec_rl (vector unsigned short,
14872 vector unsigned short);
14873 vector signed int vec_rl (vector signed int, vector unsigned int);
14874 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14875
14876 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14877 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14878
14879 vector signed short vec_vrlh (vector signed short,
14880 vector unsigned short);
14881 vector unsigned short vec_vrlh (vector unsigned short,
14882 vector unsigned short);
14883
14884 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14885 vector unsigned char vec_vrlb (vector unsigned char,
14886 vector unsigned char);
14887
14888 vector float vec_round (vector float);
14889
14890 vector float vec_recip (vector float, vector float);
14891
14892 vector float vec_rsqrt (vector float);
14893
14894 vector float vec_rsqrte (vector float);
14895
14896 vector float vec_sel (vector float, vector float, vector bool int);
14897 vector float vec_sel (vector float, vector float, vector unsigned int);
14898 vector signed int vec_sel (vector signed int,
14899 vector signed int,
14900 vector bool int);
14901 vector signed int vec_sel (vector signed int,
14902 vector signed int,
14903 vector unsigned int);
14904 vector unsigned int vec_sel (vector unsigned int,
14905 vector unsigned int,
14906 vector bool int);
14907 vector unsigned int vec_sel (vector unsigned int,
14908 vector unsigned int,
14909 vector unsigned int);
14910 vector bool int vec_sel (vector bool int,
14911 vector bool int,
14912 vector bool int);
14913 vector bool int vec_sel (vector bool int,
14914 vector bool int,
14915 vector unsigned int);
14916 vector signed short vec_sel (vector signed short,
14917 vector signed short,
14918 vector bool short);
14919 vector signed short vec_sel (vector signed short,
14920 vector signed short,
14921 vector unsigned short);
14922 vector unsigned short vec_sel (vector unsigned short,
14923 vector unsigned short,
14924 vector bool short);
14925 vector unsigned short vec_sel (vector unsigned short,
14926 vector unsigned short,
14927 vector unsigned short);
14928 vector bool short vec_sel (vector bool short,
14929 vector bool short,
14930 vector bool short);
14931 vector bool short vec_sel (vector bool short,
14932 vector bool short,
14933 vector unsigned short);
14934 vector signed char vec_sel (vector signed char,
14935 vector signed char,
14936 vector bool char);
14937 vector signed char vec_sel (vector signed char,
14938 vector signed char,
14939 vector unsigned char);
14940 vector unsigned char vec_sel (vector unsigned char,
14941 vector unsigned char,
14942 vector bool char);
14943 vector unsigned char vec_sel (vector unsigned char,
14944 vector unsigned char,
14945 vector unsigned char);
14946 vector bool char vec_sel (vector bool char,
14947 vector bool char,
14948 vector bool char);
14949 vector bool char vec_sel (vector bool char,
14950 vector bool char,
14951 vector unsigned char);
14952
14953 vector signed char vec_sl (vector signed char,
14954 vector unsigned char);
14955 vector unsigned char vec_sl (vector unsigned char,
14956 vector unsigned char);
14957 vector signed short vec_sl (vector signed short, vector unsigned short);
14958 vector unsigned short vec_sl (vector unsigned short,
14959 vector unsigned short);
14960 vector signed int vec_sl (vector signed int, vector unsigned int);
14961 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14962
14963 vector signed int vec_vslw (vector signed int, vector unsigned int);
14964 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14965
14966 vector signed short vec_vslh (vector signed short,
14967 vector unsigned short);
14968 vector unsigned short vec_vslh (vector unsigned short,
14969 vector unsigned short);
14970
14971 vector signed char vec_vslb (vector signed char, vector unsigned char);
14972 vector unsigned char vec_vslb (vector unsigned char,
14973 vector unsigned char);
14974
14975 vector float vec_sld (vector float, vector float, const int);
14976 vector signed int vec_sld (vector signed int,
14977 vector signed int,
14978 const int);
14979 vector unsigned int vec_sld (vector unsigned int,
14980 vector unsigned int,
14981 const int);
14982 vector bool int vec_sld (vector bool int,
14983 vector bool int,
14984 const int);
14985 vector signed short vec_sld (vector signed short,
14986 vector signed short,
14987 const int);
14988 vector unsigned short vec_sld (vector unsigned short,
14989 vector unsigned short,
14990 const int);
14991 vector bool short vec_sld (vector bool short,
14992 vector bool short,
14993 const int);
14994 vector pixel vec_sld (vector pixel,
14995 vector pixel,
14996 const int);
14997 vector signed char vec_sld (vector signed char,
14998 vector signed char,
14999 const int);
15000 vector unsigned char vec_sld (vector unsigned char,
15001 vector unsigned char,
15002 const int);
15003 vector bool char vec_sld (vector bool char,
15004 vector bool char,
15005 const int);
15006
15007 vector signed int vec_sll (vector signed int,
15008 vector unsigned int);
15009 vector signed int vec_sll (vector signed int,
15010 vector unsigned short);
15011 vector signed int vec_sll (vector signed int,
15012 vector unsigned char);
15013 vector unsigned int vec_sll (vector unsigned int,
15014 vector unsigned int);
15015 vector unsigned int vec_sll (vector unsigned int,
15016 vector unsigned short);
15017 vector unsigned int vec_sll (vector unsigned int,
15018 vector unsigned char);
15019 vector bool int vec_sll (vector bool int,
15020 vector unsigned int);
15021 vector bool int vec_sll (vector bool int,
15022 vector unsigned short);
15023 vector bool int vec_sll (vector bool int,
15024 vector unsigned char);
15025 vector signed short vec_sll (vector signed short,
15026 vector unsigned int);
15027 vector signed short vec_sll (vector signed short,
15028 vector unsigned short);
15029 vector signed short vec_sll (vector signed short,
15030 vector unsigned char);
15031 vector unsigned short vec_sll (vector unsigned short,
15032 vector unsigned int);
15033 vector unsigned short vec_sll (vector unsigned short,
15034 vector unsigned short);
15035 vector unsigned short vec_sll (vector unsigned short,
15036 vector unsigned char);
15037 vector bool short vec_sll (vector bool short, vector unsigned int);
15038 vector bool short vec_sll (vector bool short, vector unsigned short);
15039 vector bool short vec_sll (vector bool short, vector unsigned char);
15040 vector pixel vec_sll (vector pixel, vector unsigned int);
15041 vector pixel vec_sll (vector pixel, vector unsigned short);
15042 vector pixel vec_sll (vector pixel, vector unsigned char);
15043 vector signed char vec_sll (vector signed char, vector unsigned int);
15044 vector signed char vec_sll (vector signed char, vector unsigned short);
15045 vector signed char vec_sll (vector signed char, vector unsigned char);
15046 vector unsigned char vec_sll (vector unsigned char,
15047 vector unsigned int);
15048 vector unsigned char vec_sll (vector unsigned char,
15049 vector unsigned short);
15050 vector unsigned char vec_sll (vector unsigned char,
15051 vector unsigned char);
15052 vector bool char vec_sll (vector bool char, vector unsigned int);
15053 vector bool char vec_sll (vector bool char, vector unsigned short);
15054 vector bool char vec_sll (vector bool char, vector unsigned char);
15055
15056 vector float vec_slo (vector float, vector signed char);
15057 vector float vec_slo (vector float, vector unsigned char);
15058 vector signed int vec_slo (vector signed int, vector signed char);
15059 vector signed int vec_slo (vector signed int, vector unsigned char);
15060 vector unsigned int vec_slo (vector unsigned int, vector signed char);
15061 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
15062 vector signed short vec_slo (vector signed short, vector signed char);
15063 vector signed short vec_slo (vector signed short, vector unsigned char);
15064 vector unsigned short vec_slo (vector unsigned short,
15065 vector signed char);
15066 vector unsigned short vec_slo (vector unsigned short,
15067 vector unsigned char);
15068 vector pixel vec_slo (vector pixel, vector signed char);
15069 vector pixel vec_slo (vector pixel, vector unsigned char);
15070 vector signed char vec_slo (vector signed char, vector signed char);
15071 vector signed char vec_slo (vector signed char, vector unsigned char);
15072 vector unsigned char vec_slo (vector unsigned char, vector signed char);
15073 vector unsigned char vec_slo (vector unsigned char,
15074 vector unsigned char);
15075
15076 vector signed char vec_splat (vector signed char, const int);
15077 vector unsigned char vec_splat (vector unsigned char, const int);
15078 vector bool char vec_splat (vector bool char, const int);
15079 vector signed short vec_splat (vector signed short, const int);
15080 vector unsigned short vec_splat (vector unsigned short, const int);
15081 vector bool short vec_splat (vector bool short, const int);
15082 vector pixel vec_splat (vector pixel, const int);
15083 vector float vec_splat (vector float, const int);
15084 vector signed int vec_splat (vector signed int, const int);
15085 vector unsigned int vec_splat (vector unsigned int, const int);
15086 vector bool int vec_splat (vector bool int, const int);
15087 vector signed long vec_splat (vector signed long, const int);
15088 vector unsigned long vec_splat (vector unsigned long, const int);
15089
15090 vector signed char vec_splats (signed char);
15091 vector unsigned char vec_splats (unsigned char);
15092 vector signed short vec_splats (signed short);
15093 vector unsigned short vec_splats (unsigned short);
15094 vector signed int vec_splats (signed int);
15095 vector unsigned int vec_splats (unsigned int);
15096 vector float vec_splats (float);
15097
15098 vector float vec_vspltw (vector float, const int);
15099 vector signed int vec_vspltw (vector signed int, const int);
15100 vector unsigned int vec_vspltw (vector unsigned int, const int);
15101 vector bool int vec_vspltw (vector bool int, const int);
15102
15103 vector bool short vec_vsplth (vector bool short, const int);
15104 vector signed short vec_vsplth (vector signed short, const int);
15105 vector unsigned short vec_vsplth (vector unsigned short, const int);
15106 vector pixel vec_vsplth (vector pixel, const int);
15107
15108 vector signed char vec_vspltb (vector signed char, const int);
15109 vector unsigned char vec_vspltb (vector unsigned char, const int);
15110 vector bool char vec_vspltb (vector bool char, const int);
15111
15112 vector signed char vec_splat_s8 (const int);
15113
15114 vector signed short vec_splat_s16 (const int);
15115
15116 vector signed int vec_splat_s32 (const int);
15117
15118 vector unsigned char vec_splat_u8 (const int);
15119
15120 vector unsigned short vec_splat_u16 (const int);
15121
15122 vector unsigned int vec_splat_u32 (const int);
15123
15124 vector signed char vec_sr (vector signed char, vector unsigned char);
15125 vector unsigned char vec_sr (vector unsigned char,
15126 vector unsigned char);
15127 vector signed short vec_sr (vector signed short,
15128 vector unsigned short);
15129 vector unsigned short vec_sr (vector unsigned short,
15130 vector unsigned short);
15131 vector signed int vec_sr (vector signed int, vector unsigned int);
15132 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
15133
15134 vector signed int vec_vsrw (vector signed int, vector unsigned int);
15135 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
15136
15137 vector signed short vec_vsrh (vector signed short,
15138 vector unsigned short);
15139 vector unsigned short vec_vsrh (vector unsigned short,
15140 vector unsigned short);
15141
15142 vector signed char vec_vsrb (vector signed char, vector unsigned char);
15143 vector unsigned char vec_vsrb (vector unsigned char,
15144 vector unsigned char);
15145
15146 vector signed char vec_sra (vector signed char, vector unsigned char);
15147 vector unsigned char vec_sra (vector unsigned char,
15148 vector unsigned char);
15149 vector signed short vec_sra (vector signed short,
15150 vector unsigned short);
15151 vector unsigned short vec_sra (vector unsigned short,
15152 vector unsigned short);
15153 vector signed int vec_sra (vector signed int, vector unsigned int);
15154 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
15155
15156 vector signed int vec_vsraw (vector signed int, vector unsigned int);
15157 vector unsigned int vec_vsraw (vector unsigned int,
15158 vector unsigned int);
15159
15160 vector signed short vec_vsrah (vector signed short,
15161 vector unsigned short);
15162 vector unsigned short vec_vsrah (vector unsigned short,
15163 vector unsigned short);
15164
15165 vector signed char vec_vsrab (vector signed char, vector unsigned char);
15166 vector unsigned char vec_vsrab (vector unsigned char,
15167 vector unsigned char);
15168
15169 vector signed int vec_srl (vector signed int, vector unsigned int);
15170 vector signed int vec_srl (vector signed int, vector unsigned short);
15171 vector signed int vec_srl (vector signed int, vector unsigned char);
15172 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
15173 vector unsigned int vec_srl (vector unsigned int,
15174 vector unsigned short);
15175 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
15176 vector bool int vec_srl (vector bool int, vector unsigned int);
15177 vector bool int vec_srl (vector bool int, vector unsigned short);
15178 vector bool int vec_srl (vector bool int, vector unsigned char);
15179 vector signed short vec_srl (vector signed short, vector unsigned int);
15180 vector signed short vec_srl (vector signed short,
15181 vector unsigned short);
15182 vector signed short vec_srl (vector signed short, vector unsigned char);
15183 vector unsigned short vec_srl (vector unsigned short,
15184 vector unsigned int);
15185 vector unsigned short vec_srl (vector unsigned short,
15186 vector unsigned short);
15187 vector unsigned short vec_srl (vector unsigned short,
15188 vector unsigned char);
15189 vector bool short vec_srl (vector bool short, vector unsigned int);
15190 vector bool short vec_srl (vector bool short, vector unsigned short);
15191 vector bool short vec_srl (vector bool short, vector unsigned char);
15192 vector pixel vec_srl (vector pixel, vector unsigned int);
15193 vector pixel vec_srl (vector pixel, vector unsigned short);
15194 vector pixel vec_srl (vector pixel, vector unsigned char);
15195 vector signed char vec_srl (vector signed char, vector unsigned int);
15196 vector signed char vec_srl (vector signed char, vector unsigned short);
15197 vector signed char vec_srl (vector signed char, vector unsigned char);
15198 vector unsigned char vec_srl (vector unsigned char,
15199 vector unsigned int);
15200 vector unsigned char vec_srl (vector unsigned char,
15201 vector unsigned short);
15202 vector unsigned char vec_srl (vector unsigned char,
15203 vector unsigned char);
15204 vector bool char vec_srl (vector bool char, vector unsigned int);
15205 vector bool char vec_srl (vector bool char, vector unsigned short);
15206 vector bool char vec_srl (vector bool char, vector unsigned char);
15207
15208 vector float vec_sro (vector float, vector signed char);
15209 vector float vec_sro (vector float, vector unsigned char);
15210 vector signed int vec_sro (vector signed int, vector signed char);
15211 vector signed int vec_sro (vector signed int, vector unsigned char);
15212 vector unsigned int vec_sro (vector unsigned int, vector signed char);
15213 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
15214 vector signed short vec_sro (vector signed short, vector signed char);
15215 vector signed short vec_sro (vector signed short, vector unsigned char);
15216 vector unsigned short vec_sro (vector unsigned short,
15217 vector signed char);
15218 vector unsigned short vec_sro (vector unsigned short,
15219 vector unsigned char);
15220 vector pixel vec_sro (vector pixel, vector signed char);
15221 vector pixel vec_sro (vector pixel, vector unsigned char);
15222 vector signed char vec_sro (vector signed char, vector signed char);
15223 vector signed char vec_sro (vector signed char, vector unsigned char);
15224 vector unsigned char vec_sro (vector unsigned char, vector signed char);
15225 vector unsigned char vec_sro (vector unsigned char,
15226 vector unsigned char);
15227
15228 void vec_st (vector float, int, vector float *);
15229 void vec_st (vector float, int, float *);
15230 void vec_st (vector signed int, int, vector signed int *);
15231 void vec_st (vector signed int, int, int *);
15232 void vec_st (vector unsigned int, int, vector unsigned int *);
15233 void vec_st (vector unsigned int, int, unsigned int *);
15234 void vec_st (vector bool int, int, vector bool int *);
15235 void vec_st (vector bool int, int, unsigned int *);
15236 void vec_st (vector bool int, int, int *);
15237 void vec_st (vector signed short, int, vector signed short *);
15238 void vec_st (vector signed short, int, short *);
15239 void vec_st (vector unsigned short, int, vector unsigned short *);
15240 void vec_st (vector unsigned short, int, unsigned short *);
15241 void vec_st (vector bool short, int, vector bool short *);
15242 void vec_st (vector bool short, int, unsigned short *);
15243 void vec_st (vector pixel, int, vector pixel *);
15244 void vec_st (vector pixel, int, unsigned short *);
15245 void vec_st (vector pixel, int, short *);
15246 void vec_st (vector bool short, int, short *);
15247 void vec_st (vector signed char, int, vector signed char *);
15248 void vec_st (vector signed char, int, signed char *);
15249 void vec_st (vector unsigned char, int, vector unsigned char *);
15250 void vec_st (vector unsigned char, int, unsigned char *);
15251 void vec_st (vector bool char, int, vector bool char *);
15252 void vec_st (vector bool char, int, unsigned char *);
15253 void vec_st (vector bool char, int, signed char *);
15254
15255 void vec_ste (vector signed char, int, signed char *);
15256 void vec_ste (vector unsigned char, int, unsigned char *);
15257 void vec_ste (vector bool char, int, signed char *);
15258 void vec_ste (vector bool char, int, unsigned char *);
15259 void vec_ste (vector signed short, int, short *);
15260 void vec_ste (vector unsigned short, int, unsigned short *);
15261 void vec_ste (vector bool short, int, short *);
15262 void vec_ste (vector bool short, int, unsigned short *);
15263 void vec_ste (vector pixel, int, short *);
15264 void vec_ste (vector pixel, int, unsigned short *);
15265 void vec_ste (vector float, int, float *);
15266 void vec_ste (vector signed int, int, int *);
15267 void vec_ste (vector unsigned int, int, unsigned int *);
15268 void vec_ste (vector bool int, int, int *);
15269 void vec_ste (vector bool int, int, unsigned int *);
15270
15271 void vec_stvewx (vector float, int, float *);
15272 void vec_stvewx (vector signed int, int, int *);
15273 void vec_stvewx (vector unsigned int, int, unsigned int *);
15274 void vec_stvewx (vector bool int, int, int *);
15275 void vec_stvewx (vector bool int, int, unsigned int *);
15276
15277 void vec_stvehx (vector signed short, int, short *);
15278 void vec_stvehx (vector unsigned short, int, unsigned short *);
15279 void vec_stvehx (vector bool short, int, short *);
15280 void vec_stvehx (vector bool short, int, unsigned short *);
15281 void vec_stvehx (vector pixel, int, short *);
15282 void vec_stvehx (vector pixel, int, unsigned short *);
15283
15284 void vec_stvebx (vector signed char, int, signed char *);
15285 void vec_stvebx (vector unsigned char, int, unsigned char *);
15286 void vec_stvebx (vector bool char, int, signed char *);
15287 void vec_stvebx (vector bool char, int, unsigned char *);
15288
15289 void vec_stl (vector float, int, vector float *);
15290 void vec_stl (vector float, int, float *);
15291 void vec_stl (vector signed int, int, vector signed int *);
15292 void vec_stl (vector signed int, int, int *);
15293 void vec_stl (vector unsigned int, int, vector unsigned int *);
15294 void vec_stl (vector unsigned int, int, unsigned int *);
15295 void vec_stl (vector bool int, int, vector bool int *);
15296 void vec_stl (vector bool int, int, unsigned int *);
15297 void vec_stl (vector bool int, int, int *);
15298 void vec_stl (vector signed short, int, vector signed short *);
15299 void vec_stl (vector signed short, int, short *);
15300 void vec_stl (vector unsigned short, int, vector unsigned short *);
15301 void vec_stl (vector unsigned short, int, unsigned short *);
15302 void vec_stl (vector bool short, int, vector bool short *);
15303 void vec_stl (vector bool short, int, unsigned short *);
15304 void vec_stl (vector bool short, int, short *);
15305 void vec_stl (vector pixel, int, vector pixel *);
15306 void vec_stl (vector pixel, int, unsigned short *);
15307 void vec_stl (vector pixel, int, short *);
15308 void vec_stl (vector signed char, int, vector signed char *);
15309 void vec_stl (vector signed char, int, signed char *);
15310 void vec_stl (vector unsigned char, int, vector unsigned char *);
15311 void vec_stl (vector unsigned char, int, unsigned char *);
15312 void vec_stl (vector bool char, int, vector bool char *);
15313 void vec_stl (vector bool char, int, unsigned char *);
15314 void vec_stl (vector bool char, int, signed char *);
15315
15316 vector signed char vec_sub (vector bool char, vector signed char);
15317 vector signed char vec_sub (vector signed char, vector bool char);
15318 vector signed char vec_sub (vector signed char, vector signed char);
15319 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15320 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15321 vector unsigned char vec_sub (vector unsigned char,
15322 vector unsigned char);
15323 vector signed short vec_sub (vector bool short, vector signed short);
15324 vector signed short vec_sub (vector signed short, vector bool short);
15325 vector signed short vec_sub (vector signed short, vector signed short);
15326 vector unsigned short vec_sub (vector bool short,
15327 vector unsigned short);
15328 vector unsigned short vec_sub (vector unsigned short,
15329 vector bool short);
15330 vector unsigned short vec_sub (vector unsigned short,
15331 vector unsigned short);
15332 vector signed int vec_sub (vector bool int, vector signed int);
15333 vector signed int vec_sub (vector signed int, vector bool int);
15334 vector signed int vec_sub (vector signed int, vector signed int);
15335 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15336 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15337 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15338 vector float vec_sub (vector float, vector float);
15339
15340 vector float vec_vsubfp (vector float, vector float);
15341
15342 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15343 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15344 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15345 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15346 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15347 vector unsigned int vec_vsubuwm (vector unsigned int,
15348 vector unsigned int);
15349
15350 vector signed short vec_vsubuhm (vector bool short,
15351 vector signed short);
15352 vector signed short vec_vsubuhm (vector signed short,
15353 vector bool short);
15354 vector signed short vec_vsubuhm (vector signed short,
15355 vector signed short);
15356 vector unsigned short vec_vsubuhm (vector bool short,
15357 vector unsigned short);
15358 vector unsigned short vec_vsubuhm (vector unsigned short,
15359 vector bool short);
15360 vector unsigned short vec_vsubuhm (vector unsigned short,
15361 vector unsigned short);
15362
15363 vector signed char vec_vsububm (vector bool char, vector signed char);
15364 vector signed char vec_vsububm (vector signed char, vector bool char);
15365 vector signed char vec_vsububm (vector signed char, vector signed char);
15366 vector unsigned char vec_vsububm (vector bool char,
15367 vector unsigned char);
15368 vector unsigned char vec_vsububm (vector unsigned char,
15369 vector bool char);
15370 vector unsigned char vec_vsububm (vector unsigned char,
15371 vector unsigned char);
15372
15373 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15374
15375 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15376 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15377 vector unsigned char vec_subs (vector unsigned char,
15378 vector unsigned char);
15379 vector signed char vec_subs (vector bool char, vector signed char);
15380 vector signed char vec_subs (vector signed char, vector bool char);
15381 vector signed char vec_subs (vector signed char, vector signed char);
15382 vector unsigned short vec_subs (vector bool short,
15383 vector unsigned short);
15384 vector unsigned short vec_subs (vector unsigned short,
15385 vector bool short);
15386 vector unsigned short vec_subs (vector unsigned short,
15387 vector unsigned short);
15388 vector signed short vec_subs (vector bool short, vector signed short);
15389 vector signed short vec_subs (vector signed short, vector bool short);
15390 vector signed short vec_subs (vector signed short, vector signed short);
15391 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15392 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15393 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15394 vector signed int vec_subs (vector bool int, vector signed int);
15395 vector signed int vec_subs (vector signed int, vector bool int);
15396 vector signed int vec_subs (vector signed int, vector signed int);
15397
15398 vector signed int vec_vsubsws (vector bool int, vector signed int);
15399 vector signed int vec_vsubsws (vector signed int, vector bool int);
15400 vector signed int vec_vsubsws (vector signed int, vector signed int);
15401
15402 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15403 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15404 vector unsigned int vec_vsubuws (vector unsigned int,
15405 vector unsigned int);
15406
15407 vector signed short vec_vsubshs (vector bool short,
15408 vector signed short);
15409 vector signed short vec_vsubshs (vector signed short,
15410 vector bool short);
15411 vector signed short vec_vsubshs (vector signed short,
15412 vector signed short);
15413
15414 vector unsigned short vec_vsubuhs (vector bool short,
15415 vector unsigned short);
15416 vector unsigned short vec_vsubuhs (vector unsigned short,
15417 vector bool short);
15418 vector unsigned short vec_vsubuhs (vector unsigned short,
15419 vector unsigned short);
15420
15421 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15422 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15423 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15424
15425 vector unsigned char vec_vsububs (vector bool char,
15426 vector unsigned char);
15427 vector unsigned char vec_vsububs (vector unsigned char,
15428 vector bool char);
15429 vector unsigned char vec_vsububs (vector unsigned char,
15430 vector unsigned char);
15431
15432 vector unsigned int vec_sum4s (vector unsigned char,
15433 vector unsigned int);
15434 vector signed int vec_sum4s (vector signed char, vector signed int);
15435 vector signed int vec_sum4s (vector signed short, vector signed int);
15436
15437 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15438
15439 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15440
15441 vector unsigned int vec_vsum4ubs (vector unsigned char,
15442 vector unsigned int);
15443
15444 vector signed int vec_sum2s (vector signed int, vector signed int);
15445
15446 vector signed int vec_sums (vector signed int, vector signed int);
15447
15448 vector float vec_trunc (vector float);
15449
15450 vector signed short vec_unpackh (vector signed char);
15451 vector bool short vec_unpackh (vector bool char);
15452 vector signed int vec_unpackh (vector signed short);
15453 vector bool int vec_unpackh (vector bool short);
15454 vector unsigned int vec_unpackh (vector pixel);
15455
15456 vector bool int vec_vupkhsh (vector bool short);
15457 vector signed int vec_vupkhsh (vector signed short);
15458
15459 vector unsigned int vec_vupkhpx (vector pixel);
15460
15461 vector bool short vec_vupkhsb (vector bool char);
15462 vector signed short vec_vupkhsb (vector signed char);
15463
15464 vector signed short vec_unpackl (vector signed char);
15465 vector bool short vec_unpackl (vector bool char);
15466 vector unsigned int vec_unpackl (vector pixel);
15467 vector signed int vec_unpackl (vector signed short);
15468 vector bool int vec_unpackl (vector bool short);
15469
15470 vector unsigned int vec_vupklpx (vector pixel);
15471
15472 vector bool int vec_vupklsh (vector bool short);
15473 vector signed int vec_vupklsh (vector signed short);
15474
15475 vector bool short vec_vupklsb (vector bool char);
15476 vector signed short vec_vupklsb (vector signed char);
15477
15478 vector float vec_xor (vector float, vector float);
15479 vector float vec_xor (vector float, vector bool int);
15480 vector float vec_xor (vector bool int, vector float);
15481 vector bool int vec_xor (vector bool int, vector bool int);
15482 vector signed int vec_xor (vector bool int, vector signed int);
15483 vector signed int vec_xor (vector signed int, vector bool int);
15484 vector signed int vec_xor (vector signed int, vector signed int);
15485 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15486 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15487 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15488 vector bool short vec_xor (vector bool short, vector bool short);
15489 vector signed short vec_xor (vector bool short, vector signed short);
15490 vector signed short vec_xor (vector signed short, vector bool short);
15491 vector signed short vec_xor (vector signed short, vector signed short);
15492 vector unsigned short vec_xor (vector bool short,
15493 vector unsigned short);
15494 vector unsigned short vec_xor (vector unsigned short,
15495 vector bool short);
15496 vector unsigned short vec_xor (vector unsigned short,
15497 vector unsigned short);
15498 vector signed char vec_xor (vector bool char, vector signed char);
15499 vector bool char vec_xor (vector bool char, vector bool char);
15500 vector signed char vec_xor (vector signed char, vector bool char);
15501 vector signed char vec_xor (vector signed char, vector signed char);
15502 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15503 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15504 vector unsigned char vec_xor (vector unsigned char,
15505 vector unsigned char);
15506
15507 int vec_all_eq (vector signed char, vector bool char);
15508 int vec_all_eq (vector signed char, vector signed char);
15509 int vec_all_eq (vector unsigned char, vector bool char);
15510 int vec_all_eq (vector unsigned char, vector unsigned char);
15511 int vec_all_eq (vector bool char, vector bool char);
15512 int vec_all_eq (vector bool char, vector unsigned char);
15513 int vec_all_eq (vector bool char, vector signed char);
15514 int vec_all_eq (vector signed short, vector bool short);
15515 int vec_all_eq (vector signed short, vector signed short);
15516 int vec_all_eq (vector unsigned short, vector bool short);
15517 int vec_all_eq (vector unsigned short, vector unsigned short);
15518 int vec_all_eq (vector bool short, vector bool short);
15519 int vec_all_eq (vector bool short, vector unsigned short);
15520 int vec_all_eq (vector bool short, vector signed short);
15521 int vec_all_eq (vector pixel, vector pixel);
15522 int vec_all_eq (vector signed int, vector bool int);
15523 int vec_all_eq (vector signed int, vector signed int);
15524 int vec_all_eq (vector unsigned int, vector bool int);
15525 int vec_all_eq (vector unsigned int, vector unsigned int);
15526 int vec_all_eq (vector bool int, vector bool int);
15527 int vec_all_eq (vector bool int, vector unsigned int);
15528 int vec_all_eq (vector bool int, vector signed int);
15529 int vec_all_eq (vector float, vector float);
15530
15531 int vec_all_ge (vector bool char, vector unsigned char);
15532 int vec_all_ge (vector unsigned char, vector bool char);
15533 int vec_all_ge (vector unsigned char, vector unsigned char);
15534 int vec_all_ge (vector bool char, vector signed char);
15535 int vec_all_ge (vector signed char, vector bool char);
15536 int vec_all_ge (vector signed char, vector signed char);
15537 int vec_all_ge (vector bool short, vector unsigned short);
15538 int vec_all_ge (vector unsigned short, vector bool short);
15539 int vec_all_ge (vector unsigned short, vector unsigned short);
15540 int vec_all_ge (vector signed short, vector signed short);
15541 int vec_all_ge (vector bool short, vector signed short);
15542 int vec_all_ge (vector signed short, vector bool short);
15543 int vec_all_ge (vector bool int, vector unsigned int);
15544 int vec_all_ge (vector unsigned int, vector bool int);
15545 int vec_all_ge (vector unsigned int, vector unsigned int);
15546 int vec_all_ge (vector bool int, vector signed int);
15547 int vec_all_ge (vector signed int, vector bool int);
15548 int vec_all_ge (vector signed int, vector signed int);
15549 int vec_all_ge (vector float, vector float);
15550
15551 int vec_all_gt (vector bool char, vector unsigned char);
15552 int vec_all_gt (vector unsigned char, vector bool char);
15553 int vec_all_gt (vector unsigned char, vector unsigned char);
15554 int vec_all_gt (vector bool char, vector signed char);
15555 int vec_all_gt (vector signed char, vector bool char);
15556 int vec_all_gt (vector signed char, vector signed char);
15557 int vec_all_gt (vector bool short, vector unsigned short);
15558 int vec_all_gt (vector unsigned short, vector bool short);
15559 int vec_all_gt (vector unsigned short, vector unsigned short);
15560 int vec_all_gt (vector bool short, vector signed short);
15561 int vec_all_gt (vector signed short, vector bool short);
15562 int vec_all_gt (vector signed short, vector signed short);
15563 int vec_all_gt (vector bool int, vector unsigned int);
15564 int vec_all_gt (vector unsigned int, vector bool int);
15565 int vec_all_gt (vector unsigned int, vector unsigned int);
15566 int vec_all_gt (vector bool int, vector signed int);
15567 int vec_all_gt (vector signed int, vector bool int);
15568 int vec_all_gt (vector signed int, vector signed int);
15569 int vec_all_gt (vector float, vector float);
15570
15571 int vec_all_in (vector float, vector float);
15572
15573 int vec_all_le (vector bool char, vector unsigned char);
15574 int vec_all_le (vector unsigned char, vector bool char);
15575 int vec_all_le (vector unsigned char, vector unsigned char);
15576 int vec_all_le (vector bool char, vector signed char);
15577 int vec_all_le (vector signed char, vector bool char);
15578 int vec_all_le (vector signed char, vector signed char);
15579 int vec_all_le (vector bool short, vector unsigned short);
15580 int vec_all_le (vector unsigned short, vector bool short);
15581 int vec_all_le (vector unsigned short, vector unsigned short);
15582 int vec_all_le (vector bool short, vector signed short);
15583 int vec_all_le (vector signed short, vector bool short);
15584 int vec_all_le (vector signed short, vector signed short);
15585 int vec_all_le (vector bool int, vector unsigned int);
15586 int vec_all_le (vector unsigned int, vector bool int);
15587 int vec_all_le (vector unsigned int, vector unsigned int);
15588 int vec_all_le (vector bool int, vector signed int);
15589 int vec_all_le (vector signed int, vector bool int);
15590 int vec_all_le (vector signed int, vector signed int);
15591 int vec_all_le (vector float, vector float);
15592
15593 int vec_all_lt (vector bool char, vector unsigned char);
15594 int vec_all_lt (vector unsigned char, vector bool char);
15595 int vec_all_lt (vector unsigned char, vector unsigned char);
15596 int vec_all_lt (vector bool char, vector signed char);
15597 int vec_all_lt (vector signed char, vector bool char);
15598 int vec_all_lt (vector signed char, vector signed char);
15599 int vec_all_lt (vector bool short, vector unsigned short);
15600 int vec_all_lt (vector unsigned short, vector bool short);
15601 int vec_all_lt (vector unsigned short, vector unsigned short);
15602 int vec_all_lt (vector bool short, vector signed short);
15603 int vec_all_lt (vector signed short, vector bool short);
15604 int vec_all_lt (vector signed short, vector signed short);
15605 int vec_all_lt (vector bool int, vector unsigned int);
15606 int vec_all_lt (vector unsigned int, vector bool int);
15607 int vec_all_lt (vector unsigned int, vector unsigned int);
15608 int vec_all_lt (vector bool int, vector signed int);
15609 int vec_all_lt (vector signed int, vector bool int);
15610 int vec_all_lt (vector signed int, vector signed int);
15611 int vec_all_lt (vector float, vector float);
15612
15613 int vec_all_nan (vector float);
15614
15615 int vec_all_ne (vector signed char, vector bool char);
15616 int vec_all_ne (vector signed char, vector signed char);
15617 int vec_all_ne (vector unsigned char, vector bool char);
15618 int vec_all_ne (vector unsigned char, vector unsigned char);
15619 int vec_all_ne (vector bool char, vector bool char);
15620 int vec_all_ne (vector bool char, vector unsigned char);
15621 int vec_all_ne (vector bool char, vector signed char);
15622 int vec_all_ne (vector signed short, vector bool short);
15623 int vec_all_ne (vector signed short, vector signed short);
15624 int vec_all_ne (vector unsigned short, vector bool short);
15625 int vec_all_ne (vector unsigned short, vector unsigned short);
15626 int vec_all_ne (vector bool short, vector bool short);
15627 int vec_all_ne (vector bool short, vector unsigned short);
15628 int vec_all_ne (vector bool short, vector signed short);
15629 int vec_all_ne (vector pixel, vector pixel);
15630 int vec_all_ne (vector signed int, vector bool int);
15631 int vec_all_ne (vector signed int, vector signed int);
15632 int vec_all_ne (vector unsigned int, vector bool int);
15633 int vec_all_ne (vector unsigned int, vector unsigned int);
15634 int vec_all_ne (vector bool int, vector bool int);
15635 int vec_all_ne (vector bool int, vector unsigned int);
15636 int vec_all_ne (vector bool int, vector signed int);
15637 int vec_all_ne (vector float, vector float);
15638
15639 int vec_all_nge (vector float, vector float);
15640
15641 int vec_all_ngt (vector float, vector float);
15642
15643 int vec_all_nle (vector float, vector float);
15644
15645 int vec_all_nlt (vector float, vector float);
15646
15647 int vec_all_numeric (vector float);
15648
15649 int vec_any_eq (vector signed char, vector bool char);
15650 int vec_any_eq (vector signed char, vector signed char);
15651 int vec_any_eq (vector unsigned char, vector bool char);
15652 int vec_any_eq (vector unsigned char, vector unsigned char);
15653 int vec_any_eq (vector bool char, vector bool char);
15654 int vec_any_eq (vector bool char, vector unsigned char);
15655 int vec_any_eq (vector bool char, vector signed char);
15656 int vec_any_eq (vector signed short, vector bool short);
15657 int vec_any_eq (vector signed short, vector signed short);
15658 int vec_any_eq (vector unsigned short, vector bool short);
15659 int vec_any_eq (vector unsigned short, vector unsigned short);
15660 int vec_any_eq (vector bool short, vector bool short);
15661 int vec_any_eq (vector bool short, vector unsigned short);
15662 int vec_any_eq (vector bool short, vector signed short);
15663 int vec_any_eq (vector pixel, vector pixel);
15664 int vec_any_eq (vector signed int, vector bool int);
15665 int vec_any_eq (vector signed int, vector signed int);
15666 int vec_any_eq (vector unsigned int, vector bool int);
15667 int vec_any_eq (vector unsigned int, vector unsigned int);
15668 int vec_any_eq (vector bool int, vector bool int);
15669 int vec_any_eq (vector bool int, vector unsigned int);
15670 int vec_any_eq (vector bool int, vector signed int);
15671 int vec_any_eq (vector float, vector float);
15672
15673 int vec_any_ge (vector signed char, vector bool char);
15674 int vec_any_ge (vector unsigned char, vector bool char);
15675 int vec_any_ge (vector unsigned char, vector unsigned char);
15676 int vec_any_ge (vector signed char, vector signed char);
15677 int vec_any_ge (vector bool char, vector unsigned char);
15678 int vec_any_ge (vector bool char, vector signed char);
15679 int vec_any_ge (vector unsigned short, vector bool short);
15680 int vec_any_ge (vector unsigned short, vector unsigned short);
15681 int vec_any_ge (vector signed short, vector signed short);
15682 int vec_any_ge (vector signed short, vector bool short);
15683 int vec_any_ge (vector bool short, vector unsigned short);
15684 int vec_any_ge (vector bool short, vector signed short);
15685 int vec_any_ge (vector signed int, vector bool int);
15686 int vec_any_ge (vector unsigned int, vector bool int);
15687 int vec_any_ge (vector unsigned int, vector unsigned int);
15688 int vec_any_ge (vector signed int, vector signed int);
15689 int vec_any_ge (vector bool int, vector unsigned int);
15690 int vec_any_ge (vector bool int, vector signed int);
15691 int vec_any_ge (vector float, vector float);
15692
15693 int vec_any_gt (vector bool char, vector unsigned char);
15694 int vec_any_gt (vector unsigned char, vector bool char);
15695 int vec_any_gt (vector unsigned char, vector unsigned char);
15696 int vec_any_gt (vector bool char, vector signed char);
15697 int vec_any_gt (vector signed char, vector bool char);
15698 int vec_any_gt (vector signed char, vector signed char);
15699 int vec_any_gt (vector bool short, vector unsigned short);
15700 int vec_any_gt (vector unsigned short, vector bool short);
15701 int vec_any_gt (vector unsigned short, vector unsigned short);
15702 int vec_any_gt (vector bool short, vector signed short);
15703 int vec_any_gt (vector signed short, vector bool short);
15704 int vec_any_gt (vector signed short, vector signed short);
15705 int vec_any_gt (vector bool int, vector unsigned int);
15706 int vec_any_gt (vector unsigned int, vector bool int);
15707 int vec_any_gt (vector unsigned int, vector unsigned int);
15708 int vec_any_gt (vector bool int, vector signed int);
15709 int vec_any_gt (vector signed int, vector bool int);
15710 int vec_any_gt (vector signed int, vector signed int);
15711 int vec_any_gt (vector float, vector float);
15712
15713 int vec_any_le (vector bool char, vector unsigned char);
15714 int vec_any_le (vector unsigned char, vector bool char);
15715 int vec_any_le (vector unsigned char, vector unsigned char);
15716 int vec_any_le (vector bool char, vector signed char);
15717 int vec_any_le (vector signed char, vector bool char);
15718 int vec_any_le (vector signed char, vector signed char);
15719 int vec_any_le (vector bool short, vector unsigned short);
15720 int vec_any_le (vector unsigned short, vector bool short);
15721 int vec_any_le (vector unsigned short, vector unsigned short);
15722 int vec_any_le (vector bool short, vector signed short);
15723 int vec_any_le (vector signed short, vector bool short);
15724 int vec_any_le (vector signed short, vector signed short);
15725 int vec_any_le (vector bool int, vector unsigned int);
15726 int vec_any_le (vector unsigned int, vector bool int);
15727 int vec_any_le (vector unsigned int, vector unsigned int);
15728 int vec_any_le (vector bool int, vector signed int);
15729 int vec_any_le (vector signed int, vector bool int);
15730 int vec_any_le (vector signed int, vector signed int);
15731 int vec_any_le (vector float, vector float);
15732
15733 int vec_any_lt (vector bool char, vector unsigned char);
15734 int vec_any_lt (vector unsigned char, vector bool char);
15735 int vec_any_lt (vector unsigned char, vector unsigned char);
15736 int vec_any_lt (vector bool char, vector signed char);
15737 int vec_any_lt (vector signed char, vector bool char);
15738 int vec_any_lt (vector signed char, vector signed char);
15739 int vec_any_lt (vector bool short, vector unsigned short);
15740 int vec_any_lt (vector unsigned short, vector bool short);
15741 int vec_any_lt (vector unsigned short, vector unsigned short);
15742 int vec_any_lt (vector bool short, vector signed short);
15743 int vec_any_lt (vector signed short, vector bool short);
15744 int vec_any_lt (vector signed short, vector signed short);
15745 int vec_any_lt (vector bool int, vector unsigned int);
15746 int vec_any_lt (vector unsigned int, vector bool int);
15747 int vec_any_lt (vector unsigned int, vector unsigned int);
15748 int vec_any_lt (vector bool int, vector signed int);
15749 int vec_any_lt (vector signed int, vector bool int);
15750 int vec_any_lt (vector signed int, vector signed int);
15751 int vec_any_lt (vector float, vector float);
15752
15753 int vec_any_nan (vector float);
15754
15755 int vec_any_ne (vector signed char, vector bool char);
15756 int vec_any_ne (vector signed char, vector signed char);
15757 int vec_any_ne (vector unsigned char, vector bool char);
15758 int vec_any_ne (vector unsigned char, vector unsigned char);
15759 int vec_any_ne (vector bool char, vector bool char);
15760 int vec_any_ne (vector bool char, vector unsigned char);
15761 int vec_any_ne (vector bool char, vector signed char);
15762 int vec_any_ne (vector signed short, vector bool short);
15763 int vec_any_ne (vector signed short, vector signed short);
15764 int vec_any_ne (vector unsigned short, vector bool short);
15765 int vec_any_ne (vector unsigned short, vector unsigned short);
15766 int vec_any_ne (vector bool short, vector bool short);
15767 int vec_any_ne (vector bool short, vector unsigned short);
15768 int vec_any_ne (vector bool short, vector signed short);
15769 int vec_any_ne (vector pixel, vector pixel);
15770 int vec_any_ne (vector signed int, vector bool int);
15771 int vec_any_ne (vector signed int, vector signed int);
15772 int vec_any_ne (vector unsigned int, vector bool int);
15773 int vec_any_ne (vector unsigned int, vector unsigned int);
15774 int vec_any_ne (vector bool int, vector bool int);
15775 int vec_any_ne (vector bool int, vector unsigned int);
15776 int vec_any_ne (vector bool int, vector signed int);
15777 int vec_any_ne (vector float, vector float);
15778
15779 int vec_any_nge (vector float, vector float);
15780
15781 int vec_any_ngt (vector float, vector float);
15782
15783 int vec_any_nle (vector float, vector float);
15784
15785 int vec_any_nlt (vector float, vector float);
15786
15787 int vec_any_numeric (vector float);
15788
15789 int vec_any_out (vector float, vector float);
15790 @end smallexample
15791
15792 If the vector/scalar (VSX) instruction set is available, the following
15793 additional functions are available:
15794
15795 @smallexample
15796 vector double vec_abs (vector double);
15797 vector double vec_add (vector double, vector double);
15798 vector double vec_and (vector double, vector double);
15799 vector double vec_and (vector double, vector bool long);
15800 vector double vec_and (vector bool long, vector double);
15801 vector long vec_and (vector long, vector long);
15802 vector long vec_and (vector long, vector bool long);
15803 vector long vec_and (vector bool long, vector long);
15804 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15805 vector unsigned long vec_and (vector unsigned long, vector bool long);
15806 vector unsigned long vec_and (vector bool long, vector unsigned long);
15807 vector double vec_andc (vector double, vector double);
15808 vector double vec_andc (vector double, vector bool long);
15809 vector double vec_andc (vector bool long, vector double);
15810 vector long vec_andc (vector long, vector long);
15811 vector long vec_andc (vector long, vector bool long);
15812 vector long vec_andc (vector bool long, vector long);
15813 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15814 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15815 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15816 vector double vec_ceil (vector double);
15817 vector bool long vec_cmpeq (vector double, vector double);
15818 vector bool long vec_cmpge (vector double, vector double);
15819 vector bool long vec_cmpgt (vector double, vector double);
15820 vector bool long vec_cmple (vector double, vector double);
15821 vector bool long vec_cmplt (vector double, vector double);
15822 vector double vec_cpsgn (vector double, vector double);
15823 vector float vec_div (vector float, vector float);
15824 vector double vec_div (vector double, vector double);
15825 vector long vec_div (vector long, vector long);
15826 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15827 vector double vec_floor (vector double);
15828 vector double vec_ld (int, const vector double *);
15829 vector double vec_ld (int, const double *);
15830 vector double vec_ldl (int, const vector double *);
15831 vector double vec_ldl (int, const double *);
15832 vector unsigned char vec_lvsl (int, const volatile double *);
15833 vector unsigned char vec_lvsr (int, const volatile double *);
15834 vector double vec_madd (vector double, vector double, vector double);
15835 vector double vec_max (vector double, vector double);
15836 vector signed long vec_mergeh (vector signed long, vector signed long);
15837 vector signed long vec_mergeh (vector signed long, vector bool long);
15838 vector signed long vec_mergeh (vector bool long, vector signed long);
15839 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15840 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15841 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15842 vector signed long vec_mergel (vector signed long, vector signed long);
15843 vector signed long vec_mergel (vector signed long, vector bool long);
15844 vector signed long vec_mergel (vector bool long, vector signed long);
15845 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15846 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15847 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15848 vector double vec_min (vector double, vector double);
15849 vector float vec_msub (vector float, vector float, vector float);
15850 vector double vec_msub (vector double, vector double, vector double);
15851 vector float vec_mul (vector float, vector float);
15852 vector double vec_mul (vector double, vector double);
15853 vector long vec_mul (vector long, vector long);
15854 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15855 vector float vec_nearbyint (vector float);
15856 vector double vec_nearbyint (vector double);
15857 vector float vec_nmadd (vector float, vector float, vector float);
15858 vector double vec_nmadd (vector double, vector double, vector double);
15859 vector double vec_nmsub (vector double, vector double, vector double);
15860 vector double vec_nor (vector double, vector double);
15861 vector long vec_nor (vector long, vector long);
15862 vector long vec_nor (vector long, vector bool long);
15863 vector long vec_nor (vector bool long, vector long);
15864 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15865 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15866 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15867 vector double vec_or (vector double, vector double);
15868 vector double vec_or (vector double, vector bool long);
15869 vector double vec_or (vector bool long, vector double);
15870 vector long vec_or (vector long, vector long);
15871 vector long vec_or (vector long, vector bool long);
15872 vector long vec_or (vector bool long, vector long);
15873 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15874 vector unsigned long vec_or (vector unsigned long, vector bool long);
15875 vector unsigned long vec_or (vector bool long, vector unsigned long);
15876 vector double vec_perm (vector double, vector double, vector unsigned char);
15877 vector long vec_perm (vector long, vector long, vector unsigned char);
15878 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15879 vector unsigned char);
15880 vector double vec_rint (vector double);
15881 vector double vec_recip (vector double, vector double);
15882 vector double vec_rsqrt (vector double);
15883 vector double vec_rsqrte (vector double);
15884 vector double vec_sel (vector double, vector double, vector bool long);
15885 vector double vec_sel (vector double, vector double, vector unsigned long);
15886 vector long vec_sel (vector long, vector long, vector long);
15887 vector long vec_sel (vector long, vector long, vector unsigned long);
15888 vector long vec_sel (vector long, vector long, vector bool long);
15889 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15890 vector long);
15891 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15892 vector unsigned long);
15893 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15894 vector bool long);
15895 vector double vec_splats (double);
15896 vector signed long vec_splats (signed long);
15897 vector unsigned long vec_splats (unsigned long);
15898 vector float vec_sqrt (vector float);
15899 vector double vec_sqrt (vector double);
15900 void vec_st (vector double, int, vector double *);
15901 void vec_st (vector double, int, double *);
15902 vector double vec_sub (vector double, vector double);
15903 vector double vec_trunc (vector double);
15904 vector double vec_xor (vector double, vector double);
15905 vector double vec_xor (vector double, vector bool long);
15906 vector double vec_xor (vector bool long, vector double);
15907 vector long vec_xor (vector long, vector long);
15908 vector long vec_xor (vector long, vector bool long);
15909 vector long vec_xor (vector bool long, vector long);
15910 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15911 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15912 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15913 int vec_all_eq (vector double, vector double);
15914 int vec_all_ge (vector double, vector double);
15915 int vec_all_gt (vector double, vector double);
15916 int vec_all_le (vector double, vector double);
15917 int vec_all_lt (vector double, vector double);
15918 int vec_all_nan (vector double);
15919 int vec_all_ne (vector double, vector double);
15920 int vec_all_nge (vector double, vector double);
15921 int vec_all_ngt (vector double, vector double);
15922 int vec_all_nle (vector double, vector double);
15923 int vec_all_nlt (vector double, vector double);
15924 int vec_all_numeric (vector double);
15925 int vec_any_eq (vector double, vector double);
15926 int vec_any_ge (vector double, vector double);
15927 int vec_any_gt (vector double, vector double);
15928 int vec_any_le (vector double, vector double);
15929 int vec_any_lt (vector double, vector double);
15930 int vec_any_nan (vector double);
15931 int vec_any_ne (vector double, vector double);
15932 int vec_any_nge (vector double, vector double);
15933 int vec_any_ngt (vector double, vector double);
15934 int vec_any_nle (vector double, vector double);
15935 int vec_any_nlt (vector double, vector double);
15936 int vec_any_numeric (vector double);
15937
15938 vector double vec_vsx_ld (int, const vector double *);
15939 vector double vec_vsx_ld (int, const double *);
15940 vector float vec_vsx_ld (int, const vector float *);
15941 vector float vec_vsx_ld (int, const float *);
15942 vector bool int vec_vsx_ld (int, const vector bool int *);
15943 vector signed int vec_vsx_ld (int, const vector signed int *);
15944 vector signed int vec_vsx_ld (int, const int *);
15945 vector signed int vec_vsx_ld (int, const long *);
15946 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15947 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15948 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15949 vector bool short vec_vsx_ld (int, const vector bool short *);
15950 vector pixel vec_vsx_ld (int, const vector pixel *);
15951 vector signed short vec_vsx_ld (int, const vector signed short *);
15952 vector signed short vec_vsx_ld (int, const short *);
15953 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15954 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15955 vector bool char vec_vsx_ld (int, const vector bool char *);
15956 vector signed char vec_vsx_ld (int, const vector signed char *);
15957 vector signed char vec_vsx_ld (int, const signed char *);
15958 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15959 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15960
15961 void vec_vsx_st (vector double, int, vector double *);
15962 void vec_vsx_st (vector double, int, double *);
15963 void vec_vsx_st (vector float, int, vector float *);
15964 void vec_vsx_st (vector float, int, float *);
15965 void vec_vsx_st (vector signed int, int, vector signed int *);
15966 void vec_vsx_st (vector signed int, int, int *);
15967 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15968 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15969 void vec_vsx_st (vector bool int, int, vector bool int *);
15970 void vec_vsx_st (vector bool int, int, unsigned int *);
15971 void vec_vsx_st (vector bool int, int, int *);
15972 void vec_vsx_st (vector signed short, int, vector signed short *);
15973 void vec_vsx_st (vector signed short, int, short *);
15974 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15975 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15976 void vec_vsx_st (vector bool short, int, vector bool short *);
15977 void vec_vsx_st (vector bool short, int, unsigned short *);
15978 void vec_vsx_st (vector pixel, int, vector pixel *);
15979 void vec_vsx_st (vector pixel, int, unsigned short *);
15980 void vec_vsx_st (vector pixel, int, short *);
15981 void vec_vsx_st (vector bool short, int, short *);
15982 void vec_vsx_st (vector signed char, int, vector signed char *);
15983 void vec_vsx_st (vector signed char, int, signed char *);
15984 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15985 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15986 void vec_vsx_st (vector bool char, int, vector bool char *);
15987 void vec_vsx_st (vector bool char, int, unsigned char *);
15988 void vec_vsx_st (vector bool char, int, signed char *);
15989
15990 vector double vec_xxpermdi (vector double, vector double, int);
15991 vector float vec_xxpermdi (vector float, vector float, int);
15992 vector long long vec_xxpermdi (vector long long, vector long long, int);
15993 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15994 vector unsigned long long, int);
15995 vector int vec_xxpermdi (vector int, vector int, int);
15996 vector unsigned int vec_xxpermdi (vector unsigned int,
15997 vector unsigned int, int);
15998 vector short vec_xxpermdi (vector short, vector short, int);
15999 vector unsigned short vec_xxpermdi (vector unsigned short,
16000 vector unsigned short, int);
16001 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
16002 vector unsigned char vec_xxpermdi (vector unsigned char,
16003 vector unsigned char, int);
16004
16005 vector double vec_xxsldi (vector double, vector double, int);
16006 vector float vec_xxsldi (vector float, vector float, int);
16007 vector long long vec_xxsldi (vector long long, vector long long, int);
16008 vector unsigned long long vec_xxsldi (vector unsigned long long,
16009 vector unsigned long long, int);
16010 vector int vec_xxsldi (vector int, vector int, int);
16011 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
16012 vector short vec_xxsldi (vector short, vector short, int);
16013 vector unsigned short vec_xxsldi (vector unsigned short,
16014 vector unsigned short, int);
16015 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
16016 vector unsigned char vec_xxsldi (vector unsigned char,
16017 vector unsigned char, int);
16018 @end smallexample
16019
16020 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
16021 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
16022 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
16023 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
16024 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
16025
16026 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16027 instruction set is available, the following additional functions are
16028 available for both 32-bit and 64-bit targets. For 64-bit targets, you
16029 can use @var{vector long} instead of @var{vector long long},
16030 @var{vector bool long} instead of @var{vector bool long long}, and
16031 @var{vector unsigned long} instead of @var{vector unsigned long long}.
16032
16033 @smallexample
16034 vector long long vec_abs (vector long long);
16035
16036 vector long long vec_add (vector long long, vector long long);
16037 vector unsigned long long vec_add (vector unsigned long long,
16038 vector unsigned long long);
16039
16040 int vec_all_eq (vector long long, vector long long);
16041 int vec_all_eq (vector unsigned long long, vector unsigned long long);
16042 int vec_all_ge (vector long long, vector long long);
16043 int vec_all_ge (vector unsigned long long, vector unsigned long long);
16044 int vec_all_gt (vector long long, vector long long);
16045 int vec_all_gt (vector unsigned long long, vector unsigned long long);
16046 int vec_all_le (vector long long, vector long long);
16047 int vec_all_le (vector unsigned long long, vector unsigned long long);
16048 int vec_all_lt (vector long long, vector long long);
16049 int vec_all_lt (vector unsigned long long, vector unsigned long long);
16050 int vec_all_ne (vector long long, vector long long);
16051 int vec_all_ne (vector unsigned long long, vector unsigned long long);
16052
16053 int vec_any_eq (vector long long, vector long long);
16054 int vec_any_eq (vector unsigned long long, vector unsigned long long);
16055 int vec_any_ge (vector long long, vector long long);
16056 int vec_any_ge (vector unsigned long long, vector unsigned long long);
16057 int vec_any_gt (vector long long, vector long long);
16058 int vec_any_gt (vector unsigned long long, vector unsigned long long);
16059 int vec_any_le (vector long long, vector long long);
16060 int vec_any_le (vector unsigned long long, vector unsigned long long);
16061 int vec_any_lt (vector long long, vector long long);
16062 int vec_any_lt (vector unsigned long long, vector unsigned long long);
16063 int vec_any_ne (vector long long, vector long long);
16064 int vec_any_ne (vector unsigned long long, vector unsigned long long);
16065
16066 vector long long vec_eqv (vector long long, vector long long);
16067 vector long long vec_eqv (vector bool long long, vector long long);
16068 vector long long vec_eqv (vector long long, vector bool long long);
16069 vector unsigned long long vec_eqv (vector unsigned long long,
16070 vector unsigned long long);
16071 vector unsigned long long vec_eqv (vector bool long long,
16072 vector unsigned long long);
16073 vector unsigned long long vec_eqv (vector unsigned long long,
16074 vector bool long long);
16075 vector int vec_eqv (vector int, vector int);
16076 vector int vec_eqv (vector bool int, vector int);
16077 vector int vec_eqv (vector int, vector bool int);
16078 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
16079 vector unsigned int vec_eqv (vector bool unsigned int,
16080 vector unsigned int);
16081 vector unsigned int vec_eqv (vector unsigned int,
16082 vector bool unsigned int);
16083 vector short vec_eqv (vector short, vector short);
16084 vector short vec_eqv (vector bool short, vector short);
16085 vector short vec_eqv (vector short, vector bool short);
16086 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
16087 vector unsigned short vec_eqv (vector bool unsigned short,
16088 vector unsigned short);
16089 vector unsigned short vec_eqv (vector unsigned short,
16090 vector bool unsigned short);
16091 vector signed char vec_eqv (vector signed char, vector signed char);
16092 vector signed char vec_eqv (vector bool signed char, vector signed char);
16093 vector signed char vec_eqv (vector signed char, vector bool signed char);
16094 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
16095 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
16096 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
16097
16098 vector long long vec_max (vector long long, vector long long);
16099 vector unsigned long long vec_max (vector unsigned long long,
16100 vector unsigned long long);
16101
16102 vector signed int vec_mergee (vector signed int, vector signed int);
16103 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
16104 vector bool int vec_mergee (vector bool int, vector bool int);
16105
16106 vector signed int vec_mergeo (vector signed int, vector signed int);
16107 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
16108 vector bool int vec_mergeo (vector bool int, vector bool int);
16109
16110 vector long long vec_min (vector long long, vector long long);
16111 vector unsigned long long vec_min (vector unsigned long long,
16112 vector unsigned long long);
16113
16114 vector long long vec_nand (vector long long, vector long long);
16115 vector long long vec_nand (vector bool long long, vector long long);
16116 vector long long vec_nand (vector long long, vector bool long long);
16117 vector unsigned long long vec_nand (vector unsigned long long,
16118 vector unsigned long long);
16119 vector unsigned long long vec_nand (vector bool long long,
16120 vector unsigned long long);
16121 vector unsigned long long vec_nand (vector unsigned long long,
16122 vector bool long long);
16123 vector int vec_nand (vector int, vector int);
16124 vector int vec_nand (vector bool int, vector int);
16125 vector int vec_nand (vector int, vector bool int);
16126 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
16127 vector unsigned int vec_nand (vector bool unsigned int,
16128 vector unsigned int);
16129 vector unsigned int vec_nand (vector unsigned int,
16130 vector bool unsigned int);
16131 vector short vec_nand (vector short, vector short);
16132 vector short vec_nand (vector bool short, vector short);
16133 vector short vec_nand (vector short, vector bool short);
16134 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
16135 vector unsigned short vec_nand (vector bool unsigned short,
16136 vector unsigned short);
16137 vector unsigned short vec_nand (vector unsigned short,
16138 vector bool unsigned short);
16139 vector signed char vec_nand (vector signed char, vector signed char);
16140 vector signed char vec_nand (vector bool signed char, vector signed char);
16141 vector signed char vec_nand (vector signed char, vector bool signed char);
16142 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
16143 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
16144 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
16145
16146 vector long long vec_orc (vector long long, vector long long);
16147 vector long long vec_orc (vector bool long long, vector long long);
16148 vector long long vec_orc (vector long long, vector bool long long);
16149 vector unsigned long long vec_orc (vector unsigned long long,
16150 vector unsigned long long);
16151 vector unsigned long long vec_orc (vector bool long long,
16152 vector unsigned long long);
16153 vector unsigned long long vec_orc (vector unsigned long long,
16154 vector bool long long);
16155 vector int vec_orc (vector int, vector int);
16156 vector int vec_orc (vector bool int, vector int);
16157 vector int vec_orc (vector int, vector bool int);
16158 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
16159 vector unsigned int vec_orc (vector bool unsigned int,
16160 vector unsigned int);
16161 vector unsigned int vec_orc (vector unsigned int,
16162 vector bool unsigned int);
16163 vector short vec_orc (vector short, vector short);
16164 vector short vec_orc (vector bool short, vector short);
16165 vector short vec_orc (vector short, vector bool short);
16166 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
16167 vector unsigned short vec_orc (vector bool unsigned short,
16168 vector unsigned short);
16169 vector unsigned short vec_orc (vector unsigned short,
16170 vector bool unsigned short);
16171 vector signed char vec_orc (vector signed char, vector signed char);
16172 vector signed char vec_orc (vector bool signed char, vector signed char);
16173 vector signed char vec_orc (vector signed char, vector bool signed char);
16174 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
16175 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
16176 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
16177
16178 vector int vec_pack (vector long long, vector long long);
16179 vector unsigned int vec_pack (vector unsigned long long,
16180 vector unsigned long long);
16181 vector bool int vec_pack (vector bool long long, vector bool long long);
16182
16183 vector int vec_packs (vector long long, vector long long);
16184 vector unsigned int vec_packs (vector unsigned long long,
16185 vector unsigned long long);
16186
16187 vector unsigned int vec_packsu (vector long long, vector long long);
16188 vector unsigned int vec_packsu (vector unsigned long long,
16189 vector unsigned long long);
16190
16191 vector long long vec_rl (vector long long,
16192 vector unsigned long long);
16193 vector long long vec_rl (vector unsigned long long,
16194 vector unsigned long long);
16195
16196 vector long long vec_sl (vector long long, vector unsigned long long);
16197 vector long long vec_sl (vector unsigned long long,
16198 vector unsigned long long);
16199
16200 vector long long vec_sr (vector long long, vector unsigned long long);
16201 vector unsigned long long char vec_sr (vector unsigned long long,
16202 vector unsigned long long);
16203
16204 vector long long vec_sra (vector long long, vector unsigned long long);
16205 vector unsigned long long vec_sra (vector unsigned long long,
16206 vector unsigned long long);
16207
16208 vector long long vec_sub (vector long long, vector long long);
16209 vector unsigned long long vec_sub (vector unsigned long long,
16210 vector unsigned long long);
16211
16212 vector long long vec_unpackh (vector int);
16213 vector unsigned long long vec_unpackh (vector unsigned int);
16214
16215 vector long long vec_unpackl (vector int);
16216 vector unsigned long long vec_unpackl (vector unsigned int);
16217
16218 vector long long vec_vaddudm (vector long long, vector long long);
16219 vector long long vec_vaddudm (vector bool long long, vector long long);
16220 vector long long vec_vaddudm (vector long long, vector bool long long);
16221 vector unsigned long long vec_vaddudm (vector unsigned long long,
16222 vector unsigned long long);
16223 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
16224 vector unsigned long long);
16225 vector unsigned long long vec_vaddudm (vector unsigned long long,
16226 vector bool unsigned long long);
16227
16228 vector long long vec_vbpermq (vector signed char, vector signed char);
16229 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
16230
16231 vector long long vec_cntlz (vector long long);
16232 vector unsigned long long vec_cntlz (vector unsigned long long);
16233 vector int vec_cntlz (vector int);
16234 vector unsigned int vec_cntlz (vector int);
16235 vector short vec_cntlz (vector short);
16236 vector unsigned short vec_cntlz (vector unsigned short);
16237 vector signed char vec_cntlz (vector signed char);
16238 vector unsigned char vec_cntlz (vector unsigned char);
16239
16240 vector long long vec_vclz (vector long long);
16241 vector unsigned long long vec_vclz (vector unsigned long long);
16242 vector int vec_vclz (vector int);
16243 vector unsigned int vec_vclz (vector int);
16244 vector short vec_vclz (vector short);
16245 vector unsigned short vec_vclz (vector unsigned short);
16246 vector signed char vec_vclz (vector signed char);
16247 vector unsigned char vec_vclz (vector unsigned char);
16248
16249 vector signed char vec_vclzb (vector signed char);
16250 vector unsigned char vec_vclzb (vector unsigned char);
16251
16252 vector long long vec_vclzd (vector long long);
16253 vector unsigned long long vec_vclzd (vector unsigned long long);
16254
16255 vector short vec_vclzh (vector short);
16256 vector unsigned short vec_vclzh (vector unsigned short);
16257
16258 vector int vec_vclzw (vector int);
16259 vector unsigned int vec_vclzw (vector int);
16260
16261 vector signed char vec_vgbbd (vector signed char);
16262 vector unsigned char vec_vgbbd (vector unsigned char);
16263
16264 vector long long vec_vmaxsd (vector long long, vector long long);
16265
16266 vector unsigned long long vec_vmaxud (vector unsigned long long,
16267 unsigned vector long long);
16268
16269 vector long long vec_vminsd (vector long long, vector long long);
16270
16271 vector unsigned long long vec_vminud (vector long long,
16272 vector long long);
16273
16274 vector int vec_vpksdss (vector long long, vector long long);
16275 vector unsigned int vec_vpksdss (vector long long, vector long long);
16276
16277 vector unsigned int vec_vpkudus (vector unsigned long long,
16278 vector unsigned long long);
16279
16280 vector int vec_vpkudum (vector long long, vector long long);
16281 vector unsigned int vec_vpkudum (vector unsigned long long,
16282 vector unsigned long long);
16283 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16284
16285 vector long long vec_vpopcnt (vector long long);
16286 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16287 vector int vec_vpopcnt (vector int);
16288 vector unsigned int vec_vpopcnt (vector int);
16289 vector short vec_vpopcnt (vector short);
16290 vector unsigned short vec_vpopcnt (vector unsigned short);
16291 vector signed char vec_vpopcnt (vector signed char);
16292 vector unsigned char vec_vpopcnt (vector unsigned char);
16293
16294 vector signed char vec_vpopcntb (vector signed char);
16295 vector unsigned char vec_vpopcntb (vector unsigned char);
16296
16297 vector long long vec_vpopcntd (vector long long);
16298 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16299
16300 vector short vec_vpopcnth (vector short);
16301 vector unsigned short vec_vpopcnth (vector unsigned short);
16302
16303 vector int vec_vpopcntw (vector int);
16304 vector unsigned int vec_vpopcntw (vector int);
16305
16306 vector long long vec_vrld (vector long long, vector unsigned long long);
16307 vector unsigned long long vec_vrld (vector unsigned long long,
16308 vector unsigned long long);
16309
16310 vector long long vec_vsld (vector long long, vector unsigned long long);
16311 vector long long vec_vsld (vector unsigned long long,
16312 vector unsigned long long);
16313
16314 vector long long vec_vsrad (vector long long, vector unsigned long long);
16315 vector unsigned long long vec_vsrad (vector unsigned long long,
16316 vector unsigned long long);
16317
16318 vector long long vec_vsrd (vector long long, vector unsigned long long);
16319 vector unsigned long long char vec_vsrd (vector unsigned long long,
16320 vector unsigned long long);
16321
16322 vector long long vec_vsubudm (vector long long, vector long long);
16323 vector long long vec_vsubudm (vector bool long long, vector long long);
16324 vector long long vec_vsubudm (vector long long, vector bool long long);
16325 vector unsigned long long vec_vsubudm (vector unsigned long long,
16326 vector unsigned long long);
16327 vector unsigned long long vec_vsubudm (vector bool long long,
16328 vector unsigned long long);
16329 vector unsigned long long vec_vsubudm (vector unsigned long long,
16330 vector bool long long);
16331
16332 vector long long vec_vupkhsw (vector int);
16333 vector unsigned long long vec_vupkhsw (vector unsigned int);
16334
16335 vector long long vec_vupklsw (vector int);
16336 vector unsigned long long vec_vupklsw (vector int);
16337 @end smallexample
16338
16339 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16340 instruction set is available, the following additional functions are
16341 available for 64-bit targets. New vector types
16342 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16343 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16344 builtins.
16345
16346 The normal vector extract, and set operations work on
16347 @var{vector __int128_t} and @var{vector __uint128_t} types,
16348 but the index value must be 0.
16349
16350 @smallexample
16351 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16352 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16353
16354 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16355 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16356
16357 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16358 vector __int128_t);
16359 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16360 vector __uint128_t);
16361
16362 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16363 vector __int128_t);
16364 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16365 vector __uint128_t);
16366
16367 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16368 vector __int128_t);
16369 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16370 vector __uint128_t);
16371
16372 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16373 vector __int128_t);
16374 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16375 vector __uint128_t);
16376
16377 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16378 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16379
16380 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16381 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16382
16383 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16384 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16385 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16386 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16387 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16388 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16389 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16390 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16391 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16392 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16393 @end smallexample
16394
16395 If the cryptographic instructions are enabled (@option{-mcrypto} or
16396 @option{-mcpu=power8}), the following builtins are enabled.
16397
16398 @smallexample
16399 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16400
16401 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16402 vector unsigned long long);
16403
16404 vector unsigned long long __builtin_crypto_vcipherlast
16405 (vector unsigned long long,
16406 vector unsigned long long);
16407
16408 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16409 vector unsigned long long);
16410
16411 vector unsigned long long __builtin_crypto_vncipherlast
16412 (vector unsigned long long,
16413 vector unsigned long long);
16414
16415 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16416 vector unsigned char,
16417 vector unsigned char);
16418
16419 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16420 vector unsigned short,
16421 vector unsigned short);
16422
16423 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16424 vector unsigned int,
16425 vector unsigned int);
16426
16427 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16428 vector unsigned long long,
16429 vector unsigned long long);
16430
16431 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16432 vector unsigned char);
16433
16434 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16435 vector unsigned short);
16436
16437 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16438 vector unsigned int);
16439
16440 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16441 vector unsigned long long);
16442
16443 vector unsigned long long __builtin_crypto_vshasigmad
16444 (vector unsigned long long, int, int);
16445
16446 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16447 int, int);
16448 @end smallexample
16449
16450 The second argument to the @var{__builtin_crypto_vshasigmad} and
16451 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16452 integer that is 0 or 1. The third argument to these builtin functions
16453 must be a constant integer in the range of 0 to 15.
16454
16455 @node PowerPC Hardware Transactional Memory Built-in Functions
16456 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16457 GCC provides two interfaces for accessing the Hardware Transactional
16458 Memory (HTM) instructions available on some of the PowerPC family
16459 of processors (eg, POWER8). The two interfaces come in a low level
16460 interface, consisting of built-in functions specific to PowerPC and a
16461 higher level interface consisting of inline functions that are common
16462 between PowerPC and S/390.
16463
16464 @subsubsection PowerPC HTM Low Level Built-in Functions
16465
16466 The following low level built-in functions are available with
16467 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16468 They all generate the machine instruction that is part of the name.
16469
16470 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16471 the full 4-bit condition register value set by their associated hardware
16472 instruction. The header file @code{htmintrin.h} defines some macros that can
16473 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16474 returns a simple true or false value depending on whether a transaction was
16475 successfully started or not. The arguments of the builtins match exactly the
16476 type and order of the associated hardware instruction's operands, except for
16477 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16478 Refer to the ISA manual for a description of each instruction's operands.
16479
16480 @smallexample
16481 unsigned int __builtin_tbegin (unsigned int)
16482 unsigned int __builtin_tend (unsigned int)
16483
16484 unsigned int __builtin_tabort (unsigned int)
16485 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16486 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16487 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16488 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16489
16490 unsigned int __builtin_tcheck (void)
16491 unsigned int __builtin_treclaim (unsigned int)
16492 unsigned int __builtin_trechkpt (void)
16493 unsigned int __builtin_tsr (unsigned int)
16494 @end smallexample
16495
16496 In addition to the above HTM built-ins, we have added built-ins for
16497 some common extended mnemonics of the HTM instructions:
16498
16499 @smallexample
16500 unsigned int __builtin_tendall (void)
16501 unsigned int __builtin_tresume (void)
16502 unsigned int __builtin_tsuspend (void)
16503 @end smallexample
16504
16505 Note that the semantics of the above HTM builtins are required to mimic
16506 the locking semantics used for critical sections. Builtins that are used
16507 to create a new transaction or restart a suspended transaction must have
16508 lock acquisition like semantics while those builtins that end or suspend a
16509 transaction must have lock release like semantics. Specifically, this must
16510 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16511 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16512 that returns 0, and lock release is as-if an execution of
16513 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16514 implicit implementation-defined lock used for all transactions. The HTM
16515 instructions associated with with the builtins inherently provide the
16516 correct acquisition and release hardware barriers required. However,
16517 the compiler must also be prohibited from moving loads and stores across
16518 the builtins in a way that would violate their semantics. This has been
16519 accomplished by adding memory barriers to the associated HTM instructions
16520 (which is a conservative approach to provide acquire and release semantics).
16521 Earlier versions of the compiler did not treat the HTM instructions as
16522 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16523 be used to determine whether the current compiler treats HTM instructions
16524 as memory barriers or not. This allows the user to explicitly add memory
16525 barriers to their code when using an older version of the compiler.
16526
16527 The following set of built-in functions are available to gain access
16528 to the HTM specific special purpose registers.
16529
16530 @smallexample
16531 unsigned long __builtin_get_texasr (void)
16532 unsigned long __builtin_get_texasru (void)
16533 unsigned long __builtin_get_tfhar (void)
16534 unsigned long __builtin_get_tfiar (void)
16535
16536 void __builtin_set_texasr (unsigned long);
16537 void __builtin_set_texasru (unsigned long);
16538 void __builtin_set_tfhar (unsigned long);
16539 void __builtin_set_tfiar (unsigned long);
16540 @end smallexample
16541
16542 Example usage of these low level built-in functions may look like:
16543
16544 @smallexample
16545 #include <htmintrin.h>
16546
16547 int num_retries = 10;
16548
16549 while (1)
16550 @{
16551 if (__builtin_tbegin (0))
16552 @{
16553 /* Transaction State Initiated. */
16554 if (is_locked (lock))
16555 __builtin_tabort (0);
16556 ... transaction code...
16557 __builtin_tend (0);
16558 break;
16559 @}
16560 else
16561 @{
16562 /* Transaction State Failed. Use locks if the transaction
16563 failure is "persistent" or we've tried too many times. */
16564 if (num_retries-- <= 0
16565 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16566 @{
16567 acquire_lock (lock);
16568 ... non transactional fallback path...
16569 release_lock (lock);
16570 break;
16571 @}
16572 @}
16573 @}
16574 @end smallexample
16575
16576 One final built-in function has been added that returns the value of
16577 the 2-bit Transaction State field of the Machine Status Register (MSR)
16578 as stored in @code{CR0}.
16579
16580 @smallexample
16581 unsigned long __builtin_ttest (void)
16582 @end smallexample
16583
16584 This built-in can be used to determine the current transaction state
16585 using the following code example:
16586
16587 @smallexample
16588 #include <htmintrin.h>
16589
16590 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16591
16592 if (tx_state == _HTM_TRANSACTIONAL)
16593 @{
16594 /* Code to use in transactional state. */
16595 @}
16596 else if (tx_state == _HTM_NONTRANSACTIONAL)
16597 @{
16598 /* Code to use in non-transactional state. */
16599 @}
16600 else if (tx_state == _HTM_SUSPENDED)
16601 @{
16602 /* Code to use in transaction suspended state. */
16603 @}
16604 @end smallexample
16605
16606 @subsubsection PowerPC HTM High Level Inline Functions
16607
16608 The following high level HTM interface is made available by including
16609 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16610 where CPU is `power8' or later. This interface is common between PowerPC
16611 and S/390, allowing users to write one HTM source implementation that
16612 can be compiled and executed on either system.
16613
16614 @smallexample
16615 long __TM_simple_begin (void)
16616 long __TM_begin (void* const TM_buff)
16617 long __TM_end (void)
16618 void __TM_abort (void)
16619 void __TM_named_abort (unsigned char const code)
16620 void __TM_resume (void)
16621 void __TM_suspend (void)
16622
16623 long __TM_is_user_abort (void* const TM_buff)
16624 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16625 long __TM_is_illegal (void* const TM_buff)
16626 long __TM_is_footprint_exceeded (void* const TM_buff)
16627 long __TM_nesting_depth (void* const TM_buff)
16628 long __TM_is_nested_too_deep(void* const TM_buff)
16629 long __TM_is_conflict(void* const TM_buff)
16630 long __TM_is_failure_persistent(void* const TM_buff)
16631 long __TM_failure_address(void* const TM_buff)
16632 long long __TM_failure_code(void* const TM_buff)
16633 @end smallexample
16634
16635 Using these common set of HTM inline functions, we can create
16636 a more portable version of the HTM example in the previous
16637 section that will work on either PowerPC or S/390:
16638
16639 @smallexample
16640 #include <htmxlintrin.h>
16641
16642 int num_retries = 10;
16643 TM_buff_type TM_buff;
16644
16645 while (1)
16646 @{
16647 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16648 @{
16649 /* Transaction State Initiated. */
16650 if (is_locked (lock))
16651 __TM_abort ();
16652 ... transaction code...
16653 __TM_end ();
16654 break;
16655 @}
16656 else
16657 @{
16658 /* Transaction State Failed. Use locks if the transaction
16659 failure is "persistent" or we've tried too many times. */
16660 if (num_retries-- <= 0
16661 || __TM_is_failure_persistent (TM_buff))
16662 @{
16663 acquire_lock (lock);
16664 ... non transactional fallback path...
16665 release_lock (lock);
16666 break;
16667 @}
16668 @}
16669 @}
16670 @end smallexample
16671
16672 @node RX Built-in Functions
16673 @subsection RX Built-in Functions
16674 GCC supports some of the RX instructions which cannot be expressed in
16675 the C programming language via the use of built-in functions. The
16676 following functions are supported:
16677
16678 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16679 Generates the @code{brk} machine instruction.
16680 @end deftypefn
16681
16682 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16683 Generates the @code{clrpsw} machine instruction to clear the specified
16684 bit in the processor status word.
16685 @end deftypefn
16686
16687 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16688 Generates the @code{int} machine instruction to generate an interrupt
16689 with the specified value.
16690 @end deftypefn
16691
16692 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16693 Generates the @code{machi} machine instruction to add the result of
16694 multiplying the top 16 bits of the two arguments into the
16695 accumulator.
16696 @end deftypefn
16697
16698 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16699 Generates the @code{maclo} machine instruction to add the result of
16700 multiplying the bottom 16 bits of the two arguments into the
16701 accumulator.
16702 @end deftypefn
16703
16704 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16705 Generates the @code{mulhi} machine instruction to place the result of
16706 multiplying the top 16 bits of the two arguments into the
16707 accumulator.
16708 @end deftypefn
16709
16710 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16711 Generates the @code{mullo} machine instruction to place the result of
16712 multiplying the bottom 16 bits of the two arguments into the
16713 accumulator.
16714 @end deftypefn
16715
16716 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16717 Generates the @code{mvfachi} machine instruction to read the top
16718 32 bits of the accumulator.
16719 @end deftypefn
16720
16721 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16722 Generates the @code{mvfacmi} machine instruction to read the middle
16723 32 bits of the accumulator.
16724 @end deftypefn
16725
16726 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16727 Generates the @code{mvfc} machine instruction which reads the control
16728 register specified in its argument and returns its value.
16729 @end deftypefn
16730
16731 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16732 Generates the @code{mvtachi} machine instruction to set the top
16733 32 bits of the accumulator.
16734 @end deftypefn
16735
16736 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16737 Generates the @code{mvtaclo} machine instruction to set the bottom
16738 32 bits of the accumulator.
16739 @end deftypefn
16740
16741 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16742 Generates the @code{mvtc} machine instruction which sets control
16743 register number @code{reg} to @code{val}.
16744 @end deftypefn
16745
16746 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16747 Generates the @code{mvtipl} machine instruction set the interrupt
16748 priority level.
16749 @end deftypefn
16750
16751 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16752 Generates the @code{racw} machine instruction to round the accumulator
16753 according to the specified mode.
16754 @end deftypefn
16755
16756 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16757 Generates the @code{revw} machine instruction which swaps the bytes in
16758 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16759 and also bits 16--23 occupy bits 24--31 and vice versa.
16760 @end deftypefn
16761
16762 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16763 Generates the @code{rmpa} machine instruction which initiates a
16764 repeated multiply and accumulate sequence.
16765 @end deftypefn
16766
16767 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16768 Generates the @code{round} machine instruction which returns the
16769 floating-point argument rounded according to the current rounding mode
16770 set in the floating-point status word register.
16771 @end deftypefn
16772
16773 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16774 Generates the @code{sat} machine instruction which returns the
16775 saturated value of the argument.
16776 @end deftypefn
16777
16778 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16779 Generates the @code{setpsw} machine instruction to set the specified
16780 bit in the processor status word.
16781 @end deftypefn
16782
16783 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16784 Generates the @code{wait} machine instruction.
16785 @end deftypefn
16786
16787 @node S/390 System z Built-in Functions
16788 @subsection S/390 System z Built-in Functions
16789 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16790 Generates the @code{tbegin} machine instruction starting a
16791 non-constrained hardware transaction. If the parameter is non-NULL the
16792 memory area is used to store the transaction diagnostic buffer and
16793 will be passed as first operand to @code{tbegin}. This buffer can be
16794 defined using the @code{struct __htm_tdb} C struct defined in
16795 @code{htmintrin.h} and must reside on a double-word boundary. The
16796 second tbegin operand is set to @code{0xff0c}. This enables
16797 save/restore of all GPRs and disables aborts for FPR and AR
16798 manipulations inside the transaction body. The condition code set by
16799 the tbegin instruction is returned as integer value. The tbegin
16800 instruction by definition overwrites the content of all FPRs. The
16801 compiler will generate code which saves and restores the FPRs. For
16802 soft-float code it is recommended to used the @code{*_nofloat}
16803 variant. In order to prevent a TDB from being written it is required
16804 to pass a constant zero value as parameter. Passing a zero value
16805 through a variable is not sufficient. Although modifications of
16806 access registers inside the transaction will not trigger an
16807 transaction abort it is not supported to actually modify them. Access
16808 registers do not get saved when entering a transaction. They will have
16809 undefined state when reaching the abort code.
16810 @end deftypefn
16811
16812 Macros for the possible return codes of tbegin are defined in the
16813 @code{htmintrin.h} header file:
16814
16815 @table @code
16816 @item _HTM_TBEGIN_STARTED
16817 @code{tbegin} has been executed as part of normal processing. The
16818 transaction body is supposed to be executed.
16819 @item _HTM_TBEGIN_INDETERMINATE
16820 The transaction was aborted due to an indeterminate condition which
16821 might be persistent.
16822 @item _HTM_TBEGIN_TRANSIENT
16823 The transaction aborted due to a transient failure. The transaction
16824 should be re-executed in that case.
16825 @item _HTM_TBEGIN_PERSISTENT
16826 The transaction aborted due to a persistent failure. Re-execution
16827 under same circumstances will not be productive.
16828 @end table
16829
16830 @defmac _HTM_FIRST_USER_ABORT_CODE
16831 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16832 specifies the first abort code which can be used for
16833 @code{__builtin_tabort}. Values below this threshold are reserved for
16834 machine use.
16835 @end defmac
16836
16837 @deftp {Data type} {struct __htm_tdb}
16838 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16839 the structure of the transaction diagnostic block as specified in the
16840 Principles of Operation manual chapter 5-91.
16841 @end deftp
16842
16843 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16844 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16845 Using this variant in code making use of FPRs will leave the FPRs in
16846 undefined state when entering the transaction abort handler code.
16847 @end deftypefn
16848
16849 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16850 In addition to @code{__builtin_tbegin} a loop for transient failures
16851 is generated. If tbegin returns a condition code of 2 the transaction
16852 will be retried as often as specified in the second argument. The
16853 perform processor assist instruction is used to tell the CPU about the
16854 number of fails so far.
16855 @end deftypefn
16856
16857 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16858 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16859 restores. Using this variant in code making use of FPRs will leave
16860 the FPRs in undefined state when entering the transaction abort
16861 handler code.
16862 @end deftypefn
16863
16864 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16865 Generates the @code{tbeginc} machine instruction starting a constrained
16866 hardware transaction. The second operand is set to @code{0xff08}.
16867 @end deftypefn
16868
16869 @deftypefn {Built-in Function} int __builtin_tend (void)
16870 Generates the @code{tend} machine instruction finishing a transaction
16871 and making the changes visible to other threads. The condition code
16872 generated by tend is returned as integer value.
16873 @end deftypefn
16874
16875 @deftypefn {Built-in Function} void __builtin_tabort (int)
16876 Generates the @code{tabort} machine instruction with the specified
16877 abort code. Abort codes from 0 through 255 are reserved and will
16878 result in an error message.
16879 @end deftypefn
16880
16881 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16882 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16883 integer parameter is loaded into rX and a value of zero is loaded into
16884 rY. The integer parameter specifies the number of times the
16885 transaction repeatedly aborted.
16886 @end deftypefn
16887
16888 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16889 Generates the @code{etnd} machine instruction. The current nesting
16890 depth is returned as integer value. For a nesting depth of 0 the code
16891 is not executed as part of an transaction.
16892 @end deftypefn
16893
16894 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16895
16896 Generates the @code{ntstg} machine instruction. The second argument
16897 is written to the first arguments location. The store operation will
16898 not be rolled-back in case of an transaction abort.
16899 @end deftypefn
16900
16901 @node SH Built-in Functions
16902 @subsection SH Built-in Functions
16903 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16904 families of processors:
16905
16906 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16907 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16908 used by system code that manages threads and execution contexts. The compiler
16909 normally does not generate code that modifies the contents of @samp{GBR} and
16910 thus the value is preserved across function calls. Changing the @samp{GBR}
16911 value in user code must be done with caution, since the compiler might use
16912 @samp{GBR} in order to access thread local variables.
16913
16914 @end deftypefn
16915
16916 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16917 Returns the value that is currently set in the @samp{GBR} register.
16918 Memory loads and stores that use the thread pointer as a base address are
16919 turned into @samp{GBR} based displacement loads and stores, if possible.
16920 For example:
16921 @smallexample
16922 struct my_tcb
16923 @{
16924 int a, b, c, d, e;
16925 @};
16926
16927 int get_tcb_value (void)
16928 @{
16929 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16930 return ((my_tcb*)__builtin_thread_pointer ())->c;
16931 @}
16932
16933 @end smallexample
16934 @end deftypefn
16935
16936 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16937 Returns the value that is currently set in the @samp{FPSCR} register.
16938 @end deftypefn
16939
16940 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16941 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16942 preserving the current values of the FR, SZ and PR bits.
16943 @end deftypefn
16944
16945 @node SPARC VIS Built-in Functions
16946 @subsection SPARC VIS Built-in Functions
16947
16948 GCC supports SIMD operations on the SPARC using both the generic vector
16949 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16950 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16951 switch, the VIS extension is exposed as the following built-in functions:
16952
16953 @smallexample
16954 typedef int v1si __attribute__ ((vector_size (4)));
16955 typedef int v2si __attribute__ ((vector_size (8)));
16956 typedef short v4hi __attribute__ ((vector_size (8)));
16957 typedef short v2hi __attribute__ ((vector_size (4)));
16958 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16959 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16960
16961 void __builtin_vis_write_gsr (int64_t);
16962 int64_t __builtin_vis_read_gsr (void);
16963
16964 void * __builtin_vis_alignaddr (void *, long);
16965 void * __builtin_vis_alignaddrl (void *, long);
16966 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16967 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16968 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16969 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16970
16971 v4hi __builtin_vis_fexpand (v4qi);
16972
16973 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16974 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16975 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16976 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16977 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16978 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16979 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16980
16981 v4qi __builtin_vis_fpack16 (v4hi);
16982 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16983 v2hi __builtin_vis_fpackfix (v2si);
16984 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16985
16986 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16987
16988 long __builtin_vis_edge8 (void *, void *);
16989 long __builtin_vis_edge8l (void *, void *);
16990 long __builtin_vis_edge16 (void *, void *);
16991 long __builtin_vis_edge16l (void *, void *);
16992 long __builtin_vis_edge32 (void *, void *);
16993 long __builtin_vis_edge32l (void *, void *);
16994
16995 long __builtin_vis_fcmple16 (v4hi, v4hi);
16996 long __builtin_vis_fcmple32 (v2si, v2si);
16997 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16998 long __builtin_vis_fcmpne32 (v2si, v2si);
16999 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
17000 long __builtin_vis_fcmpgt32 (v2si, v2si);
17001 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
17002 long __builtin_vis_fcmpeq32 (v2si, v2si);
17003
17004 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
17005 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
17006 v2si __builtin_vis_fpadd32 (v2si, v2si);
17007 v1si __builtin_vis_fpadd32s (v1si, v1si);
17008 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
17009 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
17010 v2si __builtin_vis_fpsub32 (v2si, v2si);
17011 v1si __builtin_vis_fpsub32s (v1si, v1si);
17012
17013 long __builtin_vis_array8 (long, long);
17014 long __builtin_vis_array16 (long, long);
17015 long __builtin_vis_array32 (long, long);
17016 @end smallexample
17017
17018 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
17019 functions also become available:
17020
17021 @smallexample
17022 long __builtin_vis_bmask (long, long);
17023 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
17024 v2si __builtin_vis_bshufflev2si (v2si, v2si);
17025 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
17026 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
17027
17028 long __builtin_vis_edge8n (void *, void *);
17029 long __builtin_vis_edge8ln (void *, void *);
17030 long __builtin_vis_edge16n (void *, void *);
17031 long __builtin_vis_edge16ln (void *, void *);
17032 long __builtin_vis_edge32n (void *, void *);
17033 long __builtin_vis_edge32ln (void *, void *);
17034 @end smallexample
17035
17036 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
17037 functions also become available:
17038
17039 @smallexample
17040 void __builtin_vis_cmask8 (long);
17041 void __builtin_vis_cmask16 (long);
17042 void __builtin_vis_cmask32 (long);
17043
17044 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
17045
17046 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
17047 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
17048 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
17049 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
17050 v2si __builtin_vis_fsll16 (v2si, v2si);
17051 v2si __builtin_vis_fslas16 (v2si, v2si);
17052 v2si __builtin_vis_fsrl16 (v2si, v2si);
17053 v2si __builtin_vis_fsra16 (v2si, v2si);
17054
17055 long __builtin_vis_pdistn (v8qi, v8qi);
17056
17057 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
17058
17059 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
17060 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
17061
17062 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
17063 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
17064 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
17065 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
17066 v2si __builtin_vis_fpadds32 (v2si, v2si);
17067 v1si __builtin_vis_fpadds32s (v1si, v1si);
17068 v2si __builtin_vis_fpsubs32 (v2si, v2si);
17069 v1si __builtin_vis_fpsubs32s (v1si, v1si);
17070
17071 long __builtin_vis_fucmple8 (v8qi, v8qi);
17072 long __builtin_vis_fucmpne8 (v8qi, v8qi);
17073 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
17074 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
17075
17076 float __builtin_vis_fhadds (float, float);
17077 double __builtin_vis_fhaddd (double, double);
17078 float __builtin_vis_fhsubs (float, float);
17079 double __builtin_vis_fhsubd (double, double);
17080 float __builtin_vis_fnhadds (float, float);
17081 double __builtin_vis_fnhaddd (double, double);
17082
17083 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
17084 int64_t __builtin_vis_xmulx (int64_t, int64_t);
17085 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
17086 @end smallexample
17087
17088 @node SPU Built-in Functions
17089 @subsection SPU Built-in Functions
17090
17091 GCC provides extensions for the SPU processor as described in the
17092 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
17093 found at @uref{http://cell.scei.co.jp/} or
17094 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
17095 implementation differs in several ways.
17096
17097 @itemize @bullet
17098
17099 @item
17100 The optional extension of specifying vector constants in parentheses is
17101 not supported.
17102
17103 @item
17104 A vector initializer requires no cast if the vector constant is of the
17105 same type as the variable it is initializing.
17106
17107 @item
17108 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17109 vector type is the default signedness of the base type. The default
17110 varies depending on the operating system, so a portable program should
17111 always specify the signedness.
17112
17113 @item
17114 By default, the keyword @code{__vector} is added. The macro
17115 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
17116 undefined.
17117
17118 @item
17119 GCC allows using a @code{typedef} name as the type specifier for a
17120 vector type.
17121
17122 @item
17123 For C, overloaded functions are implemented with macros so the following
17124 does not work:
17125
17126 @smallexample
17127 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17128 @end smallexample
17129
17130 @noindent
17131 Since @code{spu_add} is a macro, the vector constant in the example
17132 is treated as four separate arguments. Wrap the entire argument in
17133 parentheses for this to work.
17134
17135 @item
17136 The extended version of @code{__builtin_expect} is not supported.
17137
17138 @end itemize
17139
17140 @emph{Note:} Only the interface described in the aforementioned
17141 specification is supported. Internally, GCC uses built-in functions to
17142 implement the required functionality, but these are not supported and
17143 are subject to change without notice.
17144
17145 @node TI C6X Built-in Functions
17146 @subsection TI C6X Built-in Functions
17147
17148 GCC provides intrinsics to access certain instructions of the TI C6X
17149 processors. These intrinsics, listed below, are available after
17150 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
17151 to C6X instructions.
17152
17153 @smallexample
17154
17155 int _sadd (int, int)
17156 int _ssub (int, int)
17157 int _sadd2 (int, int)
17158 int _ssub2 (int, int)
17159 long long _mpy2 (int, int)
17160 long long _smpy2 (int, int)
17161 int _add4 (int, int)
17162 int _sub4 (int, int)
17163 int _saddu4 (int, int)
17164
17165 int _smpy (int, int)
17166 int _smpyh (int, int)
17167 int _smpyhl (int, int)
17168 int _smpylh (int, int)
17169
17170 int _sshl (int, int)
17171 int _subc (int, int)
17172
17173 int _avg2 (int, int)
17174 int _avgu4 (int, int)
17175
17176 int _clrr (int, int)
17177 int _extr (int, int)
17178 int _extru (int, int)
17179 int _abs (int)
17180 int _abs2 (int)
17181
17182 @end smallexample
17183
17184 @node TILE-Gx Built-in Functions
17185 @subsection TILE-Gx Built-in Functions
17186
17187 GCC provides intrinsics to access every instruction of the TILE-Gx
17188 processor. The intrinsics are of the form:
17189
17190 @smallexample
17191
17192 unsigned long long __insn_@var{op} (...)
17193
17194 @end smallexample
17195
17196 Where @var{op} is the name of the instruction. Refer to the ISA manual
17197 for the complete list of instructions.
17198
17199 GCC also provides intrinsics to directly access the network registers.
17200 The intrinsics are:
17201
17202 @smallexample
17203
17204 unsigned long long __tile_idn0_receive (void)
17205 unsigned long long __tile_idn1_receive (void)
17206 unsigned long long __tile_udn0_receive (void)
17207 unsigned long long __tile_udn1_receive (void)
17208 unsigned long long __tile_udn2_receive (void)
17209 unsigned long long __tile_udn3_receive (void)
17210 void __tile_idn_send (unsigned long long)
17211 void __tile_udn_send (unsigned long long)
17212
17213 @end smallexample
17214
17215 The intrinsic @code{void __tile_network_barrier (void)} is used to
17216 guarantee that no network operations before it are reordered with
17217 those after it.
17218
17219 @node TILEPro Built-in Functions
17220 @subsection TILEPro Built-in Functions
17221
17222 GCC provides intrinsics to access every instruction of the TILEPro
17223 processor. The intrinsics are of the form:
17224
17225 @smallexample
17226
17227 unsigned __insn_@var{op} (...)
17228
17229 @end smallexample
17230
17231 @noindent
17232 where @var{op} is the name of the instruction. Refer to the ISA manual
17233 for the complete list of instructions.
17234
17235 GCC also provides intrinsics to directly access the network registers.
17236 The intrinsics are:
17237
17238 @smallexample
17239
17240 unsigned __tile_idn0_receive (void)
17241 unsigned __tile_idn1_receive (void)
17242 unsigned __tile_sn_receive (void)
17243 unsigned __tile_udn0_receive (void)
17244 unsigned __tile_udn1_receive (void)
17245 unsigned __tile_udn2_receive (void)
17246 unsigned __tile_udn3_receive (void)
17247 void __tile_idn_send (unsigned)
17248 void __tile_sn_send (unsigned)
17249 void __tile_udn_send (unsigned)
17250
17251 @end smallexample
17252
17253 The intrinsic @code{void __tile_network_barrier (void)} is used to
17254 guarantee that no network operations before it are reordered with
17255 those after it.
17256
17257 @node x86 Built-in Functions
17258 @subsection x86 Built-in Functions
17259
17260 These built-in functions are available for the x86-32 and x86-64 family
17261 of computers, depending on the command-line switches used.
17262
17263 If you specify command-line switches such as @option{-msse},
17264 the compiler could use the extended instruction sets even if the built-ins
17265 are not used explicitly in the program. For this reason, applications
17266 that perform run-time CPU detection must compile separate files for each
17267 supported architecture, using the appropriate flags. In particular,
17268 the file containing the CPU detection code should be compiled without
17269 these options.
17270
17271 The following machine modes are available for use with MMX built-in functions
17272 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
17273 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
17274 vector of eight 8-bit integers. Some of the built-in functions operate on
17275 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
17276
17277 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
17278 of two 32-bit floating-point values.
17279
17280 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
17281 floating-point values. Some instructions use a vector of four 32-bit
17282 integers, these use @code{V4SI}. Finally, some instructions operate on an
17283 entire vector register, interpreting it as a 128-bit integer, these use mode
17284 @code{TI}.
17285
17286 In 64-bit mode, the x86-64 family of processors uses additional built-in
17287 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
17288 floating point and @code{TC} 128-bit complex floating-point values.
17289
17290 The following floating-point built-in functions are available in 64-bit
17291 mode. All of them implement the function that is part of the name.
17292
17293 @smallexample
17294 __float128 __builtin_fabsq (__float128)
17295 __float128 __builtin_copysignq (__float128, __float128)
17296 @end smallexample
17297
17298 The following built-in function is always available.
17299
17300 @table @code
17301 @item void __builtin_ia32_pause (void)
17302 Generates the @code{pause} machine instruction with a compiler memory
17303 barrier.
17304 @end table
17305
17306 The following floating-point built-in functions are made available in the
17307 64-bit mode.
17308
17309 @table @code
17310 @item __float128 __builtin_infq (void)
17311 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
17312 @findex __builtin_infq
17313
17314 @item __float128 __builtin_huge_valq (void)
17315 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
17316 @findex __builtin_huge_valq
17317 @end table
17318
17319 The following built-in functions are always available and can be used to
17320 check the target platform type.
17321
17322 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
17323 This function runs the CPU detection code to check the type of CPU and the
17324 features supported. This built-in function needs to be invoked along with the built-in functions
17325 to check CPU type and features, @code{__builtin_cpu_is} and
17326 @code{__builtin_cpu_supports}, only when used in a function that is
17327 executed before any constructors are called. The CPU detection code is
17328 automatically executed in a very high priority constructor.
17329
17330 For example, this function has to be used in @code{ifunc} resolvers that
17331 check for CPU type using the built-in functions @code{__builtin_cpu_is}
17332 and @code{__builtin_cpu_supports}, or in constructors on targets that
17333 don't support constructor priority.
17334 @smallexample
17335
17336 static void (*resolve_memcpy (void)) (void)
17337 @{
17338 // ifunc resolvers fire before constructors, explicitly call the init
17339 // function.
17340 __builtin_cpu_init ();
17341 if (__builtin_cpu_supports ("ssse3"))
17342 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
17343 else
17344 return default_memcpy;
17345 @}
17346
17347 void *memcpy (void *, const void *, size_t)
17348 __attribute__ ((ifunc ("resolve_memcpy")));
17349 @end smallexample
17350
17351 @end deftypefn
17352
17353 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
17354 This function returns a positive integer if the run-time CPU
17355 is of type @var{cpuname}
17356 and returns @code{0} otherwise. The following CPU names can be detected:
17357
17358 @table @samp
17359 @item intel
17360 Intel CPU.
17361
17362 @item atom
17363 Intel Atom CPU.
17364
17365 @item core2
17366 Intel Core 2 CPU.
17367
17368 @item corei7
17369 Intel Core i7 CPU.
17370
17371 @item nehalem
17372 Intel Core i7 Nehalem CPU.
17373
17374 @item westmere
17375 Intel Core i7 Westmere CPU.
17376
17377 @item sandybridge
17378 Intel Core i7 Sandy Bridge CPU.
17379
17380 @item amd
17381 AMD CPU.
17382
17383 @item amdfam10h
17384 AMD Family 10h CPU.
17385
17386 @item barcelona
17387 AMD Family 10h Barcelona CPU.
17388
17389 @item shanghai
17390 AMD Family 10h Shanghai CPU.
17391
17392 @item istanbul
17393 AMD Family 10h Istanbul CPU.
17394
17395 @item btver1
17396 AMD Family 14h CPU.
17397
17398 @item amdfam15h
17399 AMD Family 15h CPU.
17400
17401 @item bdver1
17402 AMD Family 15h Bulldozer version 1.
17403
17404 @item bdver2
17405 AMD Family 15h Bulldozer version 2.
17406
17407 @item bdver3
17408 AMD Family 15h Bulldozer version 3.
17409
17410 @item bdver4
17411 AMD Family 15h Bulldozer version 4.
17412
17413 @item btver2
17414 AMD Family 16h CPU.
17415
17416 @item znver1
17417 AMD Family 17h CPU.
17418 @end table
17419
17420 Here is an example:
17421 @smallexample
17422 if (__builtin_cpu_is ("corei7"))
17423 @{
17424 do_corei7 (); // Core i7 specific implementation.
17425 @}
17426 else
17427 @{
17428 do_generic (); // Generic implementation.
17429 @}
17430 @end smallexample
17431 @end deftypefn
17432
17433 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17434 This function returns a positive integer if the run-time CPU
17435 supports @var{feature}
17436 and returns @code{0} otherwise. The following features can be detected:
17437
17438 @table @samp
17439 @item cmov
17440 CMOV instruction.
17441 @item mmx
17442 MMX instructions.
17443 @item popcnt
17444 POPCNT instruction.
17445 @item sse
17446 SSE instructions.
17447 @item sse2
17448 SSE2 instructions.
17449 @item sse3
17450 SSE3 instructions.
17451 @item ssse3
17452 SSSE3 instructions.
17453 @item sse4.1
17454 SSE4.1 instructions.
17455 @item sse4.2
17456 SSE4.2 instructions.
17457 @item avx
17458 AVX instructions.
17459 @item avx2
17460 AVX2 instructions.
17461 @item avx512f
17462 AVX512F instructions.
17463 @end table
17464
17465 Here is an example:
17466 @smallexample
17467 if (__builtin_cpu_supports ("popcnt"))
17468 @{
17469 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17470 @}
17471 else
17472 @{
17473 count = generic_countbits (n); //generic implementation.
17474 @}
17475 @end smallexample
17476 @end deftypefn
17477
17478
17479 The following built-in functions are made available by @option{-mmmx}.
17480 All of them generate the machine instruction that is part of the name.
17481
17482 @smallexample
17483 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17484 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17485 v2si __builtin_ia32_paddd (v2si, v2si)
17486 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17487 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17488 v2si __builtin_ia32_psubd (v2si, v2si)
17489 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17490 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17491 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17492 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17493 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17494 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17495 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17496 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17497 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17498 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17499 di __builtin_ia32_pand (di, di)
17500 di __builtin_ia32_pandn (di,di)
17501 di __builtin_ia32_por (di, di)
17502 di __builtin_ia32_pxor (di, di)
17503 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17504 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17505 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17506 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17507 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17508 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17509 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17510 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17511 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17512 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17513 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17514 v2si __builtin_ia32_punpckldq (v2si, v2si)
17515 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17516 v4hi __builtin_ia32_packssdw (v2si, v2si)
17517 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17518
17519 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17520 v2si __builtin_ia32_pslld (v2si, v2si)
17521 v1di __builtin_ia32_psllq (v1di, v1di)
17522 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17523 v2si __builtin_ia32_psrld (v2si, v2si)
17524 v1di __builtin_ia32_psrlq (v1di, v1di)
17525 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17526 v2si __builtin_ia32_psrad (v2si, v2si)
17527 v4hi __builtin_ia32_psllwi (v4hi, int)
17528 v2si __builtin_ia32_pslldi (v2si, int)
17529 v1di __builtin_ia32_psllqi (v1di, int)
17530 v4hi __builtin_ia32_psrlwi (v4hi, int)
17531 v2si __builtin_ia32_psrldi (v2si, int)
17532 v1di __builtin_ia32_psrlqi (v1di, int)
17533 v4hi __builtin_ia32_psrawi (v4hi, int)
17534 v2si __builtin_ia32_psradi (v2si, int)
17535
17536 @end smallexample
17537
17538 The following built-in functions are made available either with
17539 @option{-msse}, or with a combination of @option{-m3dnow} and
17540 @option{-march=athlon}. All of them generate the machine
17541 instruction that is part of the name.
17542
17543 @smallexample
17544 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17545 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17546 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17547 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17548 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17549 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17550 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17551 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17552 int __builtin_ia32_pmovmskb (v8qi)
17553 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17554 void __builtin_ia32_movntq (di *, di)
17555 void __builtin_ia32_sfence (void)
17556 @end smallexample
17557
17558 The following built-in functions are available when @option{-msse} is used.
17559 All of them generate the machine instruction that is part of the name.
17560
17561 @smallexample
17562 int __builtin_ia32_comieq (v4sf, v4sf)
17563 int __builtin_ia32_comineq (v4sf, v4sf)
17564 int __builtin_ia32_comilt (v4sf, v4sf)
17565 int __builtin_ia32_comile (v4sf, v4sf)
17566 int __builtin_ia32_comigt (v4sf, v4sf)
17567 int __builtin_ia32_comige (v4sf, v4sf)
17568 int __builtin_ia32_ucomieq (v4sf, v4sf)
17569 int __builtin_ia32_ucomineq (v4sf, v4sf)
17570 int __builtin_ia32_ucomilt (v4sf, v4sf)
17571 int __builtin_ia32_ucomile (v4sf, v4sf)
17572 int __builtin_ia32_ucomigt (v4sf, v4sf)
17573 int __builtin_ia32_ucomige (v4sf, v4sf)
17574 v4sf __builtin_ia32_addps (v4sf, v4sf)
17575 v4sf __builtin_ia32_subps (v4sf, v4sf)
17576 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17577 v4sf __builtin_ia32_divps (v4sf, v4sf)
17578 v4sf __builtin_ia32_addss (v4sf, v4sf)
17579 v4sf __builtin_ia32_subss (v4sf, v4sf)
17580 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17581 v4sf __builtin_ia32_divss (v4sf, v4sf)
17582 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17583 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17584 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17585 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17586 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17587 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17588 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17589 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17590 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17591 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17592 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17593 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17594 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17595 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17596 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17597 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17598 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17599 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17600 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17601 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17602 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17603 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17604 v4sf __builtin_ia32_minps (v4sf, v4sf)
17605 v4sf __builtin_ia32_minss (v4sf, v4sf)
17606 v4sf __builtin_ia32_andps (v4sf, v4sf)
17607 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17608 v4sf __builtin_ia32_orps (v4sf, v4sf)
17609 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17610 v4sf __builtin_ia32_movss (v4sf, v4sf)
17611 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17612 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17613 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17614 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17615 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17616 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17617 v2si __builtin_ia32_cvtps2pi (v4sf)
17618 int __builtin_ia32_cvtss2si (v4sf)
17619 v2si __builtin_ia32_cvttps2pi (v4sf)
17620 int __builtin_ia32_cvttss2si (v4sf)
17621 v4sf __builtin_ia32_rcpps (v4sf)
17622 v4sf __builtin_ia32_rsqrtps (v4sf)
17623 v4sf __builtin_ia32_sqrtps (v4sf)
17624 v4sf __builtin_ia32_rcpss (v4sf)
17625 v4sf __builtin_ia32_rsqrtss (v4sf)
17626 v4sf __builtin_ia32_sqrtss (v4sf)
17627 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17628 void __builtin_ia32_movntps (float *, v4sf)
17629 int __builtin_ia32_movmskps (v4sf)
17630 @end smallexample
17631
17632 The following built-in functions are available when @option{-msse} is used.
17633
17634 @table @code
17635 @item v4sf __builtin_ia32_loadups (float *)
17636 Generates the @code{movups} machine instruction as a load from memory.
17637 @item void __builtin_ia32_storeups (float *, v4sf)
17638 Generates the @code{movups} machine instruction as a store to memory.
17639 @item v4sf __builtin_ia32_loadss (float *)
17640 Generates the @code{movss} machine instruction as a load from memory.
17641 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17642 Generates the @code{movhps} machine instruction as a load from memory.
17643 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17644 Generates the @code{movlps} machine instruction as a load from memory
17645 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17646 Generates the @code{movhps} machine instruction as a store to memory.
17647 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17648 Generates the @code{movlps} machine instruction as a store to memory.
17649 @end table
17650
17651 The following built-in functions are available when @option{-msse2} is used.
17652 All of them generate the machine instruction that is part of the name.
17653
17654 @smallexample
17655 int __builtin_ia32_comisdeq (v2df, v2df)
17656 int __builtin_ia32_comisdlt (v2df, v2df)
17657 int __builtin_ia32_comisdle (v2df, v2df)
17658 int __builtin_ia32_comisdgt (v2df, v2df)
17659 int __builtin_ia32_comisdge (v2df, v2df)
17660 int __builtin_ia32_comisdneq (v2df, v2df)
17661 int __builtin_ia32_ucomisdeq (v2df, v2df)
17662 int __builtin_ia32_ucomisdlt (v2df, v2df)
17663 int __builtin_ia32_ucomisdle (v2df, v2df)
17664 int __builtin_ia32_ucomisdgt (v2df, v2df)
17665 int __builtin_ia32_ucomisdge (v2df, v2df)
17666 int __builtin_ia32_ucomisdneq (v2df, v2df)
17667 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17668 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17669 v2df __builtin_ia32_cmplepd (v2df, v2df)
17670 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17671 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17672 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17673 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17674 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17675 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17676 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17677 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17678 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17679 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17680 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17681 v2df __builtin_ia32_cmplesd (v2df, v2df)
17682 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17683 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17684 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17685 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17686 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17687 v2di __builtin_ia32_paddq (v2di, v2di)
17688 v2di __builtin_ia32_psubq (v2di, v2di)
17689 v2df __builtin_ia32_addpd (v2df, v2df)
17690 v2df __builtin_ia32_subpd (v2df, v2df)
17691 v2df __builtin_ia32_mulpd (v2df, v2df)
17692 v2df __builtin_ia32_divpd (v2df, v2df)
17693 v2df __builtin_ia32_addsd (v2df, v2df)
17694 v2df __builtin_ia32_subsd (v2df, v2df)
17695 v2df __builtin_ia32_mulsd (v2df, v2df)
17696 v2df __builtin_ia32_divsd (v2df, v2df)
17697 v2df __builtin_ia32_minpd (v2df, v2df)
17698 v2df __builtin_ia32_maxpd (v2df, v2df)
17699 v2df __builtin_ia32_minsd (v2df, v2df)
17700 v2df __builtin_ia32_maxsd (v2df, v2df)
17701 v2df __builtin_ia32_andpd (v2df, v2df)
17702 v2df __builtin_ia32_andnpd (v2df, v2df)
17703 v2df __builtin_ia32_orpd (v2df, v2df)
17704 v2df __builtin_ia32_xorpd (v2df, v2df)
17705 v2df __builtin_ia32_movsd (v2df, v2df)
17706 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17707 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17708 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17709 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17710 v4si __builtin_ia32_paddd128 (v4si, v4si)
17711 v2di __builtin_ia32_paddq128 (v2di, v2di)
17712 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17713 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17714 v4si __builtin_ia32_psubd128 (v4si, v4si)
17715 v2di __builtin_ia32_psubq128 (v2di, v2di)
17716 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17717 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17718 v2di __builtin_ia32_pand128 (v2di, v2di)
17719 v2di __builtin_ia32_pandn128 (v2di, v2di)
17720 v2di __builtin_ia32_por128 (v2di, v2di)
17721 v2di __builtin_ia32_pxor128 (v2di, v2di)
17722 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17723 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17724 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17725 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17726 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17727 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17728 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17729 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17730 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17731 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17732 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17733 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17734 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17735 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17736 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17737 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17738 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17739 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17740 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17741 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17742 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17743 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17744 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17745 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17746 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17747 v2df __builtin_ia32_loadupd (double *)
17748 void __builtin_ia32_storeupd (double *, v2df)
17749 v2df __builtin_ia32_loadhpd (v2df, double const *)
17750 v2df __builtin_ia32_loadlpd (v2df, double const *)
17751 int __builtin_ia32_movmskpd (v2df)
17752 int __builtin_ia32_pmovmskb128 (v16qi)
17753 void __builtin_ia32_movnti (int *, int)
17754 void __builtin_ia32_movnti64 (long long int *, long long int)
17755 void __builtin_ia32_movntpd (double *, v2df)
17756 void __builtin_ia32_movntdq (v2df *, v2df)
17757 v4si __builtin_ia32_pshufd (v4si, int)
17758 v8hi __builtin_ia32_pshuflw (v8hi, int)
17759 v8hi __builtin_ia32_pshufhw (v8hi, int)
17760 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17761 v2df __builtin_ia32_sqrtpd (v2df)
17762 v2df __builtin_ia32_sqrtsd (v2df)
17763 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17764 v2df __builtin_ia32_cvtdq2pd (v4si)
17765 v4sf __builtin_ia32_cvtdq2ps (v4si)
17766 v4si __builtin_ia32_cvtpd2dq (v2df)
17767 v2si __builtin_ia32_cvtpd2pi (v2df)
17768 v4sf __builtin_ia32_cvtpd2ps (v2df)
17769 v4si __builtin_ia32_cvttpd2dq (v2df)
17770 v2si __builtin_ia32_cvttpd2pi (v2df)
17771 v2df __builtin_ia32_cvtpi2pd (v2si)
17772 int __builtin_ia32_cvtsd2si (v2df)
17773 int __builtin_ia32_cvttsd2si (v2df)
17774 long long __builtin_ia32_cvtsd2si64 (v2df)
17775 long long __builtin_ia32_cvttsd2si64 (v2df)
17776 v4si __builtin_ia32_cvtps2dq (v4sf)
17777 v2df __builtin_ia32_cvtps2pd (v4sf)
17778 v4si __builtin_ia32_cvttps2dq (v4sf)
17779 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17780 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17781 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17782 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17783 void __builtin_ia32_clflush (const void *)
17784 void __builtin_ia32_lfence (void)
17785 void __builtin_ia32_mfence (void)
17786 v16qi __builtin_ia32_loaddqu (const char *)
17787 void __builtin_ia32_storedqu (char *, v16qi)
17788 v1di __builtin_ia32_pmuludq (v2si, v2si)
17789 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17790 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17791 v4si __builtin_ia32_pslld128 (v4si, v4si)
17792 v2di __builtin_ia32_psllq128 (v2di, v2di)
17793 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17794 v4si __builtin_ia32_psrld128 (v4si, v4si)
17795 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17796 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17797 v4si __builtin_ia32_psrad128 (v4si, v4si)
17798 v2di __builtin_ia32_pslldqi128 (v2di, int)
17799 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17800 v4si __builtin_ia32_pslldi128 (v4si, int)
17801 v2di __builtin_ia32_psllqi128 (v2di, int)
17802 v2di __builtin_ia32_psrldqi128 (v2di, int)
17803 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17804 v4si __builtin_ia32_psrldi128 (v4si, int)
17805 v2di __builtin_ia32_psrlqi128 (v2di, int)
17806 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17807 v4si __builtin_ia32_psradi128 (v4si, int)
17808 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17809 v2di __builtin_ia32_movq128 (v2di)
17810 @end smallexample
17811
17812 The following built-in functions are available when @option{-msse3} is used.
17813 All of them generate the machine instruction that is part of the name.
17814
17815 @smallexample
17816 v2df __builtin_ia32_addsubpd (v2df, v2df)
17817 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17818 v2df __builtin_ia32_haddpd (v2df, v2df)
17819 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17820 v2df __builtin_ia32_hsubpd (v2df, v2df)
17821 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17822 v16qi __builtin_ia32_lddqu (char const *)
17823 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17824 v4sf __builtin_ia32_movshdup (v4sf)
17825 v4sf __builtin_ia32_movsldup (v4sf)
17826 void __builtin_ia32_mwait (unsigned int, unsigned int)
17827 @end smallexample
17828
17829 The following built-in functions are available when @option{-mssse3} is used.
17830 All of them generate the machine instruction that is part of the name.
17831
17832 @smallexample
17833 v2si __builtin_ia32_phaddd (v2si, v2si)
17834 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17835 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17836 v2si __builtin_ia32_phsubd (v2si, v2si)
17837 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17838 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17839 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17840 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17841 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17842 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17843 v2si __builtin_ia32_psignd (v2si, v2si)
17844 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17845 v1di __builtin_ia32_palignr (v1di, v1di, int)
17846 v8qi __builtin_ia32_pabsb (v8qi)
17847 v2si __builtin_ia32_pabsd (v2si)
17848 v4hi __builtin_ia32_pabsw (v4hi)
17849 @end smallexample
17850
17851 The following built-in functions are available when @option{-mssse3} is used.
17852 All of them generate the machine instruction that is part of the name.
17853
17854 @smallexample
17855 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17856 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17857 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17858 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17859 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17860 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17861 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17862 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17863 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17864 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17865 v4si __builtin_ia32_psignd128 (v4si, v4si)
17866 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17867 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17868 v16qi __builtin_ia32_pabsb128 (v16qi)
17869 v4si __builtin_ia32_pabsd128 (v4si)
17870 v8hi __builtin_ia32_pabsw128 (v8hi)
17871 @end smallexample
17872
17873 The following built-in functions are available when @option{-msse4.1} is
17874 used. All of them generate the machine instruction that is part of the
17875 name.
17876
17877 @smallexample
17878 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17879 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17880 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17881 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17882 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17883 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17884 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17885 v2di __builtin_ia32_movntdqa (v2di *);
17886 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17887 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17888 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17889 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17890 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17891 v8hi __builtin_ia32_phminposuw128 (v8hi)
17892 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17893 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17894 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17895 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17896 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17897 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17898 v4si __builtin_ia32_pminud128 (v4si, v4si)
17899 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17900 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17901 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17902 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17903 v2di __builtin_ia32_pmovsxdq128 (v4si)
17904 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17905 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17906 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17907 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17908 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17909 v2di __builtin_ia32_pmovzxdq128 (v4si)
17910 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17911 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17912 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17913 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17914 int __builtin_ia32_ptestc128 (v2di, v2di)
17915 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17916 int __builtin_ia32_ptestz128 (v2di, v2di)
17917 v2df __builtin_ia32_roundpd (v2df, const int)
17918 v4sf __builtin_ia32_roundps (v4sf, const int)
17919 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17920 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17921 @end smallexample
17922
17923 The following built-in functions are available when @option{-msse4.1} is
17924 used.
17925
17926 @table @code
17927 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17928 Generates the @code{insertps} machine instruction.
17929 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17930 Generates the @code{pextrb} machine instruction.
17931 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17932 Generates the @code{pinsrb} machine instruction.
17933 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17934 Generates the @code{pinsrd} machine instruction.
17935 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17936 Generates the @code{pinsrq} machine instruction in 64bit mode.
17937 @end table
17938
17939 The following built-in functions are changed to generate new SSE4.1
17940 instructions when @option{-msse4.1} is used.
17941
17942 @table @code
17943 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17944 Generates the @code{extractps} machine instruction.
17945 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17946 Generates the @code{pextrd} machine instruction.
17947 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17948 Generates the @code{pextrq} machine instruction in 64bit mode.
17949 @end table
17950
17951 The following built-in functions are available when @option{-msse4.2} is
17952 used. All of them generate the machine instruction that is part of the
17953 name.
17954
17955 @smallexample
17956 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17957 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17958 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17959 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17960 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17961 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17962 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17963 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17964 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17965 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17966 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17967 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17968 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17969 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17970 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17971 @end smallexample
17972
17973 The following built-in functions are available when @option{-msse4.2} is
17974 used.
17975
17976 @table @code
17977 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17978 Generates the @code{crc32b} machine instruction.
17979 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17980 Generates the @code{crc32w} machine instruction.
17981 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17982 Generates the @code{crc32l} machine instruction.
17983 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17984 Generates the @code{crc32q} machine instruction.
17985 @end table
17986
17987 The following built-in functions are changed to generate new SSE4.2
17988 instructions when @option{-msse4.2} is used.
17989
17990 @table @code
17991 @item int __builtin_popcount (unsigned int)
17992 Generates the @code{popcntl} machine instruction.
17993 @item int __builtin_popcountl (unsigned long)
17994 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17995 depending on the size of @code{unsigned long}.
17996 @item int __builtin_popcountll (unsigned long long)
17997 Generates the @code{popcntq} machine instruction.
17998 @end table
17999
18000 The following built-in functions are available when @option{-mavx} is
18001 used. All of them generate the machine instruction that is part of the
18002 name.
18003
18004 @smallexample
18005 v4df __builtin_ia32_addpd256 (v4df,v4df)
18006 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
18007 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
18008 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
18009 v4df __builtin_ia32_andnpd256 (v4df,v4df)
18010 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
18011 v4df __builtin_ia32_andpd256 (v4df,v4df)
18012 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
18013 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
18014 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
18015 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
18016 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
18017 v2df __builtin_ia32_cmppd (v2df,v2df,int)
18018 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
18019 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
18020 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
18021 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
18022 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
18023 v4df __builtin_ia32_cvtdq2pd256 (v4si)
18024 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
18025 v4si __builtin_ia32_cvtpd2dq256 (v4df)
18026 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
18027 v8si __builtin_ia32_cvtps2dq256 (v8sf)
18028 v4df __builtin_ia32_cvtps2pd256 (v4sf)
18029 v4si __builtin_ia32_cvttpd2dq256 (v4df)
18030 v8si __builtin_ia32_cvttps2dq256 (v8sf)
18031 v4df __builtin_ia32_divpd256 (v4df,v4df)
18032 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
18033 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
18034 v4df __builtin_ia32_haddpd256 (v4df,v4df)
18035 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
18036 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
18037 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
18038 v32qi __builtin_ia32_lddqu256 (pcchar)
18039 v32qi __builtin_ia32_loaddqu256 (pcchar)
18040 v4df __builtin_ia32_loadupd256 (pcdouble)
18041 v8sf __builtin_ia32_loadups256 (pcfloat)
18042 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
18043 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
18044 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
18045 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
18046 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
18047 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
18048 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
18049 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
18050 v4df __builtin_ia32_maxpd256 (v4df,v4df)
18051 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
18052 v4df __builtin_ia32_minpd256 (v4df,v4df)
18053 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
18054 v4df __builtin_ia32_movddup256 (v4df)
18055 int __builtin_ia32_movmskpd256 (v4df)
18056 int __builtin_ia32_movmskps256 (v8sf)
18057 v8sf __builtin_ia32_movshdup256 (v8sf)
18058 v8sf __builtin_ia32_movsldup256 (v8sf)
18059 v4df __builtin_ia32_mulpd256 (v4df,v4df)
18060 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
18061 v4df __builtin_ia32_orpd256 (v4df,v4df)
18062 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
18063 v2df __builtin_ia32_pd_pd256 (v4df)
18064 v4df __builtin_ia32_pd256_pd (v2df)
18065 v4sf __builtin_ia32_ps_ps256 (v8sf)
18066 v8sf __builtin_ia32_ps256_ps (v4sf)
18067 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
18068 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
18069 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
18070 v8sf __builtin_ia32_rcpps256 (v8sf)
18071 v4df __builtin_ia32_roundpd256 (v4df,int)
18072 v8sf __builtin_ia32_roundps256 (v8sf,int)
18073 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
18074 v8sf __builtin_ia32_rsqrtps256 (v8sf)
18075 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
18076 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
18077 v4si __builtin_ia32_si_si256 (v8si)
18078 v8si __builtin_ia32_si256_si (v4si)
18079 v4df __builtin_ia32_sqrtpd256 (v4df)
18080 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
18081 v8sf __builtin_ia32_sqrtps256 (v8sf)
18082 void __builtin_ia32_storedqu256 (pchar,v32qi)
18083 void __builtin_ia32_storeupd256 (pdouble,v4df)
18084 void __builtin_ia32_storeups256 (pfloat,v8sf)
18085 v4df __builtin_ia32_subpd256 (v4df,v4df)
18086 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
18087 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
18088 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
18089 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
18090 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
18091 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
18092 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
18093 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
18094 v4sf __builtin_ia32_vbroadcastss (pcfloat)
18095 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
18096 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
18097 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
18098 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
18099 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
18100 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
18101 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
18102 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
18103 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
18104 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
18105 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
18106 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
18107 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
18108 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
18109 v2df __builtin_ia32_vpermilpd (v2df,int)
18110 v4df __builtin_ia32_vpermilpd256 (v4df,int)
18111 v4sf __builtin_ia32_vpermilps (v4sf,int)
18112 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
18113 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
18114 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
18115 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
18116 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
18117 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
18118 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
18119 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
18120 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
18121 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
18122 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
18123 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
18124 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
18125 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
18126 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
18127 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
18128 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
18129 void __builtin_ia32_vzeroall (void)
18130 void __builtin_ia32_vzeroupper (void)
18131 v4df __builtin_ia32_xorpd256 (v4df,v4df)
18132 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
18133 @end smallexample
18134
18135 The following built-in functions are available when @option{-mavx2} is
18136 used. All of them generate the machine instruction that is part of the
18137 name.
18138
18139 @smallexample
18140 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
18141 v32qi __builtin_ia32_pabsb256 (v32qi)
18142 v16hi __builtin_ia32_pabsw256 (v16hi)
18143 v8si __builtin_ia32_pabsd256 (v8si)
18144 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
18145 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
18146 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
18147 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
18148 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
18149 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
18150 v8si __builtin_ia32_paddd256 (v8si,v8si)
18151 v4di __builtin_ia32_paddq256 (v4di,v4di)
18152 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
18153 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
18154 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
18155 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
18156 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
18157 v4di __builtin_ia32_andsi256 (v4di,v4di)
18158 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
18159 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
18160 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
18161 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
18162 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
18163 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
18164 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
18165 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
18166 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
18167 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
18168 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
18169 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
18170 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
18171 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
18172 v8si __builtin_ia32_phaddd256 (v8si,v8si)
18173 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
18174 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
18175 v8si __builtin_ia32_phsubd256 (v8si,v8si)
18176 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
18177 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
18178 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
18179 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
18180 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
18181 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
18182 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
18183 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
18184 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
18185 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
18186 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
18187 v8si __builtin_ia32_pminsd256 (v8si,v8si)
18188 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
18189 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
18190 v8si __builtin_ia32_pminud256 (v8si,v8si)
18191 int __builtin_ia32_pmovmskb256 (v32qi)
18192 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
18193 v8si __builtin_ia32_pmovsxbd256 (v16qi)
18194 v4di __builtin_ia32_pmovsxbq256 (v16qi)
18195 v8si __builtin_ia32_pmovsxwd256 (v8hi)
18196 v4di __builtin_ia32_pmovsxwq256 (v8hi)
18197 v4di __builtin_ia32_pmovsxdq256 (v4si)
18198 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
18199 v8si __builtin_ia32_pmovzxbd256 (v16qi)
18200 v4di __builtin_ia32_pmovzxbq256 (v16qi)
18201 v8si __builtin_ia32_pmovzxwd256 (v8hi)
18202 v4di __builtin_ia32_pmovzxwq256 (v8hi)
18203 v4di __builtin_ia32_pmovzxdq256 (v4si)
18204 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
18205 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
18206 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
18207 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
18208 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
18209 v8si __builtin_ia32_pmulld256 (v8si,v8si)
18210 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
18211 v4di __builtin_ia32_por256 (v4di,v4di)
18212 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
18213 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
18214 v8si __builtin_ia32_pshufd256 (v8si,int)
18215 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
18216 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
18217 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
18218 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
18219 v8si __builtin_ia32_psignd256 (v8si,v8si)
18220 v4di __builtin_ia32_pslldqi256 (v4di,int)
18221 v16hi __builtin_ia32_psllwi256 (16hi,int)
18222 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
18223 v8si __builtin_ia32_pslldi256 (v8si,int)
18224 v8si __builtin_ia32_pslld256(v8si,v4si)
18225 v4di __builtin_ia32_psllqi256 (v4di,int)
18226 v4di __builtin_ia32_psllq256(v4di,v2di)
18227 v16hi __builtin_ia32_psrawi256 (v16hi,int)
18228 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
18229 v8si __builtin_ia32_psradi256 (v8si,int)
18230 v8si __builtin_ia32_psrad256 (v8si,v4si)
18231 v4di __builtin_ia32_psrldqi256 (v4di, int)
18232 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
18233 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
18234 v8si __builtin_ia32_psrldi256 (v8si,int)
18235 v8si __builtin_ia32_psrld256 (v8si,v4si)
18236 v4di __builtin_ia32_psrlqi256 (v4di,int)
18237 v4di __builtin_ia32_psrlq256(v4di,v2di)
18238 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
18239 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
18240 v8si __builtin_ia32_psubd256 (v8si,v8si)
18241 v4di __builtin_ia32_psubq256 (v4di,v4di)
18242 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
18243 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
18244 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
18245 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
18246 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
18247 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
18248 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
18249 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
18250 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
18251 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
18252 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
18253 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
18254 v4di __builtin_ia32_pxor256 (v4di,v4di)
18255 v4di __builtin_ia32_movntdqa256 (pv4di)
18256 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
18257 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
18258 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
18259 v4di __builtin_ia32_vbroadcastsi256 (v2di)
18260 v4si __builtin_ia32_pblendd128 (v4si,v4si)
18261 v8si __builtin_ia32_pblendd256 (v8si,v8si)
18262 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
18263 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
18264 v8si __builtin_ia32_pbroadcastd256 (v4si)
18265 v4di __builtin_ia32_pbroadcastq256 (v2di)
18266 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
18267 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
18268 v4si __builtin_ia32_pbroadcastd128 (v4si)
18269 v2di __builtin_ia32_pbroadcastq128 (v2di)
18270 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
18271 v4df __builtin_ia32_permdf256 (v4df,int)
18272 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
18273 v4di __builtin_ia32_permdi256 (v4di,int)
18274 v4di __builtin_ia32_permti256 (v4di,v4di,int)
18275 v4di __builtin_ia32_extract128i256 (v4di,int)
18276 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
18277 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
18278 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
18279 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
18280 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
18281 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
18282 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
18283 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
18284 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
18285 v8si __builtin_ia32_psllv8si (v8si,v8si)
18286 v4si __builtin_ia32_psllv4si (v4si,v4si)
18287 v4di __builtin_ia32_psllv4di (v4di,v4di)
18288 v2di __builtin_ia32_psllv2di (v2di,v2di)
18289 v8si __builtin_ia32_psrav8si (v8si,v8si)
18290 v4si __builtin_ia32_psrav4si (v4si,v4si)
18291 v8si __builtin_ia32_psrlv8si (v8si,v8si)
18292 v4si __builtin_ia32_psrlv4si (v4si,v4si)
18293 v4di __builtin_ia32_psrlv4di (v4di,v4di)
18294 v2di __builtin_ia32_psrlv2di (v2di,v2di)
18295 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
18296 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
18297 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
18298 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
18299 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
18300 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
18301 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
18302 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
18303 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
18304 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
18305 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
18306 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
18307 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
18308 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
18309 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
18310 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
18311 @end smallexample
18312
18313 The following built-in functions are available when @option{-maes} is
18314 used. All of them generate the machine instruction that is part of the
18315 name.
18316
18317 @smallexample
18318 v2di __builtin_ia32_aesenc128 (v2di, v2di)
18319 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
18320 v2di __builtin_ia32_aesdec128 (v2di, v2di)
18321 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
18322 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
18323 v2di __builtin_ia32_aesimc128 (v2di)
18324 @end smallexample
18325
18326 The following built-in function is available when @option{-mpclmul} is
18327 used.
18328
18329 @table @code
18330 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
18331 Generates the @code{pclmulqdq} machine instruction.
18332 @end table
18333
18334 The following built-in function is available when @option{-mfsgsbase} is
18335 used. All of them generate the machine instruction that is part of the
18336 name.
18337
18338 @smallexample
18339 unsigned int __builtin_ia32_rdfsbase32 (void)
18340 unsigned long long __builtin_ia32_rdfsbase64 (void)
18341 unsigned int __builtin_ia32_rdgsbase32 (void)
18342 unsigned long long __builtin_ia32_rdgsbase64 (void)
18343 void _writefsbase_u32 (unsigned int)
18344 void _writefsbase_u64 (unsigned long long)
18345 void _writegsbase_u32 (unsigned int)
18346 void _writegsbase_u64 (unsigned long long)
18347 @end smallexample
18348
18349 The following built-in function is available when @option{-mrdrnd} is
18350 used. All of them generate the machine instruction that is part of the
18351 name.
18352
18353 @smallexample
18354 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
18355 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
18356 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
18357 @end smallexample
18358
18359 The following built-in functions are available when @option{-msse4a} is used.
18360 All of them generate the machine instruction that is part of the name.
18361
18362 @smallexample
18363 void __builtin_ia32_movntsd (double *, v2df)
18364 void __builtin_ia32_movntss (float *, v4sf)
18365 v2di __builtin_ia32_extrq (v2di, v16qi)
18366 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
18367 v2di __builtin_ia32_insertq (v2di, v2di)
18368 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
18369 @end smallexample
18370
18371 The following built-in functions are available when @option{-mxop} is used.
18372 @smallexample
18373 v2df __builtin_ia32_vfrczpd (v2df)
18374 v4sf __builtin_ia32_vfrczps (v4sf)
18375 v2df __builtin_ia32_vfrczsd (v2df)
18376 v4sf __builtin_ia32_vfrczss (v4sf)
18377 v4df __builtin_ia32_vfrczpd256 (v4df)
18378 v8sf __builtin_ia32_vfrczps256 (v8sf)
18379 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18380 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18381 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18382 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18383 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18384 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18385 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18386 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18387 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18388 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18389 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18390 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18391 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18392 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18393 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18394 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18395 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18396 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18397 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18398 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18399 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18400 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18401 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18402 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18403 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18404 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18405 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18406 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18407 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18408 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18409 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18410 v4si __builtin_ia32_vpcomged (v4si, v4si)
18411 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18412 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18413 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18414 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18415 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18416 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18417 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18418 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18419 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18420 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18421 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18422 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18423 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18424 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18425 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18426 v4si __builtin_ia32_vpcomled (v4si, v4si)
18427 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18428 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18429 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18430 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18431 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18432 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18433 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18434 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18435 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18436 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18437 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18438 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18439 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18440 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18441 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18442 v4si __builtin_ia32_vpcomned (v4si, v4si)
18443 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18444 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18445 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18446 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18447 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18448 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18449 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18450 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18451 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18452 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18453 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18454 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18455 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18456 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18457 v4si __builtin_ia32_vphaddbd (v16qi)
18458 v2di __builtin_ia32_vphaddbq (v16qi)
18459 v8hi __builtin_ia32_vphaddbw (v16qi)
18460 v2di __builtin_ia32_vphadddq (v4si)
18461 v4si __builtin_ia32_vphaddubd (v16qi)
18462 v2di __builtin_ia32_vphaddubq (v16qi)
18463 v8hi __builtin_ia32_vphaddubw (v16qi)
18464 v2di __builtin_ia32_vphaddudq (v4si)
18465 v4si __builtin_ia32_vphadduwd (v8hi)
18466 v2di __builtin_ia32_vphadduwq (v8hi)
18467 v4si __builtin_ia32_vphaddwd (v8hi)
18468 v2di __builtin_ia32_vphaddwq (v8hi)
18469 v8hi __builtin_ia32_vphsubbw (v16qi)
18470 v2di __builtin_ia32_vphsubdq (v4si)
18471 v4si __builtin_ia32_vphsubwd (v8hi)
18472 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18473 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18474 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18475 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18476 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18477 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18478 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18479 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18480 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18481 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18482 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18483 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18484 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18485 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18486 v4si __builtin_ia32_vprotd (v4si, v4si)
18487 v2di __builtin_ia32_vprotq (v2di, v2di)
18488 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18489 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18490 v4si __builtin_ia32_vpshad (v4si, v4si)
18491 v2di __builtin_ia32_vpshaq (v2di, v2di)
18492 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18493 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18494 v4si __builtin_ia32_vpshld (v4si, v4si)
18495 v2di __builtin_ia32_vpshlq (v2di, v2di)
18496 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18497 @end smallexample
18498
18499 The following built-in functions are available when @option{-mfma4} is used.
18500 All of them generate the machine instruction that is part of the name.
18501
18502 @smallexample
18503 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18504 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18505 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18506 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18507 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18508 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18509 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18510 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18511 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18512 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18513 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18514 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18515 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18516 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18517 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18518 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18519 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18520 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18521 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18522 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18523 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18524 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18525 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18526 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18527 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18528 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18529 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18530 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18531 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18532 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18533 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18534 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18535
18536 @end smallexample
18537
18538 The following built-in functions are available when @option{-mlwp} is used.
18539
18540 @smallexample
18541 void __builtin_ia32_llwpcb16 (void *);
18542 void __builtin_ia32_llwpcb32 (void *);
18543 void __builtin_ia32_llwpcb64 (void *);
18544 void * __builtin_ia32_llwpcb16 (void);
18545 void * __builtin_ia32_llwpcb32 (void);
18546 void * __builtin_ia32_llwpcb64 (void);
18547 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18548 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18549 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18550 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18551 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18552 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18553 @end smallexample
18554
18555 The following built-in functions are available when @option{-mbmi} is used.
18556 All of them generate the machine instruction that is part of the name.
18557 @smallexample
18558 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18559 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18560 @end smallexample
18561
18562 The following built-in functions are available when @option{-mbmi2} is used.
18563 All of them generate the machine instruction that is part of the name.
18564 @smallexample
18565 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18566 unsigned int _pdep_u32 (unsigned int, unsigned int)
18567 unsigned int _pext_u32 (unsigned int, unsigned int)
18568 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18569 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18570 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18571 @end smallexample
18572
18573 The following built-in functions are available when @option{-mlzcnt} is used.
18574 All of them generate the machine instruction that is part of the name.
18575 @smallexample
18576 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18577 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18578 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18579 @end smallexample
18580
18581 The following built-in functions are available when @option{-mfxsr} is used.
18582 All of them generate the machine instruction that is part of the name.
18583 @smallexample
18584 void __builtin_ia32_fxsave (void *)
18585 void __builtin_ia32_fxrstor (void *)
18586 void __builtin_ia32_fxsave64 (void *)
18587 void __builtin_ia32_fxrstor64 (void *)
18588 @end smallexample
18589
18590 The following built-in functions are available when @option{-mxsave} is used.
18591 All of them generate the machine instruction that is part of the name.
18592 @smallexample
18593 void __builtin_ia32_xsave (void *, long long)
18594 void __builtin_ia32_xrstor (void *, long long)
18595 void __builtin_ia32_xsave64 (void *, long long)
18596 void __builtin_ia32_xrstor64 (void *, long long)
18597 @end smallexample
18598
18599 The following built-in functions are available when @option{-mxsaveopt} is used.
18600 All of them generate the machine instruction that is part of the name.
18601 @smallexample
18602 void __builtin_ia32_xsaveopt (void *, long long)
18603 void __builtin_ia32_xsaveopt64 (void *, long long)
18604 @end smallexample
18605
18606 The following built-in functions are available when @option{-mtbm} is used.
18607 Both of them generate the immediate form of the bextr machine instruction.
18608 @smallexample
18609 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18610 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18611 @end smallexample
18612
18613
18614 The following built-in functions are available when @option{-m3dnow} is used.
18615 All of them generate the machine instruction that is part of the name.
18616
18617 @smallexample
18618 void __builtin_ia32_femms (void)
18619 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18620 v2si __builtin_ia32_pf2id (v2sf)
18621 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18622 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18623 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18624 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18625 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18626 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18627 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18628 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18629 v2sf __builtin_ia32_pfrcp (v2sf)
18630 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18631 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18632 v2sf __builtin_ia32_pfrsqrt (v2sf)
18633 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18634 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18635 v2sf __builtin_ia32_pi2fd (v2si)
18636 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18637 @end smallexample
18638
18639 The following built-in functions are available when both @option{-m3dnow}
18640 and @option{-march=athlon} are used. All of them generate the machine
18641 instruction that is part of the name.
18642
18643 @smallexample
18644 v2si __builtin_ia32_pf2iw (v2sf)
18645 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18646 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18647 v2sf __builtin_ia32_pi2fw (v2si)
18648 v2sf __builtin_ia32_pswapdsf (v2sf)
18649 v2si __builtin_ia32_pswapdsi (v2si)
18650 @end smallexample
18651
18652 The following built-in functions are available when @option{-mrtm} is used
18653 They are used for restricted transactional memory. These are the internal
18654 low level functions. Normally the functions in
18655 @ref{x86 transactional memory intrinsics} should be used instead.
18656
18657 @smallexample
18658 int __builtin_ia32_xbegin ()
18659 void __builtin_ia32_xend ()
18660 void __builtin_ia32_xabort (status)
18661 int __builtin_ia32_xtest ()
18662 @end smallexample
18663
18664 The following built-in functions are available when @option{-mmwaitx} is used.
18665 All of them generate the machine instruction that is part of the name.
18666 @smallexample
18667 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18668 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18669 @end smallexample
18670
18671 The following built-in functions are available when @option{-mclzero} is used.
18672 All of them generate the machine instruction that is part of the name.
18673 @smallexample
18674 void __builtin_i32_clzero (void *)
18675 @end smallexample
18676
18677 The following built-in functions are available when @option{-mpku} is used.
18678 They generate reads and writes to PKRU.
18679 @smallexample
18680 void __builtin_ia32_wrpkru (unsigned int)
18681 unsigned int __builtin_ia32_rdpkru ()
18682 @end smallexample
18683
18684 @node x86 transactional memory intrinsics
18685 @subsection x86 Transactional Memory Intrinsics
18686
18687 These hardware transactional memory intrinsics for x86 allow you to use
18688 memory transactions with RTM (Restricted Transactional Memory).
18689 This support is enabled with the @option{-mrtm} option.
18690 For using HLE (Hardware Lock Elision) see
18691 @ref{x86 specific memory model extensions for transactional memory} instead.
18692
18693 A memory transaction commits all changes to memory in an atomic way,
18694 as visible to other threads. If the transaction fails it is rolled back
18695 and all side effects discarded.
18696
18697 Generally there is no guarantee that a memory transaction ever succeeds
18698 and suitable fallback code always needs to be supplied.
18699
18700 @deftypefn {RTM Function} {unsigned} _xbegin ()
18701 Start a RTM (Restricted Transactional Memory) transaction.
18702 Returns @code{_XBEGIN_STARTED} when the transaction
18703 started successfully (note this is not 0, so the constant has to be
18704 explicitly tested).
18705
18706 If the transaction aborts, all side-effects
18707 are undone and an abort code encoded as a bit mask is returned.
18708 The following macros are defined:
18709
18710 @table @code
18711 @item _XABORT_EXPLICIT
18712 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18713 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18714 @item _XABORT_RETRY
18715 Transaction retry is possible.
18716 @item _XABORT_CONFLICT
18717 Transaction abort due to a memory conflict with another thread.
18718 @item _XABORT_CAPACITY
18719 Transaction abort due to the transaction using too much memory.
18720 @item _XABORT_DEBUG
18721 Transaction abort due to a debug trap.
18722 @item _XABORT_NESTED
18723 Transaction abort in an inner nested transaction.
18724 @end table
18725
18726 There is no guarantee
18727 any transaction ever succeeds, so there always needs to be a valid
18728 fallback path.
18729 @end deftypefn
18730
18731 @deftypefn {RTM Function} {void} _xend ()
18732 Commit the current transaction. When no transaction is active this faults.
18733 All memory side-effects of the transaction become visible
18734 to other threads in an atomic manner.
18735 @end deftypefn
18736
18737 @deftypefn {RTM Function} {int} _xtest ()
18738 Return a nonzero value if a transaction is currently active, otherwise 0.
18739 @end deftypefn
18740
18741 @deftypefn {RTM Function} {void} _xabort (status)
18742 Abort the current transaction. When no transaction is active this is a no-op.
18743 The @var{status} is an 8-bit constant; its value is encoded in the return
18744 value from @code{_xbegin}.
18745 @end deftypefn
18746
18747 Here is an example showing handling for @code{_XABORT_RETRY}
18748 and a fallback path for other failures:
18749
18750 @smallexample
18751 #include <immintrin.h>
18752
18753 int n_tries, max_tries;
18754 unsigned status = _XABORT_EXPLICIT;
18755 ...
18756
18757 for (n_tries = 0; n_tries < max_tries; n_tries++)
18758 @{
18759 status = _xbegin ();
18760 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18761 break;
18762 @}
18763 if (status == _XBEGIN_STARTED)
18764 @{
18765 ... transaction code...
18766 _xend ();
18767 @}
18768 else
18769 @{
18770 ... non-transactional fallback path...
18771 @}
18772 @end smallexample
18773
18774 @noindent
18775 Note that, in most cases, the transactional and non-transactional code
18776 must synchronize together to ensure consistency.
18777
18778 @node Target Format Checks
18779 @section Format Checks Specific to Particular Target Machines
18780
18781 For some target machines, GCC supports additional options to the
18782 format attribute
18783 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18784
18785 @menu
18786 * Solaris Format Checks::
18787 * Darwin Format Checks::
18788 @end menu
18789
18790 @node Solaris Format Checks
18791 @subsection Solaris Format Checks
18792
18793 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18794 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18795 conversions, and the two-argument @code{%b} conversion for displaying
18796 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18797
18798 @node Darwin Format Checks
18799 @subsection Darwin Format Checks
18800
18801 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18802 attribute context. Declarations made with such attribution are parsed for correct syntax
18803 and format argument types. However, parsing of the format string itself is currently undefined
18804 and is not carried out by this version of the compiler.
18805
18806 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18807 also be used as format arguments. Note that the relevant headers are only likely to be
18808 available on Darwin (OSX) installations. On such installations, the XCode and system
18809 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18810 associated functions.
18811
18812 @node Pragmas
18813 @section Pragmas Accepted by GCC
18814 @cindex pragmas
18815 @cindex @code{#pragma}
18816
18817 GCC supports several types of pragmas, primarily in order to compile
18818 code originally written for other compilers. Note that in general
18819 we do not recommend the use of pragmas; @xref{Function Attributes},
18820 for further explanation.
18821
18822 @menu
18823 * AArch64 Pragmas::
18824 * ARM Pragmas::
18825 * M32C Pragmas::
18826 * MeP Pragmas::
18827 * RS/6000 and PowerPC Pragmas::
18828 * S/390 Pragmas::
18829 * Darwin Pragmas::
18830 * Solaris Pragmas::
18831 * Symbol-Renaming Pragmas::
18832 * Structure-Layout Pragmas::
18833 * Weak Pragmas::
18834 * Diagnostic Pragmas::
18835 * Visibility Pragmas::
18836 * Push/Pop Macro Pragmas::
18837 * Function Specific Option Pragmas::
18838 * Loop-Specific Pragmas::
18839 @end menu
18840
18841 @node AArch64 Pragmas
18842 @subsection AArch64 Pragmas
18843
18844 The pragmas defined by the AArch64 target correspond to the AArch64
18845 target function attributes. They can be specified as below:
18846 @smallexample
18847 #pragma GCC target("string")
18848 @end smallexample
18849
18850 where @code{@var{string}} can be any string accepted as an AArch64 target
18851 attribute. @xref{AArch64 Function Attributes}, for more details
18852 on the permissible values of @code{string}.
18853
18854 @node ARM Pragmas
18855 @subsection ARM Pragmas
18856
18857 The ARM target defines pragmas for controlling the default addition of
18858 @code{long_call} and @code{short_call} attributes to functions.
18859 @xref{Function Attributes}, for information about the effects of these
18860 attributes.
18861
18862 @table @code
18863 @item long_calls
18864 @cindex pragma, long_calls
18865 Set all subsequent functions to have the @code{long_call} attribute.
18866
18867 @item no_long_calls
18868 @cindex pragma, no_long_calls
18869 Set all subsequent functions to have the @code{short_call} attribute.
18870
18871 @item long_calls_off
18872 @cindex pragma, long_calls_off
18873 Do not affect the @code{long_call} or @code{short_call} attributes of
18874 subsequent functions.
18875 @end table
18876
18877 @node M32C Pragmas
18878 @subsection M32C Pragmas
18879
18880 @table @code
18881 @item GCC memregs @var{number}
18882 @cindex pragma, memregs
18883 Overrides the command-line option @code{-memregs=} for the current
18884 file. Use with care! This pragma must be before any function in the
18885 file, and mixing different memregs values in different objects may
18886 make them incompatible. This pragma is useful when a
18887 performance-critical function uses a memreg for temporary values,
18888 as it may allow you to reduce the number of memregs used.
18889
18890 @item ADDRESS @var{name} @var{address}
18891 @cindex pragma, address
18892 For any declared symbols matching @var{name}, this does three things
18893 to that symbol: it forces the symbol to be located at the given
18894 address (a number), it forces the symbol to be volatile, and it
18895 changes the symbol's scope to be static. This pragma exists for
18896 compatibility with other compilers, but note that the common
18897 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18898 instead). Example:
18899
18900 @smallexample
18901 #pragma ADDRESS port3 0x103
18902 char port3;
18903 @end smallexample
18904
18905 @end table
18906
18907 @node MeP Pragmas
18908 @subsection MeP Pragmas
18909
18910 @table @code
18911
18912 @item custom io_volatile (on|off)
18913 @cindex pragma, custom io_volatile
18914 Overrides the command-line option @code{-mio-volatile} for the current
18915 file. Note that for compatibility with future GCC releases, this
18916 option should only be used once before any @code{io} variables in each
18917 file.
18918
18919 @item GCC coprocessor available @var{registers}
18920 @cindex pragma, coprocessor available
18921 Specifies which coprocessor registers are available to the register
18922 allocator. @var{registers} may be a single register, register range
18923 separated by ellipses, or comma-separated list of those. Example:
18924
18925 @smallexample
18926 #pragma GCC coprocessor available $c0...$c10, $c28
18927 @end smallexample
18928
18929 @item GCC coprocessor call_saved @var{registers}
18930 @cindex pragma, coprocessor call_saved
18931 Specifies which coprocessor registers are to be saved and restored by
18932 any function using them. @var{registers} may be a single register,
18933 register range separated by ellipses, or comma-separated list of
18934 those. Example:
18935
18936 @smallexample
18937 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18938 @end smallexample
18939
18940 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18941 @cindex pragma, coprocessor subclass
18942 Creates and defines a register class. These register classes can be
18943 used by inline @code{asm} constructs. @var{registers} may be a single
18944 register, register range separated by ellipses, or comma-separated
18945 list of those. Example:
18946
18947 @smallexample
18948 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18949
18950 asm ("cpfoo %0" : "=B" (x));
18951 @end smallexample
18952
18953 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18954 @cindex pragma, disinterrupt
18955 For the named functions, the compiler adds code to disable interrupts
18956 for the duration of those functions. If any functions so named
18957 are not encountered in the source, a warning is emitted that the pragma is
18958 not used. Examples:
18959
18960 @smallexample
18961 #pragma disinterrupt foo
18962 #pragma disinterrupt bar, grill
18963 int foo () @{ @dots{} @}
18964 @end smallexample
18965
18966 @item GCC call @var{name} , @var{name} @dots{}
18967 @cindex pragma, call
18968 For the named functions, the compiler always uses a register-indirect
18969 call model when calling the named functions. Examples:
18970
18971 @smallexample
18972 extern int foo ();
18973 #pragma call foo
18974 @end smallexample
18975
18976 @end table
18977
18978 @node RS/6000 and PowerPC Pragmas
18979 @subsection RS/6000 and PowerPC Pragmas
18980
18981 The RS/6000 and PowerPC targets define one pragma for controlling
18982 whether or not the @code{longcall} attribute is added to function
18983 declarations by default. This pragma overrides the @option{-mlongcall}
18984 option, but not the @code{longcall} and @code{shortcall} attributes.
18985 @xref{RS/6000 and PowerPC Options}, for more information about when long
18986 calls are and are not necessary.
18987
18988 @table @code
18989 @item longcall (1)
18990 @cindex pragma, longcall
18991 Apply the @code{longcall} attribute to all subsequent function
18992 declarations.
18993
18994 @item longcall (0)
18995 Do not apply the @code{longcall} attribute to subsequent function
18996 declarations.
18997 @end table
18998
18999 @c Describe h8300 pragmas here.
19000 @c Describe sh pragmas here.
19001 @c Describe v850 pragmas here.
19002
19003 @node S/390 Pragmas
19004 @subsection S/390 Pragmas
19005
19006 The pragmas defined by the S/390 target correspond to the S/390
19007 target function attributes and some the additional options:
19008
19009 @table @samp
19010 @item zvector
19011 @itemx no-zvector
19012 @end table
19013
19014 Note that options of the pragma, unlike options of the target
19015 attribute, do change the value of preprocessor macros like
19016 @code{__VEC__}. They can be specified as below:
19017
19018 @smallexample
19019 #pragma GCC target("string[,string]...")
19020 #pragma GCC target("string"[,"string"]...)
19021 @end smallexample
19022
19023 @node Darwin Pragmas
19024 @subsection Darwin Pragmas
19025
19026 The following pragmas are available for all architectures running the
19027 Darwin operating system. These are useful for compatibility with other
19028 Mac OS compilers.
19029
19030 @table @code
19031 @item mark @var{tokens}@dots{}
19032 @cindex pragma, mark
19033 This pragma is accepted, but has no effect.
19034
19035 @item options align=@var{alignment}
19036 @cindex pragma, options align
19037 This pragma sets the alignment of fields in structures. The values of
19038 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
19039 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
19040 properly; to restore the previous setting, use @code{reset} for the
19041 @var{alignment}.
19042
19043 @item segment @var{tokens}@dots{}
19044 @cindex pragma, segment
19045 This pragma is accepted, but has no effect.
19046
19047 @item unused (@var{var} [, @var{var}]@dots{})
19048 @cindex pragma, unused
19049 This pragma declares variables to be possibly unused. GCC does not
19050 produce warnings for the listed variables. The effect is similar to
19051 that of the @code{unused} attribute, except that this pragma may appear
19052 anywhere within the variables' scopes.
19053 @end table
19054
19055 @node Solaris Pragmas
19056 @subsection Solaris Pragmas
19057
19058 The Solaris target supports @code{#pragma redefine_extname}
19059 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
19060 @code{#pragma} directives for compatibility with the system compiler.
19061
19062 @table @code
19063 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
19064 @cindex pragma, align
19065
19066 Increase the minimum alignment of each @var{variable} to @var{alignment}.
19067 This is the same as GCC's @code{aligned} attribute @pxref{Variable
19068 Attributes}). Macro expansion occurs on the arguments to this pragma
19069 when compiling C and Objective-C@. It does not currently occur when
19070 compiling C++, but this is a bug which may be fixed in a future
19071 release.
19072
19073 @item fini (@var{function} [, @var{function}]...)
19074 @cindex pragma, fini
19075
19076 This pragma causes each listed @var{function} to be called after
19077 main, or during shared module unloading, by adding a call to the
19078 @code{.fini} section.
19079
19080 @item init (@var{function} [, @var{function}]...)
19081 @cindex pragma, init
19082
19083 This pragma causes each listed @var{function} to be called during
19084 initialization (before @code{main}) or during shared module loading, by
19085 adding a call to the @code{.init} section.
19086
19087 @end table
19088
19089 @node Symbol-Renaming Pragmas
19090 @subsection Symbol-Renaming Pragmas
19091
19092 GCC supports a @code{#pragma} directive that changes the name used in
19093 assembly for a given declaration. While this pragma is supported on all
19094 platforms, it is intended primarily to provide compatibility with the
19095 Solaris system headers. This effect can also be achieved using the asm
19096 labels extension (@pxref{Asm Labels}).
19097
19098 @table @code
19099 @item redefine_extname @var{oldname} @var{newname}
19100 @cindex pragma, redefine_extname
19101
19102 This pragma gives the C function @var{oldname} the assembly symbol
19103 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
19104 is defined if this pragma is available (currently on all platforms).
19105 @end table
19106
19107 This pragma and the asm labels extension interact in a complicated
19108 manner. Here are some corner cases you may want to be aware of:
19109
19110 @enumerate
19111 @item This pragma silently applies only to declarations with external
19112 linkage. Asm labels do not have this restriction.
19113
19114 @item In C++, this pragma silently applies only to declarations with
19115 ``C'' linkage. Again, asm labels do not have this restriction.
19116
19117 @item If either of the ways of changing the assembly name of a
19118 declaration are applied to a declaration whose assembly name has
19119 already been determined (either by a previous use of one of these
19120 features, or because the compiler needed the assembly name in order to
19121 generate code), and the new name is different, a warning issues and
19122 the name does not change.
19123
19124 @item The @var{oldname} used by @code{#pragma redefine_extname} is
19125 always the C-language name.
19126 @end enumerate
19127
19128 @node Structure-Layout Pragmas
19129 @subsection Structure-Layout Pragmas
19130
19131 For compatibility with Microsoft Windows compilers, GCC supports a
19132 set of @code{#pragma} directives that change the maximum alignment of
19133 members of structures (other than zero-width bit-fields), unions, and
19134 classes subsequently defined. The @var{n} value below always is required
19135 to be a small power of two and specifies the new alignment in bytes.
19136
19137 @enumerate
19138 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
19139 @item @code{#pragma pack()} sets the alignment to the one that was in
19140 effect when compilation started (see also command-line option
19141 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
19142 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
19143 setting on an internal stack and then optionally sets the new alignment.
19144 @item @code{#pragma pack(pop)} restores the alignment setting to the one
19145 saved at the top of the internal stack (and removes that stack entry).
19146 Note that @code{#pragma pack([@var{n}])} does not influence this internal
19147 stack; thus it is possible to have @code{#pragma pack(push)} followed by
19148 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
19149 @code{#pragma pack(pop)}.
19150 @end enumerate
19151
19152 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
19153 directive which lays out structures and unions subsequently defined as the
19154 documented @code{__attribute__ ((ms_struct))}.
19155
19156 @enumerate
19157 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
19158 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
19159 @item @code{#pragma ms_struct reset} goes back to the default layout.
19160 @end enumerate
19161
19162 Most targets also support the @code{#pragma scalar_storage_order} directive
19163 which lays out structures and unions subsequently defined as the documented
19164 @code{__attribute__ ((scalar_storage_order))}.
19165
19166 @enumerate
19167 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
19168 of the scalar fields to big-endian.
19169 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
19170 of the scalar fields to little-endian.
19171 @item @code{#pragma scalar_storage_order default} goes back to the endianness
19172 that was in effect when compilation started (see also command-line option
19173 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
19174 @end enumerate
19175
19176 @node Weak Pragmas
19177 @subsection Weak Pragmas
19178
19179 For compatibility with SVR4, GCC supports a set of @code{#pragma}
19180 directives for declaring symbols to be weak, and defining weak
19181 aliases.
19182
19183 @table @code
19184 @item #pragma weak @var{symbol}
19185 @cindex pragma, weak
19186 This pragma declares @var{symbol} to be weak, as if the declaration
19187 had the attribute of the same name. The pragma may appear before
19188 or after the declaration of @var{symbol}. It is not an error for
19189 @var{symbol} to never be defined at all.
19190
19191 @item #pragma weak @var{symbol1} = @var{symbol2}
19192 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
19193 It is an error if @var{symbol2} is not defined in the current
19194 translation unit.
19195 @end table
19196
19197 @node Diagnostic Pragmas
19198 @subsection Diagnostic Pragmas
19199
19200 GCC allows the user to selectively enable or disable certain types of
19201 diagnostics, and change the kind of the diagnostic. For example, a
19202 project's policy might require that all sources compile with
19203 @option{-Werror} but certain files might have exceptions allowing
19204 specific types of warnings. Or, a project might selectively enable
19205 diagnostics and treat them as errors depending on which preprocessor
19206 macros are defined.
19207
19208 @table @code
19209 @item #pragma GCC diagnostic @var{kind} @var{option}
19210 @cindex pragma, diagnostic
19211
19212 Modifies the disposition of a diagnostic. Note that not all
19213 diagnostics are modifiable; at the moment only warnings (normally
19214 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
19215 Use @option{-fdiagnostics-show-option} to determine which diagnostics
19216 are controllable and which option controls them.
19217
19218 @var{kind} is @samp{error} to treat this diagnostic as an error,
19219 @samp{warning} to treat it like a warning (even if @option{-Werror} is
19220 in effect), or @samp{ignored} if the diagnostic is to be ignored.
19221 @var{option} is a double quoted string that matches the command-line
19222 option.
19223
19224 @smallexample
19225 #pragma GCC diagnostic warning "-Wformat"
19226 #pragma GCC diagnostic error "-Wformat"
19227 #pragma GCC diagnostic ignored "-Wformat"
19228 @end smallexample
19229
19230 Note that these pragmas override any command-line options. GCC keeps
19231 track of the location of each pragma, and issues diagnostics according
19232 to the state as of that point in the source file. Thus, pragmas occurring
19233 after a line do not affect diagnostics caused by that line.
19234
19235 @item #pragma GCC diagnostic push
19236 @itemx #pragma GCC diagnostic pop
19237
19238 Causes GCC to remember the state of the diagnostics as of each
19239 @code{push}, and restore to that point at each @code{pop}. If a
19240 @code{pop} has no matching @code{push}, the command-line options are
19241 restored.
19242
19243 @smallexample
19244 #pragma GCC diagnostic error "-Wuninitialized"
19245 foo(a); /* error is given for this one */
19246 #pragma GCC diagnostic push
19247 #pragma GCC diagnostic ignored "-Wuninitialized"
19248 foo(b); /* no diagnostic for this one */
19249 #pragma GCC diagnostic pop
19250 foo(c); /* error is given for this one */
19251 #pragma GCC diagnostic pop
19252 foo(d); /* depends on command-line options */
19253 @end smallexample
19254
19255 @end table
19256
19257 GCC also offers a simple mechanism for printing messages during
19258 compilation.
19259
19260 @table @code
19261 @item #pragma message @var{string}
19262 @cindex pragma, diagnostic
19263
19264 Prints @var{string} as a compiler message on compilation. The message
19265 is informational only, and is neither a compilation warning nor an error.
19266
19267 @smallexample
19268 #pragma message "Compiling " __FILE__ "..."
19269 @end smallexample
19270
19271 @var{string} may be parenthesized, and is printed with location
19272 information. For example,
19273
19274 @smallexample
19275 #define DO_PRAGMA(x) _Pragma (#x)
19276 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
19277
19278 TODO(Remember to fix this)
19279 @end smallexample
19280
19281 @noindent
19282 prints @samp{/tmp/file.c:4: note: #pragma message:
19283 TODO - Remember to fix this}.
19284
19285 @end table
19286
19287 @node Visibility Pragmas
19288 @subsection Visibility Pragmas
19289
19290 @table @code
19291 @item #pragma GCC visibility push(@var{visibility})
19292 @itemx #pragma GCC visibility pop
19293 @cindex pragma, visibility
19294
19295 This pragma allows the user to set the visibility for multiple
19296 declarations without having to give each a visibility attribute
19297 (@pxref{Function Attributes}).
19298
19299 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
19300 declarations. Class members and template specializations are not
19301 affected; if you want to override the visibility for a particular
19302 member or instantiation, you must use an attribute.
19303
19304 @end table
19305
19306
19307 @node Push/Pop Macro Pragmas
19308 @subsection Push/Pop Macro Pragmas
19309
19310 For compatibility with Microsoft Windows compilers, GCC supports
19311 @samp{#pragma push_macro(@var{"macro_name"})}
19312 and @samp{#pragma pop_macro(@var{"macro_name"})}.
19313
19314 @table @code
19315 @item #pragma push_macro(@var{"macro_name"})
19316 @cindex pragma, push_macro
19317 This pragma saves the value of the macro named as @var{macro_name} to
19318 the top of the stack for this macro.
19319
19320 @item #pragma pop_macro(@var{"macro_name"})
19321 @cindex pragma, pop_macro
19322 This pragma sets the value of the macro named as @var{macro_name} to
19323 the value on top of the stack for this macro. If the stack for
19324 @var{macro_name} is empty, the value of the macro remains unchanged.
19325 @end table
19326
19327 For example:
19328
19329 @smallexample
19330 #define X 1
19331 #pragma push_macro("X")
19332 #undef X
19333 #define X -1
19334 #pragma pop_macro("X")
19335 int x [X];
19336 @end smallexample
19337
19338 @noindent
19339 In this example, the definition of X as 1 is saved by @code{#pragma
19340 push_macro} and restored by @code{#pragma pop_macro}.
19341
19342 @node Function Specific Option Pragmas
19343 @subsection Function Specific Option Pragmas
19344
19345 @table @code
19346 @item #pragma GCC target (@var{"string"}...)
19347 @cindex pragma GCC target
19348
19349 This pragma allows you to set target specific options for functions
19350 defined later in the source file. One or more strings can be
19351 specified. Each function that is defined after this point is as
19352 if @code{attribute((target("STRING")))} was specified for that
19353 function. The parenthesis around the options is optional.
19354 @xref{Function Attributes}, for more information about the
19355 @code{target} attribute and the attribute syntax.
19356
19357 The @code{#pragma GCC target} pragma is presently implemented for
19358 x86, PowerPC, and Nios II targets only.
19359 @end table
19360
19361 @table @code
19362 @item #pragma GCC optimize (@var{"string"}...)
19363 @cindex pragma GCC optimize
19364
19365 This pragma allows you to set global optimization options for functions
19366 defined later in the source file. One or more strings can be
19367 specified. Each function that is defined after this point is as
19368 if @code{attribute((optimize("STRING")))} was specified for that
19369 function. The parenthesis around the options is optional.
19370 @xref{Function Attributes}, for more information about the
19371 @code{optimize} attribute and the attribute syntax.
19372 @end table
19373
19374 @table @code
19375 @item #pragma GCC push_options
19376 @itemx #pragma GCC pop_options
19377 @cindex pragma GCC push_options
19378 @cindex pragma GCC pop_options
19379
19380 These pragmas maintain a stack of the current target and optimization
19381 options. It is intended for include files where you temporarily want
19382 to switch to using a different @samp{#pragma GCC target} or
19383 @samp{#pragma GCC optimize} and then to pop back to the previous
19384 options.
19385 @end table
19386
19387 @table @code
19388 @item #pragma GCC reset_options
19389 @cindex pragma GCC reset_options
19390
19391 This pragma clears the current @code{#pragma GCC target} and
19392 @code{#pragma GCC optimize} to use the default switches as specified
19393 on the command line.
19394 @end table
19395
19396 @node Loop-Specific Pragmas
19397 @subsection Loop-Specific Pragmas
19398
19399 @table @code
19400 @item #pragma GCC ivdep
19401 @cindex pragma GCC ivdep
19402 @end table
19403
19404 With this pragma, the programmer asserts that there are no loop-carried
19405 dependencies which would prevent consecutive iterations of
19406 the following loop from executing concurrently with SIMD
19407 (single instruction multiple data) instructions.
19408
19409 For example, the compiler can only unconditionally vectorize the following
19410 loop with the pragma:
19411
19412 @smallexample
19413 void foo (int n, int *a, int *b, int *c)
19414 @{
19415 int i, j;
19416 #pragma GCC ivdep
19417 for (i = 0; i < n; ++i)
19418 a[i] = b[i] + c[i];
19419 @}
19420 @end smallexample
19421
19422 @noindent
19423 In this example, using the @code{restrict} qualifier had the same
19424 effect. In the following example, that would not be possible. Assume
19425 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19426 that it can unconditionally vectorize the following loop:
19427
19428 @smallexample
19429 void ignore_vec_dep (int *a, int k, int c, int m)
19430 @{
19431 #pragma GCC ivdep
19432 for (int i = 0; i < m; i++)
19433 a[i] = a[i + k] * c;
19434 @}
19435 @end smallexample
19436
19437
19438 @node Unnamed Fields
19439 @section Unnamed Structure and Union Fields
19440 @cindex @code{struct}
19441 @cindex @code{union}
19442
19443 As permitted by ISO C11 and for compatibility with other compilers,
19444 GCC allows you to define
19445 a structure or union that contains, as fields, structures and unions
19446 without names. For example:
19447
19448 @smallexample
19449 struct @{
19450 int a;
19451 union @{
19452 int b;
19453 float c;
19454 @};
19455 int d;
19456 @} foo;
19457 @end smallexample
19458
19459 @noindent
19460 In this example, you are able to access members of the unnamed
19461 union with code like @samp{foo.b}. Note that only unnamed structs and
19462 unions are allowed, you may not have, for example, an unnamed
19463 @code{int}.
19464
19465 You must never create such structures that cause ambiguous field definitions.
19466 For example, in this structure:
19467
19468 @smallexample
19469 struct @{
19470 int a;
19471 struct @{
19472 int a;
19473 @};
19474 @} foo;
19475 @end smallexample
19476
19477 @noindent
19478 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19479 The compiler gives errors for such constructs.
19480
19481 @opindex fms-extensions
19482 Unless @option{-fms-extensions} is used, the unnamed field must be a
19483 structure or union definition without a tag (for example, @samp{struct
19484 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19485 also be a definition with a tag such as @samp{struct foo @{ int a;
19486 @};}, a reference to a previously defined structure or union such as
19487 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19488 previously defined structure or union type.
19489
19490 @opindex fplan9-extensions
19491 The option @option{-fplan9-extensions} enables
19492 @option{-fms-extensions} as well as two other extensions. First, a
19493 pointer to a structure is automatically converted to a pointer to an
19494 anonymous field for assignments and function calls. For example:
19495
19496 @smallexample
19497 struct s1 @{ int a; @};
19498 struct s2 @{ struct s1; @};
19499 extern void f1 (struct s1 *);
19500 void f2 (struct s2 *p) @{ f1 (p); @}
19501 @end smallexample
19502
19503 @noindent
19504 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19505 converted into a pointer to the anonymous field.
19506
19507 Second, when the type of an anonymous field is a @code{typedef} for a
19508 @code{struct} or @code{union}, code may refer to the field using the
19509 name of the @code{typedef}.
19510
19511 @smallexample
19512 typedef struct @{ int a; @} s1;
19513 struct s2 @{ s1; @};
19514 s1 f1 (struct s2 *p) @{ return p->s1; @}
19515 @end smallexample
19516
19517 These usages are only permitted when they are not ambiguous.
19518
19519 @node Thread-Local
19520 @section Thread-Local Storage
19521 @cindex Thread-Local Storage
19522 @cindex @acronym{TLS}
19523 @cindex @code{__thread}
19524
19525 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19526 are allocated such that there is one instance of the variable per extant
19527 thread. The runtime model GCC uses to implement this originates
19528 in the IA-64 processor-specific ABI, but has since been migrated
19529 to other processors as well. It requires significant support from
19530 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19531 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19532 is not available everywhere.
19533
19534 At the user level, the extension is visible with a new storage
19535 class keyword: @code{__thread}. For example:
19536
19537 @smallexample
19538 __thread int i;
19539 extern __thread struct state s;
19540 static __thread char *p;
19541 @end smallexample
19542
19543 The @code{__thread} specifier may be used alone, with the @code{extern}
19544 or @code{static} specifiers, but with no other storage class specifier.
19545 When used with @code{extern} or @code{static}, @code{__thread} must appear
19546 immediately after the other storage class specifier.
19547
19548 The @code{__thread} specifier may be applied to any global, file-scoped
19549 static, function-scoped static, or static data member of a class. It may
19550 not be applied to block-scoped automatic or non-static data member.
19551
19552 When the address-of operator is applied to a thread-local variable, it is
19553 evaluated at run time and returns the address of the current thread's
19554 instance of that variable. An address so obtained may be used by any
19555 thread. When a thread terminates, any pointers to thread-local variables
19556 in that thread become invalid.
19557
19558 No static initialization may refer to the address of a thread-local variable.
19559
19560 In C++, if an initializer is present for a thread-local variable, it must
19561 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19562 standard.
19563
19564 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19565 ELF Handling For Thread-Local Storage} for a detailed explanation of
19566 the four thread-local storage addressing models, and how the runtime
19567 is expected to function.
19568
19569 @menu
19570 * C99 Thread-Local Edits::
19571 * C++98 Thread-Local Edits::
19572 @end menu
19573
19574 @node C99 Thread-Local Edits
19575 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19576
19577 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19578 that document the exact semantics of the language extension.
19579
19580 @itemize @bullet
19581 @item
19582 @cite{5.1.2 Execution environments}
19583
19584 Add new text after paragraph 1
19585
19586 @quotation
19587 Within either execution environment, a @dfn{thread} is a flow of
19588 control within a program. It is implementation defined whether
19589 or not there may be more than one thread associated with a program.
19590 It is implementation defined how threads beyond the first are
19591 created, the name and type of the function called at thread
19592 startup, and how threads may be terminated. However, objects
19593 with thread storage duration shall be initialized before thread
19594 startup.
19595 @end quotation
19596
19597 @item
19598 @cite{6.2.4 Storage durations of objects}
19599
19600 Add new text before paragraph 3
19601
19602 @quotation
19603 An object whose identifier is declared with the storage-class
19604 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19605 Its lifetime is the entire execution of the thread, and its
19606 stored value is initialized only once, prior to thread startup.
19607 @end quotation
19608
19609 @item
19610 @cite{6.4.1 Keywords}
19611
19612 Add @code{__thread}.
19613
19614 @item
19615 @cite{6.7.1 Storage-class specifiers}
19616
19617 Add @code{__thread} to the list of storage class specifiers in
19618 paragraph 1.
19619
19620 Change paragraph 2 to
19621
19622 @quotation
19623 With the exception of @code{__thread}, at most one storage-class
19624 specifier may be given [@dots{}]. The @code{__thread} specifier may
19625 be used alone, or immediately following @code{extern} or
19626 @code{static}.
19627 @end quotation
19628
19629 Add new text after paragraph 6
19630
19631 @quotation
19632 The declaration of an identifier for a variable that has
19633 block scope that specifies @code{__thread} shall also
19634 specify either @code{extern} or @code{static}.
19635
19636 The @code{__thread} specifier shall be used only with
19637 variables.
19638 @end quotation
19639 @end itemize
19640
19641 @node C++98 Thread-Local Edits
19642 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19643
19644 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19645 that document the exact semantics of the language extension.
19646
19647 @itemize @bullet
19648 @item
19649 @b{[intro.execution]}
19650
19651 New text after paragraph 4
19652
19653 @quotation
19654 A @dfn{thread} is a flow of control within the abstract machine.
19655 It is implementation defined whether or not there may be more than
19656 one thread.
19657 @end quotation
19658
19659 New text after paragraph 7
19660
19661 @quotation
19662 It is unspecified whether additional action must be taken to
19663 ensure when and whether side effects are visible to other threads.
19664 @end quotation
19665
19666 @item
19667 @b{[lex.key]}
19668
19669 Add @code{__thread}.
19670
19671 @item
19672 @b{[basic.start.main]}
19673
19674 Add after paragraph 5
19675
19676 @quotation
19677 The thread that begins execution at the @code{main} function is called
19678 the @dfn{main thread}. It is implementation defined how functions
19679 beginning threads other than the main thread are designated or typed.
19680 A function so designated, as well as the @code{main} function, is called
19681 a @dfn{thread startup function}. It is implementation defined what
19682 happens if a thread startup function returns. It is implementation
19683 defined what happens to other threads when any thread calls @code{exit}.
19684 @end quotation
19685
19686 @item
19687 @b{[basic.start.init]}
19688
19689 Add after paragraph 4
19690
19691 @quotation
19692 The storage for an object of thread storage duration shall be
19693 statically initialized before the first statement of the thread startup
19694 function. An object of thread storage duration shall not require
19695 dynamic initialization.
19696 @end quotation
19697
19698 @item
19699 @b{[basic.start.term]}
19700
19701 Add after paragraph 3
19702
19703 @quotation
19704 The type of an object with thread storage duration shall not have a
19705 non-trivial destructor, nor shall it be an array type whose elements
19706 (directly or indirectly) have non-trivial destructors.
19707 @end quotation
19708
19709 @item
19710 @b{[basic.stc]}
19711
19712 Add ``thread storage duration'' to the list in paragraph 1.
19713
19714 Change paragraph 2
19715
19716 @quotation
19717 Thread, static, and automatic storage durations are associated with
19718 objects introduced by declarations [@dots{}].
19719 @end quotation
19720
19721 Add @code{__thread} to the list of specifiers in paragraph 3.
19722
19723 @item
19724 @b{[basic.stc.thread]}
19725
19726 New section before @b{[basic.stc.static]}
19727
19728 @quotation
19729 The keyword @code{__thread} applied to a non-local object gives the
19730 object thread storage duration.
19731
19732 A local variable or class data member declared both @code{static}
19733 and @code{__thread} gives the variable or member thread storage
19734 duration.
19735 @end quotation
19736
19737 @item
19738 @b{[basic.stc.static]}
19739
19740 Change paragraph 1
19741
19742 @quotation
19743 All objects that have neither thread storage duration, dynamic
19744 storage duration nor are local [@dots{}].
19745 @end quotation
19746
19747 @item
19748 @b{[dcl.stc]}
19749
19750 Add @code{__thread} to the list in paragraph 1.
19751
19752 Change paragraph 1
19753
19754 @quotation
19755 With the exception of @code{__thread}, at most one
19756 @var{storage-class-specifier} shall appear in a given
19757 @var{decl-specifier-seq}. The @code{__thread} specifier may
19758 be used alone, or immediately following the @code{extern} or
19759 @code{static} specifiers. [@dots{}]
19760 @end quotation
19761
19762 Add after paragraph 5
19763
19764 @quotation
19765 The @code{__thread} specifier can be applied only to the names of objects
19766 and to anonymous unions.
19767 @end quotation
19768
19769 @item
19770 @b{[class.mem]}
19771
19772 Add after paragraph 6
19773
19774 @quotation
19775 Non-@code{static} members shall not be @code{__thread}.
19776 @end quotation
19777 @end itemize
19778
19779 @node Binary constants
19780 @section Binary Constants using the @samp{0b} Prefix
19781 @cindex Binary constants using the @samp{0b} prefix
19782
19783 Integer constants can be written as binary constants, consisting of a
19784 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19785 @samp{0B}. This is particularly useful in environments that operate a
19786 lot on the bit level (like microcontrollers).
19787
19788 The following statements are identical:
19789
19790 @smallexample
19791 i = 42;
19792 i = 0x2a;
19793 i = 052;
19794 i = 0b101010;
19795 @end smallexample
19796
19797 The type of these constants follows the same rules as for octal or
19798 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19799 can be applied.
19800
19801 @node C++ Extensions
19802 @chapter Extensions to the C++ Language
19803 @cindex extensions, C++ language
19804 @cindex C++ language extensions
19805
19806 The GNU compiler provides these extensions to the C++ language (and you
19807 can also use most of the C language extensions in your C++ programs). If you
19808 want to write code that checks whether these features are available, you can
19809 test for the GNU compiler the same way as for C programs: check for a
19810 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19811 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19812 Predefined Macros,cpp,The GNU C Preprocessor}).
19813
19814 @menu
19815 * C++ Volatiles:: What constitutes an access to a volatile object.
19816 * Restricted Pointers:: C99 restricted pointers and references.
19817 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19818 * C++ Interface:: You can use a single C++ header file for both
19819 declarations and definitions.
19820 * Template Instantiation:: Methods for ensuring that exactly one copy of
19821 each needed template instantiation is emitted.
19822 * Bound member functions:: You can extract a function pointer to the
19823 method denoted by a @samp{->*} or @samp{.*} expression.
19824 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19825 * Function Multiversioning:: Declaring multiple function versions.
19826 * Namespace Association:: Strong using-directives for namespace association.
19827 * Type Traits:: Compiler support for type traits.
19828 * C++ Concepts:: Improved support for generic programming.
19829 * Java Exceptions:: Tweaking exception handling to work with Java.
19830 * Deprecated Features:: Things will disappear from G++.
19831 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19832 @end menu
19833
19834 @node C++ Volatiles
19835 @section When is a Volatile C++ Object Accessed?
19836 @cindex accessing volatiles
19837 @cindex volatile read
19838 @cindex volatile write
19839 @cindex volatile access
19840
19841 The C++ standard differs from the C standard in its treatment of
19842 volatile objects. It fails to specify what constitutes a volatile
19843 access, except to say that C++ should behave in a similar manner to C
19844 with respect to volatiles, where possible. However, the different
19845 lvalueness of expressions between C and C++ complicate the behavior.
19846 G++ behaves the same as GCC for volatile access, @xref{C
19847 Extensions,,Volatiles}, for a description of GCC's behavior.
19848
19849 The C and C++ language specifications differ when an object is
19850 accessed in a void context:
19851
19852 @smallexample
19853 volatile int *src = @var{somevalue};
19854 *src;
19855 @end smallexample
19856
19857 The C++ standard specifies that such expressions do not undergo lvalue
19858 to rvalue conversion, and that the type of the dereferenced object may
19859 be incomplete. The C++ standard does not specify explicitly that it
19860 is lvalue to rvalue conversion that is responsible for causing an
19861 access. There is reason to believe that it is, because otherwise
19862 certain simple expressions become undefined. However, because it
19863 would surprise most programmers, G++ treats dereferencing a pointer to
19864 volatile object of complete type as GCC would do for an equivalent
19865 type in C@. When the object has incomplete type, G++ issues a
19866 warning; if you wish to force an error, you must force a conversion to
19867 rvalue with, for instance, a static cast.
19868
19869 When using a reference to volatile, G++ does not treat equivalent
19870 expressions as accesses to volatiles, but instead issues a warning that
19871 no volatile is accessed. The rationale for this is that otherwise it
19872 becomes difficult to determine where volatile access occur, and not
19873 possible to ignore the return value from functions returning volatile
19874 references. Again, if you wish to force a read, cast the reference to
19875 an rvalue.
19876
19877 G++ implements the same behavior as GCC does when assigning to a
19878 volatile object---there is no reread of the assigned-to object, the
19879 assigned rvalue is reused. Note that in C++ assignment expressions
19880 are lvalues, and if used as an lvalue, the volatile object is
19881 referred to. For instance, @var{vref} refers to @var{vobj}, as
19882 expected, in the following example:
19883
19884 @smallexample
19885 volatile int vobj;
19886 volatile int &vref = vobj = @var{something};
19887 @end smallexample
19888
19889 @node Restricted Pointers
19890 @section Restricting Pointer Aliasing
19891 @cindex restricted pointers
19892 @cindex restricted references
19893 @cindex restricted this pointer
19894
19895 As with the C front end, G++ understands the C99 feature of restricted pointers,
19896 specified with the @code{__restrict__}, or @code{__restrict} type
19897 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19898 language flag, @code{restrict} is not a keyword in C++.
19899
19900 In addition to allowing restricted pointers, you can specify restricted
19901 references, which indicate that the reference is not aliased in the local
19902 context.
19903
19904 @smallexample
19905 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19906 @{
19907 /* @r{@dots{}} */
19908 @}
19909 @end smallexample
19910
19911 @noindent
19912 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19913 @var{rref} refers to a (different) unaliased integer.
19914
19915 You may also specify whether a member function's @var{this} pointer is
19916 unaliased by using @code{__restrict__} as a member function qualifier.
19917
19918 @smallexample
19919 void T::fn () __restrict__
19920 @{
19921 /* @r{@dots{}} */
19922 @}
19923 @end smallexample
19924
19925 @noindent
19926 Within the body of @code{T::fn}, @var{this} has the effective
19927 definition @code{T *__restrict__ const this}. Notice that the
19928 interpretation of a @code{__restrict__} member function qualifier is
19929 different to that of @code{const} or @code{volatile} qualifier, in that it
19930 is applied to the pointer rather than the object. This is consistent with
19931 other compilers that implement restricted pointers.
19932
19933 As with all outermost parameter qualifiers, @code{__restrict__} is
19934 ignored in function definition matching. This means you only need to
19935 specify @code{__restrict__} in a function definition, rather than
19936 in a function prototype as well.
19937
19938 @node Vague Linkage
19939 @section Vague Linkage
19940 @cindex vague linkage
19941
19942 There are several constructs in C++ that require space in the object
19943 file but are not clearly tied to a single translation unit. We say that
19944 these constructs have ``vague linkage''. Typically such constructs are
19945 emitted wherever they are needed, though sometimes we can be more
19946 clever.
19947
19948 @table @asis
19949 @item Inline Functions
19950 Inline functions are typically defined in a header file which can be
19951 included in many different compilations. Hopefully they can usually be
19952 inlined, but sometimes an out-of-line copy is necessary, if the address
19953 of the function is taken or if inlining fails. In general, we emit an
19954 out-of-line copy in all translation units where one is needed. As an
19955 exception, we only emit inline virtual functions with the vtable, since
19956 it always requires a copy.
19957
19958 Local static variables and string constants used in an inline function
19959 are also considered to have vague linkage, since they must be shared
19960 between all inlined and out-of-line instances of the function.
19961
19962 @item VTables
19963 @cindex vtable
19964 C++ virtual functions are implemented in most compilers using a lookup
19965 table, known as a vtable. The vtable contains pointers to the virtual
19966 functions provided by a class, and each object of the class contains a
19967 pointer to its vtable (or vtables, in some multiple-inheritance
19968 situations). If the class declares any non-inline, non-pure virtual
19969 functions, the first one is chosen as the ``key method'' for the class,
19970 and the vtable is only emitted in the translation unit where the key
19971 method is defined.
19972
19973 @emph{Note:} If the chosen key method is later defined as inline, the
19974 vtable is still emitted in every translation unit that defines it.
19975 Make sure that any inline virtuals are declared inline in the class
19976 body, even if they are not defined there.
19977
19978 @item @code{type_info} objects
19979 @cindex @code{type_info}
19980 @cindex RTTI
19981 C++ requires information about types to be written out in order to
19982 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19983 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19984 object is written out along with the vtable so that @samp{dynamic_cast}
19985 can determine the dynamic type of a class object at run time. For all
19986 other types, we write out the @samp{type_info} object when it is used: when
19987 applying @samp{typeid} to an expression, throwing an object, or
19988 referring to a type in a catch clause or exception specification.
19989
19990 @item Template Instantiations
19991 Most everything in this section also applies to template instantiations,
19992 but there are other options as well.
19993 @xref{Template Instantiation,,Where's the Template?}.
19994
19995 @end table
19996
19997 When used with GNU ld version 2.8 or later on an ELF system such as
19998 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19999 these constructs will be discarded at link time. This is known as
20000 COMDAT support.
20001
20002 On targets that don't support COMDAT, but do support weak symbols, GCC
20003 uses them. This way one copy overrides all the others, but
20004 the unused copies still take up space in the executable.
20005
20006 For targets that do not support either COMDAT or weak symbols,
20007 most entities with vague linkage are emitted as local symbols to
20008 avoid duplicate definition errors from the linker. This does not happen
20009 for local statics in inlines, however, as having multiple copies
20010 almost certainly breaks things.
20011
20012 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
20013 another way to control placement of these constructs.
20014
20015 @node C++ Interface
20016 @section C++ Interface and Implementation Pragmas
20017
20018 @cindex interface and implementation headers, C++
20019 @cindex C++ interface and implementation headers
20020 @cindex pragmas, interface and implementation
20021
20022 @code{#pragma interface} and @code{#pragma implementation} provide the
20023 user with a way of explicitly directing the compiler to emit entities
20024 with vague linkage (and debugging information) in a particular
20025 translation unit.
20026
20027 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
20028 by COMDAT support and the ``key method'' heuristic
20029 mentioned in @ref{Vague Linkage}. Using them can actually cause your
20030 program to grow due to unnecessary out-of-line copies of inline
20031 functions.
20032
20033 @table @code
20034 @item #pragma interface
20035 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
20036 @kindex #pragma interface
20037 Use this directive in @emph{header files} that define object classes, to save
20038 space in most of the object files that use those classes. Normally,
20039 local copies of certain information (backup copies of inline member
20040 functions, debugging information, and the internal tables that implement
20041 virtual functions) must be kept in each object file that includes class
20042 definitions. You can use this pragma to avoid such duplication. When a
20043 header file containing @samp{#pragma interface} is included in a
20044 compilation, this auxiliary information is not generated (unless
20045 the main input source file itself uses @samp{#pragma implementation}).
20046 Instead, the object files contain references to be resolved at link
20047 time.
20048
20049 The second form of this directive is useful for the case where you have
20050 multiple headers with the same name in different directories. If you
20051 use this form, you must specify the same string to @samp{#pragma
20052 implementation}.
20053
20054 @item #pragma implementation
20055 @itemx #pragma implementation "@var{objects}.h"
20056 @kindex #pragma implementation
20057 Use this pragma in a @emph{main input file}, when you want full output from
20058 included header files to be generated (and made globally visible). The
20059 included header file, in turn, should use @samp{#pragma interface}.
20060 Backup copies of inline member functions, debugging information, and the
20061 internal tables used to implement virtual functions are all generated in
20062 implementation files.
20063
20064 @cindex implied @code{#pragma implementation}
20065 @cindex @code{#pragma implementation}, implied
20066 @cindex naming convention, implementation headers
20067 If you use @samp{#pragma implementation} with no argument, it applies to
20068 an include file with the same basename@footnote{A file's @dfn{basename}
20069 is the name stripped of all leading path information and of trailing
20070 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
20071 file. For example, in @file{allclass.cc}, giving just
20072 @samp{#pragma implementation}
20073 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
20074
20075 Use the string argument if you want a single implementation file to
20076 include code from multiple header files. (You must also use
20077 @samp{#include} to include the header file; @samp{#pragma
20078 implementation} only specifies how to use the file---it doesn't actually
20079 include it.)
20080
20081 There is no way to split up the contents of a single header file into
20082 multiple implementation files.
20083 @end table
20084
20085 @cindex inlining and C++ pragmas
20086 @cindex C++ pragmas, effect on inlining
20087 @cindex pragmas in C++, effect on inlining
20088 @samp{#pragma implementation} and @samp{#pragma interface} also have an
20089 effect on function inlining.
20090
20091 If you define a class in a header file marked with @samp{#pragma
20092 interface}, the effect on an inline function defined in that class is
20093 similar to an explicit @code{extern} declaration---the compiler emits
20094 no code at all to define an independent version of the function. Its
20095 definition is used only for inlining with its callers.
20096
20097 @opindex fno-implement-inlines
20098 Conversely, when you include the same header file in a main source file
20099 that declares it as @samp{#pragma implementation}, the compiler emits
20100 code for the function itself; this defines a version of the function
20101 that can be found via pointers (or by callers compiled without
20102 inlining). If all calls to the function can be inlined, you can avoid
20103 emitting the function by compiling with @option{-fno-implement-inlines}.
20104 If any calls are not inlined, you will get linker errors.
20105
20106 @node Template Instantiation
20107 @section Where's the Template?
20108 @cindex template instantiation
20109
20110 C++ templates were the first language feature to require more
20111 intelligence from the environment than was traditionally found on a UNIX
20112 system. Somehow the compiler and linker have to make sure that each
20113 template instance occurs exactly once in the executable if it is needed,
20114 and not at all otherwise. There are two basic approaches to this
20115 problem, which are referred to as the Borland model and the Cfront model.
20116
20117 @table @asis
20118 @item Borland model
20119 Borland C++ solved the template instantiation problem by adding the code
20120 equivalent of common blocks to their linker; the compiler emits template
20121 instances in each translation unit that uses them, and the linker
20122 collapses them together. The advantage of this model is that the linker
20123 only has to consider the object files themselves; there is no external
20124 complexity to worry about. The disadvantage is that compilation time
20125 is increased because the template code is being compiled repeatedly.
20126 Code written for this model tends to include definitions of all
20127 templates in the header file, since they must be seen to be
20128 instantiated.
20129
20130 @item Cfront model
20131 The AT&T C++ translator, Cfront, solved the template instantiation
20132 problem by creating the notion of a template repository, an
20133 automatically maintained place where template instances are stored. A
20134 more modern version of the repository works as follows: As individual
20135 object files are built, the compiler places any template definitions and
20136 instantiations encountered in the repository. At link time, the link
20137 wrapper adds in the objects in the repository and compiles any needed
20138 instances that were not previously emitted. The advantages of this
20139 model are more optimal compilation speed and the ability to use the
20140 system linker; to implement the Borland model a compiler vendor also
20141 needs to replace the linker. The disadvantages are vastly increased
20142 complexity, and thus potential for error; for some code this can be
20143 just as transparent, but in practice it can been very difficult to build
20144 multiple programs in one directory and one program in multiple
20145 directories. Code written for this model tends to separate definitions
20146 of non-inline member templates into a separate file, which should be
20147 compiled separately.
20148 @end table
20149
20150 G++ implements the Borland model on targets where the linker supports it,
20151 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
20152 Otherwise G++ implements neither automatic model.
20153
20154 You have the following options for dealing with template instantiations:
20155
20156 @enumerate
20157 @item
20158 Do nothing. Code written for the Borland model works fine, but
20159 each translation unit contains instances of each of the templates it
20160 uses. The duplicate instances will be discarded by the linker, but in
20161 a large program, this can lead to an unacceptable amount of code
20162 duplication in object files or shared libraries.
20163
20164 Duplicate instances of a template can be avoided by defining an explicit
20165 instantiation in one object file, and preventing the compiler from doing
20166 implicit instantiations in any other object files by using an explicit
20167 instantiation declaration, using the @code{extern template} syntax:
20168
20169 @smallexample
20170 extern template int max (int, int);
20171 @end smallexample
20172
20173 This syntax is defined in the C++ 2011 standard, but has been supported by
20174 G++ and other compilers since well before 2011.
20175
20176 Explicit instantiations can be used for the largest or most frequently
20177 duplicated instances, without having to know exactly which other instances
20178 are used in the rest of the program. You can scatter the explicit
20179 instantiations throughout your program, perhaps putting them in the
20180 translation units where the instances are used or the translation units
20181 that define the templates themselves; you can put all of the explicit
20182 instantiations you need into one big file; or you can create small files
20183 like
20184
20185 @smallexample
20186 #include "Foo.h"
20187 #include "Foo.cc"
20188
20189 template class Foo<int>;
20190 template ostream& operator <<
20191 (ostream&, const Foo<int>&);
20192 @end smallexample
20193
20194 @noindent
20195 for each of the instances you need, and create a template instantiation
20196 library from those.
20197
20198 This is the simplest option, but also offers flexibility and
20199 fine-grained control when necessary. It is also the most portable
20200 alternative and programs using this approach will work with most modern
20201 compilers.
20202
20203 @item
20204 @opindex frepo
20205 Compile your template-using code with @option{-frepo}. The compiler
20206 generates files with the extension @samp{.rpo} listing all of the
20207 template instantiations used in the corresponding object files that
20208 could be instantiated there; the link wrapper, @samp{collect2},
20209 then updates the @samp{.rpo} files to tell the compiler where to place
20210 those instantiations and rebuild any affected object files. The
20211 link-time overhead is negligible after the first pass, as the compiler
20212 continues to place the instantiations in the same files.
20213
20214 This can be a suitable option for application code written for the Borland
20215 model, as it usually just works. Code written for the Cfront model
20216 needs to be modified so that the template definitions are available at
20217 one or more points of instantiation; usually this is as simple as adding
20218 @code{#include <tmethods.cc>} to the end of each template header.
20219
20220 For library code, if you want the library to provide all of the template
20221 instantiations it needs, just try to link all of its object files
20222 together; the link will fail, but cause the instantiations to be
20223 generated as a side effect. Be warned, however, that this may cause
20224 conflicts if multiple libraries try to provide the same instantiations.
20225 For greater control, use explicit instantiation as described in the next
20226 option.
20227
20228 @item
20229 @opindex fno-implicit-templates
20230 Compile your code with @option{-fno-implicit-templates} to disable the
20231 implicit generation of template instances, and explicitly instantiate
20232 all the ones you use. This approach requires more knowledge of exactly
20233 which instances you need than do the others, but it's less
20234 mysterious and allows greater control if you want to ensure that only
20235 the intended instances are used.
20236
20237 If you are using Cfront-model code, you can probably get away with not
20238 using @option{-fno-implicit-templates} when compiling files that don't
20239 @samp{#include} the member template definitions.
20240
20241 If you use one big file to do the instantiations, you may want to
20242 compile it without @option{-fno-implicit-templates} so you get all of the
20243 instances required by your explicit instantiations (but not by any
20244 other files) without having to specify them as well.
20245
20246 In addition to forward declaration of explicit instantiations
20247 (with @code{extern}), G++ has extended the template instantiation
20248 syntax to support instantiation of the compiler support data for a
20249 template class (i.e.@: the vtable) without instantiating any of its
20250 members (with @code{inline}), and instantiation of only the static data
20251 members of a template class, without the support data or member
20252 functions (with @code{static}):
20253
20254 @smallexample
20255 inline template class Foo<int>;
20256 static template class Foo<int>;
20257 @end smallexample
20258 @end enumerate
20259
20260 @node Bound member functions
20261 @section Extracting the Function Pointer from a Bound Pointer to Member Function
20262 @cindex pmf
20263 @cindex pointer to member function
20264 @cindex bound pointer to member function
20265
20266 In C++, pointer to member functions (PMFs) are implemented using a wide
20267 pointer of sorts to handle all the possible call mechanisms; the PMF
20268 needs to store information about how to adjust the @samp{this} pointer,
20269 and if the function pointed to is virtual, where to find the vtable, and
20270 where in the vtable to look for the member function. If you are using
20271 PMFs in an inner loop, you should really reconsider that decision. If
20272 that is not an option, you can extract the pointer to the function that
20273 would be called for a given object/PMF pair and call it directly inside
20274 the inner loop, to save a bit of time.
20275
20276 Note that you still pay the penalty for the call through a
20277 function pointer; on most modern architectures, such a call defeats the
20278 branch prediction features of the CPU@. This is also true of normal
20279 virtual function calls.
20280
20281 The syntax for this extension is
20282
20283 @smallexample
20284 extern A a;
20285 extern int (A::*fp)();
20286 typedef int (*fptr)(A *);
20287
20288 fptr p = (fptr)(a.*fp);
20289 @end smallexample
20290
20291 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
20292 no object is needed to obtain the address of the function. They can be
20293 converted to function pointers directly:
20294
20295 @smallexample
20296 fptr p1 = (fptr)(&A::foo);
20297 @end smallexample
20298
20299 @opindex Wno-pmf-conversions
20300 You must specify @option{-Wno-pmf-conversions} to use this extension.
20301
20302 @node C++ Attributes
20303 @section C++-Specific Variable, Function, and Type Attributes
20304
20305 Some attributes only make sense for C++ programs.
20306
20307 @table @code
20308 @item abi_tag ("@var{tag}", ...)
20309 @cindex @code{abi_tag} function attribute
20310 @cindex @code{abi_tag} variable attribute
20311 @cindex @code{abi_tag} type attribute
20312 The @code{abi_tag} attribute can be applied to a function, variable, or class
20313 declaration. It modifies the mangled name of the entity to
20314 incorporate the tag name, in order to distinguish the function or
20315 class from an earlier version with a different ABI; perhaps the class
20316 has changed size, or the function has a different return type that is
20317 not encoded in the mangled name.
20318
20319 The attribute can also be applied to an inline namespace, but does not
20320 affect the mangled name of the namespace; in this case it is only used
20321 for @option{-Wabi-tag} warnings and automatic tagging of functions and
20322 variables. Tagging inline namespaces is generally preferable to
20323 tagging individual declarations, but the latter is sometimes
20324 necessary, such as when only certain members of a class need to be
20325 tagged.
20326
20327 The argument can be a list of strings of arbitrary length. The
20328 strings are sorted on output, so the order of the list is
20329 unimportant.
20330
20331 A redeclaration of an entity must not add new ABI tags,
20332 since doing so would change the mangled name.
20333
20334 The ABI tags apply to a name, so all instantiations and
20335 specializations of a template have the same tags. The attribute will
20336 be ignored if applied to an explicit specialization or instantiation.
20337
20338 The @option{-Wabi-tag} flag enables a warning about a class which does
20339 not have all the ABI tags used by its subobjects and virtual functions; for users with code
20340 that needs to coexist with an earlier ABI, using this option can help
20341 to find all affected types that need to be tagged.
20342
20343 When a type involving an ABI tag is used as the type of a variable or
20344 return type of a function where that tag is not already present in the
20345 signature of the function, the tag is automatically applied to the
20346 variable or function. @option{-Wabi-tag} also warns about this
20347 situation; this warning can be avoided by explicitly tagging the
20348 variable or function or moving it into a tagged inline namespace.
20349
20350 @item init_priority (@var{priority})
20351 @cindex @code{init_priority} variable attribute
20352
20353 In Standard C++, objects defined at namespace scope are guaranteed to be
20354 initialized in an order in strict accordance with that of their definitions
20355 @emph{in a given translation unit}. No guarantee is made for initializations
20356 across translation units. However, GNU C++ allows users to control the
20357 order of initialization of objects defined at namespace scope with the
20358 @code{init_priority} attribute by specifying a relative @var{priority},
20359 a constant integral expression currently bounded between 101 and 65535
20360 inclusive. Lower numbers indicate a higher priority.
20361
20362 In the following example, @code{A} would normally be created before
20363 @code{B}, but the @code{init_priority} attribute reverses that order:
20364
20365 @smallexample
20366 Some_Class A __attribute__ ((init_priority (2000)));
20367 Some_Class B __attribute__ ((init_priority (543)));
20368 @end smallexample
20369
20370 @noindent
20371 Note that the particular values of @var{priority} do not matter; only their
20372 relative ordering.
20373
20374 @item java_interface
20375 @cindex @code{java_interface} type attribute
20376
20377 This type attribute informs C++ that the class is a Java interface. It may
20378 only be applied to classes declared within an @code{extern "Java"} block.
20379 Calls to methods declared in this interface are dispatched using GCJ's
20380 interface table mechanism, instead of regular virtual table dispatch.
20381
20382 @item warn_unused
20383 @cindex @code{warn_unused} type attribute
20384
20385 For C++ types with non-trivial constructors and/or destructors it is
20386 impossible for the compiler to determine whether a variable of this
20387 type is truly unused if it is not referenced. This type attribute
20388 informs the compiler that variables of this type should be warned
20389 about if they appear to be unused, just like variables of fundamental
20390 types.
20391
20392 This attribute is appropriate for types which just represent a value,
20393 such as @code{std::string}; it is not appropriate for types which
20394 control a resource, such as @code{std::lock_guard}.
20395
20396 This attribute is also accepted in C, but it is unnecessary because C
20397 does not have constructors or destructors.
20398
20399 @end table
20400
20401 See also @ref{Namespace Association}.
20402
20403 @node Function Multiversioning
20404 @section Function Multiversioning
20405 @cindex function versions
20406
20407 With the GNU C++ front end, for x86 targets, you may specify multiple
20408 versions of a function, where each function is specialized for a
20409 specific target feature. At runtime, the appropriate version of the
20410 function is automatically executed depending on the characteristics of
20411 the execution platform. Here is an example.
20412
20413 @smallexample
20414 __attribute__ ((target ("default")))
20415 int foo ()
20416 @{
20417 // The default version of foo.
20418 return 0;
20419 @}
20420
20421 __attribute__ ((target ("sse4.2")))
20422 int foo ()
20423 @{
20424 // foo version for SSE4.2
20425 return 1;
20426 @}
20427
20428 __attribute__ ((target ("arch=atom")))
20429 int foo ()
20430 @{
20431 // foo version for the Intel ATOM processor
20432 return 2;
20433 @}
20434
20435 __attribute__ ((target ("arch=amdfam10")))
20436 int foo ()
20437 @{
20438 // foo version for the AMD Family 0x10 processors.
20439 return 3;
20440 @}
20441
20442 int main ()
20443 @{
20444 int (*p)() = &foo;
20445 assert ((*p) () == foo ());
20446 return 0;
20447 @}
20448 @end smallexample
20449
20450 In the above example, four versions of function foo are created. The
20451 first version of foo with the target attribute "default" is the default
20452 version. This version gets executed when no other target specific
20453 version qualifies for execution on a particular platform. A new version
20454 of foo is created by using the same function signature but with a
20455 different target string. Function foo is called or a pointer to it is
20456 taken just like a regular function. GCC takes care of doing the
20457 dispatching to call the right version at runtime. Refer to the
20458 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20459 Function Multiversioning} for more details.
20460
20461 @node Namespace Association
20462 @section Namespace Association
20463
20464 @strong{Caution:} The semantics of this extension are equivalent
20465 to C++ 2011 inline namespaces. Users should use inline namespaces
20466 instead as this extension will be removed in future versions of G++.
20467
20468 A using-directive with @code{__attribute ((strong))} is stronger
20469 than a normal using-directive in two ways:
20470
20471 @itemize @bullet
20472 @item
20473 Templates from the used namespace can be specialized and explicitly
20474 instantiated as though they were members of the using namespace.
20475
20476 @item
20477 The using namespace is considered an associated namespace of all
20478 templates in the used namespace for purposes of argument-dependent
20479 name lookup.
20480 @end itemize
20481
20482 The used namespace must be nested within the using namespace so that
20483 normal unqualified lookup works properly.
20484
20485 This is useful for composing a namespace transparently from
20486 implementation namespaces. For example:
20487
20488 @smallexample
20489 namespace std @{
20490 namespace debug @{
20491 template <class T> struct A @{ @};
20492 @}
20493 using namespace debug __attribute ((__strong__));
20494 template <> struct A<int> @{ @}; // @r{OK to specialize}
20495
20496 template <class T> void f (A<T>);
20497 @}
20498
20499 int main()
20500 @{
20501 f (std::A<float>()); // @r{lookup finds} std::f
20502 f (std::A<int>());
20503 @}
20504 @end smallexample
20505
20506 @node Type Traits
20507 @section Type Traits
20508
20509 The C++ front end implements syntactic extensions that allow
20510 compile-time determination of
20511 various characteristics of a type (or of a
20512 pair of types).
20513
20514 @table @code
20515 @item __has_nothrow_assign (type)
20516 If @code{type} is const qualified or is a reference type then the trait is
20517 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20518 is true, else if @code{type} is a cv class or union type with copy assignment
20519 operators that are known not to throw an exception then the trait is true,
20520 else it is false. Requires: @code{type} shall be a complete type,
20521 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20522
20523 @item __has_nothrow_copy (type)
20524 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20525 @code{type} is a cv class or union type with copy constructors that
20526 are known not to throw an exception then the trait is true, else it is false.
20527 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20528 @code{void}, or an array of unknown bound.
20529
20530 @item __has_nothrow_constructor (type)
20531 If @code{__has_trivial_constructor (type)} is true then the trait is
20532 true, else if @code{type} is a cv class or union type (or array
20533 thereof) with a default constructor that is known not to throw an
20534 exception then the trait is true, else it is false. Requires:
20535 @code{type} shall be a complete type, (possibly cv-qualified)
20536 @code{void}, or an array of unknown bound.
20537
20538 @item __has_trivial_assign (type)
20539 If @code{type} is const qualified or is a reference type then the trait is
20540 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20541 true, else if @code{type} is a cv class or union type with a trivial
20542 copy assignment ([class.copy]) then the trait is true, else it is
20543 false. Requires: @code{type} shall be a complete type, (possibly
20544 cv-qualified) @code{void}, or an array of unknown bound.
20545
20546 @item __has_trivial_copy (type)
20547 If @code{__is_pod (type)} is true or @code{type} is a reference type
20548 then the trait is true, else if @code{type} is a cv class or union type
20549 with a trivial copy constructor ([class.copy]) then the trait
20550 is true, else it is false. Requires: @code{type} shall be a complete
20551 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20552
20553 @item __has_trivial_constructor (type)
20554 If @code{__is_pod (type)} is true then the trait is true, else if
20555 @code{type} is a cv class or union type (or array thereof) with a
20556 trivial default constructor ([class.ctor]) then the trait is true,
20557 else it is false. Requires: @code{type} shall be a complete
20558 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20559
20560 @item __has_trivial_destructor (type)
20561 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20562 the trait is true, else if @code{type} is a cv class or union type (or
20563 array thereof) with a trivial destructor ([class.dtor]) then the trait
20564 is true, else it is false. Requires: @code{type} shall be a complete
20565 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20566
20567 @item __has_virtual_destructor (type)
20568 If @code{type} is a class type with a virtual destructor
20569 ([class.dtor]) then the trait is true, else it is false. Requires:
20570 @code{type} shall be a complete type, (possibly cv-qualified)
20571 @code{void}, or an array of unknown bound.
20572
20573 @item __is_abstract (type)
20574 If @code{type} is an abstract class ([class.abstract]) then the trait
20575 is true, else it is false. Requires: @code{type} shall be a complete
20576 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20577
20578 @item __is_base_of (base_type, derived_type)
20579 If @code{base_type} is a base class of @code{derived_type}
20580 ([class.derived]) then the trait is true, otherwise it is false.
20581 Top-level cv qualifications of @code{base_type} and
20582 @code{derived_type} are ignored. For the purposes of this trait, a
20583 class type is considered is own base. Requires: if @code{__is_class
20584 (base_type)} and @code{__is_class (derived_type)} are true and
20585 @code{base_type} and @code{derived_type} are not the same type
20586 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20587 type. A diagnostic is produced if this requirement is not met.
20588
20589 @item __is_class (type)
20590 If @code{type} is a cv class type, and not a union type
20591 ([basic.compound]) the trait is true, else it is false.
20592
20593 @item __is_empty (type)
20594 If @code{__is_class (type)} is false then the trait is false.
20595 Otherwise @code{type} is considered empty if and only if: @code{type}
20596 has no non-static data members, or all non-static data members, if
20597 any, are bit-fields of length 0, and @code{type} has no virtual
20598 members, and @code{type} has no virtual base classes, and @code{type}
20599 has no base classes @code{base_type} for which
20600 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20601 be a complete type, (possibly cv-qualified) @code{void}, or an array
20602 of unknown bound.
20603
20604 @item __is_enum (type)
20605 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20606 true, else it is false.
20607
20608 @item __is_literal_type (type)
20609 If @code{type} is a literal type ([basic.types]) the trait is
20610 true, else it is false. Requires: @code{type} shall be a complete type,
20611 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20612
20613 @item __is_pod (type)
20614 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20615 else it is false. Requires: @code{type} shall be a complete type,
20616 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20617
20618 @item __is_polymorphic (type)
20619 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20620 is true, else it is false. Requires: @code{type} shall be a complete
20621 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20622
20623 @item __is_standard_layout (type)
20624 If @code{type} is a standard-layout type ([basic.types]) the trait is
20625 true, else it is false. Requires: @code{type} shall be a complete
20626 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20627
20628 @item __is_trivial (type)
20629 If @code{type} is a trivial type ([basic.types]) the trait is
20630 true, else it is false. Requires: @code{type} shall be a complete
20631 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20632
20633 @item __is_union (type)
20634 If @code{type} is a cv union type ([basic.compound]) the trait is
20635 true, else it is false.
20636
20637 @item __underlying_type (type)
20638 The underlying type of @code{type}. Requires: @code{type} shall be
20639 an enumeration type ([dcl.enum]).
20640
20641 @end table
20642
20643
20644 @node C++ Concepts
20645 @section C++ Concepts
20646
20647 C++ concepts provide much-improved support for generic programming. In
20648 particular, they allow the specification of constraints on template arguments.
20649 The constraints are used to extend the usual overloading and partial
20650 specialization capabilities of the language, allowing generic data structures
20651 and algorithms to be ``refined'' based on their properties rather than their
20652 type names.
20653
20654 The following keywords are reserved for concepts.
20655
20656 @table @code
20657 @item assumes
20658 States an expression as an assumption, and if possible, verifies that the
20659 assumption is valid. For example, @code{assume(n > 0)}.
20660
20661 @item axiom
20662 Introduces an axiom definition. Axioms introduce requirements on values.
20663
20664 @item forall
20665 Introduces a universally quantified object in an axiom. For example,
20666 @code{forall (int n) n + 0 == n}).
20667
20668 @item concept
20669 Introduces a concept definition. Concepts are sets of syntactic and semantic
20670 requirements on types and their values.
20671
20672 @item requires
20673 Introduces constraints on template arguments or requirements for a member
20674 function of a class template.
20675
20676 @end table
20677
20678 The front end also exposes a number of internal mechanism that can be used
20679 to simplify the writing of type traits. Note that some of these traits are
20680 likely to be removed in the future.
20681
20682 @table @code
20683 @item __is_same (type1, type2)
20684 A binary type trait: true whenever the type arguments are the same.
20685
20686 @end table
20687
20688
20689 @node Java Exceptions
20690 @section Java Exceptions
20691
20692 The Java language uses a slightly different exception handling model
20693 from C++. Normally, GNU C++ automatically detects when you are
20694 writing C++ code that uses Java exceptions, and handle them
20695 appropriately. However, if C++ code only needs to execute destructors
20696 when Java exceptions are thrown through it, GCC guesses incorrectly.
20697 Sample problematic code is:
20698
20699 @smallexample
20700 struct S @{ ~S(); @};
20701 extern void bar(); // @r{is written in Java, and may throw exceptions}
20702 void foo()
20703 @{
20704 S s;
20705 bar();
20706 @}
20707 @end smallexample
20708
20709 @noindent
20710 The usual effect of an incorrect guess is a link failure, complaining of
20711 a missing routine called @samp{__gxx_personality_v0}.
20712
20713 You can inform the compiler that Java exceptions are to be used in a
20714 translation unit, irrespective of what it might think, by writing
20715 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20716 @samp{#pragma} must appear before any functions that throw or catch
20717 exceptions, or run destructors when exceptions are thrown through them.
20718
20719 You cannot mix Java and C++ exceptions in the same translation unit. It
20720 is believed to be safe to throw a C++ exception from one file through
20721 another file compiled for the Java exception model, or vice versa, but
20722 there may be bugs in this area.
20723
20724 @node Deprecated Features
20725 @section Deprecated Features
20726
20727 In the past, the GNU C++ compiler was extended to experiment with new
20728 features, at a time when the C++ language was still evolving. Now that
20729 the C++ standard is complete, some of those features are superseded by
20730 superior alternatives. Using the old features might cause a warning in
20731 some cases that the feature will be dropped in the future. In other
20732 cases, the feature might be gone already.
20733
20734 While the list below is not exhaustive, it documents some of the options
20735 that are now deprecated:
20736
20737 @table @code
20738 @item -fexternal-templates
20739 @itemx -falt-external-templates
20740 These are two of the many ways for G++ to implement template
20741 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20742 defines how template definitions have to be organized across
20743 implementation units. G++ has an implicit instantiation mechanism that
20744 should work just fine for standard-conforming code.
20745
20746 @item -fstrict-prototype
20747 @itemx -fno-strict-prototype
20748 Previously it was possible to use an empty prototype parameter list to
20749 indicate an unspecified number of parameters (like C), rather than no
20750 parameters, as C++ demands. This feature has been removed, except where
20751 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20752 @end table
20753
20754 G++ allows a virtual function returning @samp{void *} to be overridden
20755 by one returning a different pointer type. This extension to the
20756 covariant return type rules is now deprecated and will be removed from a
20757 future version.
20758
20759 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20760 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20761 and are now removed from G++. Code using these operators should be
20762 modified to use @code{std::min} and @code{std::max} instead.
20763
20764 The named return value extension has been deprecated, and is now
20765 removed from G++.
20766
20767 The use of initializer lists with new expressions has been deprecated,
20768 and is now removed from G++.
20769
20770 Floating and complex non-type template parameters have been deprecated,
20771 and are now removed from G++.
20772
20773 The implicit typename extension has been deprecated and is now
20774 removed from G++.
20775
20776 The use of default arguments in function pointers, function typedefs
20777 and other places where they are not permitted by the standard is
20778 deprecated and will be removed from a future version of G++.
20779
20780 G++ allows floating-point literals to appear in integral constant expressions,
20781 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20782 This extension is deprecated and will be removed from a future version.
20783
20784 G++ allows static data members of const floating-point type to be declared
20785 with an initializer in a class definition. The standard only allows
20786 initializers for static members of const integral types and const
20787 enumeration types so this extension has been deprecated and will be removed
20788 from a future version.
20789
20790 @node Backwards Compatibility
20791 @section Backwards Compatibility
20792 @cindex Backwards Compatibility
20793 @cindex ARM [Annotated C++ Reference Manual]
20794
20795 Now that there is a definitive ISO standard C++, G++ has a specification
20796 to adhere to. The C++ language evolved over time, and features that
20797 used to be acceptable in previous drafts of the standard, such as the ARM
20798 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20799 compilation of C++ written to such drafts, G++ contains some backwards
20800 compatibilities. @emph{All such backwards compatibility features are
20801 liable to disappear in future versions of G++.} They should be considered
20802 deprecated. @xref{Deprecated Features}.
20803
20804 @table @code
20805 @item For scope
20806 If a variable is declared at for scope, it used to remain in scope until
20807 the end of the scope that contained the for statement (rather than just
20808 within the for scope). G++ retains this, but issues a warning, if such a
20809 variable is accessed outside the for scope.
20810
20811 @item Implicit C language
20812 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20813 scope to set the language. On such systems, all header files are
20814 implicitly scoped inside a C language scope. Also, an empty prototype
20815 @code{()} is treated as an unspecified number of arguments, rather
20816 than no arguments, as C++ demands.
20817 @end table
20818
20819 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20820 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr