Add notinbranch/inbranch flags to attribute __simd__.
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2015 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
17
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
21
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
52 or arrays as values.
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
75 function.
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
219
220 @smallexample
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
223
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
228
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
233
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
238
239 A local label declaration looks like this:
240
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
244
245 @noindent
246 or
247
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
251
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
254
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
258
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
265
266 @smallexample
267 #define SEARCH(value, array, target) \
268 do @{ \
269 __label__ found; \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
272 int i, j; \
273 int value; \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
278 (value) = -1; \
279 found:; \
280 @} while (0)
281 @end smallexample
282
283 This could also be written using a statement expression:
284
285 @smallexample
286 #define SEARCH(array, target) \
287 (@{ \
288 __label__ found; \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
291 int i, j; \
292 int value; \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
297 value = -1; \
298 found: \
299 value; \
300 @})
301 @end smallexample
302
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
305
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
312
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
317
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
323
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
329
330 @smallexample
331 goto *ptr;
332 @end smallexample
333
334 @noindent
335 Any expression of type @code{void *} is allowed.
336
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
339
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
343
344 @noindent
345 Then you can select a label with indexing, like this:
346
347 @smallexample
348 goto *array[i];
349 @end smallexample
350
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
354
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
359
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
363
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
368
369 An alternate way to write the above example is
370
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
376
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
383
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
390
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
396
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
400
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
404
405 @smallexample
406 @group
407 foo (double a, double b)
408 @{
409 double square (double z) @{ return z * z; @}
410
411 return square (a) + square (b);
412 @}
413 @end group
414 @end smallexample
415
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
420
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
424 @{
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
427 int i;
428 /* @r{@dots{}} */
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @}
432 @end group
433 @end smallexample
434
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
438
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
441
442 @smallexample
443 hack (int *array, int size)
444 @{
445 void store (int index, int value)
446 @{ array[index] = value; @}
447
448 intermediate (store, size);
449 @}
450 @end smallexample
451
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
457
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
465
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
470
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
476
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
480 @{
481 __label__ failure;
482 int access (int *array, int index)
483 @{
484 if (index > size)
485 goto failure;
486 return array[index + offset];
487 @}
488 int i;
489 /* @r{@dots{}} */
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492 /* @r{@dots{}} */
493 return 0;
494
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
497 failure:
498 return -1;
499 @}
500 @end group
501 @end smallexample
502
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
507
508 @smallexample
509 bar (int *array, int offset, int size)
510 @{
511 __label__ failure;
512 auto int access (int *, int);
513 /* @r{@dots{}} */
514 int access (int *array, int index)
515 @{
516 if (index > size)
517 goto failure;
518 return array[index + offset];
519 @}
520 /* @r{@dots{}} */
521 @}
522 @end smallexample
523
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
528
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
533
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
538
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
543
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
548
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
553 @end deftypefn
554
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
559
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
563
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
567
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
573
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
579
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
594 @{
595 int r = fprintf (f, "myprintf: ");
596 if (r < 0)
597 return r;
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
599 if (s < 0)
600 return s;
601 return r + s;
602 @}
603 @end smallexample
604 @end deftypefn
605
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
618 @{
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
621
622 if (__builtin_constant_p (oflag))
623 @{
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 @{
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
628 @}
629 return open (path, oflag, __builtin_va_arg_pack ());
630 @}
631
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
634
635 return open (path, oflag, __builtin_va_arg_pack ());
636 @}
637 #endif
638 @end smallexample
639 @end deftypefn
640
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
646
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
650
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
653
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
657
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
661
662 Here is an example with a typename as the argument:
663
664 @smallexample
665 typeof (int *)
666 @end smallexample
667
668 @noindent
669 Here the type described is that of pointers to @code{int}.
670
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
674
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
678
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
682
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
688
689 @smallexample
690 #define max(a,b) \
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
694 @end smallexample
695
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
701
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
708
709 @noindent
710 Some more examples of the use of @code{typeof}:
711
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
715
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of such values.
722
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
726
727 @item
728 This declares @code{y} as an array of pointers to characters:
729
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
733
734 @noindent
735 It is equivalent to the following traditional C declaration:
736
737 @smallexample
738 char *y[4];
739 @end smallexample
740
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
743
744 @smallexample
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
748
749 @noindent
750 Now the declaration can be rewritten this way:
751
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
755
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
760
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
769
770 @smallexample
771 #define max(a,b) \
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
775 @end smallexample
776
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
784
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
789
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
797
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
801
802 Therefore, the expression
803
804 @smallexample
805 x ? : y
806 @end smallexample
807
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
811
812 This example is perfectly equivalent to
813
814 @smallexample
815 x ? x : y
816 @end smallexample
817
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
827
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
831
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
838
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
846
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
854
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
862
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
870
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
876
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
882
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
889
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
899
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
909
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
916
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF 2
920 debug info format can represent this, so use of DWARF 2 is recommended.
921 If you are using the stabs debug info format, GCC describes a noncontiguous
922 complex variable as if it were two separate variables of noncomplex type.
923 If the variable's actual name is @code{foo}, the two fictitious
924 variables are named @code{foo$real} and @code{foo$imag}. You can
925 examine and set these two fictitious variables with your debugger.
926
927 @node Floating Types
928 @section Additional Floating Types
929 @cindex additional floating types
930 @cindex @code{__float80} data type
931 @cindex @code{__float128} data type
932 @cindex @code{__ibm128} data type
933 @cindex @code{w} floating point suffix
934 @cindex @code{q} floating point suffix
935 @cindex @code{W} floating point suffix
936 @cindex @code{Q} floating point suffix
937
938 As an extension, GNU C supports additional floating
939 types, @code{__float80} and @code{__float128} to support 80-bit
940 (@code{XFmode}) and 128-bit (@code{TFmode}) floating types.
941 Support for additional types includes the arithmetic operators:
942 add, subtract, multiply, divide; unary arithmetic operators;
943 relational operators; equality operators; and conversions to and from
944 integer and other floating types. Use a suffix @samp{w} or @samp{W}
945 in a literal constant of type @code{__float80} or type
946 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
947
948 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
949 types using the corresponding internal complex type, @code{XCmode} for
950 @code{__float80} type and @code{TCmode} for @code{__float128} type:
951
952 @smallexample
953 typedef _Complex float __attribute__((mode(TC))) _Complex128;
954 typedef _Complex float __attribute__((mode(XC))) _Complex80;
955 @end smallexample
956
957 On PowerPC Linux, Freebsd and Darwin systems, the default for
958 @code{long double} is to use the IBM extended floating point format
959 that uses a pair of @code{double} values to extend the precision.
960 This means that the mode @code{TCmode} was already used by the
961 traditional IBM long double format, and you would need to use the mode
962 @code{KCmode}:
963
964 @smallexample
965 typedef _Complex float __attribute__((mode(KC))) _Complex128;
966 @end smallexample
967
968 Not all targets support additional floating-point types. @code{__float80}
969 and @code{__float128} types are supported on x86 and IA-64 targets.
970 The @code{__float128} type is supported on hppa HP-UX.
971 The @code{__float128} type is supported on PowerPC systems by default
972 if the vector scalar instruction set (VSX) is enabled.
973
974 On the PowerPC, @code{__ibm128} provides access to the IBM extended
975 double format, and it is intended to be used by the library functions
976 that handle conversions if/when long double is changed to be IEEE
977 128-bit floating point.
978
979 @node Half-Precision
980 @section Half-Precision Floating Point
981 @cindex half-precision floating point
982 @cindex @code{__fp16} data type
983
984 On ARM targets, GCC supports half-precision (16-bit) floating point via
985 the @code{__fp16} type. You must enable this type explicitly
986 with the @option{-mfp16-format} command-line option in order to use it.
987
988 ARM supports two incompatible representations for half-precision
989 floating-point values. You must choose one of the representations and
990 use it consistently in your program.
991
992 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
993 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
994 There are 11 bits of significand precision, approximately 3
995 decimal digits.
996
997 Specifying @option{-mfp16-format=alternative} selects the ARM
998 alternative format. This representation is similar to the IEEE
999 format, but does not support infinities or NaNs. Instead, the range
1000 of exponents is extended, so that this format can represent normalized
1001 values in the range of @math{2^{-14}} to 131008.
1002
1003 The @code{__fp16} type is a storage format only. For purposes
1004 of arithmetic and other operations, @code{__fp16} values in C or C++
1005 expressions are automatically promoted to @code{float}. In addition,
1006 you cannot declare a function with a return value or parameters
1007 of type @code{__fp16}.
1008
1009 Note that conversions from @code{double} to @code{__fp16}
1010 involve an intermediate conversion to @code{float}. Because
1011 of rounding, this can sometimes produce a different result than a
1012 direct conversion.
1013
1014 ARM provides hardware support for conversions between
1015 @code{__fp16} and @code{float} values
1016 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1017 code using these hardware instructions if you compile with
1018 options to select an FPU that provides them;
1019 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1020 in addition to the @option{-mfp16-format} option to select
1021 a half-precision format.
1022
1023 Language-level support for the @code{__fp16} data type is
1024 independent of whether GCC generates code using hardware floating-point
1025 instructions. In cases where hardware support is not specified, GCC
1026 implements conversions between @code{__fp16} and @code{float} values
1027 as library calls.
1028
1029 @node Decimal Float
1030 @section Decimal Floating Types
1031 @cindex decimal floating types
1032 @cindex @code{_Decimal32} data type
1033 @cindex @code{_Decimal64} data type
1034 @cindex @code{_Decimal128} data type
1035 @cindex @code{df} integer suffix
1036 @cindex @code{dd} integer suffix
1037 @cindex @code{dl} integer suffix
1038 @cindex @code{DF} integer suffix
1039 @cindex @code{DD} integer suffix
1040 @cindex @code{DL} integer suffix
1041
1042 As an extension, GNU C supports decimal floating types as
1043 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1044 floating types in GCC will evolve as the draft technical report changes.
1045 Calling conventions for any target might also change. Not all targets
1046 support decimal floating types.
1047
1048 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1049 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1050 @code{float}, @code{double}, and @code{long double} whose radix is not
1051 specified by the C standard but is usually two.
1052
1053 Support for decimal floating types includes the arithmetic operators
1054 add, subtract, multiply, divide; unary arithmetic operators;
1055 relational operators; equality operators; and conversions to and from
1056 integer and other floating types. Use a suffix @samp{df} or
1057 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1058 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1059 @code{_Decimal128}.
1060
1061 GCC support of decimal float as specified by the draft technical report
1062 is incomplete:
1063
1064 @itemize @bullet
1065 @item
1066 When the value of a decimal floating type cannot be represented in the
1067 integer type to which it is being converted, the result is undefined
1068 rather than the result value specified by the draft technical report.
1069
1070 @item
1071 GCC does not provide the C library functionality associated with
1072 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1073 @file{wchar.h}, which must come from a separate C library implementation.
1074 Because of this the GNU C compiler does not define macro
1075 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1076 the technical report.
1077 @end itemize
1078
1079 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1080 are supported by the DWARF 2 debug information format.
1081
1082 @node Hex Floats
1083 @section Hex Floats
1084 @cindex hex floats
1085
1086 ISO C99 supports floating-point numbers written not only in the usual
1087 decimal notation, such as @code{1.55e1}, but also numbers such as
1088 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1089 supports this in C90 mode (except in some cases when strictly
1090 conforming) and in C++. In that format the
1091 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1092 mandatory. The exponent is a decimal number that indicates the power of
1093 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1094 @tex
1095 $1 {15\over16}$,
1096 @end tex
1097 @ifnottex
1098 1 15/16,
1099 @end ifnottex
1100 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1101 is the same as @code{1.55e1}.
1102
1103 Unlike for floating-point numbers in the decimal notation the exponent
1104 is always required in the hexadecimal notation. Otherwise the compiler
1105 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1106 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1107 extension for floating-point constants of type @code{float}.
1108
1109 @node Fixed-Point
1110 @section Fixed-Point Types
1111 @cindex fixed-point types
1112 @cindex @code{_Fract} data type
1113 @cindex @code{_Accum} data type
1114 @cindex @code{_Sat} data type
1115 @cindex @code{hr} fixed-suffix
1116 @cindex @code{r} fixed-suffix
1117 @cindex @code{lr} fixed-suffix
1118 @cindex @code{llr} fixed-suffix
1119 @cindex @code{uhr} fixed-suffix
1120 @cindex @code{ur} fixed-suffix
1121 @cindex @code{ulr} fixed-suffix
1122 @cindex @code{ullr} fixed-suffix
1123 @cindex @code{hk} fixed-suffix
1124 @cindex @code{k} fixed-suffix
1125 @cindex @code{lk} fixed-suffix
1126 @cindex @code{llk} fixed-suffix
1127 @cindex @code{uhk} fixed-suffix
1128 @cindex @code{uk} fixed-suffix
1129 @cindex @code{ulk} fixed-suffix
1130 @cindex @code{ullk} fixed-suffix
1131 @cindex @code{HR} fixed-suffix
1132 @cindex @code{R} fixed-suffix
1133 @cindex @code{LR} fixed-suffix
1134 @cindex @code{LLR} fixed-suffix
1135 @cindex @code{UHR} fixed-suffix
1136 @cindex @code{UR} fixed-suffix
1137 @cindex @code{ULR} fixed-suffix
1138 @cindex @code{ULLR} fixed-suffix
1139 @cindex @code{HK} fixed-suffix
1140 @cindex @code{K} fixed-suffix
1141 @cindex @code{LK} fixed-suffix
1142 @cindex @code{LLK} fixed-suffix
1143 @cindex @code{UHK} fixed-suffix
1144 @cindex @code{UK} fixed-suffix
1145 @cindex @code{ULK} fixed-suffix
1146 @cindex @code{ULLK} fixed-suffix
1147
1148 As an extension, GNU C supports fixed-point types as
1149 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1150 types in GCC will evolve as the draft technical report changes.
1151 Calling conventions for any target might also change. Not all targets
1152 support fixed-point types.
1153
1154 The fixed-point types are
1155 @code{short _Fract},
1156 @code{_Fract},
1157 @code{long _Fract},
1158 @code{long long _Fract},
1159 @code{unsigned short _Fract},
1160 @code{unsigned _Fract},
1161 @code{unsigned long _Fract},
1162 @code{unsigned long long _Fract},
1163 @code{_Sat short _Fract},
1164 @code{_Sat _Fract},
1165 @code{_Sat long _Fract},
1166 @code{_Sat long long _Fract},
1167 @code{_Sat unsigned short _Fract},
1168 @code{_Sat unsigned _Fract},
1169 @code{_Sat unsigned long _Fract},
1170 @code{_Sat unsigned long long _Fract},
1171 @code{short _Accum},
1172 @code{_Accum},
1173 @code{long _Accum},
1174 @code{long long _Accum},
1175 @code{unsigned short _Accum},
1176 @code{unsigned _Accum},
1177 @code{unsigned long _Accum},
1178 @code{unsigned long long _Accum},
1179 @code{_Sat short _Accum},
1180 @code{_Sat _Accum},
1181 @code{_Sat long _Accum},
1182 @code{_Sat long long _Accum},
1183 @code{_Sat unsigned short _Accum},
1184 @code{_Sat unsigned _Accum},
1185 @code{_Sat unsigned long _Accum},
1186 @code{_Sat unsigned long long _Accum}.
1187
1188 Fixed-point data values contain fractional and optional integral parts.
1189 The format of fixed-point data varies and depends on the target machine.
1190
1191 Support for fixed-point types includes:
1192 @itemize @bullet
1193 @item
1194 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1195 @item
1196 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1197 @item
1198 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1199 @item
1200 binary shift operators (@code{<<}, @code{>>})
1201 @item
1202 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1203 @item
1204 equality operators (@code{==}, @code{!=})
1205 @item
1206 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1207 @code{<<=}, @code{>>=})
1208 @item
1209 conversions to and from integer, floating-point, or fixed-point types
1210 @end itemize
1211
1212 Use a suffix in a fixed-point literal constant:
1213 @itemize
1214 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1215 @code{_Sat short _Fract}
1216 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1217 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1218 @code{_Sat long _Fract}
1219 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1220 @code{_Sat long long _Fract}
1221 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1222 @code{_Sat unsigned short _Fract}
1223 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1224 @code{_Sat unsigned _Fract}
1225 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1226 @code{_Sat unsigned long _Fract}
1227 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1228 and @code{_Sat unsigned long long _Fract}
1229 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1230 @code{_Sat short _Accum}
1231 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1232 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1233 @code{_Sat long _Accum}
1234 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1235 @code{_Sat long long _Accum}
1236 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1237 @code{_Sat unsigned short _Accum}
1238 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1239 @code{_Sat unsigned _Accum}
1240 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1241 @code{_Sat unsigned long _Accum}
1242 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1243 and @code{_Sat unsigned long long _Accum}
1244 @end itemize
1245
1246 GCC support of fixed-point types as specified by the draft technical report
1247 is incomplete:
1248
1249 @itemize @bullet
1250 @item
1251 Pragmas to control overflow and rounding behaviors are not implemented.
1252 @end itemize
1253
1254 Fixed-point types are supported by the DWARF 2 debug information format.
1255
1256 @node Named Address Spaces
1257 @section Named Address Spaces
1258 @cindex Named Address Spaces
1259
1260 As an extension, GNU C supports named address spaces as
1261 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1262 address spaces in GCC will evolve as the draft technical report
1263 changes. Calling conventions for any target might also change. At
1264 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1265 address spaces other than the generic address space.
1266
1267 Address space identifiers may be used exactly like any other C type
1268 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1269 document for more details.
1270
1271 @anchor{AVR Named Address Spaces}
1272 @subsection AVR Named Address Spaces
1273
1274 On the AVR target, there are several address spaces that can be used
1275 in order to put read-only data into the flash memory and access that
1276 data by means of the special instructions @code{LPM} or @code{ELPM}
1277 needed to read from flash.
1278
1279 Per default, any data including read-only data is located in RAM
1280 (the generic address space) so that non-generic address spaces are
1281 needed to locate read-only data in flash memory
1282 @emph{and} to generate the right instructions to access this data
1283 without using (inline) assembler code.
1284
1285 @table @code
1286 @item __flash
1287 @cindex @code{__flash} AVR Named Address Spaces
1288 The @code{__flash} qualifier locates data in the
1289 @code{.progmem.data} section. Data is read using the @code{LPM}
1290 instruction. Pointers to this address space are 16 bits wide.
1291
1292 @item __flash1
1293 @itemx __flash2
1294 @itemx __flash3
1295 @itemx __flash4
1296 @itemx __flash5
1297 @cindex @code{__flash1} AVR Named Address Spaces
1298 @cindex @code{__flash2} AVR Named Address Spaces
1299 @cindex @code{__flash3} AVR Named Address Spaces
1300 @cindex @code{__flash4} AVR Named Address Spaces
1301 @cindex @code{__flash5} AVR Named Address Spaces
1302 These are 16-bit address spaces locating data in section
1303 @code{.progmem@var{N}.data} where @var{N} refers to
1304 address space @code{__flash@var{N}}.
1305 The compiler sets the @code{RAMPZ} segment register appropriately
1306 before reading data by means of the @code{ELPM} instruction.
1307
1308 @item __memx
1309 @cindex @code{__memx} AVR Named Address Spaces
1310 This is a 24-bit address space that linearizes flash and RAM:
1311 If the high bit of the address is set, data is read from
1312 RAM using the lower two bytes as RAM address.
1313 If the high bit of the address is clear, data is read from flash
1314 with @code{RAMPZ} set according to the high byte of the address.
1315 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1316
1317 Objects in this address space are located in @code{.progmemx.data}.
1318 @end table
1319
1320 @b{Example}
1321
1322 @smallexample
1323 char my_read (const __flash char ** p)
1324 @{
1325 /* p is a pointer to RAM that points to a pointer to flash.
1326 The first indirection of p reads that flash pointer
1327 from RAM and the second indirection reads a char from this
1328 flash address. */
1329
1330 return **p;
1331 @}
1332
1333 /* Locate array[] in flash memory */
1334 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1335
1336 int i = 1;
1337
1338 int main (void)
1339 @{
1340 /* Return 17 by reading from flash memory */
1341 return array[array[i]];
1342 @}
1343 @end smallexample
1344
1345 @noindent
1346 For each named address space supported by avr-gcc there is an equally
1347 named but uppercase built-in macro defined.
1348 The purpose is to facilitate testing if respective address space
1349 support is available or not:
1350
1351 @smallexample
1352 #ifdef __FLASH
1353 const __flash int var = 1;
1354
1355 int read_var (void)
1356 @{
1357 return var;
1358 @}
1359 #else
1360 #include <avr/pgmspace.h> /* From AVR-LibC */
1361
1362 const int var PROGMEM = 1;
1363
1364 int read_var (void)
1365 @{
1366 return (int) pgm_read_word (&var);
1367 @}
1368 #endif /* __FLASH */
1369 @end smallexample
1370
1371 @noindent
1372 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1373 locates data in flash but
1374 accesses to these data read from generic address space, i.e.@:
1375 from RAM,
1376 so that you need special accessors like @code{pgm_read_byte}
1377 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1378 together with attribute @code{progmem}.
1379
1380 @noindent
1381 @b{Limitations and caveats}
1382
1383 @itemize
1384 @item
1385 Reading across the 64@tie{}KiB section boundary of
1386 the @code{__flash} or @code{__flash@var{N}} address spaces
1387 shows undefined behavior. The only address space that
1388 supports reading across the 64@tie{}KiB flash segment boundaries is
1389 @code{__memx}.
1390
1391 @item
1392 If you use one of the @code{__flash@var{N}} address spaces
1393 you must arrange your linker script to locate the
1394 @code{.progmem@var{N}.data} sections according to your needs.
1395
1396 @item
1397 Any data or pointers to the non-generic address spaces must
1398 be qualified as @code{const}, i.e.@: as read-only data.
1399 This still applies if the data in one of these address
1400 spaces like software version number or calibration lookup table are intended to
1401 be changed after load time by, say, a boot loader. In this case
1402 the right qualification is @code{const} @code{volatile} so that the compiler
1403 must not optimize away known values or insert them
1404 as immediates into operands of instructions.
1405
1406 @item
1407 The following code initializes a variable @code{pfoo}
1408 located in static storage with a 24-bit address:
1409 @smallexample
1410 extern const __memx char foo;
1411 const __memx void *pfoo = &foo;
1412 @end smallexample
1413
1414 @noindent
1415 Such code requires at least binutils 2.23, see
1416 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1417
1418 @end itemize
1419
1420 @subsection M32C Named Address Spaces
1421 @cindex @code{__far} M32C Named Address Spaces
1422
1423 On the M32C target, with the R8C and M16C CPU variants, variables
1424 qualified with @code{__far} are accessed using 32-bit addresses in
1425 order to access memory beyond the first 64@tie{}Ki bytes. If
1426 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1427 effect.
1428
1429 @subsection RL78 Named Address Spaces
1430 @cindex @code{__far} RL78 Named Address Spaces
1431
1432 On the RL78 target, variables qualified with @code{__far} are accessed
1433 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1434 addresses. Non-far variables are assumed to appear in the topmost
1435 64@tie{}KiB of the address space.
1436
1437 @subsection SPU Named Address Spaces
1438 @cindex @code{__ea} SPU Named Address Spaces
1439
1440 On the SPU target variables may be declared as
1441 belonging to another address space by qualifying the type with the
1442 @code{__ea} address space identifier:
1443
1444 @smallexample
1445 extern int __ea i;
1446 @end smallexample
1447
1448 @noindent
1449 The compiler generates special code to access the variable @code{i}.
1450 It may use runtime library
1451 support, or generate special machine instructions to access that address
1452 space.
1453
1454 @subsection x86 Named Address Spaces
1455 @cindex x86 named address spaces
1456
1457 On the x86 target, variables may be declared as being relative
1458 to the @code{%fs} or @code{%gs} segments.
1459
1460 @table @code
1461 @item __seg_fs
1462 @itemx __seg_gs
1463 @cindex @code{__seg_fs} x86 named address space
1464 @cindex @code{__seg_gs} x86 named address space
1465 The object is accessed with the respective segment override prefix.
1466
1467 The respective segment base must be set via some method specific to
1468 the operating system. Rather than require an expensive system call
1469 to retrieve the segment base, these address spaces are not considered
1470 to be subspaces of the generic (flat) address space. This means that
1471 explicit casts are required to convert pointers between these address
1472 spaces and the generic address space. In practice the application
1473 should cast to @code{uintptr_t} and apply the segment base offset
1474 that it installed previously.
1475
1476 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1477 defined when these address spaces are supported.
1478
1479 @item __seg_tls
1480 @cindex @code{__seg_tls} x86 named address space
1481 Some operating systems define either the @code{%fs} or @code{%gs}
1482 segment as the thread-local storage base for each thread. Objects
1483 within this address space are accessed with the appropriate
1484 segment override prefix.
1485
1486 The pointer located at address 0 within the segment contains the
1487 offset of the segment within the generic address space. Thus this
1488 address space is considered a subspace of the generic address space,
1489 and the known segment offset is applied when converting addresses
1490 to and from the generic address space.
1491
1492 The preprocessor symbol @code{__SEG_TLS} is defined when this
1493 address space is supported.
1494
1495 @end table
1496
1497 @node Zero Length
1498 @section Arrays of Length Zero
1499 @cindex arrays of length zero
1500 @cindex zero-length arrays
1501 @cindex length-zero arrays
1502 @cindex flexible array members
1503
1504 Zero-length arrays are allowed in GNU C@. They are very useful as the
1505 last element of a structure that is really a header for a variable-length
1506 object:
1507
1508 @smallexample
1509 struct line @{
1510 int length;
1511 char contents[0];
1512 @};
1513
1514 struct line *thisline = (struct line *)
1515 malloc (sizeof (struct line) + this_length);
1516 thisline->length = this_length;
1517 @end smallexample
1518
1519 In ISO C90, you would have to give @code{contents} a length of 1, which
1520 means either you waste space or complicate the argument to @code{malloc}.
1521
1522 In ISO C99, you would use a @dfn{flexible array member}, which is
1523 slightly different in syntax and semantics:
1524
1525 @itemize @bullet
1526 @item
1527 Flexible array members are written as @code{contents[]} without
1528 the @code{0}.
1529
1530 @item
1531 Flexible array members have incomplete type, and so the @code{sizeof}
1532 operator may not be applied. As a quirk of the original implementation
1533 of zero-length arrays, @code{sizeof} evaluates to zero.
1534
1535 @item
1536 Flexible array members may only appear as the last member of a
1537 @code{struct} that is otherwise non-empty.
1538
1539 @item
1540 A structure containing a flexible array member, or a union containing
1541 such a structure (possibly recursively), may not be a member of a
1542 structure or an element of an array. (However, these uses are
1543 permitted by GCC as extensions.)
1544 @end itemize
1545
1546 Non-empty initialization of zero-length
1547 arrays is treated like any case where there are more initializer
1548 elements than the array holds, in that a suitable warning about ``excess
1549 elements in array'' is given, and the excess elements (all of them, in
1550 this case) are ignored.
1551
1552 GCC allows static initialization of flexible array members.
1553 This is equivalent to defining a new structure containing the original
1554 structure followed by an array of sufficient size to contain the data.
1555 E.g.@: in the following, @code{f1} is constructed as if it were declared
1556 like @code{f2}.
1557
1558 @smallexample
1559 struct f1 @{
1560 int x; int y[];
1561 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1562
1563 struct f2 @{
1564 struct f1 f1; int data[3];
1565 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1566 @end smallexample
1567
1568 @noindent
1569 The convenience of this extension is that @code{f1} has the desired
1570 type, eliminating the need to consistently refer to @code{f2.f1}.
1571
1572 This has symmetry with normal static arrays, in that an array of
1573 unknown size is also written with @code{[]}.
1574
1575 Of course, this extension only makes sense if the extra data comes at
1576 the end of a top-level object, as otherwise we would be overwriting
1577 data at subsequent offsets. To avoid undue complication and confusion
1578 with initialization of deeply nested arrays, we simply disallow any
1579 non-empty initialization except when the structure is the top-level
1580 object. For example:
1581
1582 @smallexample
1583 struct foo @{ int x; int y[]; @};
1584 struct bar @{ struct foo z; @};
1585
1586 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1587 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1588 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1589 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1590 @end smallexample
1591
1592 @node Empty Structures
1593 @section Structures with No Members
1594 @cindex empty structures
1595 @cindex zero-size structures
1596
1597 GCC permits a C structure to have no members:
1598
1599 @smallexample
1600 struct empty @{
1601 @};
1602 @end smallexample
1603
1604 The structure has size zero. In C++, empty structures are part
1605 of the language. G++ treats empty structures as if they had a single
1606 member of type @code{char}.
1607
1608 @node Variable Length
1609 @section Arrays of Variable Length
1610 @cindex variable-length arrays
1611 @cindex arrays of variable length
1612 @cindex VLAs
1613
1614 Variable-length automatic arrays are allowed in ISO C99, and as an
1615 extension GCC accepts them in C90 mode and in C++. These arrays are
1616 declared like any other automatic arrays, but with a length that is not
1617 a constant expression. The storage is allocated at the point of
1618 declaration and deallocated when the block scope containing the declaration
1619 exits. For
1620 example:
1621
1622 @smallexample
1623 FILE *
1624 concat_fopen (char *s1, char *s2, char *mode)
1625 @{
1626 char str[strlen (s1) + strlen (s2) + 1];
1627 strcpy (str, s1);
1628 strcat (str, s2);
1629 return fopen (str, mode);
1630 @}
1631 @end smallexample
1632
1633 @cindex scope of a variable length array
1634 @cindex variable-length array scope
1635 @cindex deallocating variable length arrays
1636 Jumping or breaking out of the scope of the array name deallocates the
1637 storage. Jumping into the scope is not allowed; you get an error
1638 message for it.
1639
1640 @cindex variable-length array in a structure
1641 As an extension, GCC accepts variable-length arrays as a member of
1642 a structure or a union. For example:
1643
1644 @smallexample
1645 void
1646 foo (int n)
1647 @{
1648 struct S @{ int x[n]; @};
1649 @}
1650 @end smallexample
1651
1652 @cindex @code{alloca} vs variable-length arrays
1653 You can use the function @code{alloca} to get an effect much like
1654 variable-length arrays. The function @code{alloca} is available in
1655 many other C implementations (but not in all). On the other hand,
1656 variable-length arrays are more elegant.
1657
1658 There are other differences between these two methods. Space allocated
1659 with @code{alloca} exists until the containing @emph{function} returns.
1660 The space for a variable-length array is deallocated as soon as the array
1661 name's scope ends, unless you also use @code{alloca} in this scope.
1662
1663 You can also use variable-length arrays as arguments to functions:
1664
1665 @smallexample
1666 struct entry
1667 tester (int len, char data[len][len])
1668 @{
1669 /* @r{@dots{}} */
1670 @}
1671 @end smallexample
1672
1673 The length of an array is computed once when the storage is allocated
1674 and is remembered for the scope of the array in case you access it with
1675 @code{sizeof}.
1676
1677 If you want to pass the array first and the length afterward, you can
1678 use a forward declaration in the parameter list---another GNU extension.
1679
1680 @smallexample
1681 struct entry
1682 tester (int len; char data[len][len], int len)
1683 @{
1684 /* @r{@dots{}} */
1685 @}
1686 @end smallexample
1687
1688 @cindex parameter forward declaration
1689 The @samp{int len} before the semicolon is a @dfn{parameter forward
1690 declaration}, and it serves the purpose of making the name @code{len}
1691 known when the declaration of @code{data} is parsed.
1692
1693 You can write any number of such parameter forward declarations in the
1694 parameter list. They can be separated by commas or semicolons, but the
1695 last one must end with a semicolon, which is followed by the ``real''
1696 parameter declarations. Each forward declaration must match a ``real''
1697 declaration in parameter name and data type. ISO C99 does not support
1698 parameter forward declarations.
1699
1700 @node Variadic Macros
1701 @section Macros with a Variable Number of Arguments.
1702 @cindex variable number of arguments
1703 @cindex macro with variable arguments
1704 @cindex rest argument (in macro)
1705 @cindex variadic macros
1706
1707 In the ISO C standard of 1999, a macro can be declared to accept a
1708 variable number of arguments much as a function can. The syntax for
1709 defining the macro is similar to that of a function. Here is an
1710 example:
1711
1712 @smallexample
1713 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1714 @end smallexample
1715
1716 @noindent
1717 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1718 such a macro, it represents the zero or more tokens until the closing
1719 parenthesis that ends the invocation, including any commas. This set of
1720 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1721 wherever it appears. See the CPP manual for more information.
1722
1723 GCC has long supported variadic macros, and used a different syntax that
1724 allowed you to give a name to the variable arguments just like any other
1725 argument. Here is an example:
1726
1727 @smallexample
1728 #define debug(format, args...) fprintf (stderr, format, args)
1729 @end smallexample
1730
1731 @noindent
1732 This is in all ways equivalent to the ISO C example above, but arguably
1733 more readable and descriptive.
1734
1735 GNU CPP has two further variadic macro extensions, and permits them to
1736 be used with either of the above forms of macro definition.
1737
1738 In standard C, you are not allowed to leave the variable argument out
1739 entirely; but you are allowed to pass an empty argument. For example,
1740 this invocation is invalid in ISO C, because there is no comma after
1741 the string:
1742
1743 @smallexample
1744 debug ("A message")
1745 @end smallexample
1746
1747 GNU CPP permits you to completely omit the variable arguments in this
1748 way. In the above examples, the compiler would complain, though since
1749 the expansion of the macro still has the extra comma after the format
1750 string.
1751
1752 To help solve this problem, CPP behaves specially for variable arguments
1753 used with the token paste operator, @samp{##}. If instead you write
1754
1755 @smallexample
1756 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1757 @end smallexample
1758
1759 @noindent
1760 and if the variable arguments are omitted or empty, the @samp{##}
1761 operator causes the preprocessor to remove the comma before it. If you
1762 do provide some variable arguments in your macro invocation, GNU CPP
1763 does not complain about the paste operation and instead places the
1764 variable arguments after the comma. Just like any other pasted macro
1765 argument, these arguments are not macro expanded.
1766
1767 @node Escaped Newlines
1768 @section Slightly Looser Rules for Escaped Newlines
1769 @cindex escaped newlines
1770 @cindex newlines (escaped)
1771
1772 The preprocessor treatment of escaped newlines is more relaxed
1773 than that specified by the C90 standard, which requires the newline
1774 to immediately follow a backslash.
1775 GCC's implementation allows whitespace in the form
1776 of spaces, horizontal and vertical tabs, and form feeds between the
1777 backslash and the subsequent newline. The preprocessor issues a
1778 warning, but treats it as a valid escaped newline and combines the two
1779 lines to form a single logical line. This works within comments and
1780 tokens, as well as between tokens. Comments are @emph{not} treated as
1781 whitespace for the purposes of this relaxation, since they have not
1782 yet been replaced with spaces.
1783
1784 @node Subscripting
1785 @section Non-Lvalue Arrays May Have Subscripts
1786 @cindex subscripting
1787 @cindex arrays, non-lvalue
1788
1789 @cindex subscripting and function values
1790 In ISO C99, arrays that are not lvalues still decay to pointers, and
1791 may be subscripted, although they may not be modified or used after
1792 the next sequence point and the unary @samp{&} operator may not be
1793 applied to them. As an extension, GNU C allows such arrays to be
1794 subscripted in C90 mode, though otherwise they do not decay to
1795 pointers outside C99 mode. For example,
1796 this is valid in GNU C though not valid in C90:
1797
1798 @smallexample
1799 @group
1800 struct foo @{int a[4];@};
1801
1802 struct foo f();
1803
1804 bar (int index)
1805 @{
1806 return f().a[index];
1807 @}
1808 @end group
1809 @end smallexample
1810
1811 @node Pointer Arith
1812 @section Arithmetic on @code{void}- and Function-Pointers
1813 @cindex void pointers, arithmetic
1814 @cindex void, size of pointer to
1815 @cindex function pointers, arithmetic
1816 @cindex function, size of pointer to
1817
1818 In GNU C, addition and subtraction operations are supported on pointers to
1819 @code{void} and on pointers to functions. This is done by treating the
1820 size of a @code{void} or of a function as 1.
1821
1822 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1823 and on function types, and returns 1.
1824
1825 @opindex Wpointer-arith
1826 The option @option{-Wpointer-arith} requests a warning if these extensions
1827 are used.
1828
1829 @node Pointers to Arrays
1830 @section Pointers to Arrays with Qualifiers Work as Expected
1831 @cindex pointers to arrays
1832 @cindex const qualifier
1833
1834 In GNU C, pointers to arrays with qualifiers work similar to pointers
1835 to other qualified types. For example, a value of type @code{int (*)[5]}
1836 can be used to initialize a variable of type @code{const int (*)[5]}.
1837 These types are incompatible in ISO C because the @code{const} qualifier
1838 is formally attached to the element type of the array and not the
1839 array itself.
1840
1841 @smallexample
1842 extern void
1843 transpose (int N, int M, double out[M][N], const double in[N][M]);
1844 double x[3][2];
1845 double y[2][3];
1846 @r{@dots{}}
1847 transpose(3, 2, y, x);
1848 @end smallexample
1849
1850 @node Initializers
1851 @section Non-Constant Initializers
1852 @cindex initializers, non-constant
1853 @cindex non-constant initializers
1854
1855 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1856 automatic variable are not required to be constant expressions in GNU C@.
1857 Here is an example of an initializer with run-time varying elements:
1858
1859 @smallexample
1860 foo (float f, float g)
1861 @{
1862 float beat_freqs[2] = @{ f-g, f+g @};
1863 /* @r{@dots{}} */
1864 @}
1865 @end smallexample
1866
1867 @node Compound Literals
1868 @section Compound Literals
1869 @cindex constructor expressions
1870 @cindex initializations in expressions
1871 @cindex structures, constructor expression
1872 @cindex expressions, constructor
1873 @cindex compound literals
1874 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1875
1876 ISO C99 supports compound literals. A compound literal looks like
1877 a cast containing an initializer. Its value is an object of the
1878 type specified in the cast, containing the elements specified in
1879 the initializer; it is an lvalue. As an extension, GCC supports
1880 compound literals in C90 mode and in C++, though the semantics are
1881 somewhat different in C++.
1882
1883 Usually, the specified type is a structure. Assume that
1884 @code{struct foo} and @code{structure} are declared as shown:
1885
1886 @smallexample
1887 struct foo @{int a; char b[2];@} structure;
1888 @end smallexample
1889
1890 @noindent
1891 Here is an example of constructing a @code{struct foo} with a compound literal:
1892
1893 @smallexample
1894 structure = ((struct foo) @{x + y, 'a', 0@});
1895 @end smallexample
1896
1897 @noindent
1898 This is equivalent to writing the following:
1899
1900 @smallexample
1901 @{
1902 struct foo temp = @{x + y, 'a', 0@};
1903 structure = temp;
1904 @}
1905 @end smallexample
1906
1907 You can also construct an array, though this is dangerous in C++, as
1908 explained below. If all the elements of the compound literal are
1909 (made up of) simple constant expressions, suitable for use in
1910 initializers of objects of static storage duration, then the compound
1911 literal can be coerced to a pointer to its first element and used in
1912 such an initializer, as shown here:
1913
1914 @smallexample
1915 char **foo = (char *[]) @{ "x", "y", "z" @};
1916 @end smallexample
1917
1918 Compound literals for scalar types and union types are
1919 also allowed, but then the compound literal is equivalent
1920 to a cast.
1921
1922 As a GNU extension, GCC allows initialization of objects with static storage
1923 duration by compound literals (which is not possible in ISO C99, because
1924 the initializer is not a constant).
1925 It is handled as if the object is initialized only with the bracket
1926 enclosed list if the types of the compound literal and the object match.
1927 The initializer list of the compound literal must be constant.
1928 If the object being initialized has array type of unknown size, the size is
1929 determined by compound literal size.
1930
1931 @smallexample
1932 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1933 static int y[] = (int []) @{1, 2, 3@};
1934 static int z[] = (int [3]) @{1@};
1935 @end smallexample
1936
1937 @noindent
1938 The above lines are equivalent to the following:
1939 @smallexample
1940 static struct foo x = @{1, 'a', 'b'@};
1941 static int y[] = @{1, 2, 3@};
1942 static int z[] = @{1, 0, 0@};
1943 @end smallexample
1944
1945 In C, a compound literal designates an unnamed object with static or
1946 automatic storage duration. In C++, a compound literal designates a
1947 temporary object, which only lives until the end of its
1948 full-expression. As a result, well-defined C code that takes the
1949 address of a subobject of a compound literal can be undefined in C++,
1950 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1951 For instance, if the array compound literal example above appeared
1952 inside a function, any subsequent use of @samp{foo} in C++ has
1953 undefined behavior because the lifetime of the array ends after the
1954 declaration of @samp{foo}.
1955
1956 As an optimization, the C++ compiler sometimes gives array compound
1957 literals longer lifetimes: when the array either appears outside a
1958 function or has const-qualified type. If @samp{foo} and its
1959 initializer had elements of @samp{char *const} type rather than
1960 @samp{char *}, or if @samp{foo} were a global variable, the array
1961 would have static storage duration. But it is probably safest just to
1962 avoid the use of array compound literals in code compiled as C++.
1963
1964 @node Designated Inits
1965 @section Designated Initializers
1966 @cindex initializers with labeled elements
1967 @cindex labeled elements in initializers
1968 @cindex case labels in initializers
1969 @cindex designated initializers
1970
1971 Standard C90 requires the elements of an initializer to appear in a fixed
1972 order, the same as the order of the elements in the array or structure
1973 being initialized.
1974
1975 In ISO C99 you can give the elements in any order, specifying the array
1976 indices or structure field names they apply to, and GNU C allows this as
1977 an extension in C90 mode as well. This extension is not
1978 implemented in GNU C++.
1979
1980 To specify an array index, write
1981 @samp{[@var{index}] =} before the element value. For example,
1982
1983 @smallexample
1984 int a[6] = @{ [4] = 29, [2] = 15 @};
1985 @end smallexample
1986
1987 @noindent
1988 is equivalent to
1989
1990 @smallexample
1991 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1992 @end smallexample
1993
1994 @noindent
1995 The index values must be constant expressions, even if the array being
1996 initialized is automatic.
1997
1998 An alternative syntax for this that has been obsolete since GCC 2.5 but
1999 GCC still accepts is to write @samp{[@var{index}]} before the element
2000 value, with no @samp{=}.
2001
2002 To initialize a range of elements to the same value, write
2003 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2004 extension. For example,
2005
2006 @smallexample
2007 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2008 @end smallexample
2009
2010 @noindent
2011 If the value in it has side-effects, the side-effects happen only once,
2012 not for each initialized field by the range initializer.
2013
2014 @noindent
2015 Note that the length of the array is the highest value specified
2016 plus one.
2017
2018 In a structure initializer, specify the name of a field to initialize
2019 with @samp{.@var{fieldname} =} before the element value. For example,
2020 given the following structure,
2021
2022 @smallexample
2023 struct point @{ int x, y; @};
2024 @end smallexample
2025
2026 @noindent
2027 the following initialization
2028
2029 @smallexample
2030 struct point p = @{ .y = yvalue, .x = xvalue @};
2031 @end smallexample
2032
2033 @noindent
2034 is equivalent to
2035
2036 @smallexample
2037 struct point p = @{ xvalue, yvalue @};
2038 @end smallexample
2039
2040 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2041 @samp{@var{fieldname}:}, as shown here:
2042
2043 @smallexample
2044 struct point p = @{ y: yvalue, x: xvalue @};
2045 @end smallexample
2046
2047 Omitted field members are implicitly initialized the same as objects
2048 that have static storage duration.
2049
2050 @cindex designators
2051 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2052 @dfn{designator}. You can also use a designator (or the obsolete colon
2053 syntax) when initializing a union, to specify which element of the union
2054 should be used. For example,
2055
2056 @smallexample
2057 union foo @{ int i; double d; @};
2058
2059 union foo f = @{ .d = 4 @};
2060 @end smallexample
2061
2062 @noindent
2063 converts 4 to a @code{double} to store it in the union using
2064 the second element. By contrast, casting 4 to type @code{union foo}
2065 stores it into the union as the integer @code{i}, since it is
2066 an integer. (@xref{Cast to Union}.)
2067
2068 You can combine this technique of naming elements with ordinary C
2069 initialization of successive elements. Each initializer element that
2070 does not have a designator applies to the next consecutive element of the
2071 array or structure. For example,
2072
2073 @smallexample
2074 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2075 @end smallexample
2076
2077 @noindent
2078 is equivalent to
2079
2080 @smallexample
2081 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2082 @end smallexample
2083
2084 Labeling the elements of an array initializer is especially useful
2085 when the indices are characters or belong to an @code{enum} type.
2086 For example:
2087
2088 @smallexample
2089 int whitespace[256]
2090 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2091 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2092 @end smallexample
2093
2094 @cindex designator lists
2095 You can also write a series of @samp{.@var{fieldname}} and
2096 @samp{[@var{index}]} designators before an @samp{=} to specify a
2097 nested subobject to initialize; the list is taken relative to the
2098 subobject corresponding to the closest surrounding brace pair. For
2099 example, with the @samp{struct point} declaration above:
2100
2101 @smallexample
2102 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2103 @end smallexample
2104
2105 @noindent
2106 If the same field is initialized multiple times, it has the value from
2107 the last initialization. If any such overridden initialization has
2108 side-effect, it is unspecified whether the side-effect happens or not.
2109 Currently, GCC discards them and issues a warning.
2110
2111 @node Case Ranges
2112 @section Case Ranges
2113 @cindex case ranges
2114 @cindex ranges in case statements
2115
2116 You can specify a range of consecutive values in a single @code{case} label,
2117 like this:
2118
2119 @smallexample
2120 case @var{low} ... @var{high}:
2121 @end smallexample
2122
2123 @noindent
2124 This has the same effect as the proper number of individual @code{case}
2125 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2126
2127 This feature is especially useful for ranges of ASCII character codes:
2128
2129 @smallexample
2130 case 'A' ... 'Z':
2131 @end smallexample
2132
2133 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2134 it may be parsed wrong when you use it with integer values. For example,
2135 write this:
2136
2137 @smallexample
2138 case 1 ... 5:
2139 @end smallexample
2140
2141 @noindent
2142 rather than this:
2143
2144 @smallexample
2145 case 1...5:
2146 @end smallexample
2147
2148 @node Cast to Union
2149 @section Cast to a Union Type
2150 @cindex cast to a union
2151 @cindex union, casting to a
2152
2153 A cast to union type is similar to other casts, except that the type
2154 specified is a union type. You can specify the type either with
2155 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2156 a constructor, not a cast, and hence does not yield an lvalue like
2157 normal casts. (@xref{Compound Literals}.)
2158
2159 The types that may be cast to the union type are those of the members
2160 of the union. Thus, given the following union and variables:
2161
2162 @smallexample
2163 union foo @{ int i; double d; @};
2164 int x;
2165 double y;
2166 @end smallexample
2167
2168 @noindent
2169 both @code{x} and @code{y} can be cast to type @code{union foo}.
2170
2171 Using the cast as the right-hand side of an assignment to a variable of
2172 union type is equivalent to storing in a member of the union:
2173
2174 @smallexample
2175 union foo u;
2176 /* @r{@dots{}} */
2177 u = (union foo) x @equiv{} u.i = x
2178 u = (union foo) y @equiv{} u.d = y
2179 @end smallexample
2180
2181 You can also use the union cast as a function argument:
2182
2183 @smallexample
2184 void hack (union foo);
2185 /* @r{@dots{}} */
2186 hack ((union foo) x);
2187 @end smallexample
2188
2189 @node Mixed Declarations
2190 @section Mixed Declarations and Code
2191 @cindex mixed declarations and code
2192 @cindex declarations, mixed with code
2193 @cindex code, mixed with declarations
2194
2195 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2196 within compound statements. As an extension, GNU C also allows this in
2197 C90 mode. For example, you could do:
2198
2199 @smallexample
2200 int i;
2201 /* @r{@dots{}} */
2202 i++;
2203 int j = i + 2;
2204 @end smallexample
2205
2206 Each identifier is visible from where it is declared until the end of
2207 the enclosing block.
2208
2209 @node Function Attributes
2210 @section Declaring Attributes of Functions
2211 @cindex function attributes
2212 @cindex declaring attributes of functions
2213 @cindex @code{volatile} applied to function
2214 @cindex @code{const} applied to function
2215
2216 In GNU C, you can use function attributes to declare certain things
2217 about functions called in your program which help the compiler
2218 optimize calls and check your code more carefully. For example, you
2219 can use attributes to declare that a function never returns
2220 (@code{noreturn}), returns a value depending only on its arguments
2221 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2222
2223 You can also use attributes to control memory placement, code
2224 generation options or call/return conventions within the function
2225 being annotated. Many of these attributes are target-specific. For
2226 example, many targets support attributes for defining interrupt
2227 handler functions, which typically must follow special register usage
2228 and return conventions.
2229
2230 Function attributes are introduced by the @code{__attribute__} keyword
2231 on a declaration, followed by an attribute specification inside double
2232 parentheses. You can specify multiple attributes in a declaration by
2233 separating them by commas within the double parentheses or by
2234 immediately following an attribute declaration with another attribute
2235 declaration. @xref{Attribute Syntax}, for the exact rules on
2236 attribute syntax and placement.
2237
2238 GCC also supports attributes on
2239 variable declarations (@pxref{Variable Attributes}),
2240 labels (@pxref{Label Attributes}),
2241 enumerators (@pxref{Enumerator Attributes}),
2242 and types (@pxref{Type Attributes}).
2243
2244 There is some overlap between the purposes of attributes and pragmas
2245 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2246 found convenient to use @code{__attribute__} to achieve a natural
2247 attachment of attributes to their corresponding declarations, whereas
2248 @code{#pragma} is of use for compatibility with other compilers
2249 or constructs that do not naturally form part of the grammar.
2250
2251 In addition to the attributes documented here,
2252 GCC plugins may provide their own attributes.
2253
2254 @menu
2255 * Common Function Attributes::
2256 * AArch64 Function Attributes::
2257 * ARC Function Attributes::
2258 * ARM Function Attributes::
2259 * AVR Function Attributes::
2260 * Blackfin Function Attributes::
2261 * CR16 Function Attributes::
2262 * Epiphany Function Attributes::
2263 * H8/300 Function Attributes::
2264 * IA-64 Function Attributes::
2265 * M32C Function Attributes::
2266 * M32R/D Function Attributes::
2267 * m68k Function Attributes::
2268 * MCORE Function Attributes::
2269 * MeP Function Attributes::
2270 * MicroBlaze Function Attributes::
2271 * Microsoft Windows Function Attributes::
2272 * MIPS Function Attributes::
2273 * MSP430 Function Attributes::
2274 * NDS32 Function Attributes::
2275 * Nios II Function Attributes::
2276 * PowerPC Function Attributes::
2277 * RL78 Function Attributes::
2278 * RX Function Attributes::
2279 * S/390 Function Attributes::
2280 * SH Function Attributes::
2281 * SPU Function Attributes::
2282 * Symbian OS Function Attributes::
2283 * Visium Function Attributes::
2284 * x86 Function Attributes::
2285 * Xstormy16 Function Attributes::
2286 @end menu
2287
2288 @node Common Function Attributes
2289 @subsection Common Function Attributes
2290
2291 The following attributes are supported on most targets.
2292
2293 @table @code
2294 @c Keep this table alphabetized by attribute name. Treat _ as space.
2295
2296 @item alias ("@var{target}")
2297 @cindex @code{alias} function attribute
2298 The @code{alias} attribute causes the declaration to be emitted as an
2299 alias for another symbol, which must be specified. For instance,
2300
2301 @smallexample
2302 void __f () @{ /* @r{Do something.} */; @}
2303 void f () __attribute__ ((weak, alias ("__f")));
2304 @end smallexample
2305
2306 @noindent
2307 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2308 mangled name for the target must be used. It is an error if @samp{__f}
2309 is not defined in the same translation unit.
2310
2311 This attribute requires assembler and object file support,
2312 and may not be available on all targets.
2313
2314 @item aligned (@var{alignment})
2315 @cindex @code{aligned} function attribute
2316 This attribute specifies a minimum alignment for the function,
2317 measured in bytes.
2318
2319 You cannot use this attribute to decrease the alignment of a function,
2320 only to increase it. However, when you explicitly specify a function
2321 alignment this overrides the effect of the
2322 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2323 function.
2324
2325 Note that the effectiveness of @code{aligned} attributes may be
2326 limited by inherent limitations in your linker. On many systems, the
2327 linker is only able to arrange for functions to be aligned up to a
2328 certain maximum alignment. (For some linkers, the maximum supported
2329 alignment may be very very small.) See your linker documentation for
2330 further information.
2331
2332 The @code{aligned} attribute can also be used for variables and fields
2333 (@pxref{Variable Attributes}.)
2334
2335 @item alloc_align
2336 @cindex @code{alloc_align} function attribute
2337 The @code{alloc_align} attribute is used to tell the compiler that the
2338 function return value points to memory, where the returned pointer minimum
2339 alignment is given by one of the functions parameters. GCC uses this
2340 information to improve pointer alignment analysis.
2341
2342 The function parameter denoting the allocated alignment is specified by
2343 one integer argument, whose number is the argument of the attribute.
2344 Argument numbering starts at one.
2345
2346 For instance,
2347
2348 @smallexample
2349 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2350 @end smallexample
2351
2352 @noindent
2353 declares that @code{my_memalign} returns memory with minimum alignment
2354 given by parameter 1.
2355
2356 @item alloc_size
2357 @cindex @code{alloc_size} function attribute
2358 The @code{alloc_size} attribute is used to tell the compiler that the
2359 function return value points to memory, where the size is given by
2360 one or two of the functions parameters. GCC uses this
2361 information to improve the correctness of @code{__builtin_object_size}.
2362
2363 The function parameter(s) denoting the allocated size are specified by
2364 one or two integer arguments supplied to the attribute. The allocated size
2365 is either the value of the single function argument specified or the product
2366 of the two function arguments specified. Argument numbering starts at
2367 one.
2368
2369 For instance,
2370
2371 @smallexample
2372 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2373 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2374 @end smallexample
2375
2376 @noindent
2377 declares that @code{my_calloc} returns memory of the size given by
2378 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2379 of the size given by parameter 2.
2380
2381 @item always_inline
2382 @cindex @code{always_inline} function attribute
2383 Generally, functions are not inlined unless optimization is specified.
2384 For functions declared inline, this attribute inlines the function
2385 independent of any restrictions that otherwise apply to inlining.
2386 Failure to inline such a function is diagnosed as an error.
2387 Note that if such a function is called indirectly the compiler may
2388 or may not inline it depending on optimization level and a failure
2389 to inline an indirect call may or may not be diagnosed.
2390
2391 @item artificial
2392 @cindex @code{artificial} function attribute
2393 This attribute is useful for small inline wrappers that if possible
2394 should appear during debugging as a unit. Depending on the debug
2395 info format it either means marking the function as artificial
2396 or using the caller location for all instructions within the inlined
2397 body.
2398
2399 @item assume_aligned
2400 @cindex @code{assume_aligned} function attribute
2401 The @code{assume_aligned} attribute is used to tell the compiler that the
2402 function return value points to memory, where the returned pointer minimum
2403 alignment is given by the first argument.
2404 If the attribute has two arguments, the second argument is misalignment offset.
2405
2406 For instance
2407
2408 @smallexample
2409 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2410 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2411 @end smallexample
2412
2413 @noindent
2414 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2415 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2416 to 8.
2417
2418 @item bnd_instrument
2419 @cindex @code{bnd_instrument} function attribute
2420 The @code{bnd_instrument} attribute on functions is used to inform the
2421 compiler that the function should be instrumented when compiled
2422 with the @option{-fchkp-instrument-marked-only} option.
2423
2424 @item bnd_legacy
2425 @cindex @code{bnd_legacy} function attribute
2426 @cindex Pointer Bounds Checker attributes
2427 The @code{bnd_legacy} attribute on functions is used to inform the
2428 compiler that the function should not be instrumented when compiled
2429 with the @option{-fcheck-pointer-bounds} option.
2430
2431 @item cold
2432 @cindex @code{cold} function attribute
2433 The @code{cold} attribute on functions is used to inform the compiler that
2434 the function is unlikely to be executed. The function is optimized for
2435 size rather than speed and on many targets it is placed into a special
2436 subsection of the text section so all cold functions appear close together,
2437 improving code locality of non-cold parts of program. The paths leading
2438 to calls of cold functions within code are marked as unlikely by the branch
2439 prediction mechanism. It is thus useful to mark functions used to handle
2440 unlikely conditions, such as @code{perror}, as cold to improve optimization
2441 of hot functions that do call marked functions in rare occasions.
2442
2443 When profile feedback is available, via @option{-fprofile-use}, cold functions
2444 are automatically detected and this attribute is ignored.
2445
2446 @item const
2447 @cindex @code{const} function attribute
2448 @cindex functions that have no side effects
2449 Many functions do not examine any values except their arguments, and
2450 have no effects except the return value. Basically this is just slightly
2451 more strict class than the @code{pure} attribute below, since function is not
2452 allowed to read global memory.
2453
2454 @cindex pointer arguments
2455 Note that a function that has pointer arguments and examines the data
2456 pointed to must @emph{not} be declared @code{const}. Likewise, a
2457 function that calls a non-@code{const} function usually must not be
2458 @code{const}. It does not make sense for a @code{const} function to
2459 return @code{void}.
2460
2461 @item constructor
2462 @itemx destructor
2463 @itemx constructor (@var{priority})
2464 @itemx destructor (@var{priority})
2465 @cindex @code{constructor} function attribute
2466 @cindex @code{destructor} function attribute
2467 The @code{constructor} attribute causes the function to be called
2468 automatically before execution enters @code{main ()}. Similarly, the
2469 @code{destructor} attribute causes the function to be called
2470 automatically after @code{main ()} completes or @code{exit ()} is
2471 called. Functions with these attributes are useful for
2472 initializing data that is used implicitly during the execution of
2473 the program.
2474
2475 You may provide an optional integer priority to control the order in
2476 which constructor and destructor functions are run. A constructor
2477 with a smaller priority number runs before a constructor with a larger
2478 priority number; the opposite relationship holds for destructors. So,
2479 if you have a constructor that allocates a resource and a destructor
2480 that deallocates the same resource, both functions typically have the
2481 same priority. The priorities for constructor and destructor
2482 functions are the same as those specified for namespace-scope C++
2483 objects (@pxref{C++ Attributes}).
2484
2485 These attributes are not currently implemented for Objective-C@.
2486
2487 @item deprecated
2488 @itemx deprecated (@var{msg})
2489 @cindex @code{deprecated} function attribute
2490 The @code{deprecated} attribute results in a warning if the function
2491 is used anywhere in the source file. This is useful when identifying
2492 functions that are expected to be removed in a future version of a
2493 program. The warning also includes the location of the declaration
2494 of the deprecated function, to enable users to easily find further
2495 information about why the function is deprecated, or what they should
2496 do instead. Note that the warnings only occurs for uses:
2497
2498 @smallexample
2499 int old_fn () __attribute__ ((deprecated));
2500 int old_fn ();
2501 int (*fn_ptr)() = old_fn;
2502 @end smallexample
2503
2504 @noindent
2505 results in a warning on line 3 but not line 2. The optional @var{msg}
2506 argument, which must be a string, is printed in the warning if
2507 present.
2508
2509 The @code{deprecated} attribute can also be used for variables and
2510 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2511
2512 @item error ("@var{message}")
2513 @itemx warning ("@var{message}")
2514 @cindex @code{error} function attribute
2515 @cindex @code{warning} function attribute
2516 If the @code{error} or @code{warning} attribute
2517 is used on a function declaration and a call to such a function
2518 is not eliminated through dead code elimination or other optimizations,
2519 an error or warning (respectively) that includes @var{message} is diagnosed.
2520 This is useful
2521 for compile-time checking, especially together with @code{__builtin_constant_p}
2522 and inline functions where checking the inline function arguments is not
2523 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2524
2525 While it is possible to leave the function undefined and thus invoke
2526 a link failure (to define the function with
2527 a message in @code{.gnu.warning*} section),
2528 when using these attributes the problem is diagnosed
2529 earlier and with exact location of the call even in presence of inline
2530 functions or when not emitting debugging information.
2531
2532 @item externally_visible
2533 @cindex @code{externally_visible} function attribute
2534 This attribute, attached to a global variable or function, nullifies
2535 the effect of the @option{-fwhole-program} command-line option, so the
2536 object remains visible outside the current compilation unit.
2537
2538 If @option{-fwhole-program} is used together with @option{-flto} and
2539 @command{gold} is used as the linker plugin,
2540 @code{externally_visible} attributes are automatically added to functions
2541 (not variable yet due to a current @command{gold} issue)
2542 that are accessed outside of LTO objects according to resolution file
2543 produced by @command{gold}.
2544 For other linkers that cannot generate resolution file,
2545 explicit @code{externally_visible} attributes are still necessary.
2546
2547 @item flatten
2548 @cindex @code{flatten} function attribute
2549 Generally, inlining into a function is limited. For a function marked with
2550 this attribute, every call inside this function is inlined, if possible.
2551 Whether the function itself is considered for inlining depends on its size and
2552 the current inlining parameters.
2553
2554 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2555 @cindex @code{format} function attribute
2556 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2557 @opindex Wformat
2558 The @code{format} attribute specifies that a function takes @code{printf},
2559 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2560 should be type-checked against a format string. For example, the
2561 declaration:
2562
2563 @smallexample
2564 extern int
2565 my_printf (void *my_object, const char *my_format, ...)
2566 __attribute__ ((format (printf, 2, 3)));
2567 @end smallexample
2568
2569 @noindent
2570 causes the compiler to check the arguments in calls to @code{my_printf}
2571 for consistency with the @code{printf} style format string argument
2572 @code{my_format}.
2573
2574 The parameter @var{archetype} determines how the format string is
2575 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2576 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2577 @code{strfmon}. (You can also use @code{__printf__},
2578 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2579 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2580 @code{ms_strftime} are also present.
2581 @var{archetype} values such as @code{printf} refer to the formats accepted
2582 by the system's C runtime library,
2583 while values prefixed with @samp{gnu_} always refer
2584 to the formats accepted by the GNU C Library. On Microsoft Windows
2585 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2586 @file{msvcrt.dll} library.
2587 The parameter @var{string-index}
2588 specifies which argument is the format string argument (starting
2589 from 1), while @var{first-to-check} is the number of the first
2590 argument to check against the format string. For functions
2591 where the arguments are not available to be checked (such as
2592 @code{vprintf}), specify the third parameter as zero. In this case the
2593 compiler only checks the format string for consistency. For
2594 @code{strftime} formats, the third parameter is required to be zero.
2595 Since non-static C++ methods have an implicit @code{this} argument, the
2596 arguments of such methods should be counted from two, not one, when
2597 giving values for @var{string-index} and @var{first-to-check}.
2598
2599 In the example above, the format string (@code{my_format}) is the second
2600 argument of the function @code{my_print}, and the arguments to check
2601 start with the third argument, so the correct parameters for the format
2602 attribute are 2 and 3.
2603
2604 @opindex ffreestanding
2605 @opindex fno-builtin
2606 The @code{format} attribute allows you to identify your own functions
2607 that take format strings as arguments, so that GCC can check the
2608 calls to these functions for errors. The compiler always (unless
2609 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2610 for the standard library functions @code{printf}, @code{fprintf},
2611 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2612 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2613 warnings are requested (using @option{-Wformat}), so there is no need to
2614 modify the header file @file{stdio.h}. In C99 mode, the functions
2615 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2616 @code{vsscanf} are also checked. Except in strictly conforming C
2617 standard modes, the X/Open function @code{strfmon} is also checked as
2618 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2619 @xref{C Dialect Options,,Options Controlling C Dialect}.
2620
2621 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2622 recognized in the same context. Declarations including these format attributes
2623 are parsed for correct syntax, however the result of checking of such format
2624 strings is not yet defined, and is not carried out by this version of the
2625 compiler.
2626
2627 The target may also provide additional types of format checks.
2628 @xref{Target Format Checks,,Format Checks Specific to Particular
2629 Target Machines}.
2630
2631 @item format_arg (@var{string-index})
2632 @cindex @code{format_arg} function attribute
2633 @opindex Wformat-nonliteral
2634 The @code{format_arg} attribute specifies that a function takes a format
2635 string for a @code{printf}, @code{scanf}, @code{strftime} or
2636 @code{strfmon} style function and modifies it (for example, to translate
2637 it into another language), so the result can be passed to a
2638 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2639 function (with the remaining arguments to the format function the same
2640 as they would have been for the unmodified string). For example, the
2641 declaration:
2642
2643 @smallexample
2644 extern char *
2645 my_dgettext (char *my_domain, const char *my_format)
2646 __attribute__ ((format_arg (2)));
2647 @end smallexample
2648
2649 @noindent
2650 causes the compiler to check the arguments in calls to a @code{printf},
2651 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2652 format string argument is a call to the @code{my_dgettext} function, for
2653 consistency with the format string argument @code{my_format}. If the
2654 @code{format_arg} attribute had not been specified, all the compiler
2655 could tell in such calls to format functions would be that the format
2656 string argument is not constant; this would generate a warning when
2657 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2658 without the attribute.
2659
2660 The parameter @var{string-index} specifies which argument is the format
2661 string argument (starting from one). Since non-static C++ methods have
2662 an implicit @code{this} argument, the arguments of such methods should
2663 be counted from two.
2664
2665 The @code{format_arg} attribute allows you to identify your own
2666 functions that modify format strings, so that GCC can check the
2667 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2668 type function whose operands are a call to one of your own function.
2669 The compiler always treats @code{gettext}, @code{dgettext}, and
2670 @code{dcgettext} in this manner except when strict ISO C support is
2671 requested by @option{-ansi} or an appropriate @option{-std} option, or
2672 @option{-ffreestanding} or @option{-fno-builtin}
2673 is used. @xref{C Dialect Options,,Options
2674 Controlling C Dialect}.
2675
2676 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2677 @code{NSString} reference for compatibility with the @code{format} attribute
2678 above.
2679
2680 The target may also allow additional types in @code{format-arg} attributes.
2681 @xref{Target Format Checks,,Format Checks Specific to Particular
2682 Target Machines}.
2683
2684 @item gnu_inline
2685 @cindex @code{gnu_inline} function attribute
2686 This attribute should be used with a function that is also declared
2687 with the @code{inline} keyword. It directs GCC to treat the function
2688 as if it were defined in gnu90 mode even when compiling in C99 or
2689 gnu99 mode.
2690
2691 If the function is declared @code{extern}, then this definition of the
2692 function is used only for inlining. In no case is the function
2693 compiled as a standalone function, not even if you take its address
2694 explicitly. Such an address becomes an external reference, as if you
2695 had only declared the function, and had not defined it. This has
2696 almost the effect of a macro. The way to use this is to put a
2697 function definition in a header file with this attribute, and put
2698 another copy of the function, without @code{extern}, in a library
2699 file. The definition in the header file causes most calls to the
2700 function to be inlined. If any uses of the function remain, they
2701 refer to the single copy in the library. Note that the two
2702 definitions of the functions need not be precisely the same, although
2703 if they do not have the same effect your program may behave oddly.
2704
2705 In C, if the function is neither @code{extern} nor @code{static}, then
2706 the function is compiled as a standalone function, as well as being
2707 inlined where possible.
2708
2709 This is how GCC traditionally handled functions declared
2710 @code{inline}. Since ISO C99 specifies a different semantics for
2711 @code{inline}, this function attribute is provided as a transition
2712 measure and as a useful feature in its own right. This attribute is
2713 available in GCC 4.1.3 and later. It is available if either of the
2714 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2715 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2716 Function is As Fast As a Macro}.
2717
2718 In C++, this attribute does not depend on @code{extern} in any way,
2719 but it still requires the @code{inline} keyword to enable its special
2720 behavior.
2721
2722 @item hot
2723 @cindex @code{hot} function attribute
2724 The @code{hot} attribute on a function is used to inform the compiler that
2725 the function is a hot spot of the compiled program. The function is
2726 optimized more aggressively and on many targets it is placed into a special
2727 subsection of the text section so all hot functions appear close together,
2728 improving locality.
2729
2730 When profile feedback is available, via @option{-fprofile-use}, hot functions
2731 are automatically detected and this attribute is ignored.
2732
2733 @item ifunc ("@var{resolver}")
2734 @cindex @code{ifunc} function attribute
2735 @cindex indirect functions
2736 @cindex functions that are dynamically resolved
2737 The @code{ifunc} attribute is used to mark a function as an indirect
2738 function using the STT_GNU_IFUNC symbol type extension to the ELF
2739 standard. This allows the resolution of the symbol value to be
2740 determined dynamically at load time, and an optimized version of the
2741 routine can be selected for the particular processor or other system
2742 characteristics determined then. To use this attribute, first define
2743 the implementation functions available, and a resolver function that
2744 returns a pointer to the selected implementation function. The
2745 implementation functions' declarations must match the API of the
2746 function being implemented, the resolver's declaration is be a
2747 function returning pointer to void function returning void:
2748
2749 @smallexample
2750 void *my_memcpy (void *dst, const void *src, size_t len)
2751 @{
2752 @dots{}
2753 @}
2754
2755 static void (*resolve_memcpy (void)) (void)
2756 @{
2757 return my_memcpy; // we'll just always select this routine
2758 @}
2759 @end smallexample
2760
2761 @noindent
2762 The exported header file declaring the function the user calls would
2763 contain:
2764
2765 @smallexample
2766 extern void *memcpy (void *, const void *, size_t);
2767 @end smallexample
2768
2769 @noindent
2770 allowing the user to call this as a regular function, unaware of the
2771 implementation. Finally, the indirect function needs to be defined in
2772 the same translation unit as the resolver function:
2773
2774 @smallexample
2775 void *memcpy (void *, const void *, size_t)
2776 __attribute__ ((ifunc ("resolve_memcpy")));
2777 @end smallexample
2778
2779 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2780 and GNU C Library version 2.11.1 are required to use this feature.
2781
2782 @item interrupt
2783 @itemx interrupt_handler
2784 Many GCC back ends support attributes to indicate that a function is
2785 an interrupt handler, which tells the compiler to generate function
2786 entry and exit sequences that differ from those from regular
2787 functions. The exact syntax and behavior are target-specific;
2788 refer to the following subsections for details.
2789
2790 @item leaf
2791 @cindex @code{leaf} function attribute
2792 Calls to external functions with this attribute must return to the current
2793 compilation unit only by return or by exception handling. In particular, leaf
2794 functions are not allowed to call callback function passed to it from the current
2795 compilation unit or directly call functions exported by the unit or longjmp
2796 into the unit. Leaf function might still call functions from other compilation
2797 units and thus they are not necessarily leaf in the sense that they contain no
2798 function calls at all.
2799
2800 The attribute is intended for library functions to improve dataflow analysis.
2801 The compiler takes the hint that any data not escaping the current compilation unit can
2802 not be used or modified by the leaf function. For example, the @code{sin} function
2803 is a leaf function, but @code{qsort} is not.
2804
2805 Note that leaf functions might invoke signals and signal handlers might be
2806 defined in the current compilation unit and use static variables. The only
2807 compliant way to write such a signal handler is to declare such variables
2808 @code{volatile}.
2809
2810 The attribute has no effect on functions defined within the current compilation
2811 unit. This is to allow easy merging of multiple compilation units into one,
2812 for example, by using the link-time optimization. For this reason the
2813 attribute is not allowed on types to annotate indirect calls.
2814
2815
2816 @item malloc
2817 @cindex @code{malloc} function attribute
2818 @cindex functions that behave like malloc
2819 This tells the compiler that a function is @code{malloc}-like, i.e.,
2820 that the pointer @var{P} returned by the function cannot alias any
2821 other pointer valid when the function returns, and moreover no
2822 pointers to valid objects occur in any storage addressed by @var{P}.
2823
2824 Using this attribute can improve optimization. Functions like
2825 @code{malloc} and @code{calloc} have this property because they return
2826 a pointer to uninitialized or zeroed-out storage. However, functions
2827 like @code{realloc} do not have this property, as they can return a
2828 pointer to storage containing pointers.
2829
2830 @item no_icf
2831 @cindex @code{no_icf} function attribute
2832 This function attribute prevents a functions from being merged with another
2833 semantically equivalent function.
2834
2835 @item no_instrument_function
2836 @cindex @code{no_instrument_function} function attribute
2837 @opindex finstrument-functions
2838 If @option{-finstrument-functions} is given, profiling function calls are
2839 generated at entry and exit of most user-compiled functions.
2840 Functions with this attribute are not so instrumented.
2841
2842 @item no_reorder
2843 @cindex @code{no_reorder} function attribute
2844 Do not reorder functions or variables marked @code{no_reorder}
2845 against each other or top level assembler statements the executable.
2846 The actual order in the program will depend on the linker command
2847 line. Static variables marked like this are also not removed.
2848 This has a similar effect
2849 as the @option{-fno-toplevel-reorder} option, but only applies to the
2850 marked symbols.
2851
2852 @item no_sanitize_address
2853 @itemx no_address_safety_analysis
2854 @cindex @code{no_sanitize_address} function attribute
2855 The @code{no_sanitize_address} attribute on functions is used
2856 to inform the compiler that it should not instrument memory accesses
2857 in the function when compiling with the @option{-fsanitize=address} option.
2858 The @code{no_address_safety_analysis} is a deprecated alias of the
2859 @code{no_sanitize_address} attribute, new code should use
2860 @code{no_sanitize_address}.
2861
2862 @item no_sanitize_thread
2863 @cindex @code{no_sanitize_thread} function attribute
2864 The @code{no_sanitize_thread} attribute on functions is used
2865 to inform the compiler that it should not instrument memory accesses
2866 in the function when compiling with the @option{-fsanitize=thread} option.
2867
2868 @item no_sanitize_undefined
2869 @cindex @code{no_sanitize_undefined} function attribute
2870 The @code{no_sanitize_undefined} attribute on functions is used
2871 to inform the compiler that it should not check for undefined behavior
2872 in the function when compiling with the @option{-fsanitize=undefined} option.
2873
2874 @item no_split_stack
2875 @cindex @code{no_split_stack} function attribute
2876 @opindex fsplit-stack
2877 If @option{-fsplit-stack} is given, functions have a small
2878 prologue which decides whether to split the stack. Functions with the
2879 @code{no_split_stack} attribute do not have that prologue, and thus
2880 may run with only a small amount of stack space available.
2881
2882 @item noclone
2883 @cindex @code{noclone} function attribute
2884 This function attribute prevents a function from being considered for
2885 cloning---a mechanism that produces specialized copies of functions
2886 and which is (currently) performed by interprocedural constant
2887 propagation.
2888
2889 @item noinline
2890 @cindex @code{noinline} function attribute
2891 This function attribute prevents a function from being considered for
2892 inlining.
2893 @c Don't enumerate the optimizations by name here; we try to be
2894 @c future-compatible with this mechanism.
2895 If the function does not have side-effects, there are optimizations
2896 other than inlining that cause function calls to be optimized away,
2897 although the function call is live. To keep such calls from being
2898 optimized away, put
2899 @smallexample
2900 asm ("");
2901 @end smallexample
2902
2903 @noindent
2904 (@pxref{Extended Asm}) in the called function, to serve as a special
2905 side-effect.
2906
2907 @item nonnull (@var{arg-index}, @dots{})
2908 @cindex @code{nonnull} function attribute
2909 @cindex functions with non-null pointer arguments
2910 The @code{nonnull} attribute specifies that some function parameters should
2911 be non-null pointers. For instance, the declaration:
2912
2913 @smallexample
2914 extern void *
2915 my_memcpy (void *dest, const void *src, size_t len)
2916 __attribute__((nonnull (1, 2)));
2917 @end smallexample
2918
2919 @noindent
2920 causes the compiler to check that, in calls to @code{my_memcpy},
2921 arguments @var{dest} and @var{src} are non-null. If the compiler
2922 determines that a null pointer is passed in an argument slot marked
2923 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2924 is issued. The compiler may also choose to make optimizations based
2925 on the knowledge that certain function arguments will never be null.
2926
2927 If no argument index list is given to the @code{nonnull} attribute,
2928 all pointer arguments are marked as non-null. To illustrate, the
2929 following declaration is equivalent to the previous example:
2930
2931 @smallexample
2932 extern void *
2933 my_memcpy (void *dest, const void *src, size_t len)
2934 __attribute__((nonnull));
2935 @end smallexample
2936
2937 @item noreturn
2938 @cindex @code{noreturn} function attribute
2939 @cindex functions that never return
2940 A few standard library functions, such as @code{abort} and @code{exit},
2941 cannot return. GCC knows this automatically. Some programs define
2942 their own functions that never return. You can declare them
2943 @code{noreturn} to tell the compiler this fact. For example,
2944
2945 @smallexample
2946 @group
2947 void fatal () __attribute__ ((noreturn));
2948
2949 void
2950 fatal (/* @r{@dots{}} */)
2951 @{
2952 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2953 exit (1);
2954 @}
2955 @end group
2956 @end smallexample
2957
2958 The @code{noreturn} keyword tells the compiler to assume that
2959 @code{fatal} cannot return. It can then optimize without regard to what
2960 would happen if @code{fatal} ever did return. This makes slightly
2961 better code. More importantly, it helps avoid spurious warnings of
2962 uninitialized variables.
2963
2964 The @code{noreturn} keyword does not affect the exceptional path when that
2965 applies: a @code{noreturn}-marked function may still return to the caller
2966 by throwing an exception or calling @code{longjmp}.
2967
2968 Do not assume that registers saved by the calling function are
2969 restored before calling the @code{noreturn} function.
2970
2971 It does not make sense for a @code{noreturn} function to have a return
2972 type other than @code{void}.
2973
2974 @item nothrow
2975 @cindex @code{nothrow} function attribute
2976 The @code{nothrow} attribute is used to inform the compiler that a
2977 function cannot throw an exception. For example, most functions in
2978 the standard C library can be guaranteed not to throw an exception
2979 with the notable exceptions of @code{qsort} and @code{bsearch} that
2980 take function pointer arguments.
2981
2982 @item noplt
2983 @cindex @code{noplt} function attribute
2984 The @code{noplt} attribute is the counterpart to option @option{-fno-plt} and
2985 does not use PLT for calls to functions marked with this attribute in position
2986 independent code.
2987
2988 @smallexample
2989 @group
2990 /* Externally defined function foo. */
2991 int foo () __attribute__ ((noplt));
2992
2993 int
2994 main (/* @r{@dots{}} */)
2995 @{
2996 /* @r{@dots{}} */
2997 foo ();
2998 /* @r{@dots{}} */
2999 @}
3000 @end group
3001 @end smallexample
3002
3003 The @code{noplt} attribute on function foo tells the compiler to assume that
3004 the function foo is externally defined and the call to foo must avoid the PLT
3005 in position independent code.
3006
3007 Additionally, a few targets also convert calls to those functions that are
3008 marked to not use the PLT to use the GOT instead for non-position independent
3009 code.
3010
3011 @item optimize
3012 @cindex @code{optimize} function attribute
3013 The @code{optimize} attribute is used to specify that a function is to
3014 be compiled with different optimization options than specified on the
3015 command line. Arguments can either be numbers or strings. Numbers
3016 are assumed to be an optimization level. Strings that begin with
3017 @code{O} are assumed to be an optimization option, while other options
3018 are assumed to be used with a @code{-f} prefix. You can also use the
3019 @samp{#pragma GCC optimize} pragma to set the optimization options
3020 that affect more than one function.
3021 @xref{Function Specific Option Pragmas}, for details about the
3022 @samp{#pragma GCC optimize} pragma.
3023
3024 This can be used for instance to have frequently-executed functions
3025 compiled with more aggressive optimization options that produce faster
3026 and larger code, while other functions can be compiled with less
3027 aggressive options.
3028
3029 @item pure
3030 @cindex @code{pure} function attribute
3031 @cindex functions that have no side effects
3032 Many functions have no effects except the return value and their
3033 return value depends only on the parameters and/or global variables.
3034 Such a function can be subject
3035 to common subexpression elimination and loop optimization just as an
3036 arithmetic operator would be. These functions should be declared
3037 with the attribute @code{pure}. For example,
3038
3039 @smallexample
3040 int square (int) __attribute__ ((pure));
3041 @end smallexample
3042
3043 @noindent
3044 says that the hypothetical function @code{square} is safe to call
3045 fewer times than the program says.
3046
3047 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3048 Interesting non-pure functions are functions with infinite loops or those
3049 depending on volatile memory or other system resource, that may change between
3050 two consecutive calls (such as @code{feof} in a multithreading environment).
3051
3052 @item returns_nonnull
3053 @cindex @code{returns_nonnull} function attribute
3054 The @code{returns_nonnull} attribute specifies that the function
3055 return value should be a non-null pointer. For instance, the declaration:
3056
3057 @smallexample
3058 extern void *
3059 mymalloc (size_t len) __attribute__((returns_nonnull));
3060 @end smallexample
3061
3062 @noindent
3063 lets the compiler optimize callers based on the knowledge
3064 that the return value will never be null.
3065
3066 @item returns_twice
3067 @cindex @code{returns_twice} function attribute
3068 @cindex functions that return more than once
3069 The @code{returns_twice} attribute tells the compiler that a function may
3070 return more than one time. The compiler ensures that all registers
3071 are dead before calling such a function and emits a warning about
3072 the variables that may be clobbered after the second return from the
3073 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3074 The @code{longjmp}-like counterpart of such function, if any, might need
3075 to be marked with the @code{noreturn} attribute.
3076
3077 @item section ("@var{section-name}")
3078 @cindex @code{section} function attribute
3079 @cindex functions in arbitrary sections
3080 Normally, the compiler places the code it generates in the @code{text} section.
3081 Sometimes, however, you need additional sections, or you need certain
3082 particular functions to appear in special sections. The @code{section}
3083 attribute specifies that a function lives in a particular section.
3084 For example, the declaration:
3085
3086 @smallexample
3087 extern void foobar (void) __attribute__ ((section ("bar")));
3088 @end smallexample
3089
3090 @noindent
3091 puts the function @code{foobar} in the @code{bar} section.
3092
3093 Some file formats do not support arbitrary sections so the @code{section}
3094 attribute is not available on all platforms.
3095 If you need to map the entire contents of a module to a particular
3096 section, consider using the facilities of the linker instead.
3097
3098 @item sentinel
3099 @cindex @code{sentinel} function attribute
3100 This function attribute ensures that a parameter in a function call is
3101 an explicit @code{NULL}. The attribute is only valid on variadic
3102 functions. By default, the sentinel is located at position zero, the
3103 last parameter of the function call. If an optional integer position
3104 argument P is supplied to the attribute, the sentinel must be located at
3105 position P counting backwards from the end of the argument list.
3106
3107 @smallexample
3108 __attribute__ ((sentinel))
3109 is equivalent to
3110 __attribute__ ((sentinel(0)))
3111 @end smallexample
3112
3113 The attribute is automatically set with a position of 0 for the built-in
3114 functions @code{execl} and @code{execlp}. The built-in function
3115 @code{execle} has the attribute set with a position of 1.
3116
3117 A valid @code{NULL} in this context is defined as zero with any pointer
3118 type. If your system defines the @code{NULL} macro with an integer type
3119 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3120 with a copy that redefines NULL appropriately.
3121
3122 The warnings for missing or incorrect sentinels are enabled with
3123 @option{-Wformat}.
3124
3125 @item stack_protect
3126 @cindex @code{stack_protect} function attribute
3127 This function attribute make a stack protection of the function if
3128 flags @option{fstack-protector} or @option{fstack-protector-strong}
3129 or @option{fstack-protector-explicit} are set.
3130
3131 @item target_clones (@var{options})
3132 @cindex @code{target_clones} function attribute
3133 The @code{target_clones} attribute is used to specify that a function is to
3134 be cloned into multiple versions compiled with different target options
3135 than specified on the command line. The supported options and restrictions
3136 are the same as for @code{target} attribute.
3137
3138 For instance on an x86, you could compile a function with
3139 @code{target_clones("sse4.1,avx")}. It will create 2 function clones,
3140 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3141 At the function call it will create resolver @code{ifunc}, that will
3142 dynamically call a clone suitable for current architecture.
3143
3144 @item simd
3145 @itemx simd("@var{mask}")
3146 @cindex @code{simd} function attribute.
3147 This attribute enables creation of one or more function versions that
3148 can process multiple arguments using SIMD instructions from a
3149 single invocation. Specifying this attribute allows compiler to
3150 assume that such versions are available at link time (provided
3151 in the same or another translation unit). Generated versions are
3152 target dependent and described in corresponding Vector ABI document. For
3153 x86_64 target this document can be found
3154 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3155 The attribute should not be used together with Cilk Plus @code{vector}
3156 attribute on the same function.
3157 If the attribute is specified and @code{#pragma omp declare simd}
3158 present on a declaration and @code{-fopenmp} or @code{-fopenmp-simd}
3159 switch is specified, then the attribute is ignored.
3160 The optional argument @var{mask} may have "notinbranch" or "inbranch"
3161 value and instructs the compiler to generate non-masked or masked
3162 clones correspondingly. By default, all clones are generated.
3163
3164 @item target (@var{options})
3165 @cindex @code{target} function attribute
3166 Multiple target back ends implement the @code{target} attribute
3167 to specify that a function is to
3168 be compiled with different target options than specified on the
3169 command line. This can be used for instance to have functions
3170 compiled with a different ISA (instruction set architecture) than the
3171 default. You can also use the @samp{#pragma GCC target} pragma to set
3172 more than one function to be compiled with specific target options.
3173 @xref{Function Specific Option Pragmas}, for details about the
3174 @samp{#pragma GCC target} pragma.
3175
3176 For instance, on an x86, you could declare one function with the
3177 @code{target("sse4.1,arch=core2")} attribute and another with
3178 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3179 compiling the first function with @option{-msse4.1} and
3180 @option{-march=core2} options, and the second function with
3181 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3182 to make sure that a function is only invoked on a machine that
3183 supports the particular ISA it is compiled for (for example by using
3184 @code{cpuid} on x86 to determine what feature bits and architecture
3185 family are used).
3186
3187 @smallexample
3188 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3189 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3190 @end smallexample
3191
3192 You can either use multiple
3193 strings separated by commas to specify multiple options,
3194 or separate the options with a comma (@samp{,}) within a single string.
3195
3196 The options supported are specific to each target; refer to @ref{x86
3197 Function Attributes}, @ref{PowerPC Function Attributes},
3198 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3199 for details.
3200
3201 @item unused
3202 @cindex @code{unused} function attribute
3203 This attribute, attached to a function, means that the function is meant
3204 to be possibly unused. GCC does not produce a warning for this
3205 function.
3206
3207 @item used
3208 @cindex @code{used} function attribute
3209 This attribute, attached to a function, means that code must be emitted
3210 for the function even if it appears that the function is not referenced.
3211 This is useful, for example, when the function is referenced only in
3212 inline assembly.
3213
3214 When applied to a member function of a C++ class template, the
3215 attribute also means that the function is instantiated if the
3216 class itself is instantiated.
3217
3218 @item visibility ("@var{visibility_type}")
3219 @cindex @code{visibility} function attribute
3220 This attribute affects the linkage of the declaration to which it is attached.
3221 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3222 (@pxref{Common Type Attributes}) as well as functions.
3223
3224 There are four supported @var{visibility_type} values: default,
3225 hidden, protected or internal visibility.
3226
3227 @smallexample
3228 void __attribute__ ((visibility ("protected")))
3229 f () @{ /* @r{Do something.} */; @}
3230 int i __attribute__ ((visibility ("hidden")));
3231 @end smallexample
3232
3233 The possible values of @var{visibility_type} correspond to the
3234 visibility settings in the ELF gABI.
3235
3236 @table @code
3237 @c keep this list of visibilities in alphabetical order.
3238
3239 @item default
3240 Default visibility is the normal case for the object file format.
3241 This value is available for the visibility attribute to override other
3242 options that may change the assumed visibility of entities.
3243
3244 On ELF, default visibility means that the declaration is visible to other
3245 modules and, in shared libraries, means that the declared entity may be
3246 overridden.
3247
3248 On Darwin, default visibility means that the declaration is visible to
3249 other modules.
3250
3251 Default visibility corresponds to ``external linkage'' in the language.
3252
3253 @item hidden
3254 Hidden visibility indicates that the entity declared has a new
3255 form of linkage, which we call ``hidden linkage''. Two
3256 declarations of an object with hidden linkage refer to the same object
3257 if they are in the same shared object.
3258
3259 @item internal
3260 Internal visibility is like hidden visibility, but with additional
3261 processor specific semantics. Unless otherwise specified by the
3262 psABI, GCC defines internal visibility to mean that a function is
3263 @emph{never} called from another module. Compare this with hidden
3264 functions which, while they cannot be referenced directly by other
3265 modules, can be referenced indirectly via function pointers. By
3266 indicating that a function cannot be called from outside the module,
3267 GCC may for instance omit the load of a PIC register since it is known
3268 that the calling function loaded the correct value.
3269
3270 @item protected
3271 Protected visibility is like default visibility except that it
3272 indicates that references within the defining module bind to the
3273 definition in that module. That is, the declared entity cannot be
3274 overridden by another module.
3275
3276 @end table
3277
3278 All visibilities are supported on many, but not all, ELF targets
3279 (supported when the assembler supports the @samp{.visibility}
3280 pseudo-op). Default visibility is supported everywhere. Hidden
3281 visibility is supported on Darwin targets.
3282
3283 The visibility attribute should be applied only to declarations that
3284 would otherwise have external linkage. The attribute should be applied
3285 consistently, so that the same entity should not be declared with
3286 different settings of the attribute.
3287
3288 In C++, the visibility attribute applies to types as well as functions
3289 and objects, because in C++ types have linkage. A class must not have
3290 greater visibility than its non-static data member types and bases,
3291 and class members default to the visibility of their class. Also, a
3292 declaration without explicit visibility is limited to the visibility
3293 of its type.
3294
3295 In C++, you can mark member functions and static member variables of a
3296 class with the visibility attribute. This is useful if you know a
3297 particular method or static member variable should only be used from
3298 one shared object; then you can mark it hidden while the rest of the
3299 class has default visibility. Care must be taken to avoid breaking
3300 the One Definition Rule; for example, it is usually not useful to mark
3301 an inline method as hidden without marking the whole class as hidden.
3302
3303 A C++ namespace declaration can also have the visibility attribute.
3304
3305 @smallexample
3306 namespace nspace1 __attribute__ ((visibility ("protected")))
3307 @{ /* @r{Do something.} */; @}
3308 @end smallexample
3309
3310 This attribute applies only to the particular namespace body, not to
3311 other definitions of the same namespace; it is equivalent to using
3312 @samp{#pragma GCC visibility} before and after the namespace
3313 definition (@pxref{Visibility Pragmas}).
3314
3315 In C++, if a template argument has limited visibility, this
3316 restriction is implicitly propagated to the template instantiation.
3317 Otherwise, template instantiations and specializations default to the
3318 visibility of their template.
3319
3320 If both the template and enclosing class have explicit visibility, the
3321 visibility from the template is used.
3322
3323 @item warn_unused_result
3324 @cindex @code{warn_unused_result} function attribute
3325 The @code{warn_unused_result} attribute causes a warning to be emitted
3326 if a caller of the function with this attribute does not use its
3327 return value. This is useful for functions where not checking
3328 the result is either a security problem or always a bug, such as
3329 @code{realloc}.
3330
3331 @smallexample
3332 int fn () __attribute__ ((warn_unused_result));
3333 int foo ()
3334 @{
3335 if (fn () < 0) return -1;
3336 fn ();
3337 return 0;
3338 @}
3339 @end smallexample
3340
3341 @noindent
3342 results in warning on line 5.
3343
3344 @item weak
3345 @cindex @code{weak} function attribute
3346 The @code{weak} attribute causes the declaration to be emitted as a weak
3347 symbol rather than a global. This is primarily useful in defining
3348 library functions that can be overridden in user code, though it can
3349 also be used with non-function declarations. Weak symbols are supported
3350 for ELF targets, and also for a.out targets when using the GNU assembler
3351 and linker.
3352
3353 @item weakref
3354 @itemx weakref ("@var{target}")
3355 @cindex @code{weakref} function attribute
3356 The @code{weakref} attribute marks a declaration as a weak reference.
3357 Without arguments, it should be accompanied by an @code{alias} attribute
3358 naming the target symbol. Optionally, the @var{target} may be given as
3359 an argument to @code{weakref} itself. In either case, @code{weakref}
3360 implicitly marks the declaration as @code{weak}. Without a
3361 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3362 @code{weakref} is equivalent to @code{weak}.
3363
3364 @smallexample
3365 static int x() __attribute__ ((weakref ("y")));
3366 /* is equivalent to... */
3367 static int x() __attribute__ ((weak, weakref, alias ("y")));
3368 /* and to... */
3369 static int x() __attribute__ ((weakref));
3370 static int x() __attribute__ ((alias ("y")));
3371 @end smallexample
3372
3373 A weak reference is an alias that does not by itself require a
3374 definition to be given for the target symbol. If the target symbol is
3375 only referenced through weak references, then it becomes a @code{weak}
3376 undefined symbol. If it is directly referenced, however, then such
3377 strong references prevail, and a definition is required for the
3378 symbol, not necessarily in the same translation unit.
3379
3380 The effect is equivalent to moving all references to the alias to a
3381 separate translation unit, renaming the alias to the aliased symbol,
3382 declaring it as weak, compiling the two separate translation units and
3383 performing a reloadable link on them.
3384
3385 At present, a declaration to which @code{weakref} is attached can
3386 only be @code{static}.
3387
3388 @item lower
3389 @itemx upper
3390 @itemx either
3391 @cindex lower memory region on the MSP430
3392 @cindex upper memory region on the MSP430
3393 @cindex either memory region on the MSP430
3394 On the MSP430 target these attributes can be used to specify whether
3395 the function or variable should be placed into low memory, high
3396 memory, or the placement should be left to the linker to decide. The
3397 attributes are only significant if compiling for the MSP430X
3398 architecture.
3399
3400 The attributes work in conjunction with a linker script that has been
3401 augmented to specify where to place sections with a @code{.lower} and
3402 a @code{.upper} prefix. So for example as well as placing the
3403 @code{.data} section the script would also specify the placement of a
3404 @code{.lower.data} and a @code{.upper.data} section. The intention
3405 being that @code{lower} sections are placed into a small but easier to
3406 access memory region and the upper sections are placed into a larger, but
3407 slower to access region.
3408
3409 The @code{either} attribute is special. It tells the linker to place
3410 the object into the corresponding @code{lower} section if there is
3411 room for it. If there is insufficient room then the object is placed
3412 into the corresponding @code{upper} section instead. Note - the
3413 placement algorithm is not very sophisticated. It will not attempt to
3414 find an optimal packing of the @code{lower} sections. It just makes
3415 one pass over the objects and does the best that it can. Using the
3416 @option{-ffunction-sections} and @option{-fdata-sections} command line
3417 options can help the packing however, since they produce smaller,
3418 easier to pack regions.
3419
3420 @item reentrant
3421 On the MSP430 a function can be given the @code{reentant} attribute.
3422 This makes the function disable interrupts upon entry and enable
3423 interrupts upon exit. Reentrant functions cannot be @code{naked}.
3424
3425 @item critical
3426 On the MSP430 a function can be given the @code{critical} attribute.
3427 This makes the function disable interrupts upon entry and restore the
3428 previous interrupt enabled/disabled state upon exit. A function
3429 cannot have both the @code{reentrant} and @code{critical} attributes.
3430 Critical functions cannot be @code{naked}.
3431
3432 @item wakeup
3433 On the MSP430 a function can be given the @code{wakeup} attribute.
3434 Such a function must also have the @code{interrupt} attribute. When a
3435 function with the @code{wakeup} attribute exists the processor will be
3436 woken up from any low-power state in which it may be residing.
3437
3438 @end table
3439
3440 @c This is the end of the target-independent attribute table
3441
3442 @node AArch64 Function Attributes
3443 @subsection AArch64 Function Attributes
3444
3445 The following target-specific function attributes are available for the
3446 AArch64 target. For the most part, these options mirror the behavior of
3447 similar command-line options (@pxref{AArch64 Options}), but on a
3448 per-function basis.
3449
3450 @table @code
3451 @item general-regs-only
3452 @cindex @code{general-regs-only} function attribute, AArch64
3453 Indicates that no floating-point or Advanced SIMD registers should be
3454 used when generating code for this function. If the function explicitly
3455 uses floating-point code, then the compiler gives an error. This is
3456 the same behavior as that of the command-line option
3457 @option{-mgeneral-regs-only}.
3458
3459 @item fix-cortex-a53-835769
3460 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3461 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3462 applied to this function. To explicitly disable the workaround for this
3463 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3464 This corresponds to the behavior of the command line options
3465 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3466
3467 @item cmodel=
3468 @cindex @code{cmodel=} function attribute, AArch64
3469 Indicates that code should be generated for a particular code model for
3470 this function. The behavior and permissible arguments are the same as
3471 for the command line option @option{-mcmodel=}.
3472
3473 @item strict-align
3474 @cindex @code{strict-align} function attribute, AArch64
3475 Indicates that the compiler should not assume that unaligned memory references
3476 are handled by the system. The behavior is the same as for the command-line
3477 option @option{-mstrict-align}.
3478
3479 @item omit-leaf-frame-pointer
3480 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3481 Indicates that the frame pointer should be omitted for a leaf function call.
3482 To keep the frame pointer, the inverse attribute
3483 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3484 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3485 and @option{-mno-omit-leaf-frame-pointer}.
3486
3487 @item tls-dialect=
3488 @cindex @code{tls-dialect=} function attribute, AArch64
3489 Specifies the TLS dialect to use for this function. The behavior and
3490 permissible arguments are the same as for the command-line option
3491 @option{-mtls-dialect=}.
3492
3493 @item arch=
3494 @cindex @code{arch=} function attribute, AArch64
3495 Specifies the architecture version and architectural extensions to use
3496 for this function. The behavior and permissible arguments are the same as
3497 for the @option{-march=} command-line option.
3498
3499 @item tune=
3500 @cindex @code{tune=} function attribute, AArch64
3501 Specifies the core for which to tune the performance of this function.
3502 The behavior and permissible arguments are the same as for the @option{-mtune=}
3503 command-line option.
3504
3505 @item cpu=
3506 @cindex @code{cpu=} function attribute, AArch64
3507 Specifies the core for which to tune the performance of this function and also
3508 whose architectural features to use. The behavior and valid arguments are the
3509 same as for the @option{-mcpu=} command-line option.
3510
3511 @end table
3512
3513 The above target attributes can be specified as follows:
3514
3515 @smallexample
3516 __attribute__((target("@var{attr-string}")))
3517 int
3518 f (int a)
3519 @{
3520 return a + 5;
3521 @}
3522 @end smallexample
3523
3524 where @code{@var{attr-string}} is one of the attribute strings specified above.
3525
3526 Additionally, the architectural extension string may be specified on its
3527 own. This can be used to turn on and off particular architectural extensions
3528 without having to specify a particular architecture version or core. Example:
3529
3530 @smallexample
3531 __attribute__((target("+crc+nocrypto")))
3532 int
3533 foo (int a)
3534 @{
3535 return a + 5;
3536 @}
3537 @end smallexample
3538
3539 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3540 extension and disables the @code{crypto} extension for the function @code{foo}
3541 without modifying an existing @option{-march=} or @option{-mcpu} option.
3542
3543 Multiple target function attributes can be specified by separating them with
3544 a comma. For example:
3545 @smallexample
3546 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3547 int
3548 foo (int a)
3549 @{
3550 return a + 5;
3551 @}
3552 @end smallexample
3553
3554 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3555 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3556
3557 @subsubsection Inlining rules
3558 Specifying target attributes on individual functions or performing link-time
3559 optimization across translation units compiled with different target options
3560 can affect function inlining rules:
3561
3562 In particular, a caller function can inline a callee function only if the
3563 architectural features available to the callee are a subset of the features
3564 available to the caller.
3565 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3566 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3567 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3568 because the all the architectural features that function @code{bar} requires
3569 are available to function @code{foo}. Conversely, function @code{bar} cannot
3570 inline function @code{foo}.
3571
3572 Additionally inlining a function compiled with @option{-mstrict-align} into a
3573 function compiled without @code{-mstrict-align} is not allowed.
3574 However, inlining a function compiled without @option{-mstrict-align} into a
3575 function compiled with @option{-mstrict-align} is allowed.
3576
3577 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3578 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3579 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3580 architectural feature rules specified above.
3581
3582 @node ARC Function Attributes
3583 @subsection ARC Function Attributes
3584
3585 These function attributes are supported by the ARC back end:
3586
3587 @table @code
3588 @item interrupt
3589 @cindex @code{interrupt} function attribute, ARC
3590 Use this attribute to indicate
3591 that the specified function is an interrupt handler. The compiler generates
3592 function entry and exit sequences suitable for use in an interrupt handler
3593 when this attribute is present.
3594
3595 On the ARC, you must specify the kind of interrupt to be handled
3596 in a parameter to the interrupt attribute like this:
3597
3598 @smallexample
3599 void f () __attribute__ ((interrupt ("ilink1")));
3600 @end smallexample
3601
3602 Permissible values for this parameter are: @w{@code{ilink1}} and
3603 @w{@code{ilink2}}.
3604
3605 @item long_call
3606 @itemx medium_call
3607 @itemx short_call
3608 @cindex @code{long_call} function attribute, ARC
3609 @cindex @code{medium_call} function attribute, ARC
3610 @cindex @code{short_call} function attribute, ARC
3611 @cindex indirect calls, ARC
3612 These attributes specify how a particular function is called.
3613 These attributes override the
3614 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3615 command-line switches and @code{#pragma long_calls} settings.
3616
3617 For ARC, a function marked with the @code{long_call} attribute is
3618 always called using register-indirect jump-and-link instructions,
3619 thereby enabling the called function to be placed anywhere within the
3620 32-bit address space. A function marked with the @code{medium_call}
3621 attribute will always be close enough to be called with an unconditional
3622 branch-and-link instruction, which has a 25-bit offset from
3623 the call site. A function marked with the @code{short_call}
3624 attribute will always be close enough to be called with a conditional
3625 branch-and-link instruction, which has a 21-bit offset from
3626 the call site.
3627 @end table
3628
3629 @node ARM Function Attributes
3630 @subsection ARM Function Attributes
3631
3632 These function attributes are supported for ARM targets:
3633
3634 @table @code
3635 @item interrupt
3636 @cindex @code{interrupt} function attribute, ARM
3637 Use this attribute to indicate
3638 that the specified function is an interrupt handler. The compiler generates
3639 function entry and exit sequences suitable for use in an interrupt handler
3640 when this attribute is present.
3641
3642 You can specify the kind of interrupt to be handled by
3643 adding an optional parameter to the interrupt attribute like this:
3644
3645 @smallexample
3646 void f () __attribute__ ((interrupt ("IRQ")));
3647 @end smallexample
3648
3649 @noindent
3650 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3651 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3652
3653 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3654 may be called with a word-aligned stack pointer.
3655
3656 @item isr
3657 @cindex @code{isr} function attribute, ARM
3658 Use this attribute on ARM to write Interrupt Service Routines. This is an
3659 alias to the @code{interrupt} attribute above.
3660
3661 @item long_call
3662 @itemx short_call
3663 @cindex @code{long_call} function attribute, ARM
3664 @cindex @code{short_call} function attribute, ARM
3665 @cindex indirect calls, ARM
3666 These attributes specify how a particular function is called.
3667 These attributes override the
3668 @option{-mlong-calls} (@pxref{ARM Options})
3669 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3670 @code{long_call} attribute indicates that the function might be far
3671 away from the call site and require a different (more expensive)
3672 calling sequence. The @code{short_call} attribute always places
3673 the offset to the function from the call site into the @samp{BL}
3674 instruction directly.
3675
3676 @item naked
3677 @cindex @code{naked} function attribute, ARM
3678 This attribute allows the compiler to construct the
3679 requisite function declaration, while allowing the body of the
3680 function to be assembly code. The specified function will not have
3681 prologue/epilogue sequences generated by the compiler. Only basic
3682 @code{asm} statements can safely be included in naked functions
3683 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3684 basic @code{asm} and C code may appear to work, they cannot be
3685 depended upon to work reliably and are not supported.
3686
3687 @item pcs
3688 @cindex @code{pcs} function attribute, ARM
3689
3690 The @code{pcs} attribute can be used to control the calling convention
3691 used for a function on ARM. The attribute takes an argument that specifies
3692 the calling convention to use.
3693
3694 When compiling using the AAPCS ABI (or a variant of it) then valid
3695 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3696 order to use a variant other than @code{"aapcs"} then the compiler must
3697 be permitted to use the appropriate co-processor registers (i.e., the
3698 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3699 For example,
3700
3701 @smallexample
3702 /* Argument passed in r0, and result returned in r0+r1. */
3703 double f2d (float) __attribute__((pcs("aapcs")));
3704 @end smallexample
3705
3706 Variadic functions always use the @code{"aapcs"} calling convention and
3707 the compiler rejects attempts to specify an alternative.
3708
3709 @item target (@var{options})
3710 @cindex @code{target} function attribute
3711 As discussed in @ref{Common Function Attributes}, this attribute
3712 allows specification of target-specific compilation options.
3713
3714 On ARM, the following options are allowed:
3715
3716 @table @samp
3717 @item thumb
3718 @cindex @code{target("thumb")} function attribute, ARM
3719 Force code generation in the Thumb (T16/T32) ISA, depending on the
3720 architecture level.
3721
3722 @item arm
3723 @cindex @code{target("arm")} function attribute, ARM
3724 Force code generation in the ARM (A32) ISA.
3725
3726 Functions from different modes can be inlined in the caller's mode.
3727
3728 @item fpu=
3729 @cindex @code{target("fpu=")} function attribute, ARM
3730 Specifies the fpu for which to tune the performance of this function.
3731 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3732 command-line option.
3733
3734 @end table
3735
3736 @end table
3737
3738 @node AVR Function Attributes
3739 @subsection AVR Function Attributes
3740
3741 These function attributes are supported by the AVR back end:
3742
3743 @table @code
3744 @item interrupt
3745 @cindex @code{interrupt} function attribute, AVR
3746 Use this attribute to indicate
3747 that the specified function is an interrupt handler. The compiler generates
3748 function entry and exit sequences suitable for use in an interrupt handler
3749 when this attribute is present.
3750
3751 On the AVR, the hardware globally disables interrupts when an
3752 interrupt is executed. The first instruction of an interrupt handler
3753 declared with this attribute is a @code{SEI} instruction to
3754 re-enable interrupts. See also the @code{signal} function attribute
3755 that does not insert a @code{SEI} instruction. If both @code{signal} and
3756 @code{interrupt} are specified for the same function, @code{signal}
3757 is silently ignored.
3758
3759 @item naked
3760 @cindex @code{naked} function attribute, AVR
3761 This attribute allows the compiler to construct the
3762 requisite function declaration, while allowing the body of the
3763 function to be assembly code. The specified function will not have
3764 prologue/epilogue sequences generated by the compiler. Only basic
3765 @code{asm} statements can safely be included in naked functions
3766 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3767 basic @code{asm} and C code may appear to work, they cannot be
3768 depended upon to work reliably and are not supported.
3769
3770 @item OS_main
3771 @itemx OS_task
3772 @cindex @code{OS_main} function attribute, AVR
3773 @cindex @code{OS_task} function attribute, AVR
3774 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3775 do not save/restore any call-saved register in their prologue/epilogue.
3776
3777 The @code{OS_main} attribute can be used when there @emph{is
3778 guarantee} that interrupts are disabled at the time when the function
3779 is entered. This saves resources when the stack pointer has to be
3780 changed to set up a frame for local variables.
3781
3782 The @code{OS_task} attribute can be used when there is @emph{no
3783 guarantee} that interrupts are disabled at that time when the function
3784 is entered like for, e@.g@. task functions in a multi-threading operating
3785 system. In that case, changing the stack pointer register is
3786 guarded by save/clear/restore of the global interrupt enable flag.
3787
3788 The differences to the @code{naked} function attribute are:
3789 @itemize @bullet
3790 @item @code{naked} functions do not have a return instruction whereas
3791 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3792 @code{RETI} return instruction.
3793 @item @code{naked} functions do not set up a frame for local variables
3794 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3795 as needed.
3796 @end itemize
3797
3798 @item signal
3799 @cindex @code{signal} function attribute, AVR
3800 Use this attribute on the AVR to indicate that the specified
3801 function is an interrupt handler. The compiler generates function
3802 entry and exit sequences suitable for use in an interrupt handler when this
3803 attribute is present.
3804
3805 See also the @code{interrupt} function attribute.
3806
3807 The AVR hardware globally disables interrupts when an interrupt is executed.
3808 Interrupt handler functions defined with the @code{signal} attribute
3809 do not re-enable interrupts. It is save to enable interrupts in a
3810 @code{signal} handler. This ``save'' only applies to the code
3811 generated by the compiler and not to the IRQ layout of the
3812 application which is responsibility of the application.
3813
3814 If both @code{signal} and @code{interrupt} are specified for the same
3815 function, @code{signal} is silently ignored.
3816 @end table
3817
3818 @node Blackfin Function Attributes
3819 @subsection Blackfin Function Attributes
3820
3821 These function attributes are supported by the Blackfin back end:
3822
3823 @table @code
3824
3825 @item exception_handler
3826 @cindex @code{exception_handler} function attribute
3827 @cindex exception handler functions, Blackfin
3828 Use this attribute on the Blackfin to indicate that the specified function
3829 is an exception handler. The compiler generates function entry and
3830 exit sequences suitable for use in an exception handler when this
3831 attribute is present.
3832
3833 @item interrupt_handler
3834 @cindex @code{interrupt_handler} function attribute, Blackfin
3835 Use this attribute to
3836 indicate that the specified function is an interrupt handler. The compiler
3837 generates function entry and exit sequences suitable for use in an
3838 interrupt handler when this attribute is present.
3839
3840 @item kspisusp
3841 @cindex @code{kspisusp} function attribute, Blackfin
3842 @cindex User stack pointer in interrupts on the Blackfin
3843 When used together with @code{interrupt_handler}, @code{exception_handler}
3844 or @code{nmi_handler}, code is generated to load the stack pointer
3845 from the USP register in the function prologue.
3846
3847 @item l1_text
3848 @cindex @code{l1_text} function attribute, Blackfin
3849 This attribute specifies a function to be placed into L1 Instruction
3850 SRAM@. The function is put into a specific section named @code{.l1.text}.
3851 With @option{-mfdpic}, function calls with a such function as the callee
3852 or caller uses inlined PLT.
3853
3854 @item l2
3855 @cindex @code{l2} function attribute, Blackfin
3856 This attribute specifies a function to be placed into L2
3857 SRAM. The function is put into a specific section named
3858 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3859 an inlined PLT.
3860
3861 @item longcall
3862 @itemx shortcall
3863 @cindex indirect calls, Blackfin
3864 @cindex @code{longcall} function attribute, Blackfin
3865 @cindex @code{shortcall} function attribute, Blackfin
3866 The @code{longcall} attribute
3867 indicates that the function might be far away from the call site and
3868 require a different (more expensive) calling sequence. The
3869 @code{shortcall} attribute indicates that the function is always close
3870 enough for the shorter calling sequence to be used. These attributes
3871 override the @option{-mlongcall} switch.
3872
3873 @item nesting
3874 @cindex @code{nesting} function attribute, Blackfin
3875 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3876 Use this attribute together with @code{interrupt_handler},
3877 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3878 entry code should enable nested interrupts or exceptions.
3879
3880 @item nmi_handler
3881 @cindex @code{nmi_handler} function attribute, Blackfin
3882 @cindex NMI handler functions on the Blackfin processor
3883 Use this attribute on the Blackfin to indicate that the specified function
3884 is an NMI handler. The compiler generates function entry and
3885 exit sequences suitable for use in an NMI handler when this
3886 attribute is present.
3887
3888 @item saveall
3889 @cindex @code{saveall} function attribute, Blackfin
3890 @cindex save all registers on the Blackfin
3891 Use this attribute to indicate that
3892 all registers except the stack pointer should be saved in the prologue
3893 regardless of whether they are used or not.
3894 @end table
3895
3896 @node CR16 Function Attributes
3897 @subsection CR16 Function Attributes
3898
3899 These function attributes are supported by the CR16 back end:
3900
3901 @table @code
3902 @item interrupt
3903 @cindex @code{interrupt} function attribute, CR16
3904 Use this attribute to indicate
3905 that the specified function is an interrupt handler. The compiler generates
3906 function entry and exit sequences suitable for use in an interrupt handler
3907 when this attribute is present.
3908 @end table
3909
3910 @node Epiphany Function Attributes
3911 @subsection Epiphany Function Attributes
3912
3913 These function attributes are supported by the Epiphany back end:
3914
3915 @table @code
3916 @item disinterrupt
3917 @cindex @code{disinterrupt} function attribute, Epiphany
3918 This attribute causes the compiler to emit
3919 instructions to disable interrupts for the duration of the given
3920 function.
3921
3922 @item forwarder_section
3923 @cindex @code{forwarder_section} function attribute, Epiphany
3924 This attribute modifies the behavior of an interrupt handler.
3925 The interrupt handler may be in external memory which cannot be
3926 reached by a branch instruction, so generate a local memory trampoline
3927 to transfer control. The single parameter identifies the section where
3928 the trampoline is placed.
3929
3930 @item interrupt
3931 @cindex @code{interrupt} function attribute, Epiphany
3932 Use this attribute to indicate
3933 that the specified function is an interrupt handler. The compiler generates
3934 function entry and exit sequences suitable for use in an interrupt handler
3935 when this attribute is present. It may also generate
3936 a special section with code to initialize the interrupt vector table.
3937
3938 On Epiphany targets one or more optional parameters can be added like this:
3939
3940 @smallexample
3941 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3942 @end smallexample
3943
3944 Permissible values for these parameters are: @w{@code{reset}},
3945 @w{@code{software_exception}}, @w{@code{page_miss}},
3946 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3947 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3948 Multiple parameters indicate that multiple entries in the interrupt
3949 vector table should be initialized for this function, i.e.@: for each
3950 parameter @w{@var{name}}, a jump to the function is emitted in
3951 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3952 entirely, in which case no interrupt vector table entry is provided.
3953
3954 Note that interrupts are enabled inside the function
3955 unless the @code{disinterrupt} attribute is also specified.
3956
3957 The following examples are all valid uses of these attributes on
3958 Epiphany targets:
3959 @smallexample
3960 void __attribute__ ((interrupt)) universal_handler ();
3961 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3962 void __attribute__ ((interrupt ("dma0, dma1")))
3963 universal_dma_handler ();
3964 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3965 fast_timer_handler ();
3966 void __attribute__ ((interrupt ("dma0, dma1"),
3967 forwarder_section ("tramp")))
3968 external_dma_handler ();
3969 @end smallexample
3970
3971 @item long_call
3972 @itemx short_call
3973 @cindex @code{long_call} function attribute, Epiphany
3974 @cindex @code{short_call} function attribute, Epiphany
3975 @cindex indirect calls, Epiphany
3976 These attributes specify how a particular function is called.
3977 These attributes override the
3978 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3979 command-line switch and @code{#pragma long_calls} settings.
3980 @end table
3981
3982
3983 @node H8/300 Function Attributes
3984 @subsection H8/300 Function Attributes
3985
3986 These function attributes are available for H8/300 targets:
3987
3988 @table @code
3989 @item function_vector
3990 @cindex @code{function_vector} function attribute, H8/300
3991 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3992 that the specified function should be called through the function vector.
3993 Calling a function through the function vector reduces code size; however,
3994 the function vector has a limited size (maximum 128 entries on the H8/300
3995 and 64 entries on the H8/300H and H8S)
3996 and shares space with the interrupt vector.
3997
3998 @item interrupt_handler
3999 @cindex @code{interrupt_handler} function attribute, H8/300
4000 Use this attribute on the H8/300, H8/300H, and H8S to
4001 indicate that the specified function is an interrupt handler. The compiler
4002 generates function entry and exit sequences suitable for use in an
4003 interrupt handler when this attribute is present.
4004
4005 @item saveall
4006 @cindex @code{saveall} function attribute, H8/300
4007 @cindex save all registers on the H8/300, H8/300H, and H8S
4008 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4009 all registers except the stack pointer should be saved in the prologue
4010 regardless of whether they are used or not.
4011 @end table
4012
4013 @node IA-64 Function Attributes
4014 @subsection IA-64 Function Attributes
4015
4016 These function attributes are supported on IA-64 targets:
4017
4018 @table @code
4019 @item syscall_linkage
4020 @cindex @code{syscall_linkage} function attribute, IA-64
4021 This attribute is used to modify the IA-64 calling convention by marking
4022 all input registers as live at all function exits. This makes it possible
4023 to restart a system call after an interrupt without having to save/restore
4024 the input registers. This also prevents kernel data from leaking into
4025 application code.
4026
4027 @item version_id
4028 @cindex @code{version_id} function attribute, IA-64
4029 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4030 symbol to contain a version string, thus allowing for function level
4031 versioning. HP-UX system header files may use function level versioning
4032 for some system calls.
4033
4034 @smallexample
4035 extern int foo () __attribute__((version_id ("20040821")));
4036 @end smallexample
4037
4038 @noindent
4039 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4040 @end table
4041
4042 @node M32C Function Attributes
4043 @subsection M32C Function Attributes
4044
4045 These function attributes are supported by the M32C back end:
4046
4047 @table @code
4048 @item bank_switch
4049 @cindex @code{bank_switch} function attribute, M32C
4050 When added to an interrupt handler with the M32C port, causes the
4051 prologue and epilogue to use bank switching to preserve the registers
4052 rather than saving them on the stack.
4053
4054 @item fast_interrupt
4055 @cindex @code{fast_interrupt} function attribute, M32C
4056 Use this attribute on the M32C port to indicate that the specified
4057 function is a fast interrupt handler. This is just like the
4058 @code{interrupt} attribute, except that @code{freit} is used to return
4059 instead of @code{reit}.
4060
4061 @item function_vector
4062 @cindex @code{function_vector} function attribute, M16C/M32C
4063 On M16C/M32C targets, the @code{function_vector} attribute declares a
4064 special page subroutine call function. Use of this attribute reduces
4065 the code size by 2 bytes for each call generated to the
4066 subroutine. The argument to the attribute is the vector number entry
4067 from the special page vector table which contains the 16 low-order
4068 bits of the subroutine's entry address. Each vector table has special
4069 page number (18 to 255) that is used in @code{jsrs} instructions.
4070 Jump addresses of the routines are generated by adding 0x0F0000 (in
4071 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4072 2-byte addresses set in the vector table. Therefore you need to ensure
4073 that all the special page vector routines should get mapped within the
4074 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4075 (for M32C).
4076
4077 In the following example 2 bytes are saved for each call to
4078 function @code{foo}.
4079
4080 @smallexample
4081 void foo (void) __attribute__((function_vector(0x18)));
4082 void foo (void)
4083 @{
4084 @}
4085
4086 void bar (void)
4087 @{
4088 foo();
4089 @}
4090 @end smallexample
4091
4092 If functions are defined in one file and are called in another file,
4093 then be sure to write this declaration in both files.
4094
4095 This attribute is ignored for R8C target.
4096
4097 @item interrupt
4098 @cindex @code{interrupt} function attribute, M32C
4099 Use this attribute to indicate
4100 that the specified function is an interrupt handler. The compiler generates
4101 function entry and exit sequences suitable for use in an interrupt handler
4102 when this attribute is present.
4103 @end table
4104
4105 @node M32R/D Function Attributes
4106 @subsection M32R/D Function Attributes
4107
4108 These function attributes are supported by the M32R/D back end:
4109
4110 @table @code
4111 @item interrupt
4112 @cindex @code{interrupt} function attribute, M32R/D
4113 Use this attribute to indicate
4114 that the specified function is an interrupt handler. The compiler generates
4115 function entry and exit sequences suitable for use in an interrupt handler
4116 when this attribute is present.
4117
4118 @item model (@var{model-name})
4119 @cindex @code{model} function attribute, M32R/D
4120 @cindex function addressability on the M32R/D
4121
4122 On the M32R/D, use this attribute to set the addressability of an
4123 object, and of the code generated for a function. The identifier
4124 @var{model-name} is one of @code{small}, @code{medium}, or
4125 @code{large}, representing each of the code models.
4126
4127 Small model objects live in the lower 16MB of memory (so that their
4128 addresses can be loaded with the @code{ld24} instruction), and are
4129 callable with the @code{bl} instruction.
4130
4131 Medium model objects may live anywhere in the 32-bit address space (the
4132 compiler generates @code{seth/add3} instructions to load their addresses),
4133 and are callable with the @code{bl} instruction.
4134
4135 Large model objects may live anywhere in the 32-bit address space (the
4136 compiler generates @code{seth/add3} instructions to load their addresses),
4137 and may not be reachable with the @code{bl} instruction (the compiler
4138 generates the much slower @code{seth/add3/jl} instruction sequence).
4139 @end table
4140
4141 @node m68k Function Attributes
4142 @subsection m68k Function Attributes
4143
4144 These function attributes are supported by the m68k back end:
4145
4146 @table @code
4147 @item interrupt
4148 @itemx interrupt_handler
4149 @cindex @code{interrupt} function attribute, m68k
4150 @cindex @code{interrupt_handler} function attribute, m68k
4151 Use this attribute to
4152 indicate that the specified function is an interrupt handler. The compiler
4153 generates function entry and exit sequences suitable for use in an
4154 interrupt handler when this attribute is present. Either name may be used.
4155
4156 @item interrupt_thread
4157 @cindex @code{interrupt_thread} function attribute, fido
4158 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4159 that the specified function is an interrupt handler that is designed
4160 to run as a thread. The compiler omits generate prologue/epilogue
4161 sequences and replaces the return instruction with a @code{sleep}
4162 instruction. This attribute is available only on fido.
4163 @end table
4164
4165 @node MCORE Function Attributes
4166 @subsection MCORE Function Attributes
4167
4168 These function attributes are supported by the MCORE back end:
4169
4170 @table @code
4171 @item naked
4172 @cindex @code{naked} function attribute, MCORE
4173 This attribute allows the compiler to construct the
4174 requisite function declaration, while allowing the body of the
4175 function to be assembly code. The specified function will not have
4176 prologue/epilogue sequences generated by the compiler. Only basic
4177 @code{asm} statements can safely be included in naked functions
4178 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4179 basic @code{asm} and C code may appear to work, they cannot be
4180 depended upon to work reliably and are not supported.
4181 @end table
4182
4183 @node MeP Function Attributes
4184 @subsection MeP Function Attributes
4185
4186 These function attributes are supported by the MeP back end:
4187
4188 @table @code
4189 @item disinterrupt
4190 @cindex @code{disinterrupt} function attribute, MeP
4191 On MeP targets, this attribute causes the compiler to emit
4192 instructions to disable interrupts for the duration of the given
4193 function.
4194
4195 @item interrupt
4196 @cindex @code{interrupt} function attribute, MeP
4197 Use this attribute to indicate
4198 that the specified function is an interrupt handler. The compiler generates
4199 function entry and exit sequences suitable for use in an interrupt handler
4200 when this attribute is present.
4201
4202 @item near
4203 @cindex @code{near} function attribute, MeP
4204 This attribute causes the compiler to assume the called
4205 function is close enough to use the normal calling convention,
4206 overriding the @option{-mtf} command-line option.
4207
4208 @item far
4209 @cindex @code{far} function attribute, MeP
4210 On MeP targets this causes the compiler to use a calling convention
4211 that assumes the called function is too far away for the built-in
4212 addressing modes.
4213
4214 @item vliw
4215 @cindex @code{vliw} function attribute, MeP
4216 The @code{vliw} attribute tells the compiler to emit
4217 instructions in VLIW mode instead of core mode. Note that this
4218 attribute is not allowed unless a VLIW coprocessor has been configured
4219 and enabled through command-line options.
4220 @end table
4221
4222 @node MicroBlaze Function Attributes
4223 @subsection MicroBlaze Function Attributes
4224
4225 These function attributes are supported on MicroBlaze targets:
4226
4227 @table @code
4228 @item save_volatiles
4229 @cindex @code{save_volatiles} function attribute, MicroBlaze
4230 Use this attribute to indicate that the function is
4231 an interrupt handler. All volatile registers (in addition to non-volatile
4232 registers) are saved in the function prologue. If the function is a leaf
4233 function, only volatiles used by the function are saved. A normal function
4234 return is generated instead of a return from interrupt.
4235
4236 @item break_handler
4237 @cindex @code{break_handler} function attribute, MicroBlaze
4238 @cindex break handler functions
4239 Use this attribute to indicate that
4240 the specified function is a break handler. The compiler generates function
4241 entry and exit sequences suitable for use in an break handler when this
4242 attribute is present. The return from @code{break_handler} is done through
4243 the @code{rtbd} instead of @code{rtsd}.
4244
4245 @smallexample
4246 void f () __attribute__ ((break_handler));
4247 @end smallexample
4248 @end table
4249
4250 @node Microsoft Windows Function Attributes
4251 @subsection Microsoft Windows Function Attributes
4252
4253 The following attributes are available on Microsoft Windows and Symbian OS
4254 targets.
4255
4256 @table @code
4257 @item dllexport
4258 @cindex @code{dllexport} function attribute
4259 @cindex @code{__declspec(dllexport)}
4260 On Microsoft Windows targets and Symbian OS targets the
4261 @code{dllexport} attribute causes the compiler to provide a global
4262 pointer to a pointer in a DLL, so that it can be referenced with the
4263 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4264 name is formed by combining @code{_imp__} and the function or variable
4265 name.
4266
4267 You can use @code{__declspec(dllexport)} as a synonym for
4268 @code{__attribute__ ((dllexport))} for compatibility with other
4269 compilers.
4270
4271 On systems that support the @code{visibility} attribute, this
4272 attribute also implies ``default'' visibility. It is an error to
4273 explicitly specify any other visibility.
4274
4275 GCC's default behavior is to emit all inline functions with the
4276 @code{dllexport} attribute. Since this can cause object file-size bloat,
4277 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4278 ignore the attribute for inlined functions unless the
4279 @option{-fkeep-inline-functions} flag is used instead.
4280
4281 The attribute is ignored for undefined symbols.
4282
4283 When applied to C++ classes, the attribute marks defined non-inlined
4284 member functions and static data members as exports. Static consts
4285 initialized in-class are not marked unless they are also defined
4286 out-of-class.
4287
4288 For Microsoft Windows targets there are alternative methods for
4289 including the symbol in the DLL's export table such as using a
4290 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4291 the @option{--export-all} linker flag.
4292
4293 @item dllimport
4294 @cindex @code{dllimport} function attribute
4295 @cindex @code{__declspec(dllimport)}
4296 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4297 attribute causes the compiler to reference a function or variable via
4298 a global pointer to a pointer that is set up by the DLL exporting the
4299 symbol. The attribute implies @code{extern}. On Microsoft Windows
4300 targets, the pointer name is formed by combining @code{_imp__} and the
4301 function or variable name.
4302
4303 You can use @code{__declspec(dllimport)} as a synonym for
4304 @code{__attribute__ ((dllimport))} for compatibility with other
4305 compilers.
4306
4307 On systems that support the @code{visibility} attribute, this
4308 attribute also implies ``default'' visibility. It is an error to
4309 explicitly specify any other visibility.
4310
4311 Currently, the attribute is ignored for inlined functions. If the
4312 attribute is applied to a symbol @emph{definition}, an error is reported.
4313 If a symbol previously declared @code{dllimport} is later defined, the
4314 attribute is ignored in subsequent references, and a warning is emitted.
4315 The attribute is also overridden by a subsequent declaration as
4316 @code{dllexport}.
4317
4318 When applied to C++ classes, the attribute marks non-inlined
4319 member functions and static data members as imports. However, the
4320 attribute is ignored for virtual methods to allow creation of vtables
4321 using thunks.
4322
4323 On the SH Symbian OS target the @code{dllimport} attribute also has
4324 another affect---it can cause the vtable and run-time type information
4325 for a class to be exported. This happens when the class has a
4326 dllimported constructor or a non-inline, non-pure virtual function
4327 and, for either of those two conditions, the class also has an inline
4328 constructor or destructor and has a key function that is defined in
4329 the current translation unit.
4330
4331 For Microsoft Windows targets the use of the @code{dllimport}
4332 attribute on functions is not necessary, but provides a small
4333 performance benefit by eliminating a thunk in the DLL@. The use of the
4334 @code{dllimport} attribute on imported variables can be avoided by passing the
4335 @option{--enable-auto-import} switch to the GNU linker. As with
4336 functions, using the attribute for a variable eliminates a thunk in
4337 the DLL@.
4338
4339 One drawback to using this attribute is that a pointer to a
4340 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4341 address. However, a pointer to a @emph{function} with the
4342 @code{dllimport} attribute can be used as a constant initializer; in
4343 this case, the address of a stub function in the import lib is
4344 referenced. On Microsoft Windows targets, the attribute can be disabled
4345 for functions by setting the @option{-mnop-fun-dllimport} flag.
4346 @end table
4347
4348 @node MIPS Function Attributes
4349 @subsection MIPS Function Attributes
4350
4351 These function attributes are supported by the MIPS back end:
4352
4353 @table @code
4354 @item interrupt
4355 @cindex @code{interrupt} function attribute, MIPS
4356 Use this attribute to indicate that the specified function is an interrupt
4357 handler. The compiler generates function entry and exit sequences suitable
4358 for use in an interrupt handler when this attribute is present.
4359 An optional argument is supported for the interrupt attribute which allows
4360 the interrupt mode to be described. By default GCC assumes the external
4361 interrupt controller (EIC) mode is in use, this can be explicitly set using
4362 @code{eic}. When interrupts are non-masked then the requested Interrupt
4363 Priority Level (IPL) is copied to the current IPL which has the effect of only
4364 enabling higher priority interrupts. To use vectored interrupt mode use
4365 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4366 the behaviour of the non-masked interrupt support and GCC will arrange to mask
4367 all interrupts from sw0 up to and including the specified interrupt vector.
4368
4369 You can use the following attributes to modify the behavior
4370 of an interrupt handler:
4371 @table @code
4372 @item use_shadow_register_set
4373 @cindex @code{use_shadow_register_set} function attribute, MIPS
4374 Assume that the handler uses a shadow register set, instead of
4375 the main general-purpose registers. An optional argument @code{intstack} is
4376 supported to indicate that the shadow register set contains a valid stack
4377 pointer.
4378
4379 @item keep_interrupts_masked
4380 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4381 Keep interrupts masked for the whole function. Without this attribute,
4382 GCC tries to reenable interrupts for as much of the function as it can.
4383
4384 @item use_debug_exception_return
4385 @cindex @code{use_debug_exception_return} function attribute, MIPS
4386 Return using the @code{deret} instruction. Interrupt handlers that don't
4387 have this attribute return using @code{eret} instead.
4388 @end table
4389
4390 You can use any combination of these attributes, as shown below:
4391 @smallexample
4392 void __attribute__ ((interrupt)) v0 ();
4393 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4394 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4395 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4396 void __attribute__ ((interrupt, use_shadow_register_set,
4397 keep_interrupts_masked)) v4 ();
4398 void __attribute__ ((interrupt, use_shadow_register_set,
4399 use_debug_exception_return)) v5 ();
4400 void __attribute__ ((interrupt, keep_interrupts_masked,
4401 use_debug_exception_return)) v6 ();
4402 void __attribute__ ((interrupt, use_shadow_register_set,
4403 keep_interrupts_masked,
4404 use_debug_exception_return)) v7 ();
4405 void __attribute__ ((interrupt("eic"))) v8 ();
4406 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4407 @end smallexample
4408
4409 @item long_call
4410 @itemx near
4411 @itemx far
4412 @cindex indirect calls, MIPS
4413 @cindex @code{long_call} function attribute, MIPS
4414 @cindex @code{near} function attribute, MIPS
4415 @cindex @code{far} function attribute, MIPS
4416 These attributes specify how a particular function is called on MIPS@.
4417 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4418 command-line switch. The @code{long_call} and @code{far} attributes are
4419 synonyms, and cause the compiler to always call
4420 the function by first loading its address into a register, and then using
4421 the contents of that register. The @code{near} attribute has the opposite
4422 effect; it specifies that non-PIC calls should be made using the more
4423 efficient @code{jal} instruction.
4424
4425 @item mips16
4426 @itemx nomips16
4427 @cindex @code{mips16} function attribute, MIPS
4428 @cindex @code{nomips16} function attribute, MIPS
4429
4430 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4431 function attributes to locally select or turn off MIPS16 code generation.
4432 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4433 while MIPS16 code generation is disabled for functions with the
4434 @code{nomips16} attribute. These attributes override the
4435 @option{-mips16} and @option{-mno-mips16} options on the command line
4436 (@pxref{MIPS Options}).
4437
4438 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4439 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4440 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4441 may interact badly with some GCC extensions such as @code{__builtin_apply}
4442 (@pxref{Constructing Calls}).
4443
4444 @item micromips, MIPS
4445 @itemx nomicromips, MIPS
4446 @cindex @code{micromips} function attribute
4447 @cindex @code{nomicromips} function attribute
4448
4449 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4450 function attributes to locally select or turn off microMIPS code generation.
4451 A function with the @code{micromips} attribute is emitted as microMIPS code,
4452 while microMIPS code generation is disabled for functions with the
4453 @code{nomicromips} attribute. These attributes override the
4454 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4455 (@pxref{MIPS Options}).
4456
4457 When compiling files containing mixed microMIPS and non-microMIPS code, the
4458 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4459 command line,
4460 not that within individual functions. Mixed microMIPS and non-microMIPS code
4461 may interact badly with some GCC extensions such as @code{__builtin_apply}
4462 (@pxref{Constructing Calls}).
4463
4464 @item nocompression
4465 @cindex @code{nocompression} function attribute, MIPS
4466 On MIPS targets, you can use the @code{nocompression} function attribute
4467 to locally turn off MIPS16 and microMIPS code generation. This attribute
4468 overrides the @option{-mips16} and @option{-mmicromips} options on the
4469 command line (@pxref{MIPS Options}).
4470 @end table
4471
4472 @node MSP430 Function Attributes
4473 @subsection MSP430 Function Attributes
4474
4475 These function attributes are supported by the MSP430 back end:
4476
4477 @table @code
4478 @item critical
4479 @cindex @code{critical} function attribute, MSP430
4480 Critical functions disable interrupts upon entry and restore the
4481 previous interrupt state upon exit. Critical functions cannot also
4482 have the @code{naked} or @code{reentrant} attributes. They can have
4483 the @code{interrupt} attribute.
4484
4485 @item interrupt
4486 @cindex @code{interrupt} function attribute, MSP430
4487 Use this attribute to indicate
4488 that the specified function is an interrupt handler. The compiler generates
4489 function entry and exit sequences suitable for use in an interrupt handler
4490 when this attribute is present.
4491
4492 You can provide an argument to the interrupt
4493 attribute which specifies a name or number. If the argument is a
4494 number it indicates the slot in the interrupt vector table (0 - 31) to
4495 which this handler should be assigned. If the argument is a name it
4496 is treated as a symbolic name for the vector slot. These names should
4497 match up with appropriate entries in the linker script. By default
4498 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4499 @code{reset} for vector 31 are recognized.
4500
4501 @item naked
4502 @cindex @code{naked} function attribute, MSP430
4503 This attribute allows the compiler to construct the
4504 requisite function declaration, while allowing the body of the
4505 function to be assembly code. The specified function will not have
4506 prologue/epilogue sequences generated by the compiler. Only basic
4507 @code{asm} statements can safely be included in naked functions
4508 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4509 basic @code{asm} and C code may appear to work, they cannot be
4510 depended upon to work reliably and are not supported.
4511
4512 @item reentrant
4513 @cindex @code{reentrant} function attribute, MSP430
4514 Reentrant functions disable interrupts upon entry and enable them
4515 upon exit. Reentrant functions cannot also have the @code{naked}
4516 or @code{critical} attributes. They can have the @code{interrupt}
4517 attribute.
4518
4519 @item wakeup
4520 @cindex @code{wakeup} function attribute, MSP430
4521 This attribute only applies to interrupt functions. It is silently
4522 ignored if applied to a non-interrupt function. A wakeup interrupt
4523 function will rouse the processor from any low-power state that it
4524 might be in when the function exits.
4525 @end table
4526
4527 @node NDS32 Function Attributes
4528 @subsection NDS32 Function Attributes
4529
4530 These function attributes are supported by the NDS32 back end:
4531
4532 @table @code
4533 @item exception
4534 @cindex @code{exception} function attribute
4535 @cindex exception handler functions, NDS32
4536 Use this attribute on the NDS32 target to indicate that the specified function
4537 is an exception handler. The compiler will generate corresponding sections
4538 for use in an exception handler.
4539
4540 @item interrupt
4541 @cindex @code{interrupt} function attribute, NDS32
4542 On NDS32 target, this attribute indicates that the specified function
4543 is an interrupt handler. The compiler generates corresponding sections
4544 for use in an interrupt handler. You can use the following attributes
4545 to modify the behavior:
4546 @table @code
4547 @item nested
4548 @cindex @code{nested} function attribute, NDS32
4549 This interrupt service routine is interruptible.
4550 @item not_nested
4551 @cindex @code{not_nested} function attribute, NDS32
4552 This interrupt service routine is not interruptible.
4553 @item nested_ready
4554 @cindex @code{nested_ready} function attribute, NDS32
4555 This interrupt service routine is interruptible after @code{PSW.GIE}
4556 (global interrupt enable) is set. This allows interrupt service routine to
4557 finish some short critical code before enabling interrupts.
4558 @item save_all
4559 @cindex @code{save_all} function attribute, NDS32
4560 The system will help save all registers into stack before entering
4561 interrupt handler.
4562 @item partial_save
4563 @cindex @code{partial_save} function attribute, NDS32
4564 The system will help save caller registers into stack before entering
4565 interrupt handler.
4566 @end table
4567
4568 @item naked
4569 @cindex @code{naked} function attribute, NDS32
4570 This attribute allows the compiler to construct the
4571 requisite function declaration, while allowing the body of the
4572 function to be assembly code. The specified function will not have
4573 prologue/epilogue sequences generated by the compiler. Only basic
4574 @code{asm} statements can safely be included in naked functions
4575 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4576 basic @code{asm} and C code may appear to work, they cannot be
4577 depended upon to work reliably and are not supported.
4578
4579 @item reset
4580 @cindex @code{reset} function attribute, NDS32
4581 @cindex reset handler functions
4582 Use this attribute on the NDS32 target to indicate that the specified function
4583 is a reset handler. The compiler will generate corresponding sections
4584 for use in a reset handler. You can use the following attributes
4585 to provide extra exception handling:
4586 @table @code
4587 @item nmi
4588 @cindex @code{nmi} function attribute, NDS32
4589 Provide a user-defined function to handle NMI exception.
4590 @item warm
4591 @cindex @code{warm} function attribute, NDS32
4592 Provide a user-defined function to handle warm reset exception.
4593 @end table
4594 @end table
4595
4596 @node Nios II Function Attributes
4597 @subsection Nios II Function Attributes
4598
4599 These function attributes are supported by the Nios II back end:
4600
4601 @table @code
4602 @item target (@var{options})
4603 @cindex @code{target} function attribute
4604 As discussed in @ref{Common Function Attributes}, this attribute
4605 allows specification of target-specific compilation options.
4606
4607 When compiling for Nios II, the following options are allowed:
4608
4609 @table @samp
4610 @item custom-@var{insn}=@var{N}
4611 @itemx no-custom-@var{insn}
4612 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4613 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4614 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4615 custom instruction with encoding @var{N} when generating code that uses
4616 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4617 the custom instruction @var{insn}.
4618 These target attributes correspond to the
4619 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4620 command-line options, and support the same set of @var{insn} keywords.
4621 @xref{Nios II Options}, for more information.
4622
4623 @item custom-fpu-cfg=@var{name}
4624 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4625 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4626 command-line option, to select a predefined set of custom instructions
4627 named @var{name}.
4628 @xref{Nios II Options}, for more information.
4629 @end table
4630 @end table
4631
4632 @node PowerPC Function Attributes
4633 @subsection PowerPC Function Attributes
4634
4635 These function attributes are supported by the PowerPC back end:
4636
4637 @table @code
4638 @item longcall
4639 @itemx shortcall
4640 @cindex indirect calls, PowerPC
4641 @cindex @code{longcall} function attribute, PowerPC
4642 @cindex @code{shortcall} function attribute, PowerPC
4643 The @code{longcall} attribute
4644 indicates that the function might be far away from the call site and
4645 require a different (more expensive) calling sequence. The
4646 @code{shortcall} attribute indicates that the function is always close
4647 enough for the shorter calling sequence to be used. These attributes
4648 override both the @option{-mlongcall} switch and
4649 the @code{#pragma longcall} setting.
4650
4651 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4652 calls are necessary.
4653
4654 @item target (@var{options})
4655 @cindex @code{target} function attribute
4656 As discussed in @ref{Common Function Attributes}, this attribute
4657 allows specification of target-specific compilation options.
4658
4659 On the PowerPC, the following options are allowed:
4660
4661 @table @samp
4662 @item altivec
4663 @itemx no-altivec
4664 @cindex @code{target("altivec")} function attribute, PowerPC
4665 Generate code that uses (does not use) AltiVec instructions. In
4666 32-bit code, you cannot enable AltiVec instructions unless
4667 @option{-mabi=altivec} is used on the command line.
4668
4669 @item cmpb
4670 @itemx no-cmpb
4671 @cindex @code{target("cmpb")} function attribute, PowerPC
4672 Generate code that uses (does not use) the compare bytes instruction
4673 implemented on the POWER6 processor and other processors that support
4674 the PowerPC V2.05 architecture.
4675
4676 @item dlmzb
4677 @itemx no-dlmzb
4678 @cindex @code{target("dlmzb")} function attribute, PowerPC
4679 Generate code that uses (does not use) the string-search @samp{dlmzb}
4680 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4681 generated by default when targeting those processors.
4682
4683 @item fprnd
4684 @itemx no-fprnd
4685 @cindex @code{target("fprnd")} function attribute, PowerPC
4686 Generate code that uses (does not use) the FP round to integer
4687 instructions implemented on the POWER5+ processor and other processors
4688 that support the PowerPC V2.03 architecture.
4689
4690 @item hard-dfp
4691 @itemx no-hard-dfp
4692 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4693 Generate code that uses (does not use) the decimal floating-point
4694 instructions implemented on some POWER processors.
4695
4696 @item isel
4697 @itemx no-isel
4698 @cindex @code{target("isel")} function attribute, PowerPC
4699 Generate code that uses (does not use) ISEL instruction.
4700
4701 @item mfcrf
4702 @itemx no-mfcrf
4703 @cindex @code{target("mfcrf")} function attribute, PowerPC
4704 Generate code that uses (does not use) the move from condition
4705 register field instruction implemented on the POWER4 processor and
4706 other processors that support the PowerPC V2.01 architecture.
4707
4708 @item mfpgpr
4709 @itemx no-mfpgpr
4710 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4711 Generate code that uses (does not use) the FP move to/from general
4712 purpose register instructions implemented on the POWER6X processor and
4713 other processors that support the extended PowerPC V2.05 architecture.
4714
4715 @item mulhw
4716 @itemx no-mulhw
4717 @cindex @code{target("mulhw")} function attribute, PowerPC
4718 Generate code that uses (does not use) the half-word multiply and
4719 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4720 These instructions are generated by default when targeting those
4721 processors.
4722
4723 @item multiple
4724 @itemx no-multiple
4725 @cindex @code{target("multiple")} function attribute, PowerPC
4726 Generate code that uses (does not use) the load multiple word
4727 instructions and the store multiple word instructions.
4728
4729 @item update
4730 @itemx no-update
4731 @cindex @code{target("update")} function attribute, PowerPC
4732 Generate code that uses (does not use) the load or store instructions
4733 that update the base register to the address of the calculated memory
4734 location.
4735
4736 @item popcntb
4737 @itemx no-popcntb
4738 @cindex @code{target("popcntb")} function attribute, PowerPC
4739 Generate code that uses (does not use) the popcount and double-precision
4740 FP reciprocal estimate instruction implemented on the POWER5
4741 processor and other processors that support the PowerPC V2.02
4742 architecture.
4743
4744 @item popcntd
4745 @itemx no-popcntd
4746 @cindex @code{target("popcntd")} function attribute, PowerPC
4747 Generate code that uses (does not use) the popcount instruction
4748 implemented on the POWER7 processor and other processors that support
4749 the PowerPC V2.06 architecture.
4750
4751 @item powerpc-gfxopt
4752 @itemx no-powerpc-gfxopt
4753 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4754 Generate code that uses (does not use) the optional PowerPC
4755 architecture instructions in the Graphics group, including
4756 floating-point select.
4757
4758 @item powerpc-gpopt
4759 @itemx no-powerpc-gpopt
4760 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4761 Generate code that uses (does not use) the optional PowerPC
4762 architecture instructions in the General Purpose group, including
4763 floating-point square root.
4764
4765 @item recip-precision
4766 @itemx no-recip-precision
4767 @cindex @code{target("recip-precision")} function attribute, PowerPC
4768 Assume (do not assume) that the reciprocal estimate instructions
4769 provide higher-precision estimates than is mandated by the PowerPC
4770 ABI.
4771
4772 @item string
4773 @itemx no-string
4774 @cindex @code{target("string")} function attribute, PowerPC
4775 Generate code that uses (does not use) the load string instructions
4776 and the store string word instructions to save multiple registers and
4777 do small block moves.
4778
4779 @item vsx
4780 @itemx no-vsx
4781 @cindex @code{target("vsx")} function attribute, PowerPC
4782 Generate code that uses (does not use) vector/scalar (VSX)
4783 instructions, and also enable the use of built-in functions that allow
4784 more direct access to the VSX instruction set. In 32-bit code, you
4785 cannot enable VSX or AltiVec instructions unless
4786 @option{-mabi=altivec} is used on the command line.
4787
4788 @item friz
4789 @itemx no-friz
4790 @cindex @code{target("friz")} function attribute, PowerPC
4791 Generate (do not generate) the @code{friz} instruction when the
4792 @option{-funsafe-math-optimizations} option is used to optimize
4793 rounding a floating-point value to 64-bit integer and back to floating
4794 point. The @code{friz} instruction does not return the same value if
4795 the floating-point number is too large to fit in an integer.
4796
4797 @item avoid-indexed-addresses
4798 @itemx no-avoid-indexed-addresses
4799 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4800 Generate code that tries to avoid (not avoid) the use of indexed load
4801 or store instructions.
4802
4803 @item paired
4804 @itemx no-paired
4805 @cindex @code{target("paired")} function attribute, PowerPC
4806 Generate code that uses (does not use) the generation of PAIRED simd
4807 instructions.
4808
4809 @item longcall
4810 @itemx no-longcall
4811 @cindex @code{target("longcall")} function attribute, PowerPC
4812 Generate code that assumes (does not assume) that all calls are far
4813 away so that a longer more expensive calling sequence is required.
4814
4815 @item cpu=@var{CPU}
4816 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4817 Specify the architecture to generate code for when compiling the
4818 function. If you select the @code{target("cpu=power7")} attribute when
4819 generating 32-bit code, VSX and AltiVec instructions are not generated
4820 unless you use the @option{-mabi=altivec} option on the command line.
4821
4822 @item tune=@var{TUNE}
4823 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4824 Specify the architecture to tune for when compiling the function. If
4825 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4826 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4827 compilation tunes for the @var{CPU} architecture, and not the
4828 default tuning specified on the command line.
4829 @end table
4830
4831 On the PowerPC, the inliner does not inline a
4832 function that has different target options than the caller, unless the
4833 callee has a subset of the target options of the caller.
4834 @end table
4835
4836 @node RL78 Function Attributes
4837 @subsection RL78 Function Attributes
4838
4839 These function attributes are supported by the RL78 back end:
4840
4841 @table @code
4842 @item interrupt
4843 @itemx brk_interrupt
4844 @cindex @code{interrupt} function attribute, RL78
4845 @cindex @code{brk_interrupt} function attribute, RL78
4846 These attributes indicate
4847 that the specified function is an interrupt handler. The compiler generates
4848 function entry and exit sequences suitable for use in an interrupt handler
4849 when this attribute is present.
4850
4851 Use @code{brk_interrupt} instead of @code{interrupt} for
4852 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4853 that must end with @code{RETB} instead of @code{RETI}).
4854
4855 @item naked
4856 @cindex @code{naked} function attribute, RL78
4857 This attribute allows the compiler to construct the
4858 requisite function declaration, while allowing the body of the
4859 function to be assembly code. The specified function will not have
4860 prologue/epilogue sequences generated by the compiler. Only basic
4861 @code{asm} statements can safely be included in naked functions
4862 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4863 basic @code{asm} and C code may appear to work, they cannot be
4864 depended upon to work reliably and are not supported.
4865 @end table
4866
4867 @node RX Function Attributes
4868 @subsection RX Function Attributes
4869
4870 These function attributes are supported by the RX back end:
4871
4872 @table @code
4873 @item fast_interrupt
4874 @cindex @code{fast_interrupt} function attribute, RX
4875 Use this attribute on the RX port to indicate that the specified
4876 function is a fast interrupt handler. This is just like the
4877 @code{interrupt} attribute, except that @code{freit} is used to return
4878 instead of @code{reit}.
4879
4880 @item interrupt
4881 @cindex @code{interrupt} function attribute, RX
4882 Use this attribute to indicate
4883 that the specified function is an interrupt handler. The compiler generates
4884 function entry and exit sequences suitable for use in an interrupt handler
4885 when this attribute is present.
4886
4887 On RX targets, you may specify one or more vector numbers as arguments
4888 to the attribute, as well as naming an alternate table name.
4889 Parameters are handled sequentially, so one handler can be assigned to
4890 multiple entries in multiple tables. One may also pass the magic
4891 string @code{"$default"} which causes the function to be used for any
4892 unfilled slots in the current table.
4893
4894 This example shows a simple assignment of a function to one vector in
4895 the default table (note that preprocessor macros may be used for
4896 chip-specific symbolic vector names):
4897 @smallexample
4898 void __attribute__ ((interrupt (5))) txd1_handler ();
4899 @end smallexample
4900
4901 This example assigns a function to two slots in the default table
4902 (using preprocessor macros defined elsewhere) and makes it the default
4903 for the @code{dct} table:
4904 @smallexample
4905 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4906 txd1_handler ();
4907 @end smallexample
4908
4909 @item naked
4910 @cindex @code{naked} function attribute, RX
4911 This attribute allows the compiler to construct the
4912 requisite function declaration, while allowing the body of the
4913 function to be assembly code. The specified function will not have
4914 prologue/epilogue sequences generated by the compiler. Only basic
4915 @code{asm} statements can safely be included in naked functions
4916 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4917 basic @code{asm} and C code may appear to work, they cannot be
4918 depended upon to work reliably and are not supported.
4919
4920 @item vector
4921 @cindex @code{vector} function attribute, RX
4922 This RX attribute is similar to the @code{interrupt} attribute, including its
4923 parameters, but does not make the function an interrupt-handler type
4924 function (i.e. it retains the normal C function calling ABI). See the
4925 @code{interrupt} attribute for a description of its arguments.
4926 @end table
4927
4928 @node S/390 Function Attributes
4929 @subsection S/390 Function Attributes
4930
4931 These function attributes are supported on the S/390:
4932
4933 @table @code
4934 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4935 @cindex @code{hotpatch} function attribute, S/390
4936
4937 On S/390 System z targets, you can use this function attribute to
4938 make GCC generate a ``hot-patching'' function prologue. If the
4939 @option{-mhotpatch=} command-line option is used at the same time,
4940 the @code{hotpatch} attribute takes precedence. The first of the
4941 two arguments specifies the number of halfwords to be added before
4942 the function label. A second argument can be used to specify the
4943 number of halfwords to be added after the function label. For
4944 both arguments the maximum allowed value is 1000000.
4945
4946 If both arguments are zero, hotpatching is disabled.
4947 @end table
4948
4949 @node SH Function Attributes
4950 @subsection SH Function Attributes
4951
4952 These function attributes are supported on the SH family of processors:
4953
4954 @table @code
4955 @item function_vector
4956 @cindex @code{function_vector} function attribute, SH
4957 @cindex calling functions through the function vector on SH2A
4958 On SH2A targets, this attribute declares a function to be called using the
4959 TBR relative addressing mode. The argument to this attribute is the entry
4960 number of the same function in a vector table containing all the TBR
4961 relative addressable functions. For correct operation the TBR must be setup
4962 accordingly to point to the start of the vector table before any functions with
4963 this attribute are invoked. Usually a good place to do the initialization is
4964 the startup routine. The TBR relative vector table can have at max 256 function
4965 entries. The jumps to these functions are generated using a SH2A specific,
4966 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
4967 from GNU binutils version 2.7 or later for this attribute to work correctly.
4968
4969 In an application, for a function being called once, this attribute
4970 saves at least 8 bytes of code; and if other successive calls are being
4971 made to the same function, it saves 2 bytes of code per each of these
4972 calls.
4973
4974 @item interrupt_handler
4975 @cindex @code{interrupt_handler} function attribute, SH
4976 Use this attribute to
4977 indicate that the specified function is an interrupt handler. The compiler
4978 generates function entry and exit sequences suitable for use in an
4979 interrupt handler when this attribute is present.
4980
4981 @item nosave_low_regs
4982 @cindex @code{nosave_low_regs} function attribute, SH
4983 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
4984 function should not save and restore registers R0..R7. This can be used on SH3*
4985 and SH4* targets that have a second R0..R7 register bank for non-reentrant
4986 interrupt handlers.
4987
4988 @item renesas
4989 @cindex @code{renesas} function attribute, SH
4990 On SH targets this attribute specifies that the function or struct follows the
4991 Renesas ABI.
4992
4993 @item resbank
4994 @cindex @code{resbank} function attribute, SH
4995 On the SH2A target, this attribute enables the high-speed register
4996 saving and restoration using a register bank for @code{interrupt_handler}
4997 routines. Saving to the bank is performed automatically after the CPU
4998 accepts an interrupt that uses a register bank.
4999
5000 The nineteen 32-bit registers comprising general register R0 to R14,
5001 control register GBR, and system registers MACH, MACL, and PR and the
5002 vector table address offset are saved into a register bank. Register
5003 banks are stacked in first-in last-out (FILO) sequence. Restoration
5004 from the bank is executed by issuing a RESBANK instruction.
5005
5006 @item sp_switch
5007 @cindex @code{sp_switch} function attribute, SH
5008 Use this attribute on the SH to indicate an @code{interrupt_handler}
5009 function should switch to an alternate stack. It expects a string
5010 argument that names a global variable holding the address of the
5011 alternate stack.
5012
5013 @smallexample
5014 void *alt_stack;
5015 void f () __attribute__ ((interrupt_handler,
5016 sp_switch ("alt_stack")));
5017 @end smallexample
5018
5019 @item trap_exit
5020 @cindex @code{trap_exit} function attribute, SH
5021 Use this attribute on the SH for an @code{interrupt_handler} to return using
5022 @code{trapa} instead of @code{rte}. This attribute expects an integer
5023 argument specifying the trap number to be used.
5024
5025 @item trapa_handler
5026 @cindex @code{trapa_handler} function attribute, SH
5027 On SH targets this function attribute is similar to @code{interrupt_handler}
5028 but it does not save and restore all registers.
5029 @end table
5030
5031 @node SPU Function Attributes
5032 @subsection SPU Function Attributes
5033
5034 These function attributes are supported by the SPU back end:
5035
5036 @table @code
5037 @item naked
5038 @cindex @code{naked} function attribute, SPU
5039 This attribute allows the compiler to construct the
5040 requisite function declaration, while allowing the body of the
5041 function to be assembly code. The specified function will not have
5042 prologue/epilogue sequences generated by the compiler. Only basic
5043 @code{asm} statements can safely be included in naked functions
5044 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5045 basic @code{asm} and C code may appear to work, they cannot be
5046 depended upon to work reliably and are not supported.
5047 @end table
5048
5049 @node Symbian OS Function Attributes
5050 @subsection Symbian OS Function Attributes
5051
5052 @xref{Microsoft Windows Function Attributes}, for discussion of the
5053 @code{dllexport} and @code{dllimport} attributes.
5054
5055 @node Visium Function Attributes
5056 @subsection Visium Function Attributes
5057
5058 These function attributes are supported by the Visium back end:
5059
5060 @table @code
5061 @item interrupt
5062 @cindex @code{interrupt} function attribute, Visium
5063 Use this attribute to indicate
5064 that the specified function is an interrupt handler. The compiler generates
5065 function entry and exit sequences suitable for use in an interrupt handler
5066 when this attribute is present.
5067 @end table
5068
5069 @node x86 Function Attributes
5070 @subsection x86 Function Attributes
5071
5072 These function attributes are supported by the x86 back end:
5073
5074 @table @code
5075 @item cdecl
5076 @cindex @code{cdecl} function attribute, x86-32
5077 @cindex functions that pop the argument stack on x86-32
5078 @opindex mrtd
5079 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5080 assume that the calling function pops off the stack space used to
5081 pass arguments. This is
5082 useful to override the effects of the @option{-mrtd} switch.
5083
5084 @item fastcall
5085 @cindex @code{fastcall} function attribute, x86-32
5086 @cindex functions that pop the argument stack on x86-32
5087 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5088 pass the first argument (if of integral type) in the register ECX and
5089 the second argument (if of integral type) in the register EDX@. Subsequent
5090 and other typed arguments are passed on the stack. The called function
5091 pops the arguments off the stack. If the number of arguments is variable all
5092 arguments are pushed on the stack.
5093
5094 @item thiscall
5095 @cindex @code{thiscall} function attribute, x86-32
5096 @cindex functions that pop the argument stack on x86-32
5097 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5098 pass the first argument (if of integral type) in the register ECX.
5099 Subsequent and other typed arguments are passed on the stack. The called
5100 function pops the arguments off the stack.
5101 If the number of arguments is variable all arguments are pushed on the
5102 stack.
5103 The @code{thiscall} attribute is intended for C++ non-static member functions.
5104 As a GCC extension, this calling convention can be used for C functions
5105 and for static member methods.
5106
5107 @item ms_abi
5108 @itemx sysv_abi
5109 @cindex @code{ms_abi} function attribute, x86
5110 @cindex @code{sysv_abi} function attribute, x86
5111
5112 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5113 to indicate which calling convention should be used for a function. The
5114 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5115 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5116 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5117 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5118
5119 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5120 requires the @option{-maccumulate-outgoing-args} option.
5121
5122 @item callee_pop_aggregate_return (@var{number})
5123 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5124
5125 On x86-32 targets, you can use this attribute to control how
5126 aggregates are returned in memory. If the caller is responsible for
5127 popping the hidden pointer together with the rest of the arguments, specify
5128 @var{number} equal to zero. If callee is responsible for popping the
5129 hidden pointer, specify @var{number} equal to one.
5130
5131 The default x86-32 ABI assumes that the callee pops the
5132 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5133 the compiler assumes that the
5134 caller pops the stack for hidden pointer.
5135
5136 @item ms_hook_prologue
5137 @cindex @code{ms_hook_prologue} function attribute, x86
5138
5139 On 32-bit and 64-bit x86 targets, you can use
5140 this function attribute to make GCC generate the ``hot-patching'' function
5141 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5142 and newer.
5143
5144 @item regparm (@var{number})
5145 @cindex @code{regparm} function attribute, x86
5146 @cindex functions that are passed arguments in registers on x86-32
5147 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5148 pass arguments number one to @var{number} if they are of integral type
5149 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5150 take a variable number of arguments continue to be passed all of their
5151 arguments on the stack.
5152
5153 Beware that on some ELF systems this attribute is unsuitable for
5154 global functions in shared libraries with lazy binding (which is the
5155 default). Lazy binding sends the first call via resolving code in
5156 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5157 per the standard calling conventions. Solaris 8 is affected by this.
5158 Systems with the GNU C Library version 2.1 or higher
5159 and FreeBSD are believed to be
5160 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5161 disabled with the linker or the loader if desired, to avoid the
5162 problem.)
5163
5164 @item sseregparm
5165 @cindex @code{sseregparm} function attribute, x86
5166 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5167 causes the compiler to pass up to 3 floating-point arguments in
5168 SSE registers instead of on the stack. Functions that take a
5169 variable number of arguments continue to pass all of their
5170 floating-point arguments on the stack.
5171
5172 @item force_align_arg_pointer
5173 @cindex @code{force_align_arg_pointer} function attribute, x86
5174 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5175 applied to individual function definitions, generating an alternate
5176 prologue and epilogue that realigns the run-time stack if necessary.
5177 This supports mixing legacy codes that run with a 4-byte aligned stack
5178 with modern codes that keep a 16-byte stack for SSE compatibility.
5179
5180 @item stdcall
5181 @cindex @code{stdcall} function attribute, x86-32
5182 @cindex functions that pop the argument stack on x86-32
5183 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5184 assume that the called function pops off the stack space used to
5185 pass arguments, unless it takes a variable number of arguments.
5186
5187 @item target (@var{options})
5188 @cindex @code{target} function attribute
5189 As discussed in @ref{Common Function Attributes}, this attribute
5190 allows specification of target-specific compilation options.
5191
5192 On the x86, the following options are allowed:
5193 @table @samp
5194 @item abm
5195 @itemx no-abm
5196 @cindex @code{target("abm")} function attribute, x86
5197 Enable/disable the generation of the advanced bit instructions.
5198
5199 @item aes
5200 @itemx no-aes
5201 @cindex @code{target("aes")} function attribute, x86
5202 Enable/disable the generation of the AES instructions.
5203
5204 @item default
5205 @cindex @code{target("default")} function attribute, x86
5206 @xref{Function Multiversioning}, where it is used to specify the
5207 default function version.
5208
5209 @item mmx
5210 @itemx no-mmx
5211 @cindex @code{target("mmx")} function attribute, x86
5212 Enable/disable the generation of the MMX instructions.
5213
5214 @item pclmul
5215 @itemx no-pclmul
5216 @cindex @code{target("pclmul")} function attribute, x86
5217 Enable/disable the generation of the PCLMUL instructions.
5218
5219 @item popcnt
5220 @itemx no-popcnt
5221 @cindex @code{target("popcnt")} function attribute, x86
5222 Enable/disable the generation of the POPCNT instruction.
5223
5224 @item sse
5225 @itemx no-sse
5226 @cindex @code{target("sse")} function attribute, x86
5227 Enable/disable the generation of the SSE instructions.
5228
5229 @item sse2
5230 @itemx no-sse2
5231 @cindex @code{target("sse2")} function attribute, x86
5232 Enable/disable the generation of the SSE2 instructions.
5233
5234 @item sse3
5235 @itemx no-sse3
5236 @cindex @code{target("sse3")} function attribute, x86
5237 Enable/disable the generation of the SSE3 instructions.
5238
5239 @item sse4
5240 @itemx no-sse4
5241 @cindex @code{target("sse4")} function attribute, x86
5242 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5243 and SSE4.2).
5244
5245 @item sse4.1
5246 @itemx no-sse4.1
5247 @cindex @code{target("sse4.1")} function attribute, x86
5248 Enable/disable the generation of the sse4.1 instructions.
5249
5250 @item sse4.2
5251 @itemx no-sse4.2
5252 @cindex @code{target("sse4.2")} function attribute, x86
5253 Enable/disable the generation of the sse4.2 instructions.
5254
5255 @item sse4a
5256 @itemx no-sse4a
5257 @cindex @code{target("sse4a")} function attribute, x86
5258 Enable/disable the generation of the SSE4A instructions.
5259
5260 @item fma4
5261 @itemx no-fma4
5262 @cindex @code{target("fma4")} function attribute, x86
5263 Enable/disable the generation of the FMA4 instructions.
5264
5265 @item xop
5266 @itemx no-xop
5267 @cindex @code{target("xop")} function attribute, x86
5268 Enable/disable the generation of the XOP instructions.
5269
5270 @item lwp
5271 @itemx no-lwp
5272 @cindex @code{target("lwp")} function attribute, x86
5273 Enable/disable the generation of the LWP instructions.
5274
5275 @item ssse3
5276 @itemx no-ssse3
5277 @cindex @code{target("ssse3")} function attribute, x86
5278 Enable/disable the generation of the SSSE3 instructions.
5279
5280 @item cld
5281 @itemx no-cld
5282 @cindex @code{target("cld")} function attribute, x86
5283 Enable/disable the generation of the CLD before string moves.
5284
5285 @item fancy-math-387
5286 @itemx no-fancy-math-387
5287 @cindex @code{target("fancy-math-387")} function attribute, x86
5288 Enable/disable the generation of the @code{sin}, @code{cos}, and
5289 @code{sqrt} instructions on the 387 floating-point unit.
5290
5291 @item fused-madd
5292 @itemx no-fused-madd
5293 @cindex @code{target("fused-madd")} function attribute, x86
5294 Enable/disable the generation of the fused multiply/add instructions.
5295
5296 @item ieee-fp
5297 @itemx no-ieee-fp
5298 @cindex @code{target("ieee-fp")} function attribute, x86
5299 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5300
5301 @item inline-all-stringops
5302 @itemx no-inline-all-stringops
5303 @cindex @code{target("inline-all-stringops")} function attribute, x86
5304 Enable/disable inlining of string operations.
5305
5306 @item inline-stringops-dynamically
5307 @itemx no-inline-stringops-dynamically
5308 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5309 Enable/disable the generation of the inline code to do small string
5310 operations and calling the library routines for large operations.
5311
5312 @item align-stringops
5313 @itemx no-align-stringops
5314 @cindex @code{target("align-stringops")} function attribute, x86
5315 Do/do not align destination of inlined string operations.
5316
5317 @item recip
5318 @itemx no-recip
5319 @cindex @code{target("recip")} function attribute, x86
5320 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5321 instructions followed an additional Newton-Raphson step instead of
5322 doing a floating-point division.
5323
5324 @item arch=@var{ARCH}
5325 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5326 Specify the architecture to generate code for in compiling the function.
5327
5328 @item tune=@var{TUNE}
5329 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5330 Specify the architecture to tune for in compiling the function.
5331
5332 @item fpmath=@var{FPMATH}
5333 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5334 Specify which floating-point unit to use. You must specify the
5335 @code{target("fpmath=sse,387")} option as
5336 @code{target("fpmath=sse+387")} because the comma would separate
5337 different options.
5338 @end table
5339
5340 On the x86, the inliner does not inline a
5341 function that has different target options than the caller, unless the
5342 callee has a subset of the target options of the caller. For example
5343 a function declared with @code{target("sse3")} can inline a function
5344 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5345 @end table
5346
5347 @node Xstormy16 Function Attributes
5348 @subsection Xstormy16 Function Attributes
5349
5350 These function attributes are supported by the Xstormy16 back end:
5351
5352 @table @code
5353 @item interrupt
5354 @cindex @code{interrupt} function attribute, Xstormy16
5355 Use this attribute to indicate
5356 that the specified function is an interrupt handler. The compiler generates
5357 function entry and exit sequences suitable for use in an interrupt handler
5358 when this attribute is present.
5359 @end table
5360
5361 @node Variable Attributes
5362 @section Specifying Attributes of Variables
5363 @cindex attribute of variables
5364 @cindex variable attributes
5365
5366 The keyword @code{__attribute__} allows you to specify special
5367 attributes of variables or structure fields. This keyword is followed
5368 by an attribute specification inside double parentheses. Some
5369 attributes are currently defined generically for variables.
5370 Other attributes are defined for variables on particular target
5371 systems. Other attributes are available for functions
5372 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5373 enumerators (@pxref{Enumerator Attributes}), and for types
5374 (@pxref{Type Attributes}).
5375 Other front ends might define more attributes
5376 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5377
5378 @xref{Attribute Syntax}, for details of the exact syntax for using
5379 attributes.
5380
5381 @menu
5382 * Common Variable Attributes::
5383 * AVR Variable Attributes::
5384 * Blackfin Variable Attributes::
5385 * H8/300 Variable Attributes::
5386 * IA-64 Variable Attributes::
5387 * M32R/D Variable Attributes::
5388 * MeP Variable Attributes::
5389 * Microsoft Windows Variable Attributes::
5390 * MSP430 Variable Attributes::
5391 * PowerPC Variable Attributes::
5392 * SPU Variable Attributes::
5393 * x86 Variable Attributes::
5394 * Xstormy16 Variable Attributes::
5395 @end menu
5396
5397 @node Common Variable Attributes
5398 @subsection Common Variable Attributes
5399
5400 The following attributes are supported on most targets.
5401
5402 @table @code
5403 @cindex @code{aligned} variable attribute
5404 @item aligned (@var{alignment})
5405 This attribute specifies a minimum alignment for the variable or
5406 structure field, measured in bytes. For example, the declaration:
5407
5408 @smallexample
5409 int x __attribute__ ((aligned (16))) = 0;
5410 @end smallexample
5411
5412 @noindent
5413 causes the compiler to allocate the global variable @code{x} on a
5414 16-byte boundary. On a 68040, this could be used in conjunction with
5415 an @code{asm} expression to access the @code{move16} instruction which
5416 requires 16-byte aligned operands.
5417
5418 You can also specify the alignment of structure fields. For example, to
5419 create a double-word aligned @code{int} pair, you could write:
5420
5421 @smallexample
5422 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5423 @end smallexample
5424
5425 @noindent
5426 This is an alternative to creating a union with a @code{double} member,
5427 which forces the union to be double-word aligned.
5428
5429 As in the preceding examples, you can explicitly specify the alignment
5430 (in bytes) that you wish the compiler to use for a given variable or
5431 structure field. Alternatively, you can leave out the alignment factor
5432 and just ask the compiler to align a variable or field to the
5433 default alignment for the target architecture you are compiling for.
5434 The default alignment is sufficient for all scalar types, but may not be
5435 enough for all vector types on a target that supports vector operations.
5436 The default alignment is fixed for a particular target ABI.
5437
5438 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5439 which is the largest alignment ever used for any data type on the
5440 target machine you are compiling for. For example, you could write:
5441
5442 @smallexample
5443 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5444 @end smallexample
5445
5446 The compiler automatically sets the alignment for the declared
5447 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5448 often make copy operations more efficient, because the compiler can
5449 use whatever instructions copy the biggest chunks of memory when
5450 performing copies to or from the variables or fields that you have
5451 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5452 may change depending on command-line options.
5453
5454 When used on a struct, or struct member, the @code{aligned} attribute can
5455 only increase the alignment; in order to decrease it, the @code{packed}
5456 attribute must be specified as well. When used as part of a typedef, the
5457 @code{aligned} attribute can both increase and decrease alignment, and
5458 specifying the @code{packed} attribute generates a warning.
5459
5460 Note that the effectiveness of @code{aligned} attributes may be limited
5461 by inherent limitations in your linker. On many systems, the linker is
5462 only able to arrange for variables to be aligned up to a certain maximum
5463 alignment. (For some linkers, the maximum supported alignment may
5464 be very very small.) If your linker is only able to align variables
5465 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5466 in an @code{__attribute__} still only provides you with 8-byte
5467 alignment. See your linker documentation for further information.
5468
5469 The @code{aligned} attribute can also be used for functions
5470 (@pxref{Common Function Attributes}.)
5471
5472 @item cleanup (@var{cleanup_function})
5473 @cindex @code{cleanup} variable attribute
5474 The @code{cleanup} attribute runs a function when the variable goes
5475 out of scope. This attribute can only be applied to auto function
5476 scope variables; it may not be applied to parameters or variables
5477 with static storage duration. The function must take one parameter,
5478 a pointer to a type compatible with the variable. The return value
5479 of the function (if any) is ignored.
5480
5481 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5482 is run during the stack unwinding that happens during the
5483 processing of the exception. Note that the @code{cleanup} attribute
5484 does not allow the exception to be caught, only to perform an action.
5485 It is undefined what happens if @var{cleanup_function} does not
5486 return normally.
5487
5488 @item common
5489 @itemx nocommon
5490 @cindex @code{common} variable attribute
5491 @cindex @code{nocommon} variable attribute
5492 @opindex fcommon
5493 @opindex fno-common
5494 The @code{common} attribute requests GCC to place a variable in
5495 ``common'' storage. The @code{nocommon} attribute requests the
5496 opposite---to allocate space for it directly.
5497
5498 These attributes override the default chosen by the
5499 @option{-fno-common} and @option{-fcommon} flags respectively.
5500
5501 @item deprecated
5502 @itemx deprecated (@var{msg})
5503 @cindex @code{deprecated} variable attribute
5504 The @code{deprecated} attribute results in a warning if the variable
5505 is used anywhere in the source file. This is useful when identifying
5506 variables that are expected to be removed in a future version of a
5507 program. The warning also includes the location of the declaration
5508 of the deprecated variable, to enable users to easily find further
5509 information about why the variable is deprecated, or what they should
5510 do instead. Note that the warning only occurs for uses:
5511
5512 @smallexample
5513 extern int old_var __attribute__ ((deprecated));
5514 extern int old_var;
5515 int new_fn () @{ return old_var; @}
5516 @end smallexample
5517
5518 @noindent
5519 results in a warning on line 3 but not line 2. The optional @var{msg}
5520 argument, which must be a string, is printed in the warning if
5521 present.
5522
5523 The @code{deprecated} attribute can also be used for functions and
5524 types (@pxref{Common Function Attributes},
5525 @pxref{Common Type Attributes}).
5526
5527 @item mode (@var{mode})
5528 @cindex @code{mode} variable attribute
5529 This attribute specifies the data type for the declaration---whichever
5530 type corresponds to the mode @var{mode}. This in effect lets you
5531 request an integer or floating-point type according to its width.
5532
5533 You may also specify a mode of @code{byte} or @code{__byte__} to
5534 indicate the mode corresponding to a one-byte integer, @code{word} or
5535 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5536 or @code{__pointer__} for the mode used to represent pointers.
5537
5538 @item packed
5539 @cindex @code{packed} variable attribute
5540 The @code{packed} attribute specifies that a variable or structure field
5541 should have the smallest possible alignment---one byte for a variable,
5542 and one bit for a field, unless you specify a larger value with the
5543 @code{aligned} attribute.
5544
5545 Here is a structure in which the field @code{x} is packed, so that it
5546 immediately follows @code{a}:
5547
5548 @smallexample
5549 struct foo
5550 @{
5551 char a;
5552 int x[2] __attribute__ ((packed));
5553 @};
5554 @end smallexample
5555
5556 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5557 @code{packed} attribute on bit-fields of type @code{char}. This has
5558 been fixed in GCC 4.4 but the change can lead to differences in the
5559 structure layout. See the documentation of
5560 @option{-Wpacked-bitfield-compat} for more information.
5561
5562 @item section ("@var{section-name}")
5563 @cindex @code{section} variable attribute
5564 Normally, the compiler places the objects it generates in sections like
5565 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5566 or you need certain particular variables to appear in special sections,
5567 for example to map to special hardware. The @code{section}
5568 attribute specifies that a variable (or function) lives in a particular
5569 section. For example, this small program uses several specific section names:
5570
5571 @smallexample
5572 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5573 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5574 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5575 int init_data __attribute__ ((section ("INITDATA")));
5576
5577 main()
5578 @{
5579 /* @r{Initialize stack pointer} */
5580 init_sp (stack + sizeof (stack));
5581
5582 /* @r{Initialize initialized data} */
5583 memcpy (&init_data, &data, &edata - &data);
5584
5585 /* @r{Turn on the serial ports} */
5586 init_duart (&a);
5587 init_duart (&b);
5588 @}
5589 @end smallexample
5590
5591 @noindent
5592 Use the @code{section} attribute with
5593 @emph{global} variables and not @emph{local} variables,
5594 as shown in the example.
5595
5596 You may use the @code{section} attribute with initialized or
5597 uninitialized global variables but the linker requires
5598 each object be defined once, with the exception that uninitialized
5599 variables tentatively go in the @code{common} (or @code{bss}) section
5600 and can be multiply ``defined''. Using the @code{section} attribute
5601 changes what section the variable goes into and may cause the
5602 linker to issue an error if an uninitialized variable has multiple
5603 definitions. You can force a variable to be initialized with the
5604 @option{-fno-common} flag or the @code{nocommon} attribute.
5605
5606 Some file formats do not support arbitrary sections so the @code{section}
5607 attribute is not available on all platforms.
5608 If you need to map the entire contents of a module to a particular
5609 section, consider using the facilities of the linker instead.
5610
5611 @item tls_model ("@var{tls_model}")
5612 @cindex @code{tls_model} variable attribute
5613 The @code{tls_model} attribute sets thread-local storage model
5614 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5615 overriding @option{-ftls-model=} command-line switch on a per-variable
5616 basis.
5617 The @var{tls_model} argument should be one of @code{global-dynamic},
5618 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5619
5620 Not all targets support this attribute.
5621
5622 @item unused
5623 @cindex @code{unused} variable attribute
5624 This attribute, attached to a variable, means that the variable is meant
5625 to be possibly unused. GCC does not produce a warning for this
5626 variable.
5627
5628 @item used
5629 @cindex @code{used} variable attribute
5630 This attribute, attached to a variable with static storage, means that
5631 the variable must be emitted even if it appears that the variable is not
5632 referenced.
5633
5634 When applied to a static data member of a C++ class template, the
5635 attribute also means that the member is instantiated if the
5636 class itself is instantiated.
5637
5638 @item vector_size (@var{bytes})
5639 @cindex @code{vector_size} variable attribute
5640 This attribute specifies the vector size for the variable, measured in
5641 bytes. For example, the declaration:
5642
5643 @smallexample
5644 int foo __attribute__ ((vector_size (16)));
5645 @end smallexample
5646
5647 @noindent
5648 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5649 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5650 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5651
5652 This attribute is only applicable to integral and float scalars,
5653 although arrays, pointers, and function return values are allowed in
5654 conjunction with this construct.
5655
5656 Aggregates with this attribute are invalid, even if they are of the same
5657 size as a corresponding scalar. For example, the declaration:
5658
5659 @smallexample
5660 struct S @{ int a; @};
5661 struct S __attribute__ ((vector_size (16))) foo;
5662 @end smallexample
5663
5664 @noindent
5665 is invalid even if the size of the structure is the same as the size of
5666 the @code{int}.
5667
5668 @item visibility ("@var{visibility_type}")
5669 @cindex @code{visibility} variable attribute
5670 This attribute affects the linkage of the declaration to which it is attached.
5671 The @code{visibility} attribute is described in
5672 @ref{Common Function Attributes}.
5673
5674 @item weak
5675 @cindex @code{weak} variable attribute
5676 The @code{weak} attribute is described in
5677 @ref{Common Function Attributes}.
5678
5679 @end table
5680
5681 @node AVR Variable Attributes
5682 @subsection AVR Variable Attributes
5683
5684 @table @code
5685 @item progmem
5686 @cindex @code{progmem} variable attribute, AVR
5687 The @code{progmem} attribute is used on the AVR to place read-only
5688 data in the non-volatile program memory (flash). The @code{progmem}
5689 attribute accomplishes this by putting respective variables into a
5690 section whose name starts with @code{.progmem}.
5691
5692 This attribute works similar to the @code{section} attribute
5693 but adds additional checking. Notice that just like the
5694 @code{section} attribute, @code{progmem} affects the location
5695 of the data but not how this data is accessed.
5696
5697 In order to read data located with the @code{progmem} attribute
5698 (inline) assembler must be used.
5699 @smallexample
5700 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5701 #include <avr/pgmspace.h>
5702
5703 /* Locate var in flash memory */
5704 const int var[2] PROGMEM = @{ 1, 2 @};
5705
5706 int read_var (int i)
5707 @{
5708 /* Access var[] by accessor macro from avr/pgmspace.h */
5709 return (int) pgm_read_word (& var[i]);
5710 @}
5711 @end smallexample
5712
5713 AVR is a Harvard architecture processor and data and read-only data
5714 normally resides in the data memory (RAM).
5715
5716 See also the @ref{AVR Named Address Spaces} section for
5717 an alternate way to locate and access data in flash memory.
5718
5719 @item io
5720 @itemx io (@var{addr})
5721 @cindex @code{io} variable attribute, AVR
5722 Variables with the @code{io} attribute are used to address
5723 memory-mapped peripherals in the io address range.
5724 If an address is specified, the variable
5725 is assigned that address, and the value is interpreted as an
5726 address in the data address space.
5727 Example:
5728
5729 @smallexample
5730 volatile int porta __attribute__((io (0x22)));
5731 @end smallexample
5732
5733 The address specified in the address in the data address range.
5734
5735 Otherwise, the variable it is not assigned an address, but the
5736 compiler will still use in/out instructions where applicable,
5737 assuming some other module assigns an address in the io address range.
5738 Example:
5739
5740 @smallexample
5741 extern volatile int porta __attribute__((io));
5742 @end smallexample
5743
5744 @item io_low
5745 @itemx io_low (@var{addr})
5746 @cindex @code{io_low} variable attribute, AVR
5747 This is like the @code{io} attribute, but additionally it informs the
5748 compiler that the object lies in the lower half of the I/O area,
5749 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5750 instructions.
5751
5752 @item address
5753 @itemx address (@var{addr})
5754 @cindex @code{address} variable attribute, AVR
5755 Variables with the @code{address} attribute are used to address
5756 memory-mapped peripherals that may lie outside the io address range.
5757
5758 @smallexample
5759 volatile int porta __attribute__((address (0x600)));
5760 @end smallexample
5761
5762 @end table
5763
5764 @node Blackfin Variable Attributes
5765 @subsection Blackfin Variable Attributes
5766
5767 Three attributes are currently defined for the Blackfin.
5768
5769 @table @code
5770 @item l1_data
5771 @itemx l1_data_A
5772 @itemx l1_data_B
5773 @cindex @code{l1_data} variable attribute, Blackfin
5774 @cindex @code{l1_data_A} variable attribute, Blackfin
5775 @cindex @code{l1_data_B} variable attribute, Blackfin
5776 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5777 Variables with @code{l1_data} attribute are put into the specific section
5778 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5779 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5780 attribute are put into the specific section named @code{.l1.data.B}.
5781
5782 @item l2
5783 @cindex @code{l2} variable attribute, Blackfin
5784 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5785 Variables with @code{l2} attribute are put into the specific section
5786 named @code{.l2.data}.
5787 @end table
5788
5789 @node H8/300 Variable Attributes
5790 @subsection H8/300 Variable Attributes
5791
5792 These variable attributes are available for H8/300 targets:
5793
5794 @table @code
5795 @item eightbit_data
5796 @cindex @code{eightbit_data} variable attribute, H8/300
5797 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5798 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5799 variable should be placed into the eight-bit data section.
5800 The compiler generates more efficient code for certain operations
5801 on data in the eight-bit data area. Note the eight-bit data area is limited to
5802 256 bytes of data.
5803
5804 You must use GAS and GLD from GNU binutils version 2.7 or later for
5805 this attribute to work correctly.
5806
5807 @item tiny_data
5808 @cindex @code{tiny_data} variable attribute, H8/300
5809 @cindex tiny data section on the H8/300H and H8S
5810 Use this attribute on the H8/300H and H8S to indicate that the specified
5811 variable should be placed into the tiny data section.
5812 The compiler generates more efficient code for loads and stores
5813 on data in the tiny data section. Note the tiny data area is limited to
5814 slightly under 32KB of data.
5815
5816 @end table
5817
5818 @node IA-64 Variable Attributes
5819 @subsection IA-64 Variable Attributes
5820
5821 The IA-64 back end supports the following variable attribute:
5822
5823 @table @code
5824 @item model (@var{model-name})
5825 @cindex @code{model} variable attribute, IA-64
5826
5827 On IA-64, use this attribute to set the addressability of an object.
5828 At present, the only supported identifier for @var{model-name} is
5829 @code{small}, indicating addressability via ``small'' (22-bit)
5830 addresses (so that their addresses can be loaded with the @code{addl}
5831 instruction). Caveat: such addressing is by definition not position
5832 independent and hence this attribute must not be used for objects
5833 defined by shared libraries.
5834
5835 @end table
5836
5837 @node M32R/D Variable Attributes
5838 @subsection M32R/D Variable Attributes
5839
5840 One attribute is currently defined for the M32R/D@.
5841
5842 @table @code
5843 @item model (@var{model-name})
5844 @cindex @code{model-name} variable attribute, M32R/D
5845 @cindex variable addressability on the M32R/D
5846 Use this attribute on the M32R/D to set the addressability of an object.
5847 The identifier @var{model-name} is one of @code{small}, @code{medium},
5848 or @code{large}, representing each of the code models.
5849
5850 Small model objects live in the lower 16MB of memory (so that their
5851 addresses can be loaded with the @code{ld24} instruction).
5852
5853 Medium and large model objects may live anywhere in the 32-bit address space
5854 (the compiler generates @code{seth/add3} instructions to load their
5855 addresses).
5856 @end table
5857
5858 @node MeP Variable Attributes
5859 @subsection MeP Variable Attributes
5860
5861 The MeP target has a number of addressing modes and busses. The
5862 @code{near} space spans the standard memory space's first 16 megabytes
5863 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5864 The @code{based} space is a 128-byte region in the memory space that
5865 is addressed relative to the @code{$tp} register. The @code{tiny}
5866 space is a 65536-byte region relative to the @code{$gp} register. In
5867 addition to these memory regions, the MeP target has a separate 16-bit
5868 control bus which is specified with @code{cb} attributes.
5869
5870 @table @code
5871
5872 @item based
5873 @cindex @code{based} variable attribute, MeP
5874 Any variable with the @code{based} attribute is assigned to the
5875 @code{.based} section, and is accessed with relative to the
5876 @code{$tp} register.
5877
5878 @item tiny
5879 @cindex @code{tiny} variable attribute, MeP
5880 Likewise, the @code{tiny} attribute assigned variables to the
5881 @code{.tiny} section, relative to the @code{$gp} register.
5882
5883 @item near
5884 @cindex @code{near} variable attribute, MeP
5885 Variables with the @code{near} attribute are assumed to have addresses
5886 that fit in a 24-bit addressing mode. This is the default for large
5887 variables (@code{-mtiny=4} is the default) but this attribute can
5888 override @code{-mtiny=} for small variables, or override @code{-ml}.
5889
5890 @item far
5891 @cindex @code{far} variable attribute, MeP
5892 Variables with the @code{far} attribute are addressed using a full
5893 32-bit address. Since this covers the entire memory space, this
5894 allows modules to make no assumptions about where variables might be
5895 stored.
5896
5897 @item io
5898 @cindex @code{io} variable attribute, MeP
5899 @itemx io (@var{addr})
5900 Variables with the @code{io} attribute are used to address
5901 memory-mapped peripherals. If an address is specified, the variable
5902 is assigned that address, else it is not assigned an address (it is
5903 assumed some other module assigns an address). Example:
5904
5905 @smallexample
5906 int timer_count __attribute__((io(0x123)));
5907 @end smallexample
5908
5909 @item cb
5910 @itemx cb (@var{addr})
5911 @cindex @code{cb} variable attribute, MeP
5912 Variables with the @code{cb} attribute are used to access the control
5913 bus, using special instructions. @code{addr} indicates the control bus
5914 address. Example:
5915
5916 @smallexample
5917 int cpu_clock __attribute__((cb(0x123)));
5918 @end smallexample
5919
5920 @end table
5921
5922 @node Microsoft Windows Variable Attributes
5923 @subsection Microsoft Windows Variable Attributes
5924
5925 You can use these attributes on Microsoft Windows targets.
5926 @ref{x86 Variable Attributes} for additional Windows compatibility
5927 attributes available on all x86 targets.
5928
5929 @table @code
5930 @item dllimport
5931 @itemx dllexport
5932 @cindex @code{dllimport} variable attribute
5933 @cindex @code{dllexport} variable attribute
5934 The @code{dllimport} and @code{dllexport} attributes are described in
5935 @ref{Microsoft Windows Function Attributes}.
5936
5937 @item selectany
5938 @cindex @code{selectany} variable attribute
5939 The @code{selectany} attribute causes an initialized global variable to
5940 have link-once semantics. When multiple definitions of the variable are
5941 encountered by the linker, the first is selected and the remainder are
5942 discarded. Following usage by the Microsoft compiler, the linker is told
5943 @emph{not} to warn about size or content differences of the multiple
5944 definitions.
5945
5946 Although the primary usage of this attribute is for POD types, the
5947 attribute can also be applied to global C++ objects that are initialized
5948 by a constructor. In this case, the static initialization and destruction
5949 code for the object is emitted in each translation defining the object,
5950 but the calls to the constructor and destructor are protected by a
5951 link-once guard variable.
5952
5953 The @code{selectany} attribute is only available on Microsoft Windows
5954 targets. You can use @code{__declspec (selectany)} as a synonym for
5955 @code{__attribute__ ((selectany))} for compatibility with other
5956 compilers.
5957
5958 @item shared
5959 @cindex @code{shared} variable attribute
5960 On Microsoft Windows, in addition to putting variable definitions in a named
5961 section, the section can also be shared among all running copies of an
5962 executable or DLL@. For example, this small program defines shared data
5963 by putting it in a named section @code{shared} and marking the section
5964 shareable:
5965
5966 @smallexample
5967 int foo __attribute__((section ("shared"), shared)) = 0;
5968
5969 int
5970 main()
5971 @{
5972 /* @r{Read and write foo. All running
5973 copies see the same value.} */
5974 return 0;
5975 @}
5976 @end smallexample
5977
5978 @noindent
5979 You may only use the @code{shared} attribute along with @code{section}
5980 attribute with a fully-initialized global definition because of the way
5981 linkers work. See @code{section} attribute for more information.
5982
5983 The @code{shared} attribute is only available on Microsoft Windows@.
5984
5985 @end table
5986
5987 @node MSP430 Variable Attributes
5988 @subsection MSP430 Variable Attributes
5989
5990 @table @code
5991 @item noinit
5992 @cindex @code{noinit} MSP430 variable attribute
5993 Any data with the @code{noinit} attribute will not be initialised by
5994 the C runtime startup code, or the program loader. Not initialising
5995 data in this way can reduce program startup times.
5996
5997 @item persistent
5998 @cindex @code{persistent} MSP430 variable attribute
5999 Any variable with the @code{persistent} attribute will not be
6000 initialised by the C runtime startup code. Instead its value will be
6001 set once, when the application is loaded, and then never initialised
6002 again, even if the processor is reset or the program restarts.
6003 Persistent data is intended to be placed into FLASH RAM, where its
6004 value will be retained across resets. The linker script being used to
6005 create the application should ensure that persistent data is correctly
6006 placed.
6007
6008 @item lower
6009 @itemx upper
6010 @itemx either
6011 @cindex @code{lower} memory region on the MSP430
6012 @cindex @code{upper} memory region on the MSP430
6013 @cindex @code{either} memory region on the MSP430
6014 These attributes are the same as the MSP430 function attributes of the
6015 same name. These attributes can be applied to both functions and
6016 variables.
6017 @end table
6018
6019 @node PowerPC Variable Attributes
6020 @subsection PowerPC Variable Attributes
6021
6022 Three attributes currently are defined for PowerPC configurations:
6023 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6024
6025 @cindex @code{ms_struct} variable attribute, PowerPC
6026 @cindex @code{gcc_struct} variable attribute, PowerPC
6027 For full documentation of the struct attributes please see the
6028 documentation in @ref{x86 Variable Attributes}.
6029
6030 @cindex @code{altivec} variable attribute, PowerPC
6031 For documentation of @code{altivec} attribute please see the
6032 documentation in @ref{PowerPC Type Attributes}.
6033
6034 @node SPU Variable Attributes
6035 @subsection SPU Variable Attributes
6036
6037 @cindex @code{spu_vector} variable attribute, SPU
6038 The SPU supports the @code{spu_vector} attribute for variables. For
6039 documentation of this attribute please see the documentation in
6040 @ref{SPU Type Attributes}.
6041
6042 @node x86 Variable Attributes
6043 @subsection x86 Variable Attributes
6044
6045 Two attributes are currently defined for x86 configurations:
6046 @code{ms_struct} and @code{gcc_struct}.
6047
6048 @table @code
6049 @item ms_struct
6050 @itemx gcc_struct
6051 @cindex @code{ms_struct} variable attribute, x86
6052 @cindex @code{gcc_struct} variable attribute, x86
6053
6054 If @code{packed} is used on a structure, or if bit-fields are used,
6055 it may be that the Microsoft ABI lays out the structure differently
6056 than the way GCC normally does. Particularly when moving packed
6057 data between functions compiled with GCC and the native Microsoft compiler
6058 (either via function call or as data in a file), it may be necessary to access
6059 either format.
6060
6061 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6062 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6063 command-line options, respectively;
6064 see @ref{x86 Options}, for details of how structure layout is affected.
6065 @xref{x86 Type Attributes}, for information about the corresponding
6066 attributes on types.
6067
6068 @end table
6069
6070 @node Xstormy16 Variable Attributes
6071 @subsection Xstormy16 Variable Attributes
6072
6073 One attribute is currently defined for xstormy16 configurations:
6074 @code{below100}.
6075
6076 @table @code
6077 @item below100
6078 @cindex @code{below100} variable attribute, Xstormy16
6079
6080 If a variable has the @code{below100} attribute (@code{BELOW100} is
6081 allowed also), GCC places the variable in the first 0x100 bytes of
6082 memory and use special opcodes to access it. Such variables are
6083 placed in either the @code{.bss_below100} section or the
6084 @code{.data_below100} section.
6085
6086 @end table
6087
6088 @node Type Attributes
6089 @section Specifying Attributes of Types
6090 @cindex attribute of types
6091 @cindex type attributes
6092
6093 The keyword @code{__attribute__} allows you to specify special
6094 attributes of types. Some type attributes apply only to @code{struct}
6095 and @code{union} types, while others can apply to any type defined
6096 via a @code{typedef} declaration. Other attributes are defined for
6097 functions (@pxref{Function Attributes}), labels (@pxref{Label
6098 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6099 variables (@pxref{Variable Attributes}).
6100
6101 The @code{__attribute__} keyword is followed by an attribute specification
6102 inside double parentheses.
6103
6104 You may specify type attributes in an enum, struct or union type
6105 declaration or definition by placing them immediately after the
6106 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6107 syntax is to place them just past the closing curly brace of the
6108 definition.
6109
6110 You can also include type attributes in a @code{typedef} declaration.
6111 @xref{Attribute Syntax}, for details of the exact syntax for using
6112 attributes.
6113
6114 @menu
6115 * Common Type Attributes::
6116 * ARM Type Attributes::
6117 * MeP Type Attributes::
6118 * PowerPC Type Attributes::
6119 * SPU Type Attributes::
6120 * x86 Type Attributes::
6121 @end menu
6122
6123 @node Common Type Attributes
6124 @subsection Common Type Attributes
6125
6126 The following type attributes are supported on most targets.
6127
6128 @table @code
6129 @cindex @code{aligned} type attribute
6130 @item aligned (@var{alignment})
6131 This attribute specifies a minimum alignment (in bytes) for variables
6132 of the specified type. For example, the declarations:
6133
6134 @smallexample
6135 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6136 typedef int more_aligned_int __attribute__ ((aligned (8)));
6137 @end smallexample
6138
6139 @noindent
6140 force the compiler to ensure (as far as it can) that each variable whose
6141 type is @code{struct S} or @code{more_aligned_int} is allocated and
6142 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6143 variables of type @code{struct S} aligned to 8-byte boundaries allows
6144 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6145 store) instructions when copying one variable of type @code{struct S} to
6146 another, thus improving run-time efficiency.
6147
6148 Note that the alignment of any given @code{struct} or @code{union} type
6149 is required by the ISO C standard to be at least a perfect multiple of
6150 the lowest common multiple of the alignments of all of the members of
6151 the @code{struct} or @code{union} in question. This means that you @emph{can}
6152 effectively adjust the alignment of a @code{struct} or @code{union}
6153 type by attaching an @code{aligned} attribute to any one of the members
6154 of such a type, but the notation illustrated in the example above is a
6155 more obvious, intuitive, and readable way to request the compiler to
6156 adjust the alignment of an entire @code{struct} or @code{union} type.
6157
6158 As in the preceding example, you can explicitly specify the alignment
6159 (in bytes) that you wish the compiler to use for a given @code{struct}
6160 or @code{union} type. Alternatively, you can leave out the alignment factor
6161 and just ask the compiler to align a type to the maximum
6162 useful alignment for the target machine you are compiling for. For
6163 example, you could write:
6164
6165 @smallexample
6166 struct S @{ short f[3]; @} __attribute__ ((aligned));
6167 @end smallexample
6168
6169 Whenever you leave out the alignment factor in an @code{aligned}
6170 attribute specification, the compiler automatically sets the alignment
6171 for the type to the largest alignment that is ever used for any data
6172 type on the target machine you are compiling for. Doing this can often
6173 make copy operations more efficient, because the compiler can use
6174 whatever instructions copy the biggest chunks of memory when performing
6175 copies to or from the variables that have types that you have aligned
6176 this way.
6177
6178 In the example above, if the size of each @code{short} is 2 bytes, then
6179 the size of the entire @code{struct S} type is 6 bytes. The smallest
6180 power of two that is greater than or equal to that is 8, so the
6181 compiler sets the alignment for the entire @code{struct S} type to 8
6182 bytes.
6183
6184 Note that although you can ask the compiler to select a time-efficient
6185 alignment for a given type and then declare only individual stand-alone
6186 objects of that type, the compiler's ability to select a time-efficient
6187 alignment is primarily useful only when you plan to create arrays of
6188 variables having the relevant (efficiently aligned) type. If you
6189 declare or use arrays of variables of an efficiently-aligned type, then
6190 it is likely that your program also does pointer arithmetic (or
6191 subscripting, which amounts to the same thing) on pointers to the
6192 relevant type, and the code that the compiler generates for these
6193 pointer arithmetic operations is often more efficient for
6194 efficiently-aligned types than for other types.
6195
6196 The @code{aligned} attribute can only increase the alignment; but you
6197 can decrease it by specifying @code{packed} as well. See below.
6198
6199 Note that the effectiveness of @code{aligned} attributes may be limited
6200 by inherent limitations in your linker. On many systems, the linker is
6201 only able to arrange for variables to be aligned up to a certain maximum
6202 alignment. (For some linkers, the maximum supported alignment may
6203 be very very small.) If your linker is only able to align variables
6204 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6205 in an @code{__attribute__} still only provides you with 8-byte
6206 alignment. See your linker documentation for further information.
6207
6208 @opindex fshort-enums
6209 Specifying this attribute for @code{struct} and @code{union} types is
6210 equivalent to specifying the @code{packed} attribute on each of the
6211 structure or union members. Specifying the @option{-fshort-enums}
6212 flag on the line is equivalent to specifying the @code{packed}
6213 attribute on all @code{enum} definitions.
6214
6215 In the following example @code{struct my_packed_struct}'s members are
6216 packed closely together, but the internal layout of its @code{s} member
6217 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6218 be packed too.
6219
6220 @smallexample
6221 struct my_unpacked_struct
6222 @{
6223 char c;
6224 int i;
6225 @};
6226
6227 struct __attribute__ ((__packed__)) my_packed_struct
6228 @{
6229 char c;
6230 int i;
6231 struct my_unpacked_struct s;
6232 @};
6233 @end smallexample
6234
6235 You may only specify this attribute on the definition of an @code{enum},
6236 @code{struct} or @code{union}, not on a @code{typedef} that does not
6237 also define the enumerated type, structure or union.
6238
6239 @item bnd_variable_size
6240 @cindex @code{bnd_variable_size} type attribute
6241 @cindex Pointer Bounds Checker attributes
6242 When applied to a structure field, this attribute tells Pointer
6243 Bounds Checker that the size of this field should not be computed
6244 using static type information. It may be used to mark variably-sized
6245 static array fields placed at the end of a structure.
6246
6247 @smallexample
6248 struct S
6249 @{
6250 int size;
6251 char data[1];
6252 @}
6253 S *p = (S *)malloc (sizeof(S) + 100);
6254 p->data[10] = 0; //Bounds violation
6255 @end smallexample
6256
6257 @noindent
6258 By using an attribute for the field we may avoid unwanted bound
6259 violation checks:
6260
6261 @smallexample
6262 struct S
6263 @{
6264 int size;
6265 char data[1] __attribute__((bnd_variable_size));
6266 @}
6267 S *p = (S *)malloc (sizeof(S) + 100);
6268 p->data[10] = 0; //OK
6269 @end smallexample
6270
6271 @item deprecated
6272 @itemx deprecated (@var{msg})
6273 @cindex @code{deprecated} type attribute
6274 The @code{deprecated} attribute results in a warning if the type
6275 is used anywhere in the source file. This is useful when identifying
6276 types that are expected to be removed in a future version of a program.
6277 If possible, the warning also includes the location of the declaration
6278 of the deprecated type, to enable users to easily find further
6279 information about why the type is deprecated, or what they should do
6280 instead. Note that the warnings only occur for uses and then only
6281 if the type is being applied to an identifier that itself is not being
6282 declared as deprecated.
6283
6284 @smallexample
6285 typedef int T1 __attribute__ ((deprecated));
6286 T1 x;
6287 typedef T1 T2;
6288 T2 y;
6289 typedef T1 T3 __attribute__ ((deprecated));
6290 T3 z __attribute__ ((deprecated));
6291 @end smallexample
6292
6293 @noindent
6294 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6295 warning is issued for line 4 because T2 is not explicitly
6296 deprecated. Line 5 has no warning because T3 is explicitly
6297 deprecated. Similarly for line 6. The optional @var{msg}
6298 argument, which must be a string, is printed in the warning if
6299 present.
6300
6301 The @code{deprecated} attribute can also be used for functions and
6302 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6303
6304 @item designated_init
6305 @cindex @code{designated_init} type attribute
6306 This attribute may only be applied to structure types. It indicates
6307 that any initialization of an object of this type must use designated
6308 initializers rather than positional initializers. The intent of this
6309 attribute is to allow the programmer to indicate that a structure's
6310 layout may change, and that therefore relying on positional
6311 initialization will result in future breakage.
6312
6313 GCC emits warnings based on this attribute by default; use
6314 @option{-Wno-designated-init} to suppress them.
6315
6316 @item may_alias
6317 @cindex @code{may_alias} type attribute
6318 Accesses through pointers to types with this attribute are not subject
6319 to type-based alias analysis, but are instead assumed to be able to alias
6320 any other type of objects.
6321 In the context of section 6.5 paragraph 7 of the C99 standard,
6322 an lvalue expression
6323 dereferencing such a pointer is treated like having a character type.
6324 See @option{-fstrict-aliasing} for more information on aliasing issues.
6325 This extension exists to support some vector APIs, in which pointers to
6326 one vector type are permitted to alias pointers to a different vector type.
6327
6328 Note that an object of a type with this attribute does not have any
6329 special semantics.
6330
6331 Example of use:
6332
6333 @smallexample
6334 typedef short __attribute__((__may_alias__)) short_a;
6335
6336 int
6337 main (void)
6338 @{
6339 int a = 0x12345678;
6340 short_a *b = (short_a *) &a;
6341
6342 b[1] = 0;
6343
6344 if (a == 0x12345678)
6345 abort();
6346
6347 exit(0);
6348 @}
6349 @end smallexample
6350
6351 @noindent
6352 If you replaced @code{short_a} with @code{short} in the variable
6353 declaration, the above program would abort when compiled with
6354 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6355 above.
6356
6357 @item packed
6358 @cindex @code{packed} type attribute
6359 This attribute, attached to @code{struct} or @code{union} type
6360 definition, specifies that each member (other than zero-width bit-fields)
6361 of the structure or union is placed to minimize the memory required. When
6362 attached to an @code{enum} definition, it indicates that the smallest
6363 integral type should be used.
6364
6365 @item scalar_storage_order ("@var{endianness}")
6366 @cindex @code{scalar_storage_order} type attribute
6367 When attached to a @code{union} or a @code{struct}, this attribute sets
6368 the storage order, aka endianness, of the scalar fields of the type, as
6369 well as the array fields whose component is scalar. The supported
6370 endianness are @code{big-endian} and @code{little-endian}. The attribute
6371 has no effects on fields which are themselves a @code{union}, a @code{struct}
6372 or an array whose component is a @code{union} or a @code{struct}, and it is
6373 possible to have fields with a different scalar storage order than the
6374 enclosing type.
6375
6376 This attribute is supported only for targets that use a uniform default
6377 scalar storage order (fortunately, most of them), i.e. targets that store
6378 the scalars either all in big-endian or all in little-endian.
6379
6380 Additional restrictions are enforced for types with the reverse scalar
6381 storage order with regard to the scalar storage order of the target:
6382
6383 @itemize
6384 @item Taking the address of a scalar field of a @code{union} or a
6385 @code{struct} with reverse scalar storage order is not permitted and will
6386 yield an error.
6387 @item Taking the address of an array field, whose component is scalar, of
6388 a @code{union} or a @code{struct} with reverse scalar storage order is
6389 permitted but will yield a warning, unless @option{-Wno-scalar-storage-order}
6390 is specified.
6391 @item Taking the address of a @code{union} or a @code{struct} with reverse
6392 scalar storage order is permitted.
6393 @end itemize
6394
6395 These restrictions exist because the storage order attribute is lost when
6396 the address of a scalar or the address of an array with scalar component
6397 is taken, so storing indirectly through this address will generally not work.
6398 The second case is nevertheless allowed to be able to perform a block copy
6399 from or to the array.
6400
6401 @item transparent_union
6402 @cindex @code{transparent_union} type attribute
6403
6404 This attribute, attached to a @code{union} type definition, indicates
6405 that any function parameter having that union type causes calls to that
6406 function to be treated in a special way.
6407
6408 First, the argument corresponding to a transparent union type can be of
6409 any type in the union; no cast is required. Also, if the union contains
6410 a pointer type, the corresponding argument can be a null pointer
6411 constant or a void pointer expression; and if the union contains a void
6412 pointer type, the corresponding argument can be any pointer expression.
6413 If the union member type is a pointer, qualifiers like @code{const} on
6414 the referenced type must be respected, just as with normal pointer
6415 conversions.
6416
6417 Second, the argument is passed to the function using the calling
6418 conventions of the first member of the transparent union, not the calling
6419 conventions of the union itself. All members of the union must have the
6420 same machine representation; this is necessary for this argument passing
6421 to work properly.
6422
6423 Transparent unions are designed for library functions that have multiple
6424 interfaces for compatibility reasons. For example, suppose the
6425 @code{wait} function must accept either a value of type @code{int *} to
6426 comply with POSIX, or a value of type @code{union wait *} to comply with
6427 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6428 @code{wait} would accept both kinds of arguments, but it would also
6429 accept any other pointer type and this would make argument type checking
6430 less useful. Instead, @code{<sys/wait.h>} might define the interface
6431 as follows:
6432
6433 @smallexample
6434 typedef union __attribute__ ((__transparent_union__))
6435 @{
6436 int *__ip;
6437 union wait *__up;
6438 @} wait_status_ptr_t;
6439
6440 pid_t wait (wait_status_ptr_t);
6441 @end smallexample
6442
6443 @noindent
6444 This interface allows either @code{int *} or @code{union wait *}
6445 arguments to be passed, using the @code{int *} calling convention.
6446 The program can call @code{wait} with arguments of either type:
6447
6448 @smallexample
6449 int w1 () @{ int w; return wait (&w); @}
6450 int w2 () @{ union wait w; return wait (&w); @}
6451 @end smallexample
6452
6453 @noindent
6454 With this interface, @code{wait}'s implementation might look like this:
6455
6456 @smallexample
6457 pid_t wait (wait_status_ptr_t p)
6458 @{
6459 return waitpid (-1, p.__ip, 0);
6460 @}
6461 @end smallexample
6462
6463 @item unused
6464 @cindex @code{unused} type attribute
6465 When attached to a type (including a @code{union} or a @code{struct}),
6466 this attribute means that variables of that type are meant to appear
6467 possibly unused. GCC does not produce a warning for any variables of
6468 that type, even if the variable appears to do nothing. This is often
6469 the case with lock or thread classes, which are usually defined and then
6470 not referenced, but contain constructors and destructors that have
6471 nontrivial bookkeeping functions.
6472
6473 @item visibility
6474 @cindex @code{visibility} type attribute
6475 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6476 applied to class, struct, union and enum types. Unlike other type
6477 attributes, the attribute must appear between the initial keyword and
6478 the name of the type; it cannot appear after the body of the type.
6479
6480 Note that the type visibility is applied to vague linkage entities
6481 associated with the class (vtable, typeinfo node, etc.). In
6482 particular, if a class is thrown as an exception in one shared object
6483 and caught in another, the class must have default visibility.
6484 Otherwise the two shared objects are unable to use the same
6485 typeinfo node and exception handling will break.
6486
6487 @end table
6488
6489 To specify multiple attributes, separate them by commas within the
6490 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6491 packed))}.
6492
6493 @node ARM Type Attributes
6494 @subsection ARM Type Attributes
6495
6496 @cindex @code{notshared} type attribute, ARM
6497 On those ARM targets that support @code{dllimport} (such as Symbian
6498 OS), you can use the @code{notshared} attribute to indicate that the
6499 virtual table and other similar data for a class should not be
6500 exported from a DLL@. For example:
6501
6502 @smallexample
6503 class __declspec(notshared) C @{
6504 public:
6505 __declspec(dllimport) C();
6506 virtual void f();
6507 @}
6508
6509 __declspec(dllexport)
6510 C::C() @{@}
6511 @end smallexample
6512
6513 @noindent
6514 In this code, @code{C::C} is exported from the current DLL, but the
6515 virtual table for @code{C} is not exported. (You can use
6516 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6517 most Symbian OS code uses @code{__declspec}.)
6518
6519 @node MeP Type Attributes
6520 @subsection MeP Type Attributes
6521
6522 @cindex @code{based} type attribute, MeP
6523 @cindex @code{tiny} type attribute, MeP
6524 @cindex @code{near} type attribute, MeP
6525 @cindex @code{far} type attribute, MeP
6526 Many of the MeP variable attributes may be applied to types as well.
6527 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6528 @code{far} attributes may be applied to either. The @code{io} and
6529 @code{cb} attributes may not be applied to types.
6530
6531 @node PowerPC Type Attributes
6532 @subsection PowerPC Type Attributes
6533
6534 Three attributes currently are defined for PowerPC configurations:
6535 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6536
6537 @cindex @code{ms_struct} type attribute, PowerPC
6538 @cindex @code{gcc_struct} type attribute, PowerPC
6539 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6540 attributes please see the documentation in @ref{x86 Type Attributes}.
6541
6542 @cindex @code{altivec} type attribute, PowerPC
6543 The @code{altivec} attribute allows one to declare AltiVec vector data
6544 types supported by the AltiVec Programming Interface Manual. The
6545 attribute requires an argument to specify one of three vector types:
6546 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6547 and @code{bool__} (always followed by unsigned).
6548
6549 @smallexample
6550 __attribute__((altivec(vector__)))
6551 __attribute__((altivec(pixel__))) unsigned short
6552 __attribute__((altivec(bool__))) unsigned
6553 @end smallexample
6554
6555 These attributes mainly are intended to support the @code{__vector},
6556 @code{__pixel}, and @code{__bool} AltiVec keywords.
6557
6558 @node SPU Type Attributes
6559 @subsection SPU Type Attributes
6560
6561 @cindex @code{spu_vector} type attribute, SPU
6562 The SPU supports the @code{spu_vector} attribute for types. This attribute
6563 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6564 Language Extensions Specification. It is intended to support the
6565 @code{__vector} keyword.
6566
6567 @node x86 Type Attributes
6568 @subsection x86 Type Attributes
6569
6570 Two attributes are currently defined for x86 configurations:
6571 @code{ms_struct} and @code{gcc_struct}.
6572
6573 @table @code
6574
6575 @item ms_struct
6576 @itemx gcc_struct
6577 @cindex @code{ms_struct} type attribute, x86
6578 @cindex @code{gcc_struct} type attribute, x86
6579
6580 If @code{packed} is used on a structure, or if bit-fields are used
6581 it may be that the Microsoft ABI packs them differently
6582 than GCC normally packs them. Particularly when moving packed
6583 data between functions compiled with GCC and the native Microsoft compiler
6584 (either via function call or as data in a file), it may be necessary to access
6585 either format.
6586
6587 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6588 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6589 command-line options, respectively;
6590 see @ref{x86 Options}, for details of how structure layout is affected.
6591 @xref{x86 Variable Attributes}, for information about the corresponding
6592 attributes on variables.
6593
6594 @end table
6595
6596 @node Label Attributes
6597 @section Label Attributes
6598 @cindex Label Attributes
6599
6600 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6601 details of the exact syntax for using attributes. Other attributes are
6602 available for functions (@pxref{Function Attributes}), variables
6603 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6604 and for types (@pxref{Type Attributes}).
6605
6606 This example uses the @code{cold} label attribute to indicate the
6607 @code{ErrorHandling} branch is unlikely to be taken and that the
6608 @code{ErrorHandling} label is unused:
6609
6610 @smallexample
6611
6612 asm goto ("some asm" : : : : NoError);
6613
6614 /* This branch (the fall-through from the asm) is less commonly used */
6615 ErrorHandling:
6616 __attribute__((cold, unused)); /* Semi-colon is required here */
6617 printf("error\n");
6618 return 0;
6619
6620 NoError:
6621 printf("no error\n");
6622 return 1;
6623 @end smallexample
6624
6625 @table @code
6626 @item unused
6627 @cindex @code{unused} label attribute
6628 This feature is intended for program-generated code that may contain
6629 unused labels, but which is compiled with @option{-Wall}. It is
6630 not normally appropriate to use in it human-written code, though it
6631 could be useful in cases where the code that jumps to the label is
6632 contained within an @code{#ifdef} conditional.
6633
6634 @item hot
6635 @cindex @code{hot} label attribute
6636 The @code{hot} attribute on a label is used to inform the compiler that
6637 the path following the label is more likely than paths that are not so
6638 annotated. This attribute is used in cases where @code{__builtin_expect}
6639 cannot be used, for instance with computed goto or @code{asm goto}.
6640
6641 @item cold
6642 @cindex @code{cold} label attribute
6643 The @code{cold} attribute on labels is used to inform the compiler that
6644 the path following the label is unlikely to be executed. This attribute
6645 is used in cases where @code{__builtin_expect} cannot be used, for instance
6646 with computed goto or @code{asm goto}.
6647
6648 @end table
6649
6650 @node Enumerator Attributes
6651 @section Enumerator Attributes
6652 @cindex Enumerator Attributes
6653
6654 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6655 details of the exact syntax for using attributes. Other attributes are
6656 available for functions (@pxref{Function Attributes}), variables
6657 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6658 and for types (@pxref{Type Attributes}).
6659
6660 This example uses the @code{deprecated} enumerator attribute to indicate the
6661 @code{oldval} enumerator is deprecated:
6662
6663 @smallexample
6664 enum E @{
6665 oldval __attribute__((deprecated)),
6666 newval
6667 @};
6668
6669 int
6670 fn (void)
6671 @{
6672 return oldval;
6673 @}
6674 @end smallexample
6675
6676 @table @code
6677 @item deprecated
6678 @cindex @code{deprecated} enumerator attribute
6679 The @code{deprecated} attribute results in a warning if the enumerator
6680 is used anywhere in the source file. This is useful when identifying
6681 enumerators that are expected to be removed in a future version of a
6682 program. The warning also includes the location of the declaration
6683 of the deprecated enumerator, to enable users to easily find further
6684 information about why the enumerator is deprecated, or what they should
6685 do instead. Note that the warnings only occurs for uses.
6686
6687 @end table
6688
6689 @node Attribute Syntax
6690 @section Attribute Syntax
6691 @cindex attribute syntax
6692
6693 This section describes the syntax with which @code{__attribute__} may be
6694 used, and the constructs to which attribute specifiers bind, for the C
6695 language. Some details may vary for C++ and Objective-C@. Because of
6696 infelicities in the grammar for attributes, some forms described here
6697 may not be successfully parsed in all cases.
6698
6699 There are some problems with the semantics of attributes in C++. For
6700 example, there are no manglings for attributes, although they may affect
6701 code generation, so problems may arise when attributed types are used in
6702 conjunction with templates or overloading. Similarly, @code{typeid}
6703 does not distinguish between types with different attributes. Support
6704 for attributes in C++ may be restricted in future to attributes on
6705 declarations only, but not on nested declarators.
6706
6707 @xref{Function Attributes}, for details of the semantics of attributes
6708 applying to functions. @xref{Variable Attributes}, for details of the
6709 semantics of attributes applying to variables. @xref{Type Attributes},
6710 for details of the semantics of attributes applying to structure, union
6711 and enumerated types.
6712 @xref{Label Attributes}, for details of the semantics of attributes
6713 applying to labels.
6714 @xref{Enumerator Attributes}, for details of the semantics of attributes
6715 applying to enumerators.
6716
6717 An @dfn{attribute specifier} is of the form
6718 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6719 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6720 each attribute is one of the following:
6721
6722 @itemize @bullet
6723 @item
6724 Empty. Empty attributes are ignored.
6725
6726 @item
6727 An attribute name
6728 (which may be an identifier such as @code{unused}, or a reserved
6729 word such as @code{const}).
6730
6731 @item
6732 An attribute name followed by a parenthesized list of
6733 parameters for the attribute.
6734 These parameters take one of the following forms:
6735
6736 @itemize @bullet
6737 @item
6738 An identifier. For example, @code{mode} attributes use this form.
6739
6740 @item
6741 An identifier followed by a comma and a non-empty comma-separated list
6742 of expressions. For example, @code{format} attributes use this form.
6743
6744 @item
6745 A possibly empty comma-separated list of expressions. For example,
6746 @code{format_arg} attributes use this form with the list being a single
6747 integer constant expression, and @code{alias} attributes use this form
6748 with the list being a single string constant.
6749 @end itemize
6750 @end itemize
6751
6752 An @dfn{attribute specifier list} is a sequence of one or more attribute
6753 specifiers, not separated by any other tokens.
6754
6755 You may optionally specify attribute names with @samp{__}
6756 preceding and following the name.
6757 This allows you to use them in header files without
6758 being concerned about a possible macro of the same name. For example,
6759 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6760
6761
6762 @subsubheading Label Attributes
6763
6764 In GNU C, an attribute specifier list may appear after the colon following a
6765 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6766 attributes on labels if the attribute specifier is immediately
6767 followed by a semicolon (i.e., the label applies to an empty
6768 statement). If the semicolon is missing, C++ label attributes are
6769 ambiguous, as it is permissible for a declaration, which could begin
6770 with an attribute list, to be labelled in C++. Declarations cannot be
6771 labelled in C90 or C99, so the ambiguity does not arise there.
6772
6773 @subsubheading Enumerator Attributes
6774
6775 In GNU C, an attribute specifier list may appear as part of an enumerator.
6776 The attribute goes after the enumeration constant, before @code{=}, if
6777 present. The optional attribute in the enumerator appertains to the
6778 enumeration constant. It is not possible to place the attribute after
6779 the constant expression, if present.
6780
6781 @subsubheading Type Attributes
6782
6783 An attribute specifier list may appear as part of a @code{struct},
6784 @code{union} or @code{enum} specifier. It may go either immediately
6785 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6786 the closing brace. The former syntax is preferred.
6787 Where attribute specifiers follow the closing brace, they are considered
6788 to relate to the structure, union or enumerated type defined, not to any
6789 enclosing declaration the type specifier appears in, and the type
6790 defined is not complete until after the attribute specifiers.
6791 @c Otherwise, there would be the following problems: a shift/reduce
6792 @c conflict between attributes binding the struct/union/enum and
6793 @c binding to the list of specifiers/qualifiers; and "aligned"
6794 @c attributes could use sizeof for the structure, but the size could be
6795 @c changed later by "packed" attributes.
6796
6797
6798 @subsubheading All other attributes
6799
6800 Otherwise, an attribute specifier appears as part of a declaration,
6801 counting declarations of unnamed parameters and type names, and relates
6802 to that declaration (which may be nested in another declaration, for
6803 example in the case of a parameter declaration), or to a particular declarator
6804 within a declaration. Where an
6805 attribute specifier is applied to a parameter declared as a function or
6806 an array, it should apply to the function or array rather than the
6807 pointer to which the parameter is implicitly converted, but this is not
6808 yet correctly implemented.
6809
6810 Any list of specifiers and qualifiers at the start of a declaration may
6811 contain attribute specifiers, whether or not such a list may in that
6812 context contain storage class specifiers. (Some attributes, however,
6813 are essentially in the nature of storage class specifiers, and only make
6814 sense where storage class specifiers may be used; for example,
6815 @code{section}.) There is one necessary limitation to this syntax: the
6816 first old-style parameter declaration in a function definition cannot
6817 begin with an attribute specifier, because such an attribute applies to
6818 the function instead by syntax described below (which, however, is not
6819 yet implemented in this case). In some other cases, attribute
6820 specifiers are permitted by this grammar but not yet supported by the
6821 compiler. All attribute specifiers in this place relate to the
6822 declaration as a whole. In the obsolescent usage where a type of
6823 @code{int} is implied by the absence of type specifiers, such a list of
6824 specifiers and qualifiers may be an attribute specifier list with no
6825 other specifiers or qualifiers.
6826
6827 At present, the first parameter in a function prototype must have some
6828 type specifier that is not an attribute specifier; this resolves an
6829 ambiguity in the interpretation of @code{void f(int
6830 (__attribute__((foo)) x))}, but is subject to change. At present, if
6831 the parentheses of a function declarator contain only attributes then
6832 those attributes are ignored, rather than yielding an error or warning
6833 or implying a single parameter of type int, but this is subject to
6834 change.
6835
6836 An attribute specifier list may appear immediately before a declarator
6837 (other than the first) in a comma-separated list of declarators in a
6838 declaration of more than one identifier using a single list of
6839 specifiers and qualifiers. Such attribute specifiers apply
6840 only to the identifier before whose declarator they appear. For
6841 example, in
6842
6843 @smallexample
6844 __attribute__((noreturn)) void d0 (void),
6845 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6846 d2 (void);
6847 @end smallexample
6848
6849 @noindent
6850 the @code{noreturn} attribute applies to all the functions
6851 declared; the @code{format} attribute only applies to @code{d1}.
6852
6853 An attribute specifier list may appear immediately before the comma,
6854 @code{=} or semicolon terminating the declaration of an identifier other
6855 than a function definition. Such attribute specifiers apply
6856 to the declared object or function. Where an
6857 assembler name for an object or function is specified (@pxref{Asm
6858 Labels}), the attribute must follow the @code{asm}
6859 specification.
6860
6861 An attribute specifier list may, in future, be permitted to appear after
6862 the declarator in a function definition (before any old-style parameter
6863 declarations or the function body).
6864
6865 Attribute specifiers may be mixed with type qualifiers appearing inside
6866 the @code{[]} of a parameter array declarator, in the C99 construct by
6867 which such qualifiers are applied to the pointer to which the array is
6868 implicitly converted. Such attribute specifiers apply to the pointer,
6869 not to the array, but at present this is not implemented and they are
6870 ignored.
6871
6872 An attribute specifier list may appear at the start of a nested
6873 declarator. At present, there are some limitations in this usage: the
6874 attributes correctly apply to the declarator, but for most individual
6875 attributes the semantics this implies are not implemented.
6876 When attribute specifiers follow the @code{*} of a pointer
6877 declarator, they may be mixed with any type qualifiers present.
6878 The following describes the formal semantics of this syntax. It makes the
6879 most sense if you are familiar with the formal specification of
6880 declarators in the ISO C standard.
6881
6882 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6883 D1}, where @code{T} contains declaration specifiers that specify a type
6884 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6885 contains an identifier @var{ident}. The type specified for @var{ident}
6886 for derived declarators whose type does not include an attribute
6887 specifier is as in the ISO C standard.
6888
6889 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
6890 and the declaration @code{T D} specifies the type
6891 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6892 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6893 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
6894
6895 If @code{D1} has the form @code{*
6896 @var{type-qualifier-and-attribute-specifier-list} D}, and the
6897 declaration @code{T D} specifies the type
6898 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
6899 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
6900 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
6901 @var{ident}.
6902
6903 For example,
6904
6905 @smallexample
6906 void (__attribute__((noreturn)) ****f) (void);
6907 @end smallexample
6908
6909 @noindent
6910 specifies the type ``pointer to pointer to pointer to pointer to
6911 non-returning function returning @code{void}''. As another example,
6912
6913 @smallexample
6914 char *__attribute__((aligned(8))) *f;
6915 @end smallexample
6916
6917 @noindent
6918 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
6919 Note again that this does not work with most attributes; for example,
6920 the usage of @samp{aligned} and @samp{noreturn} attributes given above
6921 is not yet supported.
6922
6923 For compatibility with existing code written for compiler versions that
6924 did not implement attributes on nested declarators, some laxity is
6925 allowed in the placing of attributes. If an attribute that only applies
6926 to types is applied to a declaration, it is treated as applying to
6927 the type of that declaration. If an attribute that only applies to
6928 declarations is applied to the type of a declaration, it is treated
6929 as applying to that declaration; and, for compatibility with code
6930 placing the attributes immediately before the identifier declared, such
6931 an attribute applied to a function return type is treated as
6932 applying to the function type, and such an attribute applied to an array
6933 element type is treated as applying to the array type. If an
6934 attribute that only applies to function types is applied to a
6935 pointer-to-function type, it is treated as applying to the pointer
6936 target type; if such an attribute is applied to a function return type
6937 that is not a pointer-to-function type, it is treated as applying
6938 to the function type.
6939
6940 @node Function Prototypes
6941 @section Prototypes and Old-Style Function Definitions
6942 @cindex function prototype declarations
6943 @cindex old-style function definitions
6944 @cindex promotion of formal parameters
6945
6946 GNU C extends ISO C to allow a function prototype to override a later
6947 old-style non-prototype definition. Consider the following example:
6948
6949 @smallexample
6950 /* @r{Use prototypes unless the compiler is old-fashioned.} */
6951 #ifdef __STDC__
6952 #define P(x) x
6953 #else
6954 #define P(x) ()
6955 #endif
6956
6957 /* @r{Prototype function declaration.} */
6958 int isroot P((uid_t));
6959
6960 /* @r{Old-style function definition.} */
6961 int
6962 isroot (x) /* @r{??? lossage here ???} */
6963 uid_t x;
6964 @{
6965 return x == 0;
6966 @}
6967 @end smallexample
6968
6969 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
6970 not allow this example, because subword arguments in old-style
6971 non-prototype definitions are promoted. Therefore in this example the
6972 function definition's argument is really an @code{int}, which does not
6973 match the prototype argument type of @code{short}.
6974
6975 This restriction of ISO C makes it hard to write code that is portable
6976 to traditional C compilers, because the programmer does not know
6977 whether the @code{uid_t} type is @code{short}, @code{int}, or
6978 @code{long}. Therefore, in cases like these GNU C allows a prototype
6979 to override a later old-style definition. More precisely, in GNU C, a
6980 function prototype argument type overrides the argument type specified
6981 by a later old-style definition if the former type is the same as the
6982 latter type before promotion. Thus in GNU C the above example is
6983 equivalent to the following:
6984
6985 @smallexample
6986 int isroot (uid_t);
6987
6988 int
6989 isroot (uid_t x)
6990 @{
6991 return x == 0;
6992 @}
6993 @end smallexample
6994
6995 @noindent
6996 GNU C++ does not support old-style function definitions, so this
6997 extension is irrelevant.
6998
6999 @node C++ Comments
7000 @section C++ Style Comments
7001 @cindex @code{//}
7002 @cindex C++ comments
7003 @cindex comments, C++ style
7004
7005 In GNU C, you may use C++ style comments, which start with @samp{//} and
7006 continue until the end of the line. Many other C implementations allow
7007 such comments, and they are included in the 1999 C standard. However,
7008 C++ style comments are not recognized if you specify an @option{-std}
7009 option specifying a version of ISO C before C99, or @option{-ansi}
7010 (equivalent to @option{-std=c90}).
7011
7012 @node Dollar Signs
7013 @section Dollar Signs in Identifier Names
7014 @cindex $
7015 @cindex dollar signs in identifier names
7016 @cindex identifier names, dollar signs in
7017
7018 In GNU C, you may normally use dollar signs in identifier names.
7019 This is because many traditional C implementations allow such identifiers.
7020 However, dollar signs in identifiers are not supported on a few target
7021 machines, typically because the target assembler does not allow them.
7022
7023 @node Character Escapes
7024 @section The Character @key{ESC} in Constants
7025
7026 You can use the sequence @samp{\e} in a string or character constant to
7027 stand for the ASCII character @key{ESC}.
7028
7029 @node Alignment
7030 @section Inquiring on Alignment of Types or Variables
7031 @cindex alignment
7032 @cindex type alignment
7033 @cindex variable alignment
7034
7035 The keyword @code{__alignof__} allows you to inquire about how an object
7036 is aligned, or the minimum alignment usually required by a type. Its
7037 syntax is just like @code{sizeof}.
7038
7039 For example, if the target machine requires a @code{double} value to be
7040 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7041 This is true on many RISC machines. On more traditional machine
7042 designs, @code{__alignof__ (double)} is 4 or even 2.
7043
7044 Some machines never actually require alignment; they allow reference to any
7045 data type even at an odd address. For these machines, @code{__alignof__}
7046 reports the smallest alignment that GCC gives the data type, usually as
7047 mandated by the target ABI.
7048
7049 If the operand of @code{__alignof__} is an lvalue rather than a type,
7050 its value is the required alignment for its type, taking into account
7051 any minimum alignment specified with GCC's @code{__attribute__}
7052 extension (@pxref{Variable Attributes}). For example, after this
7053 declaration:
7054
7055 @smallexample
7056 struct foo @{ int x; char y; @} foo1;
7057 @end smallexample
7058
7059 @noindent
7060 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7061 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7062
7063 It is an error to ask for the alignment of an incomplete type.
7064
7065
7066 @node Inline
7067 @section An Inline Function is As Fast As a Macro
7068 @cindex inline functions
7069 @cindex integrating function code
7070 @cindex open coding
7071 @cindex macros, inline alternative
7072
7073 By declaring a function inline, you can direct GCC to make
7074 calls to that function faster. One way GCC can achieve this is to
7075 integrate that function's code into the code for its callers. This
7076 makes execution faster by eliminating the function-call overhead; in
7077 addition, if any of the actual argument values are constant, their
7078 known values may permit simplifications at compile time so that not
7079 all of the inline function's code needs to be included. The effect on
7080 code size is less predictable; object code may be larger or smaller
7081 with function inlining, depending on the particular case. You can
7082 also direct GCC to try to integrate all ``simple enough'' functions
7083 into their callers with the option @option{-finline-functions}.
7084
7085 GCC implements three different semantics of declaring a function
7086 inline. One is available with @option{-std=gnu89} or
7087 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7088 on all inline declarations, another when
7089 @option{-std=c99}, @option{-std=c11},
7090 @option{-std=gnu99} or @option{-std=gnu11}
7091 (without @option{-fgnu89-inline}), and the third
7092 is used when compiling C++.
7093
7094 To declare a function inline, use the @code{inline} keyword in its
7095 declaration, like this:
7096
7097 @smallexample
7098 static inline int
7099 inc (int *a)
7100 @{
7101 return (*a)++;
7102 @}
7103 @end smallexample
7104
7105 If you are writing a header file to be included in ISO C90 programs, write
7106 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7107
7108 The three types of inlining behave similarly in two important cases:
7109 when the @code{inline} keyword is used on a @code{static} function,
7110 like the example above, and when a function is first declared without
7111 using the @code{inline} keyword and then is defined with
7112 @code{inline}, like this:
7113
7114 @smallexample
7115 extern int inc (int *a);
7116 inline int
7117 inc (int *a)
7118 @{
7119 return (*a)++;
7120 @}
7121 @end smallexample
7122
7123 In both of these common cases, the program behaves the same as if you
7124 had not used the @code{inline} keyword, except for its speed.
7125
7126 @cindex inline functions, omission of
7127 @opindex fkeep-inline-functions
7128 When a function is both inline and @code{static}, if all calls to the
7129 function are integrated into the caller, and the function's address is
7130 never used, then the function's own assembler code is never referenced.
7131 In this case, GCC does not actually output assembler code for the
7132 function, unless you specify the option @option{-fkeep-inline-functions}.
7133 If there is a nonintegrated call, then the function is compiled to
7134 assembler code as usual. The function must also be compiled as usual if
7135 the program refers to its address, because that can't be inlined.
7136
7137 @opindex Winline
7138 Note that certain usages in a function definition can make it unsuitable
7139 for inline substitution. Among these usages are: variadic functions,
7140 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7141 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7142 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7143 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7144 function marked @code{inline} could not be substituted, and gives the
7145 reason for the failure.
7146
7147 @cindex automatic @code{inline} for C++ member fns
7148 @cindex @code{inline} automatic for C++ member fns
7149 @cindex member fns, automatically @code{inline}
7150 @cindex C++ member fns, automatically @code{inline}
7151 @opindex fno-default-inline
7152 As required by ISO C++, GCC considers member functions defined within
7153 the body of a class to be marked inline even if they are
7154 not explicitly declared with the @code{inline} keyword. You can
7155 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7156 Options,,Options Controlling C++ Dialect}.
7157
7158 GCC does not inline any functions when not optimizing unless you specify
7159 the @samp{always_inline} attribute for the function, like this:
7160
7161 @smallexample
7162 /* @r{Prototype.} */
7163 inline void foo (const char) __attribute__((always_inline));
7164 @end smallexample
7165
7166 The remainder of this section is specific to GNU C90 inlining.
7167
7168 @cindex non-static inline function
7169 When an inline function is not @code{static}, then the compiler must assume
7170 that there may be calls from other source files; since a global symbol can
7171 be defined only once in any program, the function must not be defined in
7172 the other source files, so the calls therein cannot be integrated.
7173 Therefore, a non-@code{static} inline function is always compiled on its
7174 own in the usual fashion.
7175
7176 If you specify both @code{inline} and @code{extern} in the function
7177 definition, then the definition is used only for inlining. In no case
7178 is the function compiled on its own, not even if you refer to its
7179 address explicitly. Such an address becomes an external reference, as
7180 if you had only declared the function, and had not defined it.
7181
7182 This combination of @code{inline} and @code{extern} has almost the
7183 effect of a macro. The way to use it is to put a function definition in
7184 a header file with these keywords, and put another copy of the
7185 definition (lacking @code{inline} and @code{extern}) in a library file.
7186 The definition in the header file causes most calls to the function
7187 to be inlined. If any uses of the function remain, they refer to
7188 the single copy in the library.
7189
7190 @node Volatiles
7191 @section When is a Volatile Object Accessed?
7192 @cindex accessing volatiles
7193 @cindex volatile read
7194 @cindex volatile write
7195 @cindex volatile access
7196
7197 C has the concept of volatile objects. These are normally accessed by
7198 pointers and used for accessing hardware or inter-thread
7199 communication. The standard encourages compilers to refrain from
7200 optimizations concerning accesses to volatile objects, but leaves it
7201 implementation defined as to what constitutes a volatile access. The
7202 minimum requirement is that at a sequence point all previous accesses
7203 to volatile objects have stabilized and no subsequent accesses have
7204 occurred. Thus an implementation is free to reorder and combine
7205 volatile accesses that occur between sequence points, but cannot do
7206 so for accesses across a sequence point. The use of volatile does
7207 not allow you to violate the restriction on updating objects multiple
7208 times between two sequence points.
7209
7210 Accesses to non-volatile objects are not ordered with respect to
7211 volatile accesses. You cannot use a volatile object as a memory
7212 barrier to order a sequence of writes to non-volatile memory. For
7213 instance:
7214
7215 @smallexample
7216 int *ptr = @var{something};
7217 volatile int vobj;
7218 *ptr = @var{something};
7219 vobj = 1;
7220 @end smallexample
7221
7222 @noindent
7223 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7224 that the write to @var{*ptr} occurs by the time the update
7225 of @var{vobj} happens. If you need this guarantee, you must use
7226 a stronger memory barrier such as:
7227
7228 @smallexample
7229 int *ptr = @var{something};
7230 volatile int vobj;
7231 *ptr = @var{something};
7232 asm volatile ("" : : : "memory");
7233 vobj = 1;
7234 @end smallexample
7235
7236 A scalar volatile object is read when it is accessed in a void context:
7237
7238 @smallexample
7239 volatile int *src = @var{somevalue};
7240 *src;
7241 @end smallexample
7242
7243 Such expressions are rvalues, and GCC implements this as a
7244 read of the volatile object being pointed to.
7245
7246 Assignments are also expressions and have an rvalue. However when
7247 assigning to a scalar volatile, the volatile object is not reread,
7248 regardless of whether the assignment expression's rvalue is used or
7249 not. If the assignment's rvalue is used, the value is that assigned
7250 to the volatile object. For instance, there is no read of @var{vobj}
7251 in all the following cases:
7252
7253 @smallexample
7254 int obj;
7255 volatile int vobj;
7256 vobj = @var{something};
7257 obj = vobj = @var{something};
7258 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7259 obj = (@var{something}, vobj = @var{anotherthing});
7260 @end smallexample
7261
7262 If you need to read the volatile object after an assignment has
7263 occurred, you must use a separate expression with an intervening
7264 sequence point.
7265
7266 As bit-fields are not individually addressable, volatile bit-fields may
7267 be implicitly read when written to, or when adjacent bit-fields are
7268 accessed. Bit-field operations may be optimized such that adjacent
7269 bit-fields are only partially accessed, if they straddle a storage unit
7270 boundary. For these reasons it is unwise to use volatile bit-fields to
7271 access hardware.
7272
7273 @node Using Assembly Language with C
7274 @section How to Use Inline Assembly Language in C Code
7275 @cindex @code{asm} keyword
7276 @cindex assembly language in C
7277 @cindex inline assembly language
7278 @cindex mixing assembly language and C
7279
7280 The @code{asm} keyword allows you to embed assembler instructions
7281 within C code. GCC provides two forms of inline @code{asm}
7282 statements. A @dfn{basic @code{asm}} statement is one with no
7283 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7284 statement (@pxref{Extended Asm}) includes one or more operands.
7285 The extended form is preferred for mixing C and assembly language
7286 within a function, but to include assembly language at
7287 top level you must use basic @code{asm}.
7288
7289 You can also use the @code{asm} keyword to override the assembler name
7290 for a C symbol, or to place a C variable in a specific register.
7291
7292 @menu
7293 * Basic Asm:: Inline assembler without operands.
7294 * Extended Asm:: Inline assembler with operands.
7295 * Constraints:: Constraints for @code{asm} operands
7296 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7297 * Explicit Register Variables:: Defining variables residing in specified
7298 registers.
7299 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7300 @end menu
7301
7302 @node Basic Asm
7303 @subsection Basic Asm --- Assembler Instructions Without Operands
7304 @cindex basic @code{asm}
7305 @cindex assembly language in C, basic
7306
7307 A basic @code{asm} statement has the following syntax:
7308
7309 @example
7310 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7311 @end example
7312
7313 The @code{asm} keyword is a GNU extension.
7314 When writing code that can be compiled with @option{-ansi} and the
7315 various @option{-std} options, use @code{__asm__} instead of
7316 @code{asm} (@pxref{Alternate Keywords}).
7317
7318 @subsubheading Qualifiers
7319 @table @code
7320 @item volatile
7321 The optional @code{volatile} qualifier has no effect.
7322 All basic @code{asm} blocks are implicitly volatile.
7323 @end table
7324
7325 @subsubheading Parameters
7326 @table @var
7327
7328 @item AssemblerInstructions
7329 This is a literal string that specifies the assembler code. The string can
7330 contain any instructions recognized by the assembler, including directives.
7331 GCC does not parse the assembler instructions themselves and
7332 does not know what they mean or even whether they are valid assembler input.
7333
7334 You may place multiple assembler instructions together in a single @code{asm}
7335 string, separated by the characters normally used in assembly code for the
7336 system. A combination that works in most places is a newline to break the
7337 line, plus a tab character (written as @samp{\n\t}).
7338 Some assemblers allow semicolons as a line separator. However,
7339 note that some assembler dialects use semicolons to start a comment.
7340 @end table
7341
7342 @subsubheading Remarks
7343 Using extended @code{asm} typically produces smaller, safer, and more
7344 efficient code, and in most cases it is a better solution than basic
7345 @code{asm}. However, there are two situations where only basic @code{asm}
7346 can be used:
7347
7348 @itemize @bullet
7349 @item
7350 Extended @code{asm} statements have to be inside a C
7351 function, so to write inline assembly language at file scope (``top-level''),
7352 outside of C functions, you must use basic @code{asm}.
7353 You can use this technique to emit assembler directives,
7354 define assembly language macros that can be invoked elsewhere in the file,
7355 or write entire functions in assembly language.
7356
7357 @item
7358 Functions declared
7359 with the @code{naked} attribute also require basic @code{asm}
7360 (@pxref{Function Attributes}).
7361 @end itemize
7362
7363 Safely accessing C data and calling functions from basic @code{asm} is more
7364 complex than it may appear. To access C data, it is better to use extended
7365 @code{asm}.
7366
7367 Do not expect a sequence of @code{asm} statements to remain perfectly
7368 consecutive after compilation. If certain instructions need to remain
7369 consecutive in the output, put them in a single multi-instruction @code{asm}
7370 statement. Note that GCC's optimizers can move @code{asm} statements
7371 relative to other code, including across jumps.
7372
7373 @code{asm} statements may not perform jumps into other @code{asm} statements.
7374 GCC does not know about these jumps, and therefore cannot take
7375 account of them when deciding how to optimize. Jumps from @code{asm} to C
7376 labels are only supported in extended @code{asm}.
7377
7378 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7379 assembly code when optimizing. This can lead to unexpected duplicate
7380 symbol errors during compilation if your assembly code defines symbols or
7381 labels.
7382
7383 Since GCC does not parse the @var{AssemblerInstructions}, it has no
7384 visibility of any symbols it references. This may result in GCC discarding
7385 those symbols as unreferenced.
7386
7387 The compiler copies the assembler instructions in a basic @code{asm}
7388 verbatim to the assembly language output file, without
7389 processing dialects or any of the @samp{%} operators that are available with
7390 extended @code{asm}. This results in minor differences between basic
7391 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7392 registers you might use @samp{%eax} in basic @code{asm} and
7393 @samp{%%eax} in extended @code{asm}.
7394
7395 On targets such as x86 that support multiple assembler dialects,
7396 all basic @code{asm} blocks use the assembler dialect specified by the
7397 @option{-masm} command-line option (@pxref{x86 Options}).
7398 Basic @code{asm} provides no
7399 mechanism to provide different assembler strings for different dialects.
7400
7401 Here is an example of basic @code{asm} for i386:
7402
7403 @example
7404 /* Note that this code will not compile with -masm=intel */
7405 #define DebugBreak() asm("int $3")
7406 @end example
7407
7408 @node Extended Asm
7409 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7410 @cindex extended @code{asm}
7411 @cindex assembly language in C, extended
7412
7413 With extended @code{asm} you can read and write C variables from
7414 assembler and perform jumps from assembler code to C labels.
7415 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7416 the operand parameters after the assembler template:
7417
7418 @example
7419 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7420 : @var{OutputOperands}
7421 @r{[} : @var{InputOperands}
7422 @r{[} : @var{Clobbers} @r{]} @r{]})
7423
7424 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7425 :
7426 : @var{InputOperands}
7427 : @var{Clobbers}
7428 : @var{GotoLabels})
7429 @end example
7430
7431 The @code{asm} keyword is a GNU extension.
7432 When writing code that can be compiled with @option{-ansi} and the
7433 various @option{-std} options, use @code{__asm__} instead of
7434 @code{asm} (@pxref{Alternate Keywords}).
7435
7436 @subsubheading Qualifiers
7437 @table @code
7438
7439 @item volatile
7440 The typical use of extended @code{asm} statements is to manipulate input
7441 values to produce output values. However, your @code{asm} statements may
7442 also produce side effects. If so, you may need to use the @code{volatile}
7443 qualifier to disable certain optimizations. @xref{Volatile}.
7444
7445 @item goto
7446 This qualifier informs the compiler that the @code{asm} statement may
7447 perform a jump to one of the labels listed in the @var{GotoLabels}.
7448 @xref{GotoLabels}.
7449 @end table
7450
7451 @subsubheading Parameters
7452 @table @var
7453 @item AssemblerTemplate
7454 This is a literal string that is the template for the assembler code. It is a
7455 combination of fixed text and tokens that refer to the input, output,
7456 and goto parameters. @xref{AssemblerTemplate}.
7457
7458 @item OutputOperands
7459 A comma-separated list of the C variables modified by the instructions in the
7460 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7461
7462 @item InputOperands
7463 A comma-separated list of C expressions read by the instructions in the
7464 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7465
7466 @item Clobbers
7467 A comma-separated list of registers or other values changed by the
7468 @var{AssemblerTemplate}, beyond those listed as outputs.
7469 An empty list is permitted. @xref{Clobbers}.
7470
7471 @item GotoLabels
7472 When you are using the @code{goto} form of @code{asm}, this section contains
7473 the list of all C labels to which the code in the
7474 @var{AssemblerTemplate} may jump.
7475 @xref{GotoLabels}.
7476
7477 @code{asm} statements may not perform jumps into other @code{asm} statements,
7478 only to the listed @var{GotoLabels}.
7479 GCC's optimizers do not know about other jumps; therefore they cannot take
7480 account of them when deciding how to optimize.
7481 @end table
7482
7483 The total number of input + output + goto operands is limited to 30.
7484
7485 @subsubheading Remarks
7486 The @code{asm} statement allows you to include assembly instructions directly
7487 within C code. This may help you to maximize performance in time-sensitive
7488 code or to access assembly instructions that are not readily available to C
7489 programs.
7490
7491 Note that extended @code{asm} statements must be inside a function. Only
7492 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7493 Functions declared with the @code{naked} attribute also require basic
7494 @code{asm} (@pxref{Function Attributes}).
7495
7496 While the uses of @code{asm} are many and varied, it may help to think of an
7497 @code{asm} statement as a series of low-level instructions that convert input
7498 parameters to output parameters. So a simple (if not particularly useful)
7499 example for i386 using @code{asm} might look like this:
7500
7501 @example
7502 int src = 1;
7503 int dst;
7504
7505 asm ("mov %1, %0\n\t"
7506 "add $1, %0"
7507 : "=r" (dst)
7508 : "r" (src));
7509
7510 printf("%d\n", dst);
7511 @end example
7512
7513 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7514
7515 @anchor{Volatile}
7516 @subsubsection Volatile
7517 @cindex volatile @code{asm}
7518 @cindex @code{asm} volatile
7519
7520 GCC's optimizers sometimes discard @code{asm} statements if they determine
7521 there is no need for the output variables. Also, the optimizers may move
7522 code out of loops if they believe that the code will always return the same
7523 result (i.e. none of its input values change between calls). Using the
7524 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7525 that have no output operands, including @code{asm goto} statements,
7526 are implicitly volatile.
7527
7528 This i386 code demonstrates a case that does not use (or require) the
7529 @code{volatile} qualifier. If it is performing assertion checking, this code
7530 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7531 unreferenced by any code. As a result, the optimizers can discard the
7532 @code{asm} statement, which in turn removes the need for the entire
7533 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7534 isn't needed you allow the optimizers to produce the most efficient code
7535 possible.
7536
7537 @example
7538 void DoCheck(uint32_t dwSomeValue)
7539 @{
7540 uint32_t dwRes;
7541
7542 // Assumes dwSomeValue is not zero.
7543 asm ("bsfl %1,%0"
7544 : "=r" (dwRes)
7545 : "r" (dwSomeValue)
7546 : "cc");
7547
7548 assert(dwRes > 3);
7549 @}
7550 @end example
7551
7552 The next example shows a case where the optimizers can recognize that the input
7553 (@code{dwSomeValue}) never changes during the execution of the function and can
7554 therefore move the @code{asm} outside the loop to produce more efficient code.
7555 Again, using @code{volatile} disables this type of optimization.
7556
7557 @example
7558 void do_print(uint32_t dwSomeValue)
7559 @{
7560 uint32_t dwRes;
7561
7562 for (uint32_t x=0; x < 5; x++)
7563 @{
7564 // Assumes dwSomeValue is not zero.
7565 asm ("bsfl %1,%0"
7566 : "=r" (dwRes)
7567 : "r" (dwSomeValue)
7568 : "cc");
7569
7570 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7571 @}
7572 @}
7573 @end example
7574
7575 The following example demonstrates a case where you need to use the
7576 @code{volatile} qualifier.
7577 It uses the x86 @code{rdtsc} instruction, which reads
7578 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7579 the optimizers might assume that the @code{asm} block will always return the
7580 same value and therefore optimize away the second call.
7581
7582 @example
7583 uint64_t msr;
7584
7585 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7586 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7587 "or %%rdx, %0" // 'Or' in the lower bits.
7588 : "=a" (msr)
7589 :
7590 : "rdx");
7591
7592 printf("msr: %llx\n", msr);
7593
7594 // Do other work...
7595
7596 // Reprint the timestamp
7597 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7598 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7599 "or %%rdx, %0" // 'Or' in the lower bits.
7600 : "=a" (msr)
7601 :
7602 : "rdx");
7603
7604 printf("msr: %llx\n", msr);
7605 @end example
7606
7607 GCC's optimizers do not treat this code like the non-volatile code in the
7608 earlier examples. They do not move it out of loops or omit it on the
7609 assumption that the result from a previous call is still valid.
7610
7611 Note that the compiler can move even volatile @code{asm} instructions relative
7612 to other code, including across jump instructions. For example, on many
7613 targets there is a system register that controls the rounding mode of
7614 floating-point operations. Setting it with a volatile @code{asm}, as in the
7615 following PowerPC example, does not work reliably.
7616
7617 @example
7618 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7619 sum = x + y;
7620 @end example
7621
7622 The compiler may move the addition back before the volatile @code{asm}. To
7623 make it work as expected, add an artificial dependency to the @code{asm} by
7624 referencing a variable in the subsequent code, for example:
7625
7626 @example
7627 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7628 sum = x + y;
7629 @end example
7630
7631 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7632 assembly code when optimizing. This can lead to unexpected duplicate symbol
7633 errors during compilation if your asm code defines symbols or labels.
7634 Using @samp{%=}
7635 (@pxref{AssemblerTemplate}) may help resolve this problem.
7636
7637 @anchor{AssemblerTemplate}
7638 @subsubsection Assembler Template
7639 @cindex @code{asm} assembler template
7640
7641 An assembler template is a literal string containing assembler instructions.
7642 The compiler replaces tokens in the template that refer
7643 to inputs, outputs, and goto labels,
7644 and then outputs the resulting string to the assembler. The
7645 string can contain any instructions recognized by the assembler, including
7646 directives. GCC does not parse the assembler instructions
7647 themselves and does not know what they mean or even whether they are valid
7648 assembler input. However, it does count the statements
7649 (@pxref{Size of an asm}).
7650
7651 You may place multiple assembler instructions together in a single @code{asm}
7652 string, separated by the characters normally used in assembly code for the
7653 system. A combination that works in most places is a newline to break the
7654 line, plus a tab character to move to the instruction field (written as
7655 @samp{\n\t}).
7656 Some assemblers allow semicolons as a line separator. However, note
7657 that some assembler dialects use semicolons to start a comment.
7658
7659 Do not expect a sequence of @code{asm} statements to remain perfectly
7660 consecutive after compilation, even when you are using the @code{volatile}
7661 qualifier. If certain instructions need to remain consecutive in the output,
7662 put them in a single multi-instruction asm statement.
7663
7664 Accessing data from C programs without using input/output operands (such as
7665 by using global symbols directly from the assembler template) may not work as
7666 expected. Similarly, calling functions directly from an assembler template
7667 requires a detailed understanding of the target assembler and ABI.
7668
7669 Since GCC does not parse the assembler template,
7670 it has no visibility of any
7671 symbols it references. This may result in GCC discarding those symbols as
7672 unreferenced unless they are also listed as input, output, or goto operands.
7673
7674 @subsubheading Special format strings
7675
7676 In addition to the tokens described by the input, output, and goto operands,
7677 these tokens have special meanings in the assembler template:
7678
7679 @table @samp
7680 @item %%
7681 Outputs a single @samp{%} into the assembler code.
7682
7683 @item %=
7684 Outputs a number that is unique to each instance of the @code{asm}
7685 statement in the entire compilation. This option is useful when creating local
7686 labels and referring to them multiple times in a single template that
7687 generates multiple assembler instructions.
7688
7689 @item %@{
7690 @itemx %|
7691 @itemx %@}
7692 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7693 into the assembler code. When unescaped, these characters have special
7694 meaning to indicate multiple assembler dialects, as described below.
7695 @end table
7696
7697 @subsubheading Multiple assembler dialects in @code{asm} templates
7698
7699 On targets such as x86, GCC supports multiple assembler dialects.
7700 The @option{-masm} option controls which dialect GCC uses as its
7701 default for inline assembler. The target-specific documentation for the
7702 @option{-masm} option contains the list of supported dialects, as well as the
7703 default dialect if the option is not specified. This information may be
7704 important to understand, since assembler code that works correctly when
7705 compiled using one dialect will likely fail if compiled using another.
7706 @xref{x86 Options}.
7707
7708 If your code needs to support multiple assembler dialects (for example, if
7709 you are writing public headers that need to support a variety of compilation
7710 options), use constructs of this form:
7711
7712 @example
7713 @{ dialect0 | dialect1 | dialect2... @}
7714 @end example
7715
7716 This construct outputs @code{dialect0}
7717 when using dialect #0 to compile the code,
7718 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7719 braces than the number of dialects the compiler supports, the construct
7720 outputs nothing.
7721
7722 For example, if an x86 compiler supports two dialects
7723 (@samp{att}, @samp{intel}), an
7724 assembler template such as this:
7725
7726 @example
7727 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7728 @end example
7729
7730 @noindent
7731 is equivalent to one of
7732
7733 @example
7734 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7735 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7736 @end example
7737
7738 Using that same compiler, this code:
7739
7740 @example
7741 "xchg@{l@}\t@{%%@}ebx, %1"
7742 @end example
7743
7744 @noindent
7745 corresponds to either
7746
7747 @example
7748 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7749 "xchg\tebx, %1" @r{/* intel dialect */}
7750 @end example
7751
7752 There is no support for nesting dialect alternatives.
7753
7754 @anchor{OutputOperands}
7755 @subsubsection Output Operands
7756 @cindex @code{asm} output operands
7757
7758 An @code{asm} statement has zero or more output operands indicating the names
7759 of C variables modified by the assembler code.
7760
7761 In this i386 example, @code{old} (referred to in the template string as
7762 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7763 (@code{%2}) is an input:
7764
7765 @example
7766 bool old;
7767
7768 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7769 "sbb %0,%0" // Use the CF to calculate old.
7770 : "=r" (old), "+rm" (*Base)
7771 : "Ir" (Offset)
7772 : "cc");
7773
7774 return old;
7775 @end example
7776
7777 Operands are separated by commas. Each operand has this format:
7778
7779 @example
7780 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7781 @end example
7782
7783 @table @var
7784 @item asmSymbolicName
7785 Specifies a symbolic name for the operand.
7786 Reference the name in the assembler template
7787 by enclosing it in square brackets
7788 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7789 that contains the definition. Any valid C variable name is acceptable,
7790 including names already defined in the surrounding code. No two operands
7791 within the same @code{asm} statement can use the same symbolic name.
7792
7793 When not using an @var{asmSymbolicName}, use the (zero-based) position
7794 of the operand
7795 in the list of operands in the assembler template. For example if there are
7796 three output operands, use @samp{%0} in the template to refer to the first,
7797 @samp{%1} for the second, and @samp{%2} for the third.
7798
7799 @item constraint
7800 A string constant specifying constraints on the placement of the operand;
7801 @xref{Constraints}, for details.
7802
7803 Output constraints must begin with either @samp{=} (a variable overwriting an
7804 existing value) or @samp{+} (when reading and writing). When using
7805 @samp{=}, do not assume the location contains the existing value
7806 on entry to the @code{asm}, except
7807 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7808
7809 After the prefix, there must be one or more additional constraints
7810 (@pxref{Constraints}) that describe where the value resides. Common
7811 constraints include @samp{r} for register and @samp{m} for memory.
7812 When you list more than one possible location (for example, @code{"=rm"}),
7813 the compiler chooses the most efficient one based on the current context.
7814 If you list as many alternates as the @code{asm} statement allows, you permit
7815 the optimizers to produce the best possible code.
7816 If you must use a specific register, but your Machine Constraints do not
7817 provide sufficient control to select the specific register you want,
7818 local register variables may provide a solution (@pxref{Local Register
7819 Variables}).
7820
7821 @item cvariablename
7822 Specifies a C lvalue expression to hold the output, typically a variable name.
7823 The enclosing parentheses are a required part of the syntax.
7824
7825 @end table
7826
7827 When the compiler selects the registers to use to
7828 represent the output operands, it does not use any of the clobbered registers
7829 (@pxref{Clobbers}).
7830
7831 Output operand expressions must be lvalues. The compiler cannot check whether
7832 the operands have data types that are reasonable for the instruction being
7833 executed. For output expressions that are not directly addressable (for
7834 example a bit-field), the constraint must allow a register. In that case, GCC
7835 uses the register as the output of the @code{asm}, and then stores that
7836 register into the output.
7837
7838 Operands using the @samp{+} constraint modifier count as two operands
7839 (that is, both as input and output) towards the total maximum of 30 operands
7840 per @code{asm} statement.
7841
7842 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7843 operands that must not overlap an input. Otherwise,
7844 GCC may allocate the output operand in the same register as an unrelated
7845 input operand, on the assumption that the assembler code consumes its
7846 inputs before producing outputs. This assumption may be false if the assembler
7847 code actually consists of more than one instruction.
7848
7849 The same problem can occur if one output parameter (@var{a}) allows a register
7850 constraint and another output parameter (@var{b}) allows a memory constraint.
7851 The code generated by GCC to access the memory address in @var{b} can contain
7852 registers which @emph{might} be shared by @var{a}, and GCC considers those
7853 registers to be inputs to the asm. As above, GCC assumes that such input
7854 registers are consumed before any outputs are written. This assumption may
7855 result in incorrect behavior if the asm writes to @var{a} before using
7856 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7857 ensures that modifying @var{a} does not affect the address referenced by
7858 @var{b}. Otherwise, the location of @var{b}
7859 is undefined if @var{a} is modified before using @var{b}.
7860
7861 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
7862 instead of simply @samp{%2}). Typically these qualifiers are hardware
7863 dependent. The list of supported modifiers for x86 is found at
7864 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7865
7866 If the C code that follows the @code{asm} makes no use of any of the output
7867 operands, use @code{volatile} for the @code{asm} statement to prevent the
7868 optimizers from discarding the @code{asm} statement as unneeded
7869 (see @ref{Volatile}).
7870
7871 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
7872 references the first output operand as @code{%0} (were there a second, it
7873 would be @code{%1}, etc). The number of the first input operand is one greater
7874 than that of the last output operand. In this i386 example, that makes
7875 @code{Mask} referenced as @code{%1}:
7876
7877 @example
7878 uint32_t Mask = 1234;
7879 uint32_t Index;
7880
7881 asm ("bsfl %1, %0"
7882 : "=r" (Index)
7883 : "r" (Mask)
7884 : "cc");
7885 @end example
7886
7887 That code overwrites the variable @code{Index} (@samp{=}),
7888 placing the value in a register (@samp{r}).
7889 Using the generic @samp{r} constraint instead of a constraint for a specific
7890 register allows the compiler to pick the register to use, which can result
7891 in more efficient code. This may not be possible if an assembler instruction
7892 requires a specific register.
7893
7894 The following i386 example uses the @var{asmSymbolicName} syntax.
7895 It produces the
7896 same result as the code above, but some may consider it more readable or more
7897 maintainable since reordering index numbers is not necessary when adding or
7898 removing operands. The names @code{aIndex} and @code{aMask}
7899 are only used in this example to emphasize which
7900 names get used where.
7901 It is acceptable to reuse the names @code{Index} and @code{Mask}.
7902
7903 @example
7904 uint32_t Mask = 1234;
7905 uint32_t Index;
7906
7907 asm ("bsfl %[aMask], %[aIndex]"
7908 : [aIndex] "=r" (Index)
7909 : [aMask] "r" (Mask)
7910 : "cc");
7911 @end example
7912
7913 Here are some more examples of output operands.
7914
7915 @example
7916 uint32_t c = 1;
7917 uint32_t d;
7918 uint32_t *e = &c;
7919
7920 asm ("mov %[e], %[d]"
7921 : [d] "=rm" (d)
7922 : [e] "rm" (*e));
7923 @end example
7924
7925 Here, @code{d} may either be in a register or in memory. Since the compiler
7926 might already have the current value of the @code{uint32_t} location
7927 pointed to by @code{e}
7928 in a register, you can enable it to choose the best location
7929 for @code{d} by specifying both constraints.
7930
7931 @anchor{FlagOutputOperands}
7932 @subsection Flag Output Operands
7933 @cindex @code{asm} flag output operands
7934
7935 Some targets have a special register that holds the ``flags'' for the
7936 result of an operation or comparison. Normally, the contents of that
7937 register are either unmodifed by the asm, or the asm is considered to
7938 clobber the contents.
7939
7940 On some targets, a special form of output operand exists by which
7941 conditions in the flags register may be outputs of the asm. The set of
7942 conditions supported are target specific, but the general rule is that
7943 the output variable must be a scalar integer, and the value will be boolean.
7944 When supported, the target will define the preprocessor symbol
7945 @code{__GCC_ASM_FLAG_OUTPUTS__}.
7946
7947 Because of the special nature of the flag output operands, the constraint
7948 may not include alternatives.
7949
7950 Most often, the target has only one flags register, and thus is an implied
7951 operand of many instructions. In this case, the operand should not be
7952 referenced within the assembler template via @code{%0} etc, as there's
7953 no corresponding text in the assembly language.
7954
7955 @table @asis
7956 @item x86 family
7957 The flag output constraints for the x86 family are of the form
7958 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
7959 conditions defined in the ISA manual for @code{j@var{cc}} or
7960 @code{set@var{cc}}.
7961
7962 @table @code
7963 @item a
7964 ``above'' or unsigned greater than
7965 @item ae
7966 ``above or equal'' or unsigned greater than or equal
7967 @item b
7968 ``below'' or unsigned less than
7969 @item be
7970 ``below or equal'' or unsigned less than or equal
7971 @item c
7972 carry flag set
7973 @item e
7974 @itemx z
7975 ``equal'' or zero flag set
7976 @item g
7977 signed greater than
7978 @item ge
7979 signed greater than or equal
7980 @item l
7981 signed less than
7982 @item le
7983 signed less than or equal
7984 @item o
7985 overflow flag set
7986 @item p
7987 parity flag set
7988 @item s
7989 sign flag set
7990 @item na
7991 @itemx nae
7992 @itemx nb
7993 @itemx nbe
7994 @itemx nc
7995 @itemx ne
7996 @itemx ng
7997 @itemx nge
7998 @itemx nl
7999 @itemx nle
8000 @itemx no
8001 @itemx np
8002 @itemx ns
8003 @itemx nz
8004 ``not'' @var{flag}, or inverted versions of those above
8005 @end table
8006
8007 @end table
8008
8009 @anchor{InputOperands}
8010 @subsubsection Input Operands
8011 @cindex @code{asm} input operands
8012 @cindex @code{asm} expressions
8013
8014 Input operands make values from C variables and expressions available to the
8015 assembly code.
8016
8017 Operands are separated by commas. Each operand has this format:
8018
8019 @example
8020 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8021 @end example
8022
8023 @table @var
8024 @item asmSymbolicName
8025 Specifies a symbolic name for the operand.
8026 Reference the name in the assembler template
8027 by enclosing it in square brackets
8028 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8029 that contains the definition. Any valid C variable name is acceptable,
8030 including names already defined in the surrounding code. No two operands
8031 within the same @code{asm} statement can use the same symbolic name.
8032
8033 When not using an @var{asmSymbolicName}, use the (zero-based) position
8034 of the operand
8035 in the list of operands in the assembler template. For example if there are
8036 two output operands and three inputs,
8037 use @samp{%2} in the template to refer to the first input operand,
8038 @samp{%3} for the second, and @samp{%4} for the third.
8039
8040 @item constraint
8041 A string constant specifying constraints on the placement of the operand;
8042 @xref{Constraints}, for details.
8043
8044 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8045 When you list more than one possible location (for example, @samp{"irm"}),
8046 the compiler chooses the most efficient one based on the current context.
8047 If you must use a specific register, but your Machine Constraints do not
8048 provide sufficient control to select the specific register you want,
8049 local register variables may provide a solution (@pxref{Local Register
8050 Variables}).
8051
8052 Input constraints can also be digits (for example, @code{"0"}). This indicates
8053 that the specified input must be in the same place as the output constraint
8054 at the (zero-based) index in the output constraint list.
8055 When using @var{asmSymbolicName} syntax for the output operands,
8056 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8057
8058 @item cexpression
8059 This is the C variable or expression being passed to the @code{asm} statement
8060 as input. The enclosing parentheses are a required part of the syntax.
8061
8062 @end table
8063
8064 When the compiler selects the registers to use to represent the input
8065 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8066
8067 If there are no output operands but there are input operands, place two
8068 consecutive colons where the output operands would go:
8069
8070 @example
8071 __asm__ ("some instructions"
8072 : /* No outputs. */
8073 : "r" (Offset / 8));
8074 @end example
8075
8076 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8077 (except for inputs tied to outputs). The compiler assumes that on exit from
8078 the @code{asm} statement these operands contain the same values as they
8079 had before executing the statement.
8080 It is @emph{not} possible to use clobbers
8081 to inform the compiler that the values in these inputs are changing. One
8082 common work-around is to tie the changing input variable to an output variable
8083 that never gets used. Note, however, that if the code that follows the
8084 @code{asm} statement makes no use of any of the output operands, the GCC
8085 optimizers may discard the @code{asm} statement as unneeded
8086 (see @ref{Volatile}).
8087
8088 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8089 instead of simply @samp{%2}). Typically these qualifiers are hardware
8090 dependent. The list of supported modifiers for x86 is found at
8091 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8092
8093 In this example using the fictitious @code{combine} instruction, the
8094 constraint @code{"0"} for input operand 1 says that it must occupy the same
8095 location as output operand 0. Only input operands may use numbers in
8096 constraints, and they must each refer to an output operand. Only a number (or
8097 the symbolic assembler name) in the constraint can guarantee that one operand
8098 is in the same place as another. The mere fact that @code{foo} is the value of
8099 both operands is not enough to guarantee that they are in the same place in
8100 the generated assembler code.
8101
8102 @example
8103 asm ("combine %2, %0"
8104 : "=r" (foo)
8105 : "0" (foo), "g" (bar));
8106 @end example
8107
8108 Here is an example using symbolic names.
8109
8110 @example
8111 asm ("cmoveq %1, %2, %[result]"
8112 : [result] "=r"(result)
8113 : "r" (test), "r" (new), "[result]" (old));
8114 @end example
8115
8116 @anchor{Clobbers}
8117 @subsubsection Clobbers
8118 @cindex @code{asm} clobbers
8119
8120 While the compiler is aware of changes to entries listed in the output
8121 operands, the inline @code{asm} code may modify more than just the outputs. For
8122 example, calculations may require additional registers, or the processor may
8123 overwrite a register as a side effect of a particular assembler instruction.
8124 In order to inform the compiler of these changes, list them in the clobber
8125 list. Clobber list items are either register names or the special clobbers
8126 (listed below). Each clobber list item is a string constant
8127 enclosed in double quotes and separated by commas.
8128
8129 Clobber descriptions may not in any way overlap with an input or output
8130 operand. For example, you may not have an operand describing a register class
8131 with one member when listing that register in the clobber list. Variables
8132 declared to live in specific registers (@pxref{Explicit Register
8133 Variables}) and used
8134 as @code{asm} input or output operands must have no part mentioned in the
8135 clobber description. In particular, there is no way to specify that input
8136 operands get modified without also specifying them as output operands.
8137
8138 When the compiler selects which registers to use to represent input and output
8139 operands, it does not use any of the clobbered registers. As a result,
8140 clobbered registers are available for any use in the assembler code.
8141
8142 Here is a realistic example for the VAX showing the use of clobbered
8143 registers:
8144
8145 @example
8146 asm volatile ("movc3 %0, %1, %2"
8147 : /* No outputs. */
8148 : "g" (from), "g" (to), "g" (count)
8149 : "r0", "r1", "r2", "r3", "r4", "r5");
8150 @end example
8151
8152 Also, there are two special clobber arguments:
8153
8154 @table @code
8155 @item "cc"
8156 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8157 register. On some machines, GCC represents the condition codes as a specific
8158 hardware register; @code{"cc"} serves to name this register.
8159 On other machines, condition code handling is different,
8160 and specifying @code{"cc"} has no effect. But
8161 it is valid no matter what the target.
8162
8163 @item "memory"
8164 The @code{"memory"} clobber tells the compiler that the assembly code
8165 performs memory
8166 reads or writes to items other than those listed in the input and output
8167 operands (for example, accessing the memory pointed to by one of the input
8168 parameters). To ensure memory contains correct values, GCC may need to flush
8169 specific register values to memory before executing the @code{asm}. Further,
8170 the compiler does not assume that any values read from memory before an
8171 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8172 needed.
8173 Using the @code{"memory"} clobber effectively forms a read/write
8174 memory barrier for the compiler.
8175
8176 Note that this clobber does not prevent the @emph{processor} from doing
8177 speculative reads past the @code{asm} statement. To prevent that, you need
8178 processor-specific fence instructions.
8179
8180 Flushing registers to memory has performance implications and may be an issue
8181 for time-sensitive code. You can use a trick to avoid this if the size of
8182 the memory being accessed is known at compile time. For example, if accessing
8183 ten bytes of a string, use a memory input like:
8184
8185 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8186
8187 @end table
8188
8189 @anchor{GotoLabels}
8190 @subsubsection Goto Labels
8191 @cindex @code{asm} goto labels
8192
8193 @code{asm goto} allows assembly code to jump to one or more C labels. The
8194 @var{GotoLabels} section in an @code{asm goto} statement contains
8195 a comma-separated
8196 list of all C labels to which the assembler code may jump. GCC assumes that
8197 @code{asm} execution falls through to the next statement (if this is not the
8198 case, consider using the @code{__builtin_unreachable} intrinsic after the
8199 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8200 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8201 Attributes}).
8202
8203 An @code{asm goto} statement cannot have outputs.
8204 This is due to an internal restriction of
8205 the compiler: control transfer instructions cannot have outputs.
8206 If the assembler code does modify anything, use the @code{"memory"} clobber
8207 to force the
8208 optimizers to flush all register values to memory and reload them if
8209 necessary after the @code{asm} statement.
8210
8211 Also note that an @code{asm goto} statement is always implicitly
8212 considered volatile.
8213
8214 To reference a label in the assembler template,
8215 prefix it with @samp{%l} (lowercase @samp{L}) followed
8216 by its (zero-based) position in @var{GotoLabels} plus the number of input
8217 operands. For example, if the @code{asm} has three inputs and references two
8218 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8219
8220 Alternately, you can reference labels using the actual C label name enclosed
8221 in brackets. For example, to reference a label named @code{carry}, you can
8222 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8223 section when using this approach.
8224
8225 Here is an example of @code{asm goto} for i386:
8226
8227 @example
8228 asm goto (
8229 "btl %1, %0\n\t"
8230 "jc %l2"
8231 : /* No outputs. */
8232 : "r" (p1), "r" (p2)
8233 : "cc"
8234 : carry);
8235
8236 return 0;
8237
8238 carry:
8239 return 1;
8240 @end example
8241
8242 The following example shows an @code{asm goto} that uses a memory clobber.
8243
8244 @example
8245 int frob(int x)
8246 @{
8247 int y;
8248 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8249 : /* No outputs. */
8250 : "r"(x), "r"(&y)
8251 : "r5", "memory"
8252 : error);
8253 return y;
8254 error:
8255 return -1;
8256 @}
8257 @end example
8258
8259 @anchor{x86Operandmodifiers}
8260 @subsubsection x86 Operand Modifiers
8261
8262 References to input, output, and goto operands in the assembler template
8263 of extended @code{asm} statements can use
8264 modifiers to affect the way the operands are formatted in
8265 the code output to the assembler. For example, the
8266 following code uses the @samp{h} and @samp{b} modifiers for x86:
8267
8268 @example
8269 uint16_t num;
8270 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8271 @end example
8272
8273 @noindent
8274 These modifiers generate this assembler code:
8275
8276 @example
8277 xchg %ah, %al
8278 @end example
8279
8280 The rest of this discussion uses the following code for illustrative purposes.
8281
8282 @example
8283 int main()
8284 @{
8285 int iInt = 1;
8286
8287 top:
8288
8289 asm volatile goto ("some assembler instructions here"
8290 : /* No outputs. */
8291 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8292 : /* No clobbers. */
8293 : top);
8294 @}
8295 @end example
8296
8297 With no modifiers, this is what the output from the operands would be for the
8298 @samp{att} and @samp{intel} dialects of assembler:
8299
8300 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8301 @headitem Operand @tab masm=att @tab masm=intel
8302 @item @code{%0}
8303 @tab @code{%eax}
8304 @tab @code{eax}
8305 @item @code{%1}
8306 @tab @code{$2}
8307 @tab @code{2}
8308 @item @code{%2}
8309 @tab @code{$.L2}
8310 @tab @code{OFFSET FLAT:.L2}
8311 @end multitable
8312
8313 The table below shows the list of supported modifiers and their effects.
8314
8315 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8316 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8317 @item @code{z}
8318 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8319 @tab @code{%z0}
8320 @tab @code{l}
8321 @tab
8322 @item @code{b}
8323 @tab Print the QImode name of the register.
8324 @tab @code{%b0}
8325 @tab @code{%al}
8326 @tab @code{al}
8327 @item @code{h}
8328 @tab Print the QImode name for a ``high'' register.
8329 @tab @code{%h0}
8330 @tab @code{%ah}
8331 @tab @code{ah}
8332 @item @code{w}
8333 @tab Print the HImode name of the register.
8334 @tab @code{%w0}
8335 @tab @code{%ax}
8336 @tab @code{ax}
8337 @item @code{k}
8338 @tab Print the SImode name of the register.
8339 @tab @code{%k0}
8340 @tab @code{%eax}
8341 @tab @code{eax}
8342 @item @code{q}
8343 @tab Print the DImode name of the register.
8344 @tab @code{%q0}
8345 @tab @code{%rax}
8346 @tab @code{rax}
8347 @item @code{l}
8348 @tab Print the label name with no punctuation.
8349 @tab @code{%l2}
8350 @tab @code{.L2}
8351 @tab @code{.L2}
8352 @item @code{c}
8353 @tab Require a constant operand and print the constant expression with no punctuation.
8354 @tab @code{%c1}
8355 @tab @code{2}
8356 @tab @code{2}
8357 @end multitable
8358
8359 @anchor{x86floatingpointasmoperands}
8360 @subsubsection x86 Floating-Point @code{asm} Operands
8361
8362 On x86 targets, there are several rules on the usage of stack-like registers
8363 in the operands of an @code{asm}. These rules apply only to the operands
8364 that are stack-like registers:
8365
8366 @enumerate
8367 @item
8368 Given a set of input registers that die in an @code{asm}, it is
8369 necessary to know which are implicitly popped by the @code{asm}, and
8370 which must be explicitly popped by GCC@.
8371
8372 An input register that is implicitly popped by the @code{asm} must be
8373 explicitly clobbered, unless it is constrained to match an
8374 output operand.
8375
8376 @item
8377 For any input register that is implicitly popped by an @code{asm}, it is
8378 necessary to know how to adjust the stack to compensate for the pop.
8379 If any non-popped input is closer to the top of the reg-stack than
8380 the implicitly popped register, it would not be possible to know what the
8381 stack looked like---it's not clear how the rest of the stack ``slides
8382 up''.
8383
8384 All implicitly popped input registers must be closer to the top of
8385 the reg-stack than any input that is not implicitly popped.
8386
8387 It is possible that if an input dies in an @code{asm}, the compiler might
8388 use the input register for an output reload. Consider this example:
8389
8390 @smallexample
8391 asm ("foo" : "=t" (a) : "f" (b));
8392 @end smallexample
8393
8394 @noindent
8395 This code says that input @code{b} is not popped by the @code{asm}, and that
8396 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8397 deeper after the @code{asm} than it was before. But, it is possible that
8398 reload may think that it can use the same register for both the input and
8399 the output.
8400
8401 To prevent this from happening,
8402 if any input operand uses the @samp{f} constraint, all output register
8403 constraints must use the @samp{&} early-clobber modifier.
8404
8405 The example above is correctly written as:
8406
8407 @smallexample
8408 asm ("foo" : "=&t" (a) : "f" (b));
8409 @end smallexample
8410
8411 @item
8412 Some operands need to be in particular places on the stack. All
8413 output operands fall in this category---GCC has no other way to
8414 know which registers the outputs appear in unless you indicate
8415 this in the constraints.
8416
8417 Output operands must specifically indicate which register an output
8418 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8419 constraints must select a class with a single register.
8420
8421 @item
8422 Output operands may not be ``inserted'' between existing stack registers.
8423 Since no 387 opcode uses a read/write operand, all output operands
8424 are dead before the @code{asm}, and are pushed by the @code{asm}.
8425 It makes no sense to push anywhere but the top of the reg-stack.
8426
8427 Output operands must start at the top of the reg-stack: output
8428 operands may not ``skip'' a register.
8429
8430 @item
8431 Some @code{asm} statements may need extra stack space for internal
8432 calculations. This can be guaranteed by clobbering stack registers
8433 unrelated to the inputs and outputs.
8434
8435 @end enumerate
8436
8437 This @code{asm}
8438 takes one input, which is internally popped, and produces two outputs.
8439
8440 @smallexample
8441 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8442 @end smallexample
8443
8444 @noindent
8445 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8446 and replaces them with one output. The @code{st(1)} clobber is necessary
8447 for the compiler to know that @code{fyl2xp1} pops both inputs.
8448
8449 @smallexample
8450 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8451 @end smallexample
8452
8453 @lowersections
8454 @include md.texi
8455 @raisesections
8456
8457 @node Asm Labels
8458 @subsection Controlling Names Used in Assembler Code
8459 @cindex assembler names for identifiers
8460 @cindex names used in assembler code
8461 @cindex identifiers, names in assembler code
8462
8463 You can specify the name to be used in the assembler code for a C
8464 function or variable by writing the @code{asm} (or @code{__asm__})
8465 keyword after the declarator.
8466 It is up to you to make sure that the assembler names you choose do not
8467 conflict with any other assembler symbols, or reference registers.
8468
8469 @subsubheading Assembler names for data:
8470
8471 This sample shows how to specify the assembler name for data:
8472
8473 @smallexample
8474 int foo asm ("myfoo") = 2;
8475 @end smallexample
8476
8477 @noindent
8478 This specifies that the name to be used for the variable @code{foo} in
8479 the assembler code should be @samp{myfoo} rather than the usual
8480 @samp{_foo}.
8481
8482 On systems where an underscore is normally prepended to the name of a C
8483 variable, this feature allows you to define names for the
8484 linker that do not start with an underscore.
8485
8486 GCC does not support using this feature with a non-static local variable
8487 since such variables do not have assembler names. If you are
8488 trying to put the variable in a particular register, see
8489 @ref{Explicit Register Variables}.
8490
8491 @subsubheading Assembler names for functions:
8492
8493 To specify the assembler name for functions, write a declaration for the
8494 function before its definition and put @code{asm} there, like this:
8495
8496 @smallexample
8497 int func (int x, int y) asm ("MYFUNC");
8498
8499 int func (int x, int y)
8500 @{
8501 /* @r{@dots{}} */
8502 @end smallexample
8503
8504 @noindent
8505 This specifies that the name to be used for the function @code{func} in
8506 the assembler code should be @code{MYFUNC}.
8507
8508 @node Explicit Register Variables
8509 @subsection Variables in Specified Registers
8510 @anchor{Explicit Reg Vars}
8511 @cindex explicit register variables
8512 @cindex variables in specified registers
8513 @cindex specified registers
8514
8515 GNU C allows you to associate specific hardware registers with C
8516 variables. In almost all cases, allowing the compiler to assign
8517 registers produces the best code. However under certain unusual
8518 circumstances, more precise control over the variable storage is
8519 required.
8520
8521 Both global and local variables can be associated with a register. The
8522 consequences of performing this association are very different between
8523 the two, as explained in the sections below.
8524
8525 @menu
8526 * Global Register Variables:: Variables declared at global scope.
8527 * Local Register Variables:: Variables declared within a function.
8528 @end menu
8529
8530 @node Global Register Variables
8531 @subsubsection Defining Global Register Variables
8532 @anchor{Global Reg Vars}
8533 @cindex global register variables
8534 @cindex registers, global variables in
8535 @cindex registers, global allocation
8536
8537 You can define a global register variable and associate it with a specified
8538 register like this:
8539
8540 @smallexample
8541 register int *foo asm ("r12");
8542 @end smallexample
8543
8544 @noindent
8545 Here @code{r12} is the name of the register that should be used. Note that
8546 this is the same syntax used for defining local register variables, but for
8547 a global variable the declaration appears outside a function. The
8548 @code{register} keyword is required, and cannot be combined with
8549 @code{static}. The register name must be a valid register name for the
8550 target platform.
8551
8552 Registers are a scarce resource on most systems and allowing the
8553 compiler to manage their usage usually results in the best code. However,
8554 under special circumstances it can make sense to reserve some globally.
8555 For example this may be useful in programs such as programming language
8556 interpreters that have a couple of global variables that are accessed
8557 very often.
8558
8559 After defining a global register variable, for the current compilation
8560 unit:
8561
8562 @itemize @bullet
8563 @item The register is reserved entirely for this use, and will not be
8564 allocated for any other purpose.
8565 @item The register is not saved and restored by any functions.
8566 @item Stores into this register are never deleted even if they appear to be
8567 dead, but references may be deleted, moved or simplified.
8568 @end itemize
8569
8570 Note that these points @emph{only} apply to code that is compiled with the
8571 definition. The behavior of code that is merely linked in (for example
8572 code from libraries) is not affected.
8573
8574 If you want to recompile source files that do not actually use your global
8575 register variable so they do not use the specified register for any other
8576 purpose, you need not actually add the global register declaration to
8577 their source code. It suffices to specify the compiler option
8578 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8579 register.
8580
8581 @subsubheading Declaring the variable
8582
8583 Global register variables can not have initial values, because an
8584 executable file has no means to supply initial contents for a register.
8585
8586 When selecting a register, choose one that is normally saved and
8587 restored by function calls on your machine. This ensures that code
8588 which is unaware of this reservation (such as library routines) will
8589 restore it before returning.
8590
8591 On machines with register windows, be sure to choose a global
8592 register that is not affected magically by the function call mechanism.
8593
8594 @subsubheading Using the variable
8595
8596 @cindex @code{qsort}, and global register variables
8597 When calling routines that are not aware of the reservation, be
8598 cautious if those routines call back into code which uses them. As an
8599 example, if you call the system library version of @code{qsort}, it may
8600 clobber your registers during execution, but (if you have selected
8601 appropriate registers) it will restore them before returning. However
8602 it will @emph{not} restore them before calling @code{qsort}'s comparison
8603 function. As a result, global values will not reliably be available to
8604 the comparison function unless the @code{qsort} function itself is rebuilt.
8605
8606 Similarly, it is not safe to access the global register variables from signal
8607 handlers or from more than one thread of control. Unless you recompile
8608 them specially for the task at hand, the system library routines may
8609 temporarily use the register for other things.
8610
8611 @cindex register variable after @code{longjmp}
8612 @cindex global register after @code{longjmp}
8613 @cindex value after @code{longjmp}
8614 @findex longjmp
8615 @findex setjmp
8616 On most machines, @code{longjmp} restores to each global register
8617 variable the value it had at the time of the @code{setjmp}. On some
8618 machines, however, @code{longjmp} does not change the value of global
8619 register variables. To be portable, the function that called @code{setjmp}
8620 should make other arrangements to save the values of the global register
8621 variables, and to restore them in a @code{longjmp}. This way, the same
8622 thing happens regardless of what @code{longjmp} does.
8623
8624 Eventually there may be a way of asking the compiler to choose a register
8625 automatically, but first we need to figure out how it should choose and
8626 how to enable you to guide the choice. No solution is evident.
8627
8628 @node Local Register Variables
8629 @subsubsection Specifying Registers for Local Variables
8630 @anchor{Local Reg Vars}
8631 @cindex local variables, specifying registers
8632 @cindex specifying registers for local variables
8633 @cindex registers for local variables
8634
8635 You can define a local register variable and associate it with a specified
8636 register like this:
8637
8638 @smallexample
8639 register int *foo asm ("r12");
8640 @end smallexample
8641
8642 @noindent
8643 Here @code{r12} is the name of the register that should be used. Note
8644 that this is the same syntax used for defining global register variables,
8645 but for a local variable the declaration appears within a function. The
8646 @code{register} keyword is required, and cannot be combined with
8647 @code{static}. The register name must be a valid register name for the
8648 target platform.
8649
8650 As with global register variables, it is recommended that you choose
8651 a register that is normally saved and restored by function calls on your
8652 machine, so that calls to library routines will not clobber it.
8653
8654 The only supported use for this feature is to specify registers
8655 for input and output operands when calling Extended @code{asm}
8656 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8657 particular machine don't provide sufficient control to select the desired
8658 register. To force an operand into a register, create a local variable
8659 and specify the register name after the variable's declaration. Then use
8660 the local variable for the @code{asm} operand and specify any constraint
8661 letter that matches the register:
8662
8663 @smallexample
8664 register int *p1 asm ("r0") = @dots{};
8665 register int *p2 asm ("r1") = @dots{};
8666 register int *result asm ("r0");
8667 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8668 @end smallexample
8669
8670 @emph{Warning:} In the above example, be aware that a register (for example
8671 @code{r0}) can be call-clobbered by subsequent code, including function
8672 calls and library calls for arithmetic operators on other variables (for
8673 example the initialization of @code{p2}). In this case, use temporary
8674 variables for expressions between the register assignments:
8675
8676 @smallexample
8677 int t1 = @dots{};
8678 register int *p1 asm ("r0") = @dots{};
8679 register int *p2 asm ("r1") = t1;
8680 register int *result asm ("r0");
8681 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8682 @end smallexample
8683
8684 Defining a register variable does not reserve the register. Other than
8685 when invoking the Extended @code{asm}, the contents of the specified
8686 register are not guaranteed. For this reason, the following uses
8687 are explicitly @emph{not} supported. If they appear to work, it is only
8688 happenstance, and may stop working as intended due to (seemingly)
8689 unrelated changes in surrounding code, or even minor changes in the
8690 optimization of a future version of gcc:
8691
8692 @itemize @bullet
8693 @item Passing parameters to or from Basic @code{asm}
8694 @item Passing parameters to or from Extended @code{asm} without using input
8695 or output operands.
8696 @item Passing parameters to or from routines written in assembler (or
8697 other languages) using non-standard calling conventions.
8698 @end itemize
8699
8700 Some developers use Local Register Variables in an attempt to improve
8701 gcc's allocation of registers, especially in large functions. In this
8702 case the register name is essentially a hint to the register allocator.
8703 While in some instances this can generate better code, improvements are
8704 subject to the whims of the allocator/optimizers. Since there are no
8705 guarantees that your improvements won't be lost, this usage of Local
8706 Register Variables is discouraged.
8707
8708 On the MIPS platform, there is related use for local register variables
8709 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8710 Defining coprocessor specifics for MIPS targets, gccint,
8711 GNU Compiler Collection (GCC) Internals}).
8712
8713 @node Size of an asm
8714 @subsection Size of an @code{asm}
8715
8716 Some targets require that GCC track the size of each instruction used
8717 in order to generate correct code. Because the final length of the
8718 code produced by an @code{asm} statement is only known by the
8719 assembler, GCC must make an estimate as to how big it will be. It
8720 does this by counting the number of instructions in the pattern of the
8721 @code{asm} and multiplying that by the length of the longest
8722 instruction supported by that processor. (When working out the number
8723 of instructions, it assumes that any occurrence of a newline or of
8724 whatever statement separator character is supported by the assembler --
8725 typically @samp{;} --- indicates the end of an instruction.)
8726
8727 Normally, GCC's estimate is adequate to ensure that correct
8728 code is generated, but it is possible to confuse the compiler if you use
8729 pseudo instructions or assembler macros that expand into multiple real
8730 instructions, or if you use assembler directives that expand to more
8731 space in the object file than is needed for a single instruction.
8732 If this happens then the assembler may produce a diagnostic saying that
8733 a label is unreachable.
8734
8735 @node Alternate Keywords
8736 @section Alternate Keywords
8737 @cindex alternate keywords
8738 @cindex keywords, alternate
8739
8740 @option{-ansi} and the various @option{-std} options disable certain
8741 keywords. This causes trouble when you want to use GNU C extensions, or
8742 a general-purpose header file that should be usable by all programs,
8743 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8744 @code{inline} are not available in programs compiled with
8745 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8746 program compiled with @option{-std=c99} or @option{-std=c11}). The
8747 ISO C99 keyword
8748 @code{restrict} is only available when @option{-std=gnu99} (which will
8749 eventually be the default) or @option{-std=c99} (or the equivalent
8750 @option{-std=iso9899:1999}), or an option for a later standard
8751 version, is used.
8752
8753 The way to solve these problems is to put @samp{__} at the beginning and
8754 end of each problematical keyword. For example, use @code{__asm__}
8755 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8756
8757 Other C compilers won't accept these alternative keywords; if you want to
8758 compile with another compiler, you can define the alternate keywords as
8759 macros to replace them with the customary keywords. It looks like this:
8760
8761 @smallexample
8762 #ifndef __GNUC__
8763 #define __asm__ asm
8764 #endif
8765 @end smallexample
8766
8767 @findex __extension__
8768 @opindex pedantic
8769 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8770 You can
8771 prevent such warnings within one expression by writing
8772 @code{__extension__} before the expression. @code{__extension__} has no
8773 effect aside from this.
8774
8775 @node Incomplete Enums
8776 @section Incomplete @code{enum} Types
8777
8778 You can define an @code{enum} tag without specifying its possible values.
8779 This results in an incomplete type, much like what you get if you write
8780 @code{struct foo} without describing the elements. A later declaration
8781 that does specify the possible values completes the type.
8782
8783 You can't allocate variables or storage using the type while it is
8784 incomplete. However, you can work with pointers to that type.
8785
8786 This extension may not be very useful, but it makes the handling of
8787 @code{enum} more consistent with the way @code{struct} and @code{union}
8788 are handled.
8789
8790 This extension is not supported by GNU C++.
8791
8792 @node Function Names
8793 @section Function Names as Strings
8794 @cindex @code{__func__} identifier
8795 @cindex @code{__FUNCTION__} identifier
8796 @cindex @code{__PRETTY_FUNCTION__} identifier
8797
8798 GCC provides three magic variables that hold the name of the current
8799 function, as a string. The first of these is @code{__func__}, which
8800 is part of the C99 standard:
8801
8802 The identifier @code{__func__} is implicitly declared by the translator
8803 as if, immediately following the opening brace of each function
8804 definition, the declaration
8805
8806 @smallexample
8807 static const char __func__[] = "function-name";
8808 @end smallexample
8809
8810 @noindent
8811 appeared, where function-name is the name of the lexically-enclosing
8812 function. This name is the unadorned name of the function.
8813
8814 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8815 backward compatibility with old versions of GCC.
8816
8817 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8818 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8819 the type signature of the function as well as its bare name. For
8820 example, this program:
8821
8822 @smallexample
8823 extern "C" @{
8824 extern int printf (char *, ...);
8825 @}
8826
8827 class a @{
8828 public:
8829 void sub (int i)
8830 @{
8831 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8832 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8833 @}
8834 @};
8835
8836 int
8837 main (void)
8838 @{
8839 a ax;
8840 ax.sub (0);
8841 return 0;
8842 @}
8843 @end smallexample
8844
8845 @noindent
8846 gives this output:
8847
8848 @smallexample
8849 __FUNCTION__ = sub
8850 __PRETTY_FUNCTION__ = void a::sub(int)
8851 @end smallexample
8852
8853 These identifiers are variables, not preprocessor macros, and may not
8854 be used to initialize @code{char} arrays or be concatenated with other string
8855 literals.
8856
8857 @node Return Address
8858 @section Getting the Return or Frame Address of a Function
8859
8860 These functions may be used to get information about the callers of a
8861 function.
8862
8863 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8864 This function returns the return address of the current function, or of
8865 one of its callers. The @var{level} argument is number of frames to
8866 scan up the call stack. A value of @code{0} yields the return address
8867 of the current function, a value of @code{1} yields the return address
8868 of the caller of the current function, and so forth. When inlining
8869 the expected behavior is that the function returns the address of
8870 the function that is returned to. To work around this behavior use
8871 the @code{noinline} function attribute.
8872
8873 The @var{level} argument must be a constant integer.
8874
8875 On some machines it may be impossible to determine the return address of
8876 any function other than the current one; in such cases, or when the top
8877 of the stack has been reached, this function returns @code{0} or a
8878 random value. In addition, @code{__builtin_frame_address} may be used
8879 to determine if the top of the stack has been reached.
8880
8881 Additional post-processing of the returned value may be needed, see
8882 @code{__builtin_extract_return_addr}.
8883
8884 Calling this function with a nonzero argument can have unpredictable
8885 effects, including crashing the calling program. As a result, calls
8886 that are considered unsafe are diagnosed when the @option{-Wframe-address}
8887 option is in effect. Such calls should only be made in debugging
8888 situations.
8889 @end deftypefn
8890
8891 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
8892 The address as returned by @code{__builtin_return_address} may have to be fed
8893 through this function to get the actual encoded address. For example, on the
8894 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
8895 platforms an offset has to be added for the true next instruction to be
8896 executed.
8897
8898 If no fixup is needed, this function simply passes through @var{addr}.
8899 @end deftypefn
8900
8901 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
8902 This function does the reverse of @code{__builtin_extract_return_addr}.
8903 @end deftypefn
8904
8905 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
8906 This function is similar to @code{__builtin_return_address}, but it
8907 returns the address of the function frame rather than the return address
8908 of the function. Calling @code{__builtin_frame_address} with a value of
8909 @code{0} yields the frame address of the current function, a value of
8910 @code{1} yields the frame address of the caller of the current function,
8911 and so forth.
8912
8913 The frame is the area on the stack that holds local variables and saved
8914 registers. The frame address is normally the address of the first word
8915 pushed on to the stack by the function. However, the exact definition
8916 depends upon the processor and the calling convention. If the processor
8917 has a dedicated frame pointer register, and the function has a frame,
8918 then @code{__builtin_frame_address} returns the value of the frame
8919 pointer register.
8920
8921 On some machines it may be impossible to determine the frame address of
8922 any function other than the current one; in such cases, or when the top
8923 of the stack has been reached, this function returns @code{0} if
8924 the first frame pointer is properly initialized by the startup code.
8925
8926 Calling this function with a nonzero argument can have unpredictable
8927 effects, including crashing the calling program. As a result, calls
8928 that are considered unsafe are diagnosed when the @option{-Wframe-address}
8929 option is in effect. Such calls should only be made in debugging
8930 situations.
8931 @end deftypefn
8932
8933 @node Vector Extensions
8934 @section Using Vector Instructions through Built-in Functions
8935
8936 On some targets, the instruction set contains SIMD vector instructions which
8937 operate on multiple values contained in one large register at the same time.
8938 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
8939 this way.
8940
8941 The first step in using these extensions is to provide the necessary data
8942 types. This should be done using an appropriate @code{typedef}:
8943
8944 @smallexample
8945 typedef int v4si __attribute__ ((vector_size (16)));
8946 @end smallexample
8947
8948 @noindent
8949 The @code{int} type specifies the base type, while the attribute specifies
8950 the vector size for the variable, measured in bytes. For example, the
8951 declaration above causes the compiler to set the mode for the @code{v4si}
8952 type to be 16 bytes wide and divided into @code{int} sized units. For
8953 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
8954 corresponding mode of @code{foo} is @acronym{V4SI}.
8955
8956 The @code{vector_size} attribute is only applicable to integral and
8957 float scalars, although arrays, pointers, and function return values
8958 are allowed in conjunction with this construct. Only sizes that are
8959 a power of two are currently allowed.
8960
8961 All the basic integer types can be used as base types, both as signed
8962 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
8963 @code{long long}. In addition, @code{float} and @code{double} can be
8964 used to build floating-point vector types.
8965
8966 Specifying a combination that is not valid for the current architecture
8967 causes GCC to synthesize the instructions using a narrower mode.
8968 For example, if you specify a variable of type @code{V4SI} and your
8969 architecture does not allow for this specific SIMD type, GCC
8970 produces code that uses 4 @code{SIs}.
8971
8972 The types defined in this manner can be used with a subset of normal C
8973 operations. Currently, GCC allows using the following operators
8974 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
8975
8976 The operations behave like C++ @code{valarrays}. Addition is defined as
8977 the addition of the corresponding elements of the operands. For
8978 example, in the code below, each of the 4 elements in @var{a} is
8979 added to the corresponding 4 elements in @var{b} and the resulting
8980 vector is stored in @var{c}.
8981
8982 @smallexample
8983 typedef int v4si __attribute__ ((vector_size (16)));
8984
8985 v4si a, b, c;
8986
8987 c = a + b;
8988 @end smallexample
8989
8990 Subtraction, multiplication, division, and the logical operations
8991 operate in a similar manner. Likewise, the result of using the unary
8992 minus or complement operators on a vector type is a vector whose
8993 elements are the negative or complemented values of the corresponding
8994 elements in the operand.
8995
8996 It is possible to use shifting operators @code{<<}, @code{>>} on
8997 integer-type vectors. The operation is defined as following: @code{@{a0,
8998 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
8999 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9000 elements.
9001
9002 For convenience, it is allowed to use a binary vector operation
9003 where one operand is a scalar. In that case the compiler transforms
9004 the scalar operand into a vector where each element is the scalar from
9005 the operation. The transformation happens only if the scalar could be
9006 safely converted to the vector-element type.
9007 Consider the following code.
9008
9009 @smallexample
9010 typedef int v4si __attribute__ ((vector_size (16)));
9011
9012 v4si a, b, c;
9013 long l;
9014
9015 a = b + 1; /* a = b + @{1,1,1,1@}; */
9016 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9017
9018 a = l + a; /* Error, cannot convert long to int. */
9019 @end smallexample
9020
9021 Vectors can be subscripted as if the vector were an array with
9022 the same number of elements and base type. Out of bound accesses
9023 invoke undefined behavior at run time. Warnings for out of bound
9024 accesses for vector subscription can be enabled with
9025 @option{-Warray-bounds}.
9026
9027 Vector comparison is supported with standard comparison
9028 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9029 vector expressions of integer-type or real-type. Comparison between
9030 integer-type vectors and real-type vectors are not supported. The
9031 result of the comparison is a vector of the same width and number of
9032 elements as the comparison operands with a signed integral element
9033 type.
9034
9035 Vectors are compared element-wise producing 0 when comparison is false
9036 and -1 (constant of the appropriate type where all bits are set)
9037 otherwise. Consider the following example.
9038
9039 @smallexample
9040 typedef int v4si __attribute__ ((vector_size (16)));
9041
9042 v4si a = @{1,2,3,4@};
9043 v4si b = @{3,2,1,4@};
9044 v4si c;
9045
9046 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9047 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9048 @end smallexample
9049
9050 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9051 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9052 integer vector with the same number of elements of the same size as @code{b}
9053 and @code{c}, computes all three arguments and creates a vector
9054 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9055 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9056 As in the case of binary operations, this syntax is also accepted when
9057 one of @code{b} or @code{c} is a scalar that is then transformed into a
9058 vector. If both @code{b} and @code{c} are scalars and the type of
9059 @code{true?b:c} has the same size as the element type of @code{a}, then
9060 @code{b} and @code{c} are converted to a vector type whose elements have
9061 this type and with the same number of elements as @code{a}.
9062
9063 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9064 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9065 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9066 For mixed operations between a scalar @code{s} and a vector @code{v},
9067 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9068 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9069
9070 Vector shuffling is available using functions
9071 @code{__builtin_shuffle (vec, mask)} and
9072 @code{__builtin_shuffle (vec0, vec1, mask)}.
9073 Both functions construct a permutation of elements from one or two
9074 vectors and return a vector of the same type as the input vector(s).
9075 The @var{mask} is an integral vector with the same width (@var{W})
9076 and element count (@var{N}) as the output vector.
9077
9078 The elements of the input vectors are numbered in memory ordering of
9079 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9080 elements of @var{mask} are considered modulo @var{N} in the single-operand
9081 case and modulo @math{2*@var{N}} in the two-operand case.
9082
9083 Consider the following example,
9084
9085 @smallexample
9086 typedef int v4si __attribute__ ((vector_size (16)));
9087
9088 v4si a = @{1,2,3,4@};
9089 v4si b = @{5,6,7,8@};
9090 v4si mask1 = @{0,1,1,3@};
9091 v4si mask2 = @{0,4,2,5@};
9092 v4si res;
9093
9094 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9095 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9096 @end smallexample
9097
9098 Note that @code{__builtin_shuffle} is intentionally semantically
9099 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9100
9101 You can declare variables and use them in function calls and returns, as
9102 well as in assignments and some casts. You can specify a vector type as
9103 a return type for a function. Vector types can also be used as function
9104 arguments. It is possible to cast from one vector type to another,
9105 provided they are of the same size (in fact, you can also cast vectors
9106 to and from other datatypes of the same size).
9107
9108 You cannot operate between vectors of different lengths or different
9109 signedness without a cast.
9110
9111 @node Offsetof
9112 @section Support for @code{offsetof}
9113 @findex __builtin_offsetof
9114
9115 GCC implements for both C and C++ a syntactic extension to implement
9116 the @code{offsetof} macro.
9117
9118 @smallexample
9119 primary:
9120 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9121
9122 offsetof_member_designator:
9123 @code{identifier}
9124 | offsetof_member_designator "." @code{identifier}
9125 | offsetof_member_designator "[" @code{expr} "]"
9126 @end smallexample
9127
9128 This extension is sufficient such that
9129
9130 @smallexample
9131 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9132 @end smallexample
9133
9134 @noindent
9135 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9136 may be dependent. In either case, @var{member} may consist of a single
9137 identifier, or a sequence of member accesses and array references.
9138
9139 @node __sync Builtins
9140 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9141
9142 The following built-in functions
9143 are intended to be compatible with those described
9144 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9145 section 7.4. As such, they depart from normal GCC practice by not using
9146 the @samp{__builtin_} prefix and also by being overloaded so that they
9147 work on multiple types.
9148
9149 The definition given in the Intel documentation allows only for the use of
9150 the types @code{int}, @code{long}, @code{long long} or their unsigned
9151 counterparts. GCC allows any integral scalar or pointer type that is
9152 1, 2, 4 or 8 bytes in length.
9153
9154 These functions are implemented in terms of the @samp{__atomic}
9155 builtins (@pxref{__atomic Builtins}). They should not be used for new
9156 code which should use the @samp{__atomic} builtins instead.
9157
9158 Not all operations are supported by all target processors. If a particular
9159 operation cannot be implemented on the target processor, a warning is
9160 generated and a call to an external function is generated. The external
9161 function carries the same name as the built-in version,
9162 with an additional suffix
9163 @samp{_@var{n}} where @var{n} is the size of the data type.
9164
9165 @c ??? Should we have a mechanism to suppress this warning? This is almost
9166 @c useful for implementing the operation under the control of an external
9167 @c mutex.
9168
9169 In most cases, these built-in functions are considered a @dfn{full barrier}.
9170 That is,
9171 no memory operand is moved across the operation, either forward or
9172 backward. Further, instructions are issued as necessary to prevent the
9173 processor from speculating loads across the operation and from queuing stores
9174 after the operation.
9175
9176 All of the routines are described in the Intel documentation to take
9177 ``an optional list of variables protected by the memory barrier''. It's
9178 not clear what is meant by that; it could mean that @emph{only} the
9179 listed variables are protected, or it could mean a list of additional
9180 variables to be protected. The list is ignored by GCC which treats it as
9181 empty. GCC interprets an empty list as meaning that all globally
9182 accessible variables should be protected.
9183
9184 @table @code
9185 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9186 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9187 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9188 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9189 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9190 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9191 @findex __sync_fetch_and_add
9192 @findex __sync_fetch_and_sub
9193 @findex __sync_fetch_and_or
9194 @findex __sync_fetch_and_and
9195 @findex __sync_fetch_and_xor
9196 @findex __sync_fetch_and_nand
9197 These built-in functions perform the operation suggested by the name, and
9198 returns the value that had previously been in memory. That is,
9199
9200 @smallexample
9201 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9202 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9203 @end smallexample
9204
9205 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9206 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9207
9208 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9209 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9210 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9211 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9212 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9213 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9214 @findex __sync_add_and_fetch
9215 @findex __sync_sub_and_fetch
9216 @findex __sync_or_and_fetch
9217 @findex __sync_and_and_fetch
9218 @findex __sync_xor_and_fetch
9219 @findex __sync_nand_and_fetch
9220 These built-in functions perform the operation suggested by the name, and
9221 return the new value. That is,
9222
9223 @smallexample
9224 @{ *ptr @var{op}= value; return *ptr; @}
9225 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9226 @end smallexample
9227
9228 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9229 as @code{*ptr = ~(*ptr & value)} instead of
9230 @code{*ptr = ~*ptr & value}.
9231
9232 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9233 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9234 @findex __sync_bool_compare_and_swap
9235 @findex __sync_val_compare_and_swap
9236 These built-in functions perform an atomic compare and swap.
9237 That is, if the current
9238 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9239 @code{*@var{ptr}}.
9240
9241 The ``bool'' version returns true if the comparison is successful and
9242 @var{newval} is written. The ``val'' version returns the contents
9243 of @code{*@var{ptr}} before the operation.
9244
9245 @item __sync_synchronize (...)
9246 @findex __sync_synchronize
9247 This built-in function issues a full memory barrier.
9248
9249 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9250 @findex __sync_lock_test_and_set
9251 This built-in function, as described by Intel, is not a traditional test-and-set
9252 operation, but rather an atomic exchange operation. It writes @var{value}
9253 into @code{*@var{ptr}}, and returns the previous contents of
9254 @code{*@var{ptr}}.
9255
9256 Many targets have only minimal support for such locks, and do not support
9257 a full exchange operation. In this case, a target may support reduced
9258 functionality here by which the @emph{only} valid value to store is the
9259 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9260 is implementation defined.
9261
9262 This built-in function is not a full barrier,
9263 but rather an @dfn{acquire barrier}.
9264 This means that references after the operation cannot move to (or be
9265 speculated to) before the operation, but previous memory stores may not
9266 be globally visible yet, and previous memory loads may not yet be
9267 satisfied.
9268
9269 @item void __sync_lock_release (@var{type} *ptr, ...)
9270 @findex __sync_lock_release
9271 This built-in function releases the lock acquired by
9272 @code{__sync_lock_test_and_set}.
9273 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9274
9275 This built-in function is not a full barrier,
9276 but rather a @dfn{release barrier}.
9277 This means that all previous memory stores are globally visible, and all
9278 previous memory loads have been satisfied, but following memory reads
9279 are not prevented from being speculated to before the barrier.
9280 @end table
9281
9282 @node __atomic Builtins
9283 @section Built-in Functions for Memory Model Aware Atomic Operations
9284
9285 The following built-in functions approximately match the requirements
9286 for the C++11 memory model. They are all
9287 identified by being prefixed with @samp{__atomic} and most are
9288 overloaded so that they work with multiple types.
9289
9290 These functions are intended to replace the legacy @samp{__sync}
9291 builtins. The main difference is that the memory order that is requested
9292 is a parameter to the functions. New code should always use the
9293 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9294
9295 Note that the @samp{__atomic} builtins assume that programs will
9296 conform to the C++11 memory model. In particular, they assume
9297 that programs are free of data races. See the C++11 standard for
9298 detailed requirements.
9299
9300 The @samp{__atomic} builtins can be used with any integral scalar or
9301 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9302 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9303 supported by the architecture.
9304
9305 The four non-arithmetic functions (load, store, exchange, and
9306 compare_exchange) all have a generic version as well. This generic
9307 version works on any data type. It uses the lock-free built-in function
9308 if the specific data type size makes that possible; otherwise, an
9309 external call is left to be resolved at run time. This external call is
9310 the same format with the addition of a @samp{size_t} parameter inserted
9311 as the first parameter indicating the size of the object being pointed to.
9312 All objects must be the same size.
9313
9314 There are 6 different memory orders that can be specified. These map
9315 to the C++11 memory orders with the same names, see the C++11 standard
9316 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9317 on atomic synchronization} for detailed definitions. Individual
9318 targets may also support additional memory orders for use on specific
9319 architectures. Refer to the target documentation for details of
9320 these.
9321
9322 An atomic operation can both constrain code motion and
9323 be mapped to hardware instructions for synchronization between threads
9324 (e.g., a fence). To which extent this happens is controlled by the
9325 memory orders, which are listed here in approximately ascending order of
9326 strength. The description of each memory order is only meant to roughly
9327 illustrate the effects and is not a specification; see the C++11
9328 memory model for precise semantics.
9329
9330 @table @code
9331 @item __ATOMIC_RELAXED
9332 Implies no inter-thread ordering constraints.
9333 @item __ATOMIC_CONSUME
9334 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9335 memory order because of a deficiency in C++11's semantics for
9336 @code{memory_order_consume}.
9337 @item __ATOMIC_ACQUIRE
9338 Creates an inter-thread happens-before constraint from the release (or
9339 stronger) semantic store to this acquire load. Can prevent hoisting
9340 of code to before the operation.
9341 @item __ATOMIC_RELEASE
9342 Creates an inter-thread happens-before constraint to acquire (or stronger)
9343 semantic loads that read from this release store. Can prevent sinking
9344 of code to after the operation.
9345 @item __ATOMIC_ACQ_REL
9346 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9347 @code{__ATOMIC_RELEASE}.
9348 @item __ATOMIC_SEQ_CST
9349 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9350 @end table
9351
9352 Note that in the C++11 memory model, @emph{fences} (e.g.,
9353 @samp{__atomic_thread_fence}) take effect in combination with other
9354 atomic operations on specific memory locations (e.g., atomic loads);
9355 operations on specific memory locations do not necessarily affect other
9356 operations in the same way.
9357
9358 Target architectures are encouraged to provide their own patterns for
9359 each of the atomic built-in functions. If no target is provided, the original
9360 non-memory model set of @samp{__sync} atomic built-in functions are
9361 used, along with any required synchronization fences surrounding it in
9362 order to achieve the proper behavior. Execution in this case is subject
9363 to the same restrictions as those built-in functions.
9364
9365 If there is no pattern or mechanism to provide a lock-free instruction
9366 sequence, a call is made to an external routine with the same parameters
9367 to be resolved at run time.
9368
9369 When implementing patterns for these built-in functions, the memory order
9370 parameter can be ignored as long as the pattern implements the most
9371 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9372 orders execute correctly with this memory order but they may not execute as
9373 efficiently as they could with a more appropriate implementation of the
9374 relaxed requirements.
9375
9376 Note that the C++11 standard allows for the memory order parameter to be
9377 determined at run time rather than at compile time. These built-in
9378 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9379 than invoke a runtime library call or inline a switch statement. This is
9380 standard compliant, safe, and the simplest approach for now.
9381
9382 The memory order parameter is a signed int, but only the lower 16 bits are
9383 reserved for the memory order. The remainder of the signed int is reserved
9384 for target use and should be 0. Use of the predefined atomic values
9385 ensures proper usage.
9386
9387 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9388 This built-in function implements an atomic load operation. It returns the
9389 contents of @code{*@var{ptr}}.
9390
9391 The valid memory order variants are
9392 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9393 and @code{__ATOMIC_CONSUME}.
9394
9395 @end deftypefn
9396
9397 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9398 This is the generic version of an atomic load. It returns the
9399 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9400
9401 @end deftypefn
9402
9403 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9404 This built-in function implements an atomic store operation. It writes
9405 @code{@var{val}} into @code{*@var{ptr}}.
9406
9407 The valid memory order variants are
9408 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9409
9410 @end deftypefn
9411
9412 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9413 This is the generic version of an atomic store. It stores the value
9414 of @code{*@var{val}} into @code{*@var{ptr}}.
9415
9416 @end deftypefn
9417
9418 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9419 This built-in function implements an atomic exchange operation. It writes
9420 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9421 @code{*@var{ptr}}.
9422
9423 The valid memory order variants are
9424 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9425 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9426
9427 @end deftypefn
9428
9429 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9430 This is the generic version of an atomic exchange. It stores the
9431 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9432 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9433
9434 @end deftypefn
9435
9436 @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)
9437 This built-in function implements an atomic compare and exchange operation.
9438 This compares the contents of @code{*@var{ptr}} with the contents of
9439 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9440 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9441 equal, the operation is a @emph{read} and the current contents of
9442 @code{*@var{ptr}} is written into @code{*@var{expected}}. @var{weak} is true
9443 for weak compare_exchange, and false for the strong variation. Many targets
9444 only offer the strong variation and ignore the parameter. When in doubt, use
9445 the strong variation.
9446
9447 True is returned if @var{desired} is written into
9448 @code{*@var{ptr}} and the operation is considered to conform to the
9449 memory order specified by @var{success_memorder}. There are no
9450 restrictions on what memory order can be used here.
9451
9452 False is returned otherwise, and the operation is considered to conform
9453 to @var{failure_memorder}. This memory order cannot be
9454 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9455 stronger order than that specified by @var{success_memorder}.
9456
9457 @end deftypefn
9458
9459 @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)
9460 This built-in function implements the generic version of
9461 @code{__atomic_compare_exchange}. The function is virtually identical to
9462 @code{__atomic_compare_exchange_n}, except the desired value is also a
9463 pointer.
9464
9465 @end deftypefn
9466
9467 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9468 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9469 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9470 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9471 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9472 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9473 These built-in functions perform the operation suggested by the name, and
9474 return the result of the operation. That is,
9475
9476 @smallexample
9477 @{ *ptr @var{op}= val; return *ptr; @}
9478 @end smallexample
9479
9480 All memory orders are valid.
9481
9482 @end deftypefn
9483
9484 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9485 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9486 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9487 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9488 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9489 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9490 These built-in functions perform the operation suggested by the name, and
9491 return the value that had previously been in @code{*@var{ptr}}. That is,
9492
9493 @smallexample
9494 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9495 @end smallexample
9496
9497 All memory orders are valid.
9498
9499 @end deftypefn
9500
9501 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9502
9503 This built-in function performs an atomic test-and-set operation on
9504 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9505 defined nonzero ``set'' value and the return value is @code{true} if and only
9506 if the previous contents were ``set''.
9507 It should be only used for operands of type @code{bool} or @code{char}. For
9508 other types only part of the value may be set.
9509
9510 All memory orders are valid.
9511
9512 @end deftypefn
9513
9514 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9515
9516 This built-in function performs an atomic clear operation on
9517 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9518 It should be only used for operands of type @code{bool} or @code{char} and
9519 in conjunction with @code{__atomic_test_and_set}.
9520 For other types it may only clear partially. If the type is not @code{bool}
9521 prefer using @code{__atomic_store}.
9522
9523 The valid memory order variants are
9524 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9525 @code{__ATOMIC_RELEASE}.
9526
9527 @end deftypefn
9528
9529 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9530
9531 This built-in function acts as a synchronization fence between threads
9532 based on the specified memory order.
9533
9534 All memory orders are valid.
9535
9536 @end deftypefn
9537
9538 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9539
9540 This built-in function acts as a synchronization fence between a thread
9541 and signal handlers based in the same thread.
9542
9543 All memory orders are valid.
9544
9545 @end deftypefn
9546
9547 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9548
9549 This built-in function returns true if objects of @var{size} bytes always
9550 generate lock-free atomic instructions for the target architecture.
9551 @var{size} must resolve to a compile-time constant and the result also
9552 resolves to a compile-time constant.
9553
9554 @var{ptr} is an optional pointer to the object that may be used to determine
9555 alignment. A value of 0 indicates typical alignment should be used. The
9556 compiler may also ignore this parameter.
9557
9558 @smallexample
9559 if (_atomic_always_lock_free (sizeof (long long), 0))
9560 @end smallexample
9561
9562 @end deftypefn
9563
9564 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9565
9566 This built-in function returns true if objects of @var{size} bytes always
9567 generate lock-free atomic instructions for the target architecture. If
9568 the built-in function is not known to be lock-free, a call is made to a
9569 runtime routine named @code{__atomic_is_lock_free}.
9570
9571 @var{ptr} is an optional pointer to the object that may be used to determine
9572 alignment. A value of 0 indicates typical alignment should be used. The
9573 compiler may also ignore this parameter.
9574 @end deftypefn
9575
9576 @node Integer Overflow Builtins
9577 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9578
9579 The following built-in functions allow performing simple arithmetic operations
9580 together with checking whether the operations overflowed.
9581
9582 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9583 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9584 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9585 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9586 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9587 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9588 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9589
9590 These built-in functions promote the first two operands into infinite precision signed
9591 type and perform addition on those promoted operands. The result is then
9592 cast to the type the third pointer argument points to and stored there.
9593 If the stored result is equal to the infinite precision result, the built-in
9594 functions return false, otherwise they return true. As the addition is
9595 performed in infinite signed precision, these built-in functions have fully defined
9596 behavior for all argument values.
9597
9598 The first built-in function allows arbitrary integral types for operands and
9599 the result type must be pointer to some integer type, the rest of the built-in
9600 functions have explicit integer types.
9601
9602 The compiler will attempt to use hardware instructions to implement
9603 these built-in functions where possible, like conditional jump on overflow
9604 after addition, conditional jump on carry etc.
9605
9606 @end deftypefn
9607
9608 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9609 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9610 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9611 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9612 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9613 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9614 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9615
9616 These built-in functions are similar to the add overflow checking built-in
9617 functions above, except they perform subtraction, subtract the second argument
9618 from the first one, instead of addition.
9619
9620 @end deftypefn
9621
9622 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9623 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9624 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9625 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9626 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9627 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9628 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9629
9630 These built-in functions are similar to the add overflow checking built-in
9631 functions above, except they perform multiplication, instead of addition.
9632
9633 @end deftypefn
9634
9635 @node x86 specific memory model extensions for transactional memory
9636 @section x86-Specific Memory Model Extensions for Transactional Memory
9637
9638 The x86 architecture supports additional memory ordering flags
9639 to mark lock critical sections for hardware lock elision.
9640 These must be specified in addition to an existing memory order to
9641 atomic intrinsics.
9642
9643 @table @code
9644 @item __ATOMIC_HLE_ACQUIRE
9645 Start lock elision on a lock variable.
9646 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9647 @item __ATOMIC_HLE_RELEASE
9648 End lock elision on a lock variable.
9649 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9650 @end table
9651
9652 When a lock acquire fails, it is required for good performance to abort
9653 the transaction quickly. This can be done with a @code{_mm_pause}.
9654
9655 @smallexample
9656 #include <immintrin.h> // For _mm_pause
9657
9658 int lockvar;
9659
9660 /* Acquire lock with lock elision */
9661 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9662 _mm_pause(); /* Abort failed transaction */
9663 ...
9664 /* Free lock with lock elision */
9665 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9666 @end smallexample
9667
9668 @node Object Size Checking
9669 @section Object Size Checking Built-in Functions
9670 @findex __builtin_object_size
9671 @findex __builtin___memcpy_chk
9672 @findex __builtin___mempcpy_chk
9673 @findex __builtin___memmove_chk
9674 @findex __builtin___memset_chk
9675 @findex __builtin___strcpy_chk
9676 @findex __builtin___stpcpy_chk
9677 @findex __builtin___strncpy_chk
9678 @findex __builtin___strcat_chk
9679 @findex __builtin___strncat_chk
9680 @findex __builtin___sprintf_chk
9681 @findex __builtin___snprintf_chk
9682 @findex __builtin___vsprintf_chk
9683 @findex __builtin___vsnprintf_chk
9684 @findex __builtin___printf_chk
9685 @findex __builtin___vprintf_chk
9686 @findex __builtin___fprintf_chk
9687 @findex __builtin___vfprintf_chk
9688
9689 GCC implements a limited buffer overflow protection mechanism
9690 that can prevent some buffer overflow attacks.
9691
9692 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9693 is a built-in construct that returns a constant number of bytes from
9694 @var{ptr} to the end of the object @var{ptr} pointer points to
9695 (if known at compile time). @code{__builtin_object_size} never evaluates
9696 its arguments for side-effects. If there are any side-effects in them, it
9697 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9698 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9699 point to and all of them are known at compile time, the returned number
9700 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9701 0 and minimum if nonzero. If it is not possible to determine which objects
9702 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9703 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9704 for @var{type} 2 or 3.
9705
9706 @var{type} is an integer constant from 0 to 3. If the least significant
9707 bit is clear, objects are whole variables, if it is set, a closest
9708 surrounding subobject is considered the object a pointer points to.
9709 The second bit determines if maximum or minimum of remaining bytes
9710 is computed.
9711
9712 @smallexample
9713 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9714 char *p = &var.buf1[1], *q = &var.b;
9715
9716 /* Here the object p points to is var. */
9717 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9718 /* The subobject p points to is var.buf1. */
9719 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9720 /* The object q points to is var. */
9721 assert (__builtin_object_size (q, 0)
9722 == (char *) (&var + 1) - (char *) &var.b);
9723 /* The subobject q points to is var.b. */
9724 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9725 @end smallexample
9726 @end deftypefn
9727
9728 There are built-in functions added for many common string operation
9729 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9730 built-in is provided. This built-in has an additional last argument,
9731 which is the number of bytes remaining in object the @var{dest}
9732 argument points to or @code{(size_t) -1} if the size is not known.
9733
9734 The built-in functions are optimized into the normal string functions
9735 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9736 it is known at compile time that the destination object will not
9737 be overflown. If the compiler can determine at compile time the
9738 object will be always overflown, it issues a warning.
9739
9740 The intended use can be e.g.@:
9741
9742 @smallexample
9743 #undef memcpy
9744 #define bos0(dest) __builtin_object_size (dest, 0)
9745 #define memcpy(dest, src, n) \
9746 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9747
9748 char *volatile p;
9749 char buf[10];
9750 /* It is unknown what object p points to, so this is optimized
9751 into plain memcpy - no checking is possible. */
9752 memcpy (p, "abcde", n);
9753 /* Destination is known and length too. It is known at compile
9754 time there will be no overflow. */
9755 memcpy (&buf[5], "abcde", 5);
9756 /* Destination is known, but the length is not known at compile time.
9757 This will result in __memcpy_chk call that can check for overflow
9758 at run time. */
9759 memcpy (&buf[5], "abcde", n);
9760 /* Destination is known and it is known at compile time there will
9761 be overflow. There will be a warning and __memcpy_chk call that
9762 will abort the program at run time. */
9763 memcpy (&buf[6], "abcde", 5);
9764 @end smallexample
9765
9766 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9767 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9768 @code{strcat} and @code{strncat}.
9769
9770 There are also checking built-in functions for formatted output functions.
9771 @smallexample
9772 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9773 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9774 const char *fmt, ...);
9775 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9776 va_list ap);
9777 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9778 const char *fmt, va_list ap);
9779 @end smallexample
9780
9781 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9782 etc.@: functions and can contain implementation specific flags on what
9783 additional security measures the checking function might take, such as
9784 handling @code{%n} differently.
9785
9786 The @var{os} argument is the object size @var{s} points to, like in the
9787 other built-in functions. There is a small difference in the behavior
9788 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9789 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9790 the checking function is called with @var{os} argument set to
9791 @code{(size_t) -1}.
9792
9793 In addition to this, there are checking built-in functions
9794 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9795 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9796 These have just one additional argument, @var{flag}, right before
9797 format string @var{fmt}. If the compiler is able to optimize them to
9798 @code{fputc} etc.@: functions, it does, otherwise the checking function
9799 is called and the @var{flag} argument passed to it.
9800
9801 @node Pointer Bounds Checker builtins
9802 @section Pointer Bounds Checker Built-in Functions
9803 @cindex Pointer Bounds Checker builtins
9804 @findex __builtin___bnd_set_ptr_bounds
9805 @findex __builtin___bnd_narrow_ptr_bounds
9806 @findex __builtin___bnd_copy_ptr_bounds
9807 @findex __builtin___bnd_init_ptr_bounds
9808 @findex __builtin___bnd_null_ptr_bounds
9809 @findex __builtin___bnd_store_ptr_bounds
9810 @findex __builtin___bnd_chk_ptr_lbounds
9811 @findex __builtin___bnd_chk_ptr_ubounds
9812 @findex __builtin___bnd_chk_ptr_bounds
9813 @findex __builtin___bnd_get_ptr_lbound
9814 @findex __builtin___bnd_get_ptr_ubound
9815
9816 GCC provides a set of built-in functions to control Pointer Bounds Checker
9817 instrumentation. Note that all Pointer Bounds Checker builtins can be used
9818 even if you compile with Pointer Bounds Checker off
9819 (@option{-fno-check-pointer-bounds}).
9820 The behavior may differ in such case as documented below.
9821
9822 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9823
9824 This built-in function returns a new pointer with the value of @var{q}, and
9825 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
9826 Bounds Checker off, the built-in function just returns the first argument.
9827
9828 @smallexample
9829 extern void *__wrap_malloc (size_t n)
9830 @{
9831 void *p = (void *)__real_malloc (n);
9832 if (!p) return __builtin___bnd_null_ptr_bounds (p);
9833 return __builtin___bnd_set_ptr_bounds (p, n);
9834 @}
9835 @end smallexample
9836
9837 @end deftypefn
9838
9839 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
9840
9841 This built-in function returns a new pointer with the value of @var{p}
9842 and associates it with the narrowed bounds formed by the intersection
9843 of bounds associated with @var{q} and the bounds
9844 [@var{p}, @var{p} + @var{size} - 1].
9845 With Pointer Bounds Checker off, the built-in function just returns the first
9846 argument.
9847
9848 @smallexample
9849 void init_objects (object *objs, size_t size)
9850 @{
9851 size_t i;
9852 /* Initialize objects one-by-one passing pointers with bounds of
9853 an object, not the full array of objects. */
9854 for (i = 0; i < size; i++)
9855 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9856 sizeof(object)));
9857 @}
9858 @end smallexample
9859
9860 @end deftypefn
9861
9862 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9863
9864 This built-in function returns a new pointer with the value of @var{q},
9865 and associates it with the bounds already associated with pointer @var{r}.
9866 With Pointer Bounds Checker off, the built-in function just returns the first
9867 argument.
9868
9869 @smallexample
9870 /* Here is a way to get pointer to object's field but
9871 still with the full object's bounds. */
9872 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
9873 objptr);
9874 @end smallexample
9875
9876 @end deftypefn
9877
9878 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
9879
9880 This built-in function returns a new pointer with the value of @var{q}, and
9881 associates it with INIT (allowing full memory access) bounds. With Pointer
9882 Bounds Checker off, the built-in function just returns the first argument.
9883
9884 @end deftypefn
9885
9886 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
9887
9888 This built-in function returns a new pointer with the value of @var{q}, and
9889 associates it with NULL (allowing no memory access) bounds. With Pointer
9890 Bounds Checker off, the built-in function just returns the first argument.
9891
9892 @end deftypefn
9893
9894 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
9895
9896 This built-in function stores the bounds associated with pointer @var{ptr_val}
9897 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
9898 bounds from legacy code without touching the associated pointer's memory when
9899 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
9900 function call is ignored.
9901
9902 @end deftypefn
9903
9904 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
9905
9906 This built-in function checks if the pointer @var{q} is within the lower
9907 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
9908 function call is ignored.
9909
9910 @smallexample
9911 extern void *__wrap_memset (void *dst, int c, size_t len)
9912 @{
9913 if (len > 0)
9914 @{
9915 __builtin___bnd_chk_ptr_lbounds (dst);
9916 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
9917 __real_memset (dst, c, len);
9918 @}
9919 return dst;
9920 @}
9921 @end smallexample
9922
9923 @end deftypefn
9924
9925 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
9926
9927 This built-in function checks if the pointer @var{q} is within the upper
9928 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
9929 function call is ignored.
9930
9931 @end deftypefn
9932
9933 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
9934
9935 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
9936 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
9937 off, the built-in function call is ignored.
9938
9939 @smallexample
9940 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
9941 @{
9942 if (n > 0)
9943 @{
9944 __bnd_chk_ptr_bounds (dst, n);
9945 __bnd_chk_ptr_bounds (src, n);
9946 __real_memcpy (dst, src, n);
9947 @}
9948 return dst;
9949 @}
9950 @end smallexample
9951
9952 @end deftypefn
9953
9954 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
9955
9956 This built-in function returns the lower bound associated
9957 with the pointer @var{q}, as a pointer value.
9958 This is useful for debugging using @code{printf}.
9959 With Pointer Bounds Checker off, the built-in function returns 0.
9960
9961 @smallexample
9962 void *lb = __builtin___bnd_get_ptr_lbound (q);
9963 void *ub = __builtin___bnd_get_ptr_ubound (q);
9964 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
9965 @end smallexample
9966
9967 @end deftypefn
9968
9969 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
9970
9971 This built-in function returns the upper bound (which is a pointer) associated
9972 with the pointer @var{q}. With Pointer Bounds Checker off,
9973 the built-in function returns -1.
9974
9975 @end deftypefn
9976
9977 @node Cilk Plus Builtins
9978 @section Cilk Plus C/C++ Language Extension Built-in Functions
9979
9980 GCC provides support for the following built-in reduction functions if Cilk Plus
9981 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
9982
9983 @itemize @bullet
9984 @item @code{__sec_implicit_index}
9985 @item @code{__sec_reduce}
9986 @item @code{__sec_reduce_add}
9987 @item @code{__sec_reduce_all_nonzero}
9988 @item @code{__sec_reduce_all_zero}
9989 @item @code{__sec_reduce_any_nonzero}
9990 @item @code{__sec_reduce_any_zero}
9991 @item @code{__sec_reduce_max}
9992 @item @code{__sec_reduce_min}
9993 @item @code{__sec_reduce_max_ind}
9994 @item @code{__sec_reduce_min_ind}
9995 @item @code{__sec_reduce_mul}
9996 @item @code{__sec_reduce_mutating}
9997 @end itemize
9998
9999 Further details and examples about these built-in functions are described
10000 in the Cilk Plus language manual which can be found at
10001 @uref{http://www.cilkplus.org}.
10002
10003 @node Other Builtins
10004 @section Other Built-in Functions Provided by GCC
10005 @cindex built-in functions
10006 @findex __builtin_call_with_static_chain
10007 @findex __builtin_fpclassify
10008 @findex __builtin_isfinite
10009 @findex __builtin_isnormal
10010 @findex __builtin_isgreater
10011 @findex __builtin_isgreaterequal
10012 @findex __builtin_isinf_sign
10013 @findex __builtin_isless
10014 @findex __builtin_islessequal
10015 @findex __builtin_islessgreater
10016 @findex __builtin_isunordered
10017 @findex __builtin_powi
10018 @findex __builtin_powif
10019 @findex __builtin_powil
10020 @findex _Exit
10021 @findex _exit
10022 @findex abort
10023 @findex abs
10024 @findex acos
10025 @findex acosf
10026 @findex acosh
10027 @findex acoshf
10028 @findex acoshl
10029 @findex acosl
10030 @findex alloca
10031 @findex asin
10032 @findex asinf
10033 @findex asinh
10034 @findex asinhf
10035 @findex asinhl
10036 @findex asinl
10037 @findex atan
10038 @findex atan2
10039 @findex atan2f
10040 @findex atan2l
10041 @findex atanf
10042 @findex atanh
10043 @findex atanhf
10044 @findex atanhl
10045 @findex atanl
10046 @findex bcmp
10047 @findex bzero
10048 @findex cabs
10049 @findex cabsf
10050 @findex cabsl
10051 @findex cacos
10052 @findex cacosf
10053 @findex cacosh
10054 @findex cacoshf
10055 @findex cacoshl
10056 @findex cacosl
10057 @findex calloc
10058 @findex carg
10059 @findex cargf
10060 @findex cargl
10061 @findex casin
10062 @findex casinf
10063 @findex casinh
10064 @findex casinhf
10065 @findex casinhl
10066 @findex casinl
10067 @findex catan
10068 @findex catanf
10069 @findex catanh
10070 @findex catanhf
10071 @findex catanhl
10072 @findex catanl
10073 @findex cbrt
10074 @findex cbrtf
10075 @findex cbrtl
10076 @findex ccos
10077 @findex ccosf
10078 @findex ccosh
10079 @findex ccoshf
10080 @findex ccoshl
10081 @findex ccosl
10082 @findex ceil
10083 @findex ceilf
10084 @findex ceill
10085 @findex cexp
10086 @findex cexpf
10087 @findex cexpl
10088 @findex cimag
10089 @findex cimagf
10090 @findex cimagl
10091 @findex clog
10092 @findex clogf
10093 @findex clogl
10094 @findex conj
10095 @findex conjf
10096 @findex conjl
10097 @findex copysign
10098 @findex copysignf
10099 @findex copysignl
10100 @findex cos
10101 @findex cosf
10102 @findex cosh
10103 @findex coshf
10104 @findex coshl
10105 @findex cosl
10106 @findex cpow
10107 @findex cpowf
10108 @findex cpowl
10109 @findex cproj
10110 @findex cprojf
10111 @findex cprojl
10112 @findex creal
10113 @findex crealf
10114 @findex creall
10115 @findex csin
10116 @findex csinf
10117 @findex csinh
10118 @findex csinhf
10119 @findex csinhl
10120 @findex csinl
10121 @findex csqrt
10122 @findex csqrtf
10123 @findex csqrtl
10124 @findex ctan
10125 @findex ctanf
10126 @findex ctanh
10127 @findex ctanhf
10128 @findex ctanhl
10129 @findex ctanl
10130 @findex dcgettext
10131 @findex dgettext
10132 @findex drem
10133 @findex dremf
10134 @findex dreml
10135 @findex erf
10136 @findex erfc
10137 @findex erfcf
10138 @findex erfcl
10139 @findex erff
10140 @findex erfl
10141 @findex exit
10142 @findex exp
10143 @findex exp10
10144 @findex exp10f
10145 @findex exp10l
10146 @findex exp2
10147 @findex exp2f
10148 @findex exp2l
10149 @findex expf
10150 @findex expl
10151 @findex expm1
10152 @findex expm1f
10153 @findex expm1l
10154 @findex fabs
10155 @findex fabsf
10156 @findex fabsl
10157 @findex fdim
10158 @findex fdimf
10159 @findex fdiml
10160 @findex ffs
10161 @findex floor
10162 @findex floorf
10163 @findex floorl
10164 @findex fma
10165 @findex fmaf
10166 @findex fmal
10167 @findex fmax
10168 @findex fmaxf
10169 @findex fmaxl
10170 @findex fmin
10171 @findex fminf
10172 @findex fminl
10173 @findex fmod
10174 @findex fmodf
10175 @findex fmodl
10176 @findex fprintf
10177 @findex fprintf_unlocked
10178 @findex fputs
10179 @findex fputs_unlocked
10180 @findex frexp
10181 @findex frexpf
10182 @findex frexpl
10183 @findex fscanf
10184 @findex gamma
10185 @findex gammaf
10186 @findex gammal
10187 @findex gamma_r
10188 @findex gammaf_r
10189 @findex gammal_r
10190 @findex gettext
10191 @findex hypot
10192 @findex hypotf
10193 @findex hypotl
10194 @findex ilogb
10195 @findex ilogbf
10196 @findex ilogbl
10197 @findex imaxabs
10198 @findex index
10199 @findex isalnum
10200 @findex isalpha
10201 @findex isascii
10202 @findex isblank
10203 @findex iscntrl
10204 @findex isdigit
10205 @findex isgraph
10206 @findex islower
10207 @findex isprint
10208 @findex ispunct
10209 @findex isspace
10210 @findex isupper
10211 @findex iswalnum
10212 @findex iswalpha
10213 @findex iswblank
10214 @findex iswcntrl
10215 @findex iswdigit
10216 @findex iswgraph
10217 @findex iswlower
10218 @findex iswprint
10219 @findex iswpunct
10220 @findex iswspace
10221 @findex iswupper
10222 @findex iswxdigit
10223 @findex isxdigit
10224 @findex j0
10225 @findex j0f
10226 @findex j0l
10227 @findex j1
10228 @findex j1f
10229 @findex j1l
10230 @findex jn
10231 @findex jnf
10232 @findex jnl
10233 @findex labs
10234 @findex ldexp
10235 @findex ldexpf
10236 @findex ldexpl
10237 @findex lgamma
10238 @findex lgammaf
10239 @findex lgammal
10240 @findex lgamma_r
10241 @findex lgammaf_r
10242 @findex lgammal_r
10243 @findex llabs
10244 @findex llrint
10245 @findex llrintf
10246 @findex llrintl
10247 @findex llround
10248 @findex llroundf
10249 @findex llroundl
10250 @findex log
10251 @findex log10
10252 @findex log10f
10253 @findex log10l
10254 @findex log1p
10255 @findex log1pf
10256 @findex log1pl
10257 @findex log2
10258 @findex log2f
10259 @findex log2l
10260 @findex logb
10261 @findex logbf
10262 @findex logbl
10263 @findex logf
10264 @findex logl
10265 @findex lrint
10266 @findex lrintf
10267 @findex lrintl
10268 @findex lround
10269 @findex lroundf
10270 @findex lroundl
10271 @findex malloc
10272 @findex memchr
10273 @findex memcmp
10274 @findex memcpy
10275 @findex mempcpy
10276 @findex memset
10277 @findex modf
10278 @findex modff
10279 @findex modfl
10280 @findex nearbyint
10281 @findex nearbyintf
10282 @findex nearbyintl
10283 @findex nextafter
10284 @findex nextafterf
10285 @findex nextafterl
10286 @findex nexttoward
10287 @findex nexttowardf
10288 @findex nexttowardl
10289 @findex pow
10290 @findex pow10
10291 @findex pow10f
10292 @findex pow10l
10293 @findex powf
10294 @findex powl
10295 @findex printf
10296 @findex printf_unlocked
10297 @findex putchar
10298 @findex puts
10299 @findex remainder
10300 @findex remainderf
10301 @findex remainderl
10302 @findex remquo
10303 @findex remquof
10304 @findex remquol
10305 @findex rindex
10306 @findex rint
10307 @findex rintf
10308 @findex rintl
10309 @findex round
10310 @findex roundf
10311 @findex roundl
10312 @findex scalb
10313 @findex scalbf
10314 @findex scalbl
10315 @findex scalbln
10316 @findex scalblnf
10317 @findex scalblnf
10318 @findex scalbn
10319 @findex scalbnf
10320 @findex scanfnl
10321 @findex signbit
10322 @findex signbitf
10323 @findex signbitl
10324 @findex signbitd32
10325 @findex signbitd64
10326 @findex signbitd128
10327 @findex significand
10328 @findex significandf
10329 @findex significandl
10330 @findex sin
10331 @findex sincos
10332 @findex sincosf
10333 @findex sincosl
10334 @findex sinf
10335 @findex sinh
10336 @findex sinhf
10337 @findex sinhl
10338 @findex sinl
10339 @findex snprintf
10340 @findex sprintf
10341 @findex sqrt
10342 @findex sqrtf
10343 @findex sqrtl
10344 @findex sscanf
10345 @findex stpcpy
10346 @findex stpncpy
10347 @findex strcasecmp
10348 @findex strcat
10349 @findex strchr
10350 @findex strcmp
10351 @findex strcpy
10352 @findex strcspn
10353 @findex strdup
10354 @findex strfmon
10355 @findex strftime
10356 @findex strlen
10357 @findex strncasecmp
10358 @findex strncat
10359 @findex strncmp
10360 @findex strncpy
10361 @findex strndup
10362 @findex strpbrk
10363 @findex strrchr
10364 @findex strspn
10365 @findex strstr
10366 @findex tan
10367 @findex tanf
10368 @findex tanh
10369 @findex tanhf
10370 @findex tanhl
10371 @findex tanl
10372 @findex tgamma
10373 @findex tgammaf
10374 @findex tgammal
10375 @findex toascii
10376 @findex tolower
10377 @findex toupper
10378 @findex towlower
10379 @findex towupper
10380 @findex trunc
10381 @findex truncf
10382 @findex truncl
10383 @findex vfprintf
10384 @findex vfscanf
10385 @findex vprintf
10386 @findex vscanf
10387 @findex vsnprintf
10388 @findex vsprintf
10389 @findex vsscanf
10390 @findex y0
10391 @findex y0f
10392 @findex y0l
10393 @findex y1
10394 @findex y1f
10395 @findex y1l
10396 @findex yn
10397 @findex ynf
10398 @findex ynl
10399
10400 GCC provides a large number of built-in functions other than the ones
10401 mentioned above. Some of these are for internal use in the processing
10402 of exceptions or variable-length argument lists and are not
10403 documented here because they may change from time to time; we do not
10404 recommend general use of these functions.
10405
10406 The remaining functions are provided for optimization purposes.
10407
10408 With the exception of built-ins that have library equivalents such as
10409 the standard C library functions discussed below, or that expand to
10410 library calls, GCC built-in functions are always expanded inline and
10411 thus do not have corresponding entry points and their address cannot
10412 be obtained. Attempting to use them in an expression other than
10413 a function call results in a compile-time error.
10414
10415 @opindex fno-builtin
10416 GCC includes built-in versions of many of the functions in the standard
10417 C library. These functions come in two forms: one whose names start with
10418 the @code{__builtin_} prefix, and the other without. Both forms have the
10419 same type (including prototype), the same address (when their address is
10420 taken), and the same meaning as the C library functions even if you specify
10421 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10422 functions are only optimized in certain cases; if they are not optimized in
10423 a particular case, a call to the library function is emitted.
10424
10425 @opindex ansi
10426 @opindex std
10427 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10428 @option{-std=c99} or @option{-std=c11}), the functions
10429 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10430 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10431 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10432 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10433 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10434 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10435 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10436 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10437 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10438 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10439 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10440 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10441 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10442 @code{significandl}, @code{significand}, @code{sincosf},
10443 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10444 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10445 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10446 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10447 @code{yn}
10448 may be handled as built-in functions.
10449 All these functions have corresponding versions
10450 prefixed with @code{__builtin_}, which may be used even in strict C90
10451 mode.
10452
10453 The ISO C99 functions
10454 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10455 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10456 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10457 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10458 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10459 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10460 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10461 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10462 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10463 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10464 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10465 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10466 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10467 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10468 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10469 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10470 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10471 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10472 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10473 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10474 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10475 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10476 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10477 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10478 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10479 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10480 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10481 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10482 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10483 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10484 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10485 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10486 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10487 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10488 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10489 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10490 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10491 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10492 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10493 are handled as built-in functions
10494 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10495
10496 There are also built-in versions of the ISO C99 functions
10497 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10498 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10499 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10500 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10501 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10502 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10503 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10504 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10505 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10506 that are recognized in any mode since ISO C90 reserves these names for
10507 the purpose to which ISO C99 puts them. All these functions have
10508 corresponding versions prefixed with @code{__builtin_}.
10509
10510 The ISO C94 functions
10511 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10512 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10513 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10514 @code{towupper}
10515 are handled as built-in functions
10516 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10517
10518 The ISO C90 functions
10519 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10520 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10521 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10522 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10523 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10524 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10525 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10526 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10527 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10528 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10529 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10530 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10531 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10532 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10533 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10534 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10535 are all recognized as built-in functions unless
10536 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10537 is specified for an individual function). All of these functions have
10538 corresponding versions prefixed with @code{__builtin_}.
10539
10540 GCC provides built-in versions of the ISO C99 floating-point comparison
10541 macros that avoid raising exceptions for unordered operands. They have
10542 the same names as the standard macros ( @code{isgreater},
10543 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10544 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10545 prefixed. We intend for a library implementor to be able to simply
10546 @code{#define} each standard macro to its built-in equivalent.
10547 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10548 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10549 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10550 built-in functions appear both with and without the @code{__builtin_} prefix.
10551
10552 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10553
10554 You can use the built-in function @code{__builtin_types_compatible_p} to
10555 determine whether two types are the same.
10556
10557 This built-in function returns 1 if the unqualified versions of the
10558 types @var{type1} and @var{type2} (which are types, not expressions) are
10559 compatible, 0 otherwise. The result of this built-in function can be
10560 used in integer constant expressions.
10561
10562 This built-in function ignores top level qualifiers (e.g., @code{const},
10563 @code{volatile}). For example, @code{int} is equivalent to @code{const
10564 int}.
10565
10566 The type @code{int[]} and @code{int[5]} are compatible. On the other
10567 hand, @code{int} and @code{char *} are not compatible, even if the size
10568 of their types, on the particular architecture are the same. Also, the
10569 amount of pointer indirection is taken into account when determining
10570 similarity. Consequently, @code{short *} is not similar to
10571 @code{short **}. Furthermore, two types that are typedefed are
10572 considered compatible if their underlying types are compatible.
10573
10574 An @code{enum} type is not considered to be compatible with another
10575 @code{enum} type even if both are compatible with the same integer
10576 type; this is what the C standard specifies.
10577 For example, @code{enum @{foo, bar@}} is not similar to
10578 @code{enum @{hot, dog@}}.
10579
10580 You typically use this function in code whose execution varies
10581 depending on the arguments' types. For example:
10582
10583 @smallexample
10584 #define foo(x) \
10585 (@{ \
10586 typeof (x) tmp = (x); \
10587 if (__builtin_types_compatible_p (typeof (x), long double)) \
10588 tmp = foo_long_double (tmp); \
10589 else if (__builtin_types_compatible_p (typeof (x), double)) \
10590 tmp = foo_double (tmp); \
10591 else if (__builtin_types_compatible_p (typeof (x), float)) \
10592 tmp = foo_float (tmp); \
10593 else \
10594 abort (); \
10595 tmp; \
10596 @})
10597 @end smallexample
10598
10599 @emph{Note:} This construct is only available for C@.
10600
10601 @end deftypefn
10602
10603 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10604
10605 The @var{call_exp} expression must be a function call, and the
10606 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10607 is passed to the function call in the target's static chain location.
10608 The result of builtin is the result of the function call.
10609
10610 @emph{Note:} This builtin is only available for C@.
10611 This builtin can be used to call Go closures from C.
10612
10613 @end deftypefn
10614
10615 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10616
10617 You can use the built-in function @code{__builtin_choose_expr} to
10618 evaluate code depending on the value of a constant expression. This
10619 built-in function returns @var{exp1} if @var{const_exp}, which is an
10620 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10621
10622 This built-in function is analogous to the @samp{? :} operator in C,
10623 except that the expression returned has its type unaltered by promotion
10624 rules. Also, the built-in function does not evaluate the expression
10625 that is not chosen. For example, if @var{const_exp} evaluates to true,
10626 @var{exp2} is not evaluated even if it has side-effects.
10627
10628 This built-in function can return an lvalue if the chosen argument is an
10629 lvalue.
10630
10631 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10632 type. Similarly, if @var{exp2} is returned, its return type is the same
10633 as @var{exp2}.
10634
10635 Example:
10636
10637 @smallexample
10638 #define foo(x) \
10639 __builtin_choose_expr ( \
10640 __builtin_types_compatible_p (typeof (x), double), \
10641 foo_double (x), \
10642 __builtin_choose_expr ( \
10643 __builtin_types_compatible_p (typeof (x), float), \
10644 foo_float (x), \
10645 /* @r{The void expression results in a compile-time error} \
10646 @r{when assigning the result to something.} */ \
10647 (void)0))
10648 @end smallexample
10649
10650 @emph{Note:} This construct is only available for C@. Furthermore, the
10651 unused expression (@var{exp1} or @var{exp2} depending on the value of
10652 @var{const_exp}) may still generate syntax errors. This may change in
10653 future revisions.
10654
10655 @end deftypefn
10656
10657 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10658
10659 The built-in function @code{__builtin_complex} is provided for use in
10660 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10661 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10662 real binary floating-point type, and the result has the corresponding
10663 complex type with real and imaginary parts @var{real} and @var{imag}.
10664 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10665 infinities, NaNs and negative zeros are involved.
10666
10667 @end deftypefn
10668
10669 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10670 You can use the built-in function @code{__builtin_constant_p} to
10671 determine if a value is known to be constant at compile time and hence
10672 that GCC can perform constant-folding on expressions involving that
10673 value. The argument of the function is the value to test. The function
10674 returns the integer 1 if the argument is known to be a compile-time
10675 constant and 0 if it is not known to be a compile-time constant. A
10676 return of 0 does not indicate that the value is @emph{not} a constant,
10677 but merely that GCC cannot prove it is a constant with the specified
10678 value of the @option{-O} option.
10679
10680 You typically use this function in an embedded application where
10681 memory is a critical resource. If you have some complex calculation,
10682 you may want it to be folded if it involves constants, but need to call
10683 a function if it does not. For example:
10684
10685 @smallexample
10686 #define Scale_Value(X) \
10687 (__builtin_constant_p (X) \
10688 ? ((X) * SCALE + OFFSET) : Scale (X))
10689 @end smallexample
10690
10691 You may use this built-in function in either a macro or an inline
10692 function. However, if you use it in an inlined function and pass an
10693 argument of the function as the argument to the built-in, GCC
10694 never returns 1 when you call the inline function with a string constant
10695 or compound literal (@pxref{Compound Literals}) and does not return 1
10696 when you pass a constant numeric value to the inline function unless you
10697 specify the @option{-O} option.
10698
10699 You may also use @code{__builtin_constant_p} in initializers for static
10700 data. For instance, you can write
10701
10702 @smallexample
10703 static const int table[] = @{
10704 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10705 /* @r{@dots{}} */
10706 @};
10707 @end smallexample
10708
10709 @noindent
10710 This is an acceptable initializer even if @var{EXPRESSION} is not a
10711 constant expression, including the case where
10712 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10713 folded to a constant but @var{EXPRESSION} contains operands that are
10714 not otherwise permitted in a static initializer (for example,
10715 @code{0 && foo ()}). GCC must be more conservative about evaluating the
10716 built-in in this case, because it has no opportunity to perform
10717 optimization.
10718 @end deftypefn
10719
10720 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10721 @opindex fprofile-arcs
10722 You may use @code{__builtin_expect} to provide the compiler with
10723 branch prediction information. In general, you should prefer to
10724 use actual profile feedback for this (@option{-fprofile-arcs}), as
10725 programmers are notoriously bad at predicting how their programs
10726 actually perform. However, there are applications in which this
10727 data is hard to collect.
10728
10729 The return value is the value of @var{exp}, which should be an integral
10730 expression. The semantics of the built-in are that it is expected that
10731 @var{exp} == @var{c}. For example:
10732
10733 @smallexample
10734 if (__builtin_expect (x, 0))
10735 foo ();
10736 @end smallexample
10737
10738 @noindent
10739 indicates that we do not expect to call @code{foo}, since
10740 we expect @code{x} to be zero. Since you are limited to integral
10741 expressions for @var{exp}, you should use constructions such as
10742
10743 @smallexample
10744 if (__builtin_expect (ptr != NULL, 1))
10745 foo (*ptr);
10746 @end smallexample
10747
10748 @noindent
10749 when testing pointer or floating-point values.
10750 @end deftypefn
10751
10752 @deftypefn {Built-in Function} void __builtin_trap (void)
10753 This function causes the program to exit abnormally. GCC implements
10754 this function by using a target-dependent mechanism (such as
10755 intentionally executing an illegal instruction) or by calling
10756 @code{abort}. The mechanism used may vary from release to release so
10757 you should not rely on any particular implementation.
10758 @end deftypefn
10759
10760 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10761 If control flow reaches the point of the @code{__builtin_unreachable},
10762 the program is undefined. It is useful in situations where the
10763 compiler cannot deduce the unreachability of the code.
10764
10765 One such case is immediately following an @code{asm} statement that
10766 either never terminates, or one that transfers control elsewhere
10767 and never returns. In this example, without the
10768 @code{__builtin_unreachable}, GCC issues a warning that control
10769 reaches the end of a non-void function. It also generates code
10770 to return after the @code{asm}.
10771
10772 @smallexample
10773 int f (int c, int v)
10774 @{
10775 if (c)
10776 @{
10777 return v;
10778 @}
10779 else
10780 @{
10781 asm("jmp error_handler");
10782 __builtin_unreachable ();
10783 @}
10784 @}
10785 @end smallexample
10786
10787 @noindent
10788 Because the @code{asm} statement unconditionally transfers control out
10789 of the function, control never reaches the end of the function
10790 body. The @code{__builtin_unreachable} is in fact unreachable and
10791 communicates this fact to the compiler.
10792
10793 Another use for @code{__builtin_unreachable} is following a call a
10794 function that never returns but that is not declared
10795 @code{__attribute__((noreturn))}, as in this example:
10796
10797 @smallexample
10798 void function_that_never_returns (void);
10799
10800 int g (int c)
10801 @{
10802 if (c)
10803 @{
10804 return 1;
10805 @}
10806 else
10807 @{
10808 function_that_never_returns ();
10809 __builtin_unreachable ();
10810 @}
10811 @}
10812 @end smallexample
10813
10814 @end deftypefn
10815
10816 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10817 This function returns its first argument, and allows the compiler
10818 to assume that the returned pointer is at least @var{align} bytes
10819 aligned. This built-in can have either two or three arguments,
10820 if it has three, the third argument should have integer type, and
10821 if it is nonzero means misalignment offset. For example:
10822
10823 @smallexample
10824 void *x = __builtin_assume_aligned (arg, 16);
10825 @end smallexample
10826
10827 @noindent
10828 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10829 16-byte aligned, while:
10830
10831 @smallexample
10832 void *x = __builtin_assume_aligned (arg, 32, 8);
10833 @end smallexample
10834
10835 @noindent
10836 means that the compiler can assume for @code{x}, set to @code{arg}, that
10837 @code{(char *) x - 8} is 32-byte aligned.
10838 @end deftypefn
10839
10840 @deftypefn {Built-in Function} int __builtin_LINE ()
10841 This function is the equivalent to the preprocessor @code{__LINE__}
10842 macro and returns the line number of the invocation of the built-in.
10843 In a C++ default argument for a function @var{F}, it gets the line number of
10844 the call to @var{F}.
10845 @end deftypefn
10846
10847 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10848 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10849 macro and returns the function name the invocation of the built-in is in.
10850 @end deftypefn
10851
10852 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10853 This function is the equivalent to the preprocessor @code{__FILE__}
10854 macro and returns the file name the invocation of the built-in is in.
10855 In a C++ default argument for a function @var{F}, it gets the file name of
10856 the call to @var{F}.
10857 @end deftypefn
10858
10859 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10860 This function is used to flush the processor's instruction cache for
10861 the region of memory between @var{begin} inclusive and @var{end}
10862 exclusive. Some targets require that the instruction cache be
10863 flushed, after modifying memory containing code, in order to obtain
10864 deterministic behavior.
10865
10866 If the target does not require instruction cache flushes,
10867 @code{__builtin___clear_cache} has no effect. Otherwise either
10868 instructions are emitted in-line to clear the instruction cache or a
10869 call to the @code{__clear_cache} function in libgcc is made.
10870 @end deftypefn
10871
10872 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10873 This function is used to minimize cache-miss latency by moving data into
10874 a cache before it is accessed.
10875 You can insert calls to @code{__builtin_prefetch} into code for which
10876 you know addresses of data in memory that is likely to be accessed soon.
10877 If the target supports them, data prefetch instructions are generated.
10878 If the prefetch is done early enough before the access then the data will
10879 be in the cache by the time it is accessed.
10880
10881 The value of @var{addr} is the address of the memory to prefetch.
10882 There are two optional arguments, @var{rw} and @var{locality}.
10883 The value of @var{rw} is a compile-time constant one or zero; one
10884 means that the prefetch is preparing for a write to the memory address
10885 and zero, the default, means that the prefetch is preparing for a read.
10886 The value @var{locality} must be a compile-time constant integer between
10887 zero and three. A value of zero means that the data has no temporal
10888 locality, so it need not be left in the cache after the access. A value
10889 of three means that the data has a high degree of temporal locality and
10890 should be left in all levels of cache possible. Values of one and two
10891 mean, respectively, a low or moderate degree of temporal locality. The
10892 default is three.
10893
10894 @smallexample
10895 for (i = 0; i < n; i++)
10896 @{
10897 a[i] = a[i] + b[i];
10898 __builtin_prefetch (&a[i+j], 1, 1);
10899 __builtin_prefetch (&b[i+j], 0, 1);
10900 /* @r{@dots{}} */
10901 @}
10902 @end smallexample
10903
10904 Data prefetch does not generate faults if @var{addr} is invalid, but
10905 the address expression itself must be valid. For example, a prefetch
10906 of @code{p->next} does not fault if @code{p->next} is not a valid
10907 address, but evaluation faults if @code{p} is not a valid address.
10908
10909 If the target does not support data prefetch, the address expression
10910 is evaluated if it includes side effects but no other code is generated
10911 and GCC does not issue a warning.
10912 @end deftypefn
10913
10914 @deftypefn {Built-in Function} double __builtin_huge_val (void)
10915 Returns a positive infinity, if supported by the floating-point format,
10916 else @code{DBL_MAX}. This function is suitable for implementing the
10917 ISO C macro @code{HUGE_VAL}.
10918 @end deftypefn
10919
10920 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
10921 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
10922 @end deftypefn
10923
10924 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
10925 Similar to @code{__builtin_huge_val}, except the return
10926 type is @code{long double}.
10927 @end deftypefn
10928
10929 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
10930 This built-in implements the C99 fpclassify functionality. The first
10931 five int arguments should be the target library's notion of the
10932 possible FP classes and are used for return values. They must be
10933 constant values and they must appear in this order: @code{FP_NAN},
10934 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
10935 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
10936 to classify. GCC treats the last argument as type-generic, which
10937 means it does not do default promotion from float to double.
10938 @end deftypefn
10939
10940 @deftypefn {Built-in Function} double __builtin_inf (void)
10941 Similar to @code{__builtin_huge_val}, except a warning is generated
10942 if the target floating-point format does not support infinities.
10943 @end deftypefn
10944
10945 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
10946 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
10947 @end deftypefn
10948
10949 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
10950 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
10951 @end deftypefn
10952
10953 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
10954 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
10955 @end deftypefn
10956
10957 @deftypefn {Built-in Function} float __builtin_inff (void)
10958 Similar to @code{__builtin_inf}, except the return type is @code{float}.
10959 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
10960 @end deftypefn
10961
10962 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
10963 Similar to @code{__builtin_inf}, except the return
10964 type is @code{long double}.
10965 @end deftypefn
10966
10967 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
10968 Similar to @code{isinf}, except the return value is -1 for
10969 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
10970 Note while the parameter list is an
10971 ellipsis, this function only accepts exactly one floating-point
10972 argument. GCC treats this parameter as type-generic, which means it
10973 does not do default promotion from float to double.
10974 @end deftypefn
10975
10976 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
10977 This is an implementation of the ISO C99 function @code{nan}.
10978
10979 Since ISO C99 defines this function in terms of @code{strtod}, which we
10980 do not implement, a description of the parsing is in order. The string
10981 is parsed as by @code{strtol}; that is, the base is recognized by
10982 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
10983 in the significand such that the least significant bit of the number
10984 is at the least significant bit of the significand. The number is
10985 truncated to fit the significand field provided. The significand is
10986 forced to be a quiet NaN@.
10987
10988 This function, if given a string literal all of which would have been
10989 consumed by @code{strtol}, is evaluated early enough that it is considered a
10990 compile-time constant.
10991 @end deftypefn
10992
10993 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
10994 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
10995 @end deftypefn
10996
10997 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
10998 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
10999 @end deftypefn
11000
11001 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11002 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11003 @end deftypefn
11004
11005 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11006 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11007 @end deftypefn
11008
11009 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11010 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11011 @end deftypefn
11012
11013 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11014 Similar to @code{__builtin_nan}, except the significand is forced
11015 to be a signaling NaN@. The @code{nans} function is proposed by
11016 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11017 @end deftypefn
11018
11019 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11020 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11021 @end deftypefn
11022
11023 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11024 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11025 @end deftypefn
11026
11027 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11028 Returns one plus the index of the least significant 1-bit of @var{x}, or
11029 if @var{x} is zero, returns zero.
11030 @end deftypefn
11031
11032 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11033 Returns the number of leading 0-bits in @var{x}, starting at the most
11034 significant bit position. If @var{x} is 0, the result is undefined.
11035 @end deftypefn
11036
11037 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11038 Returns the number of trailing 0-bits in @var{x}, starting at the least
11039 significant bit position. If @var{x} is 0, the result is undefined.
11040 @end deftypefn
11041
11042 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11043 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11044 number of bits following the most significant bit that are identical
11045 to it. There are no special cases for 0 or other values.
11046 @end deftypefn
11047
11048 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11049 Returns the number of 1-bits in @var{x}.
11050 @end deftypefn
11051
11052 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11053 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11054 modulo 2.
11055 @end deftypefn
11056
11057 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11058 Similar to @code{__builtin_ffs}, except the argument type is
11059 @code{long}.
11060 @end deftypefn
11061
11062 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11063 Similar to @code{__builtin_clz}, except the argument type is
11064 @code{unsigned long}.
11065 @end deftypefn
11066
11067 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11068 Similar to @code{__builtin_ctz}, except the argument type is
11069 @code{unsigned long}.
11070 @end deftypefn
11071
11072 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11073 Similar to @code{__builtin_clrsb}, except the argument type is
11074 @code{long}.
11075 @end deftypefn
11076
11077 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11078 Similar to @code{__builtin_popcount}, except the argument type is
11079 @code{unsigned long}.
11080 @end deftypefn
11081
11082 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11083 Similar to @code{__builtin_parity}, except the argument type is
11084 @code{unsigned long}.
11085 @end deftypefn
11086
11087 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11088 Similar to @code{__builtin_ffs}, except the argument type is
11089 @code{long long}.
11090 @end deftypefn
11091
11092 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11093 Similar to @code{__builtin_clz}, except the argument type is
11094 @code{unsigned long long}.
11095 @end deftypefn
11096
11097 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11098 Similar to @code{__builtin_ctz}, except the argument type is
11099 @code{unsigned long long}.
11100 @end deftypefn
11101
11102 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11103 Similar to @code{__builtin_clrsb}, except the argument type is
11104 @code{long long}.
11105 @end deftypefn
11106
11107 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11108 Similar to @code{__builtin_popcount}, except the argument type is
11109 @code{unsigned long long}.
11110 @end deftypefn
11111
11112 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11113 Similar to @code{__builtin_parity}, except the argument type is
11114 @code{unsigned long long}.
11115 @end deftypefn
11116
11117 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11118 Returns the first argument raised to the power of the second. Unlike the
11119 @code{pow} function no guarantees about precision and rounding are made.
11120 @end deftypefn
11121
11122 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11123 Similar to @code{__builtin_powi}, except the argument and return types
11124 are @code{float}.
11125 @end deftypefn
11126
11127 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11128 Similar to @code{__builtin_powi}, except the argument and return types
11129 are @code{long double}.
11130 @end deftypefn
11131
11132 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11133 Returns @var{x} with the order of the bytes reversed; for example,
11134 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11135 exactly 8 bits.
11136 @end deftypefn
11137
11138 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11139 Similar to @code{__builtin_bswap16}, except the argument and return types
11140 are 32 bit.
11141 @end deftypefn
11142
11143 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11144 Similar to @code{__builtin_bswap32}, except the argument and return types
11145 are 64 bit.
11146 @end deftypefn
11147
11148 @node Target Builtins
11149 @section Built-in Functions Specific to Particular Target Machines
11150
11151 On some target machines, GCC supports many built-in functions specific
11152 to those machines. Generally these generate calls to specific machine
11153 instructions, but allow the compiler to schedule those calls.
11154
11155 @menu
11156 * AArch64 Built-in Functions::
11157 * Alpha Built-in Functions::
11158 * Altera Nios II Built-in Functions::
11159 * ARC Built-in Functions::
11160 * ARC SIMD Built-in Functions::
11161 * ARM iWMMXt Built-in Functions::
11162 * ARM C Language Extensions (ACLE)::
11163 * ARM Floating Point Status and Control Intrinsics::
11164 * AVR Built-in Functions::
11165 * Blackfin Built-in Functions::
11166 * FR-V Built-in Functions::
11167 * MIPS DSP Built-in Functions::
11168 * MIPS Paired-Single Support::
11169 * MIPS Loongson Built-in Functions::
11170 * Other MIPS Built-in Functions::
11171 * MSP430 Built-in Functions::
11172 * NDS32 Built-in Functions::
11173 * picoChip Built-in Functions::
11174 * PowerPC Built-in Functions::
11175 * PowerPC AltiVec/VSX Built-in Functions::
11176 * PowerPC Hardware Transactional Memory Built-in Functions::
11177 * RX Built-in Functions::
11178 * S/390 System z Built-in Functions::
11179 * SH Built-in Functions::
11180 * SPARC VIS Built-in Functions::
11181 * SPU Built-in Functions::
11182 * TI C6X Built-in Functions::
11183 * TILE-Gx Built-in Functions::
11184 * TILEPro Built-in Functions::
11185 * x86 Built-in Functions::
11186 * x86 transactional memory intrinsics::
11187 @end menu
11188
11189 @node AArch64 Built-in Functions
11190 @subsection AArch64 Built-in Functions
11191
11192 These built-in functions are available for the AArch64 family of
11193 processors.
11194 @smallexample
11195 unsigned int __builtin_aarch64_get_fpcr ()
11196 void __builtin_aarch64_set_fpcr (unsigned int)
11197 unsigned int __builtin_aarch64_get_fpsr ()
11198 void __builtin_aarch64_set_fpsr (unsigned int)
11199 @end smallexample
11200
11201 @node Alpha Built-in Functions
11202 @subsection Alpha Built-in Functions
11203
11204 These built-in functions are available for the Alpha family of
11205 processors, depending on the command-line switches used.
11206
11207 The following built-in functions are always available. They
11208 all generate the machine instruction that is part of the name.
11209
11210 @smallexample
11211 long __builtin_alpha_implver (void)
11212 long __builtin_alpha_rpcc (void)
11213 long __builtin_alpha_amask (long)
11214 long __builtin_alpha_cmpbge (long, long)
11215 long __builtin_alpha_extbl (long, long)
11216 long __builtin_alpha_extwl (long, long)
11217 long __builtin_alpha_extll (long, long)
11218 long __builtin_alpha_extql (long, long)
11219 long __builtin_alpha_extwh (long, long)
11220 long __builtin_alpha_extlh (long, long)
11221 long __builtin_alpha_extqh (long, long)
11222 long __builtin_alpha_insbl (long, long)
11223 long __builtin_alpha_inswl (long, long)
11224 long __builtin_alpha_insll (long, long)
11225 long __builtin_alpha_insql (long, long)
11226 long __builtin_alpha_inswh (long, long)
11227 long __builtin_alpha_inslh (long, long)
11228 long __builtin_alpha_insqh (long, long)
11229 long __builtin_alpha_mskbl (long, long)
11230 long __builtin_alpha_mskwl (long, long)
11231 long __builtin_alpha_mskll (long, long)
11232 long __builtin_alpha_mskql (long, long)
11233 long __builtin_alpha_mskwh (long, long)
11234 long __builtin_alpha_msklh (long, long)
11235 long __builtin_alpha_mskqh (long, long)
11236 long __builtin_alpha_umulh (long, long)
11237 long __builtin_alpha_zap (long, long)
11238 long __builtin_alpha_zapnot (long, long)
11239 @end smallexample
11240
11241 The following built-in functions are always with @option{-mmax}
11242 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11243 later. They all generate the machine instruction that is part
11244 of the name.
11245
11246 @smallexample
11247 long __builtin_alpha_pklb (long)
11248 long __builtin_alpha_pkwb (long)
11249 long __builtin_alpha_unpkbl (long)
11250 long __builtin_alpha_unpkbw (long)
11251 long __builtin_alpha_minub8 (long, long)
11252 long __builtin_alpha_minsb8 (long, long)
11253 long __builtin_alpha_minuw4 (long, long)
11254 long __builtin_alpha_minsw4 (long, long)
11255 long __builtin_alpha_maxub8 (long, long)
11256 long __builtin_alpha_maxsb8 (long, long)
11257 long __builtin_alpha_maxuw4 (long, long)
11258 long __builtin_alpha_maxsw4 (long, long)
11259 long __builtin_alpha_perr (long, long)
11260 @end smallexample
11261
11262 The following built-in functions are always with @option{-mcix}
11263 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11264 later. They all generate the machine instruction that is part
11265 of the name.
11266
11267 @smallexample
11268 long __builtin_alpha_cttz (long)
11269 long __builtin_alpha_ctlz (long)
11270 long __builtin_alpha_ctpop (long)
11271 @end smallexample
11272
11273 The following built-in functions are available on systems that use the OSF/1
11274 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11275 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11276 @code{rdval} and @code{wrval}.
11277
11278 @smallexample
11279 void *__builtin_thread_pointer (void)
11280 void __builtin_set_thread_pointer (void *)
11281 @end smallexample
11282
11283 @node Altera Nios II Built-in Functions
11284 @subsection Altera Nios II Built-in Functions
11285
11286 These built-in functions are available for the Altera Nios II
11287 family of processors.
11288
11289 The following built-in functions are always available. They
11290 all generate the machine instruction that is part of the name.
11291
11292 @example
11293 int __builtin_ldbio (volatile const void *)
11294 int __builtin_ldbuio (volatile const void *)
11295 int __builtin_ldhio (volatile const void *)
11296 int __builtin_ldhuio (volatile const void *)
11297 int __builtin_ldwio (volatile const void *)
11298 void __builtin_stbio (volatile void *, int)
11299 void __builtin_sthio (volatile void *, int)
11300 void __builtin_stwio (volatile void *, int)
11301 void __builtin_sync (void)
11302 int __builtin_rdctl (int)
11303 int __builtin_rdprs (int, int)
11304 void __builtin_wrctl (int, int)
11305 void __builtin_flushd (volatile void *)
11306 void __builtin_flushda (volatile void *)
11307 int __builtin_wrpie (int);
11308 void __builtin_eni (int);
11309 int __builtin_ldex (volatile const void *)
11310 int __builtin_stex (volatile void *, int)
11311 int __builtin_ldsex (volatile const void *)
11312 int __builtin_stsex (volatile void *, int)
11313 @end example
11314
11315 The following built-in functions are always available. They
11316 all generate a Nios II Custom Instruction. The name of the
11317 function represents the types that the function takes and
11318 returns. The letter before the @code{n} is the return type
11319 or void if absent. The @code{n} represents the first parameter
11320 to all the custom instructions, the custom instruction number.
11321 The two letters after the @code{n} represent the up to two
11322 parameters to the function.
11323
11324 The letters represent the following data types:
11325 @table @code
11326 @item <no letter>
11327 @code{void} for return type and no parameter for parameter types.
11328
11329 @item i
11330 @code{int} for return type and parameter type
11331
11332 @item f
11333 @code{float} for return type and parameter type
11334
11335 @item p
11336 @code{void *} for return type and parameter type
11337
11338 @end table
11339
11340 And the function names are:
11341 @example
11342 void __builtin_custom_n (void)
11343 void __builtin_custom_ni (int)
11344 void __builtin_custom_nf (float)
11345 void __builtin_custom_np (void *)
11346 void __builtin_custom_nii (int, int)
11347 void __builtin_custom_nif (int, float)
11348 void __builtin_custom_nip (int, void *)
11349 void __builtin_custom_nfi (float, int)
11350 void __builtin_custom_nff (float, float)
11351 void __builtin_custom_nfp (float, void *)
11352 void __builtin_custom_npi (void *, int)
11353 void __builtin_custom_npf (void *, float)
11354 void __builtin_custom_npp (void *, void *)
11355 int __builtin_custom_in (void)
11356 int __builtin_custom_ini (int)
11357 int __builtin_custom_inf (float)
11358 int __builtin_custom_inp (void *)
11359 int __builtin_custom_inii (int, int)
11360 int __builtin_custom_inif (int, float)
11361 int __builtin_custom_inip (int, void *)
11362 int __builtin_custom_infi (float, int)
11363 int __builtin_custom_inff (float, float)
11364 int __builtin_custom_infp (float, void *)
11365 int __builtin_custom_inpi (void *, int)
11366 int __builtin_custom_inpf (void *, float)
11367 int __builtin_custom_inpp (void *, void *)
11368 float __builtin_custom_fn (void)
11369 float __builtin_custom_fni (int)
11370 float __builtin_custom_fnf (float)
11371 float __builtin_custom_fnp (void *)
11372 float __builtin_custom_fnii (int, int)
11373 float __builtin_custom_fnif (int, float)
11374 float __builtin_custom_fnip (int, void *)
11375 float __builtin_custom_fnfi (float, int)
11376 float __builtin_custom_fnff (float, float)
11377 float __builtin_custom_fnfp (float, void *)
11378 float __builtin_custom_fnpi (void *, int)
11379 float __builtin_custom_fnpf (void *, float)
11380 float __builtin_custom_fnpp (void *, void *)
11381 void * __builtin_custom_pn (void)
11382 void * __builtin_custom_pni (int)
11383 void * __builtin_custom_pnf (float)
11384 void * __builtin_custom_pnp (void *)
11385 void * __builtin_custom_pnii (int, int)
11386 void * __builtin_custom_pnif (int, float)
11387 void * __builtin_custom_pnip (int, void *)
11388 void * __builtin_custom_pnfi (float, int)
11389 void * __builtin_custom_pnff (float, float)
11390 void * __builtin_custom_pnfp (float, void *)
11391 void * __builtin_custom_pnpi (void *, int)
11392 void * __builtin_custom_pnpf (void *, float)
11393 void * __builtin_custom_pnpp (void *, void *)
11394 @end example
11395
11396 @node ARC Built-in Functions
11397 @subsection ARC Built-in Functions
11398
11399 The following built-in functions are provided for ARC targets. The
11400 built-ins generate the corresponding assembly instructions. In the
11401 examples given below, the generated code often requires an operand or
11402 result to be in a register. Where necessary further code will be
11403 generated to ensure this is true, but for brevity this is not
11404 described in each case.
11405
11406 @emph{Note:} Using a built-in to generate an instruction not supported
11407 by a target may cause problems. At present the compiler is not
11408 guaranteed to detect such misuse, and as a result an internal compiler
11409 error may be generated.
11410
11411 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11412 Return 1 if @var{val} is known to have the byte alignment given
11413 by @var{alignval}, otherwise return 0.
11414 Note that this is different from
11415 @smallexample
11416 __alignof__(*(char *)@var{val}) >= alignval
11417 @end smallexample
11418 because __alignof__ sees only the type of the dereference, whereas
11419 __builtin_arc_align uses alignment information from the pointer
11420 as well as from the pointed-to type.
11421 The information available will depend on optimization level.
11422 @end deftypefn
11423
11424 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11425 Generates
11426 @example
11427 brk
11428 @end example
11429 @end deftypefn
11430
11431 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11432 The operand is the number of a register to be read. Generates:
11433 @example
11434 mov @var{dest}, r@var{regno}
11435 @end example
11436 where the value in @var{dest} will be the result returned from the
11437 built-in.
11438 @end deftypefn
11439
11440 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11441 The first operand is the number of a register to be written, the
11442 second operand is a compile time constant to write into that
11443 register. Generates:
11444 @example
11445 mov r@var{regno}, @var{val}
11446 @end example
11447 @end deftypefn
11448
11449 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11450 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11451 Generates:
11452 @example
11453 divaw @var{dest}, @var{a}, @var{b}
11454 @end example
11455 where the value in @var{dest} will be the result returned from the
11456 built-in.
11457 @end deftypefn
11458
11459 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11460 Generates
11461 @example
11462 flag @var{a}
11463 @end example
11464 @end deftypefn
11465
11466 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11467 The operand, @var{auxv}, is the address of an auxiliary register and
11468 must be a compile time constant. Generates:
11469 @example
11470 lr @var{dest}, [@var{auxr}]
11471 @end example
11472 Where the value in @var{dest} will be the result returned from the
11473 built-in.
11474 @end deftypefn
11475
11476 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11477 Only available with @option{-mmul64}. Generates:
11478 @example
11479 mul64 @var{a}, @var{b}
11480 @end example
11481 @end deftypefn
11482
11483 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11484 Only available with @option{-mmul64}. Generates:
11485 @example
11486 mulu64 @var{a}, @var{b}
11487 @end example
11488 @end deftypefn
11489
11490 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11491 Generates:
11492 @example
11493 nop
11494 @end example
11495 @end deftypefn
11496
11497 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11498 Only valid if the @samp{norm} instruction is available through the
11499 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11500 Generates:
11501 @example
11502 norm @var{dest}, @var{src}
11503 @end example
11504 Where the value in @var{dest} will be the result returned from the
11505 built-in.
11506 @end deftypefn
11507
11508 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11509 Only valid if the @samp{normw} instruction is available through the
11510 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11511 Generates:
11512 @example
11513 normw @var{dest}, @var{src}
11514 @end example
11515 Where the value in @var{dest} will be the result returned from the
11516 built-in.
11517 @end deftypefn
11518
11519 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11520 Generates:
11521 @example
11522 rtie
11523 @end example
11524 @end deftypefn
11525
11526 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11527 Generates:
11528 @example
11529 sleep @var{a}
11530 @end example
11531 @end deftypefn
11532
11533 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11534 The first argument, @var{auxv}, is the address of an auxiliary
11535 register, the second argument, @var{val}, is a compile time constant
11536 to be written to the register. Generates:
11537 @example
11538 sr @var{auxr}, [@var{val}]
11539 @end example
11540 @end deftypefn
11541
11542 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11543 Only valid with @option{-mswap}. Generates:
11544 @example
11545 swap @var{dest}, @var{src}
11546 @end example
11547 Where the value in @var{dest} will be the result returned from the
11548 built-in.
11549 @end deftypefn
11550
11551 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11552 Generates:
11553 @example
11554 swi
11555 @end example
11556 @end deftypefn
11557
11558 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11559 Only available with @option{-mcpu=ARC700}. Generates:
11560 @example
11561 sync
11562 @end example
11563 @end deftypefn
11564
11565 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11566 Only available with @option{-mcpu=ARC700}. Generates:
11567 @example
11568 trap_s @var{c}
11569 @end example
11570 @end deftypefn
11571
11572 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11573 Only available with @option{-mcpu=ARC700}. Generates:
11574 @example
11575 unimp_s
11576 @end example
11577 @end deftypefn
11578
11579 The instructions generated by the following builtins are not
11580 considered as candidates for scheduling. They are not moved around by
11581 the compiler during scheduling, and thus can be expected to appear
11582 where they are put in the C code:
11583 @example
11584 __builtin_arc_brk()
11585 __builtin_arc_core_read()
11586 __builtin_arc_core_write()
11587 __builtin_arc_flag()
11588 __builtin_arc_lr()
11589 __builtin_arc_sleep()
11590 __builtin_arc_sr()
11591 __builtin_arc_swi()
11592 @end example
11593
11594 @node ARC SIMD Built-in Functions
11595 @subsection ARC SIMD Built-in Functions
11596
11597 SIMD builtins provided by the compiler can be used to generate the
11598 vector instructions. This section describes the available builtins
11599 and their usage in programs. With the @option{-msimd} option, the
11600 compiler provides 128-bit vector types, which can be specified using
11601 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11602 can be included to use the following predefined types:
11603 @example
11604 typedef int __v4si __attribute__((vector_size(16)));
11605 typedef short __v8hi __attribute__((vector_size(16)));
11606 @end example
11607
11608 These types can be used to define 128-bit variables. The built-in
11609 functions listed in the following section can be used on these
11610 variables to generate the vector operations.
11611
11612 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11613 @file{arc-simd.h} also provides equivalent macros called
11614 @code{_@var{someinsn}} that can be used for programming ease and
11615 improved readability. The following macros for DMA control are also
11616 provided:
11617 @example
11618 #define _setup_dma_in_channel_reg _vdiwr
11619 #define _setup_dma_out_channel_reg _vdowr
11620 @end example
11621
11622 The following is a complete list of all the SIMD built-ins provided
11623 for ARC, grouped by calling signature.
11624
11625 The following take two @code{__v8hi} arguments and return a
11626 @code{__v8hi} result:
11627 @example
11628 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11629 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11630 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11631 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11632 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11633 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11634 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11635 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11636 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11637 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11638 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11639 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11640 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11641 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11642 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11643 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11644 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11645 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11646 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11647 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11648 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11649 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11650 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11651 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11652 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11653 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11654 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11655 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11656 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11657 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11658 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11659 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11660 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11661 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11662 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11663 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11664 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11665 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11666 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11667 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11668 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11669 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11670 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11671 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11672 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11673 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11674 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11675 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11676 @end example
11677
11678 The following take one @code{__v8hi} and one @code{int} argument and return a
11679 @code{__v8hi} result:
11680
11681 @example
11682 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11683 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11684 __v8hi __builtin_arc_vbminw (__v8hi, int)
11685 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11686 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11687 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11688 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11689 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11690 @end example
11691
11692 The following take one @code{__v8hi} argument and one @code{int} argument which
11693 must be a 3-bit compile time constant indicating a register number
11694 I0-I7. They return a @code{__v8hi} result.
11695 @example
11696 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11697 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11698 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11699 @end example
11700
11701 The following take one @code{__v8hi} argument and one @code{int}
11702 argument which must be a 6-bit compile time constant. They return a
11703 @code{__v8hi} result.
11704 @example
11705 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11706 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11707 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11708 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11709 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11710 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11711 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11712 @end example
11713
11714 The following take one @code{__v8hi} argument and one @code{int} argument which
11715 must be a 8-bit compile time constant. They return a @code{__v8hi}
11716 result.
11717 @example
11718 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11719 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11720 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11721 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11722 @end example
11723
11724 The following take two @code{int} arguments, the second of which which
11725 must be a 8-bit compile time constant. They return a @code{__v8hi}
11726 result:
11727 @example
11728 __v8hi __builtin_arc_vmovaw (int, const int)
11729 __v8hi __builtin_arc_vmovw (int, const int)
11730 __v8hi __builtin_arc_vmovzw (int, const int)
11731 @end example
11732
11733 The following take a single @code{__v8hi} argument and return a
11734 @code{__v8hi} result:
11735 @example
11736 __v8hi __builtin_arc_vabsaw (__v8hi)
11737 __v8hi __builtin_arc_vabsw (__v8hi)
11738 __v8hi __builtin_arc_vaddsuw (__v8hi)
11739 __v8hi __builtin_arc_vexch1 (__v8hi)
11740 __v8hi __builtin_arc_vexch2 (__v8hi)
11741 __v8hi __builtin_arc_vexch4 (__v8hi)
11742 __v8hi __builtin_arc_vsignw (__v8hi)
11743 __v8hi __builtin_arc_vupbaw (__v8hi)
11744 __v8hi __builtin_arc_vupbw (__v8hi)
11745 __v8hi __builtin_arc_vupsbaw (__v8hi)
11746 __v8hi __builtin_arc_vupsbw (__v8hi)
11747 @end example
11748
11749 The following take two @code{int} arguments and return no result:
11750 @example
11751 void __builtin_arc_vdirun (int, int)
11752 void __builtin_arc_vdorun (int, int)
11753 @end example
11754
11755 The following take two @code{int} arguments and return no result. The
11756 first argument must a 3-bit compile time constant indicating one of
11757 the DR0-DR7 DMA setup channels:
11758 @example
11759 void __builtin_arc_vdiwr (const int, int)
11760 void __builtin_arc_vdowr (const int, int)
11761 @end example
11762
11763 The following take an @code{int} argument and return no result:
11764 @example
11765 void __builtin_arc_vendrec (int)
11766 void __builtin_arc_vrec (int)
11767 void __builtin_arc_vrecrun (int)
11768 void __builtin_arc_vrun (int)
11769 @end example
11770
11771 The following take a @code{__v8hi} argument and two @code{int}
11772 arguments and return a @code{__v8hi} result. The second argument must
11773 be a 3-bit compile time constants, indicating one the registers I0-I7,
11774 and the third argument must be an 8-bit compile time constant.
11775
11776 @emph{Note:} Although the equivalent hardware instructions do not take
11777 an SIMD register as an operand, these builtins overwrite the relevant
11778 bits of the @code{__v8hi} register provided as the first argument with
11779 the value loaded from the @code{[Ib, u8]} location in the SDM.
11780
11781 @example
11782 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11783 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11784 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11785 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11786 @end example
11787
11788 The following take two @code{int} arguments and return a @code{__v8hi}
11789 result. The first argument must be a 3-bit compile time constants,
11790 indicating one the registers I0-I7, and the second argument must be an
11791 8-bit compile time constant.
11792
11793 @example
11794 __v8hi __builtin_arc_vld128 (const int, const int)
11795 __v8hi __builtin_arc_vld64w (const int, const int)
11796 @end example
11797
11798 The following take a @code{__v8hi} argument and two @code{int}
11799 arguments and return no result. The second argument must be a 3-bit
11800 compile time constants, indicating one the registers I0-I7, and the
11801 third argument must be an 8-bit compile time constant.
11802
11803 @example
11804 void __builtin_arc_vst128 (__v8hi, const int, const int)
11805 void __builtin_arc_vst64 (__v8hi, const int, const int)
11806 @end example
11807
11808 The following take a @code{__v8hi} argument and three @code{int}
11809 arguments and return no result. The second argument must be a 3-bit
11810 compile-time constant, identifying the 16-bit sub-register to be
11811 stored, the third argument must be a 3-bit compile time constants,
11812 indicating one the registers I0-I7, and the fourth argument must be an
11813 8-bit compile time constant.
11814
11815 @example
11816 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11817 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11818 @end example
11819
11820 @node ARM iWMMXt Built-in Functions
11821 @subsection ARM iWMMXt Built-in Functions
11822
11823 These built-in functions are available for the ARM family of
11824 processors when the @option{-mcpu=iwmmxt} switch is used:
11825
11826 @smallexample
11827 typedef int v2si __attribute__ ((vector_size (8)));
11828 typedef short v4hi __attribute__ ((vector_size (8)));
11829 typedef char v8qi __attribute__ ((vector_size (8)));
11830
11831 int __builtin_arm_getwcgr0 (void)
11832 void __builtin_arm_setwcgr0 (int)
11833 int __builtin_arm_getwcgr1 (void)
11834 void __builtin_arm_setwcgr1 (int)
11835 int __builtin_arm_getwcgr2 (void)
11836 void __builtin_arm_setwcgr2 (int)
11837 int __builtin_arm_getwcgr3 (void)
11838 void __builtin_arm_setwcgr3 (int)
11839 int __builtin_arm_textrmsb (v8qi, int)
11840 int __builtin_arm_textrmsh (v4hi, int)
11841 int __builtin_arm_textrmsw (v2si, int)
11842 int __builtin_arm_textrmub (v8qi, int)
11843 int __builtin_arm_textrmuh (v4hi, int)
11844 int __builtin_arm_textrmuw (v2si, int)
11845 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11846 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11847 v2si __builtin_arm_tinsrw (v2si, int, int)
11848 long long __builtin_arm_tmia (long long, int, int)
11849 long long __builtin_arm_tmiabb (long long, int, int)
11850 long long __builtin_arm_tmiabt (long long, int, int)
11851 long long __builtin_arm_tmiaph (long long, int, int)
11852 long long __builtin_arm_tmiatb (long long, int, int)
11853 long long __builtin_arm_tmiatt (long long, int, int)
11854 int __builtin_arm_tmovmskb (v8qi)
11855 int __builtin_arm_tmovmskh (v4hi)
11856 int __builtin_arm_tmovmskw (v2si)
11857 long long __builtin_arm_waccb (v8qi)
11858 long long __builtin_arm_wacch (v4hi)
11859 long long __builtin_arm_waccw (v2si)
11860 v8qi __builtin_arm_waddb (v8qi, v8qi)
11861 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11862 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11863 v4hi __builtin_arm_waddh (v4hi, v4hi)
11864 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11865 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11866 v2si __builtin_arm_waddw (v2si, v2si)
11867 v2si __builtin_arm_waddwss (v2si, v2si)
11868 v2si __builtin_arm_waddwus (v2si, v2si)
11869 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11870 long long __builtin_arm_wand(long long, long long)
11871 long long __builtin_arm_wandn (long long, long long)
11872 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11873 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11874 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11875 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11876 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
11877 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
11878 v2si __builtin_arm_wcmpeqw (v2si, v2si)
11879 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
11880 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
11881 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
11882 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
11883 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
11884 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
11885 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
11886 long long __builtin_arm_wmacsz (v4hi, v4hi)
11887 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
11888 long long __builtin_arm_wmacuz (v4hi, v4hi)
11889 v4hi __builtin_arm_wmadds (v4hi, v4hi)
11890 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
11891 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
11892 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
11893 v2si __builtin_arm_wmaxsw (v2si, v2si)
11894 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
11895 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
11896 v2si __builtin_arm_wmaxuw (v2si, v2si)
11897 v8qi __builtin_arm_wminsb (v8qi, v8qi)
11898 v4hi __builtin_arm_wminsh (v4hi, v4hi)
11899 v2si __builtin_arm_wminsw (v2si, v2si)
11900 v8qi __builtin_arm_wminub (v8qi, v8qi)
11901 v4hi __builtin_arm_wminuh (v4hi, v4hi)
11902 v2si __builtin_arm_wminuw (v2si, v2si)
11903 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
11904 v4hi __builtin_arm_wmulul (v4hi, v4hi)
11905 v4hi __builtin_arm_wmulum (v4hi, v4hi)
11906 long long __builtin_arm_wor (long long, long long)
11907 v2si __builtin_arm_wpackdss (long long, long long)
11908 v2si __builtin_arm_wpackdus (long long, long long)
11909 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
11910 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
11911 v4hi __builtin_arm_wpackwss (v2si, v2si)
11912 v4hi __builtin_arm_wpackwus (v2si, v2si)
11913 long long __builtin_arm_wrord (long long, long long)
11914 long long __builtin_arm_wrordi (long long, int)
11915 v4hi __builtin_arm_wrorh (v4hi, long long)
11916 v4hi __builtin_arm_wrorhi (v4hi, int)
11917 v2si __builtin_arm_wrorw (v2si, long long)
11918 v2si __builtin_arm_wrorwi (v2si, int)
11919 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
11920 v2si __builtin_arm_wsadbz (v8qi, v8qi)
11921 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
11922 v2si __builtin_arm_wsadhz (v4hi, v4hi)
11923 v4hi __builtin_arm_wshufh (v4hi, int)
11924 long long __builtin_arm_wslld (long long, long long)
11925 long long __builtin_arm_wslldi (long long, int)
11926 v4hi __builtin_arm_wsllh (v4hi, long long)
11927 v4hi __builtin_arm_wsllhi (v4hi, int)
11928 v2si __builtin_arm_wsllw (v2si, long long)
11929 v2si __builtin_arm_wsllwi (v2si, int)
11930 long long __builtin_arm_wsrad (long long, long long)
11931 long long __builtin_arm_wsradi (long long, int)
11932 v4hi __builtin_arm_wsrah (v4hi, long long)
11933 v4hi __builtin_arm_wsrahi (v4hi, int)
11934 v2si __builtin_arm_wsraw (v2si, long long)
11935 v2si __builtin_arm_wsrawi (v2si, int)
11936 long long __builtin_arm_wsrld (long long, long long)
11937 long long __builtin_arm_wsrldi (long long, int)
11938 v4hi __builtin_arm_wsrlh (v4hi, long long)
11939 v4hi __builtin_arm_wsrlhi (v4hi, int)
11940 v2si __builtin_arm_wsrlw (v2si, long long)
11941 v2si __builtin_arm_wsrlwi (v2si, int)
11942 v8qi __builtin_arm_wsubb (v8qi, v8qi)
11943 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
11944 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
11945 v4hi __builtin_arm_wsubh (v4hi, v4hi)
11946 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
11947 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
11948 v2si __builtin_arm_wsubw (v2si, v2si)
11949 v2si __builtin_arm_wsubwss (v2si, v2si)
11950 v2si __builtin_arm_wsubwus (v2si, v2si)
11951 v4hi __builtin_arm_wunpckehsb (v8qi)
11952 v2si __builtin_arm_wunpckehsh (v4hi)
11953 long long __builtin_arm_wunpckehsw (v2si)
11954 v4hi __builtin_arm_wunpckehub (v8qi)
11955 v2si __builtin_arm_wunpckehuh (v4hi)
11956 long long __builtin_arm_wunpckehuw (v2si)
11957 v4hi __builtin_arm_wunpckelsb (v8qi)
11958 v2si __builtin_arm_wunpckelsh (v4hi)
11959 long long __builtin_arm_wunpckelsw (v2si)
11960 v4hi __builtin_arm_wunpckelub (v8qi)
11961 v2si __builtin_arm_wunpckeluh (v4hi)
11962 long long __builtin_arm_wunpckeluw (v2si)
11963 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
11964 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
11965 v2si __builtin_arm_wunpckihw (v2si, v2si)
11966 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
11967 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
11968 v2si __builtin_arm_wunpckilw (v2si, v2si)
11969 long long __builtin_arm_wxor (long long, long long)
11970 long long __builtin_arm_wzero ()
11971 @end smallexample
11972
11973
11974 @node ARM C Language Extensions (ACLE)
11975 @subsection ARM C Language Extensions (ACLE)
11976
11977 GCC implements extensions for C as described in the ARM C Language
11978 Extensions (ACLE) specification, which can be found at
11979 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
11980
11981 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
11982 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
11983 intrinsics can be found at
11984 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
11985 The built-in intrinsics for the Advanced SIMD extension are available when
11986 NEON is enabled.
11987
11988 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
11989 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
11990 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
11991 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
11992 intrinsics yet.
11993
11994 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
11995 availability of extensions.
11996
11997 @node ARM Floating Point Status and Control Intrinsics
11998 @subsection ARM Floating Point Status and Control Intrinsics
11999
12000 These built-in functions are available for the ARM family of
12001 processors with floating-point unit.
12002
12003 @smallexample
12004 unsigned int __builtin_arm_get_fpscr ()
12005 void __builtin_arm_set_fpscr (unsigned int)
12006 @end smallexample
12007
12008 @node AVR Built-in Functions
12009 @subsection AVR Built-in Functions
12010
12011 For each built-in function for AVR, there is an equally named,
12012 uppercase built-in macro defined. That way users can easily query if
12013 or if not a specific built-in is implemented or not. For example, if
12014 @code{__builtin_avr_nop} is available the macro
12015 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12016
12017 The following built-in functions map to the respective machine
12018 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12019 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12020 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12021 as library call if no hardware multiplier is available.
12022
12023 @smallexample
12024 void __builtin_avr_nop (void)
12025 void __builtin_avr_sei (void)
12026 void __builtin_avr_cli (void)
12027 void __builtin_avr_sleep (void)
12028 void __builtin_avr_wdr (void)
12029 unsigned char __builtin_avr_swap (unsigned char)
12030 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12031 int __builtin_avr_fmuls (char, char)
12032 int __builtin_avr_fmulsu (char, unsigned char)
12033 @end smallexample
12034
12035 In order to delay execution for a specific number of cycles, GCC
12036 implements
12037 @smallexample
12038 void __builtin_avr_delay_cycles (unsigned long ticks)
12039 @end smallexample
12040
12041 @noindent
12042 @code{ticks} is the number of ticks to delay execution. Note that this
12043 built-in does not take into account the effect of interrupts that
12044 might increase delay time. @code{ticks} must be a compile-time
12045 integer constant; delays with a variable number of cycles are not supported.
12046
12047 @smallexample
12048 char __builtin_avr_flash_segment (const __memx void*)
12049 @end smallexample
12050
12051 @noindent
12052 This built-in takes a byte address to the 24-bit
12053 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12054 the number of the flash segment (the 64 KiB chunk) where the address
12055 points to. Counting starts at @code{0}.
12056 If the address does not point to flash memory, return @code{-1}.
12057
12058 @smallexample
12059 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12060 @end smallexample
12061
12062 @noindent
12063 Insert bits from @var{bits} into @var{val} and return the resulting
12064 value. The nibbles of @var{map} determine how the insertion is
12065 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12066 @enumerate
12067 @item If @var{X} is @code{0xf},
12068 then the @var{n}-th bit of @var{val} is returned unaltered.
12069
12070 @item If X is in the range 0@dots{}7,
12071 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12072
12073 @item If X is in the range 8@dots{}@code{0xe},
12074 then the @var{n}-th result bit is undefined.
12075 @end enumerate
12076
12077 @noindent
12078 One typical use case for this built-in is adjusting input and
12079 output values to non-contiguous port layouts. Some examples:
12080
12081 @smallexample
12082 // same as val, bits is unused
12083 __builtin_avr_insert_bits (0xffffffff, bits, val)
12084 @end smallexample
12085
12086 @smallexample
12087 // same as bits, val is unused
12088 __builtin_avr_insert_bits (0x76543210, bits, val)
12089 @end smallexample
12090
12091 @smallexample
12092 // same as rotating bits by 4
12093 __builtin_avr_insert_bits (0x32107654, bits, 0)
12094 @end smallexample
12095
12096 @smallexample
12097 // high nibble of result is the high nibble of val
12098 // low nibble of result is the low nibble of bits
12099 __builtin_avr_insert_bits (0xffff3210, bits, val)
12100 @end smallexample
12101
12102 @smallexample
12103 // reverse the bit order of bits
12104 __builtin_avr_insert_bits (0x01234567, bits, 0)
12105 @end smallexample
12106
12107 @node Blackfin Built-in Functions
12108 @subsection Blackfin Built-in Functions
12109
12110 Currently, there are two Blackfin-specific built-in functions. These are
12111 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12112 using inline assembly; by using these built-in functions the compiler can
12113 automatically add workarounds for hardware errata involving these
12114 instructions. These functions are named as follows:
12115
12116 @smallexample
12117 void __builtin_bfin_csync (void)
12118 void __builtin_bfin_ssync (void)
12119 @end smallexample
12120
12121 @node FR-V Built-in Functions
12122 @subsection FR-V Built-in Functions
12123
12124 GCC provides many FR-V-specific built-in functions. In general,
12125 these functions are intended to be compatible with those described
12126 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12127 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12128 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12129 pointer rather than by value.
12130
12131 Most of the functions are named after specific FR-V instructions.
12132 Such functions are said to be ``directly mapped'' and are summarized
12133 here in tabular form.
12134
12135 @menu
12136 * Argument Types::
12137 * Directly-mapped Integer Functions::
12138 * Directly-mapped Media Functions::
12139 * Raw read/write Functions::
12140 * Other Built-in Functions::
12141 @end menu
12142
12143 @node Argument Types
12144 @subsubsection Argument Types
12145
12146 The arguments to the built-in functions can be divided into three groups:
12147 register numbers, compile-time constants and run-time values. In order
12148 to make this classification clear at a glance, the arguments and return
12149 values are given the following pseudo types:
12150
12151 @multitable @columnfractions .20 .30 .15 .35
12152 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12153 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12154 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12155 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12156 @item @code{uw2} @tab @code{unsigned long long} @tab No
12157 @tab an unsigned doubleword
12158 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12159 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12160 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12161 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12162 @end multitable
12163
12164 These pseudo types are not defined by GCC, they are simply a notational
12165 convenience used in this manual.
12166
12167 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12168 and @code{sw2} are evaluated at run time. They correspond to
12169 register operands in the underlying FR-V instructions.
12170
12171 @code{const} arguments represent immediate operands in the underlying
12172 FR-V instructions. They must be compile-time constants.
12173
12174 @code{acc} arguments are evaluated at compile time and specify the number
12175 of an accumulator register. For example, an @code{acc} argument of 2
12176 selects the ACC2 register.
12177
12178 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12179 number of an IACC register. See @pxref{Other Built-in Functions}
12180 for more details.
12181
12182 @node Directly-mapped Integer Functions
12183 @subsubsection Directly-Mapped Integer Functions
12184
12185 The functions listed below map directly to FR-V I-type instructions.
12186
12187 @multitable @columnfractions .45 .32 .23
12188 @item Function prototype @tab Example usage @tab Assembly output
12189 @item @code{sw1 __ADDSS (sw1, sw1)}
12190 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12191 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12192 @item @code{sw1 __SCAN (sw1, sw1)}
12193 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12194 @tab @code{SCAN @var{a},@var{b},@var{c}}
12195 @item @code{sw1 __SCUTSS (sw1)}
12196 @tab @code{@var{b} = __SCUTSS (@var{a})}
12197 @tab @code{SCUTSS @var{a},@var{b}}
12198 @item @code{sw1 __SLASS (sw1, sw1)}
12199 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12200 @tab @code{SLASS @var{a},@var{b},@var{c}}
12201 @item @code{void __SMASS (sw1, sw1)}
12202 @tab @code{__SMASS (@var{a}, @var{b})}
12203 @tab @code{SMASS @var{a},@var{b}}
12204 @item @code{void __SMSSS (sw1, sw1)}
12205 @tab @code{__SMSSS (@var{a}, @var{b})}
12206 @tab @code{SMSSS @var{a},@var{b}}
12207 @item @code{void __SMU (sw1, sw1)}
12208 @tab @code{__SMU (@var{a}, @var{b})}
12209 @tab @code{SMU @var{a},@var{b}}
12210 @item @code{sw2 __SMUL (sw1, sw1)}
12211 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12212 @tab @code{SMUL @var{a},@var{b},@var{c}}
12213 @item @code{sw1 __SUBSS (sw1, sw1)}
12214 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12215 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12216 @item @code{uw2 __UMUL (uw1, uw1)}
12217 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12218 @tab @code{UMUL @var{a},@var{b},@var{c}}
12219 @end multitable
12220
12221 @node Directly-mapped Media Functions
12222 @subsubsection Directly-Mapped Media Functions
12223
12224 The functions listed below map directly to FR-V M-type instructions.
12225
12226 @multitable @columnfractions .45 .32 .23
12227 @item Function prototype @tab Example usage @tab Assembly output
12228 @item @code{uw1 __MABSHS (sw1)}
12229 @tab @code{@var{b} = __MABSHS (@var{a})}
12230 @tab @code{MABSHS @var{a},@var{b}}
12231 @item @code{void __MADDACCS (acc, acc)}
12232 @tab @code{__MADDACCS (@var{b}, @var{a})}
12233 @tab @code{MADDACCS @var{a},@var{b}}
12234 @item @code{sw1 __MADDHSS (sw1, sw1)}
12235 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12236 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12237 @item @code{uw1 __MADDHUS (uw1, uw1)}
12238 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12239 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12240 @item @code{uw1 __MAND (uw1, uw1)}
12241 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12242 @tab @code{MAND @var{a},@var{b},@var{c}}
12243 @item @code{void __MASACCS (acc, acc)}
12244 @tab @code{__MASACCS (@var{b}, @var{a})}
12245 @tab @code{MASACCS @var{a},@var{b}}
12246 @item @code{uw1 __MAVEH (uw1, uw1)}
12247 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12248 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12249 @item @code{uw2 __MBTOH (uw1)}
12250 @tab @code{@var{b} = __MBTOH (@var{a})}
12251 @tab @code{MBTOH @var{a},@var{b}}
12252 @item @code{void __MBTOHE (uw1 *, uw1)}
12253 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12254 @tab @code{MBTOHE @var{a},@var{b}}
12255 @item @code{void __MCLRACC (acc)}
12256 @tab @code{__MCLRACC (@var{a})}
12257 @tab @code{MCLRACC @var{a}}
12258 @item @code{void __MCLRACCA (void)}
12259 @tab @code{__MCLRACCA ()}
12260 @tab @code{MCLRACCA}
12261 @item @code{uw1 __Mcop1 (uw1, uw1)}
12262 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12263 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12264 @item @code{uw1 __Mcop2 (uw1, uw1)}
12265 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12266 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12267 @item @code{uw1 __MCPLHI (uw2, const)}
12268 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12269 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12270 @item @code{uw1 __MCPLI (uw2, const)}
12271 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12272 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12273 @item @code{void __MCPXIS (acc, sw1, sw1)}
12274 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12275 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12276 @item @code{void __MCPXIU (acc, uw1, uw1)}
12277 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12278 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12279 @item @code{void __MCPXRS (acc, sw1, sw1)}
12280 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12281 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12282 @item @code{void __MCPXRU (acc, uw1, uw1)}
12283 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12284 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12285 @item @code{uw1 __MCUT (acc, uw1)}
12286 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12287 @tab @code{MCUT @var{a},@var{b},@var{c}}
12288 @item @code{uw1 __MCUTSS (acc, sw1)}
12289 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12290 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12291 @item @code{void __MDADDACCS (acc, acc)}
12292 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12293 @tab @code{MDADDACCS @var{a},@var{b}}
12294 @item @code{void __MDASACCS (acc, acc)}
12295 @tab @code{__MDASACCS (@var{b}, @var{a})}
12296 @tab @code{MDASACCS @var{a},@var{b}}
12297 @item @code{uw2 __MDCUTSSI (acc, const)}
12298 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12299 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12300 @item @code{uw2 __MDPACKH (uw2, uw2)}
12301 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12302 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12303 @item @code{uw2 __MDROTLI (uw2, const)}
12304 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12305 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12306 @item @code{void __MDSUBACCS (acc, acc)}
12307 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12308 @tab @code{MDSUBACCS @var{a},@var{b}}
12309 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12310 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12311 @tab @code{MDUNPACKH @var{a},@var{b}}
12312 @item @code{uw2 __MEXPDHD (uw1, const)}
12313 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12314 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12315 @item @code{uw1 __MEXPDHW (uw1, const)}
12316 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12317 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12318 @item @code{uw1 __MHDSETH (uw1, const)}
12319 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12320 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12321 @item @code{sw1 __MHDSETS (const)}
12322 @tab @code{@var{b} = __MHDSETS (@var{a})}
12323 @tab @code{MHDSETS #@var{a},@var{b}}
12324 @item @code{uw1 __MHSETHIH (uw1, const)}
12325 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12326 @tab @code{MHSETHIH #@var{a},@var{b}}
12327 @item @code{sw1 __MHSETHIS (sw1, const)}
12328 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12329 @tab @code{MHSETHIS #@var{a},@var{b}}
12330 @item @code{uw1 __MHSETLOH (uw1, const)}
12331 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12332 @tab @code{MHSETLOH #@var{a},@var{b}}
12333 @item @code{sw1 __MHSETLOS (sw1, const)}
12334 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12335 @tab @code{MHSETLOS #@var{a},@var{b}}
12336 @item @code{uw1 __MHTOB (uw2)}
12337 @tab @code{@var{b} = __MHTOB (@var{a})}
12338 @tab @code{MHTOB @var{a},@var{b}}
12339 @item @code{void __MMACHS (acc, sw1, sw1)}
12340 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12341 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12342 @item @code{void __MMACHU (acc, uw1, uw1)}
12343 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12344 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12345 @item @code{void __MMRDHS (acc, sw1, sw1)}
12346 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12347 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12348 @item @code{void __MMRDHU (acc, uw1, uw1)}
12349 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12350 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12351 @item @code{void __MMULHS (acc, sw1, sw1)}
12352 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12353 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12354 @item @code{void __MMULHU (acc, uw1, uw1)}
12355 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12356 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12357 @item @code{void __MMULXHS (acc, sw1, sw1)}
12358 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12359 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12360 @item @code{void __MMULXHU (acc, uw1, uw1)}
12361 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12362 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12363 @item @code{uw1 __MNOT (uw1)}
12364 @tab @code{@var{b} = __MNOT (@var{a})}
12365 @tab @code{MNOT @var{a},@var{b}}
12366 @item @code{uw1 __MOR (uw1, uw1)}
12367 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12368 @tab @code{MOR @var{a},@var{b},@var{c}}
12369 @item @code{uw1 __MPACKH (uh, uh)}
12370 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12371 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12372 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12373 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12374 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12375 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12376 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12377 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12378 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12379 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12380 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12381 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12382 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12383 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12384 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12385 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12386 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12387 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12388 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12389 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12390 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12391 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12392 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12393 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12394 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12395 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12396 @item @code{void __MQMACHS (acc, sw2, sw2)}
12397 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12398 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12399 @item @code{void __MQMACHU (acc, uw2, uw2)}
12400 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12401 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12402 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12403 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12404 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12405 @item @code{void __MQMULHS (acc, sw2, sw2)}
12406 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12407 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12408 @item @code{void __MQMULHU (acc, uw2, uw2)}
12409 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12410 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12411 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12412 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12413 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12414 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12415 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12416 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12417 @item @code{sw2 __MQSATHS (sw2, sw2)}
12418 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12419 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12420 @item @code{uw2 __MQSLLHI (uw2, int)}
12421 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12422 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12423 @item @code{sw2 __MQSRAHI (sw2, int)}
12424 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12425 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12426 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12427 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12428 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12429 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12430 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12431 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12432 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12433 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12434 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12435 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12436 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12437 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12438 @item @code{uw1 __MRDACC (acc)}
12439 @tab @code{@var{b} = __MRDACC (@var{a})}
12440 @tab @code{MRDACC @var{a},@var{b}}
12441 @item @code{uw1 __MRDACCG (acc)}
12442 @tab @code{@var{b} = __MRDACCG (@var{a})}
12443 @tab @code{MRDACCG @var{a},@var{b}}
12444 @item @code{uw1 __MROTLI (uw1, const)}
12445 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12446 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12447 @item @code{uw1 __MROTRI (uw1, const)}
12448 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12449 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12450 @item @code{sw1 __MSATHS (sw1, sw1)}
12451 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12452 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12453 @item @code{uw1 __MSATHU (uw1, uw1)}
12454 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12455 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12456 @item @code{uw1 __MSLLHI (uw1, const)}
12457 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12458 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12459 @item @code{sw1 __MSRAHI (sw1, const)}
12460 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12461 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12462 @item @code{uw1 __MSRLHI (uw1, const)}
12463 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12464 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12465 @item @code{void __MSUBACCS (acc, acc)}
12466 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12467 @tab @code{MSUBACCS @var{a},@var{b}}
12468 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12469 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12470 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12471 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12472 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12473 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12474 @item @code{void __MTRAP (void)}
12475 @tab @code{__MTRAP ()}
12476 @tab @code{MTRAP}
12477 @item @code{uw2 __MUNPACKH (uw1)}
12478 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12479 @tab @code{MUNPACKH @var{a},@var{b}}
12480 @item @code{uw1 __MWCUT (uw2, uw1)}
12481 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12482 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12483 @item @code{void __MWTACC (acc, uw1)}
12484 @tab @code{__MWTACC (@var{b}, @var{a})}
12485 @tab @code{MWTACC @var{a},@var{b}}
12486 @item @code{void __MWTACCG (acc, uw1)}
12487 @tab @code{__MWTACCG (@var{b}, @var{a})}
12488 @tab @code{MWTACCG @var{a},@var{b}}
12489 @item @code{uw1 __MXOR (uw1, uw1)}
12490 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12491 @tab @code{MXOR @var{a},@var{b},@var{c}}
12492 @end multitable
12493
12494 @node Raw read/write Functions
12495 @subsubsection Raw Read/Write Functions
12496
12497 This sections describes built-in functions related to read and write
12498 instructions to access memory. These functions generate
12499 @code{membar} instructions to flush the I/O load and stores where
12500 appropriate, as described in Fujitsu's manual described above.
12501
12502 @table @code
12503
12504 @item unsigned char __builtin_read8 (void *@var{data})
12505 @item unsigned short __builtin_read16 (void *@var{data})
12506 @item unsigned long __builtin_read32 (void *@var{data})
12507 @item unsigned long long __builtin_read64 (void *@var{data})
12508
12509 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12510 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12511 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12512 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12513 @end table
12514
12515 @node Other Built-in Functions
12516 @subsubsection Other Built-in Functions
12517
12518 This section describes built-in functions that are not named after
12519 a specific FR-V instruction.
12520
12521 @table @code
12522 @item sw2 __IACCreadll (iacc @var{reg})
12523 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12524 for future expansion and must be 0.
12525
12526 @item sw1 __IACCreadl (iacc @var{reg})
12527 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12528 Other values of @var{reg} are rejected as invalid.
12529
12530 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12531 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12532 is reserved for future expansion and must be 0.
12533
12534 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12535 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12536 is 1. Other values of @var{reg} are rejected as invalid.
12537
12538 @item void __data_prefetch0 (const void *@var{x})
12539 Use the @code{dcpl} instruction to load the contents of address @var{x}
12540 into the data cache.
12541
12542 @item void __data_prefetch (const void *@var{x})
12543 Use the @code{nldub} instruction to load the contents of address @var{x}
12544 into the data cache. The instruction is issued in slot I1@.
12545 @end table
12546
12547 @node MIPS DSP Built-in Functions
12548 @subsection MIPS DSP Built-in Functions
12549
12550 The MIPS DSP Application-Specific Extension (ASE) includes new
12551 instructions that are designed to improve the performance of DSP and
12552 media applications. It provides instructions that operate on packed
12553 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12554
12555 GCC supports MIPS DSP operations using both the generic
12556 vector extensions (@pxref{Vector Extensions}) and a collection of
12557 MIPS-specific built-in functions. Both kinds of support are
12558 enabled by the @option{-mdsp} command-line option.
12559
12560 Revision 2 of the ASE was introduced in the second half of 2006.
12561 This revision adds extra instructions to the original ASE, but is
12562 otherwise backwards-compatible with it. You can select revision 2
12563 using the command-line option @option{-mdspr2}; this option implies
12564 @option{-mdsp}.
12565
12566 The SCOUNT and POS bits of the DSP control register are global. The
12567 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12568 POS bits. During optimization, the compiler does not delete these
12569 instructions and it does not delete calls to functions containing
12570 these instructions.
12571
12572 At present, GCC only provides support for operations on 32-bit
12573 vectors. The vector type associated with 8-bit integer data is
12574 usually called @code{v4i8}, the vector type associated with Q7
12575 is usually called @code{v4q7}, the vector type associated with 16-bit
12576 integer data is usually called @code{v2i16}, and the vector type
12577 associated with Q15 is usually called @code{v2q15}. They can be
12578 defined in C as follows:
12579
12580 @smallexample
12581 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12582 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12583 typedef short v2i16 __attribute__ ((vector_size(4)));
12584 typedef short v2q15 __attribute__ ((vector_size(4)));
12585 @end smallexample
12586
12587 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12588 initialized in the same way as aggregates. For example:
12589
12590 @smallexample
12591 v4i8 a = @{1, 2, 3, 4@};
12592 v4i8 b;
12593 b = (v4i8) @{5, 6, 7, 8@};
12594
12595 v2q15 c = @{0x0fcb, 0x3a75@};
12596 v2q15 d;
12597 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12598 @end smallexample
12599
12600 @emph{Note:} The CPU's endianness determines the order in which values
12601 are packed. On little-endian targets, the first value is the least
12602 significant and the last value is the most significant. The opposite
12603 order applies to big-endian targets. For example, the code above
12604 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12605 and @code{4} on big-endian targets.
12606
12607 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12608 representation. As shown in this example, the integer representation
12609 of a Q7 value can be obtained by multiplying the fractional value by
12610 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12611 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12612 @code{0x1.0p31}.
12613
12614 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12615 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12616 and @code{c} and @code{d} are @code{v2q15} values.
12617
12618 @multitable @columnfractions .50 .50
12619 @item C code @tab MIPS instruction
12620 @item @code{a + b} @tab @code{addu.qb}
12621 @item @code{c + d} @tab @code{addq.ph}
12622 @item @code{a - b} @tab @code{subu.qb}
12623 @item @code{c - d} @tab @code{subq.ph}
12624 @end multitable
12625
12626 The table below lists the @code{v2i16} operation for which
12627 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12628 @code{v2i16} values.
12629
12630 @multitable @columnfractions .50 .50
12631 @item C code @tab MIPS instruction
12632 @item @code{e * f} @tab @code{mul.ph}
12633 @end multitable
12634
12635 It is easier to describe the DSP built-in functions if we first define
12636 the following types:
12637
12638 @smallexample
12639 typedef int q31;
12640 typedef int i32;
12641 typedef unsigned int ui32;
12642 typedef long long a64;
12643 @end smallexample
12644
12645 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12646 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12647 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12648 @code{long long}, but we use @code{a64} to indicate values that are
12649 placed in one of the four DSP accumulators (@code{$ac0},
12650 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12651
12652 Also, some built-in functions prefer or require immediate numbers as
12653 parameters, because the corresponding DSP instructions accept both immediate
12654 numbers and register operands, or accept immediate numbers only. The
12655 immediate parameters are listed as follows.
12656
12657 @smallexample
12658 imm0_3: 0 to 3.
12659 imm0_7: 0 to 7.
12660 imm0_15: 0 to 15.
12661 imm0_31: 0 to 31.
12662 imm0_63: 0 to 63.
12663 imm0_255: 0 to 255.
12664 imm_n32_31: -32 to 31.
12665 imm_n512_511: -512 to 511.
12666 @end smallexample
12667
12668 The following built-in functions map directly to a particular MIPS DSP
12669 instruction. Please refer to the architecture specification
12670 for details on what each instruction does.
12671
12672 @smallexample
12673 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12674 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12675 q31 __builtin_mips_addq_s_w (q31, q31)
12676 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12677 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12678 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12679 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12680 q31 __builtin_mips_subq_s_w (q31, q31)
12681 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12682 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12683 i32 __builtin_mips_addsc (i32, i32)
12684 i32 __builtin_mips_addwc (i32, i32)
12685 i32 __builtin_mips_modsub (i32, i32)
12686 i32 __builtin_mips_raddu_w_qb (v4i8)
12687 v2q15 __builtin_mips_absq_s_ph (v2q15)
12688 q31 __builtin_mips_absq_s_w (q31)
12689 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12690 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12691 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12692 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12693 q31 __builtin_mips_preceq_w_phl (v2q15)
12694 q31 __builtin_mips_preceq_w_phr (v2q15)
12695 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12696 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12697 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12698 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12699 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12700 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12701 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12702 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12703 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12704 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12705 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12706 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12707 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12708 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12709 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12710 q31 __builtin_mips_shll_s_w (q31, i32)
12711 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12712 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12713 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12714 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12715 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12716 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12717 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12718 q31 __builtin_mips_shra_r_w (q31, i32)
12719 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12720 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12721 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12722 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12723 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12724 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12725 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12726 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12727 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12728 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12729 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12730 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12731 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12732 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12733 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12734 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12735 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12736 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12737 i32 __builtin_mips_bitrev (i32)
12738 i32 __builtin_mips_insv (i32, i32)
12739 v4i8 __builtin_mips_repl_qb (imm0_255)
12740 v4i8 __builtin_mips_repl_qb (i32)
12741 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12742 v2q15 __builtin_mips_repl_ph (i32)
12743 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12744 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12745 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12746 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12747 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12748 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12749 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12750 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12751 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12752 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12753 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12754 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12755 i32 __builtin_mips_extr_w (a64, imm0_31)
12756 i32 __builtin_mips_extr_w (a64, i32)
12757 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12758 i32 __builtin_mips_extr_s_h (a64, i32)
12759 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12760 i32 __builtin_mips_extr_rs_w (a64, i32)
12761 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12762 i32 __builtin_mips_extr_r_w (a64, i32)
12763 i32 __builtin_mips_extp (a64, imm0_31)
12764 i32 __builtin_mips_extp (a64, i32)
12765 i32 __builtin_mips_extpdp (a64, imm0_31)
12766 i32 __builtin_mips_extpdp (a64, i32)
12767 a64 __builtin_mips_shilo (a64, imm_n32_31)
12768 a64 __builtin_mips_shilo (a64, i32)
12769 a64 __builtin_mips_mthlip (a64, i32)
12770 void __builtin_mips_wrdsp (i32, imm0_63)
12771 i32 __builtin_mips_rddsp (imm0_63)
12772 i32 __builtin_mips_lbux (void *, i32)
12773 i32 __builtin_mips_lhx (void *, i32)
12774 i32 __builtin_mips_lwx (void *, i32)
12775 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12776 i32 __builtin_mips_bposge32 (void)
12777 a64 __builtin_mips_madd (a64, i32, i32);
12778 a64 __builtin_mips_maddu (a64, ui32, ui32);
12779 a64 __builtin_mips_msub (a64, i32, i32);
12780 a64 __builtin_mips_msubu (a64, ui32, ui32);
12781 a64 __builtin_mips_mult (i32, i32);
12782 a64 __builtin_mips_multu (ui32, ui32);
12783 @end smallexample
12784
12785 The following built-in functions map directly to a particular MIPS DSP REV 2
12786 instruction. Please refer to the architecture specification
12787 for details on what each instruction does.
12788
12789 @smallexample
12790 v4q7 __builtin_mips_absq_s_qb (v4q7);
12791 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12792 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12793 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12794 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12795 i32 __builtin_mips_append (i32, i32, imm0_31);
12796 i32 __builtin_mips_balign (i32, i32, imm0_3);
12797 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12798 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12799 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12800 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12801 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12802 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12803 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12804 q31 __builtin_mips_mulq_rs_w (q31, q31);
12805 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12806 q31 __builtin_mips_mulq_s_w (q31, q31);
12807 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12808 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12809 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12810 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12811 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12812 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12813 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12814 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12815 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12816 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12817 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12818 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12819 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12820 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12821 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12822 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12823 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12824 q31 __builtin_mips_addqh_w (q31, q31);
12825 q31 __builtin_mips_addqh_r_w (q31, q31);
12826 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12827 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12828 q31 __builtin_mips_subqh_w (q31, q31);
12829 q31 __builtin_mips_subqh_r_w (q31, q31);
12830 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12831 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12832 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12833 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12834 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12835 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12836 @end smallexample
12837
12838
12839 @node MIPS Paired-Single Support
12840 @subsection MIPS Paired-Single Support
12841
12842 The MIPS64 architecture includes a number of instructions that
12843 operate on pairs of single-precision floating-point values.
12844 Each pair is packed into a 64-bit floating-point register,
12845 with one element being designated the ``upper half'' and
12846 the other being designated the ``lower half''.
12847
12848 GCC supports paired-single operations using both the generic
12849 vector extensions (@pxref{Vector Extensions}) and a collection of
12850 MIPS-specific built-in functions. Both kinds of support are
12851 enabled by the @option{-mpaired-single} command-line option.
12852
12853 The vector type associated with paired-single values is usually
12854 called @code{v2sf}. It can be defined in C as follows:
12855
12856 @smallexample
12857 typedef float v2sf __attribute__ ((vector_size (8)));
12858 @end smallexample
12859
12860 @code{v2sf} values are initialized in the same way as aggregates.
12861 For example:
12862
12863 @smallexample
12864 v2sf a = @{1.5, 9.1@};
12865 v2sf b;
12866 float e, f;
12867 b = (v2sf) @{e, f@};
12868 @end smallexample
12869
12870 @emph{Note:} The CPU's endianness determines which value is stored in
12871 the upper half of a register and which value is stored in the lower half.
12872 On little-endian targets, the first value is the lower one and the second
12873 value is the upper one. The opposite order applies to big-endian targets.
12874 For example, the code above sets the lower half of @code{a} to
12875 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12876
12877 @node MIPS Loongson Built-in Functions
12878 @subsection MIPS Loongson Built-in Functions
12879
12880 GCC provides intrinsics to access the SIMD instructions provided by the
12881 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
12882 available after inclusion of the @code{loongson.h} header file,
12883 operate on the following 64-bit vector types:
12884
12885 @itemize
12886 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
12887 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
12888 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
12889 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
12890 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
12891 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
12892 @end itemize
12893
12894 The intrinsics provided are listed below; each is named after the
12895 machine instruction to which it corresponds, with suffixes added as
12896 appropriate to distinguish intrinsics that expand to the same machine
12897 instruction yet have different argument types. Refer to the architecture
12898 documentation for a description of the functionality of each
12899 instruction.
12900
12901 @smallexample
12902 int16x4_t packsswh (int32x2_t s, int32x2_t t);
12903 int8x8_t packsshb (int16x4_t s, int16x4_t t);
12904 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
12905 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
12906 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
12907 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
12908 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
12909 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
12910 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
12911 uint64_t paddd_u (uint64_t s, uint64_t t);
12912 int64_t paddd_s (int64_t s, int64_t t);
12913 int16x4_t paddsh (int16x4_t s, int16x4_t t);
12914 int8x8_t paddsb (int8x8_t s, int8x8_t t);
12915 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
12916 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
12917 uint64_t pandn_ud (uint64_t s, uint64_t t);
12918 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
12919 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
12920 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
12921 int64_t pandn_sd (int64_t s, int64_t t);
12922 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
12923 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
12924 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
12925 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
12926 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
12927 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
12928 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
12929 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
12930 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
12931 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
12932 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
12933 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
12934 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
12935 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
12936 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
12937 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
12938 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
12939 uint16x4_t pextrh_u (uint16x4_t s, int field);
12940 int16x4_t pextrh_s (int16x4_t s, int field);
12941 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
12942 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
12943 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
12944 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
12945 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
12946 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
12947 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
12948 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
12949 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
12950 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
12951 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
12952 int16x4_t pminsh (int16x4_t s, int16x4_t t);
12953 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
12954 uint8x8_t pmovmskb_u (uint8x8_t s);
12955 int8x8_t pmovmskb_s (int8x8_t s);
12956 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
12957 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
12958 int16x4_t pmullh (int16x4_t s, int16x4_t t);
12959 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
12960 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
12961 uint16x4_t biadd (uint8x8_t s);
12962 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
12963 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
12964 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
12965 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
12966 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
12967 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
12968 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
12969 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
12970 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
12971 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
12972 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
12973 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
12974 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
12975 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
12976 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
12977 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
12978 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
12979 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
12980 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
12981 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
12982 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
12983 uint64_t psubd_u (uint64_t s, uint64_t t);
12984 int64_t psubd_s (int64_t s, int64_t t);
12985 int16x4_t psubsh (int16x4_t s, int16x4_t t);
12986 int8x8_t psubsb (int8x8_t s, int8x8_t t);
12987 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
12988 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
12989 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
12990 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
12991 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
12992 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
12993 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
12994 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
12995 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
12996 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
12997 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
12998 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
12999 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13000 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13001 @end smallexample
13002
13003 @menu
13004 * Paired-Single Arithmetic::
13005 * Paired-Single Built-in Functions::
13006 * MIPS-3D Built-in Functions::
13007 @end menu
13008
13009 @node Paired-Single Arithmetic
13010 @subsubsection Paired-Single Arithmetic
13011
13012 The table below lists the @code{v2sf} operations for which hardware
13013 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13014 values and @code{x} is an integral value.
13015
13016 @multitable @columnfractions .50 .50
13017 @item C code @tab MIPS instruction
13018 @item @code{a + b} @tab @code{add.ps}
13019 @item @code{a - b} @tab @code{sub.ps}
13020 @item @code{-a} @tab @code{neg.ps}
13021 @item @code{a * b} @tab @code{mul.ps}
13022 @item @code{a * b + c} @tab @code{madd.ps}
13023 @item @code{a * b - c} @tab @code{msub.ps}
13024 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13025 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13026 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13027 @end multitable
13028
13029 Note that the multiply-accumulate instructions can be disabled
13030 using the command-line option @code{-mno-fused-madd}.
13031
13032 @node Paired-Single Built-in Functions
13033 @subsubsection Paired-Single Built-in Functions
13034
13035 The following paired-single functions map directly to a particular
13036 MIPS instruction. Please refer to the architecture specification
13037 for details on what each instruction does.
13038
13039 @table @code
13040 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13041 Pair lower lower (@code{pll.ps}).
13042
13043 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13044 Pair upper lower (@code{pul.ps}).
13045
13046 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13047 Pair lower upper (@code{plu.ps}).
13048
13049 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13050 Pair upper upper (@code{puu.ps}).
13051
13052 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13053 Convert pair to paired single (@code{cvt.ps.s}).
13054
13055 @item float __builtin_mips_cvt_s_pl (v2sf)
13056 Convert pair lower to single (@code{cvt.s.pl}).
13057
13058 @item float __builtin_mips_cvt_s_pu (v2sf)
13059 Convert pair upper to single (@code{cvt.s.pu}).
13060
13061 @item v2sf __builtin_mips_abs_ps (v2sf)
13062 Absolute value (@code{abs.ps}).
13063
13064 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13065 Align variable (@code{alnv.ps}).
13066
13067 @emph{Note:} The value of the third parameter must be 0 or 4
13068 modulo 8, otherwise the result is unpredictable. Please read the
13069 instruction description for details.
13070 @end table
13071
13072 The following multi-instruction functions are also available.
13073 In each case, @var{cond} can be any of the 16 floating-point conditions:
13074 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13075 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13076 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13077
13078 @table @code
13079 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13080 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13081 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13082 @code{movt.ps}/@code{movf.ps}).
13083
13084 The @code{movt} functions return the value @var{x} computed by:
13085
13086 @smallexample
13087 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13088 mov.ps @var{x},@var{c}
13089 movt.ps @var{x},@var{d},@var{cc}
13090 @end smallexample
13091
13092 The @code{movf} functions are similar but use @code{movf.ps} instead
13093 of @code{movt.ps}.
13094
13095 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13096 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13097 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13098 @code{bc1t}/@code{bc1f}).
13099
13100 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13101 and return either the upper or lower half of the result. For example:
13102
13103 @smallexample
13104 v2sf a, b;
13105 if (__builtin_mips_upper_c_eq_ps (a, b))
13106 upper_halves_are_equal ();
13107 else
13108 upper_halves_are_unequal ();
13109
13110 if (__builtin_mips_lower_c_eq_ps (a, b))
13111 lower_halves_are_equal ();
13112 else
13113 lower_halves_are_unequal ();
13114 @end smallexample
13115 @end table
13116
13117 @node MIPS-3D Built-in Functions
13118 @subsubsection MIPS-3D Built-in Functions
13119
13120 The MIPS-3D Application-Specific Extension (ASE) includes additional
13121 paired-single instructions that are designed to improve the performance
13122 of 3D graphics operations. Support for these instructions is controlled
13123 by the @option{-mips3d} command-line option.
13124
13125 The functions listed below map directly to a particular MIPS-3D
13126 instruction. Please refer to the architecture specification for
13127 more details on what each instruction does.
13128
13129 @table @code
13130 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13131 Reduction add (@code{addr.ps}).
13132
13133 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13134 Reduction multiply (@code{mulr.ps}).
13135
13136 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13137 Convert paired single to paired word (@code{cvt.pw.ps}).
13138
13139 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13140 Convert paired word to paired single (@code{cvt.ps.pw}).
13141
13142 @item float __builtin_mips_recip1_s (float)
13143 @itemx double __builtin_mips_recip1_d (double)
13144 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13145 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13146
13147 @item float __builtin_mips_recip2_s (float, float)
13148 @itemx double __builtin_mips_recip2_d (double, double)
13149 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13150 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13151
13152 @item float __builtin_mips_rsqrt1_s (float)
13153 @itemx double __builtin_mips_rsqrt1_d (double)
13154 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13155 Reduced-precision reciprocal square root (sequence step 1)
13156 (@code{rsqrt1.@var{fmt}}).
13157
13158 @item float __builtin_mips_rsqrt2_s (float, float)
13159 @itemx double __builtin_mips_rsqrt2_d (double, double)
13160 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13161 Reduced-precision reciprocal square root (sequence step 2)
13162 (@code{rsqrt2.@var{fmt}}).
13163 @end table
13164
13165 The following multi-instruction functions are also available.
13166 In each case, @var{cond} can be any of the 16 floating-point conditions:
13167 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13168 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13169 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13170
13171 @table @code
13172 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13173 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13174 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13175 @code{bc1t}/@code{bc1f}).
13176
13177 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13178 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13179 For example:
13180
13181 @smallexample
13182 float a, b;
13183 if (__builtin_mips_cabs_eq_s (a, b))
13184 true ();
13185 else
13186 false ();
13187 @end smallexample
13188
13189 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13190 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13191 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13192 @code{bc1t}/@code{bc1f}).
13193
13194 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13195 and return either the upper or lower half of the result. For example:
13196
13197 @smallexample
13198 v2sf a, b;
13199 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13200 upper_halves_are_equal ();
13201 else
13202 upper_halves_are_unequal ();
13203
13204 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13205 lower_halves_are_equal ();
13206 else
13207 lower_halves_are_unequal ();
13208 @end smallexample
13209
13210 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13211 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13212 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13213 @code{movt.ps}/@code{movf.ps}).
13214
13215 The @code{movt} functions return the value @var{x} computed by:
13216
13217 @smallexample
13218 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13219 mov.ps @var{x},@var{c}
13220 movt.ps @var{x},@var{d},@var{cc}
13221 @end smallexample
13222
13223 The @code{movf} functions are similar but use @code{movf.ps} instead
13224 of @code{movt.ps}.
13225
13226 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13227 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13228 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13229 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13230 Comparison of two paired-single values
13231 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13232 @code{bc1any2t}/@code{bc1any2f}).
13233
13234 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13235 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13236 result is true and the @code{all} forms return true if both results are true.
13237 For example:
13238
13239 @smallexample
13240 v2sf a, b;
13241 if (__builtin_mips_any_c_eq_ps (a, b))
13242 one_is_true ();
13243 else
13244 both_are_false ();
13245
13246 if (__builtin_mips_all_c_eq_ps (a, b))
13247 both_are_true ();
13248 else
13249 one_is_false ();
13250 @end smallexample
13251
13252 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13253 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13254 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13255 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13256 Comparison of four paired-single values
13257 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13258 @code{bc1any4t}/@code{bc1any4f}).
13259
13260 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13261 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13262 The @code{any} forms return true if any of the four results are true
13263 and the @code{all} forms return true if all four results are true.
13264 For example:
13265
13266 @smallexample
13267 v2sf a, b, c, d;
13268 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13269 some_are_true ();
13270 else
13271 all_are_false ();
13272
13273 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13274 all_are_true ();
13275 else
13276 some_are_false ();
13277 @end smallexample
13278 @end table
13279
13280 @node Other MIPS Built-in Functions
13281 @subsection Other MIPS Built-in Functions
13282
13283 GCC provides other MIPS-specific built-in functions:
13284
13285 @table @code
13286 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13287 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13288 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13289 when this function is available.
13290
13291 @item unsigned int __builtin_mips_get_fcsr (void)
13292 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13293 Get and set the contents of the floating-point control and status register
13294 (FPU control register 31). These functions are only available in hard-float
13295 code but can be called in both MIPS16 and non-MIPS16 contexts.
13296
13297 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13298 register except the condition codes, which GCC assumes are preserved.
13299 @end table
13300
13301 @node MSP430 Built-in Functions
13302 @subsection MSP430 Built-in Functions
13303
13304 GCC provides a couple of special builtin functions to aid in the
13305 writing of interrupt handlers in C.
13306
13307 @table @code
13308 @item __bic_SR_register_on_exit (int @var{mask})
13309 This clears the indicated bits in the saved copy of the status register
13310 currently residing on the stack. This only works inside interrupt
13311 handlers and the changes to the status register will only take affect
13312 once the handler returns.
13313
13314 @item __bis_SR_register_on_exit (int @var{mask})
13315 This sets the indicated bits in the saved copy of the status register
13316 currently residing on the stack. This only works inside interrupt
13317 handlers and the changes to the status register will only take affect
13318 once the handler returns.
13319
13320 @item __delay_cycles (long long @var{cycles})
13321 This inserts an instruction sequence that takes exactly @var{cycles}
13322 cycles (between 0 and about 17E9) to complete. The inserted sequence
13323 may use jumps, loops, or no-ops, and does not interfere with any other
13324 instructions. Note that @var{cycles} must be a compile-time constant
13325 integer - that is, you must pass a number, not a variable that may be
13326 optimized to a constant later. The number of cycles delayed by this
13327 builtin is exact.
13328 @end table
13329
13330 @node NDS32 Built-in Functions
13331 @subsection NDS32 Built-in Functions
13332
13333 These built-in functions are available for the NDS32 target:
13334
13335 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13336 Insert an ISYNC instruction into the instruction stream where
13337 @var{addr} is an instruction address for serialization.
13338 @end deftypefn
13339
13340 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13341 Insert an ISB instruction into the instruction stream.
13342 @end deftypefn
13343
13344 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13345 Return the content of a system register which is mapped by @var{sr}.
13346 @end deftypefn
13347
13348 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13349 Return the content of a user space register which is mapped by @var{usr}.
13350 @end deftypefn
13351
13352 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13353 Move the @var{value} to a system register which is mapped by @var{sr}.
13354 @end deftypefn
13355
13356 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13357 Move the @var{value} to a user space register which is mapped by @var{usr}.
13358 @end deftypefn
13359
13360 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13361 Enable global interrupt.
13362 @end deftypefn
13363
13364 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13365 Disable global interrupt.
13366 @end deftypefn
13367
13368 @node picoChip Built-in Functions
13369 @subsection picoChip Built-in Functions
13370
13371 GCC provides an interface to selected machine instructions from the
13372 picoChip instruction set.
13373
13374 @table @code
13375 @item int __builtin_sbc (int @var{value})
13376 Sign bit count. Return the number of consecutive bits in @var{value}
13377 that have the same value as the sign bit. The result is the number of
13378 leading sign bits minus one, giving the number of redundant sign bits in
13379 @var{value}.
13380
13381 @item int __builtin_byteswap (int @var{value})
13382 Byte swap. Return the result of swapping the upper and lower bytes of
13383 @var{value}.
13384
13385 @item int __builtin_brev (int @var{value})
13386 Bit reversal. Return the result of reversing the bits in
13387 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13388 and so on.
13389
13390 @item int __builtin_adds (int @var{x}, int @var{y})
13391 Saturating addition. Return the result of adding @var{x} and @var{y},
13392 storing the value 32767 if the result overflows.
13393
13394 @item int __builtin_subs (int @var{x}, int @var{y})
13395 Saturating subtraction. Return the result of subtracting @var{y} from
13396 @var{x}, storing the value @minus{}32768 if the result overflows.
13397
13398 @item void __builtin_halt (void)
13399 Halt. The processor stops execution. This built-in is useful for
13400 implementing assertions.
13401
13402 @end table
13403
13404 @node PowerPC Built-in Functions
13405 @subsection PowerPC Built-in Functions
13406
13407 These built-in functions are available for the PowerPC family of
13408 processors:
13409 @smallexample
13410 float __builtin_recipdivf (float, float);
13411 float __builtin_rsqrtf (float);
13412 double __builtin_recipdiv (double, double);
13413 double __builtin_rsqrt (double);
13414 uint64_t __builtin_ppc_get_timebase ();
13415 unsigned long __builtin_ppc_mftb ();
13416 double __builtin_unpack_longdouble (long double, int);
13417 long double __builtin_pack_longdouble (double, double);
13418 @end smallexample
13419
13420 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13421 @code{__builtin_rsqrtf} functions generate multiple instructions to
13422 implement the reciprocal sqrt functionality using reciprocal sqrt
13423 estimate instructions.
13424
13425 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13426 functions generate multiple instructions to implement division using
13427 the reciprocal estimate instructions.
13428
13429 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13430 functions generate instructions to read the Time Base Register. The
13431 @code{__builtin_ppc_get_timebase} function may generate multiple
13432 instructions and always returns the 64 bits of the Time Base Register.
13433 The @code{__builtin_ppc_mftb} function always generates one instruction and
13434 returns the Time Base Register value as an unsigned long, throwing away
13435 the most significant word on 32-bit environments.
13436
13437 The following built-in functions are available for the PowerPC family
13438 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13439 or @option{-mpopcntd}):
13440 @smallexample
13441 long __builtin_bpermd (long, long);
13442 int __builtin_divwe (int, int);
13443 int __builtin_divweo (int, int);
13444 unsigned int __builtin_divweu (unsigned int, unsigned int);
13445 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13446 long __builtin_divde (long, long);
13447 long __builtin_divdeo (long, long);
13448 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13449 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13450 unsigned int cdtbcd (unsigned int);
13451 unsigned int cbcdtd (unsigned int);
13452 unsigned int addg6s (unsigned int, unsigned int);
13453 @end smallexample
13454
13455 The @code{__builtin_divde}, @code{__builtin_divdeo},
13456 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13457 64-bit environment support ISA 2.06 or later.
13458
13459 The following built-in functions are available for the PowerPC family
13460 of processors when hardware decimal floating point
13461 (@option{-mhard-dfp}) is available:
13462 @smallexample
13463 _Decimal64 __builtin_dxex (_Decimal64);
13464 _Decimal128 __builtin_dxexq (_Decimal128);
13465 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13466 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13467 _Decimal64 __builtin_denbcd (int, _Decimal64);
13468 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13469 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13470 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13471 _Decimal64 __builtin_dscli (_Decimal64, int);
13472 _Decimal128 __builtin_dscliq (_Decimal128, int);
13473 _Decimal64 __builtin_dscri (_Decimal64, int);
13474 _Decimal128 __builtin_dscriq (_Decimal128, int);
13475 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13476 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13477 @end smallexample
13478
13479 The following built-in functions are available for the PowerPC family
13480 of processors when the Vector Scalar (vsx) instruction set is
13481 available:
13482 @smallexample
13483 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13484 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13485 unsigned long long);
13486 @end smallexample
13487
13488 @node PowerPC AltiVec/VSX Built-in Functions
13489 @subsection PowerPC AltiVec Built-in Functions
13490
13491 GCC provides an interface for the PowerPC family of processors to access
13492 the AltiVec operations described in Motorola's AltiVec Programming
13493 Interface Manual. The interface is made available by including
13494 @code{<altivec.h>} and using @option{-maltivec} and
13495 @option{-mabi=altivec}. The interface supports the following vector
13496 types.
13497
13498 @smallexample
13499 vector unsigned char
13500 vector signed char
13501 vector bool char
13502
13503 vector unsigned short
13504 vector signed short
13505 vector bool short
13506 vector pixel
13507
13508 vector unsigned int
13509 vector signed int
13510 vector bool int
13511 vector float
13512 @end smallexample
13513
13514 If @option{-mvsx} is used the following additional vector types are
13515 implemented.
13516
13517 @smallexample
13518 vector unsigned long
13519 vector signed long
13520 vector double
13521 @end smallexample
13522
13523 The long types are only implemented for 64-bit code generation, and
13524 the long type is only used in the floating point/integer conversion
13525 instructions.
13526
13527 GCC's implementation of the high-level language interface available from
13528 C and C++ code differs from Motorola's documentation in several ways.
13529
13530 @itemize @bullet
13531
13532 @item
13533 A vector constant is a list of constant expressions within curly braces.
13534
13535 @item
13536 A vector initializer requires no cast if the vector constant is of the
13537 same type as the variable it is initializing.
13538
13539 @item
13540 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13541 vector type is the default signedness of the base type. The default
13542 varies depending on the operating system, so a portable program should
13543 always specify the signedness.
13544
13545 @item
13546 Compiling with @option{-maltivec} adds keywords @code{__vector},
13547 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13548 @code{bool}. When compiling ISO C, the context-sensitive substitution
13549 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13550 disabled. To use them, you must include @code{<altivec.h>} instead.
13551
13552 @item
13553 GCC allows using a @code{typedef} name as the type specifier for a
13554 vector type.
13555
13556 @item
13557 For C, overloaded functions are implemented with macros so the following
13558 does not work:
13559
13560 @smallexample
13561 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13562 @end smallexample
13563
13564 @noindent
13565 Since @code{vec_add} is a macro, the vector constant in the example
13566 is treated as four separate arguments. Wrap the entire argument in
13567 parentheses for this to work.
13568 @end itemize
13569
13570 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13571 Internally, GCC uses built-in functions to achieve the functionality in
13572 the aforementioned header file, but they are not supported and are
13573 subject to change without notice.
13574
13575 The following interfaces are supported for the generic and specific
13576 AltiVec operations and the AltiVec predicates. In cases where there
13577 is a direct mapping between generic and specific operations, only the
13578 generic names are shown here, although the specific operations can also
13579 be used.
13580
13581 Arguments that are documented as @code{const int} require literal
13582 integral values within the range required for that operation.
13583
13584 @smallexample
13585 vector signed char vec_abs (vector signed char);
13586 vector signed short vec_abs (vector signed short);
13587 vector signed int vec_abs (vector signed int);
13588 vector float vec_abs (vector float);
13589
13590 vector signed char vec_abss (vector signed char);
13591 vector signed short vec_abss (vector signed short);
13592 vector signed int vec_abss (vector signed int);
13593
13594 vector signed char vec_add (vector bool char, vector signed char);
13595 vector signed char vec_add (vector signed char, vector bool char);
13596 vector signed char vec_add (vector signed char, vector signed char);
13597 vector unsigned char vec_add (vector bool char, vector unsigned char);
13598 vector unsigned char vec_add (vector unsigned char, vector bool char);
13599 vector unsigned char vec_add (vector unsigned char,
13600 vector unsigned char);
13601 vector signed short vec_add (vector bool short, vector signed short);
13602 vector signed short vec_add (vector signed short, vector bool short);
13603 vector signed short vec_add (vector signed short, vector signed short);
13604 vector unsigned short vec_add (vector bool short,
13605 vector unsigned short);
13606 vector unsigned short vec_add (vector unsigned short,
13607 vector bool short);
13608 vector unsigned short vec_add (vector unsigned short,
13609 vector unsigned short);
13610 vector signed int vec_add (vector bool int, vector signed int);
13611 vector signed int vec_add (vector signed int, vector bool int);
13612 vector signed int vec_add (vector signed int, vector signed int);
13613 vector unsigned int vec_add (vector bool int, vector unsigned int);
13614 vector unsigned int vec_add (vector unsigned int, vector bool int);
13615 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13616 vector float vec_add (vector float, vector float);
13617
13618 vector float vec_vaddfp (vector float, vector float);
13619
13620 vector signed int vec_vadduwm (vector bool int, vector signed int);
13621 vector signed int vec_vadduwm (vector signed int, vector bool int);
13622 vector signed int vec_vadduwm (vector signed int, vector signed int);
13623 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13624 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13625 vector unsigned int vec_vadduwm (vector unsigned int,
13626 vector unsigned int);
13627
13628 vector signed short vec_vadduhm (vector bool short,
13629 vector signed short);
13630 vector signed short vec_vadduhm (vector signed short,
13631 vector bool short);
13632 vector signed short vec_vadduhm (vector signed short,
13633 vector signed short);
13634 vector unsigned short vec_vadduhm (vector bool short,
13635 vector unsigned short);
13636 vector unsigned short vec_vadduhm (vector unsigned short,
13637 vector bool short);
13638 vector unsigned short vec_vadduhm (vector unsigned short,
13639 vector unsigned short);
13640
13641 vector signed char vec_vaddubm (vector bool char, vector signed char);
13642 vector signed char vec_vaddubm (vector signed char, vector bool char);
13643 vector signed char vec_vaddubm (vector signed char, vector signed char);
13644 vector unsigned char vec_vaddubm (vector bool char,
13645 vector unsigned char);
13646 vector unsigned char vec_vaddubm (vector unsigned char,
13647 vector bool char);
13648 vector unsigned char vec_vaddubm (vector unsigned char,
13649 vector unsigned char);
13650
13651 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13652
13653 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13654 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13655 vector unsigned char vec_adds (vector unsigned char,
13656 vector unsigned char);
13657 vector signed char vec_adds (vector bool char, vector signed char);
13658 vector signed char vec_adds (vector signed char, vector bool char);
13659 vector signed char vec_adds (vector signed char, vector signed char);
13660 vector unsigned short vec_adds (vector bool short,
13661 vector unsigned short);
13662 vector unsigned short vec_adds (vector unsigned short,
13663 vector bool short);
13664 vector unsigned short vec_adds (vector unsigned short,
13665 vector unsigned short);
13666 vector signed short vec_adds (vector bool short, vector signed short);
13667 vector signed short vec_adds (vector signed short, vector bool short);
13668 vector signed short vec_adds (vector signed short, vector signed short);
13669 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13670 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13671 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13672 vector signed int vec_adds (vector bool int, vector signed int);
13673 vector signed int vec_adds (vector signed int, vector bool int);
13674 vector signed int vec_adds (vector signed int, vector signed int);
13675
13676 vector signed int vec_vaddsws (vector bool int, vector signed int);
13677 vector signed int vec_vaddsws (vector signed int, vector bool int);
13678 vector signed int vec_vaddsws (vector signed int, vector signed int);
13679
13680 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13681 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13682 vector unsigned int vec_vadduws (vector unsigned int,
13683 vector unsigned int);
13684
13685 vector signed short vec_vaddshs (vector bool short,
13686 vector signed short);
13687 vector signed short vec_vaddshs (vector signed short,
13688 vector bool short);
13689 vector signed short vec_vaddshs (vector signed short,
13690 vector signed short);
13691
13692 vector unsigned short vec_vadduhs (vector bool short,
13693 vector unsigned short);
13694 vector unsigned short vec_vadduhs (vector unsigned short,
13695 vector bool short);
13696 vector unsigned short vec_vadduhs (vector unsigned short,
13697 vector unsigned short);
13698
13699 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13700 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13701 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13702
13703 vector unsigned char vec_vaddubs (vector bool char,
13704 vector unsigned char);
13705 vector unsigned char vec_vaddubs (vector unsigned char,
13706 vector bool char);
13707 vector unsigned char vec_vaddubs (vector unsigned char,
13708 vector unsigned char);
13709
13710 vector float vec_and (vector float, vector float);
13711 vector float vec_and (vector float, vector bool int);
13712 vector float vec_and (vector bool int, vector float);
13713 vector bool int vec_and (vector bool int, vector bool int);
13714 vector signed int vec_and (vector bool int, vector signed int);
13715 vector signed int vec_and (vector signed int, vector bool int);
13716 vector signed int vec_and (vector signed int, vector signed int);
13717 vector unsigned int vec_and (vector bool int, vector unsigned int);
13718 vector unsigned int vec_and (vector unsigned int, vector bool int);
13719 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13720 vector bool short vec_and (vector bool short, vector bool short);
13721 vector signed short vec_and (vector bool short, vector signed short);
13722 vector signed short vec_and (vector signed short, vector bool short);
13723 vector signed short vec_and (vector signed short, vector signed short);
13724 vector unsigned short vec_and (vector bool short,
13725 vector unsigned short);
13726 vector unsigned short vec_and (vector unsigned short,
13727 vector bool short);
13728 vector unsigned short vec_and (vector unsigned short,
13729 vector unsigned short);
13730 vector signed char vec_and (vector bool char, vector signed char);
13731 vector bool char vec_and (vector bool char, vector bool char);
13732 vector signed char vec_and (vector signed char, vector bool char);
13733 vector signed char vec_and (vector signed char, vector signed char);
13734 vector unsigned char vec_and (vector bool char, vector unsigned char);
13735 vector unsigned char vec_and (vector unsigned char, vector bool char);
13736 vector unsigned char vec_and (vector unsigned char,
13737 vector unsigned char);
13738
13739 vector float vec_andc (vector float, vector float);
13740 vector float vec_andc (vector float, vector bool int);
13741 vector float vec_andc (vector bool int, vector float);
13742 vector bool int vec_andc (vector bool int, vector bool int);
13743 vector signed int vec_andc (vector bool int, vector signed int);
13744 vector signed int vec_andc (vector signed int, vector bool int);
13745 vector signed int vec_andc (vector signed int, vector signed int);
13746 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13747 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13748 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13749 vector bool short vec_andc (vector bool short, vector bool short);
13750 vector signed short vec_andc (vector bool short, vector signed short);
13751 vector signed short vec_andc (vector signed short, vector bool short);
13752 vector signed short vec_andc (vector signed short, vector signed short);
13753 vector unsigned short vec_andc (vector bool short,
13754 vector unsigned short);
13755 vector unsigned short vec_andc (vector unsigned short,
13756 vector bool short);
13757 vector unsigned short vec_andc (vector unsigned short,
13758 vector unsigned short);
13759 vector signed char vec_andc (vector bool char, vector signed char);
13760 vector bool char vec_andc (vector bool char, vector bool char);
13761 vector signed char vec_andc (vector signed char, vector bool char);
13762 vector signed char vec_andc (vector signed char, vector signed char);
13763 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13764 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13765 vector unsigned char vec_andc (vector unsigned char,
13766 vector unsigned char);
13767
13768 vector unsigned char vec_avg (vector unsigned char,
13769 vector unsigned char);
13770 vector signed char vec_avg (vector signed char, vector signed char);
13771 vector unsigned short vec_avg (vector unsigned short,
13772 vector unsigned short);
13773 vector signed short vec_avg (vector signed short, vector signed short);
13774 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13775 vector signed int vec_avg (vector signed int, vector signed int);
13776
13777 vector signed int vec_vavgsw (vector signed int, vector signed int);
13778
13779 vector unsigned int vec_vavguw (vector unsigned int,
13780 vector unsigned int);
13781
13782 vector signed short vec_vavgsh (vector signed short,
13783 vector signed short);
13784
13785 vector unsigned short vec_vavguh (vector unsigned short,
13786 vector unsigned short);
13787
13788 vector signed char vec_vavgsb (vector signed char, vector signed char);
13789
13790 vector unsigned char vec_vavgub (vector unsigned char,
13791 vector unsigned char);
13792
13793 vector float vec_copysign (vector float);
13794
13795 vector float vec_ceil (vector float);
13796
13797 vector signed int vec_cmpb (vector float, vector float);
13798
13799 vector bool char vec_cmpeq (vector signed char, vector signed char);
13800 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13801 vector bool short vec_cmpeq (vector signed short, vector signed short);
13802 vector bool short vec_cmpeq (vector unsigned short,
13803 vector unsigned short);
13804 vector bool int vec_cmpeq (vector signed int, vector signed int);
13805 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13806 vector bool int vec_cmpeq (vector float, vector float);
13807
13808 vector bool int vec_vcmpeqfp (vector float, vector float);
13809
13810 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13811 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13812
13813 vector bool short vec_vcmpequh (vector signed short,
13814 vector signed short);
13815 vector bool short vec_vcmpequh (vector unsigned short,
13816 vector unsigned short);
13817
13818 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13819 vector bool char vec_vcmpequb (vector unsigned char,
13820 vector unsigned char);
13821
13822 vector bool int vec_cmpge (vector float, vector float);
13823
13824 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13825 vector bool char vec_cmpgt (vector signed char, vector signed char);
13826 vector bool short vec_cmpgt (vector unsigned short,
13827 vector unsigned short);
13828 vector bool short vec_cmpgt (vector signed short, vector signed short);
13829 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13830 vector bool int vec_cmpgt (vector signed int, vector signed int);
13831 vector bool int vec_cmpgt (vector float, vector float);
13832
13833 vector bool int vec_vcmpgtfp (vector float, vector float);
13834
13835 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13836
13837 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13838
13839 vector bool short vec_vcmpgtsh (vector signed short,
13840 vector signed short);
13841
13842 vector bool short vec_vcmpgtuh (vector unsigned short,
13843 vector unsigned short);
13844
13845 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13846
13847 vector bool char vec_vcmpgtub (vector unsigned char,
13848 vector unsigned char);
13849
13850 vector bool int vec_cmple (vector float, vector float);
13851
13852 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13853 vector bool char vec_cmplt (vector signed char, vector signed char);
13854 vector bool short vec_cmplt (vector unsigned short,
13855 vector unsigned short);
13856 vector bool short vec_cmplt (vector signed short, vector signed short);
13857 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13858 vector bool int vec_cmplt (vector signed int, vector signed int);
13859 vector bool int vec_cmplt (vector float, vector float);
13860
13861 vector float vec_cpsgn (vector float, vector float);
13862
13863 vector float vec_ctf (vector unsigned int, const int);
13864 vector float vec_ctf (vector signed int, const int);
13865 vector double vec_ctf (vector unsigned long, const int);
13866 vector double vec_ctf (vector signed long, const int);
13867
13868 vector float vec_vcfsx (vector signed int, const int);
13869
13870 vector float vec_vcfux (vector unsigned int, const int);
13871
13872 vector signed int vec_cts (vector float, const int);
13873 vector signed long vec_cts (vector double, const int);
13874
13875 vector unsigned int vec_ctu (vector float, const int);
13876 vector unsigned long vec_ctu (vector double, const int);
13877
13878 void vec_dss (const int);
13879
13880 void vec_dssall (void);
13881
13882 void vec_dst (const vector unsigned char *, int, const int);
13883 void vec_dst (const vector signed char *, int, const int);
13884 void vec_dst (const vector bool char *, int, const int);
13885 void vec_dst (const vector unsigned short *, int, const int);
13886 void vec_dst (const vector signed short *, int, const int);
13887 void vec_dst (const vector bool short *, int, const int);
13888 void vec_dst (const vector pixel *, int, const int);
13889 void vec_dst (const vector unsigned int *, int, const int);
13890 void vec_dst (const vector signed int *, int, const int);
13891 void vec_dst (const vector bool int *, int, const int);
13892 void vec_dst (const vector float *, int, const int);
13893 void vec_dst (const unsigned char *, int, const int);
13894 void vec_dst (const signed char *, int, const int);
13895 void vec_dst (const unsigned short *, int, const int);
13896 void vec_dst (const short *, int, const int);
13897 void vec_dst (const unsigned int *, int, const int);
13898 void vec_dst (const int *, int, const int);
13899 void vec_dst (const unsigned long *, int, const int);
13900 void vec_dst (const long *, int, const int);
13901 void vec_dst (const float *, int, const int);
13902
13903 void vec_dstst (const vector unsigned char *, int, const int);
13904 void vec_dstst (const vector signed char *, int, const int);
13905 void vec_dstst (const vector bool char *, int, const int);
13906 void vec_dstst (const vector unsigned short *, int, const int);
13907 void vec_dstst (const vector signed short *, int, const int);
13908 void vec_dstst (const vector bool short *, int, const int);
13909 void vec_dstst (const vector pixel *, int, const int);
13910 void vec_dstst (const vector unsigned int *, int, const int);
13911 void vec_dstst (const vector signed int *, int, const int);
13912 void vec_dstst (const vector bool int *, int, const int);
13913 void vec_dstst (const vector float *, int, const int);
13914 void vec_dstst (const unsigned char *, int, const int);
13915 void vec_dstst (const signed char *, int, const int);
13916 void vec_dstst (const unsigned short *, int, const int);
13917 void vec_dstst (const short *, int, const int);
13918 void vec_dstst (const unsigned int *, int, const int);
13919 void vec_dstst (const int *, int, const int);
13920 void vec_dstst (const unsigned long *, int, const int);
13921 void vec_dstst (const long *, int, const int);
13922 void vec_dstst (const float *, int, const int);
13923
13924 void vec_dststt (const vector unsigned char *, int, const int);
13925 void vec_dststt (const vector signed char *, int, const int);
13926 void vec_dststt (const vector bool char *, int, const int);
13927 void vec_dststt (const vector unsigned short *, int, const int);
13928 void vec_dststt (const vector signed short *, int, const int);
13929 void vec_dststt (const vector bool short *, int, const int);
13930 void vec_dststt (const vector pixel *, int, const int);
13931 void vec_dststt (const vector unsigned int *, int, const int);
13932 void vec_dststt (const vector signed int *, int, const int);
13933 void vec_dststt (const vector bool int *, int, const int);
13934 void vec_dststt (const vector float *, int, const int);
13935 void vec_dststt (const unsigned char *, int, const int);
13936 void vec_dststt (const signed char *, int, const int);
13937 void vec_dststt (const unsigned short *, int, const int);
13938 void vec_dststt (const short *, int, const int);
13939 void vec_dststt (const unsigned int *, int, const int);
13940 void vec_dststt (const int *, int, const int);
13941 void vec_dststt (const unsigned long *, int, const int);
13942 void vec_dststt (const long *, int, const int);
13943 void vec_dststt (const float *, int, const int);
13944
13945 void vec_dstt (const vector unsigned char *, int, const int);
13946 void vec_dstt (const vector signed char *, int, const int);
13947 void vec_dstt (const vector bool char *, int, const int);
13948 void vec_dstt (const vector unsigned short *, int, const int);
13949 void vec_dstt (const vector signed short *, int, const int);
13950 void vec_dstt (const vector bool short *, int, const int);
13951 void vec_dstt (const vector pixel *, int, const int);
13952 void vec_dstt (const vector unsigned int *, int, const int);
13953 void vec_dstt (const vector signed int *, int, const int);
13954 void vec_dstt (const vector bool int *, int, const int);
13955 void vec_dstt (const vector float *, int, const int);
13956 void vec_dstt (const unsigned char *, int, const int);
13957 void vec_dstt (const signed char *, int, const int);
13958 void vec_dstt (const unsigned short *, int, const int);
13959 void vec_dstt (const short *, int, const int);
13960 void vec_dstt (const unsigned int *, int, const int);
13961 void vec_dstt (const int *, int, const int);
13962 void vec_dstt (const unsigned long *, int, const int);
13963 void vec_dstt (const long *, int, const int);
13964 void vec_dstt (const float *, int, const int);
13965
13966 vector float vec_expte (vector float);
13967
13968 vector float vec_floor (vector float);
13969
13970 vector float vec_ld (int, const vector float *);
13971 vector float vec_ld (int, const float *);
13972 vector bool int vec_ld (int, const vector bool int *);
13973 vector signed int vec_ld (int, const vector signed int *);
13974 vector signed int vec_ld (int, const int *);
13975 vector signed int vec_ld (int, const long *);
13976 vector unsigned int vec_ld (int, const vector unsigned int *);
13977 vector unsigned int vec_ld (int, const unsigned int *);
13978 vector unsigned int vec_ld (int, const unsigned long *);
13979 vector bool short vec_ld (int, const vector bool short *);
13980 vector pixel vec_ld (int, const vector pixel *);
13981 vector signed short vec_ld (int, const vector signed short *);
13982 vector signed short vec_ld (int, const short *);
13983 vector unsigned short vec_ld (int, const vector unsigned short *);
13984 vector unsigned short vec_ld (int, const unsigned short *);
13985 vector bool char vec_ld (int, const vector bool char *);
13986 vector signed char vec_ld (int, const vector signed char *);
13987 vector signed char vec_ld (int, const signed char *);
13988 vector unsigned char vec_ld (int, const vector unsigned char *);
13989 vector unsigned char vec_ld (int, const unsigned char *);
13990
13991 vector signed char vec_lde (int, const signed char *);
13992 vector unsigned char vec_lde (int, const unsigned char *);
13993 vector signed short vec_lde (int, const short *);
13994 vector unsigned short vec_lde (int, const unsigned short *);
13995 vector float vec_lde (int, const float *);
13996 vector signed int vec_lde (int, const int *);
13997 vector unsigned int vec_lde (int, const unsigned int *);
13998 vector signed int vec_lde (int, const long *);
13999 vector unsigned int vec_lde (int, const unsigned long *);
14000
14001 vector float vec_lvewx (int, float *);
14002 vector signed int vec_lvewx (int, int *);
14003 vector unsigned int vec_lvewx (int, unsigned int *);
14004 vector signed int vec_lvewx (int, long *);
14005 vector unsigned int vec_lvewx (int, unsigned long *);
14006
14007 vector signed short vec_lvehx (int, short *);
14008 vector unsigned short vec_lvehx (int, unsigned short *);
14009
14010 vector signed char vec_lvebx (int, char *);
14011 vector unsigned char vec_lvebx (int, unsigned char *);
14012
14013 vector float vec_ldl (int, const vector float *);
14014 vector float vec_ldl (int, const float *);
14015 vector bool int vec_ldl (int, const vector bool int *);
14016 vector signed int vec_ldl (int, const vector signed int *);
14017 vector signed int vec_ldl (int, const int *);
14018 vector signed int vec_ldl (int, const long *);
14019 vector unsigned int vec_ldl (int, const vector unsigned int *);
14020 vector unsigned int vec_ldl (int, const unsigned int *);
14021 vector unsigned int vec_ldl (int, const unsigned long *);
14022 vector bool short vec_ldl (int, const vector bool short *);
14023 vector pixel vec_ldl (int, const vector pixel *);
14024 vector signed short vec_ldl (int, const vector signed short *);
14025 vector signed short vec_ldl (int, const short *);
14026 vector unsigned short vec_ldl (int, const vector unsigned short *);
14027 vector unsigned short vec_ldl (int, const unsigned short *);
14028 vector bool char vec_ldl (int, const vector bool char *);
14029 vector signed char vec_ldl (int, const vector signed char *);
14030 vector signed char vec_ldl (int, const signed char *);
14031 vector unsigned char vec_ldl (int, const vector unsigned char *);
14032 vector unsigned char vec_ldl (int, const unsigned char *);
14033
14034 vector float vec_loge (vector float);
14035
14036 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14037 vector unsigned char vec_lvsl (int, const volatile signed char *);
14038 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14039 vector unsigned char vec_lvsl (int, const volatile short *);
14040 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14041 vector unsigned char vec_lvsl (int, const volatile int *);
14042 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14043 vector unsigned char vec_lvsl (int, const volatile long *);
14044 vector unsigned char vec_lvsl (int, const volatile float *);
14045
14046 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14047 vector unsigned char vec_lvsr (int, const volatile signed char *);
14048 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14049 vector unsigned char vec_lvsr (int, const volatile short *);
14050 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14051 vector unsigned char vec_lvsr (int, const volatile int *);
14052 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14053 vector unsigned char vec_lvsr (int, const volatile long *);
14054 vector unsigned char vec_lvsr (int, const volatile float *);
14055
14056 vector float vec_madd (vector float, vector float, vector float);
14057
14058 vector signed short vec_madds (vector signed short,
14059 vector signed short,
14060 vector signed short);
14061
14062 vector unsigned char vec_max (vector bool char, vector unsigned char);
14063 vector unsigned char vec_max (vector unsigned char, vector bool char);
14064 vector unsigned char vec_max (vector unsigned char,
14065 vector unsigned char);
14066 vector signed char vec_max (vector bool char, vector signed char);
14067 vector signed char vec_max (vector signed char, vector bool char);
14068 vector signed char vec_max (vector signed char, vector signed char);
14069 vector unsigned short vec_max (vector bool short,
14070 vector unsigned short);
14071 vector unsigned short vec_max (vector unsigned short,
14072 vector bool short);
14073 vector unsigned short vec_max (vector unsigned short,
14074 vector unsigned short);
14075 vector signed short vec_max (vector bool short, vector signed short);
14076 vector signed short vec_max (vector signed short, vector bool short);
14077 vector signed short vec_max (vector signed short, vector signed short);
14078 vector unsigned int vec_max (vector bool int, vector unsigned int);
14079 vector unsigned int vec_max (vector unsigned int, vector bool int);
14080 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14081 vector signed int vec_max (vector bool int, vector signed int);
14082 vector signed int vec_max (vector signed int, vector bool int);
14083 vector signed int vec_max (vector signed int, vector signed int);
14084 vector float vec_max (vector float, vector float);
14085
14086 vector float vec_vmaxfp (vector float, vector float);
14087
14088 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14089 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14090 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14091
14092 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14093 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14094 vector unsigned int vec_vmaxuw (vector unsigned int,
14095 vector unsigned int);
14096
14097 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14098 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14099 vector signed short vec_vmaxsh (vector signed short,
14100 vector signed short);
14101
14102 vector unsigned short vec_vmaxuh (vector bool short,
14103 vector unsigned short);
14104 vector unsigned short vec_vmaxuh (vector unsigned short,
14105 vector bool short);
14106 vector unsigned short vec_vmaxuh (vector unsigned short,
14107 vector unsigned short);
14108
14109 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14110 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14111 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14112
14113 vector unsigned char vec_vmaxub (vector bool char,
14114 vector unsigned char);
14115 vector unsigned char vec_vmaxub (vector unsigned char,
14116 vector bool char);
14117 vector unsigned char vec_vmaxub (vector unsigned char,
14118 vector unsigned char);
14119
14120 vector bool char vec_mergeh (vector bool char, vector bool char);
14121 vector signed char vec_mergeh (vector signed char, vector signed char);
14122 vector unsigned char vec_mergeh (vector unsigned char,
14123 vector unsigned char);
14124 vector bool short vec_mergeh (vector bool short, vector bool short);
14125 vector pixel vec_mergeh (vector pixel, vector pixel);
14126 vector signed short vec_mergeh (vector signed short,
14127 vector signed short);
14128 vector unsigned short vec_mergeh (vector unsigned short,
14129 vector unsigned short);
14130 vector float vec_mergeh (vector float, vector float);
14131 vector bool int vec_mergeh (vector bool int, vector bool int);
14132 vector signed int vec_mergeh (vector signed int, vector signed int);
14133 vector unsigned int vec_mergeh (vector unsigned int,
14134 vector unsigned int);
14135
14136 vector float vec_vmrghw (vector float, vector float);
14137 vector bool int vec_vmrghw (vector bool int, vector bool int);
14138 vector signed int vec_vmrghw (vector signed int, vector signed int);
14139 vector unsigned int vec_vmrghw (vector unsigned int,
14140 vector unsigned int);
14141
14142 vector bool short vec_vmrghh (vector bool short, vector bool short);
14143 vector signed short vec_vmrghh (vector signed short,
14144 vector signed short);
14145 vector unsigned short vec_vmrghh (vector unsigned short,
14146 vector unsigned short);
14147 vector pixel vec_vmrghh (vector pixel, vector pixel);
14148
14149 vector bool char vec_vmrghb (vector bool char, vector bool char);
14150 vector signed char vec_vmrghb (vector signed char, vector signed char);
14151 vector unsigned char vec_vmrghb (vector unsigned char,
14152 vector unsigned char);
14153
14154 vector bool char vec_mergel (vector bool char, vector bool char);
14155 vector signed char vec_mergel (vector signed char, vector signed char);
14156 vector unsigned char vec_mergel (vector unsigned char,
14157 vector unsigned char);
14158 vector bool short vec_mergel (vector bool short, vector bool short);
14159 vector pixel vec_mergel (vector pixel, vector pixel);
14160 vector signed short vec_mergel (vector signed short,
14161 vector signed short);
14162 vector unsigned short vec_mergel (vector unsigned short,
14163 vector unsigned short);
14164 vector float vec_mergel (vector float, vector float);
14165 vector bool int vec_mergel (vector bool int, vector bool int);
14166 vector signed int vec_mergel (vector signed int, vector signed int);
14167 vector unsigned int vec_mergel (vector unsigned int,
14168 vector unsigned int);
14169
14170 vector float vec_vmrglw (vector float, vector float);
14171 vector signed int vec_vmrglw (vector signed int, vector signed int);
14172 vector unsigned int vec_vmrglw (vector unsigned int,
14173 vector unsigned int);
14174 vector bool int vec_vmrglw (vector bool int, vector bool int);
14175
14176 vector bool short vec_vmrglh (vector bool short, vector bool short);
14177 vector signed short vec_vmrglh (vector signed short,
14178 vector signed short);
14179 vector unsigned short vec_vmrglh (vector unsigned short,
14180 vector unsigned short);
14181 vector pixel vec_vmrglh (vector pixel, vector pixel);
14182
14183 vector bool char vec_vmrglb (vector bool char, vector bool char);
14184 vector signed char vec_vmrglb (vector signed char, vector signed char);
14185 vector unsigned char vec_vmrglb (vector unsigned char,
14186 vector unsigned char);
14187
14188 vector unsigned short vec_mfvscr (void);
14189
14190 vector unsigned char vec_min (vector bool char, vector unsigned char);
14191 vector unsigned char vec_min (vector unsigned char, vector bool char);
14192 vector unsigned char vec_min (vector unsigned char,
14193 vector unsigned char);
14194 vector signed char vec_min (vector bool char, vector signed char);
14195 vector signed char vec_min (vector signed char, vector bool char);
14196 vector signed char vec_min (vector signed char, vector signed char);
14197 vector unsigned short vec_min (vector bool short,
14198 vector unsigned short);
14199 vector unsigned short vec_min (vector unsigned short,
14200 vector bool short);
14201 vector unsigned short vec_min (vector unsigned short,
14202 vector unsigned short);
14203 vector signed short vec_min (vector bool short, vector signed short);
14204 vector signed short vec_min (vector signed short, vector bool short);
14205 vector signed short vec_min (vector signed short, vector signed short);
14206 vector unsigned int vec_min (vector bool int, vector unsigned int);
14207 vector unsigned int vec_min (vector unsigned int, vector bool int);
14208 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14209 vector signed int vec_min (vector bool int, vector signed int);
14210 vector signed int vec_min (vector signed int, vector bool int);
14211 vector signed int vec_min (vector signed int, vector signed int);
14212 vector float vec_min (vector float, vector float);
14213
14214 vector float vec_vminfp (vector float, vector float);
14215
14216 vector signed int vec_vminsw (vector bool int, vector signed int);
14217 vector signed int vec_vminsw (vector signed int, vector bool int);
14218 vector signed int vec_vminsw (vector signed int, vector signed int);
14219
14220 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14221 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14222 vector unsigned int vec_vminuw (vector unsigned int,
14223 vector unsigned int);
14224
14225 vector signed short vec_vminsh (vector bool short, vector signed short);
14226 vector signed short vec_vminsh (vector signed short, vector bool short);
14227 vector signed short vec_vminsh (vector signed short,
14228 vector signed short);
14229
14230 vector unsigned short vec_vminuh (vector bool short,
14231 vector unsigned short);
14232 vector unsigned short vec_vminuh (vector unsigned short,
14233 vector bool short);
14234 vector unsigned short vec_vminuh (vector unsigned short,
14235 vector unsigned short);
14236
14237 vector signed char vec_vminsb (vector bool char, vector signed char);
14238 vector signed char vec_vminsb (vector signed char, vector bool char);
14239 vector signed char vec_vminsb (vector signed char, vector signed char);
14240
14241 vector unsigned char vec_vminub (vector bool char,
14242 vector unsigned char);
14243 vector unsigned char vec_vminub (vector unsigned char,
14244 vector bool char);
14245 vector unsigned char vec_vminub (vector unsigned char,
14246 vector unsigned char);
14247
14248 vector signed short vec_mladd (vector signed short,
14249 vector signed short,
14250 vector signed short);
14251 vector signed short vec_mladd (vector signed short,
14252 vector unsigned short,
14253 vector unsigned short);
14254 vector signed short vec_mladd (vector unsigned short,
14255 vector signed short,
14256 vector signed short);
14257 vector unsigned short vec_mladd (vector unsigned short,
14258 vector unsigned short,
14259 vector unsigned short);
14260
14261 vector signed short vec_mradds (vector signed short,
14262 vector signed short,
14263 vector signed short);
14264
14265 vector unsigned int vec_msum (vector unsigned char,
14266 vector unsigned char,
14267 vector unsigned int);
14268 vector signed int vec_msum (vector signed char,
14269 vector unsigned char,
14270 vector signed int);
14271 vector unsigned int vec_msum (vector unsigned short,
14272 vector unsigned short,
14273 vector unsigned int);
14274 vector signed int vec_msum (vector signed short,
14275 vector signed short,
14276 vector signed int);
14277
14278 vector signed int vec_vmsumshm (vector signed short,
14279 vector signed short,
14280 vector signed int);
14281
14282 vector unsigned int vec_vmsumuhm (vector unsigned short,
14283 vector unsigned short,
14284 vector unsigned int);
14285
14286 vector signed int vec_vmsummbm (vector signed char,
14287 vector unsigned char,
14288 vector signed int);
14289
14290 vector unsigned int vec_vmsumubm (vector unsigned char,
14291 vector unsigned char,
14292 vector unsigned int);
14293
14294 vector unsigned int vec_msums (vector unsigned short,
14295 vector unsigned short,
14296 vector unsigned int);
14297 vector signed int vec_msums (vector signed short,
14298 vector signed short,
14299 vector signed int);
14300
14301 vector signed int vec_vmsumshs (vector signed short,
14302 vector signed short,
14303 vector signed int);
14304
14305 vector unsigned int vec_vmsumuhs (vector unsigned short,
14306 vector unsigned short,
14307 vector unsigned int);
14308
14309 void vec_mtvscr (vector signed int);
14310 void vec_mtvscr (vector unsigned int);
14311 void vec_mtvscr (vector bool int);
14312 void vec_mtvscr (vector signed short);
14313 void vec_mtvscr (vector unsigned short);
14314 void vec_mtvscr (vector bool short);
14315 void vec_mtvscr (vector pixel);
14316 void vec_mtvscr (vector signed char);
14317 void vec_mtvscr (vector unsigned char);
14318 void vec_mtvscr (vector bool char);
14319
14320 vector unsigned short vec_mule (vector unsigned char,
14321 vector unsigned char);
14322 vector signed short vec_mule (vector signed char,
14323 vector signed char);
14324 vector unsigned int vec_mule (vector unsigned short,
14325 vector unsigned short);
14326 vector signed int vec_mule (vector signed short, vector signed short);
14327
14328 vector signed int vec_vmulesh (vector signed short,
14329 vector signed short);
14330
14331 vector unsigned int vec_vmuleuh (vector unsigned short,
14332 vector unsigned short);
14333
14334 vector signed short vec_vmulesb (vector signed char,
14335 vector signed char);
14336
14337 vector unsigned short vec_vmuleub (vector unsigned char,
14338 vector unsigned char);
14339
14340 vector unsigned short vec_mulo (vector unsigned char,
14341 vector unsigned char);
14342 vector signed short vec_mulo (vector signed char, vector signed char);
14343 vector unsigned int vec_mulo (vector unsigned short,
14344 vector unsigned short);
14345 vector signed int vec_mulo (vector signed short, vector signed short);
14346
14347 vector signed int vec_vmulosh (vector signed short,
14348 vector signed short);
14349
14350 vector unsigned int vec_vmulouh (vector unsigned short,
14351 vector unsigned short);
14352
14353 vector signed short vec_vmulosb (vector signed char,
14354 vector signed char);
14355
14356 vector unsigned short vec_vmuloub (vector unsigned char,
14357 vector unsigned char);
14358
14359 vector float vec_nmsub (vector float, vector float, vector float);
14360
14361 vector float vec_nor (vector float, vector float);
14362 vector signed int vec_nor (vector signed int, vector signed int);
14363 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14364 vector bool int vec_nor (vector bool int, vector bool int);
14365 vector signed short vec_nor (vector signed short, vector signed short);
14366 vector unsigned short vec_nor (vector unsigned short,
14367 vector unsigned short);
14368 vector bool short vec_nor (vector bool short, vector bool short);
14369 vector signed char vec_nor (vector signed char, vector signed char);
14370 vector unsigned char vec_nor (vector unsigned char,
14371 vector unsigned char);
14372 vector bool char vec_nor (vector bool char, vector bool char);
14373
14374 vector float vec_or (vector float, vector float);
14375 vector float vec_or (vector float, vector bool int);
14376 vector float vec_or (vector bool int, vector float);
14377 vector bool int vec_or (vector bool int, vector bool int);
14378 vector signed int vec_or (vector bool int, vector signed int);
14379 vector signed int vec_or (vector signed int, vector bool int);
14380 vector signed int vec_or (vector signed int, vector signed int);
14381 vector unsigned int vec_or (vector bool int, vector unsigned int);
14382 vector unsigned int vec_or (vector unsigned int, vector bool int);
14383 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14384 vector bool short vec_or (vector bool short, vector bool short);
14385 vector signed short vec_or (vector bool short, vector signed short);
14386 vector signed short vec_or (vector signed short, vector bool short);
14387 vector signed short vec_or (vector signed short, vector signed short);
14388 vector unsigned short vec_or (vector bool short, vector unsigned short);
14389 vector unsigned short vec_or (vector unsigned short, vector bool short);
14390 vector unsigned short vec_or (vector unsigned short,
14391 vector unsigned short);
14392 vector signed char vec_or (vector bool char, vector signed char);
14393 vector bool char vec_or (vector bool char, vector bool char);
14394 vector signed char vec_or (vector signed char, vector bool char);
14395 vector signed char vec_or (vector signed char, vector signed char);
14396 vector unsigned char vec_or (vector bool char, vector unsigned char);
14397 vector unsigned char vec_or (vector unsigned char, vector bool char);
14398 vector unsigned char vec_or (vector unsigned char,
14399 vector unsigned char);
14400
14401 vector signed char vec_pack (vector signed short, vector signed short);
14402 vector unsigned char vec_pack (vector unsigned short,
14403 vector unsigned short);
14404 vector bool char vec_pack (vector bool short, vector bool short);
14405 vector signed short vec_pack (vector signed int, vector signed int);
14406 vector unsigned short vec_pack (vector unsigned int,
14407 vector unsigned int);
14408 vector bool short vec_pack (vector bool int, vector bool int);
14409
14410 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14411 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14412 vector unsigned short vec_vpkuwum (vector unsigned int,
14413 vector unsigned int);
14414
14415 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14416 vector signed char vec_vpkuhum (vector signed short,
14417 vector signed short);
14418 vector unsigned char vec_vpkuhum (vector unsigned short,
14419 vector unsigned short);
14420
14421 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14422
14423 vector unsigned char vec_packs (vector unsigned short,
14424 vector unsigned short);
14425 vector signed char vec_packs (vector signed short, vector signed short);
14426 vector unsigned short vec_packs (vector unsigned int,
14427 vector unsigned int);
14428 vector signed short vec_packs (vector signed int, vector signed int);
14429
14430 vector signed short vec_vpkswss (vector signed int, vector signed int);
14431
14432 vector unsigned short vec_vpkuwus (vector unsigned int,
14433 vector unsigned int);
14434
14435 vector signed char vec_vpkshss (vector signed short,
14436 vector signed short);
14437
14438 vector unsigned char vec_vpkuhus (vector unsigned short,
14439 vector unsigned short);
14440
14441 vector unsigned char vec_packsu (vector unsigned short,
14442 vector unsigned short);
14443 vector unsigned char vec_packsu (vector signed short,
14444 vector signed short);
14445 vector unsigned short vec_packsu (vector unsigned int,
14446 vector unsigned int);
14447 vector unsigned short vec_packsu (vector signed int, vector signed int);
14448
14449 vector unsigned short vec_vpkswus (vector signed int,
14450 vector signed int);
14451
14452 vector unsigned char vec_vpkshus (vector signed short,
14453 vector signed short);
14454
14455 vector float vec_perm (vector float,
14456 vector float,
14457 vector unsigned char);
14458 vector signed int vec_perm (vector signed int,
14459 vector signed int,
14460 vector unsigned char);
14461 vector unsigned int vec_perm (vector unsigned int,
14462 vector unsigned int,
14463 vector unsigned char);
14464 vector bool int vec_perm (vector bool int,
14465 vector bool int,
14466 vector unsigned char);
14467 vector signed short vec_perm (vector signed short,
14468 vector signed short,
14469 vector unsigned char);
14470 vector unsigned short vec_perm (vector unsigned short,
14471 vector unsigned short,
14472 vector unsigned char);
14473 vector bool short vec_perm (vector bool short,
14474 vector bool short,
14475 vector unsigned char);
14476 vector pixel vec_perm (vector pixel,
14477 vector pixel,
14478 vector unsigned char);
14479 vector signed char vec_perm (vector signed char,
14480 vector signed char,
14481 vector unsigned char);
14482 vector unsigned char vec_perm (vector unsigned char,
14483 vector unsigned char,
14484 vector unsigned char);
14485 vector bool char vec_perm (vector bool char,
14486 vector bool char,
14487 vector unsigned char);
14488
14489 vector float vec_re (vector float);
14490
14491 vector signed char vec_rl (vector signed char,
14492 vector unsigned char);
14493 vector unsigned char vec_rl (vector unsigned char,
14494 vector unsigned char);
14495 vector signed short vec_rl (vector signed short, vector unsigned short);
14496 vector unsigned short vec_rl (vector unsigned short,
14497 vector unsigned short);
14498 vector signed int vec_rl (vector signed int, vector unsigned int);
14499 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14500
14501 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14502 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14503
14504 vector signed short vec_vrlh (vector signed short,
14505 vector unsigned short);
14506 vector unsigned short vec_vrlh (vector unsigned short,
14507 vector unsigned short);
14508
14509 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14510 vector unsigned char vec_vrlb (vector unsigned char,
14511 vector unsigned char);
14512
14513 vector float vec_round (vector float);
14514
14515 vector float vec_recip (vector float, vector float);
14516
14517 vector float vec_rsqrt (vector float);
14518
14519 vector float vec_rsqrte (vector float);
14520
14521 vector float vec_sel (vector float, vector float, vector bool int);
14522 vector float vec_sel (vector float, vector float, vector unsigned int);
14523 vector signed int vec_sel (vector signed int,
14524 vector signed int,
14525 vector bool int);
14526 vector signed int vec_sel (vector signed int,
14527 vector signed int,
14528 vector unsigned int);
14529 vector unsigned int vec_sel (vector unsigned int,
14530 vector unsigned int,
14531 vector bool int);
14532 vector unsigned int vec_sel (vector unsigned int,
14533 vector unsigned int,
14534 vector unsigned int);
14535 vector bool int vec_sel (vector bool int,
14536 vector bool int,
14537 vector bool int);
14538 vector bool int vec_sel (vector bool int,
14539 vector bool int,
14540 vector unsigned int);
14541 vector signed short vec_sel (vector signed short,
14542 vector signed short,
14543 vector bool short);
14544 vector signed short vec_sel (vector signed short,
14545 vector signed short,
14546 vector unsigned short);
14547 vector unsigned short vec_sel (vector unsigned short,
14548 vector unsigned short,
14549 vector bool short);
14550 vector unsigned short vec_sel (vector unsigned short,
14551 vector unsigned short,
14552 vector unsigned short);
14553 vector bool short vec_sel (vector bool short,
14554 vector bool short,
14555 vector bool short);
14556 vector bool short vec_sel (vector bool short,
14557 vector bool short,
14558 vector unsigned short);
14559 vector signed char vec_sel (vector signed char,
14560 vector signed char,
14561 vector bool char);
14562 vector signed char vec_sel (vector signed char,
14563 vector signed char,
14564 vector unsigned char);
14565 vector unsigned char vec_sel (vector unsigned char,
14566 vector unsigned char,
14567 vector bool char);
14568 vector unsigned char vec_sel (vector unsigned char,
14569 vector unsigned char,
14570 vector unsigned char);
14571 vector bool char vec_sel (vector bool char,
14572 vector bool char,
14573 vector bool char);
14574 vector bool char vec_sel (vector bool char,
14575 vector bool char,
14576 vector unsigned char);
14577
14578 vector signed char vec_sl (vector signed char,
14579 vector unsigned char);
14580 vector unsigned char vec_sl (vector unsigned char,
14581 vector unsigned char);
14582 vector signed short vec_sl (vector signed short, vector unsigned short);
14583 vector unsigned short vec_sl (vector unsigned short,
14584 vector unsigned short);
14585 vector signed int vec_sl (vector signed int, vector unsigned int);
14586 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14587
14588 vector signed int vec_vslw (vector signed int, vector unsigned int);
14589 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14590
14591 vector signed short vec_vslh (vector signed short,
14592 vector unsigned short);
14593 vector unsigned short vec_vslh (vector unsigned short,
14594 vector unsigned short);
14595
14596 vector signed char vec_vslb (vector signed char, vector unsigned char);
14597 vector unsigned char vec_vslb (vector unsigned char,
14598 vector unsigned char);
14599
14600 vector float vec_sld (vector float, vector float, const int);
14601 vector signed int vec_sld (vector signed int,
14602 vector signed int,
14603 const int);
14604 vector unsigned int vec_sld (vector unsigned int,
14605 vector unsigned int,
14606 const int);
14607 vector bool int vec_sld (vector bool int,
14608 vector bool int,
14609 const int);
14610 vector signed short vec_sld (vector signed short,
14611 vector signed short,
14612 const int);
14613 vector unsigned short vec_sld (vector unsigned short,
14614 vector unsigned short,
14615 const int);
14616 vector bool short vec_sld (vector bool short,
14617 vector bool short,
14618 const int);
14619 vector pixel vec_sld (vector pixel,
14620 vector pixel,
14621 const int);
14622 vector signed char vec_sld (vector signed char,
14623 vector signed char,
14624 const int);
14625 vector unsigned char vec_sld (vector unsigned char,
14626 vector unsigned char,
14627 const int);
14628 vector bool char vec_sld (vector bool char,
14629 vector bool char,
14630 const int);
14631
14632 vector signed int vec_sll (vector signed int,
14633 vector unsigned int);
14634 vector signed int vec_sll (vector signed int,
14635 vector unsigned short);
14636 vector signed int vec_sll (vector signed int,
14637 vector unsigned char);
14638 vector unsigned int vec_sll (vector unsigned int,
14639 vector unsigned int);
14640 vector unsigned int vec_sll (vector unsigned int,
14641 vector unsigned short);
14642 vector unsigned int vec_sll (vector unsigned int,
14643 vector unsigned char);
14644 vector bool int vec_sll (vector bool int,
14645 vector unsigned int);
14646 vector bool int vec_sll (vector bool int,
14647 vector unsigned short);
14648 vector bool int vec_sll (vector bool int,
14649 vector unsigned char);
14650 vector signed short vec_sll (vector signed short,
14651 vector unsigned int);
14652 vector signed short vec_sll (vector signed short,
14653 vector unsigned short);
14654 vector signed short vec_sll (vector signed short,
14655 vector unsigned char);
14656 vector unsigned short vec_sll (vector unsigned short,
14657 vector unsigned int);
14658 vector unsigned short vec_sll (vector unsigned short,
14659 vector unsigned short);
14660 vector unsigned short vec_sll (vector unsigned short,
14661 vector unsigned char);
14662 vector bool short vec_sll (vector bool short, vector unsigned int);
14663 vector bool short vec_sll (vector bool short, vector unsigned short);
14664 vector bool short vec_sll (vector bool short, vector unsigned char);
14665 vector pixel vec_sll (vector pixel, vector unsigned int);
14666 vector pixel vec_sll (vector pixel, vector unsigned short);
14667 vector pixel vec_sll (vector pixel, vector unsigned char);
14668 vector signed char vec_sll (vector signed char, vector unsigned int);
14669 vector signed char vec_sll (vector signed char, vector unsigned short);
14670 vector signed char vec_sll (vector signed char, vector unsigned char);
14671 vector unsigned char vec_sll (vector unsigned char,
14672 vector unsigned int);
14673 vector unsigned char vec_sll (vector unsigned char,
14674 vector unsigned short);
14675 vector unsigned char vec_sll (vector unsigned char,
14676 vector unsigned char);
14677 vector bool char vec_sll (vector bool char, vector unsigned int);
14678 vector bool char vec_sll (vector bool char, vector unsigned short);
14679 vector bool char vec_sll (vector bool char, vector unsigned char);
14680
14681 vector float vec_slo (vector float, vector signed char);
14682 vector float vec_slo (vector float, vector unsigned char);
14683 vector signed int vec_slo (vector signed int, vector signed char);
14684 vector signed int vec_slo (vector signed int, vector unsigned char);
14685 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14686 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14687 vector signed short vec_slo (vector signed short, vector signed char);
14688 vector signed short vec_slo (vector signed short, vector unsigned char);
14689 vector unsigned short vec_slo (vector unsigned short,
14690 vector signed char);
14691 vector unsigned short vec_slo (vector unsigned short,
14692 vector unsigned char);
14693 vector pixel vec_slo (vector pixel, vector signed char);
14694 vector pixel vec_slo (vector pixel, vector unsigned char);
14695 vector signed char vec_slo (vector signed char, vector signed char);
14696 vector signed char vec_slo (vector signed char, vector unsigned char);
14697 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14698 vector unsigned char vec_slo (vector unsigned char,
14699 vector unsigned char);
14700
14701 vector signed char vec_splat (vector signed char, const int);
14702 vector unsigned char vec_splat (vector unsigned char, const int);
14703 vector bool char vec_splat (vector bool char, const int);
14704 vector signed short vec_splat (vector signed short, const int);
14705 vector unsigned short vec_splat (vector unsigned short, const int);
14706 vector bool short vec_splat (vector bool short, const int);
14707 vector pixel vec_splat (vector pixel, const int);
14708 vector float vec_splat (vector float, const int);
14709 vector signed int vec_splat (vector signed int, const int);
14710 vector unsigned int vec_splat (vector unsigned int, const int);
14711 vector bool int vec_splat (vector bool int, const int);
14712 vector signed long vec_splat (vector signed long, const int);
14713 vector unsigned long vec_splat (vector unsigned long, const int);
14714
14715 vector signed char vec_splats (signed char);
14716 vector unsigned char vec_splats (unsigned char);
14717 vector signed short vec_splats (signed short);
14718 vector unsigned short vec_splats (unsigned short);
14719 vector signed int vec_splats (signed int);
14720 vector unsigned int vec_splats (unsigned int);
14721 vector float vec_splats (float);
14722
14723 vector float vec_vspltw (vector float, const int);
14724 vector signed int vec_vspltw (vector signed int, const int);
14725 vector unsigned int vec_vspltw (vector unsigned int, const int);
14726 vector bool int vec_vspltw (vector bool int, const int);
14727
14728 vector bool short vec_vsplth (vector bool short, const int);
14729 vector signed short vec_vsplth (vector signed short, const int);
14730 vector unsigned short vec_vsplth (vector unsigned short, const int);
14731 vector pixel vec_vsplth (vector pixel, const int);
14732
14733 vector signed char vec_vspltb (vector signed char, const int);
14734 vector unsigned char vec_vspltb (vector unsigned char, const int);
14735 vector bool char vec_vspltb (vector bool char, const int);
14736
14737 vector signed char vec_splat_s8 (const int);
14738
14739 vector signed short vec_splat_s16 (const int);
14740
14741 vector signed int vec_splat_s32 (const int);
14742
14743 vector unsigned char vec_splat_u8 (const int);
14744
14745 vector unsigned short vec_splat_u16 (const int);
14746
14747 vector unsigned int vec_splat_u32 (const int);
14748
14749 vector signed char vec_sr (vector signed char, vector unsigned char);
14750 vector unsigned char vec_sr (vector unsigned char,
14751 vector unsigned char);
14752 vector signed short vec_sr (vector signed short,
14753 vector unsigned short);
14754 vector unsigned short vec_sr (vector unsigned short,
14755 vector unsigned short);
14756 vector signed int vec_sr (vector signed int, vector unsigned int);
14757 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14758
14759 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14760 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14761
14762 vector signed short vec_vsrh (vector signed short,
14763 vector unsigned short);
14764 vector unsigned short vec_vsrh (vector unsigned short,
14765 vector unsigned short);
14766
14767 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14768 vector unsigned char vec_vsrb (vector unsigned char,
14769 vector unsigned char);
14770
14771 vector signed char vec_sra (vector signed char, vector unsigned char);
14772 vector unsigned char vec_sra (vector unsigned char,
14773 vector unsigned char);
14774 vector signed short vec_sra (vector signed short,
14775 vector unsigned short);
14776 vector unsigned short vec_sra (vector unsigned short,
14777 vector unsigned short);
14778 vector signed int vec_sra (vector signed int, vector unsigned int);
14779 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14780
14781 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14782 vector unsigned int vec_vsraw (vector unsigned int,
14783 vector unsigned int);
14784
14785 vector signed short vec_vsrah (vector signed short,
14786 vector unsigned short);
14787 vector unsigned short vec_vsrah (vector unsigned short,
14788 vector unsigned short);
14789
14790 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14791 vector unsigned char vec_vsrab (vector unsigned char,
14792 vector unsigned char);
14793
14794 vector signed int vec_srl (vector signed int, vector unsigned int);
14795 vector signed int vec_srl (vector signed int, vector unsigned short);
14796 vector signed int vec_srl (vector signed int, vector unsigned char);
14797 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14798 vector unsigned int vec_srl (vector unsigned int,
14799 vector unsigned short);
14800 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14801 vector bool int vec_srl (vector bool int, vector unsigned int);
14802 vector bool int vec_srl (vector bool int, vector unsigned short);
14803 vector bool int vec_srl (vector bool int, vector unsigned char);
14804 vector signed short vec_srl (vector signed short, vector unsigned int);
14805 vector signed short vec_srl (vector signed short,
14806 vector unsigned short);
14807 vector signed short vec_srl (vector signed short, vector unsigned char);
14808 vector unsigned short vec_srl (vector unsigned short,
14809 vector unsigned int);
14810 vector unsigned short vec_srl (vector unsigned short,
14811 vector unsigned short);
14812 vector unsigned short vec_srl (vector unsigned short,
14813 vector unsigned char);
14814 vector bool short vec_srl (vector bool short, vector unsigned int);
14815 vector bool short vec_srl (vector bool short, vector unsigned short);
14816 vector bool short vec_srl (vector bool short, vector unsigned char);
14817 vector pixel vec_srl (vector pixel, vector unsigned int);
14818 vector pixel vec_srl (vector pixel, vector unsigned short);
14819 vector pixel vec_srl (vector pixel, vector unsigned char);
14820 vector signed char vec_srl (vector signed char, vector unsigned int);
14821 vector signed char vec_srl (vector signed char, vector unsigned short);
14822 vector signed char vec_srl (vector signed char, vector unsigned char);
14823 vector unsigned char vec_srl (vector unsigned char,
14824 vector unsigned int);
14825 vector unsigned char vec_srl (vector unsigned char,
14826 vector unsigned short);
14827 vector unsigned char vec_srl (vector unsigned char,
14828 vector unsigned char);
14829 vector bool char vec_srl (vector bool char, vector unsigned int);
14830 vector bool char vec_srl (vector bool char, vector unsigned short);
14831 vector bool char vec_srl (vector bool char, vector unsigned char);
14832
14833 vector float vec_sro (vector float, vector signed char);
14834 vector float vec_sro (vector float, vector unsigned char);
14835 vector signed int vec_sro (vector signed int, vector signed char);
14836 vector signed int vec_sro (vector signed int, vector unsigned char);
14837 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14838 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14839 vector signed short vec_sro (vector signed short, vector signed char);
14840 vector signed short vec_sro (vector signed short, vector unsigned char);
14841 vector unsigned short vec_sro (vector unsigned short,
14842 vector signed char);
14843 vector unsigned short vec_sro (vector unsigned short,
14844 vector unsigned char);
14845 vector pixel vec_sro (vector pixel, vector signed char);
14846 vector pixel vec_sro (vector pixel, vector unsigned char);
14847 vector signed char vec_sro (vector signed char, vector signed char);
14848 vector signed char vec_sro (vector signed char, vector unsigned char);
14849 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14850 vector unsigned char vec_sro (vector unsigned char,
14851 vector unsigned char);
14852
14853 void vec_st (vector float, int, vector float *);
14854 void vec_st (vector float, int, float *);
14855 void vec_st (vector signed int, int, vector signed int *);
14856 void vec_st (vector signed int, int, int *);
14857 void vec_st (vector unsigned int, int, vector unsigned int *);
14858 void vec_st (vector unsigned int, int, unsigned int *);
14859 void vec_st (vector bool int, int, vector bool int *);
14860 void vec_st (vector bool int, int, unsigned int *);
14861 void vec_st (vector bool int, int, int *);
14862 void vec_st (vector signed short, int, vector signed short *);
14863 void vec_st (vector signed short, int, short *);
14864 void vec_st (vector unsigned short, int, vector unsigned short *);
14865 void vec_st (vector unsigned short, int, unsigned short *);
14866 void vec_st (vector bool short, int, vector bool short *);
14867 void vec_st (vector bool short, int, unsigned short *);
14868 void vec_st (vector pixel, int, vector pixel *);
14869 void vec_st (vector pixel, int, unsigned short *);
14870 void vec_st (vector pixel, int, short *);
14871 void vec_st (vector bool short, int, short *);
14872 void vec_st (vector signed char, int, vector signed char *);
14873 void vec_st (vector signed char, int, signed char *);
14874 void vec_st (vector unsigned char, int, vector unsigned char *);
14875 void vec_st (vector unsigned char, int, unsigned char *);
14876 void vec_st (vector bool char, int, vector bool char *);
14877 void vec_st (vector bool char, int, unsigned char *);
14878 void vec_st (vector bool char, int, signed char *);
14879
14880 void vec_ste (vector signed char, int, signed char *);
14881 void vec_ste (vector unsigned char, int, unsigned char *);
14882 void vec_ste (vector bool char, int, signed char *);
14883 void vec_ste (vector bool char, int, unsigned char *);
14884 void vec_ste (vector signed short, int, short *);
14885 void vec_ste (vector unsigned short, int, unsigned short *);
14886 void vec_ste (vector bool short, int, short *);
14887 void vec_ste (vector bool short, int, unsigned short *);
14888 void vec_ste (vector pixel, int, short *);
14889 void vec_ste (vector pixel, int, unsigned short *);
14890 void vec_ste (vector float, int, float *);
14891 void vec_ste (vector signed int, int, int *);
14892 void vec_ste (vector unsigned int, int, unsigned int *);
14893 void vec_ste (vector bool int, int, int *);
14894 void vec_ste (vector bool int, int, unsigned int *);
14895
14896 void vec_stvewx (vector float, int, float *);
14897 void vec_stvewx (vector signed int, int, int *);
14898 void vec_stvewx (vector unsigned int, int, unsigned int *);
14899 void vec_stvewx (vector bool int, int, int *);
14900 void vec_stvewx (vector bool int, int, unsigned int *);
14901
14902 void vec_stvehx (vector signed short, int, short *);
14903 void vec_stvehx (vector unsigned short, int, unsigned short *);
14904 void vec_stvehx (vector bool short, int, short *);
14905 void vec_stvehx (vector bool short, int, unsigned short *);
14906 void vec_stvehx (vector pixel, int, short *);
14907 void vec_stvehx (vector pixel, int, unsigned short *);
14908
14909 void vec_stvebx (vector signed char, int, signed char *);
14910 void vec_stvebx (vector unsigned char, int, unsigned char *);
14911 void vec_stvebx (vector bool char, int, signed char *);
14912 void vec_stvebx (vector bool char, int, unsigned char *);
14913
14914 void vec_stl (vector float, int, vector float *);
14915 void vec_stl (vector float, int, float *);
14916 void vec_stl (vector signed int, int, vector signed int *);
14917 void vec_stl (vector signed int, int, int *);
14918 void vec_stl (vector unsigned int, int, vector unsigned int *);
14919 void vec_stl (vector unsigned int, int, unsigned int *);
14920 void vec_stl (vector bool int, int, vector bool int *);
14921 void vec_stl (vector bool int, int, unsigned int *);
14922 void vec_stl (vector bool int, int, int *);
14923 void vec_stl (vector signed short, int, vector signed short *);
14924 void vec_stl (vector signed short, int, short *);
14925 void vec_stl (vector unsigned short, int, vector unsigned short *);
14926 void vec_stl (vector unsigned short, int, unsigned short *);
14927 void vec_stl (vector bool short, int, vector bool short *);
14928 void vec_stl (vector bool short, int, unsigned short *);
14929 void vec_stl (vector bool short, int, short *);
14930 void vec_stl (vector pixel, int, vector pixel *);
14931 void vec_stl (vector pixel, int, unsigned short *);
14932 void vec_stl (vector pixel, int, short *);
14933 void vec_stl (vector signed char, int, vector signed char *);
14934 void vec_stl (vector signed char, int, signed char *);
14935 void vec_stl (vector unsigned char, int, vector unsigned char *);
14936 void vec_stl (vector unsigned char, int, unsigned char *);
14937 void vec_stl (vector bool char, int, vector bool char *);
14938 void vec_stl (vector bool char, int, unsigned char *);
14939 void vec_stl (vector bool char, int, signed char *);
14940
14941 vector signed char vec_sub (vector bool char, vector signed char);
14942 vector signed char vec_sub (vector signed char, vector bool char);
14943 vector signed char vec_sub (vector signed char, vector signed char);
14944 vector unsigned char vec_sub (vector bool char, vector unsigned char);
14945 vector unsigned char vec_sub (vector unsigned char, vector bool char);
14946 vector unsigned char vec_sub (vector unsigned char,
14947 vector unsigned char);
14948 vector signed short vec_sub (vector bool short, vector signed short);
14949 vector signed short vec_sub (vector signed short, vector bool short);
14950 vector signed short vec_sub (vector signed short, vector signed short);
14951 vector unsigned short vec_sub (vector bool short,
14952 vector unsigned short);
14953 vector unsigned short vec_sub (vector unsigned short,
14954 vector bool short);
14955 vector unsigned short vec_sub (vector unsigned short,
14956 vector unsigned short);
14957 vector signed int vec_sub (vector bool int, vector signed int);
14958 vector signed int vec_sub (vector signed int, vector bool int);
14959 vector signed int vec_sub (vector signed int, vector signed int);
14960 vector unsigned int vec_sub (vector bool int, vector unsigned int);
14961 vector unsigned int vec_sub (vector unsigned int, vector bool int);
14962 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
14963 vector float vec_sub (vector float, vector float);
14964
14965 vector float vec_vsubfp (vector float, vector float);
14966
14967 vector signed int vec_vsubuwm (vector bool int, vector signed int);
14968 vector signed int vec_vsubuwm (vector signed int, vector bool int);
14969 vector signed int vec_vsubuwm (vector signed int, vector signed int);
14970 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
14971 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
14972 vector unsigned int vec_vsubuwm (vector unsigned int,
14973 vector unsigned int);
14974
14975 vector signed short vec_vsubuhm (vector bool short,
14976 vector signed short);
14977 vector signed short vec_vsubuhm (vector signed short,
14978 vector bool short);
14979 vector signed short vec_vsubuhm (vector signed short,
14980 vector signed short);
14981 vector unsigned short vec_vsubuhm (vector bool short,
14982 vector unsigned short);
14983 vector unsigned short vec_vsubuhm (vector unsigned short,
14984 vector bool short);
14985 vector unsigned short vec_vsubuhm (vector unsigned short,
14986 vector unsigned short);
14987
14988 vector signed char vec_vsububm (vector bool char, vector signed char);
14989 vector signed char vec_vsububm (vector signed char, vector bool char);
14990 vector signed char vec_vsububm (vector signed char, vector signed char);
14991 vector unsigned char vec_vsububm (vector bool char,
14992 vector unsigned char);
14993 vector unsigned char vec_vsububm (vector unsigned char,
14994 vector bool char);
14995 vector unsigned char vec_vsububm (vector unsigned char,
14996 vector unsigned char);
14997
14998 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
14999
15000 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15001 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15002 vector unsigned char vec_subs (vector unsigned char,
15003 vector unsigned char);
15004 vector signed char vec_subs (vector bool char, vector signed char);
15005 vector signed char vec_subs (vector signed char, vector bool char);
15006 vector signed char vec_subs (vector signed char, vector signed char);
15007 vector unsigned short vec_subs (vector bool short,
15008 vector unsigned short);
15009 vector unsigned short vec_subs (vector unsigned short,
15010 vector bool short);
15011 vector unsigned short vec_subs (vector unsigned short,
15012 vector unsigned short);
15013 vector signed short vec_subs (vector bool short, vector signed short);
15014 vector signed short vec_subs (vector signed short, vector bool short);
15015 vector signed short vec_subs (vector signed short, vector signed short);
15016 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15017 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15018 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15019 vector signed int vec_subs (vector bool int, vector signed int);
15020 vector signed int vec_subs (vector signed int, vector bool int);
15021 vector signed int vec_subs (vector signed int, vector signed int);
15022
15023 vector signed int vec_vsubsws (vector bool int, vector signed int);
15024 vector signed int vec_vsubsws (vector signed int, vector bool int);
15025 vector signed int vec_vsubsws (vector signed int, vector signed int);
15026
15027 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15028 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15029 vector unsigned int vec_vsubuws (vector unsigned int,
15030 vector unsigned int);
15031
15032 vector signed short vec_vsubshs (vector bool short,
15033 vector signed short);
15034 vector signed short vec_vsubshs (vector signed short,
15035 vector bool short);
15036 vector signed short vec_vsubshs (vector signed short,
15037 vector signed short);
15038
15039 vector unsigned short vec_vsubuhs (vector bool short,
15040 vector unsigned short);
15041 vector unsigned short vec_vsubuhs (vector unsigned short,
15042 vector bool short);
15043 vector unsigned short vec_vsubuhs (vector unsigned short,
15044 vector unsigned short);
15045
15046 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15047 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15048 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15049
15050 vector unsigned char vec_vsububs (vector bool char,
15051 vector unsigned char);
15052 vector unsigned char vec_vsububs (vector unsigned char,
15053 vector bool char);
15054 vector unsigned char vec_vsububs (vector unsigned char,
15055 vector unsigned char);
15056
15057 vector unsigned int vec_sum4s (vector unsigned char,
15058 vector unsigned int);
15059 vector signed int vec_sum4s (vector signed char, vector signed int);
15060 vector signed int vec_sum4s (vector signed short, vector signed int);
15061
15062 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15063
15064 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15065
15066 vector unsigned int vec_vsum4ubs (vector unsigned char,
15067 vector unsigned int);
15068
15069 vector signed int vec_sum2s (vector signed int, vector signed int);
15070
15071 vector signed int vec_sums (vector signed int, vector signed int);
15072
15073 vector float vec_trunc (vector float);
15074
15075 vector signed short vec_unpackh (vector signed char);
15076 vector bool short vec_unpackh (vector bool char);
15077 vector signed int vec_unpackh (vector signed short);
15078 vector bool int vec_unpackh (vector bool short);
15079 vector unsigned int vec_unpackh (vector pixel);
15080
15081 vector bool int vec_vupkhsh (vector bool short);
15082 vector signed int vec_vupkhsh (vector signed short);
15083
15084 vector unsigned int vec_vupkhpx (vector pixel);
15085
15086 vector bool short vec_vupkhsb (vector bool char);
15087 vector signed short vec_vupkhsb (vector signed char);
15088
15089 vector signed short vec_unpackl (vector signed char);
15090 vector bool short vec_unpackl (vector bool char);
15091 vector unsigned int vec_unpackl (vector pixel);
15092 vector signed int vec_unpackl (vector signed short);
15093 vector bool int vec_unpackl (vector bool short);
15094
15095 vector unsigned int vec_vupklpx (vector pixel);
15096
15097 vector bool int vec_vupklsh (vector bool short);
15098 vector signed int vec_vupklsh (vector signed short);
15099
15100 vector bool short vec_vupklsb (vector bool char);
15101 vector signed short vec_vupklsb (vector signed char);
15102
15103 vector float vec_xor (vector float, vector float);
15104 vector float vec_xor (vector float, vector bool int);
15105 vector float vec_xor (vector bool int, vector float);
15106 vector bool int vec_xor (vector bool int, vector bool int);
15107 vector signed int vec_xor (vector bool int, vector signed int);
15108 vector signed int vec_xor (vector signed int, vector bool int);
15109 vector signed int vec_xor (vector signed int, vector signed int);
15110 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15111 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15112 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15113 vector bool short vec_xor (vector bool short, vector bool short);
15114 vector signed short vec_xor (vector bool short, vector signed short);
15115 vector signed short vec_xor (vector signed short, vector bool short);
15116 vector signed short vec_xor (vector signed short, vector signed short);
15117 vector unsigned short vec_xor (vector bool short,
15118 vector unsigned short);
15119 vector unsigned short vec_xor (vector unsigned short,
15120 vector bool short);
15121 vector unsigned short vec_xor (vector unsigned short,
15122 vector unsigned short);
15123 vector signed char vec_xor (vector bool char, vector signed char);
15124 vector bool char vec_xor (vector bool char, vector bool char);
15125 vector signed char vec_xor (vector signed char, vector bool char);
15126 vector signed char vec_xor (vector signed char, vector signed char);
15127 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15128 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15129 vector unsigned char vec_xor (vector unsigned char,
15130 vector unsigned char);
15131
15132 int vec_all_eq (vector signed char, vector bool char);
15133 int vec_all_eq (vector signed char, vector signed char);
15134 int vec_all_eq (vector unsigned char, vector bool char);
15135 int vec_all_eq (vector unsigned char, vector unsigned char);
15136 int vec_all_eq (vector bool char, vector bool char);
15137 int vec_all_eq (vector bool char, vector unsigned char);
15138 int vec_all_eq (vector bool char, vector signed char);
15139 int vec_all_eq (vector signed short, vector bool short);
15140 int vec_all_eq (vector signed short, vector signed short);
15141 int vec_all_eq (vector unsigned short, vector bool short);
15142 int vec_all_eq (vector unsigned short, vector unsigned short);
15143 int vec_all_eq (vector bool short, vector bool short);
15144 int vec_all_eq (vector bool short, vector unsigned short);
15145 int vec_all_eq (vector bool short, vector signed short);
15146 int vec_all_eq (vector pixel, vector pixel);
15147 int vec_all_eq (vector signed int, vector bool int);
15148 int vec_all_eq (vector signed int, vector signed int);
15149 int vec_all_eq (vector unsigned int, vector bool int);
15150 int vec_all_eq (vector unsigned int, vector unsigned int);
15151 int vec_all_eq (vector bool int, vector bool int);
15152 int vec_all_eq (vector bool int, vector unsigned int);
15153 int vec_all_eq (vector bool int, vector signed int);
15154 int vec_all_eq (vector float, vector float);
15155
15156 int vec_all_ge (vector bool char, vector unsigned char);
15157 int vec_all_ge (vector unsigned char, vector bool char);
15158 int vec_all_ge (vector unsigned char, vector unsigned char);
15159 int vec_all_ge (vector bool char, vector signed char);
15160 int vec_all_ge (vector signed char, vector bool char);
15161 int vec_all_ge (vector signed char, vector signed char);
15162 int vec_all_ge (vector bool short, vector unsigned short);
15163 int vec_all_ge (vector unsigned short, vector bool short);
15164 int vec_all_ge (vector unsigned short, vector unsigned short);
15165 int vec_all_ge (vector signed short, vector signed short);
15166 int vec_all_ge (vector bool short, vector signed short);
15167 int vec_all_ge (vector signed short, vector bool short);
15168 int vec_all_ge (vector bool int, vector unsigned int);
15169 int vec_all_ge (vector unsigned int, vector bool int);
15170 int vec_all_ge (vector unsigned int, vector unsigned int);
15171 int vec_all_ge (vector bool int, vector signed int);
15172 int vec_all_ge (vector signed int, vector bool int);
15173 int vec_all_ge (vector signed int, vector signed int);
15174 int vec_all_ge (vector float, vector float);
15175
15176 int vec_all_gt (vector bool char, vector unsigned char);
15177 int vec_all_gt (vector unsigned char, vector bool char);
15178 int vec_all_gt (vector unsigned char, vector unsigned char);
15179 int vec_all_gt (vector bool char, vector signed char);
15180 int vec_all_gt (vector signed char, vector bool char);
15181 int vec_all_gt (vector signed char, vector signed char);
15182 int vec_all_gt (vector bool short, vector unsigned short);
15183 int vec_all_gt (vector unsigned short, vector bool short);
15184 int vec_all_gt (vector unsigned short, vector unsigned short);
15185 int vec_all_gt (vector bool short, vector signed short);
15186 int vec_all_gt (vector signed short, vector bool short);
15187 int vec_all_gt (vector signed short, vector signed short);
15188 int vec_all_gt (vector bool int, vector unsigned int);
15189 int vec_all_gt (vector unsigned int, vector bool int);
15190 int vec_all_gt (vector unsigned int, vector unsigned int);
15191 int vec_all_gt (vector bool int, vector signed int);
15192 int vec_all_gt (vector signed int, vector bool int);
15193 int vec_all_gt (vector signed int, vector signed int);
15194 int vec_all_gt (vector float, vector float);
15195
15196 int vec_all_in (vector float, vector float);
15197
15198 int vec_all_le (vector bool char, vector unsigned char);
15199 int vec_all_le (vector unsigned char, vector bool char);
15200 int vec_all_le (vector unsigned char, vector unsigned char);
15201 int vec_all_le (vector bool char, vector signed char);
15202 int vec_all_le (vector signed char, vector bool char);
15203 int vec_all_le (vector signed char, vector signed char);
15204 int vec_all_le (vector bool short, vector unsigned short);
15205 int vec_all_le (vector unsigned short, vector bool short);
15206 int vec_all_le (vector unsigned short, vector unsigned short);
15207 int vec_all_le (vector bool short, vector signed short);
15208 int vec_all_le (vector signed short, vector bool short);
15209 int vec_all_le (vector signed short, vector signed short);
15210 int vec_all_le (vector bool int, vector unsigned int);
15211 int vec_all_le (vector unsigned int, vector bool int);
15212 int vec_all_le (vector unsigned int, vector unsigned int);
15213 int vec_all_le (vector bool int, vector signed int);
15214 int vec_all_le (vector signed int, vector bool int);
15215 int vec_all_le (vector signed int, vector signed int);
15216 int vec_all_le (vector float, vector float);
15217
15218 int vec_all_lt (vector bool char, vector unsigned char);
15219 int vec_all_lt (vector unsigned char, vector bool char);
15220 int vec_all_lt (vector unsigned char, vector unsigned char);
15221 int vec_all_lt (vector bool char, vector signed char);
15222 int vec_all_lt (vector signed char, vector bool char);
15223 int vec_all_lt (vector signed char, vector signed char);
15224 int vec_all_lt (vector bool short, vector unsigned short);
15225 int vec_all_lt (vector unsigned short, vector bool short);
15226 int vec_all_lt (vector unsigned short, vector unsigned short);
15227 int vec_all_lt (vector bool short, vector signed short);
15228 int vec_all_lt (vector signed short, vector bool short);
15229 int vec_all_lt (vector signed short, vector signed short);
15230 int vec_all_lt (vector bool int, vector unsigned int);
15231 int vec_all_lt (vector unsigned int, vector bool int);
15232 int vec_all_lt (vector unsigned int, vector unsigned int);
15233 int vec_all_lt (vector bool int, vector signed int);
15234 int vec_all_lt (vector signed int, vector bool int);
15235 int vec_all_lt (vector signed int, vector signed int);
15236 int vec_all_lt (vector float, vector float);
15237
15238 int vec_all_nan (vector float);
15239
15240 int vec_all_ne (vector signed char, vector bool char);
15241 int vec_all_ne (vector signed char, vector signed char);
15242 int vec_all_ne (vector unsigned char, vector bool char);
15243 int vec_all_ne (vector unsigned char, vector unsigned char);
15244 int vec_all_ne (vector bool char, vector bool char);
15245 int vec_all_ne (vector bool char, vector unsigned char);
15246 int vec_all_ne (vector bool char, vector signed char);
15247 int vec_all_ne (vector signed short, vector bool short);
15248 int vec_all_ne (vector signed short, vector signed short);
15249 int vec_all_ne (vector unsigned short, vector bool short);
15250 int vec_all_ne (vector unsigned short, vector unsigned short);
15251 int vec_all_ne (vector bool short, vector bool short);
15252 int vec_all_ne (vector bool short, vector unsigned short);
15253 int vec_all_ne (vector bool short, vector signed short);
15254 int vec_all_ne (vector pixel, vector pixel);
15255 int vec_all_ne (vector signed int, vector bool int);
15256 int vec_all_ne (vector signed int, vector signed int);
15257 int vec_all_ne (vector unsigned int, vector bool int);
15258 int vec_all_ne (vector unsigned int, vector unsigned int);
15259 int vec_all_ne (vector bool int, vector bool int);
15260 int vec_all_ne (vector bool int, vector unsigned int);
15261 int vec_all_ne (vector bool int, vector signed int);
15262 int vec_all_ne (vector float, vector float);
15263
15264 int vec_all_nge (vector float, vector float);
15265
15266 int vec_all_ngt (vector float, vector float);
15267
15268 int vec_all_nle (vector float, vector float);
15269
15270 int vec_all_nlt (vector float, vector float);
15271
15272 int vec_all_numeric (vector float);
15273
15274 int vec_any_eq (vector signed char, vector bool char);
15275 int vec_any_eq (vector signed char, vector signed char);
15276 int vec_any_eq (vector unsigned char, vector bool char);
15277 int vec_any_eq (vector unsigned char, vector unsigned char);
15278 int vec_any_eq (vector bool char, vector bool char);
15279 int vec_any_eq (vector bool char, vector unsigned char);
15280 int vec_any_eq (vector bool char, vector signed char);
15281 int vec_any_eq (vector signed short, vector bool short);
15282 int vec_any_eq (vector signed short, vector signed short);
15283 int vec_any_eq (vector unsigned short, vector bool short);
15284 int vec_any_eq (vector unsigned short, vector unsigned short);
15285 int vec_any_eq (vector bool short, vector bool short);
15286 int vec_any_eq (vector bool short, vector unsigned short);
15287 int vec_any_eq (vector bool short, vector signed short);
15288 int vec_any_eq (vector pixel, vector pixel);
15289 int vec_any_eq (vector signed int, vector bool int);
15290 int vec_any_eq (vector signed int, vector signed int);
15291 int vec_any_eq (vector unsigned int, vector bool int);
15292 int vec_any_eq (vector unsigned int, vector unsigned int);
15293 int vec_any_eq (vector bool int, vector bool int);
15294 int vec_any_eq (vector bool int, vector unsigned int);
15295 int vec_any_eq (vector bool int, vector signed int);
15296 int vec_any_eq (vector float, vector float);
15297
15298 int vec_any_ge (vector signed char, vector bool char);
15299 int vec_any_ge (vector unsigned char, vector bool char);
15300 int vec_any_ge (vector unsigned char, vector unsigned char);
15301 int vec_any_ge (vector signed char, vector signed char);
15302 int vec_any_ge (vector bool char, vector unsigned char);
15303 int vec_any_ge (vector bool char, vector signed char);
15304 int vec_any_ge (vector unsigned short, vector bool short);
15305 int vec_any_ge (vector unsigned short, vector unsigned short);
15306 int vec_any_ge (vector signed short, vector signed short);
15307 int vec_any_ge (vector signed short, vector bool short);
15308 int vec_any_ge (vector bool short, vector unsigned short);
15309 int vec_any_ge (vector bool short, vector signed short);
15310 int vec_any_ge (vector signed int, vector bool int);
15311 int vec_any_ge (vector unsigned int, vector bool int);
15312 int vec_any_ge (vector unsigned int, vector unsigned int);
15313 int vec_any_ge (vector signed int, vector signed int);
15314 int vec_any_ge (vector bool int, vector unsigned int);
15315 int vec_any_ge (vector bool int, vector signed int);
15316 int vec_any_ge (vector float, vector float);
15317
15318 int vec_any_gt (vector bool char, vector unsigned char);
15319 int vec_any_gt (vector unsigned char, vector bool char);
15320 int vec_any_gt (vector unsigned char, vector unsigned char);
15321 int vec_any_gt (vector bool char, vector signed char);
15322 int vec_any_gt (vector signed char, vector bool char);
15323 int vec_any_gt (vector signed char, vector signed char);
15324 int vec_any_gt (vector bool short, vector unsigned short);
15325 int vec_any_gt (vector unsigned short, vector bool short);
15326 int vec_any_gt (vector unsigned short, vector unsigned short);
15327 int vec_any_gt (vector bool short, vector signed short);
15328 int vec_any_gt (vector signed short, vector bool short);
15329 int vec_any_gt (vector signed short, vector signed short);
15330 int vec_any_gt (vector bool int, vector unsigned int);
15331 int vec_any_gt (vector unsigned int, vector bool int);
15332 int vec_any_gt (vector unsigned int, vector unsigned int);
15333 int vec_any_gt (vector bool int, vector signed int);
15334 int vec_any_gt (vector signed int, vector bool int);
15335 int vec_any_gt (vector signed int, vector signed int);
15336 int vec_any_gt (vector float, vector float);
15337
15338 int vec_any_le (vector bool char, vector unsigned char);
15339 int vec_any_le (vector unsigned char, vector bool char);
15340 int vec_any_le (vector unsigned char, vector unsigned char);
15341 int vec_any_le (vector bool char, vector signed char);
15342 int vec_any_le (vector signed char, vector bool char);
15343 int vec_any_le (vector signed char, vector signed char);
15344 int vec_any_le (vector bool short, vector unsigned short);
15345 int vec_any_le (vector unsigned short, vector bool short);
15346 int vec_any_le (vector unsigned short, vector unsigned short);
15347 int vec_any_le (vector bool short, vector signed short);
15348 int vec_any_le (vector signed short, vector bool short);
15349 int vec_any_le (vector signed short, vector signed short);
15350 int vec_any_le (vector bool int, vector unsigned int);
15351 int vec_any_le (vector unsigned int, vector bool int);
15352 int vec_any_le (vector unsigned int, vector unsigned int);
15353 int vec_any_le (vector bool int, vector signed int);
15354 int vec_any_le (vector signed int, vector bool int);
15355 int vec_any_le (vector signed int, vector signed int);
15356 int vec_any_le (vector float, vector float);
15357
15358 int vec_any_lt (vector bool char, vector unsigned char);
15359 int vec_any_lt (vector unsigned char, vector bool char);
15360 int vec_any_lt (vector unsigned char, vector unsigned char);
15361 int vec_any_lt (vector bool char, vector signed char);
15362 int vec_any_lt (vector signed char, vector bool char);
15363 int vec_any_lt (vector signed char, vector signed char);
15364 int vec_any_lt (vector bool short, vector unsigned short);
15365 int vec_any_lt (vector unsigned short, vector bool short);
15366 int vec_any_lt (vector unsigned short, vector unsigned short);
15367 int vec_any_lt (vector bool short, vector signed short);
15368 int vec_any_lt (vector signed short, vector bool short);
15369 int vec_any_lt (vector signed short, vector signed short);
15370 int vec_any_lt (vector bool int, vector unsigned int);
15371 int vec_any_lt (vector unsigned int, vector bool int);
15372 int vec_any_lt (vector unsigned int, vector unsigned int);
15373 int vec_any_lt (vector bool int, vector signed int);
15374 int vec_any_lt (vector signed int, vector bool int);
15375 int vec_any_lt (vector signed int, vector signed int);
15376 int vec_any_lt (vector float, vector float);
15377
15378 int vec_any_nan (vector float);
15379
15380 int vec_any_ne (vector signed char, vector bool char);
15381 int vec_any_ne (vector signed char, vector signed char);
15382 int vec_any_ne (vector unsigned char, vector bool char);
15383 int vec_any_ne (vector unsigned char, vector unsigned char);
15384 int vec_any_ne (vector bool char, vector bool char);
15385 int vec_any_ne (vector bool char, vector unsigned char);
15386 int vec_any_ne (vector bool char, vector signed char);
15387 int vec_any_ne (vector signed short, vector bool short);
15388 int vec_any_ne (vector signed short, vector signed short);
15389 int vec_any_ne (vector unsigned short, vector bool short);
15390 int vec_any_ne (vector unsigned short, vector unsigned short);
15391 int vec_any_ne (vector bool short, vector bool short);
15392 int vec_any_ne (vector bool short, vector unsigned short);
15393 int vec_any_ne (vector bool short, vector signed short);
15394 int vec_any_ne (vector pixel, vector pixel);
15395 int vec_any_ne (vector signed int, vector bool int);
15396 int vec_any_ne (vector signed int, vector signed int);
15397 int vec_any_ne (vector unsigned int, vector bool int);
15398 int vec_any_ne (vector unsigned int, vector unsigned int);
15399 int vec_any_ne (vector bool int, vector bool int);
15400 int vec_any_ne (vector bool int, vector unsigned int);
15401 int vec_any_ne (vector bool int, vector signed int);
15402 int vec_any_ne (vector float, vector float);
15403
15404 int vec_any_nge (vector float, vector float);
15405
15406 int vec_any_ngt (vector float, vector float);
15407
15408 int vec_any_nle (vector float, vector float);
15409
15410 int vec_any_nlt (vector float, vector float);
15411
15412 int vec_any_numeric (vector float);
15413
15414 int vec_any_out (vector float, vector float);
15415 @end smallexample
15416
15417 If the vector/scalar (VSX) instruction set is available, the following
15418 additional functions are available:
15419
15420 @smallexample
15421 vector double vec_abs (vector double);
15422 vector double vec_add (vector double, vector double);
15423 vector double vec_and (vector double, vector double);
15424 vector double vec_and (vector double, vector bool long);
15425 vector double vec_and (vector bool long, vector double);
15426 vector long vec_and (vector long, vector long);
15427 vector long vec_and (vector long, vector bool long);
15428 vector long vec_and (vector bool long, vector long);
15429 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15430 vector unsigned long vec_and (vector unsigned long, vector bool long);
15431 vector unsigned long vec_and (vector bool long, vector unsigned long);
15432 vector double vec_andc (vector double, vector double);
15433 vector double vec_andc (vector double, vector bool long);
15434 vector double vec_andc (vector bool long, vector double);
15435 vector long vec_andc (vector long, vector long);
15436 vector long vec_andc (vector long, vector bool long);
15437 vector long vec_andc (vector bool long, vector long);
15438 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15439 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15440 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15441 vector double vec_ceil (vector double);
15442 vector bool long vec_cmpeq (vector double, vector double);
15443 vector bool long vec_cmpge (vector double, vector double);
15444 vector bool long vec_cmpgt (vector double, vector double);
15445 vector bool long vec_cmple (vector double, vector double);
15446 vector bool long vec_cmplt (vector double, vector double);
15447 vector double vec_cpsgn (vector double, vector double);
15448 vector float vec_div (vector float, vector float);
15449 vector double vec_div (vector double, vector double);
15450 vector long vec_div (vector long, vector long);
15451 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15452 vector double vec_floor (vector double);
15453 vector double vec_ld (int, const vector double *);
15454 vector double vec_ld (int, const double *);
15455 vector double vec_ldl (int, const vector double *);
15456 vector double vec_ldl (int, const double *);
15457 vector unsigned char vec_lvsl (int, const volatile double *);
15458 vector unsigned char vec_lvsr (int, const volatile double *);
15459 vector double vec_madd (vector double, vector double, vector double);
15460 vector double vec_max (vector double, vector double);
15461 vector signed long vec_mergeh (vector signed long, vector signed long);
15462 vector signed long vec_mergeh (vector signed long, vector bool long);
15463 vector signed long vec_mergeh (vector bool long, vector signed long);
15464 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15465 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15466 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15467 vector signed long vec_mergel (vector signed long, vector signed long);
15468 vector signed long vec_mergel (vector signed long, vector bool long);
15469 vector signed long vec_mergel (vector bool long, vector signed long);
15470 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15471 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15472 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15473 vector double vec_min (vector double, vector double);
15474 vector float vec_msub (vector float, vector float, vector float);
15475 vector double vec_msub (vector double, vector double, vector double);
15476 vector float vec_mul (vector float, vector float);
15477 vector double vec_mul (vector double, vector double);
15478 vector long vec_mul (vector long, vector long);
15479 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15480 vector float vec_nearbyint (vector float);
15481 vector double vec_nearbyint (vector double);
15482 vector float vec_nmadd (vector float, vector float, vector float);
15483 vector double vec_nmadd (vector double, vector double, vector double);
15484 vector double vec_nmsub (vector double, vector double, vector double);
15485 vector double vec_nor (vector double, vector double);
15486 vector long vec_nor (vector long, vector long);
15487 vector long vec_nor (vector long, vector bool long);
15488 vector long vec_nor (vector bool long, vector long);
15489 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15490 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15491 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15492 vector double vec_or (vector double, vector double);
15493 vector double vec_or (vector double, vector bool long);
15494 vector double vec_or (vector bool long, vector double);
15495 vector long vec_or (vector long, vector long);
15496 vector long vec_or (vector long, vector bool long);
15497 vector long vec_or (vector bool long, vector long);
15498 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15499 vector unsigned long vec_or (vector unsigned long, vector bool long);
15500 vector unsigned long vec_or (vector bool long, vector unsigned long);
15501 vector double vec_perm (vector double, vector double, vector unsigned char);
15502 vector long vec_perm (vector long, vector long, vector unsigned char);
15503 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15504 vector unsigned char);
15505 vector double vec_rint (vector double);
15506 vector double vec_recip (vector double, vector double);
15507 vector double vec_rsqrt (vector double);
15508 vector double vec_rsqrte (vector double);
15509 vector double vec_sel (vector double, vector double, vector bool long);
15510 vector double vec_sel (vector double, vector double, vector unsigned long);
15511 vector long vec_sel (vector long, vector long, vector long);
15512 vector long vec_sel (vector long, vector long, vector unsigned long);
15513 vector long vec_sel (vector long, vector long, vector bool long);
15514 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15515 vector long);
15516 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15517 vector unsigned long);
15518 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15519 vector bool long);
15520 vector double vec_splats (double);
15521 vector signed long vec_splats (signed long);
15522 vector unsigned long vec_splats (unsigned long);
15523 vector float vec_sqrt (vector float);
15524 vector double vec_sqrt (vector double);
15525 void vec_st (vector double, int, vector double *);
15526 void vec_st (vector double, int, double *);
15527 vector double vec_sub (vector double, vector double);
15528 vector double vec_trunc (vector double);
15529 vector double vec_xor (vector double, vector double);
15530 vector double vec_xor (vector double, vector bool long);
15531 vector double vec_xor (vector bool long, vector double);
15532 vector long vec_xor (vector long, vector long);
15533 vector long vec_xor (vector long, vector bool long);
15534 vector long vec_xor (vector bool long, vector long);
15535 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15536 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15537 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15538 int vec_all_eq (vector double, vector double);
15539 int vec_all_ge (vector double, vector double);
15540 int vec_all_gt (vector double, vector double);
15541 int vec_all_le (vector double, vector double);
15542 int vec_all_lt (vector double, vector double);
15543 int vec_all_nan (vector double);
15544 int vec_all_ne (vector double, vector double);
15545 int vec_all_nge (vector double, vector double);
15546 int vec_all_ngt (vector double, vector double);
15547 int vec_all_nle (vector double, vector double);
15548 int vec_all_nlt (vector double, vector double);
15549 int vec_all_numeric (vector double);
15550 int vec_any_eq (vector double, vector double);
15551 int vec_any_ge (vector double, vector double);
15552 int vec_any_gt (vector double, vector double);
15553 int vec_any_le (vector double, vector double);
15554 int vec_any_lt (vector double, vector double);
15555 int vec_any_nan (vector double);
15556 int vec_any_ne (vector double, vector double);
15557 int vec_any_nge (vector double, vector double);
15558 int vec_any_ngt (vector double, vector double);
15559 int vec_any_nle (vector double, vector double);
15560 int vec_any_nlt (vector double, vector double);
15561 int vec_any_numeric (vector double);
15562
15563 vector double vec_vsx_ld (int, const vector double *);
15564 vector double vec_vsx_ld (int, const double *);
15565 vector float vec_vsx_ld (int, const vector float *);
15566 vector float vec_vsx_ld (int, const float *);
15567 vector bool int vec_vsx_ld (int, const vector bool int *);
15568 vector signed int vec_vsx_ld (int, const vector signed int *);
15569 vector signed int vec_vsx_ld (int, const int *);
15570 vector signed int vec_vsx_ld (int, const long *);
15571 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15572 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15573 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15574 vector bool short vec_vsx_ld (int, const vector bool short *);
15575 vector pixel vec_vsx_ld (int, const vector pixel *);
15576 vector signed short vec_vsx_ld (int, const vector signed short *);
15577 vector signed short vec_vsx_ld (int, const short *);
15578 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15579 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15580 vector bool char vec_vsx_ld (int, const vector bool char *);
15581 vector signed char vec_vsx_ld (int, const vector signed char *);
15582 vector signed char vec_vsx_ld (int, const signed char *);
15583 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15584 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15585
15586 void vec_vsx_st (vector double, int, vector double *);
15587 void vec_vsx_st (vector double, int, double *);
15588 void vec_vsx_st (vector float, int, vector float *);
15589 void vec_vsx_st (vector float, int, float *);
15590 void vec_vsx_st (vector signed int, int, vector signed int *);
15591 void vec_vsx_st (vector signed int, int, int *);
15592 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15593 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15594 void vec_vsx_st (vector bool int, int, vector bool int *);
15595 void vec_vsx_st (vector bool int, int, unsigned int *);
15596 void vec_vsx_st (vector bool int, int, int *);
15597 void vec_vsx_st (vector signed short, int, vector signed short *);
15598 void vec_vsx_st (vector signed short, int, short *);
15599 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15600 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15601 void vec_vsx_st (vector bool short, int, vector bool short *);
15602 void vec_vsx_st (vector bool short, int, unsigned short *);
15603 void vec_vsx_st (vector pixel, int, vector pixel *);
15604 void vec_vsx_st (vector pixel, int, unsigned short *);
15605 void vec_vsx_st (vector pixel, int, short *);
15606 void vec_vsx_st (vector bool short, int, short *);
15607 void vec_vsx_st (vector signed char, int, vector signed char *);
15608 void vec_vsx_st (vector signed char, int, signed char *);
15609 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15610 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15611 void vec_vsx_st (vector bool char, int, vector bool char *);
15612 void vec_vsx_st (vector bool char, int, unsigned char *);
15613 void vec_vsx_st (vector bool char, int, signed char *);
15614
15615 vector double vec_xxpermdi (vector double, vector double, int);
15616 vector float vec_xxpermdi (vector float, vector float, int);
15617 vector long long vec_xxpermdi (vector long long, vector long long, int);
15618 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15619 vector unsigned long long, int);
15620 vector int vec_xxpermdi (vector int, vector int, int);
15621 vector unsigned int vec_xxpermdi (vector unsigned int,
15622 vector unsigned int, int);
15623 vector short vec_xxpermdi (vector short, vector short, int);
15624 vector unsigned short vec_xxpermdi (vector unsigned short,
15625 vector unsigned short, int);
15626 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15627 vector unsigned char vec_xxpermdi (vector unsigned char,
15628 vector unsigned char, int);
15629
15630 vector double vec_xxsldi (vector double, vector double, int);
15631 vector float vec_xxsldi (vector float, vector float, int);
15632 vector long long vec_xxsldi (vector long long, vector long long, int);
15633 vector unsigned long long vec_xxsldi (vector unsigned long long,
15634 vector unsigned long long, int);
15635 vector int vec_xxsldi (vector int, vector int, int);
15636 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15637 vector short vec_xxsldi (vector short, vector short, int);
15638 vector unsigned short vec_xxsldi (vector unsigned short,
15639 vector unsigned short, int);
15640 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15641 vector unsigned char vec_xxsldi (vector unsigned char,
15642 vector unsigned char, int);
15643 @end smallexample
15644
15645 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15646 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15647 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
15648 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15649 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15650
15651 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15652 instruction set is available, the following additional functions are
15653 available for both 32-bit and 64-bit targets. For 64-bit targets, you
15654 can use @var{vector long} instead of @var{vector long long},
15655 @var{vector bool long} instead of @var{vector bool long long}, and
15656 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15657
15658 @smallexample
15659 vector long long vec_abs (vector long long);
15660
15661 vector long long vec_add (vector long long, vector long long);
15662 vector unsigned long long vec_add (vector unsigned long long,
15663 vector unsigned long long);
15664
15665 int vec_all_eq (vector long long, vector long long);
15666 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15667 int vec_all_ge (vector long long, vector long long);
15668 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15669 int vec_all_gt (vector long long, vector long long);
15670 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15671 int vec_all_le (vector long long, vector long long);
15672 int vec_all_le (vector unsigned long long, vector unsigned long long);
15673 int vec_all_lt (vector long long, vector long long);
15674 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15675 int vec_all_ne (vector long long, vector long long);
15676 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15677
15678 int vec_any_eq (vector long long, vector long long);
15679 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15680 int vec_any_ge (vector long long, vector long long);
15681 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15682 int vec_any_gt (vector long long, vector long long);
15683 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15684 int vec_any_le (vector long long, vector long long);
15685 int vec_any_le (vector unsigned long long, vector unsigned long long);
15686 int vec_any_lt (vector long long, vector long long);
15687 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15688 int vec_any_ne (vector long long, vector long long);
15689 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15690
15691 vector long long vec_eqv (vector long long, vector long long);
15692 vector long long vec_eqv (vector bool long long, vector long long);
15693 vector long long vec_eqv (vector long long, vector bool long long);
15694 vector unsigned long long vec_eqv (vector unsigned long long,
15695 vector unsigned long long);
15696 vector unsigned long long vec_eqv (vector bool long long,
15697 vector unsigned long long);
15698 vector unsigned long long vec_eqv (vector unsigned long long,
15699 vector bool long long);
15700 vector int vec_eqv (vector int, vector int);
15701 vector int vec_eqv (vector bool int, vector int);
15702 vector int vec_eqv (vector int, vector bool int);
15703 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15704 vector unsigned int vec_eqv (vector bool unsigned int,
15705 vector unsigned int);
15706 vector unsigned int vec_eqv (vector unsigned int,
15707 vector bool unsigned int);
15708 vector short vec_eqv (vector short, vector short);
15709 vector short vec_eqv (vector bool short, vector short);
15710 vector short vec_eqv (vector short, vector bool short);
15711 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15712 vector unsigned short vec_eqv (vector bool unsigned short,
15713 vector unsigned short);
15714 vector unsigned short vec_eqv (vector unsigned short,
15715 vector bool unsigned short);
15716 vector signed char vec_eqv (vector signed char, vector signed char);
15717 vector signed char vec_eqv (vector bool signed char, vector signed char);
15718 vector signed char vec_eqv (vector signed char, vector bool signed char);
15719 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15720 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15721 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15722
15723 vector long long vec_max (vector long long, vector long long);
15724 vector unsigned long long vec_max (vector unsigned long long,
15725 vector unsigned long long);
15726
15727 vector signed int vec_mergee (vector signed int, vector signed int);
15728 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15729 vector bool int vec_mergee (vector bool int, vector bool int);
15730
15731 vector signed int vec_mergeo (vector signed int, vector signed int);
15732 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15733 vector bool int vec_mergeo (vector bool int, vector bool int);
15734
15735 vector long long vec_min (vector long long, vector long long);
15736 vector unsigned long long vec_min (vector unsigned long long,
15737 vector unsigned long long);
15738
15739 vector long long vec_nand (vector long long, vector long long);
15740 vector long long vec_nand (vector bool long long, vector long long);
15741 vector long long vec_nand (vector long long, vector bool long long);
15742 vector unsigned long long vec_nand (vector unsigned long long,
15743 vector unsigned long long);
15744 vector unsigned long long vec_nand (vector bool long long,
15745 vector unsigned long long);
15746 vector unsigned long long vec_nand (vector unsigned long long,
15747 vector bool long long);
15748 vector int vec_nand (vector int, vector int);
15749 vector int vec_nand (vector bool int, vector int);
15750 vector int vec_nand (vector int, vector bool int);
15751 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15752 vector unsigned int vec_nand (vector bool unsigned int,
15753 vector unsigned int);
15754 vector unsigned int vec_nand (vector unsigned int,
15755 vector bool unsigned int);
15756 vector short vec_nand (vector short, vector short);
15757 vector short vec_nand (vector bool short, vector short);
15758 vector short vec_nand (vector short, vector bool short);
15759 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15760 vector unsigned short vec_nand (vector bool unsigned short,
15761 vector unsigned short);
15762 vector unsigned short vec_nand (vector unsigned short,
15763 vector bool unsigned short);
15764 vector signed char vec_nand (vector signed char, vector signed char);
15765 vector signed char vec_nand (vector bool signed char, vector signed char);
15766 vector signed char vec_nand (vector signed char, vector bool signed char);
15767 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15768 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15769 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15770
15771 vector long long vec_orc (vector long long, vector long long);
15772 vector long long vec_orc (vector bool long long, vector long long);
15773 vector long long vec_orc (vector long long, vector bool long long);
15774 vector unsigned long long vec_orc (vector unsigned long long,
15775 vector unsigned long long);
15776 vector unsigned long long vec_orc (vector bool long long,
15777 vector unsigned long long);
15778 vector unsigned long long vec_orc (vector unsigned long long,
15779 vector bool long long);
15780 vector int vec_orc (vector int, vector int);
15781 vector int vec_orc (vector bool int, vector int);
15782 vector int vec_orc (vector int, vector bool int);
15783 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15784 vector unsigned int vec_orc (vector bool unsigned int,
15785 vector unsigned int);
15786 vector unsigned int vec_orc (vector unsigned int,
15787 vector bool unsigned int);
15788 vector short vec_orc (vector short, vector short);
15789 vector short vec_orc (vector bool short, vector short);
15790 vector short vec_orc (vector short, vector bool short);
15791 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15792 vector unsigned short vec_orc (vector bool unsigned short,
15793 vector unsigned short);
15794 vector unsigned short vec_orc (vector unsigned short,
15795 vector bool unsigned short);
15796 vector signed char vec_orc (vector signed char, vector signed char);
15797 vector signed char vec_orc (vector bool signed char, vector signed char);
15798 vector signed char vec_orc (vector signed char, vector bool signed char);
15799 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15800 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15801 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15802
15803 vector int vec_pack (vector long long, vector long long);
15804 vector unsigned int vec_pack (vector unsigned long long,
15805 vector unsigned long long);
15806 vector bool int vec_pack (vector bool long long, vector bool long long);
15807
15808 vector int vec_packs (vector long long, vector long long);
15809 vector unsigned int vec_packs (vector unsigned long long,
15810 vector unsigned long long);
15811
15812 vector unsigned int vec_packsu (vector long long, vector long long);
15813 vector unsigned int vec_packsu (vector unsigned long long,
15814 vector unsigned long long);
15815
15816 vector long long vec_rl (vector long long,
15817 vector unsigned long long);
15818 vector long long vec_rl (vector unsigned long long,
15819 vector unsigned long long);
15820
15821 vector long long vec_sl (vector long long, vector unsigned long long);
15822 vector long long vec_sl (vector unsigned long long,
15823 vector unsigned long long);
15824
15825 vector long long vec_sr (vector long long, vector unsigned long long);
15826 vector unsigned long long char vec_sr (vector unsigned long long,
15827 vector unsigned long long);
15828
15829 vector long long vec_sra (vector long long, vector unsigned long long);
15830 vector unsigned long long vec_sra (vector unsigned long long,
15831 vector unsigned long long);
15832
15833 vector long long vec_sub (vector long long, vector long long);
15834 vector unsigned long long vec_sub (vector unsigned long long,
15835 vector unsigned long long);
15836
15837 vector long long vec_unpackh (vector int);
15838 vector unsigned long long vec_unpackh (vector unsigned int);
15839
15840 vector long long vec_unpackl (vector int);
15841 vector unsigned long long vec_unpackl (vector unsigned int);
15842
15843 vector long long vec_vaddudm (vector long long, vector long long);
15844 vector long long vec_vaddudm (vector bool long long, vector long long);
15845 vector long long vec_vaddudm (vector long long, vector bool long long);
15846 vector unsigned long long vec_vaddudm (vector unsigned long long,
15847 vector unsigned long long);
15848 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15849 vector unsigned long long);
15850 vector unsigned long long vec_vaddudm (vector unsigned long long,
15851 vector bool unsigned long long);
15852
15853 vector long long vec_vbpermq (vector signed char, vector signed char);
15854 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15855
15856 vector long long vec_cntlz (vector long long);
15857 vector unsigned long long vec_cntlz (vector unsigned long long);
15858 vector int vec_cntlz (vector int);
15859 vector unsigned int vec_cntlz (vector int);
15860 vector short vec_cntlz (vector short);
15861 vector unsigned short vec_cntlz (vector unsigned short);
15862 vector signed char vec_cntlz (vector signed char);
15863 vector unsigned char vec_cntlz (vector unsigned char);
15864
15865 vector long long vec_vclz (vector long long);
15866 vector unsigned long long vec_vclz (vector unsigned long long);
15867 vector int vec_vclz (vector int);
15868 vector unsigned int vec_vclz (vector int);
15869 vector short vec_vclz (vector short);
15870 vector unsigned short vec_vclz (vector unsigned short);
15871 vector signed char vec_vclz (vector signed char);
15872 vector unsigned char vec_vclz (vector unsigned char);
15873
15874 vector signed char vec_vclzb (vector signed char);
15875 vector unsigned char vec_vclzb (vector unsigned char);
15876
15877 vector long long vec_vclzd (vector long long);
15878 vector unsigned long long vec_vclzd (vector unsigned long long);
15879
15880 vector short vec_vclzh (vector short);
15881 vector unsigned short vec_vclzh (vector unsigned short);
15882
15883 vector int vec_vclzw (vector int);
15884 vector unsigned int vec_vclzw (vector int);
15885
15886 vector signed char vec_vgbbd (vector signed char);
15887 vector unsigned char vec_vgbbd (vector unsigned char);
15888
15889 vector long long vec_vmaxsd (vector long long, vector long long);
15890
15891 vector unsigned long long vec_vmaxud (vector unsigned long long,
15892 unsigned vector long long);
15893
15894 vector long long vec_vminsd (vector long long, vector long long);
15895
15896 vector unsigned long long vec_vminud (vector long long,
15897 vector long long);
15898
15899 vector int vec_vpksdss (vector long long, vector long long);
15900 vector unsigned int vec_vpksdss (vector long long, vector long long);
15901
15902 vector unsigned int vec_vpkudus (vector unsigned long long,
15903 vector unsigned long long);
15904
15905 vector int vec_vpkudum (vector long long, vector long long);
15906 vector unsigned int vec_vpkudum (vector unsigned long long,
15907 vector unsigned long long);
15908 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
15909
15910 vector long long vec_vpopcnt (vector long long);
15911 vector unsigned long long vec_vpopcnt (vector unsigned long long);
15912 vector int vec_vpopcnt (vector int);
15913 vector unsigned int vec_vpopcnt (vector int);
15914 vector short vec_vpopcnt (vector short);
15915 vector unsigned short vec_vpopcnt (vector unsigned short);
15916 vector signed char vec_vpopcnt (vector signed char);
15917 vector unsigned char vec_vpopcnt (vector unsigned char);
15918
15919 vector signed char vec_vpopcntb (vector signed char);
15920 vector unsigned char vec_vpopcntb (vector unsigned char);
15921
15922 vector long long vec_vpopcntd (vector long long);
15923 vector unsigned long long vec_vpopcntd (vector unsigned long long);
15924
15925 vector short vec_vpopcnth (vector short);
15926 vector unsigned short vec_vpopcnth (vector unsigned short);
15927
15928 vector int vec_vpopcntw (vector int);
15929 vector unsigned int vec_vpopcntw (vector int);
15930
15931 vector long long vec_vrld (vector long long, vector unsigned long long);
15932 vector unsigned long long vec_vrld (vector unsigned long long,
15933 vector unsigned long long);
15934
15935 vector long long vec_vsld (vector long long, vector unsigned long long);
15936 vector long long vec_vsld (vector unsigned long long,
15937 vector unsigned long long);
15938
15939 vector long long vec_vsrad (vector long long, vector unsigned long long);
15940 vector unsigned long long vec_vsrad (vector unsigned long long,
15941 vector unsigned long long);
15942
15943 vector long long vec_vsrd (vector long long, vector unsigned long long);
15944 vector unsigned long long char vec_vsrd (vector unsigned long long,
15945 vector unsigned long long);
15946
15947 vector long long vec_vsubudm (vector long long, vector long long);
15948 vector long long vec_vsubudm (vector bool long long, vector long long);
15949 vector long long vec_vsubudm (vector long long, vector bool long long);
15950 vector unsigned long long vec_vsubudm (vector unsigned long long,
15951 vector unsigned long long);
15952 vector unsigned long long vec_vsubudm (vector bool long long,
15953 vector unsigned long long);
15954 vector unsigned long long vec_vsubudm (vector unsigned long long,
15955 vector bool long long);
15956
15957 vector long long vec_vupkhsw (vector int);
15958 vector unsigned long long vec_vupkhsw (vector unsigned int);
15959
15960 vector long long vec_vupklsw (vector int);
15961 vector unsigned long long vec_vupklsw (vector int);
15962 @end smallexample
15963
15964 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15965 instruction set is available, the following additional functions are
15966 available for 64-bit targets. New vector types
15967 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
15968 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
15969 builtins.
15970
15971 The normal vector extract, and set operations work on
15972 @var{vector __int128_t} and @var{vector __uint128_t} types,
15973 but the index value must be 0.
15974
15975 @smallexample
15976 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
15977 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
15978
15979 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
15980 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
15981
15982 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
15983 vector __int128_t);
15984 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
15985 vector __uint128_t);
15986
15987 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
15988 vector __int128_t);
15989 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
15990 vector __uint128_t);
15991
15992 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
15993 vector __int128_t);
15994 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
15995 vector __uint128_t);
15996
15997 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
15998 vector __int128_t);
15999 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16000 vector __uint128_t);
16001
16002 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16003 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16004
16005 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16006 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16007
16008 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16009 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16010 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16011 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16012 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16013 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16014 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16015 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16016 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16017 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16018 @end smallexample
16019
16020 If the cryptographic instructions are enabled (@option{-mcrypto} or
16021 @option{-mcpu=power8}), the following builtins are enabled.
16022
16023 @smallexample
16024 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16025
16026 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16027 vector unsigned long long);
16028
16029 vector unsigned long long __builtin_crypto_vcipherlast
16030 (vector unsigned long long,
16031 vector unsigned long long);
16032
16033 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16034 vector unsigned long long);
16035
16036 vector unsigned long long __builtin_crypto_vncipherlast
16037 (vector unsigned long long,
16038 vector unsigned long long);
16039
16040 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16041 vector unsigned char,
16042 vector unsigned char);
16043
16044 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16045 vector unsigned short,
16046 vector unsigned short);
16047
16048 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16049 vector unsigned int,
16050 vector unsigned int);
16051
16052 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16053 vector unsigned long long,
16054 vector unsigned long long);
16055
16056 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16057 vector unsigned char);
16058
16059 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16060 vector unsigned short);
16061
16062 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16063 vector unsigned int);
16064
16065 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16066 vector unsigned long long);
16067
16068 vector unsigned long long __builtin_crypto_vshasigmad
16069 (vector unsigned long long, int, int);
16070
16071 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16072 int, int);
16073 @end smallexample
16074
16075 The second argument to the @var{__builtin_crypto_vshasigmad} and
16076 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16077 integer that is 0 or 1. The third argument to these builtin functions
16078 must be a constant integer in the range of 0 to 15.
16079
16080 @node PowerPC Hardware Transactional Memory Built-in Functions
16081 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16082 GCC provides two interfaces for accessing the Hardware Transactional
16083 Memory (HTM) instructions available on some of the PowerPC family
16084 of processors (eg, POWER8). The two interfaces come in a low level
16085 interface, consisting of built-in functions specific to PowerPC and a
16086 higher level interface consisting of inline functions that are common
16087 between PowerPC and S/390.
16088
16089 @subsubsection PowerPC HTM Low Level Built-in Functions
16090
16091 The following low level built-in functions are available with
16092 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16093 They all generate the machine instruction that is part of the name.
16094
16095 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16096 the full 4-bit condition register value set by their associated hardware
16097 instruction. The header file @code{htmintrin.h} defines some macros that can
16098 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16099 returns a simple true or false value depending on whether a transaction was
16100 successfully started or not. The arguments of the builtins match exactly the
16101 type and order of the associated hardware instruction's operands, except for
16102 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16103 Refer to the ISA manual for a description of each instruction's operands.
16104
16105 @smallexample
16106 unsigned int __builtin_tbegin (unsigned int)
16107 unsigned int __builtin_tend (unsigned int)
16108
16109 unsigned int __builtin_tabort (unsigned int)
16110 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16111 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16112 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16113 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16114
16115 unsigned int __builtin_tcheck (void)
16116 unsigned int __builtin_treclaim (unsigned int)
16117 unsigned int __builtin_trechkpt (void)
16118 unsigned int __builtin_tsr (unsigned int)
16119 @end smallexample
16120
16121 In addition to the above HTM built-ins, we have added built-ins for
16122 some common extended mnemonics of the HTM instructions:
16123
16124 @smallexample
16125 unsigned int __builtin_tendall (void)
16126 unsigned int __builtin_tresume (void)
16127 unsigned int __builtin_tsuspend (void)
16128 @end smallexample
16129
16130 Note that the semantics of the above HTM builtins are required to mimic
16131 the locking semantics used for critical sections. Builtins that are used
16132 to create a new transaction or restart a suspended transaction must have
16133 lock acquisition like semantics while those builtins that end or suspend a
16134 transaction must have lock release like semantics. Specifically, this must
16135 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16136 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16137 that returns 0, and lock release is as-if an execution of
16138 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16139 implicit implementation-defined lock used for all transactions. The HTM
16140 instructions associated with with the builtins inherently provide the
16141 correct acquisition and release hardware barriers required. However,
16142 the compiler must also be prohibited from moving loads and stores across
16143 the builtins in a way that would violate their semantics. This has been
16144 accomplished by adding memory barriers to the associated HTM instructions
16145 (which is a conservative approach to provide acquire and release semantics).
16146 Earlier versions of the compiler did not treat the HTM instructions as
16147 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16148 be used to determine whether the current compiler treats HTM instructions
16149 as memory barriers or not. This allows the user to explicitly add memory
16150 barriers to their code when using an older version of the compiler.
16151
16152 The following set of built-in functions are available to gain access
16153 to the HTM specific special purpose registers.
16154
16155 @smallexample
16156 unsigned long __builtin_get_texasr (void)
16157 unsigned long __builtin_get_texasru (void)
16158 unsigned long __builtin_get_tfhar (void)
16159 unsigned long __builtin_get_tfiar (void)
16160
16161 void __builtin_set_texasr (unsigned long);
16162 void __builtin_set_texasru (unsigned long);
16163 void __builtin_set_tfhar (unsigned long);
16164 void __builtin_set_tfiar (unsigned long);
16165 @end smallexample
16166
16167 Example usage of these low level built-in functions may look like:
16168
16169 @smallexample
16170 #include <htmintrin.h>
16171
16172 int num_retries = 10;
16173
16174 while (1)
16175 @{
16176 if (__builtin_tbegin (0))
16177 @{
16178 /* Transaction State Initiated. */
16179 if (is_locked (lock))
16180 __builtin_tabort (0);
16181 ... transaction code...
16182 __builtin_tend (0);
16183 break;
16184 @}
16185 else
16186 @{
16187 /* Transaction State Failed. Use locks if the transaction
16188 failure is "persistent" or we've tried too many times. */
16189 if (num_retries-- <= 0
16190 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16191 @{
16192 acquire_lock (lock);
16193 ... non transactional fallback path...
16194 release_lock (lock);
16195 break;
16196 @}
16197 @}
16198 @}
16199 @end smallexample
16200
16201 One final built-in function has been added that returns the value of
16202 the 2-bit Transaction State field of the Machine Status Register (MSR)
16203 as stored in @code{CR0}.
16204
16205 @smallexample
16206 unsigned long __builtin_ttest (void)
16207 @end smallexample
16208
16209 This built-in can be used to determine the current transaction state
16210 using the following code example:
16211
16212 @smallexample
16213 #include <htmintrin.h>
16214
16215 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16216
16217 if (tx_state == _HTM_TRANSACTIONAL)
16218 @{
16219 /* Code to use in transactional state. */
16220 @}
16221 else if (tx_state == _HTM_NONTRANSACTIONAL)
16222 @{
16223 /* Code to use in non-transactional state. */
16224 @}
16225 else if (tx_state == _HTM_SUSPENDED)
16226 @{
16227 /* Code to use in transaction suspended state. */
16228 @}
16229 @end smallexample
16230
16231 @subsubsection PowerPC HTM High Level Inline Functions
16232
16233 The following high level HTM interface is made available by including
16234 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16235 where CPU is `power8' or later. This interface is common between PowerPC
16236 and S/390, allowing users to write one HTM source implementation that
16237 can be compiled and executed on either system.
16238
16239 @smallexample
16240 long __TM_simple_begin (void)
16241 long __TM_begin (void* const TM_buff)
16242 long __TM_end (void)
16243 void __TM_abort (void)
16244 void __TM_named_abort (unsigned char const code)
16245 void __TM_resume (void)
16246 void __TM_suspend (void)
16247
16248 long __TM_is_user_abort (void* const TM_buff)
16249 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16250 long __TM_is_illegal (void* const TM_buff)
16251 long __TM_is_footprint_exceeded (void* const TM_buff)
16252 long __TM_nesting_depth (void* const TM_buff)
16253 long __TM_is_nested_too_deep(void* const TM_buff)
16254 long __TM_is_conflict(void* const TM_buff)
16255 long __TM_is_failure_persistent(void* const TM_buff)
16256 long __TM_failure_address(void* const TM_buff)
16257 long long __TM_failure_code(void* const TM_buff)
16258 @end smallexample
16259
16260 Using these common set of HTM inline functions, we can create
16261 a more portable version of the HTM example in the previous
16262 section that will work on either PowerPC or S/390:
16263
16264 @smallexample
16265 #include <htmxlintrin.h>
16266
16267 int num_retries = 10;
16268 TM_buff_type TM_buff;
16269
16270 while (1)
16271 @{
16272 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16273 @{
16274 /* Transaction State Initiated. */
16275 if (is_locked (lock))
16276 __TM_abort ();
16277 ... transaction code...
16278 __TM_end ();
16279 break;
16280 @}
16281 else
16282 @{
16283 /* Transaction State Failed. Use locks if the transaction
16284 failure is "persistent" or we've tried too many times. */
16285 if (num_retries-- <= 0
16286 || __TM_is_failure_persistent (TM_buff))
16287 @{
16288 acquire_lock (lock);
16289 ... non transactional fallback path...
16290 release_lock (lock);
16291 break;
16292 @}
16293 @}
16294 @}
16295 @end smallexample
16296
16297 @node RX Built-in Functions
16298 @subsection RX Built-in Functions
16299 GCC supports some of the RX instructions which cannot be expressed in
16300 the C programming language via the use of built-in functions. The
16301 following functions are supported:
16302
16303 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16304 Generates the @code{brk} machine instruction.
16305 @end deftypefn
16306
16307 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16308 Generates the @code{clrpsw} machine instruction to clear the specified
16309 bit in the processor status word.
16310 @end deftypefn
16311
16312 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16313 Generates the @code{int} machine instruction to generate an interrupt
16314 with the specified value.
16315 @end deftypefn
16316
16317 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16318 Generates the @code{machi} machine instruction to add the result of
16319 multiplying the top 16 bits of the two arguments into the
16320 accumulator.
16321 @end deftypefn
16322
16323 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16324 Generates the @code{maclo} machine instruction to add the result of
16325 multiplying the bottom 16 bits of the two arguments into the
16326 accumulator.
16327 @end deftypefn
16328
16329 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16330 Generates the @code{mulhi} machine instruction to place the result of
16331 multiplying the top 16 bits of the two arguments into the
16332 accumulator.
16333 @end deftypefn
16334
16335 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16336 Generates the @code{mullo} machine instruction to place the result of
16337 multiplying the bottom 16 bits of the two arguments into the
16338 accumulator.
16339 @end deftypefn
16340
16341 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16342 Generates the @code{mvfachi} machine instruction to read the top
16343 32 bits of the accumulator.
16344 @end deftypefn
16345
16346 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16347 Generates the @code{mvfacmi} machine instruction to read the middle
16348 32 bits of the accumulator.
16349 @end deftypefn
16350
16351 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16352 Generates the @code{mvfc} machine instruction which reads the control
16353 register specified in its argument and returns its value.
16354 @end deftypefn
16355
16356 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16357 Generates the @code{mvtachi} machine instruction to set the top
16358 32 bits of the accumulator.
16359 @end deftypefn
16360
16361 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16362 Generates the @code{mvtaclo} machine instruction to set the bottom
16363 32 bits of the accumulator.
16364 @end deftypefn
16365
16366 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16367 Generates the @code{mvtc} machine instruction which sets control
16368 register number @code{reg} to @code{val}.
16369 @end deftypefn
16370
16371 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16372 Generates the @code{mvtipl} machine instruction set the interrupt
16373 priority level.
16374 @end deftypefn
16375
16376 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16377 Generates the @code{racw} machine instruction to round the accumulator
16378 according to the specified mode.
16379 @end deftypefn
16380
16381 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16382 Generates the @code{revw} machine instruction which swaps the bytes in
16383 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16384 and also bits 16--23 occupy bits 24--31 and vice versa.
16385 @end deftypefn
16386
16387 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16388 Generates the @code{rmpa} machine instruction which initiates a
16389 repeated multiply and accumulate sequence.
16390 @end deftypefn
16391
16392 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16393 Generates the @code{round} machine instruction which returns the
16394 floating-point argument rounded according to the current rounding mode
16395 set in the floating-point status word register.
16396 @end deftypefn
16397
16398 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16399 Generates the @code{sat} machine instruction which returns the
16400 saturated value of the argument.
16401 @end deftypefn
16402
16403 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16404 Generates the @code{setpsw} machine instruction to set the specified
16405 bit in the processor status word.
16406 @end deftypefn
16407
16408 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16409 Generates the @code{wait} machine instruction.
16410 @end deftypefn
16411
16412 @node S/390 System z Built-in Functions
16413 @subsection S/390 System z Built-in Functions
16414 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16415 Generates the @code{tbegin} machine instruction starting a
16416 non-constraint hardware transaction. If the parameter is non-NULL the
16417 memory area is used to store the transaction diagnostic buffer and
16418 will be passed as first operand to @code{tbegin}. This buffer can be
16419 defined using the @code{struct __htm_tdb} C struct defined in
16420 @code{htmintrin.h} and must reside on a double-word boundary. The
16421 second tbegin operand is set to @code{0xff0c}. This enables
16422 save/restore of all GPRs and disables aborts for FPR and AR
16423 manipulations inside the transaction body. The condition code set by
16424 the tbegin instruction is returned as integer value. The tbegin
16425 instruction by definition overwrites the content of all FPRs. The
16426 compiler will generate code which saves and restores the FPRs. For
16427 soft-float code it is recommended to used the @code{*_nofloat}
16428 variant. In order to prevent a TDB from being written it is required
16429 to pass an constant zero value as parameter. Passing the zero value
16430 through a variable is not sufficient. Although modifications of
16431 access registers inside the transaction will not trigger an
16432 transaction abort it is not supported to actually modify them. Access
16433 registers do not get saved when entering a transaction. They will have
16434 undefined state when reaching the abort code.
16435 @end deftypefn
16436
16437 Macros for the possible return codes of tbegin are defined in the
16438 @code{htmintrin.h} header file:
16439
16440 @table @code
16441 @item _HTM_TBEGIN_STARTED
16442 @code{tbegin} has been executed as part of normal processing. The
16443 transaction body is supposed to be executed.
16444 @item _HTM_TBEGIN_INDETERMINATE
16445 The transaction was aborted due to an indeterminate condition which
16446 might be persistent.
16447 @item _HTM_TBEGIN_TRANSIENT
16448 The transaction aborted due to a transient failure. The transaction
16449 should be re-executed in that case.
16450 @item _HTM_TBEGIN_PERSISTENT
16451 The transaction aborted due to a persistent failure. Re-execution
16452 under same circumstances will not be productive.
16453 @end table
16454
16455 @defmac _HTM_FIRST_USER_ABORT_CODE
16456 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16457 specifies the first abort code which can be used for
16458 @code{__builtin_tabort}. Values below this threshold are reserved for
16459 machine use.
16460 @end defmac
16461
16462 @deftp {Data type} {struct __htm_tdb}
16463 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16464 the structure of the transaction diagnostic block as specified in the
16465 Principles of Operation manual chapter 5-91.
16466 @end deftp
16467
16468 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16469 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16470 Using this variant in code making use of FPRs will leave the FPRs in
16471 undefined state when entering the transaction abort handler code.
16472 @end deftypefn
16473
16474 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16475 In addition to @code{__builtin_tbegin} a loop for transient failures
16476 is generated. If tbegin returns a condition code of 2 the transaction
16477 will be retried as often as specified in the second argument. The
16478 perform processor assist instruction is used to tell the CPU about the
16479 number of fails so far.
16480 @end deftypefn
16481
16482 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16483 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16484 restores. Using this variant in code making use of FPRs will leave
16485 the FPRs in undefined state when entering the transaction abort
16486 handler code.
16487 @end deftypefn
16488
16489 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16490 Generates the @code{tbeginc} machine instruction starting a constraint
16491 hardware transaction. The second operand is set to @code{0xff08}.
16492 @end deftypefn
16493
16494 @deftypefn {Built-in Function} int __builtin_tend (void)
16495 Generates the @code{tend} machine instruction finishing a transaction
16496 and making the changes visible to other threads. The condition code
16497 generated by tend is returned as integer value.
16498 @end deftypefn
16499
16500 @deftypefn {Built-in Function} void __builtin_tabort (int)
16501 Generates the @code{tabort} machine instruction with the specified
16502 abort code. Abort codes from 0 through 255 are reserved and will
16503 result in an error message.
16504 @end deftypefn
16505
16506 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16507 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16508 integer parameter is loaded into rX and a value of zero is loaded into
16509 rY. The integer parameter specifies the number of times the
16510 transaction repeatedly aborted.
16511 @end deftypefn
16512
16513 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16514 Generates the @code{etnd} machine instruction. The current nesting
16515 depth is returned as integer value. For a nesting depth of 0 the code
16516 is not executed as part of an transaction.
16517 @end deftypefn
16518
16519 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16520
16521 Generates the @code{ntstg} machine instruction. The second argument
16522 is written to the first arguments location. The store operation will
16523 not be rolled-back in case of an transaction abort.
16524 @end deftypefn
16525
16526 @node SH Built-in Functions
16527 @subsection SH Built-in Functions
16528 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16529 families of processors:
16530
16531 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16532 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16533 used by system code that manages threads and execution contexts. The compiler
16534 normally does not generate code that modifies the contents of @samp{GBR} and
16535 thus the value is preserved across function calls. Changing the @samp{GBR}
16536 value in user code must be done with caution, since the compiler might use
16537 @samp{GBR} in order to access thread local variables.
16538
16539 @end deftypefn
16540
16541 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16542 Returns the value that is currently set in the @samp{GBR} register.
16543 Memory loads and stores that use the thread pointer as a base address are
16544 turned into @samp{GBR} based displacement loads and stores, if possible.
16545 For example:
16546 @smallexample
16547 struct my_tcb
16548 @{
16549 int a, b, c, d, e;
16550 @};
16551
16552 int get_tcb_value (void)
16553 @{
16554 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16555 return ((my_tcb*)__builtin_thread_pointer ())->c;
16556 @}
16557
16558 @end smallexample
16559 @end deftypefn
16560
16561 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16562 Returns the value that is currently set in the @samp{FPSCR} register.
16563 @end deftypefn
16564
16565 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16566 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16567 preserving the current values of the FR, SZ and PR bits.
16568 @end deftypefn
16569
16570 @node SPARC VIS Built-in Functions
16571 @subsection SPARC VIS Built-in Functions
16572
16573 GCC supports SIMD operations on the SPARC using both the generic vector
16574 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16575 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16576 switch, the VIS extension is exposed as the following built-in functions:
16577
16578 @smallexample
16579 typedef int v1si __attribute__ ((vector_size (4)));
16580 typedef int v2si __attribute__ ((vector_size (8)));
16581 typedef short v4hi __attribute__ ((vector_size (8)));
16582 typedef short v2hi __attribute__ ((vector_size (4)));
16583 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16584 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16585
16586 void __builtin_vis_write_gsr (int64_t);
16587 int64_t __builtin_vis_read_gsr (void);
16588
16589 void * __builtin_vis_alignaddr (void *, long);
16590 void * __builtin_vis_alignaddrl (void *, long);
16591 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16592 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16593 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16594 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16595
16596 v4hi __builtin_vis_fexpand (v4qi);
16597
16598 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16599 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16600 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16601 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16602 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16603 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16604 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16605
16606 v4qi __builtin_vis_fpack16 (v4hi);
16607 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16608 v2hi __builtin_vis_fpackfix (v2si);
16609 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16610
16611 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16612
16613 long __builtin_vis_edge8 (void *, void *);
16614 long __builtin_vis_edge8l (void *, void *);
16615 long __builtin_vis_edge16 (void *, void *);
16616 long __builtin_vis_edge16l (void *, void *);
16617 long __builtin_vis_edge32 (void *, void *);
16618 long __builtin_vis_edge32l (void *, void *);
16619
16620 long __builtin_vis_fcmple16 (v4hi, v4hi);
16621 long __builtin_vis_fcmple32 (v2si, v2si);
16622 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16623 long __builtin_vis_fcmpne32 (v2si, v2si);
16624 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16625 long __builtin_vis_fcmpgt32 (v2si, v2si);
16626 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16627 long __builtin_vis_fcmpeq32 (v2si, v2si);
16628
16629 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16630 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16631 v2si __builtin_vis_fpadd32 (v2si, v2si);
16632 v1si __builtin_vis_fpadd32s (v1si, v1si);
16633 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16634 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16635 v2si __builtin_vis_fpsub32 (v2si, v2si);
16636 v1si __builtin_vis_fpsub32s (v1si, v1si);
16637
16638 long __builtin_vis_array8 (long, long);
16639 long __builtin_vis_array16 (long, long);
16640 long __builtin_vis_array32 (long, long);
16641 @end smallexample
16642
16643 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16644 functions also become available:
16645
16646 @smallexample
16647 long __builtin_vis_bmask (long, long);
16648 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16649 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16650 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16651 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16652
16653 long __builtin_vis_edge8n (void *, void *);
16654 long __builtin_vis_edge8ln (void *, void *);
16655 long __builtin_vis_edge16n (void *, void *);
16656 long __builtin_vis_edge16ln (void *, void *);
16657 long __builtin_vis_edge32n (void *, void *);
16658 long __builtin_vis_edge32ln (void *, void *);
16659 @end smallexample
16660
16661 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16662 functions also become available:
16663
16664 @smallexample
16665 void __builtin_vis_cmask8 (long);
16666 void __builtin_vis_cmask16 (long);
16667 void __builtin_vis_cmask32 (long);
16668
16669 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16670
16671 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16672 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16673 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16674 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16675 v2si __builtin_vis_fsll16 (v2si, v2si);
16676 v2si __builtin_vis_fslas16 (v2si, v2si);
16677 v2si __builtin_vis_fsrl16 (v2si, v2si);
16678 v2si __builtin_vis_fsra16 (v2si, v2si);
16679
16680 long __builtin_vis_pdistn (v8qi, v8qi);
16681
16682 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16683
16684 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16685 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16686
16687 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16688 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16689 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16690 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16691 v2si __builtin_vis_fpadds32 (v2si, v2si);
16692 v1si __builtin_vis_fpadds32s (v1si, v1si);
16693 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16694 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16695
16696 long __builtin_vis_fucmple8 (v8qi, v8qi);
16697 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16698 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16699 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16700
16701 float __builtin_vis_fhadds (float, float);
16702 double __builtin_vis_fhaddd (double, double);
16703 float __builtin_vis_fhsubs (float, float);
16704 double __builtin_vis_fhsubd (double, double);
16705 float __builtin_vis_fnhadds (float, float);
16706 double __builtin_vis_fnhaddd (double, double);
16707
16708 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16709 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16710 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16711 @end smallexample
16712
16713 @node SPU Built-in Functions
16714 @subsection SPU Built-in Functions
16715
16716 GCC provides extensions for the SPU processor as described in the
16717 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16718 found at @uref{http://cell.scei.co.jp/} or
16719 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
16720 implementation differs in several ways.
16721
16722 @itemize @bullet
16723
16724 @item
16725 The optional extension of specifying vector constants in parentheses is
16726 not supported.
16727
16728 @item
16729 A vector initializer requires no cast if the vector constant is of the
16730 same type as the variable it is initializing.
16731
16732 @item
16733 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16734 vector type is the default signedness of the base type. The default
16735 varies depending on the operating system, so a portable program should
16736 always specify the signedness.
16737
16738 @item
16739 By default, the keyword @code{__vector} is added. The macro
16740 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16741 undefined.
16742
16743 @item
16744 GCC allows using a @code{typedef} name as the type specifier for a
16745 vector type.
16746
16747 @item
16748 For C, overloaded functions are implemented with macros so the following
16749 does not work:
16750
16751 @smallexample
16752 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16753 @end smallexample
16754
16755 @noindent
16756 Since @code{spu_add} is a macro, the vector constant in the example
16757 is treated as four separate arguments. Wrap the entire argument in
16758 parentheses for this to work.
16759
16760 @item
16761 The extended version of @code{__builtin_expect} is not supported.
16762
16763 @end itemize
16764
16765 @emph{Note:} Only the interface described in the aforementioned
16766 specification is supported. Internally, GCC uses built-in functions to
16767 implement the required functionality, but these are not supported and
16768 are subject to change without notice.
16769
16770 @node TI C6X Built-in Functions
16771 @subsection TI C6X Built-in Functions
16772
16773 GCC provides intrinsics to access certain instructions of the TI C6X
16774 processors. These intrinsics, listed below, are available after
16775 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
16776 to C6X instructions.
16777
16778 @smallexample
16779
16780 int _sadd (int, int)
16781 int _ssub (int, int)
16782 int _sadd2 (int, int)
16783 int _ssub2 (int, int)
16784 long long _mpy2 (int, int)
16785 long long _smpy2 (int, int)
16786 int _add4 (int, int)
16787 int _sub4 (int, int)
16788 int _saddu4 (int, int)
16789
16790 int _smpy (int, int)
16791 int _smpyh (int, int)
16792 int _smpyhl (int, int)
16793 int _smpylh (int, int)
16794
16795 int _sshl (int, int)
16796 int _subc (int, int)
16797
16798 int _avg2 (int, int)
16799 int _avgu4 (int, int)
16800
16801 int _clrr (int, int)
16802 int _extr (int, int)
16803 int _extru (int, int)
16804 int _abs (int)
16805 int _abs2 (int)
16806
16807 @end smallexample
16808
16809 @node TILE-Gx Built-in Functions
16810 @subsection TILE-Gx Built-in Functions
16811
16812 GCC provides intrinsics to access every instruction of the TILE-Gx
16813 processor. The intrinsics are of the form:
16814
16815 @smallexample
16816
16817 unsigned long long __insn_@var{op} (...)
16818
16819 @end smallexample
16820
16821 Where @var{op} is the name of the instruction. Refer to the ISA manual
16822 for the complete list of instructions.
16823
16824 GCC also provides intrinsics to directly access the network registers.
16825 The intrinsics are:
16826
16827 @smallexample
16828
16829 unsigned long long __tile_idn0_receive (void)
16830 unsigned long long __tile_idn1_receive (void)
16831 unsigned long long __tile_udn0_receive (void)
16832 unsigned long long __tile_udn1_receive (void)
16833 unsigned long long __tile_udn2_receive (void)
16834 unsigned long long __tile_udn3_receive (void)
16835 void __tile_idn_send (unsigned long long)
16836 void __tile_udn_send (unsigned long long)
16837
16838 @end smallexample
16839
16840 The intrinsic @code{void __tile_network_barrier (void)} is used to
16841 guarantee that no network operations before it are reordered with
16842 those after it.
16843
16844 @node TILEPro Built-in Functions
16845 @subsection TILEPro Built-in Functions
16846
16847 GCC provides intrinsics to access every instruction of the TILEPro
16848 processor. The intrinsics are of the form:
16849
16850 @smallexample
16851
16852 unsigned __insn_@var{op} (...)
16853
16854 @end smallexample
16855
16856 @noindent
16857 where @var{op} is the name of the instruction. Refer to the ISA manual
16858 for the complete list of instructions.
16859
16860 GCC also provides intrinsics to directly access the network registers.
16861 The intrinsics are:
16862
16863 @smallexample
16864
16865 unsigned __tile_idn0_receive (void)
16866 unsigned __tile_idn1_receive (void)
16867 unsigned __tile_sn_receive (void)
16868 unsigned __tile_udn0_receive (void)
16869 unsigned __tile_udn1_receive (void)
16870 unsigned __tile_udn2_receive (void)
16871 unsigned __tile_udn3_receive (void)
16872 void __tile_idn_send (unsigned)
16873 void __tile_sn_send (unsigned)
16874 void __tile_udn_send (unsigned)
16875
16876 @end smallexample
16877
16878 The intrinsic @code{void __tile_network_barrier (void)} is used to
16879 guarantee that no network operations before it are reordered with
16880 those after it.
16881
16882 @node x86 Built-in Functions
16883 @subsection x86 Built-in Functions
16884
16885 These built-in functions are available for the x86-32 and x86-64 family
16886 of computers, depending on the command-line switches used.
16887
16888 If you specify command-line switches such as @option{-msse},
16889 the compiler could use the extended instruction sets even if the built-ins
16890 are not used explicitly in the program. For this reason, applications
16891 that perform run-time CPU detection must compile separate files for each
16892 supported architecture, using the appropriate flags. In particular,
16893 the file containing the CPU detection code should be compiled without
16894 these options.
16895
16896 The following machine modes are available for use with MMX built-in functions
16897 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
16898 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
16899 vector of eight 8-bit integers. Some of the built-in functions operate on
16900 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
16901
16902 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
16903 of two 32-bit floating-point values.
16904
16905 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
16906 floating-point values. Some instructions use a vector of four 32-bit
16907 integers, these use @code{V4SI}. Finally, some instructions operate on an
16908 entire vector register, interpreting it as a 128-bit integer, these use mode
16909 @code{TI}.
16910
16911 In 64-bit mode, the x86-64 family of processors uses additional built-in
16912 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
16913 floating point and @code{TC} 128-bit complex floating-point values.
16914
16915 The following floating-point built-in functions are available in 64-bit
16916 mode. All of them implement the function that is part of the name.
16917
16918 @smallexample
16919 __float128 __builtin_fabsq (__float128)
16920 __float128 __builtin_copysignq (__float128, __float128)
16921 @end smallexample
16922
16923 The following built-in function is always available.
16924
16925 @table @code
16926 @item void __builtin_ia32_pause (void)
16927 Generates the @code{pause} machine instruction with a compiler memory
16928 barrier.
16929 @end table
16930
16931 The following floating-point built-in functions are made available in the
16932 64-bit mode.
16933
16934 @table @code
16935 @item __float128 __builtin_infq (void)
16936 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
16937 @findex __builtin_infq
16938
16939 @item __float128 __builtin_huge_valq (void)
16940 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
16941 @findex __builtin_huge_valq
16942 @end table
16943
16944 The following built-in functions are always available and can be used to
16945 check the target platform type.
16946
16947 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16948 This function runs the CPU detection code to check the type of CPU and the
16949 features supported. This built-in function needs to be invoked along with the built-in functions
16950 to check CPU type and features, @code{__builtin_cpu_is} and
16951 @code{__builtin_cpu_supports}, only when used in a function that is
16952 executed before any constructors are called. The CPU detection code is
16953 automatically executed in a very high priority constructor.
16954
16955 For example, this function has to be used in @code{ifunc} resolvers that
16956 check for CPU type using the built-in functions @code{__builtin_cpu_is}
16957 and @code{__builtin_cpu_supports}, or in constructors on targets that
16958 don't support constructor priority.
16959 @smallexample
16960
16961 static void (*resolve_memcpy (void)) (void)
16962 @{
16963 // ifunc resolvers fire before constructors, explicitly call the init
16964 // function.
16965 __builtin_cpu_init ();
16966 if (__builtin_cpu_supports ("ssse3"))
16967 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
16968 else
16969 return default_memcpy;
16970 @}
16971
16972 void *memcpy (void *, const void *, size_t)
16973 __attribute__ ((ifunc ("resolve_memcpy")));
16974 @end smallexample
16975
16976 @end deftypefn
16977
16978 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16979 This function returns a positive integer if the run-time CPU
16980 is of type @var{cpuname}
16981 and returns @code{0} otherwise. The following CPU names can be detected:
16982
16983 @table @samp
16984 @item intel
16985 Intel CPU.
16986
16987 @item atom
16988 Intel Atom CPU.
16989
16990 @item core2
16991 Intel Core 2 CPU.
16992
16993 @item corei7
16994 Intel Core i7 CPU.
16995
16996 @item nehalem
16997 Intel Core i7 Nehalem CPU.
16998
16999 @item westmere
17000 Intel Core i7 Westmere CPU.
17001
17002 @item sandybridge
17003 Intel Core i7 Sandy Bridge CPU.
17004
17005 @item amd
17006 AMD CPU.
17007
17008 @item amdfam10h
17009 AMD Family 10h CPU.
17010
17011 @item barcelona
17012 AMD Family 10h Barcelona CPU.
17013
17014 @item shanghai
17015 AMD Family 10h Shanghai CPU.
17016
17017 @item istanbul
17018 AMD Family 10h Istanbul CPU.
17019
17020 @item btver1
17021 AMD Family 14h CPU.
17022
17023 @item amdfam15h
17024 AMD Family 15h CPU.
17025
17026 @item bdver1
17027 AMD Family 15h Bulldozer version 1.
17028
17029 @item bdver2
17030 AMD Family 15h Bulldozer version 2.
17031
17032 @item bdver3
17033 AMD Family 15h Bulldozer version 3.
17034
17035 @item bdver4
17036 AMD Family 15h Bulldozer version 4.
17037
17038 @item btver2
17039 AMD Family 16h CPU.
17040
17041 @item znver1
17042 AMD Family 17h CPU.
17043 @end table
17044
17045 Here is an example:
17046 @smallexample
17047 if (__builtin_cpu_is ("corei7"))
17048 @{
17049 do_corei7 (); // Core i7 specific implementation.
17050 @}
17051 else
17052 @{
17053 do_generic (); // Generic implementation.
17054 @}
17055 @end smallexample
17056 @end deftypefn
17057
17058 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17059 This function returns a positive integer if the run-time CPU
17060 supports @var{feature}
17061 and returns @code{0} otherwise. The following features can be detected:
17062
17063 @table @samp
17064 @item cmov
17065 CMOV instruction.
17066 @item mmx
17067 MMX instructions.
17068 @item popcnt
17069 POPCNT instruction.
17070 @item sse
17071 SSE instructions.
17072 @item sse2
17073 SSE2 instructions.
17074 @item sse3
17075 SSE3 instructions.
17076 @item ssse3
17077 SSSE3 instructions.
17078 @item sse4.1
17079 SSE4.1 instructions.
17080 @item sse4.2
17081 SSE4.2 instructions.
17082 @item avx
17083 AVX instructions.
17084 @item avx2
17085 AVX2 instructions.
17086 @item avx512f
17087 AVX512F instructions.
17088 @end table
17089
17090 Here is an example:
17091 @smallexample
17092 if (__builtin_cpu_supports ("popcnt"))
17093 @{
17094 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17095 @}
17096 else
17097 @{
17098 count = generic_countbits (n); //generic implementation.
17099 @}
17100 @end smallexample
17101 @end deftypefn
17102
17103
17104 The following built-in functions are made available by @option{-mmmx}.
17105 All of them generate the machine instruction that is part of the name.
17106
17107 @smallexample
17108 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17109 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17110 v2si __builtin_ia32_paddd (v2si, v2si)
17111 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17112 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17113 v2si __builtin_ia32_psubd (v2si, v2si)
17114 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17115 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17116 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17117 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17118 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17119 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17120 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17121 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17122 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17123 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17124 di __builtin_ia32_pand (di, di)
17125 di __builtin_ia32_pandn (di,di)
17126 di __builtin_ia32_por (di, di)
17127 di __builtin_ia32_pxor (di, di)
17128 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17129 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17130 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17131 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17132 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17133 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17134 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17135 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17136 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17137 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17138 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17139 v2si __builtin_ia32_punpckldq (v2si, v2si)
17140 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17141 v4hi __builtin_ia32_packssdw (v2si, v2si)
17142 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17143
17144 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17145 v2si __builtin_ia32_pslld (v2si, v2si)
17146 v1di __builtin_ia32_psllq (v1di, v1di)
17147 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17148 v2si __builtin_ia32_psrld (v2si, v2si)
17149 v1di __builtin_ia32_psrlq (v1di, v1di)
17150 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17151 v2si __builtin_ia32_psrad (v2si, v2si)
17152 v4hi __builtin_ia32_psllwi (v4hi, int)
17153 v2si __builtin_ia32_pslldi (v2si, int)
17154 v1di __builtin_ia32_psllqi (v1di, int)
17155 v4hi __builtin_ia32_psrlwi (v4hi, int)
17156 v2si __builtin_ia32_psrldi (v2si, int)
17157 v1di __builtin_ia32_psrlqi (v1di, int)
17158 v4hi __builtin_ia32_psrawi (v4hi, int)
17159 v2si __builtin_ia32_psradi (v2si, int)
17160
17161 @end smallexample
17162
17163 The following built-in functions are made available either with
17164 @option{-msse}, or with a combination of @option{-m3dnow} and
17165 @option{-march=athlon}. All of them generate the machine
17166 instruction that is part of the name.
17167
17168 @smallexample
17169 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17170 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17171 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17172 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17173 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17174 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17175 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17176 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17177 int __builtin_ia32_pmovmskb (v8qi)
17178 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17179 void __builtin_ia32_movntq (di *, di)
17180 void __builtin_ia32_sfence (void)
17181 @end smallexample
17182
17183 The following built-in functions are available when @option{-msse} is used.
17184 All of them generate the machine instruction that is part of the name.
17185
17186 @smallexample
17187 int __builtin_ia32_comieq (v4sf, v4sf)
17188 int __builtin_ia32_comineq (v4sf, v4sf)
17189 int __builtin_ia32_comilt (v4sf, v4sf)
17190 int __builtin_ia32_comile (v4sf, v4sf)
17191 int __builtin_ia32_comigt (v4sf, v4sf)
17192 int __builtin_ia32_comige (v4sf, v4sf)
17193 int __builtin_ia32_ucomieq (v4sf, v4sf)
17194 int __builtin_ia32_ucomineq (v4sf, v4sf)
17195 int __builtin_ia32_ucomilt (v4sf, v4sf)
17196 int __builtin_ia32_ucomile (v4sf, v4sf)
17197 int __builtin_ia32_ucomigt (v4sf, v4sf)
17198 int __builtin_ia32_ucomige (v4sf, v4sf)
17199 v4sf __builtin_ia32_addps (v4sf, v4sf)
17200 v4sf __builtin_ia32_subps (v4sf, v4sf)
17201 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17202 v4sf __builtin_ia32_divps (v4sf, v4sf)
17203 v4sf __builtin_ia32_addss (v4sf, v4sf)
17204 v4sf __builtin_ia32_subss (v4sf, v4sf)
17205 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17206 v4sf __builtin_ia32_divss (v4sf, v4sf)
17207 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17208 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17209 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17210 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17211 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17212 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17213 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17214 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17215 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17216 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17217 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17218 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17219 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17220 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17221 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17222 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17223 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17224 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17225 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17226 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17227 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17228 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17229 v4sf __builtin_ia32_minps (v4sf, v4sf)
17230 v4sf __builtin_ia32_minss (v4sf, v4sf)
17231 v4sf __builtin_ia32_andps (v4sf, v4sf)
17232 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17233 v4sf __builtin_ia32_orps (v4sf, v4sf)
17234 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17235 v4sf __builtin_ia32_movss (v4sf, v4sf)
17236 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17237 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17238 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17239 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17240 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17241 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17242 v2si __builtin_ia32_cvtps2pi (v4sf)
17243 int __builtin_ia32_cvtss2si (v4sf)
17244 v2si __builtin_ia32_cvttps2pi (v4sf)
17245 int __builtin_ia32_cvttss2si (v4sf)
17246 v4sf __builtin_ia32_rcpps (v4sf)
17247 v4sf __builtin_ia32_rsqrtps (v4sf)
17248 v4sf __builtin_ia32_sqrtps (v4sf)
17249 v4sf __builtin_ia32_rcpss (v4sf)
17250 v4sf __builtin_ia32_rsqrtss (v4sf)
17251 v4sf __builtin_ia32_sqrtss (v4sf)
17252 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17253 void __builtin_ia32_movntps (float *, v4sf)
17254 int __builtin_ia32_movmskps (v4sf)
17255 @end smallexample
17256
17257 The following built-in functions are available when @option{-msse} is used.
17258
17259 @table @code
17260 @item v4sf __builtin_ia32_loadups (float *)
17261 Generates the @code{movups} machine instruction as a load from memory.
17262 @item void __builtin_ia32_storeups (float *, v4sf)
17263 Generates the @code{movups} machine instruction as a store to memory.
17264 @item v4sf __builtin_ia32_loadss (float *)
17265 Generates the @code{movss} machine instruction as a load from memory.
17266 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17267 Generates the @code{movhps} machine instruction as a load from memory.
17268 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17269 Generates the @code{movlps} machine instruction as a load from memory
17270 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17271 Generates the @code{movhps} machine instruction as a store to memory.
17272 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17273 Generates the @code{movlps} machine instruction as a store to memory.
17274 @end table
17275
17276 The following built-in functions are available when @option{-msse2} is used.
17277 All of them generate the machine instruction that is part of the name.
17278
17279 @smallexample
17280 int __builtin_ia32_comisdeq (v2df, v2df)
17281 int __builtin_ia32_comisdlt (v2df, v2df)
17282 int __builtin_ia32_comisdle (v2df, v2df)
17283 int __builtin_ia32_comisdgt (v2df, v2df)
17284 int __builtin_ia32_comisdge (v2df, v2df)
17285 int __builtin_ia32_comisdneq (v2df, v2df)
17286 int __builtin_ia32_ucomisdeq (v2df, v2df)
17287 int __builtin_ia32_ucomisdlt (v2df, v2df)
17288 int __builtin_ia32_ucomisdle (v2df, v2df)
17289 int __builtin_ia32_ucomisdgt (v2df, v2df)
17290 int __builtin_ia32_ucomisdge (v2df, v2df)
17291 int __builtin_ia32_ucomisdneq (v2df, v2df)
17292 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17293 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17294 v2df __builtin_ia32_cmplepd (v2df, v2df)
17295 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17296 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17297 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17298 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17299 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17300 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17301 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17302 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17303 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17304 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17305 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17306 v2df __builtin_ia32_cmplesd (v2df, v2df)
17307 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17308 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17309 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17310 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17311 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17312 v2di __builtin_ia32_paddq (v2di, v2di)
17313 v2di __builtin_ia32_psubq (v2di, v2di)
17314 v2df __builtin_ia32_addpd (v2df, v2df)
17315 v2df __builtin_ia32_subpd (v2df, v2df)
17316 v2df __builtin_ia32_mulpd (v2df, v2df)
17317 v2df __builtin_ia32_divpd (v2df, v2df)
17318 v2df __builtin_ia32_addsd (v2df, v2df)
17319 v2df __builtin_ia32_subsd (v2df, v2df)
17320 v2df __builtin_ia32_mulsd (v2df, v2df)
17321 v2df __builtin_ia32_divsd (v2df, v2df)
17322 v2df __builtin_ia32_minpd (v2df, v2df)
17323 v2df __builtin_ia32_maxpd (v2df, v2df)
17324 v2df __builtin_ia32_minsd (v2df, v2df)
17325 v2df __builtin_ia32_maxsd (v2df, v2df)
17326 v2df __builtin_ia32_andpd (v2df, v2df)
17327 v2df __builtin_ia32_andnpd (v2df, v2df)
17328 v2df __builtin_ia32_orpd (v2df, v2df)
17329 v2df __builtin_ia32_xorpd (v2df, v2df)
17330 v2df __builtin_ia32_movsd (v2df, v2df)
17331 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17332 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17333 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17334 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17335 v4si __builtin_ia32_paddd128 (v4si, v4si)
17336 v2di __builtin_ia32_paddq128 (v2di, v2di)
17337 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17338 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17339 v4si __builtin_ia32_psubd128 (v4si, v4si)
17340 v2di __builtin_ia32_psubq128 (v2di, v2di)
17341 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17342 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17343 v2di __builtin_ia32_pand128 (v2di, v2di)
17344 v2di __builtin_ia32_pandn128 (v2di, v2di)
17345 v2di __builtin_ia32_por128 (v2di, v2di)
17346 v2di __builtin_ia32_pxor128 (v2di, v2di)
17347 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17348 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17349 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17350 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17351 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17352 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17353 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17354 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17355 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17356 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17357 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17358 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17359 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17360 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17361 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17362 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17363 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17364 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17365 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17366 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17367 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17368 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17369 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17370 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17371 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17372 v2df __builtin_ia32_loadupd (double *)
17373 void __builtin_ia32_storeupd (double *, v2df)
17374 v2df __builtin_ia32_loadhpd (v2df, double const *)
17375 v2df __builtin_ia32_loadlpd (v2df, double const *)
17376 int __builtin_ia32_movmskpd (v2df)
17377 int __builtin_ia32_pmovmskb128 (v16qi)
17378 void __builtin_ia32_movnti (int *, int)
17379 void __builtin_ia32_movnti64 (long long int *, long long int)
17380 void __builtin_ia32_movntpd (double *, v2df)
17381 void __builtin_ia32_movntdq (v2df *, v2df)
17382 v4si __builtin_ia32_pshufd (v4si, int)
17383 v8hi __builtin_ia32_pshuflw (v8hi, int)
17384 v8hi __builtin_ia32_pshufhw (v8hi, int)
17385 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17386 v2df __builtin_ia32_sqrtpd (v2df)
17387 v2df __builtin_ia32_sqrtsd (v2df)
17388 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17389 v2df __builtin_ia32_cvtdq2pd (v4si)
17390 v4sf __builtin_ia32_cvtdq2ps (v4si)
17391 v4si __builtin_ia32_cvtpd2dq (v2df)
17392 v2si __builtin_ia32_cvtpd2pi (v2df)
17393 v4sf __builtin_ia32_cvtpd2ps (v2df)
17394 v4si __builtin_ia32_cvttpd2dq (v2df)
17395 v2si __builtin_ia32_cvttpd2pi (v2df)
17396 v2df __builtin_ia32_cvtpi2pd (v2si)
17397 int __builtin_ia32_cvtsd2si (v2df)
17398 int __builtin_ia32_cvttsd2si (v2df)
17399 long long __builtin_ia32_cvtsd2si64 (v2df)
17400 long long __builtin_ia32_cvttsd2si64 (v2df)
17401 v4si __builtin_ia32_cvtps2dq (v4sf)
17402 v2df __builtin_ia32_cvtps2pd (v4sf)
17403 v4si __builtin_ia32_cvttps2dq (v4sf)
17404 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17405 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17406 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17407 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17408 void __builtin_ia32_clflush (const void *)
17409 void __builtin_ia32_lfence (void)
17410 void __builtin_ia32_mfence (void)
17411 v16qi __builtin_ia32_loaddqu (const char *)
17412 void __builtin_ia32_storedqu (char *, v16qi)
17413 v1di __builtin_ia32_pmuludq (v2si, v2si)
17414 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17415 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17416 v4si __builtin_ia32_pslld128 (v4si, v4si)
17417 v2di __builtin_ia32_psllq128 (v2di, v2di)
17418 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17419 v4si __builtin_ia32_psrld128 (v4si, v4si)
17420 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17421 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17422 v4si __builtin_ia32_psrad128 (v4si, v4si)
17423 v2di __builtin_ia32_pslldqi128 (v2di, int)
17424 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17425 v4si __builtin_ia32_pslldi128 (v4si, int)
17426 v2di __builtin_ia32_psllqi128 (v2di, int)
17427 v2di __builtin_ia32_psrldqi128 (v2di, int)
17428 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17429 v4si __builtin_ia32_psrldi128 (v4si, int)
17430 v2di __builtin_ia32_psrlqi128 (v2di, int)
17431 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17432 v4si __builtin_ia32_psradi128 (v4si, int)
17433 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17434 v2di __builtin_ia32_movq128 (v2di)
17435 @end smallexample
17436
17437 The following built-in functions are available when @option{-msse3} is used.
17438 All of them generate the machine instruction that is part of the name.
17439
17440 @smallexample
17441 v2df __builtin_ia32_addsubpd (v2df, v2df)
17442 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17443 v2df __builtin_ia32_haddpd (v2df, v2df)
17444 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17445 v2df __builtin_ia32_hsubpd (v2df, v2df)
17446 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17447 v16qi __builtin_ia32_lddqu (char const *)
17448 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17449 v4sf __builtin_ia32_movshdup (v4sf)
17450 v4sf __builtin_ia32_movsldup (v4sf)
17451 void __builtin_ia32_mwait (unsigned int, unsigned int)
17452 @end smallexample
17453
17454 The following built-in functions are available when @option{-mssse3} is used.
17455 All of them generate the machine instruction that is part of the name.
17456
17457 @smallexample
17458 v2si __builtin_ia32_phaddd (v2si, v2si)
17459 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17460 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17461 v2si __builtin_ia32_phsubd (v2si, v2si)
17462 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17463 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17464 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17465 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17466 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17467 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17468 v2si __builtin_ia32_psignd (v2si, v2si)
17469 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17470 v1di __builtin_ia32_palignr (v1di, v1di, int)
17471 v8qi __builtin_ia32_pabsb (v8qi)
17472 v2si __builtin_ia32_pabsd (v2si)
17473 v4hi __builtin_ia32_pabsw (v4hi)
17474 @end smallexample
17475
17476 The following built-in functions are available when @option{-mssse3} is used.
17477 All of them generate the machine instruction that is part of the name.
17478
17479 @smallexample
17480 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17481 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17482 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17483 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17484 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17485 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17486 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17487 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17488 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17489 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17490 v4si __builtin_ia32_psignd128 (v4si, v4si)
17491 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17492 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17493 v16qi __builtin_ia32_pabsb128 (v16qi)
17494 v4si __builtin_ia32_pabsd128 (v4si)
17495 v8hi __builtin_ia32_pabsw128 (v8hi)
17496 @end smallexample
17497
17498 The following built-in functions are available when @option{-msse4.1} is
17499 used. All of them generate the machine instruction that is part of the
17500 name.
17501
17502 @smallexample
17503 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17504 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17505 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17506 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17507 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17508 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17509 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17510 v2di __builtin_ia32_movntdqa (v2di *);
17511 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17512 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17513 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17514 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17515 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17516 v8hi __builtin_ia32_phminposuw128 (v8hi)
17517 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17518 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17519 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17520 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17521 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17522 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17523 v4si __builtin_ia32_pminud128 (v4si, v4si)
17524 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17525 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17526 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17527 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17528 v2di __builtin_ia32_pmovsxdq128 (v4si)
17529 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17530 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17531 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17532 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17533 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17534 v2di __builtin_ia32_pmovzxdq128 (v4si)
17535 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17536 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17537 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17538 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17539 int __builtin_ia32_ptestc128 (v2di, v2di)
17540 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17541 int __builtin_ia32_ptestz128 (v2di, v2di)
17542 v2df __builtin_ia32_roundpd (v2df, const int)
17543 v4sf __builtin_ia32_roundps (v4sf, const int)
17544 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17545 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17546 @end smallexample
17547
17548 The following built-in functions are available when @option{-msse4.1} is
17549 used.
17550
17551 @table @code
17552 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17553 Generates the @code{insertps} machine instruction.
17554 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17555 Generates the @code{pextrb} machine instruction.
17556 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17557 Generates the @code{pinsrb} machine instruction.
17558 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17559 Generates the @code{pinsrd} machine instruction.
17560 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17561 Generates the @code{pinsrq} machine instruction in 64bit mode.
17562 @end table
17563
17564 The following built-in functions are changed to generate new SSE4.1
17565 instructions when @option{-msse4.1} is used.
17566
17567 @table @code
17568 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17569 Generates the @code{extractps} machine instruction.
17570 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17571 Generates the @code{pextrd} machine instruction.
17572 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17573 Generates the @code{pextrq} machine instruction in 64bit mode.
17574 @end table
17575
17576 The following built-in functions are available when @option{-msse4.2} is
17577 used. All of them generate the machine instruction that is part of the
17578 name.
17579
17580 @smallexample
17581 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17582 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17583 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17584 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17585 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17586 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17587 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17588 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17589 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17590 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17591 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17592 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17593 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17594 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17595 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17596 @end smallexample
17597
17598 The following built-in functions are available when @option{-msse4.2} is
17599 used.
17600
17601 @table @code
17602 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17603 Generates the @code{crc32b} machine instruction.
17604 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17605 Generates the @code{crc32w} machine instruction.
17606 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17607 Generates the @code{crc32l} machine instruction.
17608 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17609 Generates the @code{crc32q} machine instruction.
17610 @end table
17611
17612 The following built-in functions are changed to generate new SSE4.2
17613 instructions when @option{-msse4.2} is used.
17614
17615 @table @code
17616 @item int __builtin_popcount (unsigned int)
17617 Generates the @code{popcntl} machine instruction.
17618 @item int __builtin_popcountl (unsigned long)
17619 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17620 depending on the size of @code{unsigned long}.
17621 @item int __builtin_popcountll (unsigned long long)
17622 Generates the @code{popcntq} machine instruction.
17623 @end table
17624
17625 The following built-in functions are available when @option{-mavx} is
17626 used. All of them generate the machine instruction that is part of the
17627 name.
17628
17629 @smallexample
17630 v4df __builtin_ia32_addpd256 (v4df,v4df)
17631 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17632 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17633 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17634 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17635 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17636 v4df __builtin_ia32_andpd256 (v4df,v4df)
17637 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17638 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17639 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17640 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17641 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17642 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17643 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17644 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17645 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17646 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17647 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17648 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17649 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17650 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17651 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17652 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17653 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17654 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17655 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17656 v4df __builtin_ia32_divpd256 (v4df,v4df)
17657 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17658 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17659 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17660 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17661 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17662 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17663 v32qi __builtin_ia32_lddqu256 (pcchar)
17664 v32qi __builtin_ia32_loaddqu256 (pcchar)
17665 v4df __builtin_ia32_loadupd256 (pcdouble)
17666 v8sf __builtin_ia32_loadups256 (pcfloat)
17667 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17668 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17669 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17670 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17671 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17672 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17673 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17674 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17675 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17676 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17677 v4df __builtin_ia32_minpd256 (v4df,v4df)
17678 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17679 v4df __builtin_ia32_movddup256 (v4df)
17680 int __builtin_ia32_movmskpd256 (v4df)
17681 int __builtin_ia32_movmskps256 (v8sf)
17682 v8sf __builtin_ia32_movshdup256 (v8sf)
17683 v8sf __builtin_ia32_movsldup256 (v8sf)
17684 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17685 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17686 v4df __builtin_ia32_orpd256 (v4df,v4df)
17687 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17688 v2df __builtin_ia32_pd_pd256 (v4df)
17689 v4df __builtin_ia32_pd256_pd (v2df)
17690 v4sf __builtin_ia32_ps_ps256 (v8sf)
17691 v8sf __builtin_ia32_ps256_ps (v4sf)
17692 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17693 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17694 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17695 v8sf __builtin_ia32_rcpps256 (v8sf)
17696 v4df __builtin_ia32_roundpd256 (v4df,int)
17697 v8sf __builtin_ia32_roundps256 (v8sf,int)
17698 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17699 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17700 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17701 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17702 v4si __builtin_ia32_si_si256 (v8si)
17703 v8si __builtin_ia32_si256_si (v4si)
17704 v4df __builtin_ia32_sqrtpd256 (v4df)
17705 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17706 v8sf __builtin_ia32_sqrtps256 (v8sf)
17707 void __builtin_ia32_storedqu256 (pchar,v32qi)
17708 void __builtin_ia32_storeupd256 (pdouble,v4df)
17709 void __builtin_ia32_storeups256 (pfloat,v8sf)
17710 v4df __builtin_ia32_subpd256 (v4df,v4df)
17711 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17712 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17713 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17714 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17715 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17716 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17717 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17718 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17719 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17720 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17721 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17722 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17723 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17724 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17725 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17726 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17727 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17728 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17729 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17730 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17731 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17732 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17733 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17734 v2df __builtin_ia32_vpermilpd (v2df,int)
17735 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17736 v4sf __builtin_ia32_vpermilps (v4sf,int)
17737 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17738 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17739 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17740 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17741 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17742 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17743 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17744 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17745 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17746 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17747 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17748 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17749 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17750 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17751 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17752 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17753 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17754 void __builtin_ia32_vzeroall (void)
17755 void __builtin_ia32_vzeroupper (void)
17756 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17757 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17758 @end smallexample
17759
17760 The following built-in functions are available when @option{-mavx2} is
17761 used. All of them generate the machine instruction that is part of the
17762 name.
17763
17764 @smallexample
17765 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17766 v32qi __builtin_ia32_pabsb256 (v32qi)
17767 v16hi __builtin_ia32_pabsw256 (v16hi)
17768 v8si __builtin_ia32_pabsd256 (v8si)
17769 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17770 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17771 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17772 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17773 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17774 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17775 v8si __builtin_ia32_paddd256 (v8si,v8si)
17776 v4di __builtin_ia32_paddq256 (v4di,v4di)
17777 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17778 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17779 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17780 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17781 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17782 v4di __builtin_ia32_andsi256 (v4di,v4di)
17783 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17784 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17785 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17786 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17787 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17788 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17789 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17790 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17791 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17792 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17793 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17794 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17795 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17796 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17797 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17798 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17799 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17800 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17801 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17802 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17803 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17804 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17805 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17806 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17807 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17808 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17809 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17810 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17811 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17812 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17813 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17814 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17815 v8si __builtin_ia32_pminud256 (v8si,v8si)
17816 int __builtin_ia32_pmovmskb256 (v32qi)
17817 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17818 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17819 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17820 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17821 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17822 v4di __builtin_ia32_pmovsxdq256 (v4si)
17823 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17824 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17825 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17826 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17827 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17828 v4di __builtin_ia32_pmovzxdq256 (v4si)
17829 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17830 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17831 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17832 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17833 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17834 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17835 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17836 v4di __builtin_ia32_por256 (v4di,v4di)
17837 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17838 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17839 v8si __builtin_ia32_pshufd256 (v8si,int)
17840 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17841 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17842 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17843 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17844 v8si __builtin_ia32_psignd256 (v8si,v8si)
17845 v4di __builtin_ia32_pslldqi256 (v4di,int)
17846 v16hi __builtin_ia32_psllwi256 (16hi,int)
17847 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17848 v8si __builtin_ia32_pslldi256 (v8si,int)
17849 v8si __builtin_ia32_pslld256(v8si,v4si)
17850 v4di __builtin_ia32_psllqi256 (v4di,int)
17851 v4di __builtin_ia32_psllq256(v4di,v2di)
17852 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17853 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17854 v8si __builtin_ia32_psradi256 (v8si,int)
17855 v8si __builtin_ia32_psrad256 (v8si,v4si)
17856 v4di __builtin_ia32_psrldqi256 (v4di, int)
17857 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17858 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17859 v8si __builtin_ia32_psrldi256 (v8si,int)
17860 v8si __builtin_ia32_psrld256 (v8si,v4si)
17861 v4di __builtin_ia32_psrlqi256 (v4di,int)
17862 v4di __builtin_ia32_psrlq256(v4di,v2di)
17863 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17864 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17865 v8si __builtin_ia32_psubd256 (v8si,v8si)
17866 v4di __builtin_ia32_psubq256 (v4di,v4di)
17867 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17868 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17869 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17870 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17871 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17872 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17873 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17874 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
17875 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
17876 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
17877 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
17878 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
17879 v4di __builtin_ia32_pxor256 (v4di,v4di)
17880 v4di __builtin_ia32_movntdqa256 (pv4di)
17881 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
17882 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
17883 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
17884 v4di __builtin_ia32_vbroadcastsi256 (v2di)
17885 v4si __builtin_ia32_pblendd128 (v4si,v4si)
17886 v8si __builtin_ia32_pblendd256 (v8si,v8si)
17887 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
17888 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
17889 v8si __builtin_ia32_pbroadcastd256 (v4si)
17890 v4di __builtin_ia32_pbroadcastq256 (v2di)
17891 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
17892 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
17893 v4si __builtin_ia32_pbroadcastd128 (v4si)
17894 v2di __builtin_ia32_pbroadcastq128 (v2di)
17895 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
17896 v4df __builtin_ia32_permdf256 (v4df,int)
17897 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
17898 v4di __builtin_ia32_permdi256 (v4di,int)
17899 v4di __builtin_ia32_permti256 (v4di,v4di,int)
17900 v4di __builtin_ia32_extract128i256 (v4di,int)
17901 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
17902 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
17903 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
17904 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
17905 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
17906 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
17907 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
17908 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
17909 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
17910 v8si __builtin_ia32_psllv8si (v8si,v8si)
17911 v4si __builtin_ia32_psllv4si (v4si,v4si)
17912 v4di __builtin_ia32_psllv4di (v4di,v4di)
17913 v2di __builtin_ia32_psllv2di (v2di,v2di)
17914 v8si __builtin_ia32_psrav8si (v8si,v8si)
17915 v4si __builtin_ia32_psrav4si (v4si,v4si)
17916 v8si __builtin_ia32_psrlv8si (v8si,v8si)
17917 v4si __builtin_ia32_psrlv4si (v4si,v4si)
17918 v4di __builtin_ia32_psrlv4di (v4di,v4di)
17919 v2di __builtin_ia32_psrlv2di (v2di,v2di)
17920 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
17921 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
17922 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
17923 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
17924 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
17925 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
17926 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
17927 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
17928 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
17929 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
17930 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
17931 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
17932 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
17933 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
17934 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
17935 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
17936 @end smallexample
17937
17938 The following built-in functions are available when @option{-maes} is
17939 used. All of them generate the machine instruction that is part of the
17940 name.
17941
17942 @smallexample
17943 v2di __builtin_ia32_aesenc128 (v2di, v2di)
17944 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
17945 v2di __builtin_ia32_aesdec128 (v2di, v2di)
17946 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
17947 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
17948 v2di __builtin_ia32_aesimc128 (v2di)
17949 @end smallexample
17950
17951 The following built-in function is available when @option{-mpclmul} is
17952 used.
17953
17954 @table @code
17955 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
17956 Generates the @code{pclmulqdq} machine instruction.
17957 @end table
17958
17959 The following built-in function is available when @option{-mfsgsbase} is
17960 used. All of them generate the machine instruction that is part of the
17961 name.
17962
17963 @smallexample
17964 unsigned int __builtin_ia32_rdfsbase32 (void)
17965 unsigned long long __builtin_ia32_rdfsbase64 (void)
17966 unsigned int __builtin_ia32_rdgsbase32 (void)
17967 unsigned long long __builtin_ia32_rdgsbase64 (void)
17968 void _writefsbase_u32 (unsigned int)
17969 void _writefsbase_u64 (unsigned long long)
17970 void _writegsbase_u32 (unsigned int)
17971 void _writegsbase_u64 (unsigned long long)
17972 @end smallexample
17973
17974 The following built-in function is available when @option{-mrdrnd} is
17975 used. All of them generate the machine instruction that is part of the
17976 name.
17977
17978 @smallexample
17979 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
17980 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
17981 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
17982 @end smallexample
17983
17984 The following built-in functions are available when @option{-msse4a} is used.
17985 All of them generate the machine instruction that is part of the name.
17986
17987 @smallexample
17988 void __builtin_ia32_movntsd (double *, v2df)
17989 void __builtin_ia32_movntss (float *, v4sf)
17990 v2di __builtin_ia32_extrq (v2di, v16qi)
17991 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
17992 v2di __builtin_ia32_insertq (v2di, v2di)
17993 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
17994 @end smallexample
17995
17996 The following built-in functions are available when @option{-mxop} is used.
17997 @smallexample
17998 v2df __builtin_ia32_vfrczpd (v2df)
17999 v4sf __builtin_ia32_vfrczps (v4sf)
18000 v2df __builtin_ia32_vfrczsd (v2df)
18001 v4sf __builtin_ia32_vfrczss (v4sf)
18002 v4df __builtin_ia32_vfrczpd256 (v4df)
18003 v8sf __builtin_ia32_vfrczps256 (v8sf)
18004 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18005 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18006 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18007 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18008 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18009 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18010 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18011 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18012 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18013 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18014 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18015 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18016 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18017 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18018 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18019 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18020 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18021 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18022 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18023 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18024 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18025 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18026 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18027 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18028 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18029 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18030 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18031 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18032 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18033 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18034 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18035 v4si __builtin_ia32_vpcomged (v4si, v4si)
18036 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18037 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18038 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18039 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18040 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18041 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18042 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18043 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18044 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18045 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18046 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18047 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18048 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18049 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18050 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18051 v4si __builtin_ia32_vpcomled (v4si, v4si)
18052 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18053 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18054 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18055 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18056 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18057 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18058 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18059 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18060 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18061 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18062 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18063 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18064 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18065 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18066 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18067 v4si __builtin_ia32_vpcomned (v4si, v4si)
18068 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18069 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18070 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18071 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18072 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18073 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18074 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18075 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18076 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18077 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18078 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18079 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18080 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18081 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18082 v4si __builtin_ia32_vphaddbd (v16qi)
18083 v2di __builtin_ia32_vphaddbq (v16qi)
18084 v8hi __builtin_ia32_vphaddbw (v16qi)
18085 v2di __builtin_ia32_vphadddq (v4si)
18086 v4si __builtin_ia32_vphaddubd (v16qi)
18087 v2di __builtin_ia32_vphaddubq (v16qi)
18088 v8hi __builtin_ia32_vphaddubw (v16qi)
18089 v2di __builtin_ia32_vphaddudq (v4si)
18090 v4si __builtin_ia32_vphadduwd (v8hi)
18091 v2di __builtin_ia32_vphadduwq (v8hi)
18092 v4si __builtin_ia32_vphaddwd (v8hi)
18093 v2di __builtin_ia32_vphaddwq (v8hi)
18094 v8hi __builtin_ia32_vphsubbw (v16qi)
18095 v2di __builtin_ia32_vphsubdq (v4si)
18096 v4si __builtin_ia32_vphsubwd (v8hi)
18097 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18098 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18099 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18100 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18101 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18102 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18103 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18104 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18105 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18106 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18107 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18108 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18109 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18110 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18111 v4si __builtin_ia32_vprotd (v4si, v4si)
18112 v2di __builtin_ia32_vprotq (v2di, v2di)
18113 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18114 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18115 v4si __builtin_ia32_vpshad (v4si, v4si)
18116 v2di __builtin_ia32_vpshaq (v2di, v2di)
18117 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18118 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18119 v4si __builtin_ia32_vpshld (v4si, v4si)
18120 v2di __builtin_ia32_vpshlq (v2di, v2di)
18121 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18122 @end smallexample
18123
18124 The following built-in functions are available when @option{-mfma4} is used.
18125 All of them generate the machine instruction that is part of the name.
18126
18127 @smallexample
18128 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18129 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18130 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18131 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18132 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18133 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18134 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18135 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18136 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18137 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18138 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18139 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18140 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18141 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18142 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18143 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18144 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18145 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18146 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18147 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18148 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18149 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18150 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18151 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18152 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18153 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18154 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18155 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18156 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18157 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18158 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18159 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18160
18161 @end smallexample
18162
18163 The following built-in functions are available when @option{-mlwp} is used.
18164
18165 @smallexample
18166 void __builtin_ia32_llwpcb16 (void *);
18167 void __builtin_ia32_llwpcb32 (void *);
18168 void __builtin_ia32_llwpcb64 (void *);
18169 void * __builtin_ia32_llwpcb16 (void);
18170 void * __builtin_ia32_llwpcb32 (void);
18171 void * __builtin_ia32_llwpcb64 (void);
18172 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18173 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18174 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18175 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18176 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18177 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18178 @end smallexample
18179
18180 The following built-in functions are available when @option{-mbmi} is used.
18181 All of them generate the machine instruction that is part of the name.
18182 @smallexample
18183 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18184 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18185 @end smallexample
18186
18187 The following built-in functions are available when @option{-mbmi2} is used.
18188 All of them generate the machine instruction that is part of the name.
18189 @smallexample
18190 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18191 unsigned int _pdep_u32 (unsigned int, unsigned int)
18192 unsigned int _pext_u32 (unsigned int, unsigned int)
18193 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18194 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18195 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18196 @end smallexample
18197
18198 The following built-in functions are available when @option{-mlzcnt} is used.
18199 All of them generate the machine instruction that is part of the name.
18200 @smallexample
18201 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18202 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18203 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18204 @end smallexample
18205
18206 The following built-in functions are available when @option{-mfxsr} is used.
18207 All of them generate the machine instruction that is part of the name.
18208 @smallexample
18209 void __builtin_ia32_fxsave (void *)
18210 void __builtin_ia32_fxrstor (void *)
18211 void __builtin_ia32_fxsave64 (void *)
18212 void __builtin_ia32_fxrstor64 (void *)
18213 @end smallexample
18214
18215 The following built-in functions are available when @option{-mxsave} is used.
18216 All of them generate the machine instruction that is part of the name.
18217 @smallexample
18218 void __builtin_ia32_xsave (void *, long long)
18219 void __builtin_ia32_xrstor (void *, long long)
18220 void __builtin_ia32_xsave64 (void *, long long)
18221 void __builtin_ia32_xrstor64 (void *, long long)
18222 @end smallexample
18223
18224 The following built-in functions are available when @option{-mxsaveopt} is used.
18225 All of them generate the machine instruction that is part of the name.
18226 @smallexample
18227 void __builtin_ia32_xsaveopt (void *, long long)
18228 void __builtin_ia32_xsaveopt64 (void *, long long)
18229 @end smallexample
18230
18231 The following built-in functions are available when @option{-mtbm} is used.
18232 Both of them generate the immediate form of the bextr machine instruction.
18233 @smallexample
18234 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18235 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18236 @end smallexample
18237
18238
18239 The following built-in functions are available when @option{-m3dnow} is used.
18240 All of them generate the machine instruction that is part of the name.
18241
18242 @smallexample
18243 void __builtin_ia32_femms (void)
18244 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18245 v2si __builtin_ia32_pf2id (v2sf)
18246 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18247 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18248 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18249 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18250 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18251 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18252 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18253 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18254 v2sf __builtin_ia32_pfrcp (v2sf)
18255 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18256 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18257 v2sf __builtin_ia32_pfrsqrt (v2sf)
18258 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18259 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18260 v2sf __builtin_ia32_pi2fd (v2si)
18261 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18262 @end smallexample
18263
18264 The following built-in functions are available when both @option{-m3dnow}
18265 and @option{-march=athlon} are used. All of them generate the machine
18266 instruction that is part of the name.
18267
18268 @smallexample
18269 v2si __builtin_ia32_pf2iw (v2sf)
18270 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18271 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18272 v2sf __builtin_ia32_pi2fw (v2si)
18273 v2sf __builtin_ia32_pswapdsf (v2sf)
18274 v2si __builtin_ia32_pswapdsi (v2si)
18275 @end smallexample
18276
18277 The following built-in functions are available when @option{-mrtm} is used
18278 They are used for restricted transactional memory. These are the internal
18279 low level functions. Normally the functions in
18280 @ref{x86 transactional memory intrinsics} should be used instead.
18281
18282 @smallexample
18283 int __builtin_ia32_xbegin ()
18284 void __builtin_ia32_xend ()
18285 void __builtin_ia32_xabort (status)
18286 int __builtin_ia32_xtest ()
18287 @end smallexample
18288
18289 The following built-in functions are available when @option{-mmwaitx} is used.
18290 All of them generate the machine instruction that is part of the name.
18291 @smallexample
18292 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18293 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18294 @end smallexample
18295
18296 @node x86 transactional memory intrinsics
18297 @subsection x86 Transactional Memory Intrinsics
18298
18299 These hardware transactional memory intrinsics for x86 allow you to use
18300 memory transactions with RTM (Restricted Transactional Memory).
18301 This support is enabled with the @option{-mrtm} option.
18302 For using HLE (Hardware Lock Elision) see
18303 @ref{x86 specific memory model extensions for transactional memory} instead.
18304
18305 A memory transaction commits all changes to memory in an atomic way,
18306 as visible to other threads. If the transaction fails it is rolled back
18307 and all side effects discarded.
18308
18309 Generally there is no guarantee that a memory transaction ever succeeds
18310 and suitable fallback code always needs to be supplied.
18311
18312 @deftypefn {RTM Function} {unsigned} _xbegin ()
18313 Start a RTM (Restricted Transactional Memory) transaction.
18314 Returns @code{_XBEGIN_STARTED} when the transaction
18315 started successfully (note this is not 0, so the constant has to be
18316 explicitly tested).
18317
18318 If the transaction aborts, all side-effects
18319 are undone and an abort code encoded as a bit mask is returned.
18320 The following macros are defined:
18321
18322 @table @code
18323 @item _XABORT_EXPLICIT
18324 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18325 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18326 @item _XABORT_RETRY
18327 Transaction retry is possible.
18328 @item _XABORT_CONFLICT
18329 Transaction abort due to a memory conflict with another thread.
18330 @item _XABORT_CAPACITY
18331 Transaction abort due to the transaction using too much memory.
18332 @item _XABORT_DEBUG
18333 Transaction abort due to a debug trap.
18334 @item _XABORT_NESTED
18335 Transaction abort in an inner nested transaction.
18336 @end table
18337
18338 There is no guarantee
18339 any transaction ever succeeds, so there always needs to be a valid
18340 fallback path.
18341 @end deftypefn
18342
18343 @deftypefn {RTM Function} {void} _xend ()
18344 Commit the current transaction. When no transaction is active this faults.
18345 All memory side-effects of the transaction become visible
18346 to other threads in an atomic manner.
18347 @end deftypefn
18348
18349 @deftypefn {RTM Function} {int} _xtest ()
18350 Return a nonzero value if a transaction is currently active, otherwise 0.
18351 @end deftypefn
18352
18353 @deftypefn {RTM Function} {void} _xabort (status)
18354 Abort the current transaction. When no transaction is active this is a no-op.
18355 The @var{status} is an 8-bit constant; its value is encoded in the return
18356 value from @code{_xbegin}.
18357 @end deftypefn
18358
18359 Here is an example showing handling for @code{_XABORT_RETRY}
18360 and a fallback path for other failures:
18361
18362 @smallexample
18363 #include <immintrin.h>
18364
18365 int n_tries, max_tries;
18366 unsigned status = _XABORT_EXPLICIT;
18367 ...
18368
18369 for (n_tries = 0; n_tries < max_tries; n_tries++)
18370 @{
18371 status = _xbegin ();
18372 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18373 break;
18374 @}
18375 if (status == _XBEGIN_STARTED)
18376 @{
18377 ... transaction code...
18378 _xend ();
18379 @}
18380 else
18381 @{
18382 ... non-transactional fallback path...
18383 @}
18384 @end smallexample
18385
18386 @noindent
18387 Note that, in most cases, the transactional and non-transactional code
18388 must synchronize together to ensure consistency.
18389
18390 @node Target Format Checks
18391 @section Format Checks Specific to Particular Target Machines
18392
18393 For some target machines, GCC supports additional options to the
18394 format attribute
18395 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18396
18397 @menu
18398 * Solaris Format Checks::
18399 * Darwin Format Checks::
18400 @end menu
18401
18402 @node Solaris Format Checks
18403 @subsection Solaris Format Checks
18404
18405 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18406 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18407 conversions, and the two-argument @code{%b} conversion for displaying
18408 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18409
18410 @node Darwin Format Checks
18411 @subsection Darwin Format Checks
18412
18413 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18414 attribute context. Declarations made with such attribution are parsed for correct syntax
18415 and format argument types. However, parsing of the format string itself is currently undefined
18416 and is not carried out by this version of the compiler.
18417
18418 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18419 also be used as format arguments. Note that the relevant headers are only likely to be
18420 available on Darwin (OSX) installations. On such installations, the XCode and system
18421 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18422 associated functions.
18423
18424 @node Pragmas
18425 @section Pragmas Accepted by GCC
18426 @cindex pragmas
18427 @cindex @code{#pragma}
18428
18429 GCC supports several types of pragmas, primarily in order to compile
18430 code originally written for other compilers. Note that in general
18431 we do not recommend the use of pragmas; @xref{Function Attributes},
18432 for further explanation.
18433
18434 @menu
18435 * AArch64 Pragmas::
18436 * ARM Pragmas::
18437 * M32C Pragmas::
18438 * MeP Pragmas::
18439 * RS/6000 and PowerPC Pragmas::
18440 * Darwin Pragmas::
18441 * Solaris Pragmas::
18442 * Symbol-Renaming Pragmas::
18443 * Structure-Layout Pragmas::
18444 * Weak Pragmas::
18445 * Diagnostic Pragmas::
18446 * Visibility Pragmas::
18447 * Push/Pop Macro Pragmas::
18448 * Function Specific Option Pragmas::
18449 * Loop-Specific Pragmas::
18450 @end menu
18451
18452 @node AArch64 Pragmas
18453 @subsection AArch64 Pragmas
18454
18455 The pragmas defined by the AArch64 target correspond to the AArch64
18456 target function attributes. They can be specified as below:
18457 @smallexample
18458 #pragma GCC target("string")
18459 @end smallexample
18460
18461 where @code{@var{string}} can be any string accepted as an AArch64 target
18462 attribute. @xref{AArch64 Function Attributes}, for more details
18463 on the permissible values of @code{string}.
18464
18465 @node ARM Pragmas
18466 @subsection ARM Pragmas
18467
18468 The ARM target defines pragmas for controlling the default addition of
18469 @code{long_call} and @code{short_call} attributes to functions.
18470 @xref{Function Attributes}, for information about the effects of these
18471 attributes.
18472
18473 @table @code
18474 @item long_calls
18475 @cindex pragma, long_calls
18476 Set all subsequent functions to have the @code{long_call} attribute.
18477
18478 @item no_long_calls
18479 @cindex pragma, no_long_calls
18480 Set all subsequent functions to have the @code{short_call} attribute.
18481
18482 @item long_calls_off
18483 @cindex pragma, long_calls_off
18484 Do not affect the @code{long_call} or @code{short_call} attributes of
18485 subsequent functions.
18486 @end table
18487
18488 @node M32C Pragmas
18489 @subsection M32C Pragmas
18490
18491 @table @code
18492 @item GCC memregs @var{number}
18493 @cindex pragma, memregs
18494 Overrides the command-line option @code{-memregs=} for the current
18495 file. Use with care! This pragma must be before any function in the
18496 file, and mixing different memregs values in different objects may
18497 make them incompatible. This pragma is useful when a
18498 performance-critical function uses a memreg for temporary values,
18499 as it may allow you to reduce the number of memregs used.
18500
18501 @item ADDRESS @var{name} @var{address}
18502 @cindex pragma, address
18503 For any declared symbols matching @var{name}, this does three things
18504 to that symbol: it forces the symbol to be located at the given
18505 address (a number), it forces the symbol to be volatile, and it
18506 changes the symbol's scope to be static. This pragma exists for
18507 compatibility with other compilers, but note that the common
18508 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18509 instead). Example:
18510
18511 @smallexample
18512 #pragma ADDRESS port3 0x103
18513 char port3;
18514 @end smallexample
18515
18516 @end table
18517
18518 @node MeP Pragmas
18519 @subsection MeP Pragmas
18520
18521 @table @code
18522
18523 @item custom io_volatile (on|off)
18524 @cindex pragma, custom io_volatile
18525 Overrides the command-line option @code{-mio-volatile} for the current
18526 file. Note that for compatibility with future GCC releases, this
18527 option should only be used once before any @code{io} variables in each
18528 file.
18529
18530 @item GCC coprocessor available @var{registers}
18531 @cindex pragma, coprocessor available
18532 Specifies which coprocessor registers are available to the register
18533 allocator. @var{registers} may be a single register, register range
18534 separated by ellipses, or comma-separated list of those. Example:
18535
18536 @smallexample
18537 #pragma GCC coprocessor available $c0...$c10, $c28
18538 @end smallexample
18539
18540 @item GCC coprocessor call_saved @var{registers}
18541 @cindex pragma, coprocessor call_saved
18542 Specifies which coprocessor registers are to be saved and restored by
18543 any function using them. @var{registers} may be a single register,
18544 register range separated by ellipses, or comma-separated list of
18545 those. Example:
18546
18547 @smallexample
18548 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18549 @end smallexample
18550
18551 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18552 @cindex pragma, coprocessor subclass
18553 Creates and defines a register class. These register classes can be
18554 used by inline @code{asm} constructs. @var{registers} may be a single
18555 register, register range separated by ellipses, or comma-separated
18556 list of those. Example:
18557
18558 @smallexample
18559 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18560
18561 asm ("cpfoo %0" : "=B" (x));
18562 @end smallexample
18563
18564 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18565 @cindex pragma, disinterrupt
18566 For the named functions, the compiler adds code to disable interrupts
18567 for the duration of those functions. If any functions so named
18568 are not encountered in the source, a warning is emitted that the pragma is
18569 not used. Examples:
18570
18571 @smallexample
18572 #pragma disinterrupt foo
18573 #pragma disinterrupt bar, grill
18574 int foo () @{ @dots{} @}
18575 @end smallexample
18576
18577 @item GCC call @var{name} , @var{name} @dots{}
18578 @cindex pragma, call
18579 For the named functions, the compiler always uses a register-indirect
18580 call model when calling the named functions. Examples:
18581
18582 @smallexample
18583 extern int foo ();
18584 #pragma call foo
18585 @end smallexample
18586
18587 @end table
18588
18589 @node RS/6000 and PowerPC Pragmas
18590 @subsection RS/6000 and PowerPC Pragmas
18591
18592 The RS/6000 and PowerPC targets define one pragma for controlling
18593 whether or not the @code{longcall} attribute is added to function
18594 declarations by default. This pragma overrides the @option{-mlongcall}
18595 option, but not the @code{longcall} and @code{shortcall} attributes.
18596 @xref{RS/6000 and PowerPC Options}, for more information about when long
18597 calls are and are not necessary.
18598
18599 @table @code
18600 @item longcall (1)
18601 @cindex pragma, longcall
18602 Apply the @code{longcall} attribute to all subsequent function
18603 declarations.
18604
18605 @item longcall (0)
18606 Do not apply the @code{longcall} attribute to subsequent function
18607 declarations.
18608 @end table
18609
18610 @c Describe h8300 pragmas here.
18611 @c Describe sh pragmas here.
18612 @c Describe v850 pragmas here.
18613
18614 @node Darwin Pragmas
18615 @subsection Darwin Pragmas
18616
18617 The following pragmas are available for all architectures running the
18618 Darwin operating system. These are useful for compatibility with other
18619 Mac OS compilers.
18620
18621 @table @code
18622 @item mark @var{tokens}@dots{}
18623 @cindex pragma, mark
18624 This pragma is accepted, but has no effect.
18625
18626 @item options align=@var{alignment}
18627 @cindex pragma, options align
18628 This pragma sets the alignment of fields in structures. The values of
18629 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18630 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
18631 properly; to restore the previous setting, use @code{reset} for the
18632 @var{alignment}.
18633
18634 @item segment @var{tokens}@dots{}
18635 @cindex pragma, segment
18636 This pragma is accepted, but has no effect.
18637
18638 @item unused (@var{var} [, @var{var}]@dots{})
18639 @cindex pragma, unused
18640 This pragma declares variables to be possibly unused. GCC does not
18641 produce warnings for the listed variables. The effect is similar to
18642 that of the @code{unused} attribute, except that this pragma may appear
18643 anywhere within the variables' scopes.
18644 @end table
18645
18646 @node Solaris Pragmas
18647 @subsection Solaris Pragmas
18648
18649 The Solaris target supports @code{#pragma redefine_extname}
18650 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
18651 @code{#pragma} directives for compatibility with the system compiler.
18652
18653 @table @code
18654 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18655 @cindex pragma, align
18656
18657 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18658 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18659 Attributes}). Macro expansion occurs on the arguments to this pragma
18660 when compiling C and Objective-C@. It does not currently occur when
18661 compiling C++, but this is a bug which may be fixed in a future
18662 release.
18663
18664 @item fini (@var{function} [, @var{function}]...)
18665 @cindex pragma, fini
18666
18667 This pragma causes each listed @var{function} to be called after
18668 main, or during shared module unloading, by adding a call to the
18669 @code{.fini} section.
18670
18671 @item init (@var{function} [, @var{function}]...)
18672 @cindex pragma, init
18673
18674 This pragma causes each listed @var{function} to be called during
18675 initialization (before @code{main}) or during shared module loading, by
18676 adding a call to the @code{.init} section.
18677
18678 @end table
18679
18680 @node Symbol-Renaming Pragmas
18681 @subsection Symbol-Renaming Pragmas
18682
18683 GCC supports a @code{#pragma} directive that changes the name used in
18684 assembly for a given declaration. While this pragma is supported on all
18685 platforms, it is intended primarily to provide compatibility with the
18686 Solaris system headers. This effect can also be achieved using the asm
18687 labels extension (@pxref{Asm Labels}).
18688
18689 @table @code
18690 @item redefine_extname @var{oldname} @var{newname}
18691 @cindex pragma, redefine_extname
18692
18693 This pragma gives the C function @var{oldname} the assembly symbol
18694 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18695 is defined if this pragma is available (currently on all platforms).
18696 @end table
18697
18698 This pragma and the asm labels extension interact in a complicated
18699 manner. Here are some corner cases you may want to be aware of:
18700
18701 @enumerate
18702 @item This pragma silently applies only to declarations with external
18703 linkage. Asm labels do not have this restriction.
18704
18705 @item In C++, this pragma silently applies only to declarations with
18706 ``C'' linkage. Again, asm labels do not have this restriction.
18707
18708 @item If either of the ways of changing the assembly name of a
18709 declaration are applied to a declaration whose assembly name has
18710 already been determined (either by a previous use of one of these
18711 features, or because the compiler needed the assembly name in order to
18712 generate code), and the new name is different, a warning issues and
18713 the name does not change.
18714
18715 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18716 always the C-language name.
18717 @end enumerate
18718
18719 @node Structure-Layout Pragmas
18720 @subsection Structure-Layout Pragmas
18721
18722 For compatibility with Microsoft Windows compilers, GCC supports a
18723 set of @code{#pragma} directives that change the maximum alignment of
18724 members of structures (other than zero-width bit-fields), unions, and
18725 classes subsequently defined. The @var{n} value below always is required
18726 to be a small power of two and specifies the new alignment in bytes.
18727
18728 @enumerate
18729 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18730 @item @code{#pragma pack()} sets the alignment to the one that was in
18731 effect when compilation started (see also command-line option
18732 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18733 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18734 setting on an internal stack and then optionally sets the new alignment.
18735 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18736 saved at the top of the internal stack (and removes that stack entry).
18737 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18738 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18739 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18740 @code{#pragma pack(pop)}.
18741 @end enumerate
18742
18743 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
18744 directive which lays out structures and unions subsequently defined as the
18745 documented @code{__attribute__ ((ms_struct))}.
18746
18747 @enumerate
18748 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
18749 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
18750 @item @code{#pragma ms_struct reset} goes back to the default layout.
18751 @end enumerate
18752
18753 Most targets also support the @code{#pragma scalar_storage_order} directive
18754 which lays out structures and unions subsequently defined as the documented
18755 @code{__attribute__ ((scalar_storage_order))}.
18756
18757 @enumerate
18758 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
18759 of the scalar fields to big-endian.
18760 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
18761 of the scalar fields to little-endian.
18762 @item @code{#pragma scalar_storage_order default} goes back to the endianness
18763 that was in effect when compilation started (see also command-line option
18764 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
18765 @end enumerate
18766
18767 @node Weak Pragmas
18768 @subsection Weak Pragmas
18769
18770 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18771 directives for declaring symbols to be weak, and defining weak
18772 aliases.
18773
18774 @table @code
18775 @item #pragma weak @var{symbol}
18776 @cindex pragma, weak
18777 This pragma declares @var{symbol} to be weak, as if the declaration
18778 had the attribute of the same name. The pragma may appear before
18779 or after the declaration of @var{symbol}. It is not an error for
18780 @var{symbol} to never be defined at all.
18781
18782 @item #pragma weak @var{symbol1} = @var{symbol2}
18783 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18784 It is an error if @var{symbol2} is not defined in the current
18785 translation unit.
18786 @end table
18787
18788 @node Diagnostic Pragmas
18789 @subsection Diagnostic Pragmas
18790
18791 GCC allows the user to selectively enable or disable certain types of
18792 diagnostics, and change the kind of the diagnostic. For example, a
18793 project's policy might require that all sources compile with
18794 @option{-Werror} but certain files might have exceptions allowing
18795 specific types of warnings. Or, a project might selectively enable
18796 diagnostics and treat them as errors depending on which preprocessor
18797 macros are defined.
18798
18799 @table @code
18800 @item #pragma GCC diagnostic @var{kind} @var{option}
18801 @cindex pragma, diagnostic
18802
18803 Modifies the disposition of a diagnostic. Note that not all
18804 diagnostics are modifiable; at the moment only warnings (normally
18805 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18806 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18807 are controllable and which option controls them.
18808
18809 @var{kind} is @samp{error} to treat this diagnostic as an error,
18810 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18811 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18812 @var{option} is a double quoted string that matches the command-line
18813 option.
18814
18815 @smallexample
18816 #pragma GCC diagnostic warning "-Wformat"
18817 #pragma GCC diagnostic error "-Wformat"
18818 #pragma GCC diagnostic ignored "-Wformat"
18819 @end smallexample
18820
18821 Note that these pragmas override any command-line options. GCC keeps
18822 track of the location of each pragma, and issues diagnostics according
18823 to the state as of that point in the source file. Thus, pragmas occurring
18824 after a line do not affect diagnostics caused by that line.
18825
18826 @item #pragma GCC diagnostic push
18827 @itemx #pragma GCC diagnostic pop
18828
18829 Causes GCC to remember the state of the diagnostics as of each
18830 @code{push}, and restore to that point at each @code{pop}. If a
18831 @code{pop} has no matching @code{push}, the command-line options are
18832 restored.
18833
18834 @smallexample
18835 #pragma GCC diagnostic error "-Wuninitialized"
18836 foo(a); /* error is given for this one */
18837 #pragma GCC diagnostic push
18838 #pragma GCC diagnostic ignored "-Wuninitialized"
18839 foo(b); /* no diagnostic for this one */
18840 #pragma GCC diagnostic pop
18841 foo(c); /* error is given for this one */
18842 #pragma GCC diagnostic pop
18843 foo(d); /* depends on command-line options */
18844 @end smallexample
18845
18846 @end table
18847
18848 GCC also offers a simple mechanism for printing messages during
18849 compilation.
18850
18851 @table @code
18852 @item #pragma message @var{string}
18853 @cindex pragma, diagnostic
18854
18855 Prints @var{string} as a compiler message on compilation. The message
18856 is informational only, and is neither a compilation warning nor an error.
18857
18858 @smallexample
18859 #pragma message "Compiling " __FILE__ "..."
18860 @end smallexample
18861
18862 @var{string} may be parenthesized, and is printed with location
18863 information. For example,
18864
18865 @smallexample
18866 #define DO_PRAGMA(x) _Pragma (#x)
18867 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
18868
18869 TODO(Remember to fix this)
18870 @end smallexample
18871
18872 @noindent
18873 prints @samp{/tmp/file.c:4: note: #pragma message:
18874 TODO - Remember to fix this}.
18875
18876 @end table
18877
18878 @node Visibility Pragmas
18879 @subsection Visibility Pragmas
18880
18881 @table @code
18882 @item #pragma GCC visibility push(@var{visibility})
18883 @itemx #pragma GCC visibility pop
18884 @cindex pragma, visibility
18885
18886 This pragma allows the user to set the visibility for multiple
18887 declarations without having to give each a visibility attribute
18888 (@pxref{Function Attributes}).
18889
18890 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
18891 declarations. Class members and template specializations are not
18892 affected; if you want to override the visibility for a particular
18893 member or instantiation, you must use an attribute.
18894
18895 @end table
18896
18897
18898 @node Push/Pop Macro Pragmas
18899 @subsection Push/Pop Macro Pragmas
18900
18901 For compatibility with Microsoft Windows compilers, GCC supports
18902 @samp{#pragma push_macro(@var{"macro_name"})}
18903 and @samp{#pragma pop_macro(@var{"macro_name"})}.
18904
18905 @table @code
18906 @item #pragma push_macro(@var{"macro_name"})
18907 @cindex pragma, push_macro
18908 This pragma saves the value of the macro named as @var{macro_name} to
18909 the top of the stack for this macro.
18910
18911 @item #pragma pop_macro(@var{"macro_name"})
18912 @cindex pragma, pop_macro
18913 This pragma sets the value of the macro named as @var{macro_name} to
18914 the value on top of the stack for this macro. If the stack for
18915 @var{macro_name} is empty, the value of the macro remains unchanged.
18916 @end table
18917
18918 For example:
18919
18920 @smallexample
18921 #define X 1
18922 #pragma push_macro("X")
18923 #undef X
18924 #define X -1
18925 #pragma pop_macro("X")
18926 int x [X];
18927 @end smallexample
18928
18929 @noindent
18930 In this example, the definition of X as 1 is saved by @code{#pragma
18931 push_macro} and restored by @code{#pragma pop_macro}.
18932
18933 @node Function Specific Option Pragmas
18934 @subsection Function Specific Option Pragmas
18935
18936 @table @code
18937 @item #pragma GCC target (@var{"string"}...)
18938 @cindex pragma GCC target
18939
18940 This pragma allows you to set target specific options for functions
18941 defined later in the source file. One or more strings can be
18942 specified. Each function that is defined after this point is as
18943 if @code{attribute((target("STRING")))} was specified for that
18944 function. The parenthesis around the options is optional.
18945 @xref{Function Attributes}, for more information about the
18946 @code{target} attribute and the attribute syntax.
18947
18948 The @code{#pragma GCC target} pragma is presently implemented for
18949 x86, PowerPC, and Nios II targets only.
18950 @end table
18951
18952 @table @code
18953 @item #pragma GCC optimize (@var{"string"}...)
18954 @cindex pragma GCC optimize
18955
18956 This pragma allows you to set global optimization options for functions
18957 defined later in the source file. One or more strings can be
18958 specified. Each function that is defined after this point is as
18959 if @code{attribute((optimize("STRING")))} was specified for that
18960 function. The parenthesis around the options is optional.
18961 @xref{Function Attributes}, for more information about the
18962 @code{optimize} attribute and the attribute syntax.
18963 @end table
18964
18965 @table @code
18966 @item #pragma GCC push_options
18967 @itemx #pragma GCC pop_options
18968 @cindex pragma GCC push_options
18969 @cindex pragma GCC pop_options
18970
18971 These pragmas maintain a stack of the current target and optimization
18972 options. It is intended for include files where you temporarily want
18973 to switch to using a different @samp{#pragma GCC target} or
18974 @samp{#pragma GCC optimize} and then to pop back to the previous
18975 options.
18976 @end table
18977
18978 @table @code
18979 @item #pragma GCC reset_options
18980 @cindex pragma GCC reset_options
18981
18982 This pragma clears the current @code{#pragma GCC target} and
18983 @code{#pragma GCC optimize} to use the default switches as specified
18984 on the command line.
18985 @end table
18986
18987 @node Loop-Specific Pragmas
18988 @subsection Loop-Specific Pragmas
18989
18990 @table @code
18991 @item #pragma GCC ivdep
18992 @cindex pragma GCC ivdep
18993 @end table
18994
18995 With this pragma, the programmer asserts that there are no loop-carried
18996 dependencies which would prevent consecutive iterations of
18997 the following loop from executing concurrently with SIMD
18998 (single instruction multiple data) instructions.
18999
19000 For example, the compiler can only unconditionally vectorize the following
19001 loop with the pragma:
19002
19003 @smallexample
19004 void foo (int n, int *a, int *b, int *c)
19005 @{
19006 int i, j;
19007 #pragma GCC ivdep
19008 for (i = 0; i < n; ++i)
19009 a[i] = b[i] + c[i];
19010 @}
19011 @end smallexample
19012
19013 @noindent
19014 In this example, using the @code{restrict} qualifier had the same
19015 effect. In the following example, that would not be possible. Assume
19016 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19017 that it can unconditionally vectorize the following loop:
19018
19019 @smallexample
19020 void ignore_vec_dep (int *a, int k, int c, int m)
19021 @{
19022 #pragma GCC ivdep
19023 for (int i = 0; i < m; i++)
19024 a[i] = a[i + k] * c;
19025 @}
19026 @end smallexample
19027
19028
19029 @node Unnamed Fields
19030 @section Unnamed Structure and Union Fields
19031 @cindex @code{struct}
19032 @cindex @code{union}
19033
19034 As permitted by ISO C11 and for compatibility with other compilers,
19035 GCC allows you to define
19036 a structure or union that contains, as fields, structures and unions
19037 without names. For example:
19038
19039 @smallexample
19040 struct @{
19041 int a;
19042 union @{
19043 int b;
19044 float c;
19045 @};
19046 int d;
19047 @} foo;
19048 @end smallexample
19049
19050 @noindent
19051 In this example, you are able to access members of the unnamed
19052 union with code like @samp{foo.b}. Note that only unnamed structs and
19053 unions are allowed, you may not have, for example, an unnamed
19054 @code{int}.
19055
19056 You must never create such structures that cause ambiguous field definitions.
19057 For example, in this structure:
19058
19059 @smallexample
19060 struct @{
19061 int a;
19062 struct @{
19063 int a;
19064 @};
19065 @} foo;
19066 @end smallexample
19067
19068 @noindent
19069 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19070 The compiler gives errors for such constructs.
19071
19072 @opindex fms-extensions
19073 Unless @option{-fms-extensions} is used, the unnamed field must be a
19074 structure or union definition without a tag (for example, @samp{struct
19075 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19076 also be a definition with a tag such as @samp{struct foo @{ int a;
19077 @};}, a reference to a previously defined structure or union such as
19078 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19079 previously defined structure or union type.
19080
19081 @opindex fplan9-extensions
19082 The option @option{-fplan9-extensions} enables
19083 @option{-fms-extensions} as well as two other extensions. First, a
19084 pointer to a structure is automatically converted to a pointer to an
19085 anonymous field for assignments and function calls. For example:
19086
19087 @smallexample
19088 struct s1 @{ int a; @};
19089 struct s2 @{ struct s1; @};
19090 extern void f1 (struct s1 *);
19091 void f2 (struct s2 *p) @{ f1 (p); @}
19092 @end smallexample
19093
19094 @noindent
19095 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19096 converted into a pointer to the anonymous field.
19097
19098 Second, when the type of an anonymous field is a @code{typedef} for a
19099 @code{struct} or @code{union}, code may refer to the field using the
19100 name of the @code{typedef}.
19101
19102 @smallexample
19103 typedef struct @{ int a; @} s1;
19104 struct s2 @{ s1; @};
19105 s1 f1 (struct s2 *p) @{ return p->s1; @}
19106 @end smallexample
19107
19108 These usages are only permitted when they are not ambiguous.
19109
19110 @node Thread-Local
19111 @section Thread-Local Storage
19112 @cindex Thread-Local Storage
19113 @cindex @acronym{TLS}
19114 @cindex @code{__thread}
19115
19116 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19117 are allocated such that there is one instance of the variable per extant
19118 thread. The runtime model GCC uses to implement this originates
19119 in the IA-64 processor-specific ABI, but has since been migrated
19120 to other processors as well. It requires significant support from
19121 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19122 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19123 is not available everywhere.
19124
19125 At the user level, the extension is visible with a new storage
19126 class keyword: @code{__thread}. For example:
19127
19128 @smallexample
19129 __thread int i;
19130 extern __thread struct state s;
19131 static __thread char *p;
19132 @end smallexample
19133
19134 The @code{__thread} specifier may be used alone, with the @code{extern}
19135 or @code{static} specifiers, but with no other storage class specifier.
19136 When used with @code{extern} or @code{static}, @code{__thread} must appear
19137 immediately after the other storage class specifier.
19138
19139 The @code{__thread} specifier may be applied to any global, file-scoped
19140 static, function-scoped static, or static data member of a class. It may
19141 not be applied to block-scoped automatic or non-static data member.
19142
19143 When the address-of operator is applied to a thread-local variable, it is
19144 evaluated at run time and returns the address of the current thread's
19145 instance of that variable. An address so obtained may be used by any
19146 thread. When a thread terminates, any pointers to thread-local variables
19147 in that thread become invalid.
19148
19149 No static initialization may refer to the address of a thread-local variable.
19150
19151 In C++, if an initializer is present for a thread-local variable, it must
19152 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19153 standard.
19154
19155 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19156 ELF Handling For Thread-Local Storage} for a detailed explanation of
19157 the four thread-local storage addressing models, and how the runtime
19158 is expected to function.
19159
19160 @menu
19161 * C99 Thread-Local Edits::
19162 * C++98 Thread-Local Edits::
19163 @end menu
19164
19165 @node C99 Thread-Local Edits
19166 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19167
19168 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19169 that document the exact semantics of the language extension.
19170
19171 @itemize @bullet
19172 @item
19173 @cite{5.1.2 Execution environments}
19174
19175 Add new text after paragraph 1
19176
19177 @quotation
19178 Within either execution environment, a @dfn{thread} is a flow of
19179 control within a program. It is implementation defined whether
19180 or not there may be more than one thread associated with a program.
19181 It is implementation defined how threads beyond the first are
19182 created, the name and type of the function called at thread
19183 startup, and how threads may be terminated. However, objects
19184 with thread storage duration shall be initialized before thread
19185 startup.
19186 @end quotation
19187
19188 @item
19189 @cite{6.2.4 Storage durations of objects}
19190
19191 Add new text before paragraph 3
19192
19193 @quotation
19194 An object whose identifier is declared with the storage-class
19195 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19196 Its lifetime is the entire execution of the thread, and its
19197 stored value is initialized only once, prior to thread startup.
19198 @end quotation
19199
19200 @item
19201 @cite{6.4.1 Keywords}
19202
19203 Add @code{__thread}.
19204
19205 @item
19206 @cite{6.7.1 Storage-class specifiers}
19207
19208 Add @code{__thread} to the list of storage class specifiers in
19209 paragraph 1.
19210
19211 Change paragraph 2 to
19212
19213 @quotation
19214 With the exception of @code{__thread}, at most one storage-class
19215 specifier may be given [@dots{}]. The @code{__thread} specifier may
19216 be used alone, or immediately following @code{extern} or
19217 @code{static}.
19218 @end quotation
19219
19220 Add new text after paragraph 6
19221
19222 @quotation
19223 The declaration of an identifier for a variable that has
19224 block scope that specifies @code{__thread} shall also
19225 specify either @code{extern} or @code{static}.
19226
19227 The @code{__thread} specifier shall be used only with
19228 variables.
19229 @end quotation
19230 @end itemize
19231
19232 @node C++98 Thread-Local Edits
19233 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19234
19235 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19236 that document the exact semantics of the language extension.
19237
19238 @itemize @bullet
19239 @item
19240 @b{[intro.execution]}
19241
19242 New text after paragraph 4
19243
19244 @quotation
19245 A @dfn{thread} is a flow of control within the abstract machine.
19246 It is implementation defined whether or not there may be more than
19247 one thread.
19248 @end quotation
19249
19250 New text after paragraph 7
19251
19252 @quotation
19253 It is unspecified whether additional action must be taken to
19254 ensure when and whether side effects are visible to other threads.
19255 @end quotation
19256
19257 @item
19258 @b{[lex.key]}
19259
19260 Add @code{__thread}.
19261
19262 @item
19263 @b{[basic.start.main]}
19264
19265 Add after paragraph 5
19266
19267 @quotation
19268 The thread that begins execution at the @code{main} function is called
19269 the @dfn{main thread}. It is implementation defined how functions
19270 beginning threads other than the main thread are designated or typed.
19271 A function so designated, as well as the @code{main} function, is called
19272 a @dfn{thread startup function}. It is implementation defined what
19273 happens if a thread startup function returns. It is implementation
19274 defined what happens to other threads when any thread calls @code{exit}.
19275 @end quotation
19276
19277 @item
19278 @b{[basic.start.init]}
19279
19280 Add after paragraph 4
19281
19282 @quotation
19283 The storage for an object of thread storage duration shall be
19284 statically initialized before the first statement of the thread startup
19285 function. An object of thread storage duration shall not require
19286 dynamic initialization.
19287 @end quotation
19288
19289 @item
19290 @b{[basic.start.term]}
19291
19292 Add after paragraph 3
19293
19294 @quotation
19295 The type of an object with thread storage duration shall not have a
19296 non-trivial destructor, nor shall it be an array type whose elements
19297 (directly or indirectly) have non-trivial destructors.
19298 @end quotation
19299
19300 @item
19301 @b{[basic.stc]}
19302
19303 Add ``thread storage duration'' to the list in paragraph 1.
19304
19305 Change paragraph 2
19306
19307 @quotation
19308 Thread, static, and automatic storage durations are associated with
19309 objects introduced by declarations [@dots{}].
19310 @end quotation
19311
19312 Add @code{__thread} to the list of specifiers in paragraph 3.
19313
19314 @item
19315 @b{[basic.stc.thread]}
19316
19317 New section before @b{[basic.stc.static]}
19318
19319 @quotation
19320 The keyword @code{__thread} applied to a non-local object gives the
19321 object thread storage duration.
19322
19323 A local variable or class data member declared both @code{static}
19324 and @code{__thread} gives the variable or member thread storage
19325 duration.
19326 @end quotation
19327
19328 @item
19329 @b{[basic.stc.static]}
19330
19331 Change paragraph 1
19332
19333 @quotation
19334 All objects that have neither thread storage duration, dynamic
19335 storage duration nor are local [@dots{}].
19336 @end quotation
19337
19338 @item
19339 @b{[dcl.stc]}
19340
19341 Add @code{__thread} to the list in paragraph 1.
19342
19343 Change paragraph 1
19344
19345 @quotation
19346 With the exception of @code{__thread}, at most one
19347 @var{storage-class-specifier} shall appear in a given
19348 @var{decl-specifier-seq}. The @code{__thread} specifier may
19349 be used alone, or immediately following the @code{extern} or
19350 @code{static} specifiers. [@dots{}]
19351 @end quotation
19352
19353 Add after paragraph 5
19354
19355 @quotation
19356 The @code{__thread} specifier can be applied only to the names of objects
19357 and to anonymous unions.
19358 @end quotation
19359
19360 @item
19361 @b{[class.mem]}
19362
19363 Add after paragraph 6
19364
19365 @quotation
19366 Non-@code{static} members shall not be @code{__thread}.
19367 @end quotation
19368 @end itemize
19369
19370 @node Binary constants
19371 @section Binary Constants using the @samp{0b} Prefix
19372 @cindex Binary constants using the @samp{0b} prefix
19373
19374 Integer constants can be written as binary constants, consisting of a
19375 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19376 @samp{0B}. This is particularly useful in environments that operate a
19377 lot on the bit level (like microcontrollers).
19378
19379 The following statements are identical:
19380
19381 @smallexample
19382 i = 42;
19383 i = 0x2a;
19384 i = 052;
19385 i = 0b101010;
19386 @end smallexample
19387
19388 The type of these constants follows the same rules as for octal or
19389 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19390 can be applied.
19391
19392 @node C++ Extensions
19393 @chapter Extensions to the C++ Language
19394 @cindex extensions, C++ language
19395 @cindex C++ language extensions
19396
19397 The GNU compiler provides these extensions to the C++ language (and you
19398 can also use most of the C language extensions in your C++ programs). If you
19399 want to write code that checks whether these features are available, you can
19400 test for the GNU compiler the same way as for C programs: check for a
19401 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19402 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19403 Predefined Macros,cpp,The GNU C Preprocessor}).
19404
19405 @menu
19406 * C++ Volatiles:: What constitutes an access to a volatile object.
19407 * Restricted Pointers:: C99 restricted pointers and references.
19408 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19409 * C++ Interface:: You can use a single C++ header file for both
19410 declarations and definitions.
19411 * Template Instantiation:: Methods for ensuring that exactly one copy of
19412 each needed template instantiation is emitted.
19413 * Bound member functions:: You can extract a function pointer to the
19414 method denoted by a @samp{->*} or @samp{.*} expression.
19415 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19416 * Function Multiversioning:: Declaring multiple function versions.
19417 * Namespace Association:: Strong using-directives for namespace association.
19418 * Type Traits:: Compiler support for type traits.
19419 * C++ Concepts:: Improved support for generic programming.
19420 * Java Exceptions:: Tweaking exception handling to work with Java.
19421 * Deprecated Features:: Things will disappear from G++.
19422 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19423 @end menu
19424
19425 @node C++ Volatiles
19426 @section When is a Volatile C++ Object Accessed?
19427 @cindex accessing volatiles
19428 @cindex volatile read
19429 @cindex volatile write
19430 @cindex volatile access
19431
19432 The C++ standard differs from the C standard in its treatment of
19433 volatile objects. It fails to specify what constitutes a volatile
19434 access, except to say that C++ should behave in a similar manner to C
19435 with respect to volatiles, where possible. However, the different
19436 lvalueness of expressions between C and C++ complicate the behavior.
19437 G++ behaves the same as GCC for volatile access, @xref{C
19438 Extensions,,Volatiles}, for a description of GCC's behavior.
19439
19440 The C and C++ language specifications differ when an object is
19441 accessed in a void context:
19442
19443 @smallexample
19444 volatile int *src = @var{somevalue};
19445 *src;
19446 @end smallexample
19447
19448 The C++ standard specifies that such expressions do not undergo lvalue
19449 to rvalue conversion, and that the type of the dereferenced object may
19450 be incomplete. The C++ standard does not specify explicitly that it
19451 is lvalue to rvalue conversion that is responsible for causing an
19452 access. There is reason to believe that it is, because otherwise
19453 certain simple expressions become undefined. However, because it
19454 would surprise most programmers, G++ treats dereferencing a pointer to
19455 volatile object of complete type as GCC would do for an equivalent
19456 type in C@. When the object has incomplete type, G++ issues a
19457 warning; if you wish to force an error, you must force a conversion to
19458 rvalue with, for instance, a static cast.
19459
19460 When using a reference to volatile, G++ does not treat equivalent
19461 expressions as accesses to volatiles, but instead issues a warning that
19462 no volatile is accessed. The rationale for this is that otherwise it
19463 becomes difficult to determine where volatile access occur, and not
19464 possible to ignore the return value from functions returning volatile
19465 references. Again, if you wish to force a read, cast the reference to
19466 an rvalue.
19467
19468 G++ implements the same behavior as GCC does when assigning to a
19469 volatile object---there is no reread of the assigned-to object, the
19470 assigned rvalue is reused. Note that in C++ assignment expressions
19471 are lvalues, and if used as an lvalue, the volatile object is
19472 referred to. For instance, @var{vref} refers to @var{vobj}, as
19473 expected, in the following example:
19474
19475 @smallexample
19476 volatile int vobj;
19477 volatile int &vref = vobj = @var{something};
19478 @end smallexample
19479
19480 @node Restricted Pointers
19481 @section Restricting Pointer Aliasing
19482 @cindex restricted pointers
19483 @cindex restricted references
19484 @cindex restricted this pointer
19485
19486 As with the C front end, G++ understands the C99 feature of restricted pointers,
19487 specified with the @code{__restrict__}, or @code{__restrict} type
19488 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19489 language flag, @code{restrict} is not a keyword in C++.
19490
19491 In addition to allowing restricted pointers, you can specify restricted
19492 references, which indicate that the reference is not aliased in the local
19493 context.
19494
19495 @smallexample
19496 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19497 @{
19498 /* @r{@dots{}} */
19499 @}
19500 @end smallexample
19501
19502 @noindent
19503 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19504 @var{rref} refers to a (different) unaliased integer.
19505
19506 You may also specify whether a member function's @var{this} pointer is
19507 unaliased by using @code{__restrict__} as a member function qualifier.
19508
19509 @smallexample
19510 void T::fn () __restrict__
19511 @{
19512 /* @r{@dots{}} */
19513 @}
19514 @end smallexample
19515
19516 @noindent
19517 Within the body of @code{T::fn}, @var{this} has the effective
19518 definition @code{T *__restrict__ const this}. Notice that the
19519 interpretation of a @code{__restrict__} member function qualifier is
19520 different to that of @code{const} or @code{volatile} qualifier, in that it
19521 is applied to the pointer rather than the object. This is consistent with
19522 other compilers that implement restricted pointers.
19523
19524 As with all outermost parameter qualifiers, @code{__restrict__} is
19525 ignored in function definition matching. This means you only need to
19526 specify @code{__restrict__} in a function definition, rather than
19527 in a function prototype as well.
19528
19529 @node Vague Linkage
19530 @section Vague Linkage
19531 @cindex vague linkage
19532
19533 There are several constructs in C++ that require space in the object
19534 file but are not clearly tied to a single translation unit. We say that
19535 these constructs have ``vague linkage''. Typically such constructs are
19536 emitted wherever they are needed, though sometimes we can be more
19537 clever.
19538
19539 @table @asis
19540 @item Inline Functions
19541 Inline functions are typically defined in a header file which can be
19542 included in many different compilations. Hopefully they can usually be
19543 inlined, but sometimes an out-of-line copy is necessary, if the address
19544 of the function is taken or if inlining fails. In general, we emit an
19545 out-of-line copy in all translation units where one is needed. As an
19546 exception, we only emit inline virtual functions with the vtable, since
19547 it always requires a copy.
19548
19549 Local static variables and string constants used in an inline function
19550 are also considered to have vague linkage, since they must be shared
19551 between all inlined and out-of-line instances of the function.
19552
19553 @item VTables
19554 @cindex vtable
19555 C++ virtual functions are implemented in most compilers using a lookup
19556 table, known as a vtable. The vtable contains pointers to the virtual
19557 functions provided by a class, and each object of the class contains a
19558 pointer to its vtable (or vtables, in some multiple-inheritance
19559 situations). If the class declares any non-inline, non-pure virtual
19560 functions, the first one is chosen as the ``key method'' for the class,
19561 and the vtable is only emitted in the translation unit where the key
19562 method is defined.
19563
19564 @emph{Note:} If the chosen key method is later defined as inline, the
19565 vtable is still emitted in every translation unit that defines it.
19566 Make sure that any inline virtuals are declared inline in the class
19567 body, even if they are not defined there.
19568
19569 @item @code{type_info} objects
19570 @cindex @code{type_info}
19571 @cindex RTTI
19572 C++ requires information about types to be written out in order to
19573 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19574 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19575 object is written out along with the vtable so that @samp{dynamic_cast}
19576 can determine the dynamic type of a class object at run time. For all
19577 other types, we write out the @samp{type_info} object when it is used: when
19578 applying @samp{typeid} to an expression, throwing an object, or
19579 referring to a type in a catch clause or exception specification.
19580
19581 @item Template Instantiations
19582 Most everything in this section also applies to template instantiations,
19583 but there are other options as well.
19584 @xref{Template Instantiation,,Where's the Template?}.
19585
19586 @end table
19587
19588 When used with GNU ld version 2.8 or later on an ELF system such as
19589 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19590 these constructs will be discarded at link time. This is known as
19591 COMDAT support.
19592
19593 On targets that don't support COMDAT, but do support weak symbols, GCC
19594 uses them. This way one copy overrides all the others, but
19595 the unused copies still take up space in the executable.
19596
19597 For targets that do not support either COMDAT or weak symbols,
19598 most entities with vague linkage are emitted as local symbols to
19599 avoid duplicate definition errors from the linker. This does not happen
19600 for local statics in inlines, however, as having multiple copies
19601 almost certainly breaks things.
19602
19603 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19604 another way to control placement of these constructs.
19605
19606 @node C++ Interface
19607 @section C++ Interface and Implementation Pragmas
19608
19609 @cindex interface and implementation headers, C++
19610 @cindex C++ interface and implementation headers
19611 @cindex pragmas, interface and implementation
19612
19613 @code{#pragma interface} and @code{#pragma implementation} provide the
19614 user with a way of explicitly directing the compiler to emit entities
19615 with vague linkage (and debugging information) in a particular
19616 translation unit.
19617
19618 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19619 by COMDAT support and the ``key method'' heuristic
19620 mentioned in @ref{Vague Linkage}. Using them can actually cause your
19621 program to grow due to unnecessary out-of-line copies of inline
19622 functions.
19623
19624 @table @code
19625 @item #pragma interface
19626 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19627 @kindex #pragma interface
19628 Use this directive in @emph{header files} that define object classes, to save
19629 space in most of the object files that use those classes. Normally,
19630 local copies of certain information (backup copies of inline member
19631 functions, debugging information, and the internal tables that implement
19632 virtual functions) must be kept in each object file that includes class
19633 definitions. You can use this pragma to avoid such duplication. When a
19634 header file containing @samp{#pragma interface} is included in a
19635 compilation, this auxiliary information is not generated (unless
19636 the main input source file itself uses @samp{#pragma implementation}).
19637 Instead, the object files contain references to be resolved at link
19638 time.
19639
19640 The second form of this directive is useful for the case where you have
19641 multiple headers with the same name in different directories. If you
19642 use this form, you must specify the same string to @samp{#pragma
19643 implementation}.
19644
19645 @item #pragma implementation
19646 @itemx #pragma implementation "@var{objects}.h"
19647 @kindex #pragma implementation
19648 Use this pragma in a @emph{main input file}, when you want full output from
19649 included header files to be generated (and made globally visible). The
19650 included header file, in turn, should use @samp{#pragma interface}.
19651 Backup copies of inline member functions, debugging information, and the
19652 internal tables used to implement virtual functions are all generated in
19653 implementation files.
19654
19655 @cindex implied @code{#pragma implementation}
19656 @cindex @code{#pragma implementation}, implied
19657 @cindex naming convention, implementation headers
19658 If you use @samp{#pragma implementation} with no argument, it applies to
19659 an include file with the same basename@footnote{A file's @dfn{basename}
19660 is the name stripped of all leading path information and of trailing
19661 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19662 file. For example, in @file{allclass.cc}, giving just
19663 @samp{#pragma implementation}
19664 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19665
19666 Use the string argument if you want a single implementation file to
19667 include code from multiple header files. (You must also use
19668 @samp{#include} to include the header file; @samp{#pragma
19669 implementation} only specifies how to use the file---it doesn't actually
19670 include it.)
19671
19672 There is no way to split up the contents of a single header file into
19673 multiple implementation files.
19674 @end table
19675
19676 @cindex inlining and C++ pragmas
19677 @cindex C++ pragmas, effect on inlining
19678 @cindex pragmas in C++, effect on inlining
19679 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19680 effect on function inlining.
19681
19682 If you define a class in a header file marked with @samp{#pragma
19683 interface}, the effect on an inline function defined in that class is
19684 similar to an explicit @code{extern} declaration---the compiler emits
19685 no code at all to define an independent version of the function. Its
19686 definition is used only for inlining with its callers.
19687
19688 @opindex fno-implement-inlines
19689 Conversely, when you include the same header file in a main source file
19690 that declares it as @samp{#pragma implementation}, the compiler emits
19691 code for the function itself; this defines a version of the function
19692 that can be found via pointers (or by callers compiled without
19693 inlining). If all calls to the function can be inlined, you can avoid
19694 emitting the function by compiling with @option{-fno-implement-inlines}.
19695 If any calls are not inlined, you will get linker errors.
19696
19697 @node Template Instantiation
19698 @section Where's the Template?
19699 @cindex template instantiation
19700
19701 C++ templates were the first language feature to require more
19702 intelligence from the environment than was traditionally found on a UNIX
19703 system. Somehow the compiler and linker have to make sure that each
19704 template instance occurs exactly once in the executable if it is needed,
19705 and not at all otherwise. There are two basic approaches to this
19706 problem, which are referred to as the Borland model and the Cfront model.
19707
19708 @table @asis
19709 @item Borland model
19710 Borland C++ solved the template instantiation problem by adding the code
19711 equivalent of common blocks to their linker; the compiler emits template
19712 instances in each translation unit that uses them, and the linker
19713 collapses them together. The advantage of this model is that the linker
19714 only has to consider the object files themselves; there is no external
19715 complexity to worry about. The disadvantage is that compilation time
19716 is increased because the template code is being compiled repeatedly.
19717 Code written for this model tends to include definitions of all
19718 templates in the header file, since they must be seen to be
19719 instantiated.
19720
19721 @item Cfront model
19722 The AT&T C++ translator, Cfront, solved the template instantiation
19723 problem by creating the notion of a template repository, an
19724 automatically maintained place where template instances are stored. A
19725 more modern version of the repository works as follows: As individual
19726 object files are built, the compiler places any template definitions and
19727 instantiations encountered in the repository. At link time, the link
19728 wrapper adds in the objects in the repository and compiles any needed
19729 instances that were not previously emitted. The advantages of this
19730 model are more optimal compilation speed and the ability to use the
19731 system linker; to implement the Borland model a compiler vendor also
19732 needs to replace the linker. The disadvantages are vastly increased
19733 complexity, and thus potential for error; for some code this can be
19734 just as transparent, but in practice it can been very difficult to build
19735 multiple programs in one directory and one program in multiple
19736 directories. Code written for this model tends to separate definitions
19737 of non-inline member templates into a separate file, which should be
19738 compiled separately.
19739 @end table
19740
19741 G++ implements the Borland model on targets where the linker supports it,
19742 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
19743 Otherwise G++ implements neither automatic model.
19744
19745 You have the following options for dealing with template instantiations:
19746
19747 @enumerate
19748 @item
19749 Do nothing. Code written for the Borland model works fine, but
19750 each translation unit contains instances of each of the templates it
19751 uses. The duplicate instances will be discarded by the linker, but in
19752 a large program, this can lead to an unacceptable amount of code
19753 duplication in object files or shared libraries.
19754
19755 Duplicate instances of a template can be avoided by defining an explicit
19756 instantiation in one object file, and preventing the compiler from doing
19757 implicit instantiations in any other object files by using an explicit
19758 instantiation declaration, using the @code{extern template} syntax:
19759
19760 @smallexample
19761 extern template int max (int, int);
19762 @end smallexample
19763
19764 This syntax is defined in the C++ 2011 standard, but has been supported by
19765 G++ and other compilers since well before 2011.
19766
19767 Explicit instantiations can be used for the largest or most frequently
19768 duplicated instances, without having to know exactly which other instances
19769 are used in the rest of the program. You can scatter the explicit
19770 instantiations throughout your program, perhaps putting them in the
19771 translation units where the instances are used or the translation units
19772 that define the templates themselves; you can put all of the explicit
19773 instantiations you need into one big file; or you can create small files
19774 like
19775
19776 @smallexample
19777 #include "Foo.h"
19778 #include "Foo.cc"
19779
19780 template class Foo<int>;
19781 template ostream& operator <<
19782 (ostream&, const Foo<int>&);
19783 @end smallexample
19784
19785 @noindent
19786 for each of the instances you need, and create a template instantiation
19787 library from those.
19788
19789 This is the simplest option, but also offers flexibility and
19790 fine-grained control when necessary. It is also the most portable
19791 alternative and programs using this approach will work with most modern
19792 compilers.
19793
19794 @item
19795 @opindex frepo
19796 Compile your template-using code with @option{-frepo}. The compiler
19797 generates files with the extension @samp{.rpo} listing all of the
19798 template instantiations used in the corresponding object files that
19799 could be instantiated there; the link wrapper, @samp{collect2},
19800 then updates the @samp{.rpo} files to tell the compiler where to place
19801 those instantiations and rebuild any affected object files. The
19802 link-time overhead is negligible after the first pass, as the compiler
19803 continues to place the instantiations in the same files.
19804
19805 This can be a suitable option for application code written for the Borland
19806 model, as it usually just works. Code written for the Cfront model
19807 needs to be modified so that the template definitions are available at
19808 one or more points of instantiation; usually this is as simple as adding
19809 @code{#include <tmethods.cc>} to the end of each template header.
19810
19811 For library code, if you want the library to provide all of the template
19812 instantiations it needs, just try to link all of its object files
19813 together; the link will fail, but cause the instantiations to be
19814 generated as a side effect. Be warned, however, that this may cause
19815 conflicts if multiple libraries try to provide the same instantiations.
19816 For greater control, use explicit instantiation as described in the next
19817 option.
19818
19819 @item
19820 @opindex fno-implicit-templates
19821 Compile your code with @option{-fno-implicit-templates} to disable the
19822 implicit generation of template instances, and explicitly instantiate
19823 all the ones you use. This approach requires more knowledge of exactly
19824 which instances you need than do the others, but it's less
19825 mysterious and allows greater control if you want to ensure that only
19826 the intended instances are used.
19827
19828 If you are using Cfront-model code, you can probably get away with not
19829 using @option{-fno-implicit-templates} when compiling files that don't
19830 @samp{#include} the member template definitions.
19831
19832 If you use one big file to do the instantiations, you may want to
19833 compile it without @option{-fno-implicit-templates} so you get all of the
19834 instances required by your explicit instantiations (but not by any
19835 other files) without having to specify them as well.
19836
19837 In addition to forward declaration of explicit instantiations
19838 (with @code{extern}), G++ has extended the template instantiation
19839 syntax to support instantiation of the compiler support data for a
19840 template class (i.e.@: the vtable) without instantiating any of its
19841 members (with @code{inline}), and instantiation of only the static data
19842 members of a template class, without the support data or member
19843 functions (with @code{static}):
19844
19845 @smallexample
19846 inline template class Foo<int>;
19847 static template class Foo<int>;
19848 @end smallexample
19849 @end enumerate
19850
19851 @node Bound member functions
19852 @section Extracting the Function Pointer from a Bound Pointer to Member Function
19853 @cindex pmf
19854 @cindex pointer to member function
19855 @cindex bound pointer to member function
19856
19857 In C++, pointer to member functions (PMFs) are implemented using a wide
19858 pointer of sorts to handle all the possible call mechanisms; the PMF
19859 needs to store information about how to adjust the @samp{this} pointer,
19860 and if the function pointed to is virtual, where to find the vtable, and
19861 where in the vtable to look for the member function. If you are using
19862 PMFs in an inner loop, you should really reconsider that decision. If
19863 that is not an option, you can extract the pointer to the function that
19864 would be called for a given object/PMF pair and call it directly inside
19865 the inner loop, to save a bit of time.
19866
19867 Note that you still pay the penalty for the call through a
19868 function pointer; on most modern architectures, such a call defeats the
19869 branch prediction features of the CPU@. This is also true of normal
19870 virtual function calls.
19871
19872 The syntax for this extension is
19873
19874 @smallexample
19875 extern A a;
19876 extern int (A::*fp)();
19877 typedef int (*fptr)(A *);
19878
19879 fptr p = (fptr)(a.*fp);
19880 @end smallexample
19881
19882 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
19883 no object is needed to obtain the address of the function. They can be
19884 converted to function pointers directly:
19885
19886 @smallexample
19887 fptr p1 = (fptr)(&A::foo);
19888 @end smallexample
19889
19890 @opindex Wno-pmf-conversions
19891 You must specify @option{-Wno-pmf-conversions} to use this extension.
19892
19893 @node C++ Attributes
19894 @section C++-Specific Variable, Function, and Type Attributes
19895
19896 Some attributes only make sense for C++ programs.
19897
19898 @table @code
19899 @item abi_tag ("@var{tag}", ...)
19900 @cindex @code{abi_tag} function attribute
19901 @cindex @code{abi_tag} variable attribute
19902 @cindex @code{abi_tag} type attribute
19903 The @code{abi_tag} attribute can be applied to a function, variable, or class
19904 declaration. It modifies the mangled name of the entity to
19905 incorporate the tag name, in order to distinguish the function or
19906 class from an earlier version with a different ABI; perhaps the class
19907 has changed size, or the function has a different return type that is
19908 not encoded in the mangled name.
19909
19910 The attribute can also be applied to an inline namespace, but does not
19911 affect the mangled name of the namespace; in this case it is only used
19912 for @option{-Wabi-tag} warnings and automatic tagging of functions and
19913 variables. Tagging inline namespaces is generally preferable to
19914 tagging individual declarations, but the latter is sometimes
19915 necessary, such as when only certain members of a class need to be
19916 tagged.
19917
19918 The argument can be a list of strings of arbitrary length. The
19919 strings are sorted on output, so the order of the list is
19920 unimportant.
19921
19922 A redeclaration of an entity must not add new ABI tags,
19923 since doing so would change the mangled name.
19924
19925 The ABI tags apply to a name, so all instantiations and
19926 specializations of a template have the same tags. The attribute will
19927 be ignored if applied to an explicit specialization or instantiation.
19928
19929 The @option{-Wabi-tag} flag enables a warning about a class which does
19930 not have all the ABI tags used by its subobjects and virtual functions; for users with code
19931 that needs to coexist with an earlier ABI, using this option can help
19932 to find all affected types that need to be tagged.
19933
19934 When a type involving an ABI tag is used as the type of a variable or
19935 return type of a function where that tag is not already present in the
19936 signature of the function, the tag is automatically applied to the
19937 variable or function. @option{-Wabi-tag} also warns about this
19938 situation; this warning can be avoided by explicitly tagging the
19939 variable or function or moving it into a tagged inline namespace.
19940
19941 @item init_priority (@var{priority})
19942 @cindex @code{init_priority} variable attribute
19943
19944 In Standard C++, objects defined at namespace scope are guaranteed to be
19945 initialized in an order in strict accordance with that of their definitions
19946 @emph{in a given translation unit}. No guarantee is made for initializations
19947 across translation units. However, GNU C++ allows users to control the
19948 order of initialization of objects defined at namespace scope with the
19949 @code{init_priority} attribute by specifying a relative @var{priority},
19950 a constant integral expression currently bounded between 101 and 65535
19951 inclusive. Lower numbers indicate a higher priority.
19952
19953 In the following example, @code{A} would normally be created before
19954 @code{B}, but the @code{init_priority} attribute reverses that order:
19955
19956 @smallexample
19957 Some_Class A __attribute__ ((init_priority (2000)));
19958 Some_Class B __attribute__ ((init_priority (543)));
19959 @end smallexample
19960
19961 @noindent
19962 Note that the particular values of @var{priority} do not matter; only their
19963 relative ordering.
19964
19965 @item java_interface
19966 @cindex @code{java_interface} type attribute
19967
19968 This type attribute informs C++ that the class is a Java interface. It may
19969 only be applied to classes declared within an @code{extern "Java"} block.
19970 Calls to methods declared in this interface are dispatched using GCJ's
19971 interface table mechanism, instead of regular virtual table dispatch.
19972
19973 @item warn_unused
19974 @cindex @code{warn_unused} type attribute
19975
19976 For C++ types with non-trivial constructors and/or destructors it is
19977 impossible for the compiler to determine whether a variable of this
19978 type is truly unused if it is not referenced. This type attribute
19979 informs the compiler that variables of this type should be warned
19980 about if they appear to be unused, just like variables of fundamental
19981 types.
19982
19983 This attribute is appropriate for types which just represent a value,
19984 such as @code{std::string}; it is not appropriate for types which
19985 control a resource, such as @code{std::mutex}.
19986
19987 This attribute is also accepted in C, but it is unnecessary because C
19988 does not have constructors or destructors.
19989
19990 @end table
19991
19992 See also @ref{Namespace Association}.
19993
19994 @node Function Multiversioning
19995 @section Function Multiversioning
19996 @cindex function versions
19997
19998 With the GNU C++ front end, for x86 targets, you may specify multiple
19999 versions of a function, where each function is specialized for a
20000 specific target feature. At runtime, the appropriate version of the
20001 function is automatically executed depending on the characteristics of
20002 the execution platform. Here is an example.
20003
20004 @smallexample
20005 __attribute__ ((target ("default")))
20006 int foo ()
20007 @{
20008 // The default version of foo.
20009 return 0;
20010 @}
20011
20012 __attribute__ ((target ("sse4.2")))
20013 int foo ()
20014 @{
20015 // foo version for SSE4.2
20016 return 1;
20017 @}
20018
20019 __attribute__ ((target ("arch=atom")))
20020 int foo ()
20021 @{
20022 // foo version for the Intel ATOM processor
20023 return 2;
20024 @}
20025
20026 __attribute__ ((target ("arch=amdfam10")))
20027 int foo ()
20028 @{
20029 // foo version for the AMD Family 0x10 processors.
20030 return 3;
20031 @}
20032
20033 int main ()
20034 @{
20035 int (*p)() = &foo;
20036 assert ((*p) () == foo ());
20037 return 0;
20038 @}
20039 @end smallexample
20040
20041 In the above example, four versions of function foo are created. The
20042 first version of foo with the target attribute "default" is the default
20043 version. This version gets executed when no other target specific
20044 version qualifies for execution on a particular platform. A new version
20045 of foo is created by using the same function signature but with a
20046 different target string. Function foo is called or a pointer to it is
20047 taken just like a regular function. GCC takes care of doing the
20048 dispatching to call the right version at runtime. Refer to the
20049 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20050 Function Multiversioning} for more details.
20051
20052 @node Namespace Association
20053 @section Namespace Association
20054
20055 @strong{Caution:} The semantics of this extension are equivalent
20056 to C++ 2011 inline namespaces. Users should use inline namespaces
20057 instead as this extension will be removed in future versions of G++.
20058
20059 A using-directive with @code{__attribute ((strong))} is stronger
20060 than a normal using-directive in two ways:
20061
20062 @itemize @bullet
20063 @item
20064 Templates from the used namespace can be specialized and explicitly
20065 instantiated as though they were members of the using namespace.
20066
20067 @item
20068 The using namespace is considered an associated namespace of all
20069 templates in the used namespace for purposes of argument-dependent
20070 name lookup.
20071 @end itemize
20072
20073 The used namespace must be nested within the using namespace so that
20074 normal unqualified lookup works properly.
20075
20076 This is useful for composing a namespace transparently from
20077 implementation namespaces. For example:
20078
20079 @smallexample
20080 namespace std @{
20081 namespace debug @{
20082 template <class T> struct A @{ @};
20083 @}
20084 using namespace debug __attribute ((__strong__));
20085 template <> struct A<int> @{ @}; // @r{OK to specialize}
20086
20087 template <class T> void f (A<T>);
20088 @}
20089
20090 int main()
20091 @{
20092 f (std::A<float>()); // @r{lookup finds} std::f
20093 f (std::A<int>());
20094 @}
20095 @end smallexample
20096
20097 @node Type Traits
20098 @section Type Traits
20099
20100 The C++ front end implements syntactic extensions that allow
20101 compile-time determination of
20102 various characteristics of a type (or of a
20103 pair of types).
20104
20105 @table @code
20106 @item __has_nothrow_assign (type)
20107 If @code{type} is const qualified or is a reference type then the trait is
20108 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20109 is true, else if @code{type} is a cv class or union type with copy assignment
20110 operators that are known not to throw an exception then the trait is true,
20111 else it is false. Requires: @code{type} shall be a complete type,
20112 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20113
20114 @item __has_nothrow_copy (type)
20115 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20116 @code{type} is a cv class or union type with copy constructors that
20117 are known not to throw an exception then the trait is true, else it is false.
20118 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20119 @code{void}, or an array of unknown bound.
20120
20121 @item __has_nothrow_constructor (type)
20122 If @code{__has_trivial_constructor (type)} is true then the trait is
20123 true, else if @code{type} is a cv class or union type (or array
20124 thereof) with a default constructor that is known not to throw an
20125 exception then the trait is true, else it is false. Requires:
20126 @code{type} shall be a complete type, (possibly cv-qualified)
20127 @code{void}, or an array of unknown bound.
20128
20129 @item __has_trivial_assign (type)
20130 If @code{type} is const qualified or is a reference type then the trait is
20131 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20132 true, else if @code{type} is a cv class or union type with a trivial
20133 copy assignment ([class.copy]) then the trait is true, else it is
20134 false. Requires: @code{type} shall be a complete type, (possibly
20135 cv-qualified) @code{void}, or an array of unknown bound.
20136
20137 @item __has_trivial_copy (type)
20138 If @code{__is_pod (type)} is true or @code{type} is a reference type
20139 then the trait is true, else if @code{type} is a cv class or union type
20140 with a trivial copy constructor ([class.copy]) then the trait
20141 is true, else it is false. Requires: @code{type} shall be a complete
20142 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20143
20144 @item __has_trivial_constructor (type)
20145 If @code{__is_pod (type)} is true then the trait is true, else if
20146 @code{type} is a cv class or union type (or array thereof) with a
20147 trivial default constructor ([class.ctor]) then the trait is true,
20148 else it is false. Requires: @code{type} shall be a complete
20149 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20150
20151 @item __has_trivial_destructor (type)
20152 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20153 the trait is true, else if @code{type} is a cv class or union type (or
20154 array thereof) with a trivial destructor ([class.dtor]) then the trait
20155 is true, else it is false. Requires: @code{type} shall be a complete
20156 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20157
20158 @item __has_virtual_destructor (type)
20159 If @code{type} is a class type with a virtual destructor
20160 ([class.dtor]) then the trait is true, else it is false. Requires:
20161 @code{type} shall be a complete type, (possibly cv-qualified)
20162 @code{void}, or an array of unknown bound.
20163
20164 @item __is_abstract (type)
20165 If @code{type} is an abstract class ([class.abstract]) then the trait
20166 is true, else it is false. Requires: @code{type} shall be a complete
20167 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20168
20169 @item __is_base_of (base_type, derived_type)
20170 If @code{base_type} is a base class of @code{derived_type}
20171 ([class.derived]) then the trait is true, otherwise it is false.
20172 Top-level cv qualifications of @code{base_type} and
20173 @code{derived_type} are ignored. For the purposes of this trait, a
20174 class type is considered is own base. Requires: if @code{__is_class
20175 (base_type)} and @code{__is_class (derived_type)} are true and
20176 @code{base_type} and @code{derived_type} are not the same type
20177 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20178 type. Diagnostic is produced if this requirement is not met.
20179
20180 @item __is_class (type)
20181 If @code{type} is a cv class type, and not a union type
20182 ([basic.compound]) the trait is true, else it is false.
20183
20184 @item __is_empty (type)
20185 If @code{__is_class (type)} is false then the trait is false.
20186 Otherwise @code{type} is considered empty if and only if: @code{type}
20187 has no non-static data members, or all non-static data members, if
20188 any, are bit-fields of length 0, and @code{type} has no virtual
20189 members, and @code{type} has no virtual base classes, and @code{type}
20190 has no base classes @code{base_type} for which
20191 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20192 be a complete type, (possibly cv-qualified) @code{void}, or an array
20193 of unknown bound.
20194
20195 @item __is_enum (type)
20196 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20197 true, else it is false.
20198
20199 @item __is_literal_type (type)
20200 If @code{type} is a literal type ([basic.types]) the trait is
20201 true, else it is false. Requires: @code{type} shall be a complete type,
20202 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20203
20204 @item __is_pod (type)
20205 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20206 else it is false. Requires: @code{type} shall be a complete type,
20207 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20208
20209 @item __is_polymorphic (type)
20210 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20211 is true, else it is false. Requires: @code{type} shall be a complete
20212 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20213
20214 @item __is_standard_layout (type)
20215 If @code{type} is a standard-layout type ([basic.types]) the trait is
20216 true, else it is false. Requires: @code{type} shall be a complete
20217 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20218
20219 @item __is_trivial (type)
20220 If @code{type} is a trivial type ([basic.types]) the trait is
20221 true, else it is false. Requires: @code{type} shall be a complete
20222 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20223
20224 @item __is_union (type)
20225 If @code{type} is a cv union type ([basic.compound]) the trait is
20226 true, else it is false.
20227
20228 @item __underlying_type (type)
20229 The underlying type of @code{type}. Requires: @code{type} shall be
20230 an enumeration type ([dcl.enum]).
20231
20232 @end table
20233
20234
20235 @node C++ Concepts
20236 @section C++ Concepts
20237
20238 C++ concepts provide much-improved support for generic programming. In
20239 particular, they allow the specification of constraints on template arguments.
20240 The constraints are used to extend the usual overloading and partial
20241 specialization capabilities of the language, allowing generic data structures
20242 and algorithms to be ``refined'' based on their properties rather than their
20243 type names.
20244
20245 The following keywords are reserved for concepts.
20246
20247 @table @code
20248 @item assumes
20249 States an expression as an assumption, and if possible, verifies that the
20250 assumption is valid. For example, @code{assume(n > 0)}.
20251
20252 @item axiom
20253 Introduces an axiom definition. Axioms introduce requirements on values.
20254
20255 @item forall
20256 Introduces a universally quantified object in an axiom. For example,
20257 @code{forall (int n) n + 0 == n}).
20258
20259 @item concept
20260 Introduces a concept definition. Concepts are sets of syntactic and semantic
20261 requirements on types and their values.
20262
20263 @item requires
20264 Introduces constraints on template arguments or requirements for a member
20265 function of a class template.
20266
20267 @end table
20268
20269 The front end also exposes a number of internal mechanism that can be used
20270 to simplify the writing of type traits. Note that some of these traits are
20271 likely to be removed in the future.
20272
20273 @table @code
20274 @item __is_same (type1, type2)
20275 A binary type trait: true whenever the type arguments are the same.
20276
20277 @end table
20278
20279
20280 @node Java Exceptions
20281 @section Java Exceptions
20282
20283 The Java language uses a slightly different exception handling model
20284 from C++. Normally, GNU C++ automatically detects when you are
20285 writing C++ code that uses Java exceptions, and handle them
20286 appropriately. However, if C++ code only needs to execute destructors
20287 when Java exceptions are thrown through it, GCC guesses incorrectly.
20288 Sample problematic code is:
20289
20290 @smallexample
20291 struct S @{ ~S(); @};
20292 extern void bar(); // @r{is written in Java, and may throw exceptions}
20293 void foo()
20294 @{
20295 S s;
20296 bar();
20297 @}
20298 @end smallexample
20299
20300 @noindent
20301 The usual effect of an incorrect guess is a link failure, complaining of
20302 a missing routine called @samp{__gxx_personality_v0}.
20303
20304 You can inform the compiler that Java exceptions are to be used in a
20305 translation unit, irrespective of what it might think, by writing
20306 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20307 @samp{#pragma} must appear before any functions that throw or catch
20308 exceptions, or run destructors when exceptions are thrown through them.
20309
20310 You cannot mix Java and C++ exceptions in the same translation unit. It
20311 is believed to be safe to throw a C++ exception from one file through
20312 another file compiled for the Java exception model, or vice versa, but
20313 there may be bugs in this area.
20314
20315 @node Deprecated Features
20316 @section Deprecated Features
20317
20318 In the past, the GNU C++ compiler was extended to experiment with new
20319 features, at a time when the C++ language was still evolving. Now that
20320 the C++ standard is complete, some of those features are superseded by
20321 superior alternatives. Using the old features might cause a warning in
20322 some cases that the feature will be dropped in the future. In other
20323 cases, the feature might be gone already.
20324
20325 While the list below is not exhaustive, it documents some of the options
20326 that are now deprecated:
20327
20328 @table @code
20329 @item -fexternal-templates
20330 @itemx -falt-external-templates
20331 These are two of the many ways for G++ to implement template
20332 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20333 defines how template definitions have to be organized across
20334 implementation units. G++ has an implicit instantiation mechanism that
20335 should work just fine for standard-conforming code.
20336
20337 @item -fstrict-prototype
20338 @itemx -fno-strict-prototype
20339 Previously it was possible to use an empty prototype parameter list to
20340 indicate an unspecified number of parameters (like C), rather than no
20341 parameters, as C++ demands. This feature has been removed, except where
20342 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20343 @end table
20344
20345 G++ allows a virtual function returning @samp{void *} to be overridden
20346 by one returning a different pointer type. This extension to the
20347 covariant return type rules is now deprecated and will be removed from a
20348 future version.
20349
20350 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20351 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20352 and are now removed from G++. Code using these operators should be
20353 modified to use @code{std::min} and @code{std::max} instead.
20354
20355 The named return value extension has been deprecated, and is now
20356 removed from G++.
20357
20358 The use of initializer lists with new expressions has been deprecated,
20359 and is now removed from G++.
20360
20361 Floating and complex non-type template parameters have been deprecated,
20362 and are now removed from G++.
20363
20364 The implicit typename extension has been deprecated and is now
20365 removed from G++.
20366
20367 The use of default arguments in function pointers, function typedefs
20368 and other places where they are not permitted by the standard is
20369 deprecated and will be removed from a future version of G++.
20370
20371 G++ allows floating-point literals to appear in integral constant expressions,
20372 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20373 This extension is deprecated and will be removed from a future version.
20374
20375 G++ allows static data members of const floating-point type to be declared
20376 with an initializer in a class definition. The standard only allows
20377 initializers for static members of const integral types and const
20378 enumeration types so this extension has been deprecated and will be removed
20379 from a future version.
20380
20381 @node Backwards Compatibility
20382 @section Backwards Compatibility
20383 @cindex Backwards Compatibility
20384 @cindex ARM [Annotated C++ Reference Manual]
20385
20386 Now that there is a definitive ISO standard C++, G++ has a specification
20387 to adhere to. The C++ language evolved over time, and features that
20388 used to be acceptable in previous drafts of the standard, such as the ARM
20389 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20390 compilation of C++ written to such drafts, G++ contains some backwards
20391 compatibilities. @emph{All such backwards compatibility features are
20392 liable to disappear in future versions of G++.} They should be considered
20393 deprecated. @xref{Deprecated Features}.
20394
20395 @table @code
20396 @item For scope
20397 If a variable is declared at for scope, it used to remain in scope until
20398 the end of the scope that contained the for statement (rather than just
20399 within the for scope). G++ retains this, but issues a warning, if such a
20400 variable is accessed outside the for scope.
20401
20402 @item Implicit C language
20403 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20404 scope to set the language. On such systems, all header files are
20405 implicitly scoped inside a C language scope. Also, an empty prototype
20406 @code{()} is treated as an unspecified number of arguments, rather
20407 than no arguments, as C++ demands.
20408 @end table
20409
20410 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20411 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr