rs6000-builtin.def (BU_FLOAT128_2): Add support for pack/unpack functions for __ibm128.
[gcc.git] / gcc / doc / extend.texi
1 @c Copyright (C) 1988-2016 Free Software Foundation, Inc.
2
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
10
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.) To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
17
18 These extensions are available in C and Objective-C@. Most of them are
19 also available in C++. @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
21
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
24
25 @menu
26 * Statement Exprs:: Putting statements and declarations inside expressions.
27 * Local Labels:: Labels local to a block.
28 * Labels as Values:: Getting pointers to labels, and computed gotos.
29 * Nested Functions:: As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls:: Dispatching a call to another function.
31 * Typeof:: @code{typeof}: referring to the type of an expression.
32 * Conditionals:: Omitting the middle operand of a @samp{?:} expression.
33 * __int128:: 128-bit integers---@code{__int128}.
34 * Long Long:: Double-word integers---@code{long long int}.
35 * Complex:: Data types for complex numbers.
36 * Floating Types:: Additional Floating Types.
37 * Half-Precision:: Half-Precision Floating Point.
38 * Decimal Float:: Decimal Floating Types.
39 * Hex Floats:: Hexadecimal floating-point constants.
40 * Fixed-Point:: Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length:: Zero-length arrays.
43 * Empty Structures:: Structures with no members.
44 * Variable Length:: Arrays whose length is computed at run time.
45 * Variadic Macros:: Macros with a variable number of arguments.
46 * Escaped Newlines:: Slightly looser rules for escaped newlines.
47 * Subscripting:: Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith:: Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays:: Pointers to arrays with qualifiers work as expected.
50 * Initializers:: Non-constant initializers.
51 * Compound Literals:: Compound literals give structures, unions
52 or arrays as values.
53 * Designated Inits:: Labeling elements of initializers.
54 * Case Ranges:: `case 1 ... 9' and such.
55 * Cast to Union:: Casting to union type from any member of the union.
56 * Mixed Declarations:: Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58 or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes:: Specifying attributes of types.
61 * Label Attributes:: Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Attribute Syntax:: Formal syntax for attributes.
64 * Function Prototypes:: Prototype declarations and old-style definitions.
65 * C++ Comments:: C++ comments are recognized.
66 * Dollar Signs:: Dollar sign is allowed in identifiers.
67 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
68 * Alignment:: Inquiring about the alignment of a type or variable.
69 * Inline:: Defining inline functions (as fast as macros).
70 * Volatiles:: What constitutes an access to a volatile object.
71 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
72 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
73 * Incomplete Enums:: @code{enum foo;}, with details to follow.
74 * Function Names:: Printable strings which are the name of the current
75 function.
76 * Return Address:: Getting the return or frame address of a function.
77 * Vector Extensions:: Using vector instructions through built-in functions.
78 * Offsetof:: Special syntax for implementing @code{offsetof}.
79 * __sync Builtins:: Legacy built-in functions for atomic memory access.
80 * __atomic Builtins:: Atomic built-in functions with memory model.
81 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
82 arithmetic overflow checking.
83 * x86 specific memory model extensions for transactional memory:: x86 memory models.
84 * Object Size Checking:: Built-in functions for limited buffer overflow
85 checking.
86 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
87 * Cilk Plus Builtins:: Built-in functions for the Cilk Plus language extension.
88 * Other Builtins:: Other built-in functions.
89 * Target Builtins:: Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas:: Pragmas accepted by GCC.
92 * Unnamed Fields:: Unnamed struct/union fields within structs/unions.
93 * Thread-Local:: Per-thread variables.
94 * Binary constants:: Binary constants using the @samp{0b} prefix.
95 @end menu
96
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
103
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@. This allows you to use loops, switches, and local variables
108 within an expression.
109
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces. For
112 example:
113
114 @smallexample
115 (@{ int y = foo (); int z;
116 if (y > 0) z = y;
117 else z = - y;
118 z; @})
119 @end smallexample
120
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
124
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct. (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
130
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once). For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
135
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
139
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects. In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
146
147 @smallexample
148 #define maxint(a,b) \
149 (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
151
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
155
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
158
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression. For instance, if @code{A} is a class, then
162
163 @smallexample
164 A a;
165
166 (@{a;@}).Foo ()
167 @end smallexample
168
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
174
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end. This makes statement
177 expressions inside macros slightly different from function calls. In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call. In the statement expression case they are destroyed during
181 the statement expression. For instance,
182
183 @smallexample
184 #define macro(a) (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
186
187 void foo ()
188 @{
189 macro (X ());
190 function (X ());
191 @}
192 @end smallexample
193
194 @noindent
195 has different places where temporaries are destroyed. For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}. In the @code{function} case that
198 temporary is destroyed when the function returns.
199
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++. (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
205
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted. Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression. In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression. For example,
219
220 @smallexample
221 foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
223
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}. If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
228
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
233
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope. A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
238
239 A local label declaration looks like this:
240
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
244
245 @noindent
246 or
247
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
251
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
254
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself. You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
258
259 The local label feature is useful for complex macros. If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them. However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function. A
264 local label avoids this problem. For example:
265
266 @smallexample
267 #define SEARCH(value, array, target) \
268 do @{ \
269 __label__ found; \
270 typeof (target) _SEARCH_target = (target); \
271 typeof (*(array)) *_SEARCH_array = (array); \
272 int i, j; \
273 int value; \
274 for (i = 0; i < max; i++) \
275 for (j = 0; j < max; j++) \
276 if (_SEARCH_array[i][j] == _SEARCH_target) \
277 @{ (value) = i; goto found; @} \
278 (value) = -1; \
279 found:; \
280 @} while (0)
281 @end smallexample
282
283 This could also be written using a statement expression:
284
285 @smallexample
286 #define SEARCH(array, target) \
287 (@{ \
288 __label__ found; \
289 typeof (target) _SEARCH_target = (target); \
290 typeof (*(array)) *_SEARCH_array = (array); \
291 int i, j; \
292 int value; \
293 for (i = 0; i < max; i++) \
294 for (j = 0; j < max; j++) \
295 if (_SEARCH_array[i][j] == _SEARCH_target) \
296 @{ value = i; goto found; @} \
297 value = -1; \
298 found: \
299 value; \
300 @})
301 @end smallexample
302
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any. @xref{Nested Functions}, for details.
305
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
312
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}. The
315 value has type @code{void *}. This value is a constant and can be used
316 wherever a constant of that type is valid. For example:
317
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
323
324 To use these values, you need to be able to jump to one. This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}. For example,
329
330 @smallexample
331 goto *ptr;
332 @end smallexample
333
334 @noindent
335 Any expression of type @code{void *} is allowed.
336
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
339
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
343
344 @noindent
345 Then you can select a label with indexing, like this:
346
347 @smallexample
348 goto *array[i];
349 @end smallexample
350
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
354
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement. The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
359
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
363
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen. The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
368
369 An alternate way to write the above example is
370
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373 &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
376
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
383
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned. If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning. If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
390
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
396
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
400
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
404
405 @smallexample
406 @group
407 foo (double a, double b)
408 @{
409 double square (double z) @{ return z * z; @}
410
411 return square (a) + square (b);
412 @}
413 @end group
414 @end smallexample
415
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition. This is
418 called @dfn{lexical scoping}. For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
420
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
424 @{
425 int access (int *array, int index)
426 @{ return array[index + offset]; @}
427 int i;
428 /* @r{@dots{}} */
429 for (i = 0; i < size; i++)
430 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
431 @}
432 @end group
433 @end smallexample
434
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
438
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
441
442 @smallexample
443 hack (int *array, int size)
444 @{
445 void store (int index, int value)
446 @{ array[index] = value; @}
447
448 intermediate (store, size);
449 @}
450 @end smallexample
451
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument. If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
457
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose. If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk. If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
465
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}. This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
470
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}). Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well. Here is an example:
476
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
480 @{
481 __label__ failure;
482 int access (int *array, int index)
483 @{
484 if (index > size)
485 goto failure;
486 return array[index + offset];
487 @}
488 int i;
489 /* @r{@dots{}} */
490 for (i = 0; i < size; i++)
491 /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492 /* @r{@dots{}} */
493 return 0;
494
495 /* @r{Control comes here from @code{access}
496 if it detects an error.} */
497 failure:
498 return -1;
499 @}
500 @end group
501 @end smallexample
502
503 A nested function always has no linkage. Declaring one with
504 @code{extern} or @code{static} is erroneous. If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
507
508 @smallexample
509 bar (int *array, int offset, int size)
510 @{
511 __label__ failure;
512 auto int access (int *, int);
513 /* @r{@dots{}} */
514 int access (int *array, int index)
515 @{
516 if (index > size)
517 goto failure;
518 return array[index + offset];
519 @}
520 /* @r{@dots{}} */
521 @}
522 @end smallexample
523
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
528
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
533
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
538
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language. It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
543
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
548
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack. Then it returns the
552 address of that block.
553 @end deftypefn
554
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
559
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}. The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
563
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}. The data
566 is saved in a block of memory allocated on the stack.
567
568 It is not always simple to compute the proper value for @var{size}. The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
573
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function. You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
579
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function. It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments. This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable. For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
594 @{
595 int r = fprintf (f, "myprintf: ");
596 if (r < 0)
597 return r;
598 int s = fprintf (f, format, __builtin_va_arg_pack ());
599 if (s < 0)
600 return s;
601 return r + s;
602 @}
603 @end smallexample
604 @end deftypefn
605
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function. It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
618 @{
619 if (__builtin_va_arg_pack_len () > 1)
620 warn_open_too_many_arguments ();
621
622 if (__builtin_constant_p (oflag))
623 @{
624 if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625 @{
626 warn_open_missing_mode ();
627 return __open_2 (path, oflag);
628 @}
629 return open (path, oflag, __builtin_va_arg_pack ());
630 @}
631
632 if (__builtin_va_arg_pack_len () < 1)
633 return __open_2 (path, oflag);
634
635 return open (path, oflag, __builtin_va_arg_pack ());
636 @}
637 #endif
638 @end smallexample
639 @end deftypefn
640
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
646
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
650
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type. Here is an example with an expression:
653
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
657
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
661
662 Here is an example with a typename as the argument:
663
664 @smallexample
665 typeof (int *)
666 @end smallexample
667
668 @noindent
669 Here the type described is that of pointers to @code{int}.
670
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
674
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used. For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
678
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
682
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
688
689 @smallexample
690 #define max(a,b) \
691 (@{ typeof (a) _a = (a); \
692 typeof (b) _b = (b); \
693 _a > _b ? _a : _b; @})
694 @end smallexample
695
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
701
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}. Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
708
709 @noindent
710 Some more examples of the use of @code{typeof}:
711
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
715
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
719
720 @item
721 This declares @code{y} as an array of such values.
722
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
726
727 @item
728 This declares @code{y} as an array of pointers to characters:
729
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
733
734 @noindent
735 It is equivalent to the following traditional C declaration:
736
737 @smallexample
738 char *y[4];
739 @end smallexample
740
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
743
744 @smallexample
745 #define pointer(T) typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
748
749 @noindent
750 Now the declaration can be rewritten this way:
751
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
755
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
760
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}. In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer. (In C++, you should use C++11
767 @code{auto} for this purpose.) Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
769
770 @smallexample
771 #define max(a,b) \
772 (@{ __auto_type _a = (a); \
773 __auto_type _b = (b); \
774 _a > _b ? _a : _b; @})
775 @end smallexample
776
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
778
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro. This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
784
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
789
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
797
798 The middle operand in a conditional expression may be omitted. Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
801
802 Therefore, the expression
803
804 @smallexample
805 x ? : y
806 @end smallexample
807
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
811
812 This example is perfectly equivalent to
813
814 @smallexample
815 x ? x : y
816 @end smallexample
817
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful. When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect. Then repeating
824 the operand in the middle would perform the side effect twice. Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
827
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
831
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer. There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
838
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
846
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer. To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer. To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
854
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines. Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction. Division and shifts are open-coded only on machines that
860 provide special support. The operations that are not open-coded use
861 special library routines that come with GCC@.
862
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes. If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}. The best way to avoid such problems is to use prototypes.
870
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
876
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++. GCC also supports complex integer data
879 types which are not part of ISO C99. You can declare complex types
880 using the keyword @code{_Complex}. As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
882
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}. @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
889
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent). For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}. Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant. This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
899
900 @cindex @code{__real__} keyword
901 @cindex @code{__imag__} keyword
902 To extract the real part of a complex-valued expression @var{exp}, write
903 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
904 extract the imaginary part. This is a GNU extension; for values of
905 floating type, you should use the ISO C99 functions @code{crealf},
906 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
907 @code{cimagl}, declared in @code{<complex.h>} and also provided as
908 built-in functions by GCC@.
909
910 @cindex complex conjugation
911 The operator @samp{~} performs complex conjugation when used on a value
912 with a complex type. This is a GNU extension; for values of
913 floating type, you should use the ISO C99 functions @code{conjf},
914 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
915 provided as built-in functions by GCC@.
916
917 GCC can allocate complex automatic variables in a noncontiguous
918 fashion; it's even possible for the real part to be in a register while
919 the imaginary part is on the stack (or vice versa). Only the DWARF 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 64-bit Linux systems there are currently problems in using
958 the complex @code{__float128} type. When these problems are fixed,
959 you would use:
960
961 @smallexample
962 typedef _Complex float __attribute__((mode(KC))) _Complex128;
963 @end smallexample
964
965 Not all targets support additional floating-point types.
966 @code{__float80} and @code{__float128} types are supported on x86 and
967 IA-64 targets. The @code{__float128} type is supported on hppa HP-UX.
968 The @code{__float128} type is supported on PowerPC 64-bit Linux
969 systems by default if the vector scalar instruction set (VSX) is
970 enabled.
971
972 On the PowerPC, @code{__ibm128} provides access to the IBM extended
973 double format, and it is intended to be used by the library functions
974 that handle conversions if/when long double is changed to be IEEE
975 128-bit floating point.
976
977 @node Half-Precision
978 @section Half-Precision Floating Point
979 @cindex half-precision floating point
980 @cindex @code{__fp16} data type
981
982 On ARM targets, GCC supports half-precision (16-bit) floating point via
983 the @code{__fp16} type. You must enable this type explicitly
984 with the @option{-mfp16-format} command-line option in order to use it.
985
986 ARM supports two incompatible representations for half-precision
987 floating-point values. You must choose one of the representations and
988 use it consistently in your program.
989
990 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
991 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
992 There are 11 bits of significand precision, approximately 3
993 decimal digits.
994
995 Specifying @option{-mfp16-format=alternative} selects the ARM
996 alternative format. This representation is similar to the IEEE
997 format, but does not support infinities or NaNs. Instead, the range
998 of exponents is extended, so that this format can represent normalized
999 values in the range of @math{2^{-14}} to 131008.
1000
1001 The @code{__fp16} type is a storage format only. For purposes
1002 of arithmetic and other operations, @code{__fp16} values in C or C++
1003 expressions are automatically promoted to @code{float}. In addition,
1004 you cannot declare a function with a return value or parameters
1005 of type @code{__fp16}.
1006
1007 Note that conversions from @code{double} to @code{__fp16}
1008 involve an intermediate conversion to @code{float}. Because
1009 of rounding, this can sometimes produce a different result than a
1010 direct conversion.
1011
1012 ARM provides hardware support for conversions between
1013 @code{__fp16} and @code{float} values
1014 as an extension to VFP and NEON (Advanced SIMD). GCC generates
1015 code using these hardware instructions if you compile with
1016 options to select an FPU that provides them;
1017 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1018 in addition to the @option{-mfp16-format} option to select
1019 a half-precision format.
1020
1021 Language-level support for the @code{__fp16} data type is
1022 independent of whether GCC generates code using hardware floating-point
1023 instructions. In cases where hardware support is not specified, GCC
1024 implements conversions between @code{__fp16} and @code{float} values
1025 as library calls.
1026
1027 @node Decimal Float
1028 @section Decimal Floating Types
1029 @cindex decimal floating types
1030 @cindex @code{_Decimal32} data type
1031 @cindex @code{_Decimal64} data type
1032 @cindex @code{_Decimal128} data type
1033 @cindex @code{df} integer suffix
1034 @cindex @code{dd} integer suffix
1035 @cindex @code{dl} integer suffix
1036 @cindex @code{DF} integer suffix
1037 @cindex @code{DD} integer suffix
1038 @cindex @code{DL} integer suffix
1039
1040 As an extension, GNU C supports decimal floating types as
1041 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1042 floating types in GCC will evolve as the draft technical report changes.
1043 Calling conventions for any target might also change. Not all targets
1044 support decimal floating types.
1045
1046 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1047 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1048 @code{float}, @code{double}, and @code{long double} whose radix is not
1049 specified by the C standard but is usually two.
1050
1051 Support for decimal floating types includes the arithmetic operators
1052 add, subtract, multiply, divide; unary arithmetic operators;
1053 relational operators; equality operators; and conversions to and from
1054 integer and other floating types. Use a suffix @samp{df} or
1055 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1056 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1057 @code{_Decimal128}.
1058
1059 GCC support of decimal float as specified by the draft technical report
1060 is incomplete:
1061
1062 @itemize @bullet
1063 @item
1064 When the value of a decimal floating type cannot be represented in the
1065 integer type to which it is being converted, the result is undefined
1066 rather than the result value specified by the draft technical report.
1067
1068 @item
1069 GCC does not provide the C library functionality associated with
1070 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1071 @file{wchar.h}, which must come from a separate C library implementation.
1072 Because of this the GNU C compiler does not define macro
1073 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1074 the technical report.
1075 @end itemize
1076
1077 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1078 are supported by the DWARF 2 debug information format.
1079
1080 @node Hex Floats
1081 @section Hex Floats
1082 @cindex hex floats
1083
1084 ISO C99 supports floating-point numbers written not only in the usual
1085 decimal notation, such as @code{1.55e1}, but also numbers such as
1086 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1087 supports this in C90 mode (except in some cases when strictly
1088 conforming) and in C++. In that format the
1089 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1090 mandatory. The exponent is a decimal number that indicates the power of
1091 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1092 @tex
1093 $1 {15\over16}$,
1094 @end tex
1095 @ifnottex
1096 1 15/16,
1097 @end ifnottex
1098 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1099 is the same as @code{1.55e1}.
1100
1101 Unlike for floating-point numbers in the decimal notation the exponent
1102 is always required in the hexadecimal notation. Otherwise the compiler
1103 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1104 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1105 extension for floating-point constants of type @code{float}.
1106
1107 @node Fixed-Point
1108 @section Fixed-Point Types
1109 @cindex fixed-point types
1110 @cindex @code{_Fract} data type
1111 @cindex @code{_Accum} data type
1112 @cindex @code{_Sat} data type
1113 @cindex @code{hr} fixed-suffix
1114 @cindex @code{r} fixed-suffix
1115 @cindex @code{lr} fixed-suffix
1116 @cindex @code{llr} fixed-suffix
1117 @cindex @code{uhr} fixed-suffix
1118 @cindex @code{ur} fixed-suffix
1119 @cindex @code{ulr} fixed-suffix
1120 @cindex @code{ullr} fixed-suffix
1121 @cindex @code{hk} fixed-suffix
1122 @cindex @code{k} fixed-suffix
1123 @cindex @code{lk} fixed-suffix
1124 @cindex @code{llk} fixed-suffix
1125 @cindex @code{uhk} fixed-suffix
1126 @cindex @code{uk} fixed-suffix
1127 @cindex @code{ulk} fixed-suffix
1128 @cindex @code{ullk} fixed-suffix
1129 @cindex @code{HR} fixed-suffix
1130 @cindex @code{R} fixed-suffix
1131 @cindex @code{LR} fixed-suffix
1132 @cindex @code{LLR} fixed-suffix
1133 @cindex @code{UHR} fixed-suffix
1134 @cindex @code{UR} fixed-suffix
1135 @cindex @code{ULR} fixed-suffix
1136 @cindex @code{ULLR} fixed-suffix
1137 @cindex @code{HK} fixed-suffix
1138 @cindex @code{K} fixed-suffix
1139 @cindex @code{LK} fixed-suffix
1140 @cindex @code{LLK} fixed-suffix
1141 @cindex @code{UHK} fixed-suffix
1142 @cindex @code{UK} fixed-suffix
1143 @cindex @code{ULK} fixed-suffix
1144 @cindex @code{ULLK} fixed-suffix
1145
1146 As an extension, GNU C supports fixed-point types as
1147 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1148 types in GCC will evolve as the draft technical report changes.
1149 Calling conventions for any target might also change. Not all targets
1150 support fixed-point types.
1151
1152 The fixed-point types are
1153 @code{short _Fract},
1154 @code{_Fract},
1155 @code{long _Fract},
1156 @code{long long _Fract},
1157 @code{unsigned short _Fract},
1158 @code{unsigned _Fract},
1159 @code{unsigned long _Fract},
1160 @code{unsigned long long _Fract},
1161 @code{_Sat short _Fract},
1162 @code{_Sat _Fract},
1163 @code{_Sat long _Fract},
1164 @code{_Sat long long _Fract},
1165 @code{_Sat unsigned short _Fract},
1166 @code{_Sat unsigned _Fract},
1167 @code{_Sat unsigned long _Fract},
1168 @code{_Sat unsigned long long _Fract},
1169 @code{short _Accum},
1170 @code{_Accum},
1171 @code{long _Accum},
1172 @code{long long _Accum},
1173 @code{unsigned short _Accum},
1174 @code{unsigned _Accum},
1175 @code{unsigned long _Accum},
1176 @code{unsigned long long _Accum},
1177 @code{_Sat short _Accum},
1178 @code{_Sat _Accum},
1179 @code{_Sat long _Accum},
1180 @code{_Sat long long _Accum},
1181 @code{_Sat unsigned short _Accum},
1182 @code{_Sat unsigned _Accum},
1183 @code{_Sat unsigned long _Accum},
1184 @code{_Sat unsigned long long _Accum}.
1185
1186 Fixed-point data values contain fractional and optional integral parts.
1187 The format of fixed-point data varies and depends on the target machine.
1188
1189 Support for fixed-point types includes:
1190 @itemize @bullet
1191 @item
1192 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1193 @item
1194 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1195 @item
1196 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1197 @item
1198 binary shift operators (@code{<<}, @code{>>})
1199 @item
1200 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1201 @item
1202 equality operators (@code{==}, @code{!=})
1203 @item
1204 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1205 @code{<<=}, @code{>>=})
1206 @item
1207 conversions to and from integer, floating-point, or fixed-point types
1208 @end itemize
1209
1210 Use a suffix in a fixed-point literal constant:
1211 @itemize
1212 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1213 @code{_Sat short _Fract}
1214 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1215 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1216 @code{_Sat long _Fract}
1217 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1218 @code{_Sat long long _Fract}
1219 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1220 @code{_Sat unsigned short _Fract}
1221 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1222 @code{_Sat unsigned _Fract}
1223 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1224 @code{_Sat unsigned long _Fract}
1225 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1226 and @code{_Sat unsigned long long _Fract}
1227 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1228 @code{_Sat short _Accum}
1229 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1230 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1231 @code{_Sat long _Accum}
1232 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1233 @code{_Sat long long _Accum}
1234 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1235 @code{_Sat unsigned short _Accum}
1236 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1237 @code{_Sat unsigned _Accum}
1238 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1239 @code{_Sat unsigned long _Accum}
1240 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1241 and @code{_Sat unsigned long long _Accum}
1242 @end itemize
1243
1244 GCC support of fixed-point types as specified by the draft technical report
1245 is incomplete:
1246
1247 @itemize @bullet
1248 @item
1249 Pragmas to control overflow and rounding behaviors are not implemented.
1250 @end itemize
1251
1252 Fixed-point types are supported by the DWARF 2 debug information format.
1253
1254 @node Named Address Spaces
1255 @section Named Address Spaces
1256 @cindex Named Address Spaces
1257
1258 As an extension, GNU C supports named address spaces as
1259 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1260 address spaces in GCC will evolve as the draft technical report
1261 changes. Calling conventions for any target might also change. At
1262 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1263 address spaces other than the generic address space.
1264
1265 Address space identifiers may be used exactly like any other C type
1266 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1267 document for more details.
1268
1269 @anchor{AVR Named Address Spaces}
1270 @subsection AVR Named Address Spaces
1271
1272 On the AVR target, there are several address spaces that can be used
1273 in order to put read-only data into the flash memory and access that
1274 data by means of the special instructions @code{LPM} or @code{ELPM}
1275 needed to read from flash.
1276
1277 Per default, any data including read-only data is located in RAM
1278 (the generic address space) so that non-generic address spaces are
1279 needed to locate read-only data in flash memory
1280 @emph{and} to generate the right instructions to access this data
1281 without using (inline) assembler code.
1282
1283 @table @code
1284 @item __flash
1285 @cindex @code{__flash} AVR Named Address Spaces
1286 The @code{__flash} qualifier locates data in the
1287 @code{.progmem.data} section. Data is read using the @code{LPM}
1288 instruction. Pointers to this address space are 16 bits wide.
1289
1290 @item __flash1
1291 @itemx __flash2
1292 @itemx __flash3
1293 @itemx __flash4
1294 @itemx __flash5
1295 @cindex @code{__flash1} AVR Named Address Spaces
1296 @cindex @code{__flash2} AVR Named Address Spaces
1297 @cindex @code{__flash3} AVR Named Address Spaces
1298 @cindex @code{__flash4} AVR Named Address Spaces
1299 @cindex @code{__flash5} AVR Named Address Spaces
1300 These are 16-bit address spaces locating data in section
1301 @code{.progmem@var{N}.data} where @var{N} refers to
1302 address space @code{__flash@var{N}}.
1303 The compiler sets the @code{RAMPZ} segment register appropriately
1304 before reading data by means of the @code{ELPM} instruction.
1305
1306 @item __memx
1307 @cindex @code{__memx} AVR Named Address Spaces
1308 This is a 24-bit address space that linearizes flash and RAM:
1309 If the high bit of the address is set, data is read from
1310 RAM using the lower two bytes as RAM address.
1311 If the high bit of the address is clear, data is read from flash
1312 with @code{RAMPZ} set according to the high byte of the address.
1313 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1314
1315 Objects in this address space are located in @code{.progmemx.data}.
1316 @end table
1317
1318 @b{Example}
1319
1320 @smallexample
1321 char my_read (const __flash char ** p)
1322 @{
1323 /* p is a pointer to RAM that points to a pointer to flash.
1324 The first indirection of p reads that flash pointer
1325 from RAM and the second indirection reads a char from this
1326 flash address. */
1327
1328 return **p;
1329 @}
1330
1331 /* Locate array[] in flash memory */
1332 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1333
1334 int i = 1;
1335
1336 int main (void)
1337 @{
1338 /* Return 17 by reading from flash memory */
1339 return array[array[i]];
1340 @}
1341 @end smallexample
1342
1343 @noindent
1344 For each named address space supported by avr-gcc there is an equally
1345 named but uppercase built-in macro defined.
1346 The purpose is to facilitate testing if respective address space
1347 support is available or not:
1348
1349 @smallexample
1350 #ifdef __FLASH
1351 const __flash int var = 1;
1352
1353 int read_var (void)
1354 @{
1355 return var;
1356 @}
1357 #else
1358 #include <avr/pgmspace.h> /* From AVR-LibC */
1359
1360 const int var PROGMEM = 1;
1361
1362 int read_var (void)
1363 @{
1364 return (int) pgm_read_word (&var);
1365 @}
1366 #endif /* __FLASH */
1367 @end smallexample
1368
1369 @noindent
1370 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1371 locates data in flash but
1372 accesses to these data read from generic address space, i.e.@:
1373 from RAM,
1374 so that you need special accessors like @code{pgm_read_byte}
1375 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1376 together with attribute @code{progmem}.
1377
1378 @noindent
1379 @b{Limitations and caveats}
1380
1381 @itemize
1382 @item
1383 Reading across the 64@tie{}KiB section boundary of
1384 the @code{__flash} or @code{__flash@var{N}} address spaces
1385 shows undefined behavior. The only address space that
1386 supports reading across the 64@tie{}KiB flash segment boundaries is
1387 @code{__memx}.
1388
1389 @item
1390 If you use one of the @code{__flash@var{N}} address spaces
1391 you must arrange your linker script to locate the
1392 @code{.progmem@var{N}.data} sections according to your needs.
1393
1394 @item
1395 Any data or pointers to the non-generic address spaces must
1396 be qualified as @code{const}, i.e.@: as read-only data.
1397 This still applies if the data in one of these address
1398 spaces like software version number or calibration lookup table are intended to
1399 be changed after load time by, say, a boot loader. In this case
1400 the right qualification is @code{const} @code{volatile} so that the compiler
1401 must not optimize away known values or insert them
1402 as immediates into operands of instructions.
1403
1404 @item
1405 The following code initializes a variable @code{pfoo}
1406 located in static storage with a 24-bit address:
1407 @smallexample
1408 extern const __memx char foo;
1409 const __memx void *pfoo = &foo;
1410 @end smallexample
1411
1412 @noindent
1413 Such code requires at least binutils 2.23, see
1414 @w{@uref{http://sourceware.org/PR13503,PR13503}}.
1415
1416 @end itemize
1417
1418 @subsection M32C Named Address Spaces
1419 @cindex @code{__far} M32C Named Address Spaces
1420
1421 On the M32C target, with the R8C and M16C CPU variants, variables
1422 qualified with @code{__far} are accessed using 32-bit addresses in
1423 order to access memory beyond the first 64@tie{}Ki bytes. If
1424 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1425 effect.
1426
1427 @subsection RL78 Named Address Spaces
1428 @cindex @code{__far} RL78 Named Address Spaces
1429
1430 On the RL78 target, variables qualified with @code{__far} are accessed
1431 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1432 addresses. Non-far variables are assumed to appear in the topmost
1433 64@tie{}KiB of the address space.
1434
1435 @subsection SPU Named Address Spaces
1436 @cindex @code{__ea} SPU Named Address Spaces
1437
1438 On the SPU target variables may be declared as
1439 belonging to another address space by qualifying the type with the
1440 @code{__ea} address space identifier:
1441
1442 @smallexample
1443 extern int __ea i;
1444 @end smallexample
1445
1446 @noindent
1447 The compiler generates special code to access the variable @code{i}.
1448 It may use runtime library
1449 support, or generate special machine instructions to access that address
1450 space.
1451
1452 @subsection x86 Named Address Spaces
1453 @cindex x86 named address spaces
1454
1455 On the x86 target, variables may be declared as being relative
1456 to the @code{%fs} or @code{%gs} segments.
1457
1458 @table @code
1459 @item __seg_fs
1460 @itemx __seg_gs
1461 @cindex @code{__seg_fs} x86 named address space
1462 @cindex @code{__seg_gs} x86 named address space
1463 The object is accessed with the respective segment override prefix.
1464
1465 The respective segment base must be set via some method specific to
1466 the operating system. Rather than require an expensive system call
1467 to retrieve the segment base, these address spaces are not considered
1468 to be subspaces of the generic (flat) address space. This means that
1469 explicit casts are required to convert pointers between these address
1470 spaces and the generic address space. In practice the application
1471 should cast to @code{uintptr_t} and apply the segment base offset
1472 that it installed previously.
1473
1474 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1475 defined when these address spaces are supported.
1476
1477 @item __seg_tls
1478 @cindex @code{__seg_tls} x86 named address space
1479 Some operating systems define either the @code{%fs} or @code{%gs}
1480 segment as the thread-local storage base for each thread. Objects
1481 within this address space are accessed with the appropriate
1482 segment override prefix.
1483
1484 The pointer located at address 0 within the segment contains the
1485 offset of the segment within the generic address space. Thus this
1486 address space is considered a subspace of the generic address space,
1487 and the known segment offset is applied when converting addresses
1488 to and from the generic address space.
1489
1490 The preprocessor symbol @code{__SEG_TLS} is defined when this
1491 address space is supported.
1492
1493 @end table
1494
1495 @node Zero Length
1496 @section Arrays of Length Zero
1497 @cindex arrays of length zero
1498 @cindex zero-length arrays
1499 @cindex length-zero arrays
1500 @cindex flexible array members
1501
1502 Zero-length arrays are allowed in GNU C@. They are very useful as the
1503 last element of a structure that is really a header for a variable-length
1504 object:
1505
1506 @smallexample
1507 struct line @{
1508 int length;
1509 char contents[0];
1510 @};
1511
1512 struct line *thisline = (struct line *)
1513 malloc (sizeof (struct line) + this_length);
1514 thisline->length = this_length;
1515 @end smallexample
1516
1517 In ISO C90, you would have to give @code{contents} a length of 1, which
1518 means either you waste space or complicate the argument to @code{malloc}.
1519
1520 In ISO C99, you would use a @dfn{flexible array member}, which is
1521 slightly different in syntax and semantics:
1522
1523 @itemize @bullet
1524 @item
1525 Flexible array members are written as @code{contents[]} without
1526 the @code{0}.
1527
1528 @item
1529 Flexible array members have incomplete type, and so the @code{sizeof}
1530 operator may not be applied. As a quirk of the original implementation
1531 of zero-length arrays, @code{sizeof} evaluates to zero.
1532
1533 @item
1534 Flexible array members may only appear as the last member of a
1535 @code{struct} that is otherwise non-empty.
1536
1537 @item
1538 A structure containing a flexible array member, or a union containing
1539 such a structure (possibly recursively), may not be a member of a
1540 structure or an element of an array. (However, these uses are
1541 permitted by GCC as extensions.)
1542 @end itemize
1543
1544 Non-empty initialization of zero-length
1545 arrays is treated like any case where there are more initializer
1546 elements than the array holds, in that a suitable warning about ``excess
1547 elements in array'' is given, and the excess elements (all of them, in
1548 this case) are ignored.
1549
1550 GCC allows static initialization of flexible array members.
1551 This is equivalent to defining a new structure containing the original
1552 structure followed by an array of sufficient size to contain the data.
1553 E.g.@: in the following, @code{f1} is constructed as if it were declared
1554 like @code{f2}.
1555
1556 @smallexample
1557 struct f1 @{
1558 int x; int y[];
1559 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1560
1561 struct f2 @{
1562 struct f1 f1; int data[3];
1563 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1564 @end smallexample
1565
1566 @noindent
1567 The convenience of this extension is that @code{f1} has the desired
1568 type, eliminating the need to consistently refer to @code{f2.f1}.
1569
1570 This has symmetry with normal static arrays, in that an array of
1571 unknown size is also written with @code{[]}.
1572
1573 Of course, this extension only makes sense if the extra data comes at
1574 the end of a top-level object, as otherwise we would be overwriting
1575 data at subsequent offsets. To avoid undue complication and confusion
1576 with initialization of deeply nested arrays, we simply disallow any
1577 non-empty initialization except when the structure is the top-level
1578 object. For example:
1579
1580 @smallexample
1581 struct foo @{ int x; int y[]; @};
1582 struct bar @{ struct foo z; @};
1583
1584 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1585 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1586 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1587 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1588 @end smallexample
1589
1590 @node Empty Structures
1591 @section Structures with No Members
1592 @cindex empty structures
1593 @cindex zero-size structures
1594
1595 GCC permits a C structure to have no members:
1596
1597 @smallexample
1598 struct empty @{
1599 @};
1600 @end smallexample
1601
1602 The structure has size zero. In C++, empty structures are part
1603 of the language. G++ treats empty structures as if they had a single
1604 member of type @code{char}.
1605
1606 @node Variable Length
1607 @section Arrays of Variable Length
1608 @cindex variable-length arrays
1609 @cindex arrays of variable length
1610 @cindex VLAs
1611
1612 Variable-length automatic arrays are allowed in ISO C99, and as an
1613 extension GCC accepts them in C90 mode and in C++. These arrays are
1614 declared like any other automatic arrays, but with a length that is not
1615 a constant expression. The storage is allocated at the point of
1616 declaration and deallocated when the block scope containing the declaration
1617 exits. For
1618 example:
1619
1620 @smallexample
1621 FILE *
1622 concat_fopen (char *s1, char *s2, char *mode)
1623 @{
1624 char str[strlen (s1) + strlen (s2) + 1];
1625 strcpy (str, s1);
1626 strcat (str, s2);
1627 return fopen (str, mode);
1628 @}
1629 @end smallexample
1630
1631 @cindex scope of a variable length array
1632 @cindex variable-length array scope
1633 @cindex deallocating variable length arrays
1634 Jumping or breaking out of the scope of the array name deallocates the
1635 storage. Jumping into the scope is not allowed; you get an error
1636 message for it.
1637
1638 @cindex variable-length array in a structure
1639 As an extension, GCC accepts variable-length arrays as a member of
1640 a structure or a union. For example:
1641
1642 @smallexample
1643 void
1644 foo (int n)
1645 @{
1646 struct S @{ int x[n]; @};
1647 @}
1648 @end smallexample
1649
1650 @cindex @code{alloca} vs variable-length arrays
1651 You can use the function @code{alloca} to get an effect much like
1652 variable-length arrays. The function @code{alloca} is available in
1653 many other C implementations (but not in all). On the other hand,
1654 variable-length arrays are more elegant.
1655
1656 There are other differences between these two methods. Space allocated
1657 with @code{alloca} exists until the containing @emph{function} returns.
1658 The space for a variable-length array is deallocated as soon as the array
1659 name's scope ends, unless you also use @code{alloca} in this scope.
1660
1661 You can also use variable-length arrays as arguments to functions:
1662
1663 @smallexample
1664 struct entry
1665 tester (int len, char data[len][len])
1666 @{
1667 /* @r{@dots{}} */
1668 @}
1669 @end smallexample
1670
1671 The length of an array is computed once when the storage is allocated
1672 and is remembered for the scope of the array in case you access it with
1673 @code{sizeof}.
1674
1675 If you want to pass the array first and the length afterward, you can
1676 use a forward declaration in the parameter list---another GNU extension.
1677
1678 @smallexample
1679 struct entry
1680 tester (int len; char data[len][len], int len)
1681 @{
1682 /* @r{@dots{}} */
1683 @}
1684 @end smallexample
1685
1686 @cindex parameter forward declaration
1687 The @samp{int len} before the semicolon is a @dfn{parameter forward
1688 declaration}, and it serves the purpose of making the name @code{len}
1689 known when the declaration of @code{data} is parsed.
1690
1691 You can write any number of such parameter forward declarations in the
1692 parameter list. They can be separated by commas or semicolons, but the
1693 last one must end with a semicolon, which is followed by the ``real''
1694 parameter declarations. Each forward declaration must match a ``real''
1695 declaration in parameter name and data type. ISO C99 does not support
1696 parameter forward declarations.
1697
1698 @node Variadic Macros
1699 @section Macros with a Variable Number of Arguments.
1700 @cindex variable number of arguments
1701 @cindex macro with variable arguments
1702 @cindex rest argument (in macro)
1703 @cindex variadic macros
1704
1705 In the ISO C standard of 1999, a macro can be declared to accept a
1706 variable number of arguments much as a function can. The syntax for
1707 defining the macro is similar to that of a function. Here is an
1708 example:
1709
1710 @smallexample
1711 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1712 @end smallexample
1713
1714 @noindent
1715 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1716 such a macro, it represents the zero or more tokens until the closing
1717 parenthesis that ends the invocation, including any commas. This set of
1718 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1719 wherever it appears. See the CPP manual for more information.
1720
1721 GCC has long supported variadic macros, and used a different syntax that
1722 allowed you to give a name to the variable arguments just like any other
1723 argument. Here is an example:
1724
1725 @smallexample
1726 #define debug(format, args...) fprintf (stderr, format, args)
1727 @end smallexample
1728
1729 @noindent
1730 This is in all ways equivalent to the ISO C example above, but arguably
1731 more readable and descriptive.
1732
1733 GNU CPP has two further variadic macro extensions, and permits them to
1734 be used with either of the above forms of macro definition.
1735
1736 In standard C, you are not allowed to leave the variable argument out
1737 entirely; but you are allowed to pass an empty argument. For example,
1738 this invocation is invalid in ISO C, because there is no comma after
1739 the string:
1740
1741 @smallexample
1742 debug ("A message")
1743 @end smallexample
1744
1745 GNU CPP permits you to completely omit the variable arguments in this
1746 way. In the above examples, the compiler would complain, though since
1747 the expansion of the macro still has the extra comma after the format
1748 string.
1749
1750 To help solve this problem, CPP behaves specially for variable arguments
1751 used with the token paste operator, @samp{##}. If instead you write
1752
1753 @smallexample
1754 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1755 @end smallexample
1756
1757 @noindent
1758 and if the variable arguments are omitted or empty, the @samp{##}
1759 operator causes the preprocessor to remove the comma before it. If you
1760 do provide some variable arguments in your macro invocation, GNU CPP
1761 does not complain about the paste operation and instead places the
1762 variable arguments after the comma. Just like any other pasted macro
1763 argument, these arguments are not macro expanded.
1764
1765 @node Escaped Newlines
1766 @section Slightly Looser Rules for Escaped Newlines
1767 @cindex escaped newlines
1768 @cindex newlines (escaped)
1769
1770 The preprocessor treatment of escaped newlines is more relaxed
1771 than that specified by the C90 standard, which requires the newline
1772 to immediately follow a backslash.
1773 GCC's implementation allows whitespace in the form
1774 of spaces, horizontal and vertical tabs, and form feeds between the
1775 backslash and the subsequent newline. The preprocessor issues a
1776 warning, but treats it as a valid escaped newline and combines the two
1777 lines to form a single logical line. This works within comments and
1778 tokens, as well as between tokens. Comments are @emph{not} treated as
1779 whitespace for the purposes of this relaxation, since they have not
1780 yet been replaced with spaces.
1781
1782 @node Subscripting
1783 @section Non-Lvalue Arrays May Have Subscripts
1784 @cindex subscripting
1785 @cindex arrays, non-lvalue
1786
1787 @cindex subscripting and function values
1788 In ISO C99, arrays that are not lvalues still decay to pointers, and
1789 may be subscripted, although they may not be modified or used after
1790 the next sequence point and the unary @samp{&} operator may not be
1791 applied to them. As an extension, GNU C allows such arrays to be
1792 subscripted in C90 mode, though otherwise they do not decay to
1793 pointers outside C99 mode. For example,
1794 this is valid in GNU C though not valid in C90:
1795
1796 @smallexample
1797 @group
1798 struct foo @{int a[4];@};
1799
1800 struct foo f();
1801
1802 bar (int index)
1803 @{
1804 return f().a[index];
1805 @}
1806 @end group
1807 @end smallexample
1808
1809 @node Pointer Arith
1810 @section Arithmetic on @code{void}- and Function-Pointers
1811 @cindex void pointers, arithmetic
1812 @cindex void, size of pointer to
1813 @cindex function pointers, arithmetic
1814 @cindex function, size of pointer to
1815
1816 In GNU C, addition and subtraction operations are supported on pointers to
1817 @code{void} and on pointers to functions. This is done by treating the
1818 size of a @code{void} or of a function as 1.
1819
1820 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1821 and on function types, and returns 1.
1822
1823 @opindex Wpointer-arith
1824 The option @option{-Wpointer-arith} requests a warning if these extensions
1825 are used.
1826
1827 @node Pointers to Arrays
1828 @section Pointers to Arrays with Qualifiers Work as Expected
1829 @cindex pointers to arrays
1830 @cindex const qualifier
1831
1832 In GNU C, pointers to arrays with qualifiers work similar to pointers
1833 to other qualified types. For example, a value of type @code{int (*)[5]}
1834 can be used to initialize a variable of type @code{const int (*)[5]}.
1835 These types are incompatible in ISO C because the @code{const} qualifier
1836 is formally attached to the element type of the array and not the
1837 array itself.
1838
1839 @smallexample
1840 extern void
1841 transpose (int N, int M, double out[M][N], const double in[N][M]);
1842 double x[3][2];
1843 double y[2][3];
1844 @r{@dots{}}
1845 transpose(3, 2, y, x);
1846 @end smallexample
1847
1848 @node Initializers
1849 @section Non-Constant Initializers
1850 @cindex initializers, non-constant
1851 @cindex non-constant initializers
1852
1853 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1854 automatic variable are not required to be constant expressions in GNU C@.
1855 Here is an example of an initializer with run-time varying elements:
1856
1857 @smallexample
1858 foo (float f, float g)
1859 @{
1860 float beat_freqs[2] = @{ f-g, f+g @};
1861 /* @r{@dots{}} */
1862 @}
1863 @end smallexample
1864
1865 @node Compound Literals
1866 @section Compound Literals
1867 @cindex constructor expressions
1868 @cindex initializations in expressions
1869 @cindex structures, constructor expression
1870 @cindex expressions, constructor
1871 @cindex compound literals
1872 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1873
1874 ISO C99 supports compound literals. A compound literal looks like
1875 a cast containing an initializer. Its value is an object of the
1876 type specified in the cast, containing the elements specified in
1877 the initializer; it is an lvalue. As an extension, GCC supports
1878 compound literals in C90 mode and in C++, though the semantics are
1879 somewhat different in C++.
1880
1881 Usually, the specified type is a structure. Assume that
1882 @code{struct foo} and @code{structure} are declared as shown:
1883
1884 @smallexample
1885 struct foo @{int a; char b[2];@} structure;
1886 @end smallexample
1887
1888 @noindent
1889 Here is an example of constructing a @code{struct foo} with a compound literal:
1890
1891 @smallexample
1892 structure = ((struct foo) @{x + y, 'a', 0@});
1893 @end smallexample
1894
1895 @noindent
1896 This is equivalent to writing the following:
1897
1898 @smallexample
1899 @{
1900 struct foo temp = @{x + y, 'a', 0@};
1901 structure = temp;
1902 @}
1903 @end smallexample
1904
1905 You can also construct an array, though this is dangerous in C++, as
1906 explained below. If all the elements of the compound literal are
1907 (made up of) simple constant expressions, suitable for use in
1908 initializers of objects of static storage duration, then the compound
1909 literal can be coerced to a pointer to its first element and used in
1910 such an initializer, as shown here:
1911
1912 @smallexample
1913 char **foo = (char *[]) @{ "x", "y", "z" @};
1914 @end smallexample
1915
1916 Compound literals for scalar types and union types are
1917 also allowed, but then the compound literal is equivalent
1918 to a cast.
1919
1920 As a GNU extension, GCC allows initialization of objects with static storage
1921 duration by compound literals (which is not possible in ISO C99, because
1922 the initializer is not a constant).
1923 It is handled as if the object is initialized only with the bracket
1924 enclosed list if the types of the compound literal and the object match.
1925 The initializer list of the compound literal must be constant.
1926 If the object being initialized has array type of unknown size, the size is
1927 determined by compound literal size.
1928
1929 @smallexample
1930 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1931 static int y[] = (int []) @{1, 2, 3@};
1932 static int z[] = (int [3]) @{1@};
1933 @end smallexample
1934
1935 @noindent
1936 The above lines are equivalent to the following:
1937 @smallexample
1938 static struct foo x = @{1, 'a', 'b'@};
1939 static int y[] = @{1, 2, 3@};
1940 static int z[] = @{1, 0, 0@};
1941 @end smallexample
1942
1943 In C, a compound literal designates an unnamed object with static or
1944 automatic storage duration. In C++, a compound literal designates a
1945 temporary object, which only lives until the end of its
1946 full-expression. As a result, well-defined C code that takes the
1947 address of a subobject of a compound literal can be undefined in C++,
1948 so the C++ compiler rejects the conversion of a temporary array to a pointer.
1949 For instance, if the array compound literal example above appeared
1950 inside a function, any subsequent use of @samp{foo} in C++ has
1951 undefined behavior because the lifetime of the array ends after the
1952 declaration of @samp{foo}.
1953
1954 As an optimization, the C++ compiler sometimes gives array compound
1955 literals longer lifetimes: when the array either appears outside a
1956 function or has const-qualified type. If @samp{foo} and its
1957 initializer had elements of @samp{char *const} type rather than
1958 @samp{char *}, or if @samp{foo} were a global variable, the array
1959 would have static storage duration. But it is probably safest just to
1960 avoid the use of array compound literals in code compiled as C++.
1961
1962 @node Designated Inits
1963 @section Designated Initializers
1964 @cindex initializers with labeled elements
1965 @cindex labeled elements in initializers
1966 @cindex case labels in initializers
1967 @cindex designated initializers
1968
1969 Standard C90 requires the elements of an initializer to appear in a fixed
1970 order, the same as the order of the elements in the array or structure
1971 being initialized.
1972
1973 In ISO C99 you can give the elements in any order, specifying the array
1974 indices or structure field names they apply to, and GNU C allows this as
1975 an extension in C90 mode as well. This extension is not
1976 implemented in GNU C++.
1977
1978 To specify an array index, write
1979 @samp{[@var{index}] =} before the element value. For example,
1980
1981 @smallexample
1982 int a[6] = @{ [4] = 29, [2] = 15 @};
1983 @end smallexample
1984
1985 @noindent
1986 is equivalent to
1987
1988 @smallexample
1989 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
1990 @end smallexample
1991
1992 @noindent
1993 The index values must be constant expressions, even if the array being
1994 initialized is automatic.
1995
1996 An alternative syntax for this that has been obsolete since GCC 2.5 but
1997 GCC still accepts is to write @samp{[@var{index}]} before the element
1998 value, with no @samp{=}.
1999
2000 To initialize a range of elements to the same value, write
2001 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2002 extension. For example,
2003
2004 @smallexample
2005 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2006 @end smallexample
2007
2008 @noindent
2009 If the value in it has side-effects, the side-effects happen only once,
2010 not for each initialized field by the range initializer.
2011
2012 @noindent
2013 Note that the length of the array is the highest value specified
2014 plus one.
2015
2016 In a structure initializer, specify the name of a field to initialize
2017 with @samp{.@var{fieldname} =} before the element value. For example,
2018 given the following structure,
2019
2020 @smallexample
2021 struct point @{ int x, y; @};
2022 @end smallexample
2023
2024 @noindent
2025 the following initialization
2026
2027 @smallexample
2028 struct point p = @{ .y = yvalue, .x = xvalue @};
2029 @end smallexample
2030
2031 @noindent
2032 is equivalent to
2033
2034 @smallexample
2035 struct point p = @{ xvalue, yvalue @};
2036 @end smallexample
2037
2038 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2039 @samp{@var{fieldname}:}, as shown here:
2040
2041 @smallexample
2042 struct point p = @{ y: yvalue, x: xvalue @};
2043 @end smallexample
2044
2045 Omitted field members are implicitly initialized the same as objects
2046 that have static storage duration.
2047
2048 @cindex designators
2049 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2050 @dfn{designator}. You can also use a designator (or the obsolete colon
2051 syntax) when initializing a union, to specify which element of the union
2052 should be used. For example,
2053
2054 @smallexample
2055 union foo @{ int i; double d; @};
2056
2057 union foo f = @{ .d = 4 @};
2058 @end smallexample
2059
2060 @noindent
2061 converts 4 to a @code{double} to store it in the union using
2062 the second element. By contrast, casting 4 to type @code{union foo}
2063 stores it into the union as the integer @code{i}, since it is
2064 an integer. (@xref{Cast to Union}.)
2065
2066 You can combine this technique of naming elements with ordinary C
2067 initialization of successive elements. Each initializer element that
2068 does not have a designator applies to the next consecutive element of the
2069 array or structure. For example,
2070
2071 @smallexample
2072 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2073 @end smallexample
2074
2075 @noindent
2076 is equivalent to
2077
2078 @smallexample
2079 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2080 @end smallexample
2081
2082 Labeling the elements of an array initializer is especially useful
2083 when the indices are characters or belong to an @code{enum} type.
2084 For example:
2085
2086 @smallexample
2087 int whitespace[256]
2088 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2089 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2090 @end smallexample
2091
2092 @cindex designator lists
2093 You can also write a series of @samp{.@var{fieldname}} and
2094 @samp{[@var{index}]} designators before an @samp{=} to specify a
2095 nested subobject to initialize; the list is taken relative to the
2096 subobject corresponding to the closest surrounding brace pair. For
2097 example, with the @samp{struct point} declaration above:
2098
2099 @smallexample
2100 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2101 @end smallexample
2102
2103 @noindent
2104 If the same field is initialized multiple times, it has the value from
2105 the last initialization. If any such overridden initialization has
2106 side-effect, it is unspecified whether the side-effect happens or not.
2107 Currently, GCC discards them and issues a warning.
2108
2109 @node Case Ranges
2110 @section Case Ranges
2111 @cindex case ranges
2112 @cindex ranges in case statements
2113
2114 You can specify a range of consecutive values in a single @code{case} label,
2115 like this:
2116
2117 @smallexample
2118 case @var{low} ... @var{high}:
2119 @end smallexample
2120
2121 @noindent
2122 This has the same effect as the proper number of individual @code{case}
2123 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2124
2125 This feature is especially useful for ranges of ASCII character codes:
2126
2127 @smallexample
2128 case 'A' ... 'Z':
2129 @end smallexample
2130
2131 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2132 it may be parsed wrong when you use it with integer values. For example,
2133 write this:
2134
2135 @smallexample
2136 case 1 ... 5:
2137 @end smallexample
2138
2139 @noindent
2140 rather than this:
2141
2142 @smallexample
2143 case 1...5:
2144 @end smallexample
2145
2146 @node Cast to Union
2147 @section Cast to a Union Type
2148 @cindex cast to a union
2149 @cindex union, casting to a
2150
2151 A cast to union type is similar to other casts, except that the type
2152 specified is a union type. You can specify the type either with
2153 @code{union @var{tag}} or with a typedef name. A cast to union is actually
2154 a constructor, not a cast, and hence does not yield an lvalue like
2155 normal casts. (@xref{Compound Literals}.)
2156
2157 The types that may be cast to the union type are those of the members
2158 of the union. Thus, given the following union and variables:
2159
2160 @smallexample
2161 union foo @{ int i; double d; @};
2162 int x;
2163 double y;
2164 @end smallexample
2165
2166 @noindent
2167 both @code{x} and @code{y} can be cast to type @code{union foo}.
2168
2169 Using the cast as the right-hand side of an assignment to a variable of
2170 union type is equivalent to storing in a member of the union:
2171
2172 @smallexample
2173 union foo u;
2174 /* @r{@dots{}} */
2175 u = (union foo) x @equiv{} u.i = x
2176 u = (union foo) y @equiv{} u.d = y
2177 @end smallexample
2178
2179 You can also use the union cast as a function argument:
2180
2181 @smallexample
2182 void hack (union foo);
2183 /* @r{@dots{}} */
2184 hack ((union foo) x);
2185 @end smallexample
2186
2187 @node Mixed Declarations
2188 @section Mixed Declarations and Code
2189 @cindex mixed declarations and code
2190 @cindex declarations, mixed with code
2191 @cindex code, mixed with declarations
2192
2193 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2194 within compound statements. As an extension, GNU C also allows this in
2195 C90 mode. For example, you could do:
2196
2197 @smallexample
2198 int i;
2199 /* @r{@dots{}} */
2200 i++;
2201 int j = i + 2;
2202 @end smallexample
2203
2204 Each identifier is visible from where it is declared until the end of
2205 the enclosing block.
2206
2207 @node Function Attributes
2208 @section Declaring Attributes of Functions
2209 @cindex function attributes
2210 @cindex declaring attributes of functions
2211 @cindex @code{volatile} applied to function
2212 @cindex @code{const} applied to function
2213
2214 In GNU C, you can use function attributes to declare certain things
2215 about functions called in your program which help the compiler
2216 optimize calls and check your code more carefully. For example, you
2217 can use attributes to declare that a function never returns
2218 (@code{noreturn}), returns a value depending only on its arguments
2219 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2220
2221 You can also use attributes to control memory placement, code
2222 generation options or call/return conventions within the function
2223 being annotated. Many of these attributes are target-specific. For
2224 example, many targets support attributes for defining interrupt
2225 handler functions, which typically must follow special register usage
2226 and return conventions.
2227
2228 Function attributes are introduced by the @code{__attribute__} keyword
2229 on a declaration, followed by an attribute specification inside double
2230 parentheses. You can specify multiple attributes in a declaration by
2231 separating them by commas within the double parentheses or by
2232 immediately following an attribute declaration with another attribute
2233 declaration. @xref{Attribute Syntax}, for the exact rules on
2234 attribute syntax and placement.
2235
2236 GCC also supports attributes on
2237 variable declarations (@pxref{Variable Attributes}),
2238 labels (@pxref{Label Attributes}),
2239 enumerators (@pxref{Enumerator Attributes}),
2240 and types (@pxref{Type Attributes}).
2241
2242 There is some overlap between the purposes of attributes and pragmas
2243 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2244 found convenient to use @code{__attribute__} to achieve a natural
2245 attachment of attributes to their corresponding declarations, whereas
2246 @code{#pragma} is of use for compatibility with other compilers
2247 or constructs that do not naturally form part of the grammar.
2248
2249 In addition to the attributes documented here,
2250 GCC plugins may provide their own attributes.
2251
2252 @menu
2253 * Common Function Attributes::
2254 * AArch64 Function Attributes::
2255 * ARC Function Attributes::
2256 * ARM Function Attributes::
2257 * AVR Function Attributes::
2258 * Blackfin Function Attributes::
2259 * CR16 Function Attributes::
2260 * Epiphany Function Attributes::
2261 * H8/300 Function Attributes::
2262 * IA-64 Function Attributes::
2263 * M32C Function Attributes::
2264 * M32R/D Function Attributes::
2265 * m68k Function Attributes::
2266 * MCORE Function Attributes::
2267 * MeP Function Attributes::
2268 * MicroBlaze Function Attributes::
2269 * Microsoft Windows Function Attributes::
2270 * MIPS Function Attributes::
2271 * MSP430 Function Attributes::
2272 * NDS32 Function Attributes::
2273 * Nios II Function Attributes::
2274 * Nvidia PTX Function Attributes::
2275 * PowerPC Function Attributes::
2276 * RL78 Function Attributes::
2277 * RX Function Attributes::
2278 * S/390 Function Attributes::
2279 * SH Function Attributes::
2280 * SPU Function Attributes::
2281 * Symbian OS Function Attributes::
2282 * V850 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 no_stack_limit
2883 @cindex @code{no_stack_limit} function attribute
2884 This attribute locally overrides the @option{-fstack-limit-register}
2885 and @option{-fstack-limit-symbol} command-line options; it has the effect
2886 of disabling stack limit checking in the function it applies to.
2887
2888 @item noclone
2889 @cindex @code{noclone} function attribute
2890 This function attribute prevents a function from being considered for
2891 cloning---a mechanism that produces specialized copies of functions
2892 and which is (currently) performed by interprocedural constant
2893 propagation.
2894
2895 @item noinline
2896 @cindex @code{noinline} function attribute
2897 This function attribute prevents a function from being considered for
2898 inlining.
2899 @c Don't enumerate the optimizations by name here; we try to be
2900 @c future-compatible with this mechanism.
2901 If the function does not have side-effects, there are optimizations
2902 other than inlining that cause function calls to be optimized away,
2903 although the function call is live. To keep such calls from being
2904 optimized away, put
2905 @smallexample
2906 asm ("");
2907 @end smallexample
2908
2909 @noindent
2910 (@pxref{Extended Asm}) in the called function, to serve as a special
2911 side-effect.
2912
2913 @item nonnull (@var{arg-index}, @dots{})
2914 @cindex @code{nonnull} function attribute
2915 @cindex functions with non-null pointer arguments
2916 The @code{nonnull} attribute specifies that some function parameters should
2917 be non-null pointers. For instance, the declaration:
2918
2919 @smallexample
2920 extern void *
2921 my_memcpy (void *dest, const void *src, size_t len)
2922 __attribute__((nonnull (1, 2)));
2923 @end smallexample
2924
2925 @noindent
2926 causes the compiler to check that, in calls to @code{my_memcpy},
2927 arguments @var{dest} and @var{src} are non-null. If the compiler
2928 determines that a null pointer is passed in an argument slot marked
2929 as non-null, and the @option{-Wnonnull} option is enabled, a warning
2930 is issued. The compiler may also choose to make optimizations based
2931 on the knowledge that certain function arguments will never be null.
2932
2933 If no argument index list is given to the @code{nonnull} attribute,
2934 all pointer arguments are marked as non-null. To illustrate, the
2935 following declaration is equivalent to the previous example:
2936
2937 @smallexample
2938 extern void *
2939 my_memcpy (void *dest, const void *src, size_t len)
2940 __attribute__((nonnull));
2941 @end smallexample
2942
2943 @item noplt
2944 @cindex @code{noplt} function attribute
2945 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
2946 Calls to functions marked with this attribute in position-independent code
2947 do not use the PLT.
2948
2949 @smallexample
2950 @group
2951 /* Externally defined function foo. */
2952 int foo () __attribute__ ((noplt));
2953
2954 int
2955 main (/* @r{@dots{}} */)
2956 @{
2957 /* @r{@dots{}} */
2958 foo ();
2959 /* @r{@dots{}} */
2960 @}
2961 @end group
2962 @end smallexample
2963
2964 The @code{noplt} attribute on function @code{foo}
2965 tells the compiler to assume that
2966 the function @code{foo} is externally defined and that the call to
2967 @code{foo} must avoid the PLT
2968 in position-independent code.
2969
2970 In position-dependent code, a few targets also convert calls to
2971 functions that are marked to not use the PLT to use the GOT instead.
2972
2973 @item noreturn
2974 @cindex @code{noreturn} function attribute
2975 @cindex functions that never return
2976 A few standard library functions, such as @code{abort} and @code{exit},
2977 cannot return. GCC knows this automatically. Some programs define
2978 their own functions that never return. You can declare them
2979 @code{noreturn} to tell the compiler this fact. For example,
2980
2981 @smallexample
2982 @group
2983 void fatal () __attribute__ ((noreturn));
2984
2985 void
2986 fatal (/* @r{@dots{}} */)
2987 @{
2988 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
2989 exit (1);
2990 @}
2991 @end group
2992 @end smallexample
2993
2994 The @code{noreturn} keyword tells the compiler to assume that
2995 @code{fatal} cannot return. It can then optimize without regard to what
2996 would happen if @code{fatal} ever did return. This makes slightly
2997 better code. More importantly, it helps avoid spurious warnings of
2998 uninitialized variables.
2999
3000 The @code{noreturn} keyword does not affect the exceptional path when that
3001 applies: a @code{noreturn}-marked function may still return to the caller
3002 by throwing an exception or calling @code{longjmp}.
3003
3004 Do not assume that registers saved by the calling function are
3005 restored before calling the @code{noreturn} function.
3006
3007 It does not make sense for a @code{noreturn} function to have a return
3008 type other than @code{void}.
3009
3010 @item nothrow
3011 @cindex @code{nothrow} function attribute
3012 The @code{nothrow} attribute is used to inform the compiler that a
3013 function cannot throw an exception. For example, most functions in
3014 the standard C library can be guaranteed not to throw an exception
3015 with the notable exceptions of @code{qsort} and @code{bsearch} that
3016 take function pointer arguments.
3017
3018 @item optimize
3019 @cindex @code{optimize} function attribute
3020 The @code{optimize} attribute is used to specify that a function is to
3021 be compiled with different optimization options than specified on the
3022 command line. Arguments can either be numbers or strings. Numbers
3023 are assumed to be an optimization level. Strings that begin with
3024 @code{O} are assumed to be an optimization option, while other options
3025 are assumed to be used with a @code{-f} prefix. You can also use the
3026 @samp{#pragma GCC optimize} pragma to set the optimization options
3027 that affect more than one function.
3028 @xref{Function Specific Option Pragmas}, for details about the
3029 @samp{#pragma GCC optimize} pragma.
3030
3031 This can be used for instance to have frequently-executed functions
3032 compiled with more aggressive optimization options that produce faster
3033 and larger code, while other functions can be compiled with less
3034 aggressive options.
3035
3036 @item pure
3037 @cindex @code{pure} function attribute
3038 @cindex functions that have no side effects
3039 Many functions have no effects except the return value and their
3040 return value depends only on the parameters and/or global variables.
3041 Such a function can be subject
3042 to common subexpression elimination and loop optimization just as an
3043 arithmetic operator would be. These functions should be declared
3044 with the attribute @code{pure}. For example,
3045
3046 @smallexample
3047 int square (int) __attribute__ ((pure));
3048 @end smallexample
3049
3050 @noindent
3051 says that the hypothetical function @code{square} is safe to call
3052 fewer times than the program says.
3053
3054 Some of common examples of pure functions are @code{strlen} or @code{memcmp}.
3055 Interesting non-pure functions are functions with infinite loops or those
3056 depending on volatile memory or other system resource, that may change between
3057 two consecutive calls (such as @code{feof} in a multithreading environment).
3058
3059 @item returns_nonnull
3060 @cindex @code{returns_nonnull} function attribute
3061 The @code{returns_nonnull} attribute specifies that the function
3062 return value should be a non-null pointer. For instance, the declaration:
3063
3064 @smallexample
3065 extern void *
3066 mymalloc (size_t len) __attribute__((returns_nonnull));
3067 @end smallexample
3068
3069 @noindent
3070 lets the compiler optimize callers based on the knowledge
3071 that the return value will never be null.
3072
3073 @item returns_twice
3074 @cindex @code{returns_twice} function attribute
3075 @cindex functions that return more than once
3076 The @code{returns_twice} attribute tells the compiler that a function may
3077 return more than one time. The compiler ensures that all registers
3078 are dead before calling such a function and emits a warning about
3079 the variables that may be clobbered after the second return from the
3080 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3081 The @code{longjmp}-like counterpart of such function, if any, might need
3082 to be marked with the @code{noreturn} attribute.
3083
3084 @item section ("@var{section-name}")
3085 @cindex @code{section} function attribute
3086 @cindex functions in arbitrary sections
3087 Normally, the compiler places the code it generates in the @code{text} section.
3088 Sometimes, however, you need additional sections, or you need certain
3089 particular functions to appear in special sections. The @code{section}
3090 attribute specifies that a function lives in a particular section.
3091 For example, the declaration:
3092
3093 @smallexample
3094 extern void foobar (void) __attribute__ ((section ("bar")));
3095 @end smallexample
3096
3097 @noindent
3098 puts the function @code{foobar} in the @code{bar} section.
3099
3100 Some file formats do not support arbitrary sections so the @code{section}
3101 attribute is not available on all platforms.
3102 If you need to map the entire contents of a module to a particular
3103 section, consider using the facilities of the linker instead.
3104
3105 @item sentinel
3106 @cindex @code{sentinel} function attribute
3107 This function attribute ensures that a parameter in a function call is
3108 an explicit @code{NULL}. The attribute is only valid on variadic
3109 functions. By default, the sentinel is located at position zero, the
3110 last parameter of the function call. If an optional integer position
3111 argument P is supplied to the attribute, the sentinel must be located at
3112 position P counting backwards from the end of the argument list.
3113
3114 @smallexample
3115 __attribute__ ((sentinel))
3116 is equivalent to
3117 __attribute__ ((sentinel(0)))
3118 @end smallexample
3119
3120 The attribute is automatically set with a position of 0 for the built-in
3121 functions @code{execl} and @code{execlp}. The built-in function
3122 @code{execle} has the attribute set with a position of 1.
3123
3124 A valid @code{NULL} in this context is defined as zero with any pointer
3125 type. If your system defines the @code{NULL} macro with an integer type
3126 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3127 with a copy that redefines NULL appropriately.
3128
3129 The warnings for missing or incorrect sentinels are enabled with
3130 @option{-Wformat}.
3131
3132 @item simd
3133 @itemx simd("@var{mask}")
3134 @cindex @code{simd} function attribute
3135 This attribute enables creation of one or more function versions that
3136 can process multiple arguments using SIMD instructions from a
3137 single invocation. Specifying this attribute allows compiler to
3138 assume that such versions are available at link time (provided
3139 in the same or another translation unit). Generated versions are
3140 target-dependent and described in the corresponding Vector ABI document. For
3141 x86_64 target this document can be found
3142 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3143
3144 The optional argument @var{mask} may have the value
3145 @code{notinbranch} or @code{inbranch},
3146 and instructs the compiler to generate non-masked or masked
3147 clones correspondingly. By default, all clones are generated.
3148
3149 The attribute should not be used together with Cilk Plus @code{vector}
3150 attribute on the same function.
3151
3152 If the attribute is specified and @code{#pragma omp declare simd} is
3153 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3154 switch is specified, then the attribute is ignored.
3155
3156 @item stack_protect
3157 @cindex @code{stack_protect} function attribute
3158 This attribute adds stack protection code to the function if
3159 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3160 or @option{-fstack-protector-explicit} are set.
3161
3162 @item target (@var{options})
3163 @cindex @code{target} function attribute
3164 Multiple target back ends implement the @code{target} attribute
3165 to specify that a function is to
3166 be compiled with different target options than specified on the
3167 command line. This can be used for instance to have functions
3168 compiled with a different ISA (instruction set architecture) than the
3169 default. You can also use the @samp{#pragma GCC target} pragma to set
3170 more than one function to be compiled with specific target options.
3171 @xref{Function Specific Option Pragmas}, for details about the
3172 @samp{#pragma GCC target} pragma.
3173
3174 For instance, on an x86, you could declare one function with the
3175 @code{target("sse4.1,arch=core2")} attribute and another with
3176 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3177 compiling the first function with @option{-msse4.1} and
3178 @option{-march=core2} options, and the second function with
3179 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3180 to make sure that a function is only invoked on a machine that
3181 supports the particular ISA it is compiled for (for example by using
3182 @code{cpuid} on x86 to determine what feature bits and architecture
3183 family are used).
3184
3185 @smallexample
3186 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3187 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3188 @end smallexample
3189
3190 You can either use multiple
3191 strings separated by commas to specify multiple options,
3192 or separate the options with a comma (@samp{,}) within a single string.
3193
3194 The options supported are specific to each target; refer to @ref{x86
3195 Function Attributes}, @ref{PowerPC Function Attributes},
3196 @ref{ARM Function Attributes},and @ref{Nios II Function Attributes},
3197 for details.
3198
3199 @item target_clones (@var{options})
3200 @cindex @code{target_clones} function attribute
3201 The @code{target_clones} attribute is used to specify that a function
3202 be cloned into multiple versions compiled with different target options
3203 than specified on the command line. The supported options and restrictions
3204 are the same as for @code{target} attribute.
3205
3206 For instance, on an x86, you could compile a function with
3207 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3208 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3209 It also creates a resolver function (see the @code{ifunc} attribute
3210 above) that dynamically selects a clone suitable for current architecture.
3211
3212 @item unused
3213 @cindex @code{unused} function attribute
3214 This attribute, attached to a function, means that the function is meant
3215 to be possibly unused. GCC does not produce a warning for this
3216 function.
3217
3218 @item used
3219 @cindex @code{used} function attribute
3220 This attribute, attached to a function, means that code must be emitted
3221 for the function even if it appears that the function is not referenced.
3222 This is useful, for example, when the function is referenced only in
3223 inline assembly.
3224
3225 When applied to a member function of a C++ class template, the
3226 attribute also means that the function is instantiated if the
3227 class itself is instantiated.
3228
3229 @item visibility ("@var{visibility_type}")
3230 @cindex @code{visibility} function attribute
3231 This attribute affects the linkage of the declaration to which it is attached.
3232 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3233 (@pxref{Common Type Attributes}) as well as functions.
3234
3235 There are four supported @var{visibility_type} values: default,
3236 hidden, protected or internal visibility.
3237
3238 @smallexample
3239 void __attribute__ ((visibility ("protected")))
3240 f () @{ /* @r{Do something.} */; @}
3241 int i __attribute__ ((visibility ("hidden")));
3242 @end smallexample
3243
3244 The possible values of @var{visibility_type} correspond to the
3245 visibility settings in the ELF gABI.
3246
3247 @table @code
3248 @c keep this list of visibilities in alphabetical order.
3249
3250 @item default
3251 Default visibility is the normal case for the object file format.
3252 This value is available for the visibility attribute to override other
3253 options that may change the assumed visibility of entities.
3254
3255 On ELF, default visibility means that the declaration is visible to other
3256 modules and, in shared libraries, means that the declared entity may be
3257 overridden.
3258
3259 On Darwin, default visibility means that the declaration is visible to
3260 other modules.
3261
3262 Default visibility corresponds to ``external linkage'' in the language.
3263
3264 @item hidden
3265 Hidden visibility indicates that the entity declared has a new
3266 form of linkage, which we call ``hidden linkage''. Two
3267 declarations of an object with hidden linkage refer to the same object
3268 if they are in the same shared object.
3269
3270 @item internal
3271 Internal visibility is like hidden visibility, but with additional
3272 processor specific semantics. Unless otherwise specified by the
3273 psABI, GCC defines internal visibility to mean that a function is
3274 @emph{never} called from another module. Compare this with hidden
3275 functions which, while they cannot be referenced directly by other
3276 modules, can be referenced indirectly via function pointers. By
3277 indicating that a function cannot be called from outside the module,
3278 GCC may for instance omit the load of a PIC register since it is known
3279 that the calling function loaded the correct value.
3280
3281 @item protected
3282 Protected visibility is like default visibility except that it
3283 indicates that references within the defining module bind to the
3284 definition in that module. That is, the declared entity cannot be
3285 overridden by another module.
3286
3287 @end table
3288
3289 All visibilities are supported on many, but not all, ELF targets
3290 (supported when the assembler supports the @samp{.visibility}
3291 pseudo-op). Default visibility is supported everywhere. Hidden
3292 visibility is supported on Darwin targets.
3293
3294 The visibility attribute should be applied only to declarations that
3295 would otherwise have external linkage. The attribute should be applied
3296 consistently, so that the same entity should not be declared with
3297 different settings of the attribute.
3298
3299 In C++, the visibility attribute applies to types as well as functions
3300 and objects, because in C++ types have linkage. A class must not have
3301 greater visibility than its non-static data member types and bases,
3302 and class members default to the visibility of their class. Also, a
3303 declaration without explicit visibility is limited to the visibility
3304 of its type.
3305
3306 In C++, you can mark member functions and static member variables of a
3307 class with the visibility attribute. This is useful if you know a
3308 particular method or static member variable should only be used from
3309 one shared object; then you can mark it hidden while the rest of the
3310 class has default visibility. Care must be taken to avoid breaking
3311 the One Definition Rule; for example, it is usually not useful to mark
3312 an inline method as hidden without marking the whole class as hidden.
3313
3314 A C++ namespace declaration can also have the visibility attribute.
3315
3316 @smallexample
3317 namespace nspace1 __attribute__ ((visibility ("protected")))
3318 @{ /* @r{Do something.} */; @}
3319 @end smallexample
3320
3321 This attribute applies only to the particular namespace body, not to
3322 other definitions of the same namespace; it is equivalent to using
3323 @samp{#pragma GCC visibility} before and after the namespace
3324 definition (@pxref{Visibility Pragmas}).
3325
3326 In C++, if a template argument has limited visibility, this
3327 restriction is implicitly propagated to the template instantiation.
3328 Otherwise, template instantiations and specializations default to the
3329 visibility of their template.
3330
3331 If both the template and enclosing class have explicit visibility, the
3332 visibility from the template is used.
3333
3334 @item warn_unused_result
3335 @cindex @code{warn_unused_result} function attribute
3336 The @code{warn_unused_result} attribute causes a warning to be emitted
3337 if a caller of the function with this attribute does not use its
3338 return value. This is useful for functions where not checking
3339 the result is either a security problem or always a bug, such as
3340 @code{realloc}.
3341
3342 @smallexample
3343 int fn () __attribute__ ((warn_unused_result));
3344 int foo ()
3345 @{
3346 if (fn () < 0) return -1;
3347 fn ();
3348 return 0;
3349 @}
3350 @end smallexample
3351
3352 @noindent
3353 results in warning on line 5.
3354
3355 @item weak
3356 @cindex @code{weak} function attribute
3357 The @code{weak} attribute causes the declaration to be emitted as a weak
3358 symbol rather than a global. This is primarily useful in defining
3359 library functions that can be overridden in user code, though it can
3360 also be used with non-function declarations. Weak symbols are supported
3361 for ELF targets, and also for a.out targets when using the GNU assembler
3362 and linker.
3363
3364 @item weakref
3365 @itemx weakref ("@var{target}")
3366 @cindex @code{weakref} function attribute
3367 The @code{weakref} attribute marks a declaration as a weak reference.
3368 Without arguments, it should be accompanied by an @code{alias} attribute
3369 naming the target symbol. Optionally, the @var{target} may be given as
3370 an argument to @code{weakref} itself. In either case, @code{weakref}
3371 implicitly marks the declaration as @code{weak}. Without a
3372 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3373 @code{weakref} is equivalent to @code{weak}.
3374
3375 @smallexample
3376 static int x() __attribute__ ((weakref ("y")));
3377 /* is equivalent to... */
3378 static int x() __attribute__ ((weak, weakref, alias ("y")));
3379 /* and to... */
3380 static int x() __attribute__ ((weakref));
3381 static int x() __attribute__ ((alias ("y")));
3382 @end smallexample
3383
3384 A weak reference is an alias that does not by itself require a
3385 definition to be given for the target symbol. If the target symbol is
3386 only referenced through weak references, then it becomes a @code{weak}
3387 undefined symbol. If it is directly referenced, however, then such
3388 strong references prevail, and a definition is required for the
3389 symbol, not necessarily in the same translation unit.
3390
3391 The effect is equivalent to moving all references to the alias to a
3392 separate translation unit, renaming the alias to the aliased symbol,
3393 declaring it as weak, compiling the two separate translation units and
3394 performing a reloadable link on them.
3395
3396 At present, a declaration to which @code{weakref} is attached can
3397 only be @code{static}.
3398
3399
3400 @end table
3401
3402 @c This is the end of the target-independent attribute table
3403
3404 @node AArch64 Function Attributes
3405 @subsection AArch64 Function Attributes
3406
3407 The following target-specific function attributes are available for the
3408 AArch64 target. For the most part, these options mirror the behavior of
3409 similar command-line options (@pxref{AArch64 Options}), but on a
3410 per-function basis.
3411
3412 @table @code
3413 @item general-regs-only
3414 @cindex @code{general-regs-only} function attribute, AArch64
3415 Indicates that no floating-point or Advanced SIMD registers should be
3416 used when generating code for this function. If the function explicitly
3417 uses floating-point code, then the compiler gives an error. This is
3418 the same behavior as that of the command-line option
3419 @option{-mgeneral-regs-only}.
3420
3421 @item fix-cortex-a53-835769
3422 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3423 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3424 applied to this function. To explicitly disable the workaround for this
3425 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3426 This corresponds to the behavior of the command line options
3427 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3428
3429 @item cmodel=
3430 @cindex @code{cmodel=} function attribute, AArch64
3431 Indicates that code should be generated for a particular code model for
3432 this function. The behavior and permissible arguments are the same as
3433 for the command line option @option{-mcmodel=}.
3434
3435 @item strict-align
3436 @cindex @code{strict-align} function attribute, AArch64
3437 Indicates that the compiler should not assume that unaligned memory references
3438 are handled by the system. The behavior is the same as for the command-line
3439 option @option{-mstrict-align}.
3440
3441 @item omit-leaf-frame-pointer
3442 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3443 Indicates that the frame pointer should be omitted for a leaf function call.
3444 To keep the frame pointer, the inverse attribute
3445 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3446 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3447 and @option{-mno-omit-leaf-frame-pointer}.
3448
3449 @item tls-dialect=
3450 @cindex @code{tls-dialect=} function attribute, AArch64
3451 Specifies the TLS dialect to use for this function. The behavior and
3452 permissible arguments are the same as for the command-line option
3453 @option{-mtls-dialect=}.
3454
3455 @item arch=
3456 @cindex @code{arch=} function attribute, AArch64
3457 Specifies the architecture version and architectural extensions to use
3458 for this function. The behavior and permissible arguments are the same as
3459 for the @option{-march=} command-line option.
3460
3461 @item tune=
3462 @cindex @code{tune=} function attribute, AArch64
3463 Specifies the core for which to tune the performance of this function.
3464 The behavior and permissible arguments are the same as for the @option{-mtune=}
3465 command-line option.
3466
3467 @item cpu=
3468 @cindex @code{cpu=} function attribute, AArch64
3469 Specifies the core for which to tune the performance of this function and also
3470 whose architectural features to use. The behavior and valid arguments are the
3471 same as for the @option{-mcpu=} command-line option.
3472
3473 @end table
3474
3475 The above target attributes can be specified as follows:
3476
3477 @smallexample
3478 __attribute__((target("@var{attr-string}")))
3479 int
3480 f (int a)
3481 @{
3482 return a + 5;
3483 @}
3484 @end smallexample
3485
3486 where @code{@var{attr-string}} is one of the attribute strings specified above.
3487
3488 Additionally, the architectural extension string may be specified on its
3489 own. This can be used to turn on and off particular architectural extensions
3490 without having to specify a particular architecture version or core. Example:
3491
3492 @smallexample
3493 __attribute__((target("+crc+nocrypto")))
3494 int
3495 foo (int a)
3496 @{
3497 return a + 5;
3498 @}
3499 @end smallexample
3500
3501 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3502 extension and disables the @code{crypto} extension for the function @code{foo}
3503 without modifying an existing @option{-march=} or @option{-mcpu} option.
3504
3505 Multiple target function attributes can be specified by separating them with
3506 a comma. For example:
3507 @smallexample
3508 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3509 int
3510 foo (int a)
3511 @{
3512 return a + 5;
3513 @}
3514 @end smallexample
3515
3516 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3517 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3518
3519 @subsubsection Inlining rules
3520 Specifying target attributes on individual functions or performing link-time
3521 optimization across translation units compiled with different target options
3522 can affect function inlining rules:
3523
3524 In particular, a caller function can inline a callee function only if the
3525 architectural features available to the callee are a subset of the features
3526 available to the caller.
3527 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3528 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3529 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3530 because the all the architectural features that function @code{bar} requires
3531 are available to function @code{foo}. Conversely, function @code{bar} cannot
3532 inline function @code{foo}.
3533
3534 Additionally inlining a function compiled with @option{-mstrict-align} into a
3535 function compiled without @code{-mstrict-align} is not allowed.
3536 However, inlining a function compiled without @option{-mstrict-align} into a
3537 function compiled with @option{-mstrict-align} is allowed.
3538
3539 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3540 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3541 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3542 architectural feature rules specified above.
3543
3544 @node ARC Function Attributes
3545 @subsection ARC Function Attributes
3546
3547 These function attributes are supported by the ARC back end:
3548
3549 @table @code
3550 @item interrupt
3551 @cindex @code{interrupt} function attribute, ARC
3552 Use this attribute to indicate
3553 that the specified function is an interrupt handler. The compiler generates
3554 function entry and exit sequences suitable for use in an interrupt handler
3555 when this attribute is present.
3556
3557 On the ARC, you must specify the kind of interrupt to be handled
3558 in a parameter to the interrupt attribute like this:
3559
3560 @smallexample
3561 void f () __attribute__ ((interrupt ("ilink1")));
3562 @end smallexample
3563
3564 Permissible values for this parameter are: @w{@code{ilink1}} and
3565 @w{@code{ilink2}}.
3566
3567 @item long_call
3568 @itemx medium_call
3569 @itemx short_call
3570 @cindex @code{long_call} function attribute, ARC
3571 @cindex @code{medium_call} function attribute, ARC
3572 @cindex @code{short_call} function attribute, ARC
3573 @cindex indirect calls, ARC
3574 These attributes specify how a particular function is called.
3575 These attributes override the
3576 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3577 command-line switches and @code{#pragma long_calls} settings.
3578
3579 For ARC, a function marked with the @code{long_call} attribute is
3580 always called using register-indirect jump-and-link instructions,
3581 thereby enabling the called function to be placed anywhere within the
3582 32-bit address space. A function marked with the @code{medium_call}
3583 attribute will always be close enough to be called with an unconditional
3584 branch-and-link instruction, which has a 25-bit offset from
3585 the call site. A function marked with the @code{short_call}
3586 attribute will always be close enough to be called with a conditional
3587 branch-and-link instruction, which has a 21-bit offset from
3588 the call site.
3589 @end table
3590
3591 @node ARM Function Attributes
3592 @subsection ARM Function Attributes
3593
3594 These function attributes are supported for ARM targets:
3595
3596 @table @code
3597 @item interrupt
3598 @cindex @code{interrupt} function attribute, ARM
3599 Use this attribute to indicate
3600 that the specified function is an interrupt handler. The compiler generates
3601 function entry and exit sequences suitable for use in an interrupt handler
3602 when this attribute is present.
3603
3604 You can specify the kind of interrupt to be handled by
3605 adding an optional parameter to the interrupt attribute like this:
3606
3607 @smallexample
3608 void f () __attribute__ ((interrupt ("IRQ")));
3609 @end smallexample
3610
3611 @noindent
3612 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3613 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3614
3615 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3616 may be called with a word-aligned stack pointer.
3617
3618 @item isr
3619 @cindex @code{isr} function attribute, ARM
3620 Use this attribute on ARM to write Interrupt Service Routines. This is an
3621 alias to the @code{interrupt} attribute above.
3622
3623 @item long_call
3624 @itemx short_call
3625 @cindex @code{long_call} function attribute, ARM
3626 @cindex @code{short_call} function attribute, ARM
3627 @cindex indirect calls, ARM
3628 These attributes specify how a particular function is called.
3629 These attributes override the
3630 @option{-mlong-calls} (@pxref{ARM Options})
3631 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3632 @code{long_call} attribute indicates that the function might be far
3633 away from the call site and require a different (more expensive)
3634 calling sequence. The @code{short_call} attribute always places
3635 the offset to the function from the call site into the @samp{BL}
3636 instruction directly.
3637
3638 @item naked
3639 @cindex @code{naked} function attribute, ARM
3640 This attribute allows the compiler to construct the
3641 requisite function declaration, while allowing the body of the
3642 function to be assembly code. The specified function will not have
3643 prologue/epilogue sequences generated by the compiler. Only basic
3644 @code{asm} statements can safely be included in naked functions
3645 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3646 basic @code{asm} and C code may appear to work, they cannot be
3647 depended upon to work reliably and are not supported.
3648
3649 @item pcs
3650 @cindex @code{pcs} function attribute, ARM
3651
3652 The @code{pcs} attribute can be used to control the calling convention
3653 used for a function on ARM. The attribute takes an argument that specifies
3654 the calling convention to use.
3655
3656 When compiling using the AAPCS ABI (or a variant of it) then valid
3657 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3658 order to use a variant other than @code{"aapcs"} then the compiler must
3659 be permitted to use the appropriate co-processor registers (i.e., the
3660 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3661 For example,
3662
3663 @smallexample
3664 /* Argument passed in r0, and result returned in r0+r1. */
3665 double f2d (float) __attribute__((pcs("aapcs")));
3666 @end smallexample
3667
3668 Variadic functions always use the @code{"aapcs"} calling convention and
3669 the compiler rejects attempts to specify an alternative.
3670
3671 @item target (@var{options})
3672 @cindex @code{target} function attribute
3673 As discussed in @ref{Common Function Attributes}, this attribute
3674 allows specification of target-specific compilation options.
3675
3676 On ARM, the following options are allowed:
3677
3678 @table @samp
3679 @item thumb
3680 @cindex @code{target("thumb")} function attribute, ARM
3681 Force code generation in the Thumb (T16/T32) ISA, depending on the
3682 architecture level.
3683
3684 @item arm
3685 @cindex @code{target("arm")} function attribute, ARM
3686 Force code generation in the ARM (A32) ISA.
3687
3688 Functions from different modes can be inlined in the caller's mode.
3689
3690 @item fpu=
3691 @cindex @code{target("fpu=")} function attribute, ARM
3692 Specifies the fpu for which to tune the performance of this function.
3693 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3694 command-line option.
3695
3696 @end table
3697
3698 @end table
3699
3700 @node AVR Function Attributes
3701 @subsection AVR Function Attributes
3702
3703 These function attributes are supported by the AVR back end:
3704
3705 @table @code
3706 @item interrupt
3707 @cindex @code{interrupt} function attribute, AVR
3708 Use this attribute to indicate
3709 that the specified function is an interrupt handler. The compiler generates
3710 function entry and exit sequences suitable for use in an interrupt handler
3711 when this attribute is present.
3712
3713 On the AVR, the hardware globally disables interrupts when an
3714 interrupt is executed. The first instruction of an interrupt handler
3715 declared with this attribute is a @code{SEI} instruction to
3716 re-enable interrupts. See also the @code{signal} function attribute
3717 that does not insert a @code{SEI} instruction. If both @code{signal} and
3718 @code{interrupt} are specified for the same function, @code{signal}
3719 is silently ignored.
3720
3721 @item naked
3722 @cindex @code{naked} function attribute, AVR
3723 This attribute allows the compiler to construct the
3724 requisite function declaration, while allowing the body of the
3725 function to be assembly code. The specified function will not have
3726 prologue/epilogue sequences generated by the compiler. Only basic
3727 @code{asm} statements can safely be included in naked functions
3728 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3729 basic @code{asm} and C code may appear to work, they cannot be
3730 depended upon to work reliably and are not supported.
3731
3732 @item OS_main
3733 @itemx OS_task
3734 @cindex @code{OS_main} function attribute, AVR
3735 @cindex @code{OS_task} function attribute, AVR
3736 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3737 do not save/restore any call-saved register in their prologue/epilogue.
3738
3739 The @code{OS_main} attribute can be used when there @emph{is
3740 guarantee} that interrupts are disabled at the time when the function
3741 is entered. This saves resources when the stack pointer has to be
3742 changed to set up a frame for local variables.
3743
3744 The @code{OS_task} attribute can be used when there is @emph{no
3745 guarantee} that interrupts are disabled at that time when the function
3746 is entered like for, e@.g@. task functions in a multi-threading operating
3747 system. In that case, changing the stack pointer register is
3748 guarded by save/clear/restore of the global interrupt enable flag.
3749
3750 The differences to the @code{naked} function attribute are:
3751 @itemize @bullet
3752 @item @code{naked} functions do not have a return instruction whereas
3753 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3754 @code{RETI} return instruction.
3755 @item @code{naked} functions do not set up a frame for local variables
3756 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3757 as needed.
3758 @end itemize
3759
3760 @item signal
3761 @cindex @code{signal} function attribute, AVR
3762 Use this attribute on the AVR to indicate that the specified
3763 function is an interrupt handler. The compiler generates function
3764 entry and exit sequences suitable for use in an interrupt handler when this
3765 attribute is present.
3766
3767 See also the @code{interrupt} function attribute.
3768
3769 The AVR hardware globally disables interrupts when an interrupt is executed.
3770 Interrupt handler functions defined with the @code{signal} attribute
3771 do not re-enable interrupts. It is save to enable interrupts in a
3772 @code{signal} handler. This ``save'' only applies to the code
3773 generated by the compiler and not to the IRQ layout of the
3774 application which is responsibility of the application.
3775
3776 If both @code{signal} and @code{interrupt} are specified for the same
3777 function, @code{signal} is silently ignored.
3778 @end table
3779
3780 @node Blackfin Function Attributes
3781 @subsection Blackfin Function Attributes
3782
3783 These function attributes are supported by the Blackfin back end:
3784
3785 @table @code
3786
3787 @item exception_handler
3788 @cindex @code{exception_handler} function attribute
3789 @cindex exception handler functions, Blackfin
3790 Use this attribute on the Blackfin to indicate that the specified function
3791 is an exception handler. The compiler generates function entry and
3792 exit sequences suitable for use in an exception handler when this
3793 attribute is present.
3794
3795 @item interrupt_handler
3796 @cindex @code{interrupt_handler} function attribute, Blackfin
3797 Use this attribute to
3798 indicate that the specified function is an interrupt handler. The compiler
3799 generates function entry and exit sequences suitable for use in an
3800 interrupt handler when this attribute is present.
3801
3802 @item kspisusp
3803 @cindex @code{kspisusp} function attribute, Blackfin
3804 @cindex User stack pointer in interrupts on the Blackfin
3805 When used together with @code{interrupt_handler}, @code{exception_handler}
3806 or @code{nmi_handler}, code is generated to load the stack pointer
3807 from the USP register in the function prologue.
3808
3809 @item l1_text
3810 @cindex @code{l1_text} function attribute, Blackfin
3811 This attribute specifies a function to be placed into L1 Instruction
3812 SRAM@. The function is put into a specific section named @code{.l1.text}.
3813 With @option{-mfdpic}, function calls with a such function as the callee
3814 or caller uses inlined PLT.
3815
3816 @item l2
3817 @cindex @code{l2} function attribute, Blackfin
3818 This attribute specifies a function to be placed into L2
3819 SRAM. The function is put into a specific section named
3820 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
3821 an inlined PLT.
3822
3823 @item longcall
3824 @itemx shortcall
3825 @cindex indirect calls, Blackfin
3826 @cindex @code{longcall} function attribute, Blackfin
3827 @cindex @code{shortcall} function attribute, Blackfin
3828 The @code{longcall} attribute
3829 indicates that the function might be far away from the call site and
3830 require a different (more expensive) calling sequence. The
3831 @code{shortcall} attribute indicates that the function is always close
3832 enough for the shorter calling sequence to be used. These attributes
3833 override the @option{-mlongcall} switch.
3834
3835 @item nesting
3836 @cindex @code{nesting} function attribute, Blackfin
3837 @cindex Allow nesting in an interrupt handler on the Blackfin processor
3838 Use this attribute together with @code{interrupt_handler},
3839 @code{exception_handler} or @code{nmi_handler} to indicate that the function
3840 entry code should enable nested interrupts or exceptions.
3841
3842 @item nmi_handler
3843 @cindex @code{nmi_handler} function attribute, Blackfin
3844 @cindex NMI handler functions on the Blackfin processor
3845 Use this attribute on the Blackfin to indicate that the specified function
3846 is an NMI handler. The compiler generates function entry and
3847 exit sequences suitable for use in an NMI handler when this
3848 attribute is present.
3849
3850 @item saveall
3851 @cindex @code{saveall} function attribute, Blackfin
3852 @cindex save all registers on the Blackfin
3853 Use this attribute to indicate that
3854 all registers except the stack pointer should be saved in the prologue
3855 regardless of whether they are used or not.
3856 @end table
3857
3858 @node CR16 Function Attributes
3859 @subsection CR16 Function Attributes
3860
3861 These function attributes are supported by the CR16 back end:
3862
3863 @table @code
3864 @item interrupt
3865 @cindex @code{interrupt} function attribute, CR16
3866 Use this attribute to indicate
3867 that the specified function is an interrupt handler. The compiler generates
3868 function entry and exit sequences suitable for use in an interrupt handler
3869 when this attribute is present.
3870 @end table
3871
3872 @node Epiphany Function Attributes
3873 @subsection Epiphany Function Attributes
3874
3875 These function attributes are supported by the Epiphany back end:
3876
3877 @table @code
3878 @item disinterrupt
3879 @cindex @code{disinterrupt} function attribute, Epiphany
3880 This attribute causes the compiler to emit
3881 instructions to disable interrupts for the duration of the given
3882 function.
3883
3884 @item forwarder_section
3885 @cindex @code{forwarder_section} function attribute, Epiphany
3886 This attribute modifies the behavior of an interrupt handler.
3887 The interrupt handler may be in external memory which cannot be
3888 reached by a branch instruction, so generate a local memory trampoline
3889 to transfer control. The single parameter identifies the section where
3890 the trampoline is placed.
3891
3892 @item interrupt
3893 @cindex @code{interrupt} function attribute, Epiphany
3894 Use this attribute to indicate
3895 that the specified function is an interrupt handler. The compiler generates
3896 function entry and exit sequences suitable for use in an interrupt handler
3897 when this attribute is present. It may also generate
3898 a special section with code to initialize the interrupt vector table.
3899
3900 On Epiphany targets one or more optional parameters can be added like this:
3901
3902 @smallexample
3903 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
3904 @end smallexample
3905
3906 Permissible values for these parameters are: @w{@code{reset}},
3907 @w{@code{software_exception}}, @w{@code{page_miss}},
3908 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
3909 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
3910 Multiple parameters indicate that multiple entries in the interrupt
3911 vector table should be initialized for this function, i.e.@: for each
3912 parameter @w{@var{name}}, a jump to the function is emitted in
3913 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
3914 entirely, in which case no interrupt vector table entry is provided.
3915
3916 Note that interrupts are enabled inside the function
3917 unless the @code{disinterrupt} attribute is also specified.
3918
3919 The following examples are all valid uses of these attributes on
3920 Epiphany targets:
3921 @smallexample
3922 void __attribute__ ((interrupt)) universal_handler ();
3923 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
3924 void __attribute__ ((interrupt ("dma0, dma1")))
3925 universal_dma_handler ();
3926 void __attribute__ ((interrupt ("timer0"), disinterrupt))
3927 fast_timer_handler ();
3928 void __attribute__ ((interrupt ("dma0, dma1"),
3929 forwarder_section ("tramp")))
3930 external_dma_handler ();
3931 @end smallexample
3932
3933 @item long_call
3934 @itemx short_call
3935 @cindex @code{long_call} function attribute, Epiphany
3936 @cindex @code{short_call} function attribute, Epiphany
3937 @cindex indirect calls, Epiphany
3938 These attributes specify how a particular function is called.
3939 These attributes override the
3940 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
3941 command-line switch and @code{#pragma long_calls} settings.
3942 @end table
3943
3944
3945 @node H8/300 Function Attributes
3946 @subsection H8/300 Function Attributes
3947
3948 These function attributes are available for H8/300 targets:
3949
3950 @table @code
3951 @item function_vector
3952 @cindex @code{function_vector} function attribute, H8/300
3953 Use this attribute on the H8/300, H8/300H, and H8S to indicate
3954 that the specified function should be called through the function vector.
3955 Calling a function through the function vector reduces code size; however,
3956 the function vector has a limited size (maximum 128 entries on the H8/300
3957 and 64 entries on the H8/300H and H8S)
3958 and shares space with the interrupt vector.
3959
3960 @item interrupt_handler
3961 @cindex @code{interrupt_handler} function attribute, H8/300
3962 Use this attribute on the H8/300, H8/300H, and H8S to
3963 indicate that the specified function is an interrupt handler. The compiler
3964 generates function entry and exit sequences suitable for use in an
3965 interrupt handler when this attribute is present.
3966
3967 @item saveall
3968 @cindex @code{saveall} function attribute, H8/300
3969 @cindex save all registers on the H8/300, H8/300H, and H8S
3970 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
3971 all registers except the stack pointer should be saved in the prologue
3972 regardless of whether they are used or not.
3973 @end table
3974
3975 @node IA-64 Function Attributes
3976 @subsection IA-64 Function Attributes
3977
3978 These function attributes are supported on IA-64 targets:
3979
3980 @table @code
3981 @item syscall_linkage
3982 @cindex @code{syscall_linkage} function attribute, IA-64
3983 This attribute is used to modify the IA-64 calling convention by marking
3984 all input registers as live at all function exits. This makes it possible
3985 to restart a system call after an interrupt without having to save/restore
3986 the input registers. This also prevents kernel data from leaking into
3987 application code.
3988
3989 @item version_id
3990 @cindex @code{version_id} function attribute, IA-64
3991 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
3992 symbol to contain a version string, thus allowing for function level
3993 versioning. HP-UX system header files may use function level versioning
3994 for some system calls.
3995
3996 @smallexample
3997 extern int foo () __attribute__((version_id ("20040821")));
3998 @end smallexample
3999
4000 @noindent
4001 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4002 @end table
4003
4004 @node M32C Function Attributes
4005 @subsection M32C Function Attributes
4006
4007 These function attributes are supported by the M32C back end:
4008
4009 @table @code
4010 @item bank_switch
4011 @cindex @code{bank_switch} function attribute, M32C
4012 When added to an interrupt handler with the M32C port, causes the
4013 prologue and epilogue to use bank switching to preserve the registers
4014 rather than saving them on the stack.
4015
4016 @item fast_interrupt
4017 @cindex @code{fast_interrupt} function attribute, M32C
4018 Use this attribute on the M32C port to indicate that the specified
4019 function is a fast interrupt handler. This is just like the
4020 @code{interrupt} attribute, except that @code{freit} is used to return
4021 instead of @code{reit}.
4022
4023 @item function_vector
4024 @cindex @code{function_vector} function attribute, M16C/M32C
4025 On M16C/M32C targets, the @code{function_vector} attribute declares a
4026 special page subroutine call function. Use of this attribute reduces
4027 the code size by 2 bytes for each call generated to the
4028 subroutine. The argument to the attribute is the vector number entry
4029 from the special page vector table which contains the 16 low-order
4030 bits of the subroutine's entry address. Each vector table has special
4031 page number (18 to 255) that is used in @code{jsrs} instructions.
4032 Jump addresses of the routines are generated by adding 0x0F0000 (in
4033 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4034 2-byte addresses set in the vector table. Therefore you need to ensure
4035 that all the special page vector routines should get mapped within the
4036 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4037 (for M32C).
4038
4039 In the following example 2 bytes are saved for each call to
4040 function @code{foo}.
4041
4042 @smallexample
4043 void foo (void) __attribute__((function_vector(0x18)));
4044 void foo (void)
4045 @{
4046 @}
4047
4048 void bar (void)
4049 @{
4050 foo();
4051 @}
4052 @end smallexample
4053
4054 If functions are defined in one file and are called in another file,
4055 then be sure to write this declaration in both files.
4056
4057 This attribute is ignored for R8C target.
4058
4059 @item interrupt
4060 @cindex @code{interrupt} function attribute, M32C
4061 Use this attribute to indicate
4062 that the specified function is an interrupt handler. The compiler generates
4063 function entry and exit sequences suitable for use in an interrupt handler
4064 when this attribute is present.
4065 @end table
4066
4067 @node M32R/D Function Attributes
4068 @subsection M32R/D Function Attributes
4069
4070 These function attributes are supported by the M32R/D back end:
4071
4072 @table @code
4073 @item interrupt
4074 @cindex @code{interrupt} function attribute, M32R/D
4075 Use this attribute to indicate
4076 that the specified function is an interrupt handler. The compiler generates
4077 function entry and exit sequences suitable for use in an interrupt handler
4078 when this attribute is present.
4079
4080 @item model (@var{model-name})
4081 @cindex @code{model} function attribute, M32R/D
4082 @cindex function addressability on the M32R/D
4083
4084 On the M32R/D, use this attribute to set the addressability of an
4085 object, and of the code generated for a function. The identifier
4086 @var{model-name} is one of @code{small}, @code{medium}, or
4087 @code{large}, representing each of the code models.
4088
4089 Small model objects live in the lower 16MB of memory (so that their
4090 addresses can be loaded with the @code{ld24} instruction), and are
4091 callable with the @code{bl} instruction.
4092
4093 Medium model objects may live anywhere in the 32-bit address space (the
4094 compiler generates @code{seth/add3} instructions to load their addresses),
4095 and are callable with the @code{bl} instruction.
4096
4097 Large model objects may live anywhere in the 32-bit address space (the
4098 compiler generates @code{seth/add3} instructions to load their addresses),
4099 and may not be reachable with the @code{bl} instruction (the compiler
4100 generates the much slower @code{seth/add3/jl} instruction sequence).
4101 @end table
4102
4103 @node m68k Function Attributes
4104 @subsection m68k Function Attributes
4105
4106 These function attributes are supported by the m68k back end:
4107
4108 @table @code
4109 @item interrupt
4110 @itemx interrupt_handler
4111 @cindex @code{interrupt} function attribute, m68k
4112 @cindex @code{interrupt_handler} function attribute, m68k
4113 Use this attribute to
4114 indicate that the specified function is an interrupt handler. The compiler
4115 generates function entry and exit sequences suitable for use in an
4116 interrupt handler when this attribute is present. Either name may be used.
4117
4118 @item interrupt_thread
4119 @cindex @code{interrupt_thread} function attribute, fido
4120 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4121 that the specified function is an interrupt handler that is designed
4122 to run as a thread. The compiler omits generate prologue/epilogue
4123 sequences and replaces the return instruction with a @code{sleep}
4124 instruction. This attribute is available only on fido.
4125 @end table
4126
4127 @node MCORE Function Attributes
4128 @subsection MCORE Function Attributes
4129
4130 These function attributes are supported by the MCORE back end:
4131
4132 @table @code
4133 @item naked
4134 @cindex @code{naked} function attribute, MCORE
4135 This attribute allows the compiler to construct the
4136 requisite function declaration, while allowing the body of the
4137 function to be assembly code. The specified function will not have
4138 prologue/epilogue sequences generated by the compiler. Only basic
4139 @code{asm} statements can safely be included in naked functions
4140 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4141 basic @code{asm} and C code may appear to work, they cannot be
4142 depended upon to work reliably and are not supported.
4143 @end table
4144
4145 @node MeP Function Attributes
4146 @subsection MeP Function Attributes
4147
4148 These function attributes are supported by the MeP back end:
4149
4150 @table @code
4151 @item disinterrupt
4152 @cindex @code{disinterrupt} function attribute, MeP
4153 On MeP targets, this attribute causes the compiler to emit
4154 instructions to disable interrupts for the duration of the given
4155 function.
4156
4157 @item interrupt
4158 @cindex @code{interrupt} function attribute, MeP
4159 Use this attribute to indicate
4160 that the specified function is an interrupt handler. The compiler generates
4161 function entry and exit sequences suitable for use in an interrupt handler
4162 when this attribute is present.
4163
4164 @item near
4165 @cindex @code{near} function attribute, MeP
4166 This attribute causes the compiler to assume the called
4167 function is close enough to use the normal calling convention,
4168 overriding the @option{-mtf} command-line option.
4169
4170 @item far
4171 @cindex @code{far} function attribute, MeP
4172 On MeP targets this causes the compiler to use a calling convention
4173 that assumes the called function is too far away for the built-in
4174 addressing modes.
4175
4176 @item vliw
4177 @cindex @code{vliw} function attribute, MeP
4178 The @code{vliw} attribute tells the compiler to emit
4179 instructions in VLIW mode instead of core mode. Note that this
4180 attribute is not allowed unless a VLIW coprocessor has been configured
4181 and enabled through command-line options.
4182 @end table
4183
4184 @node MicroBlaze Function Attributes
4185 @subsection MicroBlaze Function Attributes
4186
4187 These function attributes are supported on MicroBlaze targets:
4188
4189 @table @code
4190 @item save_volatiles
4191 @cindex @code{save_volatiles} function attribute, MicroBlaze
4192 Use this attribute to indicate that the function is
4193 an interrupt handler. All volatile registers (in addition to non-volatile
4194 registers) are saved in the function prologue. If the function is a leaf
4195 function, only volatiles used by the function are saved. A normal function
4196 return is generated instead of a return from interrupt.
4197
4198 @item break_handler
4199 @cindex @code{break_handler} function attribute, MicroBlaze
4200 @cindex break handler functions
4201 Use this attribute to indicate that
4202 the specified function is a break handler. The compiler generates function
4203 entry and exit sequences suitable for use in an break handler when this
4204 attribute is present. The return from @code{break_handler} is done through
4205 the @code{rtbd} instead of @code{rtsd}.
4206
4207 @smallexample
4208 void f () __attribute__ ((break_handler));
4209 @end smallexample
4210
4211 @item interrupt_handler
4212 @itemx fast_interrupt
4213 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4214 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4215 These attributes indicate that the specified function is an interrupt
4216 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4217 used in low-latency interrupt mode, and @code{interrupt_handler} for
4218 interrupts that do not use low-latency handlers. In both cases, GCC
4219 emits appropriate prologue code and generates a return from the handler
4220 using @code{rtid} instead of @code{rtsd}.
4221 @end table
4222
4223 @node Microsoft Windows Function Attributes
4224 @subsection Microsoft Windows Function Attributes
4225
4226 The following attributes are available on Microsoft Windows and Symbian OS
4227 targets.
4228
4229 @table @code
4230 @item dllexport
4231 @cindex @code{dllexport} function attribute
4232 @cindex @code{__declspec(dllexport)}
4233 On Microsoft Windows targets and Symbian OS targets the
4234 @code{dllexport} attribute causes the compiler to provide a global
4235 pointer to a pointer in a DLL, so that it can be referenced with the
4236 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4237 name is formed by combining @code{_imp__} and the function or variable
4238 name.
4239
4240 You can use @code{__declspec(dllexport)} as a synonym for
4241 @code{__attribute__ ((dllexport))} for compatibility with other
4242 compilers.
4243
4244 On systems that support the @code{visibility} attribute, this
4245 attribute also implies ``default'' visibility. It is an error to
4246 explicitly specify any other visibility.
4247
4248 GCC's default behavior is to emit all inline functions with the
4249 @code{dllexport} attribute. Since this can cause object file-size bloat,
4250 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4251 ignore the attribute for inlined functions unless the
4252 @option{-fkeep-inline-functions} flag is used instead.
4253
4254 The attribute is ignored for undefined symbols.
4255
4256 When applied to C++ classes, the attribute marks defined non-inlined
4257 member functions and static data members as exports. Static consts
4258 initialized in-class are not marked unless they are also defined
4259 out-of-class.
4260
4261 For Microsoft Windows targets there are alternative methods for
4262 including the symbol in the DLL's export table such as using a
4263 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4264 the @option{--export-all} linker flag.
4265
4266 @item dllimport
4267 @cindex @code{dllimport} function attribute
4268 @cindex @code{__declspec(dllimport)}
4269 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4270 attribute causes the compiler to reference a function or variable via
4271 a global pointer to a pointer that is set up by the DLL exporting the
4272 symbol. The attribute implies @code{extern}. On Microsoft Windows
4273 targets, the pointer name is formed by combining @code{_imp__} and the
4274 function or variable name.
4275
4276 You can use @code{__declspec(dllimport)} as a synonym for
4277 @code{__attribute__ ((dllimport))} for compatibility with other
4278 compilers.
4279
4280 On systems that support the @code{visibility} attribute, this
4281 attribute also implies ``default'' visibility. It is an error to
4282 explicitly specify any other visibility.
4283
4284 Currently, the attribute is ignored for inlined functions. If the
4285 attribute is applied to a symbol @emph{definition}, an error is reported.
4286 If a symbol previously declared @code{dllimport} is later defined, the
4287 attribute is ignored in subsequent references, and a warning is emitted.
4288 The attribute is also overridden by a subsequent declaration as
4289 @code{dllexport}.
4290
4291 When applied to C++ classes, the attribute marks non-inlined
4292 member functions and static data members as imports. However, the
4293 attribute is ignored for virtual methods to allow creation of vtables
4294 using thunks.
4295
4296 On the SH Symbian OS target the @code{dllimport} attribute also has
4297 another affect---it can cause the vtable and run-time type information
4298 for a class to be exported. This happens when the class has a
4299 dllimported constructor or a non-inline, non-pure virtual function
4300 and, for either of those two conditions, the class also has an inline
4301 constructor or destructor and has a key function that is defined in
4302 the current translation unit.
4303
4304 For Microsoft Windows targets the use of the @code{dllimport}
4305 attribute on functions is not necessary, but provides a small
4306 performance benefit by eliminating a thunk in the DLL@. The use of the
4307 @code{dllimport} attribute on imported variables can be avoided by passing the
4308 @option{--enable-auto-import} switch to the GNU linker. As with
4309 functions, using the attribute for a variable eliminates a thunk in
4310 the DLL@.
4311
4312 One drawback to using this attribute is that a pointer to a
4313 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4314 address. However, a pointer to a @emph{function} with the
4315 @code{dllimport} attribute can be used as a constant initializer; in
4316 this case, the address of a stub function in the import lib is
4317 referenced. On Microsoft Windows targets, the attribute can be disabled
4318 for functions by setting the @option{-mnop-fun-dllimport} flag.
4319 @end table
4320
4321 @node MIPS Function Attributes
4322 @subsection MIPS Function Attributes
4323
4324 These function attributes are supported by the MIPS back end:
4325
4326 @table @code
4327 @item interrupt
4328 @cindex @code{interrupt} function attribute, MIPS
4329 Use this attribute to indicate that the specified function is an interrupt
4330 handler. The compiler generates function entry and exit sequences suitable
4331 for use in an interrupt handler when this attribute is present.
4332 An optional argument is supported for the interrupt attribute which allows
4333 the interrupt mode to be described. By default GCC assumes the external
4334 interrupt controller (EIC) mode is in use, this can be explicitly set using
4335 @code{eic}. When interrupts are non-masked then the requested Interrupt
4336 Priority Level (IPL) is copied to the current IPL which has the effect of only
4337 enabling higher priority interrupts. To use vectored interrupt mode use
4338 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4339 the behaviour of the non-masked interrupt support and GCC will arrange to mask
4340 all interrupts from sw0 up to and including the specified interrupt vector.
4341
4342 You can use the following attributes to modify the behavior
4343 of an interrupt handler:
4344 @table @code
4345 @item use_shadow_register_set
4346 @cindex @code{use_shadow_register_set} function attribute, MIPS
4347 Assume that the handler uses a shadow register set, instead of
4348 the main general-purpose registers. An optional argument @code{intstack} is
4349 supported to indicate that the shadow register set contains a valid stack
4350 pointer.
4351
4352 @item keep_interrupts_masked
4353 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4354 Keep interrupts masked for the whole function. Without this attribute,
4355 GCC tries to reenable interrupts for as much of the function as it can.
4356
4357 @item use_debug_exception_return
4358 @cindex @code{use_debug_exception_return} function attribute, MIPS
4359 Return using the @code{deret} instruction. Interrupt handlers that don't
4360 have this attribute return using @code{eret} instead.
4361 @end table
4362
4363 You can use any combination of these attributes, as shown below:
4364 @smallexample
4365 void __attribute__ ((interrupt)) v0 ();
4366 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4367 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4368 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4369 void __attribute__ ((interrupt, use_shadow_register_set,
4370 keep_interrupts_masked)) v4 ();
4371 void __attribute__ ((interrupt, use_shadow_register_set,
4372 use_debug_exception_return)) v5 ();
4373 void __attribute__ ((interrupt, keep_interrupts_masked,
4374 use_debug_exception_return)) v6 ();
4375 void __attribute__ ((interrupt, use_shadow_register_set,
4376 keep_interrupts_masked,
4377 use_debug_exception_return)) v7 ();
4378 void __attribute__ ((interrupt("eic"))) v8 ();
4379 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4380 @end smallexample
4381
4382 @item long_call
4383 @itemx near
4384 @itemx far
4385 @cindex indirect calls, MIPS
4386 @cindex @code{long_call} function attribute, MIPS
4387 @cindex @code{near} function attribute, MIPS
4388 @cindex @code{far} function attribute, MIPS
4389 These attributes specify how a particular function is called on MIPS@.
4390 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4391 command-line switch. The @code{long_call} and @code{far} attributes are
4392 synonyms, and cause the compiler to always call
4393 the function by first loading its address into a register, and then using
4394 the contents of that register. The @code{near} attribute has the opposite
4395 effect; it specifies that non-PIC calls should be made using the more
4396 efficient @code{jal} instruction.
4397
4398 @item mips16
4399 @itemx nomips16
4400 @cindex @code{mips16} function attribute, MIPS
4401 @cindex @code{nomips16} function attribute, MIPS
4402
4403 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4404 function attributes to locally select or turn off MIPS16 code generation.
4405 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4406 while MIPS16 code generation is disabled for functions with the
4407 @code{nomips16} attribute. These attributes override the
4408 @option{-mips16} and @option{-mno-mips16} options on the command line
4409 (@pxref{MIPS Options}).
4410
4411 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4412 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4413 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4414 may interact badly with some GCC extensions such as @code{__builtin_apply}
4415 (@pxref{Constructing Calls}).
4416
4417 @item micromips, MIPS
4418 @itemx nomicromips, MIPS
4419 @cindex @code{micromips} function attribute
4420 @cindex @code{nomicromips} function attribute
4421
4422 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4423 function attributes to locally select or turn off microMIPS code generation.
4424 A function with the @code{micromips} attribute is emitted as microMIPS code,
4425 while microMIPS code generation is disabled for functions with the
4426 @code{nomicromips} attribute. These attributes override the
4427 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4428 (@pxref{MIPS Options}).
4429
4430 When compiling files containing mixed microMIPS and non-microMIPS code, the
4431 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4432 command line,
4433 not that within individual functions. Mixed microMIPS and non-microMIPS code
4434 may interact badly with some GCC extensions such as @code{__builtin_apply}
4435 (@pxref{Constructing Calls}).
4436
4437 @item nocompression
4438 @cindex @code{nocompression} function attribute, MIPS
4439 On MIPS targets, you can use the @code{nocompression} function attribute
4440 to locally turn off MIPS16 and microMIPS code generation. This attribute
4441 overrides the @option{-mips16} and @option{-mmicromips} options on the
4442 command line (@pxref{MIPS Options}).
4443 @end table
4444
4445 @node MSP430 Function Attributes
4446 @subsection MSP430 Function Attributes
4447
4448 These function attributes are supported by the MSP430 back end:
4449
4450 @table @code
4451 @item critical
4452 @cindex @code{critical} function attribute, MSP430
4453 Critical functions disable interrupts upon entry and restore the
4454 previous interrupt state upon exit. Critical functions cannot also
4455 have the @code{naked} or @code{reentrant} attributes. They can have
4456 the @code{interrupt} attribute.
4457
4458 @item interrupt
4459 @cindex @code{interrupt} function attribute, MSP430
4460 Use this attribute to indicate
4461 that the specified function is an interrupt handler. The compiler generates
4462 function entry and exit sequences suitable for use in an interrupt handler
4463 when this attribute is present.
4464
4465 You can provide an argument to the interrupt
4466 attribute which specifies a name or number. If the argument is a
4467 number it indicates the slot in the interrupt vector table (0 - 31) to
4468 which this handler should be assigned. If the argument is a name it
4469 is treated as a symbolic name for the vector slot. These names should
4470 match up with appropriate entries in the linker script. By default
4471 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4472 @code{reset} for vector 31 are recognized.
4473
4474 @item naked
4475 @cindex @code{naked} function attribute, MSP430
4476 This attribute allows the compiler to construct the
4477 requisite function declaration, while allowing the body of the
4478 function to be assembly code. The specified function will not have
4479 prologue/epilogue sequences generated by the compiler. Only basic
4480 @code{asm} statements can safely be included in naked functions
4481 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4482 basic @code{asm} and C code may appear to work, they cannot be
4483 depended upon to work reliably and are not supported.
4484
4485 @item reentrant
4486 @cindex @code{reentrant} function attribute, MSP430
4487 Reentrant functions disable interrupts upon entry and enable them
4488 upon exit. Reentrant functions cannot also have the @code{naked}
4489 or @code{critical} attributes. They can have the @code{interrupt}
4490 attribute.
4491
4492 @item wakeup
4493 @cindex @code{wakeup} function attribute, MSP430
4494 This attribute only applies to interrupt functions. It is silently
4495 ignored if applied to a non-interrupt function. A wakeup interrupt
4496 function will rouse the processor from any low-power state that it
4497 might be in when the function exits.
4498
4499 @item lower
4500 @itemx upper
4501 @itemx either
4502 @cindex @code{lower} function attribute, MSP430
4503 @cindex @code{upper} function attribute, MSP430
4504 @cindex @code{either} function attribute, MSP430
4505 On the MSP430 target these attributes can be used to specify whether
4506 the function or variable should be placed into low memory, high
4507 memory, or the placement should be left to the linker to decide. The
4508 attributes are only significant if compiling for the MSP430X
4509 architecture.
4510
4511 The attributes work in conjunction with a linker script that has been
4512 augmented to specify where to place sections with a @code{.lower} and
4513 a @code{.upper} prefix. So, for example, as well as placing the
4514 @code{.data} section, the script also specifies the placement of a
4515 @code{.lower.data} and a @code{.upper.data} section. The intention
4516 is that @code{lower} sections are placed into a small but easier to
4517 access memory region and the upper sections are placed into a larger, but
4518 slower to access, region.
4519
4520 The @code{either} attribute is special. It tells the linker to place
4521 the object into the corresponding @code{lower} section if there is
4522 room for it. If there is insufficient room then the object is placed
4523 into the corresponding @code{upper} section instead. Note that the
4524 placement algorithm is not very sophisticated. It does not attempt to
4525 find an optimal packing of the @code{lower} sections. It just makes
4526 one pass over the objects and does the best that it can. Using the
4527 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4528 options can help the packing, however, since they produce smaller,
4529 easier to pack regions.
4530 @end table
4531
4532 @node NDS32 Function Attributes
4533 @subsection NDS32 Function Attributes
4534
4535 These function attributes are supported by the NDS32 back end:
4536
4537 @table @code
4538 @item exception
4539 @cindex @code{exception} function attribute
4540 @cindex exception handler functions, NDS32
4541 Use this attribute on the NDS32 target to indicate that the specified function
4542 is an exception handler. The compiler will generate corresponding sections
4543 for use in an exception handler.
4544
4545 @item interrupt
4546 @cindex @code{interrupt} function attribute, NDS32
4547 On NDS32 target, this attribute indicates that the specified function
4548 is an interrupt handler. The compiler generates corresponding sections
4549 for use in an interrupt handler. You can use the following attributes
4550 to modify the behavior:
4551 @table @code
4552 @item nested
4553 @cindex @code{nested} function attribute, NDS32
4554 This interrupt service routine is interruptible.
4555 @item not_nested
4556 @cindex @code{not_nested} function attribute, NDS32
4557 This interrupt service routine is not interruptible.
4558 @item nested_ready
4559 @cindex @code{nested_ready} function attribute, NDS32
4560 This interrupt service routine is interruptible after @code{PSW.GIE}
4561 (global interrupt enable) is set. This allows interrupt service routine to
4562 finish some short critical code before enabling interrupts.
4563 @item save_all
4564 @cindex @code{save_all} function attribute, NDS32
4565 The system will help save all registers into stack before entering
4566 interrupt handler.
4567 @item partial_save
4568 @cindex @code{partial_save} function attribute, NDS32
4569 The system will help save caller registers into stack before entering
4570 interrupt handler.
4571 @end table
4572
4573 @item naked
4574 @cindex @code{naked} function attribute, NDS32
4575 This attribute allows the compiler to construct the
4576 requisite function declaration, while allowing the body of the
4577 function to be assembly code. The specified function will not have
4578 prologue/epilogue sequences generated by the compiler. Only basic
4579 @code{asm} statements can safely be included in naked functions
4580 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4581 basic @code{asm} and C code may appear to work, they cannot be
4582 depended upon to work reliably and are not supported.
4583
4584 @item reset
4585 @cindex @code{reset} function attribute, NDS32
4586 @cindex reset handler functions
4587 Use this attribute on the NDS32 target to indicate that the specified function
4588 is a reset handler. The compiler will generate corresponding sections
4589 for use in a reset handler. You can use the following attributes
4590 to provide extra exception handling:
4591 @table @code
4592 @item nmi
4593 @cindex @code{nmi} function attribute, NDS32
4594 Provide a user-defined function to handle NMI exception.
4595 @item warm
4596 @cindex @code{warm} function attribute, NDS32
4597 Provide a user-defined function to handle warm reset exception.
4598 @end table
4599 @end table
4600
4601 @node Nios II Function Attributes
4602 @subsection Nios II Function Attributes
4603
4604 These function attributes are supported by the Nios II back end:
4605
4606 @table @code
4607 @item target (@var{options})
4608 @cindex @code{target} function attribute
4609 As discussed in @ref{Common Function Attributes}, this attribute
4610 allows specification of target-specific compilation options.
4611
4612 When compiling for Nios II, the following options are allowed:
4613
4614 @table @samp
4615 @item custom-@var{insn}=@var{N}
4616 @itemx no-custom-@var{insn}
4617 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4618 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4619 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4620 custom instruction with encoding @var{N} when generating code that uses
4621 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4622 the custom instruction @var{insn}.
4623 These target attributes correspond to the
4624 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4625 command-line options, and support the same set of @var{insn} keywords.
4626 @xref{Nios II Options}, for more information.
4627
4628 @item custom-fpu-cfg=@var{name}
4629 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4630 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4631 command-line option, to select a predefined set of custom instructions
4632 named @var{name}.
4633 @xref{Nios II Options}, for more information.
4634 @end table
4635 @end table
4636
4637 @node Nvidia PTX Function Attributes
4638 @subsection Nvidia PTX Function Attributes
4639
4640 These function attributes are supported by the Nvidia PTX back end:
4641
4642 @table @code
4643 @item kernel
4644 @cindex @code{kernel} attribute, Nvidia PTX
4645 This attribute indicates that the corresponding function should be compiled
4646 as a kernel function, which can be invoked from the host via the CUDA RT
4647 library.
4648 By default functions are only callable only from other PTX functions.
4649
4650 Kernel functions must have @code{void} return type.
4651 @end table
4652
4653 @node PowerPC Function Attributes
4654 @subsection PowerPC Function Attributes
4655
4656 These function attributes are supported by the PowerPC back end:
4657
4658 @table @code
4659 @item longcall
4660 @itemx shortcall
4661 @cindex indirect calls, PowerPC
4662 @cindex @code{longcall} function attribute, PowerPC
4663 @cindex @code{shortcall} function attribute, PowerPC
4664 The @code{longcall} attribute
4665 indicates that the function might be far away from the call site and
4666 require a different (more expensive) calling sequence. The
4667 @code{shortcall} attribute indicates that the function is always close
4668 enough for the shorter calling sequence to be used. These attributes
4669 override both the @option{-mlongcall} switch and
4670 the @code{#pragma longcall} setting.
4671
4672 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4673 calls are necessary.
4674
4675 @item target (@var{options})
4676 @cindex @code{target} function attribute
4677 As discussed in @ref{Common Function Attributes}, this attribute
4678 allows specification of target-specific compilation options.
4679
4680 On the PowerPC, the following options are allowed:
4681
4682 @table @samp
4683 @item altivec
4684 @itemx no-altivec
4685 @cindex @code{target("altivec")} function attribute, PowerPC
4686 Generate code that uses (does not use) AltiVec instructions. In
4687 32-bit code, you cannot enable AltiVec instructions unless
4688 @option{-mabi=altivec} is used on the command line.
4689
4690 @item cmpb
4691 @itemx no-cmpb
4692 @cindex @code{target("cmpb")} function attribute, PowerPC
4693 Generate code that uses (does not use) the compare bytes instruction
4694 implemented on the POWER6 processor and other processors that support
4695 the PowerPC V2.05 architecture.
4696
4697 @item dlmzb
4698 @itemx no-dlmzb
4699 @cindex @code{target("dlmzb")} function attribute, PowerPC
4700 Generate code that uses (does not use) the string-search @samp{dlmzb}
4701 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4702 generated by default when targeting those processors.
4703
4704 @item fprnd
4705 @itemx no-fprnd
4706 @cindex @code{target("fprnd")} function attribute, PowerPC
4707 Generate code that uses (does not use) the FP round to integer
4708 instructions implemented on the POWER5+ processor and other processors
4709 that support the PowerPC V2.03 architecture.
4710
4711 @item hard-dfp
4712 @itemx no-hard-dfp
4713 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4714 Generate code that uses (does not use) the decimal floating-point
4715 instructions implemented on some POWER processors.
4716
4717 @item isel
4718 @itemx no-isel
4719 @cindex @code{target("isel")} function attribute, PowerPC
4720 Generate code that uses (does not use) ISEL instruction.
4721
4722 @item mfcrf
4723 @itemx no-mfcrf
4724 @cindex @code{target("mfcrf")} function attribute, PowerPC
4725 Generate code that uses (does not use) the move from condition
4726 register field instruction implemented on the POWER4 processor and
4727 other processors that support the PowerPC V2.01 architecture.
4728
4729 @item mfpgpr
4730 @itemx no-mfpgpr
4731 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4732 Generate code that uses (does not use) the FP move to/from general
4733 purpose register instructions implemented on the POWER6X processor and
4734 other processors that support the extended PowerPC V2.05 architecture.
4735
4736 @item mulhw
4737 @itemx no-mulhw
4738 @cindex @code{target("mulhw")} function attribute, PowerPC
4739 Generate code that uses (does not use) the half-word multiply and
4740 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4741 These instructions are generated by default when targeting those
4742 processors.
4743
4744 @item multiple
4745 @itemx no-multiple
4746 @cindex @code{target("multiple")} function attribute, PowerPC
4747 Generate code that uses (does not use) the load multiple word
4748 instructions and the store multiple word instructions.
4749
4750 @item update
4751 @itemx no-update
4752 @cindex @code{target("update")} function attribute, PowerPC
4753 Generate code that uses (does not use) the load or store instructions
4754 that update the base register to the address of the calculated memory
4755 location.
4756
4757 @item popcntb
4758 @itemx no-popcntb
4759 @cindex @code{target("popcntb")} function attribute, PowerPC
4760 Generate code that uses (does not use) the popcount and double-precision
4761 FP reciprocal estimate instruction implemented on the POWER5
4762 processor and other processors that support the PowerPC V2.02
4763 architecture.
4764
4765 @item popcntd
4766 @itemx no-popcntd
4767 @cindex @code{target("popcntd")} function attribute, PowerPC
4768 Generate code that uses (does not use) the popcount instruction
4769 implemented on the POWER7 processor and other processors that support
4770 the PowerPC V2.06 architecture.
4771
4772 @item powerpc-gfxopt
4773 @itemx no-powerpc-gfxopt
4774 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
4775 Generate code that uses (does not use) the optional PowerPC
4776 architecture instructions in the Graphics group, including
4777 floating-point select.
4778
4779 @item powerpc-gpopt
4780 @itemx no-powerpc-gpopt
4781 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
4782 Generate code that uses (does not use) the optional PowerPC
4783 architecture instructions in the General Purpose group, including
4784 floating-point square root.
4785
4786 @item recip-precision
4787 @itemx no-recip-precision
4788 @cindex @code{target("recip-precision")} function attribute, PowerPC
4789 Assume (do not assume) that the reciprocal estimate instructions
4790 provide higher-precision estimates than is mandated by the PowerPC
4791 ABI.
4792
4793 @item string
4794 @itemx no-string
4795 @cindex @code{target("string")} function attribute, PowerPC
4796 Generate code that uses (does not use) the load string instructions
4797 and the store string word instructions to save multiple registers and
4798 do small block moves.
4799
4800 @item vsx
4801 @itemx no-vsx
4802 @cindex @code{target("vsx")} function attribute, PowerPC
4803 Generate code that uses (does not use) vector/scalar (VSX)
4804 instructions, and also enable the use of built-in functions that allow
4805 more direct access to the VSX instruction set. In 32-bit code, you
4806 cannot enable VSX or AltiVec instructions unless
4807 @option{-mabi=altivec} is used on the command line.
4808
4809 @item friz
4810 @itemx no-friz
4811 @cindex @code{target("friz")} function attribute, PowerPC
4812 Generate (do not generate) the @code{friz} instruction when the
4813 @option{-funsafe-math-optimizations} option is used to optimize
4814 rounding a floating-point value to 64-bit integer and back to floating
4815 point. The @code{friz} instruction does not return the same value if
4816 the floating-point number is too large to fit in an integer.
4817
4818 @item avoid-indexed-addresses
4819 @itemx no-avoid-indexed-addresses
4820 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
4821 Generate code that tries to avoid (not avoid) the use of indexed load
4822 or store instructions.
4823
4824 @item paired
4825 @itemx no-paired
4826 @cindex @code{target("paired")} function attribute, PowerPC
4827 Generate code that uses (does not use) the generation of PAIRED simd
4828 instructions.
4829
4830 @item longcall
4831 @itemx no-longcall
4832 @cindex @code{target("longcall")} function attribute, PowerPC
4833 Generate code that assumes (does not assume) that all calls are far
4834 away so that a longer more expensive calling sequence is required.
4835
4836 @item cpu=@var{CPU}
4837 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
4838 Specify the architecture to generate code for when compiling the
4839 function. If you select the @code{target("cpu=power7")} attribute when
4840 generating 32-bit code, VSX and AltiVec instructions are not generated
4841 unless you use the @option{-mabi=altivec} option on the command line.
4842
4843 @item tune=@var{TUNE}
4844 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
4845 Specify the architecture to tune for when compiling the function. If
4846 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
4847 you do specify the @code{target("cpu=@var{CPU}")} attribute,
4848 compilation tunes for the @var{CPU} architecture, and not the
4849 default tuning specified on the command line.
4850 @end table
4851
4852 On the PowerPC, the inliner does not inline a
4853 function that has different target options than the caller, unless the
4854 callee has a subset of the target options of the caller.
4855 @end table
4856
4857 @node RL78 Function Attributes
4858 @subsection RL78 Function Attributes
4859
4860 These function attributes are supported by the RL78 back end:
4861
4862 @table @code
4863 @item interrupt
4864 @itemx brk_interrupt
4865 @cindex @code{interrupt} function attribute, RL78
4866 @cindex @code{brk_interrupt} function attribute, RL78
4867 These attributes indicate
4868 that the specified function is an interrupt handler. The compiler generates
4869 function entry and exit sequences suitable for use in an interrupt handler
4870 when this attribute is present.
4871
4872 Use @code{brk_interrupt} instead of @code{interrupt} for
4873 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
4874 that must end with @code{RETB} instead of @code{RETI}).
4875
4876 @item naked
4877 @cindex @code{naked} function attribute, RL78
4878 This attribute allows the compiler to construct the
4879 requisite function declaration, while allowing the body of the
4880 function to be assembly code. The specified function will not have
4881 prologue/epilogue sequences generated by the compiler. Only basic
4882 @code{asm} statements can safely be included in naked functions
4883 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4884 basic @code{asm} and C code may appear to work, they cannot be
4885 depended upon to work reliably and are not supported.
4886 @end table
4887
4888 @node RX Function Attributes
4889 @subsection RX Function Attributes
4890
4891 These function attributes are supported by the RX back end:
4892
4893 @table @code
4894 @item fast_interrupt
4895 @cindex @code{fast_interrupt} function attribute, RX
4896 Use this attribute on the RX port to indicate that the specified
4897 function is a fast interrupt handler. This is just like the
4898 @code{interrupt} attribute, except that @code{freit} is used to return
4899 instead of @code{reit}.
4900
4901 @item interrupt
4902 @cindex @code{interrupt} function attribute, RX
4903 Use this attribute to indicate
4904 that the specified function is an interrupt handler. The compiler generates
4905 function entry and exit sequences suitable for use in an interrupt handler
4906 when this attribute is present.
4907
4908 On RX targets, you may specify one or more vector numbers as arguments
4909 to the attribute, as well as naming an alternate table name.
4910 Parameters are handled sequentially, so one handler can be assigned to
4911 multiple entries in multiple tables. One may also pass the magic
4912 string @code{"$default"} which causes the function to be used for any
4913 unfilled slots in the current table.
4914
4915 This example shows a simple assignment of a function to one vector in
4916 the default table (note that preprocessor macros may be used for
4917 chip-specific symbolic vector names):
4918 @smallexample
4919 void __attribute__ ((interrupt (5))) txd1_handler ();
4920 @end smallexample
4921
4922 This example assigns a function to two slots in the default table
4923 (using preprocessor macros defined elsewhere) and makes it the default
4924 for the @code{dct} table:
4925 @smallexample
4926 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
4927 txd1_handler ();
4928 @end smallexample
4929
4930 @item naked
4931 @cindex @code{naked} function attribute, RX
4932 This attribute allows the compiler to construct the
4933 requisite function declaration, while allowing the body of the
4934 function to be assembly code. The specified function will not have
4935 prologue/epilogue sequences generated by the compiler. Only basic
4936 @code{asm} statements can safely be included in naked functions
4937 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4938 basic @code{asm} and C code may appear to work, they cannot be
4939 depended upon to work reliably and are not supported.
4940
4941 @item vector
4942 @cindex @code{vector} function attribute, RX
4943 This RX attribute is similar to the @code{interrupt} attribute, including its
4944 parameters, but does not make the function an interrupt-handler type
4945 function (i.e. it retains the normal C function calling ABI). See the
4946 @code{interrupt} attribute for a description of its arguments.
4947 @end table
4948
4949 @node S/390 Function Attributes
4950 @subsection S/390 Function Attributes
4951
4952 These function attributes are supported on the S/390:
4953
4954 @table @code
4955 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
4956 @cindex @code{hotpatch} function attribute, S/390
4957
4958 On S/390 System z targets, you can use this function attribute to
4959 make GCC generate a ``hot-patching'' function prologue. If the
4960 @option{-mhotpatch=} command-line option is used at the same time,
4961 the @code{hotpatch} attribute takes precedence. The first of the
4962 two arguments specifies the number of halfwords to be added before
4963 the function label. A second argument can be used to specify the
4964 number of halfwords to be added after the function label. For
4965 both arguments the maximum allowed value is 1000000.
4966
4967 If both arguments are zero, hotpatching is disabled.
4968
4969 @item target (@var{options})
4970 @cindex @code{target} function attribute
4971 As discussed in @ref{Common Function Attributes}, this attribute
4972 allows specification of target-specific compilation options.
4973
4974 On S/390, the following options are supported:
4975
4976 @table @samp
4977 @item arch=
4978 @item tune=
4979 @item stack-guard=
4980 @item stack-size=
4981 @item branch-cost=
4982 @item warn-framesize=
4983 @item backchain
4984 @itemx no-backchain
4985 @item hard-dfp
4986 @itemx no-hard-dfp
4987 @item hard-float
4988 @itemx soft-float
4989 @item htm
4990 @itemx no-htm
4991 @item vx
4992 @itemx no-vx
4993 @item packed-stack
4994 @itemx no-packed-stack
4995 @item small-exec
4996 @itemx no-small-exec
4997 @item mvcle
4998 @itemx no-mvcle
4999 @item warn-dynamicstack
5000 @itemx no-warn-dynamicstack
5001 @end table
5002
5003 The options work exactly like the S/390 specific command line
5004 options (without the prefix @option{-m}) except that they do not
5005 change any feature macros. For example,
5006
5007 @smallexample
5008 @code{target("no-vx")}
5009 @end smallexample
5010
5011 does not undefine the @code{__VEC__} macro.
5012 @end table
5013
5014 @node SH Function Attributes
5015 @subsection SH Function Attributes
5016
5017 These function attributes are supported on the SH family of processors:
5018
5019 @table @code
5020 @item function_vector
5021 @cindex @code{function_vector} function attribute, SH
5022 @cindex calling functions through the function vector on SH2A
5023 On SH2A targets, this attribute declares a function to be called using the
5024 TBR relative addressing mode. The argument to this attribute is the entry
5025 number of the same function in a vector table containing all the TBR
5026 relative addressable functions. For correct operation the TBR must be setup
5027 accordingly to point to the start of the vector table before any functions with
5028 this attribute are invoked. Usually a good place to do the initialization is
5029 the startup routine. The TBR relative vector table can have at max 256 function
5030 entries. The jumps to these functions are generated using a SH2A specific,
5031 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5032 from GNU binutils version 2.7 or later for this attribute to work correctly.
5033
5034 In an application, for a function being called once, this attribute
5035 saves at least 8 bytes of code; and if other successive calls are being
5036 made to the same function, it saves 2 bytes of code per each of these
5037 calls.
5038
5039 @item interrupt_handler
5040 @cindex @code{interrupt_handler} function attribute, SH
5041 Use this attribute to
5042 indicate that the specified function is an interrupt handler. The compiler
5043 generates function entry and exit sequences suitable for use in an
5044 interrupt handler when this attribute is present.
5045
5046 @item nosave_low_regs
5047 @cindex @code{nosave_low_regs} function attribute, SH
5048 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5049 function should not save and restore registers R0..R7. This can be used on SH3*
5050 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5051 interrupt handlers.
5052
5053 @item renesas
5054 @cindex @code{renesas} function attribute, SH
5055 On SH targets this attribute specifies that the function or struct follows the
5056 Renesas ABI.
5057
5058 @item resbank
5059 @cindex @code{resbank} function attribute, SH
5060 On the SH2A target, this attribute enables the high-speed register
5061 saving and restoration using a register bank for @code{interrupt_handler}
5062 routines. Saving to the bank is performed automatically after the CPU
5063 accepts an interrupt that uses a register bank.
5064
5065 The nineteen 32-bit registers comprising general register R0 to R14,
5066 control register GBR, and system registers MACH, MACL, and PR and the
5067 vector table address offset are saved into a register bank. Register
5068 banks are stacked in first-in last-out (FILO) sequence. Restoration
5069 from the bank is executed by issuing a RESBANK instruction.
5070
5071 @item sp_switch
5072 @cindex @code{sp_switch} function attribute, SH
5073 Use this attribute on the SH to indicate an @code{interrupt_handler}
5074 function should switch to an alternate stack. It expects a string
5075 argument that names a global variable holding the address of the
5076 alternate stack.
5077
5078 @smallexample
5079 void *alt_stack;
5080 void f () __attribute__ ((interrupt_handler,
5081 sp_switch ("alt_stack")));
5082 @end smallexample
5083
5084 @item trap_exit
5085 @cindex @code{trap_exit} function attribute, SH
5086 Use this attribute on the SH for an @code{interrupt_handler} to return using
5087 @code{trapa} instead of @code{rte}. This attribute expects an integer
5088 argument specifying the trap number to be used.
5089
5090 @item trapa_handler
5091 @cindex @code{trapa_handler} function attribute, SH
5092 On SH targets this function attribute is similar to @code{interrupt_handler}
5093 but it does not save and restore all registers.
5094 @end table
5095
5096 @node SPU Function Attributes
5097 @subsection SPU Function Attributes
5098
5099 These function attributes are supported by the SPU back end:
5100
5101 @table @code
5102 @item naked
5103 @cindex @code{naked} function attribute, SPU
5104 This attribute allows the compiler to construct the
5105 requisite function declaration, while allowing the body of the
5106 function to be assembly code. The specified function will not have
5107 prologue/epilogue sequences generated by the compiler. Only basic
5108 @code{asm} statements can safely be included in naked functions
5109 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5110 basic @code{asm} and C code may appear to work, they cannot be
5111 depended upon to work reliably and are not supported.
5112 @end table
5113
5114 @node Symbian OS Function Attributes
5115 @subsection Symbian OS Function Attributes
5116
5117 @xref{Microsoft Windows Function Attributes}, for discussion of the
5118 @code{dllexport} and @code{dllimport} attributes.
5119
5120 @node V850 Function Attributes
5121 @subsection V850 Function Attributes
5122
5123 The V850 back end supports these function attributes:
5124
5125 @table @code
5126 @item interrupt
5127 @itemx interrupt_handler
5128 @cindex @code{interrupt} function attribute, V850
5129 @cindex @code{interrupt_handler} function attribute, V850
5130 Use these attributes to indicate
5131 that the specified function is an interrupt handler. The compiler generates
5132 function entry and exit sequences suitable for use in an interrupt handler
5133 when either attribute is present.
5134 @end table
5135
5136 @node Visium Function Attributes
5137 @subsection Visium Function Attributes
5138
5139 These function attributes are supported by the Visium back end:
5140
5141 @table @code
5142 @item interrupt
5143 @cindex @code{interrupt} function attribute, Visium
5144 Use this attribute to indicate
5145 that the specified function is an interrupt handler. The compiler generates
5146 function entry and exit sequences suitable for use in an interrupt handler
5147 when this attribute is present.
5148 @end table
5149
5150 @node x86 Function Attributes
5151 @subsection x86 Function Attributes
5152
5153 These function attributes are supported by the x86 back end:
5154
5155 @table @code
5156 @item cdecl
5157 @cindex @code{cdecl} function attribute, x86-32
5158 @cindex functions that pop the argument stack on x86-32
5159 @opindex mrtd
5160 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5161 assume that the calling function pops off the stack space used to
5162 pass arguments. This is
5163 useful to override the effects of the @option{-mrtd} switch.
5164
5165 @item fastcall
5166 @cindex @code{fastcall} function attribute, x86-32
5167 @cindex functions that pop the argument stack on x86-32
5168 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5169 pass the first argument (if of integral type) in the register ECX and
5170 the second argument (if of integral type) in the register EDX@. Subsequent
5171 and other typed arguments are passed on the stack. The called function
5172 pops the arguments off the stack. If the number of arguments is variable all
5173 arguments are pushed on the stack.
5174
5175 @item thiscall
5176 @cindex @code{thiscall} function attribute, x86-32
5177 @cindex functions that pop the argument stack on x86-32
5178 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5179 pass the first argument (if of integral type) in the register ECX.
5180 Subsequent and other typed arguments are passed on the stack. The called
5181 function pops the arguments off the stack.
5182 If the number of arguments is variable all arguments are pushed on the
5183 stack.
5184 The @code{thiscall} attribute is intended for C++ non-static member functions.
5185 As a GCC extension, this calling convention can be used for C functions
5186 and for static member methods.
5187
5188 @item ms_abi
5189 @itemx sysv_abi
5190 @cindex @code{ms_abi} function attribute, x86
5191 @cindex @code{sysv_abi} function attribute, x86
5192
5193 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5194 to indicate which calling convention should be used for a function. The
5195 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5196 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5197 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5198 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5199
5200 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5201 requires the @option{-maccumulate-outgoing-args} option.
5202
5203 @item callee_pop_aggregate_return (@var{number})
5204 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5205
5206 On x86-32 targets, you can use this attribute to control how
5207 aggregates are returned in memory. If the caller is responsible for
5208 popping the hidden pointer together with the rest of the arguments, specify
5209 @var{number} equal to zero. If callee is responsible for popping the
5210 hidden pointer, specify @var{number} equal to one.
5211
5212 The default x86-32 ABI assumes that the callee pops the
5213 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5214 the compiler assumes that the
5215 caller pops the stack for hidden pointer.
5216
5217 @item ms_hook_prologue
5218 @cindex @code{ms_hook_prologue} function attribute, x86
5219
5220 On 32-bit and 64-bit x86 targets, you can use
5221 this function attribute to make GCC generate the ``hot-patching'' function
5222 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5223 and newer.
5224
5225 @item regparm (@var{number})
5226 @cindex @code{regparm} function attribute, x86
5227 @cindex functions that are passed arguments in registers on x86-32
5228 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5229 pass arguments number one to @var{number} if they are of integral type
5230 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5231 take a variable number of arguments continue to be passed all of their
5232 arguments on the stack.
5233
5234 Beware that on some ELF systems this attribute is unsuitable for
5235 global functions in shared libraries with lazy binding (which is the
5236 default). Lazy binding sends the first call via resolving code in
5237 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5238 per the standard calling conventions. Solaris 8 is affected by this.
5239 Systems with the GNU C Library version 2.1 or higher
5240 and FreeBSD are believed to be
5241 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5242 disabled with the linker or the loader if desired, to avoid the
5243 problem.)
5244
5245 @item sseregparm
5246 @cindex @code{sseregparm} function attribute, x86
5247 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5248 causes the compiler to pass up to 3 floating-point arguments in
5249 SSE registers instead of on the stack. Functions that take a
5250 variable number of arguments continue to pass all of their
5251 floating-point arguments on the stack.
5252
5253 @item force_align_arg_pointer
5254 @cindex @code{force_align_arg_pointer} function attribute, x86
5255 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5256 applied to individual function definitions, generating an alternate
5257 prologue and epilogue that realigns the run-time stack if necessary.
5258 This supports mixing legacy codes that run with a 4-byte aligned stack
5259 with modern codes that keep a 16-byte stack for SSE compatibility.
5260
5261 @item stdcall
5262 @cindex @code{stdcall} function attribute, x86-32
5263 @cindex functions that pop the argument stack on x86-32
5264 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5265 assume that the called function pops off the stack space used to
5266 pass arguments, unless it takes a variable number of arguments.
5267
5268 @item target (@var{options})
5269 @cindex @code{target} function attribute
5270 As discussed in @ref{Common Function Attributes}, this attribute
5271 allows specification of target-specific compilation options.
5272
5273 On the x86, the following options are allowed:
5274 @table @samp
5275 @item abm
5276 @itemx no-abm
5277 @cindex @code{target("abm")} function attribute, x86
5278 Enable/disable the generation of the advanced bit instructions.
5279
5280 @item aes
5281 @itemx no-aes
5282 @cindex @code{target("aes")} function attribute, x86
5283 Enable/disable the generation of the AES instructions.
5284
5285 @item default
5286 @cindex @code{target("default")} function attribute, x86
5287 @xref{Function Multiversioning}, where it is used to specify the
5288 default function version.
5289
5290 @item mmx
5291 @itemx no-mmx
5292 @cindex @code{target("mmx")} function attribute, x86
5293 Enable/disable the generation of the MMX instructions.
5294
5295 @item pclmul
5296 @itemx no-pclmul
5297 @cindex @code{target("pclmul")} function attribute, x86
5298 Enable/disable the generation of the PCLMUL instructions.
5299
5300 @item popcnt
5301 @itemx no-popcnt
5302 @cindex @code{target("popcnt")} function attribute, x86
5303 Enable/disable the generation of the POPCNT instruction.
5304
5305 @item sse
5306 @itemx no-sse
5307 @cindex @code{target("sse")} function attribute, x86
5308 Enable/disable the generation of the SSE instructions.
5309
5310 @item sse2
5311 @itemx no-sse2
5312 @cindex @code{target("sse2")} function attribute, x86
5313 Enable/disable the generation of the SSE2 instructions.
5314
5315 @item sse3
5316 @itemx no-sse3
5317 @cindex @code{target("sse3")} function attribute, x86
5318 Enable/disable the generation of the SSE3 instructions.
5319
5320 @item sse4
5321 @itemx no-sse4
5322 @cindex @code{target("sse4")} function attribute, x86
5323 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5324 and SSE4.2).
5325
5326 @item sse4.1
5327 @itemx no-sse4.1
5328 @cindex @code{target("sse4.1")} function attribute, x86
5329 Enable/disable the generation of the sse4.1 instructions.
5330
5331 @item sse4.2
5332 @itemx no-sse4.2
5333 @cindex @code{target("sse4.2")} function attribute, x86
5334 Enable/disable the generation of the sse4.2 instructions.
5335
5336 @item sse4a
5337 @itemx no-sse4a
5338 @cindex @code{target("sse4a")} function attribute, x86
5339 Enable/disable the generation of the SSE4A instructions.
5340
5341 @item fma4
5342 @itemx no-fma4
5343 @cindex @code{target("fma4")} function attribute, x86
5344 Enable/disable the generation of the FMA4 instructions.
5345
5346 @item xop
5347 @itemx no-xop
5348 @cindex @code{target("xop")} function attribute, x86
5349 Enable/disable the generation of the XOP instructions.
5350
5351 @item lwp
5352 @itemx no-lwp
5353 @cindex @code{target("lwp")} function attribute, x86
5354 Enable/disable the generation of the LWP instructions.
5355
5356 @item ssse3
5357 @itemx no-ssse3
5358 @cindex @code{target("ssse3")} function attribute, x86
5359 Enable/disable the generation of the SSSE3 instructions.
5360
5361 @item cld
5362 @itemx no-cld
5363 @cindex @code{target("cld")} function attribute, x86
5364 Enable/disable the generation of the CLD before string moves.
5365
5366 @item fancy-math-387
5367 @itemx no-fancy-math-387
5368 @cindex @code{target("fancy-math-387")} function attribute, x86
5369 Enable/disable the generation of the @code{sin}, @code{cos}, and
5370 @code{sqrt} instructions on the 387 floating-point unit.
5371
5372 @item fused-madd
5373 @itemx no-fused-madd
5374 @cindex @code{target("fused-madd")} function attribute, x86
5375 Enable/disable the generation of the fused multiply/add instructions.
5376
5377 @item ieee-fp
5378 @itemx no-ieee-fp
5379 @cindex @code{target("ieee-fp")} function attribute, x86
5380 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5381
5382 @item inline-all-stringops
5383 @itemx no-inline-all-stringops
5384 @cindex @code{target("inline-all-stringops")} function attribute, x86
5385 Enable/disable inlining of string operations.
5386
5387 @item inline-stringops-dynamically
5388 @itemx no-inline-stringops-dynamically
5389 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5390 Enable/disable the generation of the inline code to do small string
5391 operations and calling the library routines for large operations.
5392
5393 @item align-stringops
5394 @itemx no-align-stringops
5395 @cindex @code{target("align-stringops")} function attribute, x86
5396 Do/do not align destination of inlined string operations.
5397
5398 @item recip
5399 @itemx no-recip
5400 @cindex @code{target("recip")} function attribute, x86
5401 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5402 instructions followed an additional Newton-Raphson step instead of
5403 doing a floating-point division.
5404
5405 @item arch=@var{ARCH}
5406 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5407 Specify the architecture to generate code for in compiling the function.
5408
5409 @item tune=@var{TUNE}
5410 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5411 Specify the architecture to tune for in compiling the function.
5412
5413 @item fpmath=@var{FPMATH}
5414 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5415 Specify which floating-point unit to use. You must specify the
5416 @code{target("fpmath=sse,387")} option as
5417 @code{target("fpmath=sse+387")} because the comma would separate
5418 different options.
5419 @end table
5420
5421 On the x86, the inliner does not inline a
5422 function that has different target options than the caller, unless the
5423 callee has a subset of the target options of the caller. For example
5424 a function declared with @code{target("sse3")} can inline a function
5425 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5426 @end table
5427
5428 @node Xstormy16 Function Attributes
5429 @subsection Xstormy16 Function Attributes
5430
5431 These function attributes are supported by the Xstormy16 back end:
5432
5433 @table @code
5434 @item interrupt
5435 @cindex @code{interrupt} function attribute, Xstormy16
5436 Use this attribute to indicate
5437 that the specified function is an interrupt handler. The compiler generates
5438 function entry and exit sequences suitable for use in an interrupt handler
5439 when this attribute is present.
5440 @end table
5441
5442 @node Variable Attributes
5443 @section Specifying Attributes of Variables
5444 @cindex attribute of variables
5445 @cindex variable attributes
5446
5447 The keyword @code{__attribute__} allows you to specify special
5448 attributes of variables or structure fields. This keyword is followed
5449 by an attribute specification inside double parentheses. Some
5450 attributes are currently defined generically for variables.
5451 Other attributes are defined for variables on particular target
5452 systems. Other attributes are available for functions
5453 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5454 enumerators (@pxref{Enumerator Attributes}), and for types
5455 (@pxref{Type Attributes}).
5456 Other front ends might define more attributes
5457 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5458
5459 @xref{Attribute Syntax}, for details of the exact syntax for using
5460 attributes.
5461
5462 @menu
5463 * Common Variable Attributes::
5464 * AVR Variable Attributes::
5465 * Blackfin Variable Attributes::
5466 * H8/300 Variable Attributes::
5467 * IA-64 Variable Attributes::
5468 * M32R/D Variable Attributes::
5469 * MeP Variable Attributes::
5470 * Microsoft Windows Variable Attributes::
5471 * MSP430 Variable Attributes::
5472 * PowerPC Variable Attributes::
5473 * RL78 Variable Attributes::
5474 * SPU Variable Attributes::
5475 * V850 Variable Attributes::
5476 * x86 Variable Attributes::
5477 * Xstormy16 Variable Attributes::
5478 @end menu
5479
5480 @node Common Variable Attributes
5481 @subsection Common Variable Attributes
5482
5483 The following attributes are supported on most targets.
5484
5485 @table @code
5486 @cindex @code{aligned} variable attribute
5487 @item aligned (@var{alignment})
5488 This attribute specifies a minimum alignment for the variable or
5489 structure field, measured in bytes. For example, the declaration:
5490
5491 @smallexample
5492 int x __attribute__ ((aligned (16))) = 0;
5493 @end smallexample
5494
5495 @noindent
5496 causes the compiler to allocate the global variable @code{x} on a
5497 16-byte boundary. On a 68040, this could be used in conjunction with
5498 an @code{asm} expression to access the @code{move16} instruction which
5499 requires 16-byte aligned operands.
5500
5501 You can also specify the alignment of structure fields. For example, to
5502 create a double-word aligned @code{int} pair, you could write:
5503
5504 @smallexample
5505 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5506 @end smallexample
5507
5508 @noindent
5509 This is an alternative to creating a union with a @code{double} member,
5510 which forces the union to be double-word aligned.
5511
5512 As in the preceding examples, you can explicitly specify the alignment
5513 (in bytes) that you wish the compiler to use for a given variable or
5514 structure field. Alternatively, you can leave out the alignment factor
5515 and just ask the compiler to align a variable or field to the
5516 default alignment for the target architecture you are compiling for.
5517 The default alignment is sufficient for all scalar types, but may not be
5518 enough for all vector types on a target that supports vector operations.
5519 The default alignment is fixed for a particular target ABI.
5520
5521 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5522 which is the largest alignment ever used for any data type on the
5523 target machine you are compiling for. For example, you could write:
5524
5525 @smallexample
5526 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5527 @end smallexample
5528
5529 The compiler automatically sets the alignment for the declared
5530 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5531 often make copy operations more efficient, because the compiler can
5532 use whatever instructions copy the biggest chunks of memory when
5533 performing copies to or from the variables or fields that you have
5534 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5535 may change depending on command-line options.
5536
5537 When used on a struct, or struct member, the @code{aligned} attribute can
5538 only increase the alignment; in order to decrease it, the @code{packed}
5539 attribute must be specified as well. When used as part of a typedef, the
5540 @code{aligned} attribute can both increase and decrease alignment, and
5541 specifying the @code{packed} attribute generates a warning.
5542
5543 Note that the effectiveness of @code{aligned} attributes may be limited
5544 by inherent limitations in your linker. On many systems, the linker is
5545 only able to arrange for variables to be aligned up to a certain maximum
5546 alignment. (For some linkers, the maximum supported alignment may
5547 be very very small.) If your linker is only able to align variables
5548 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5549 in an @code{__attribute__} still only provides you with 8-byte
5550 alignment. See your linker documentation for further information.
5551
5552 The @code{aligned} attribute can also be used for functions
5553 (@pxref{Common Function Attributes}.)
5554
5555 @item cleanup (@var{cleanup_function})
5556 @cindex @code{cleanup} variable attribute
5557 The @code{cleanup} attribute runs a function when the variable goes
5558 out of scope. This attribute can only be applied to auto function
5559 scope variables; it may not be applied to parameters or variables
5560 with static storage duration. The function must take one parameter,
5561 a pointer to a type compatible with the variable. The return value
5562 of the function (if any) is ignored.
5563
5564 If @option{-fexceptions} is enabled, then @var{cleanup_function}
5565 is run during the stack unwinding that happens during the
5566 processing of the exception. Note that the @code{cleanup} attribute
5567 does not allow the exception to be caught, only to perform an action.
5568 It is undefined what happens if @var{cleanup_function} does not
5569 return normally.
5570
5571 @item common
5572 @itemx nocommon
5573 @cindex @code{common} variable attribute
5574 @cindex @code{nocommon} variable attribute
5575 @opindex fcommon
5576 @opindex fno-common
5577 The @code{common} attribute requests GCC to place a variable in
5578 ``common'' storage. The @code{nocommon} attribute requests the
5579 opposite---to allocate space for it directly.
5580
5581 These attributes override the default chosen by the
5582 @option{-fno-common} and @option{-fcommon} flags respectively.
5583
5584 @item deprecated
5585 @itemx deprecated (@var{msg})
5586 @cindex @code{deprecated} variable attribute
5587 The @code{deprecated} attribute results in a warning if the variable
5588 is used anywhere in the source file. This is useful when identifying
5589 variables that are expected to be removed in a future version of a
5590 program. The warning also includes the location of the declaration
5591 of the deprecated variable, to enable users to easily find further
5592 information about why the variable is deprecated, or what they should
5593 do instead. Note that the warning only occurs for uses:
5594
5595 @smallexample
5596 extern int old_var __attribute__ ((deprecated));
5597 extern int old_var;
5598 int new_fn () @{ return old_var; @}
5599 @end smallexample
5600
5601 @noindent
5602 results in a warning on line 3 but not line 2. The optional @var{msg}
5603 argument, which must be a string, is printed in the warning if
5604 present.
5605
5606 The @code{deprecated} attribute can also be used for functions and
5607 types (@pxref{Common Function Attributes},
5608 @pxref{Common Type Attributes}).
5609
5610 @item mode (@var{mode})
5611 @cindex @code{mode} variable attribute
5612 This attribute specifies the data type for the declaration---whichever
5613 type corresponds to the mode @var{mode}. This in effect lets you
5614 request an integer or floating-point type according to its width.
5615
5616 You may also specify a mode of @code{byte} or @code{__byte__} to
5617 indicate the mode corresponding to a one-byte integer, @code{word} or
5618 @code{__word__} for the mode of a one-word integer, and @code{pointer}
5619 or @code{__pointer__} for the mode used to represent pointers.
5620
5621 @item packed
5622 @cindex @code{packed} variable attribute
5623 The @code{packed} attribute specifies that a variable or structure field
5624 should have the smallest possible alignment---one byte for a variable,
5625 and one bit for a field, unless you specify a larger value with the
5626 @code{aligned} attribute.
5627
5628 Here is a structure in which the field @code{x} is packed, so that it
5629 immediately follows @code{a}:
5630
5631 @smallexample
5632 struct foo
5633 @{
5634 char a;
5635 int x[2] __attribute__ ((packed));
5636 @};
5637 @end smallexample
5638
5639 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
5640 @code{packed} attribute on bit-fields of type @code{char}. This has
5641 been fixed in GCC 4.4 but the change can lead to differences in the
5642 structure layout. See the documentation of
5643 @option{-Wpacked-bitfield-compat} for more information.
5644
5645 @item section ("@var{section-name}")
5646 @cindex @code{section} variable attribute
5647 Normally, the compiler places the objects it generates in sections like
5648 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
5649 or you need certain particular variables to appear in special sections,
5650 for example to map to special hardware. The @code{section}
5651 attribute specifies that a variable (or function) lives in a particular
5652 section. For example, this small program uses several specific section names:
5653
5654 @smallexample
5655 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
5656 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
5657 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
5658 int init_data __attribute__ ((section ("INITDATA")));
5659
5660 main()
5661 @{
5662 /* @r{Initialize stack pointer} */
5663 init_sp (stack + sizeof (stack));
5664
5665 /* @r{Initialize initialized data} */
5666 memcpy (&init_data, &data, &edata - &data);
5667
5668 /* @r{Turn on the serial ports} */
5669 init_duart (&a);
5670 init_duart (&b);
5671 @}
5672 @end smallexample
5673
5674 @noindent
5675 Use the @code{section} attribute with
5676 @emph{global} variables and not @emph{local} variables,
5677 as shown in the example.
5678
5679 You may use the @code{section} attribute with initialized or
5680 uninitialized global variables but the linker requires
5681 each object be defined once, with the exception that uninitialized
5682 variables tentatively go in the @code{common} (or @code{bss}) section
5683 and can be multiply ``defined''. Using the @code{section} attribute
5684 changes what section the variable goes into and may cause the
5685 linker to issue an error if an uninitialized variable has multiple
5686 definitions. You can force a variable to be initialized with the
5687 @option{-fno-common} flag or the @code{nocommon} attribute.
5688
5689 Some file formats do not support arbitrary sections so the @code{section}
5690 attribute is not available on all platforms.
5691 If you need to map the entire contents of a module to a particular
5692 section, consider using the facilities of the linker instead.
5693
5694 @item tls_model ("@var{tls_model}")
5695 @cindex @code{tls_model} variable attribute
5696 The @code{tls_model} attribute sets thread-local storage model
5697 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
5698 overriding @option{-ftls-model=} command-line switch on a per-variable
5699 basis.
5700 The @var{tls_model} argument should be one of @code{global-dynamic},
5701 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
5702
5703 Not all targets support this attribute.
5704
5705 @item unused
5706 @cindex @code{unused} variable attribute
5707 This attribute, attached to a variable, means that the variable is meant
5708 to be possibly unused. GCC does not produce a warning for this
5709 variable.
5710
5711 @item used
5712 @cindex @code{used} variable attribute
5713 This attribute, attached to a variable with static storage, means that
5714 the variable must be emitted even if it appears that the variable is not
5715 referenced.
5716
5717 When applied to a static data member of a C++ class template, the
5718 attribute also means that the member is instantiated if the
5719 class itself is instantiated.
5720
5721 @item vector_size (@var{bytes})
5722 @cindex @code{vector_size} variable attribute
5723 This attribute specifies the vector size for the variable, measured in
5724 bytes. For example, the declaration:
5725
5726 @smallexample
5727 int foo __attribute__ ((vector_size (16)));
5728 @end smallexample
5729
5730 @noindent
5731 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
5732 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
5733 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
5734
5735 This attribute is only applicable to integral and float scalars,
5736 although arrays, pointers, and function return values are allowed in
5737 conjunction with this construct.
5738
5739 Aggregates with this attribute are invalid, even if they are of the same
5740 size as a corresponding scalar. For example, the declaration:
5741
5742 @smallexample
5743 struct S @{ int a; @};
5744 struct S __attribute__ ((vector_size (16))) foo;
5745 @end smallexample
5746
5747 @noindent
5748 is invalid even if the size of the structure is the same as the size of
5749 the @code{int}.
5750
5751 @item visibility ("@var{visibility_type}")
5752 @cindex @code{visibility} variable attribute
5753 This attribute affects the linkage of the declaration to which it is attached.
5754 The @code{visibility} attribute is described in
5755 @ref{Common Function Attributes}.
5756
5757 @item weak
5758 @cindex @code{weak} variable attribute
5759 The @code{weak} attribute is described in
5760 @ref{Common Function Attributes}.
5761
5762 @end table
5763
5764 @node AVR Variable Attributes
5765 @subsection AVR Variable Attributes
5766
5767 @table @code
5768 @item progmem
5769 @cindex @code{progmem} variable attribute, AVR
5770 The @code{progmem} attribute is used on the AVR to place read-only
5771 data in the non-volatile program memory (flash). The @code{progmem}
5772 attribute accomplishes this by putting respective variables into a
5773 section whose name starts with @code{.progmem}.
5774
5775 This attribute works similar to the @code{section} attribute
5776 but adds additional checking. Notice that just like the
5777 @code{section} attribute, @code{progmem} affects the location
5778 of the data but not how this data is accessed.
5779
5780 In order to read data located with the @code{progmem} attribute
5781 (inline) assembler must be used.
5782 @smallexample
5783 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
5784 #include <avr/pgmspace.h>
5785
5786 /* Locate var in flash memory */
5787 const int var[2] PROGMEM = @{ 1, 2 @};
5788
5789 int read_var (int i)
5790 @{
5791 /* Access var[] by accessor macro from avr/pgmspace.h */
5792 return (int) pgm_read_word (& var[i]);
5793 @}
5794 @end smallexample
5795
5796 AVR is a Harvard architecture processor and data and read-only data
5797 normally resides in the data memory (RAM).
5798
5799 See also the @ref{AVR Named Address Spaces} section for
5800 an alternate way to locate and access data in flash memory.
5801
5802 @item io
5803 @itemx io (@var{addr})
5804 @cindex @code{io} variable attribute, AVR
5805 Variables with the @code{io} attribute are used to address
5806 memory-mapped peripherals in the io address range.
5807 If an address is specified, the variable
5808 is assigned that address, and the value is interpreted as an
5809 address in the data address space.
5810 Example:
5811
5812 @smallexample
5813 volatile int porta __attribute__((io (0x22)));
5814 @end smallexample
5815
5816 The address specified in the address in the data address range.
5817
5818 Otherwise, the variable it is not assigned an address, but the
5819 compiler will still use in/out instructions where applicable,
5820 assuming some other module assigns an address in the io address range.
5821 Example:
5822
5823 @smallexample
5824 extern volatile int porta __attribute__((io));
5825 @end smallexample
5826
5827 @item io_low
5828 @itemx io_low (@var{addr})
5829 @cindex @code{io_low} variable attribute, AVR
5830 This is like the @code{io} attribute, but additionally it informs the
5831 compiler that the object lies in the lower half of the I/O area,
5832 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
5833 instructions.
5834
5835 @item address
5836 @itemx address (@var{addr})
5837 @cindex @code{address} variable attribute, AVR
5838 Variables with the @code{address} attribute are used to address
5839 memory-mapped peripherals that may lie outside the io address range.
5840
5841 @smallexample
5842 volatile int porta __attribute__((address (0x600)));
5843 @end smallexample
5844
5845 @end table
5846
5847 @node Blackfin Variable Attributes
5848 @subsection Blackfin Variable Attributes
5849
5850 Three attributes are currently defined for the Blackfin.
5851
5852 @table @code
5853 @item l1_data
5854 @itemx l1_data_A
5855 @itemx l1_data_B
5856 @cindex @code{l1_data} variable attribute, Blackfin
5857 @cindex @code{l1_data_A} variable attribute, Blackfin
5858 @cindex @code{l1_data_B} variable attribute, Blackfin
5859 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
5860 Variables with @code{l1_data} attribute are put into the specific section
5861 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
5862 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
5863 attribute are put into the specific section named @code{.l1.data.B}.
5864
5865 @item l2
5866 @cindex @code{l2} variable attribute, Blackfin
5867 Use this attribute on the Blackfin to place the variable into L2 SRAM.
5868 Variables with @code{l2} attribute are put into the specific section
5869 named @code{.l2.data}.
5870 @end table
5871
5872 @node H8/300 Variable Attributes
5873 @subsection H8/300 Variable Attributes
5874
5875 These variable attributes are available for H8/300 targets:
5876
5877 @table @code
5878 @item eightbit_data
5879 @cindex @code{eightbit_data} variable attribute, H8/300
5880 @cindex eight-bit data on the H8/300, H8/300H, and H8S
5881 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
5882 variable should be placed into the eight-bit data section.
5883 The compiler generates more efficient code for certain operations
5884 on data in the eight-bit data area. Note the eight-bit data area is limited to
5885 256 bytes of data.
5886
5887 You must use GAS and GLD from GNU binutils version 2.7 or later for
5888 this attribute to work correctly.
5889
5890 @item tiny_data
5891 @cindex @code{tiny_data} variable attribute, H8/300
5892 @cindex tiny data section on the H8/300H and H8S
5893 Use this attribute on the H8/300H and H8S to indicate that the specified
5894 variable should be placed into the tiny data section.
5895 The compiler generates more efficient code for loads and stores
5896 on data in the tiny data section. Note the tiny data area is limited to
5897 slightly under 32KB of data.
5898
5899 @end table
5900
5901 @node IA-64 Variable Attributes
5902 @subsection IA-64 Variable Attributes
5903
5904 The IA-64 back end supports the following variable attribute:
5905
5906 @table @code
5907 @item model (@var{model-name})
5908 @cindex @code{model} variable attribute, IA-64
5909
5910 On IA-64, use this attribute to set the addressability of an object.
5911 At present, the only supported identifier for @var{model-name} is
5912 @code{small}, indicating addressability via ``small'' (22-bit)
5913 addresses (so that their addresses can be loaded with the @code{addl}
5914 instruction). Caveat: such addressing is by definition not position
5915 independent and hence this attribute must not be used for objects
5916 defined by shared libraries.
5917
5918 @end table
5919
5920 @node M32R/D Variable Attributes
5921 @subsection M32R/D Variable Attributes
5922
5923 One attribute is currently defined for the M32R/D@.
5924
5925 @table @code
5926 @item model (@var{model-name})
5927 @cindex @code{model-name} variable attribute, M32R/D
5928 @cindex variable addressability on the M32R/D
5929 Use this attribute on the M32R/D to set the addressability of an object.
5930 The identifier @var{model-name} is one of @code{small}, @code{medium},
5931 or @code{large}, representing each of the code models.
5932
5933 Small model objects live in the lower 16MB of memory (so that their
5934 addresses can be loaded with the @code{ld24} instruction).
5935
5936 Medium and large model objects may live anywhere in the 32-bit address space
5937 (the compiler generates @code{seth/add3} instructions to load their
5938 addresses).
5939 @end table
5940
5941 @node MeP Variable Attributes
5942 @subsection MeP Variable Attributes
5943
5944 The MeP target has a number of addressing modes and busses. The
5945 @code{near} space spans the standard memory space's first 16 megabytes
5946 (24 bits). The @code{far} space spans the entire 32-bit memory space.
5947 The @code{based} space is a 128-byte region in the memory space that
5948 is addressed relative to the @code{$tp} register. The @code{tiny}
5949 space is a 65536-byte region relative to the @code{$gp} register. In
5950 addition to these memory regions, the MeP target has a separate 16-bit
5951 control bus which is specified with @code{cb} attributes.
5952
5953 @table @code
5954
5955 @item based
5956 @cindex @code{based} variable attribute, MeP
5957 Any variable with the @code{based} attribute is assigned to the
5958 @code{.based} section, and is accessed with relative to the
5959 @code{$tp} register.
5960
5961 @item tiny
5962 @cindex @code{tiny} variable attribute, MeP
5963 Likewise, the @code{tiny} attribute assigned variables to the
5964 @code{.tiny} section, relative to the @code{$gp} register.
5965
5966 @item near
5967 @cindex @code{near} variable attribute, MeP
5968 Variables with the @code{near} attribute are assumed to have addresses
5969 that fit in a 24-bit addressing mode. This is the default for large
5970 variables (@code{-mtiny=4} is the default) but this attribute can
5971 override @code{-mtiny=} for small variables, or override @code{-ml}.
5972
5973 @item far
5974 @cindex @code{far} variable attribute, MeP
5975 Variables with the @code{far} attribute are addressed using a full
5976 32-bit address. Since this covers the entire memory space, this
5977 allows modules to make no assumptions about where variables might be
5978 stored.
5979
5980 @item io
5981 @cindex @code{io} variable attribute, MeP
5982 @itemx io (@var{addr})
5983 Variables with the @code{io} attribute are used to address
5984 memory-mapped peripherals. If an address is specified, the variable
5985 is assigned that address, else it is not assigned an address (it is
5986 assumed some other module assigns an address). Example:
5987
5988 @smallexample
5989 int timer_count __attribute__((io(0x123)));
5990 @end smallexample
5991
5992 @item cb
5993 @itemx cb (@var{addr})
5994 @cindex @code{cb} variable attribute, MeP
5995 Variables with the @code{cb} attribute are used to access the control
5996 bus, using special instructions. @code{addr} indicates the control bus
5997 address. Example:
5998
5999 @smallexample
6000 int cpu_clock __attribute__((cb(0x123)));
6001 @end smallexample
6002
6003 @end table
6004
6005 @node Microsoft Windows Variable Attributes
6006 @subsection Microsoft Windows Variable Attributes
6007
6008 You can use these attributes on Microsoft Windows targets.
6009 @ref{x86 Variable Attributes} for additional Windows compatibility
6010 attributes available on all x86 targets.
6011
6012 @table @code
6013 @item dllimport
6014 @itemx dllexport
6015 @cindex @code{dllimport} variable attribute
6016 @cindex @code{dllexport} variable attribute
6017 The @code{dllimport} and @code{dllexport} attributes are described in
6018 @ref{Microsoft Windows Function Attributes}.
6019
6020 @item selectany
6021 @cindex @code{selectany} variable attribute
6022 The @code{selectany} attribute causes an initialized global variable to
6023 have link-once semantics. When multiple definitions of the variable are
6024 encountered by the linker, the first is selected and the remainder are
6025 discarded. Following usage by the Microsoft compiler, the linker is told
6026 @emph{not} to warn about size or content differences of the multiple
6027 definitions.
6028
6029 Although the primary usage of this attribute is for POD types, the
6030 attribute can also be applied to global C++ objects that are initialized
6031 by a constructor. In this case, the static initialization and destruction
6032 code for the object is emitted in each translation defining the object,
6033 but the calls to the constructor and destructor are protected by a
6034 link-once guard variable.
6035
6036 The @code{selectany} attribute is only available on Microsoft Windows
6037 targets. You can use @code{__declspec (selectany)} as a synonym for
6038 @code{__attribute__ ((selectany))} for compatibility with other
6039 compilers.
6040
6041 @item shared
6042 @cindex @code{shared} variable attribute
6043 On Microsoft Windows, in addition to putting variable definitions in a named
6044 section, the section can also be shared among all running copies of an
6045 executable or DLL@. For example, this small program defines shared data
6046 by putting it in a named section @code{shared} and marking the section
6047 shareable:
6048
6049 @smallexample
6050 int foo __attribute__((section ("shared"), shared)) = 0;
6051
6052 int
6053 main()
6054 @{
6055 /* @r{Read and write foo. All running
6056 copies see the same value.} */
6057 return 0;
6058 @}
6059 @end smallexample
6060
6061 @noindent
6062 You may only use the @code{shared} attribute along with @code{section}
6063 attribute with a fully-initialized global definition because of the way
6064 linkers work. See @code{section} attribute for more information.
6065
6066 The @code{shared} attribute is only available on Microsoft Windows@.
6067
6068 @end table
6069
6070 @node MSP430 Variable Attributes
6071 @subsection MSP430 Variable Attributes
6072
6073 @table @code
6074 @item noinit
6075 @cindex @code{noinit} variable attribute, MSP430
6076 Any data with the @code{noinit} attribute will not be initialised by
6077 the C runtime startup code, or the program loader. Not initialising
6078 data in this way can reduce program startup times.
6079
6080 @item persistent
6081 @cindex @code{persistent} variable attribute, MSP430
6082 Any variable with the @code{persistent} attribute will not be
6083 initialised by the C runtime startup code. Instead its value will be
6084 set once, when the application is loaded, and then never initialised
6085 again, even if the processor is reset or the program restarts.
6086 Persistent data is intended to be placed into FLASH RAM, where its
6087 value will be retained across resets. The linker script being used to
6088 create the application should ensure that persistent data is correctly
6089 placed.
6090
6091 @item lower
6092 @itemx upper
6093 @itemx either
6094 @cindex @code{lower} variable attribute, MSP430
6095 @cindex @code{upper} variable attribute, MSP430
6096 @cindex @code{either} variable attribute, MSP430
6097 These attributes are the same as the MSP430 function attributes of the
6098 same name (@pxref{MSP430 Function Attributes}).
6099 These attributes can be applied to both functions and variables.
6100 @end table
6101
6102 @node PowerPC Variable Attributes
6103 @subsection PowerPC Variable Attributes
6104
6105 Three attributes currently are defined for PowerPC configurations:
6106 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6107
6108 @cindex @code{ms_struct} variable attribute, PowerPC
6109 @cindex @code{gcc_struct} variable attribute, PowerPC
6110 For full documentation of the struct attributes please see the
6111 documentation in @ref{x86 Variable Attributes}.
6112
6113 @cindex @code{altivec} variable attribute, PowerPC
6114 For documentation of @code{altivec} attribute please see the
6115 documentation in @ref{PowerPC Type Attributes}.
6116
6117 @node RL78 Variable Attributes
6118 @subsection RL78 Variable Attributes
6119
6120 @cindex @code{saddr} variable attribute, RL78
6121 The RL78 back end supports the @code{saddr} variable attribute. This
6122 specifies placement of the corresponding variable in the SADDR area,
6123 which can be accessed more efficiently than the default memory region.
6124
6125 @node SPU Variable Attributes
6126 @subsection SPU Variable Attributes
6127
6128 @cindex @code{spu_vector} variable attribute, SPU
6129 The SPU supports the @code{spu_vector} attribute for variables. For
6130 documentation of this attribute please see the documentation in
6131 @ref{SPU Type Attributes}.
6132
6133 @node V850 Variable Attributes
6134 @subsection V850 Variable Attributes
6135
6136 These variable attributes are supported by the V850 back end:
6137
6138 @table @code
6139
6140 @item sda
6141 @cindex @code{sda} variable attribute, V850
6142 Use this attribute to explicitly place a variable in the small data area,
6143 which can hold up to 64 kilobytes.
6144
6145 @item tda
6146 @cindex @code{tda} variable attribute, V850
6147 Use this attribute to explicitly place a variable in the tiny data area,
6148 which can hold up to 256 bytes in total.
6149
6150 @item zda
6151 @cindex @code{zda} variable attribute, V850
6152 Use this attribute to explicitly place a variable in the first 32 kilobytes
6153 of memory.
6154 @end table
6155
6156 @node x86 Variable Attributes
6157 @subsection x86 Variable Attributes
6158
6159 Two attributes are currently defined for x86 configurations:
6160 @code{ms_struct} and @code{gcc_struct}.
6161
6162 @table @code
6163 @item ms_struct
6164 @itemx gcc_struct
6165 @cindex @code{ms_struct} variable attribute, x86
6166 @cindex @code{gcc_struct} variable attribute, x86
6167
6168 If @code{packed} is used on a structure, or if bit-fields are used,
6169 it may be that the Microsoft ABI lays out the structure differently
6170 than the way GCC normally does. Particularly when moving packed
6171 data between functions compiled with GCC and the native Microsoft compiler
6172 (either via function call or as data in a file), it may be necessary to access
6173 either format.
6174
6175 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6176 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6177 command-line options, respectively;
6178 see @ref{x86 Options}, for details of how structure layout is affected.
6179 @xref{x86 Type Attributes}, for information about the corresponding
6180 attributes on types.
6181
6182 @end table
6183
6184 @node Xstormy16 Variable Attributes
6185 @subsection Xstormy16 Variable Attributes
6186
6187 One attribute is currently defined for xstormy16 configurations:
6188 @code{below100}.
6189
6190 @table @code
6191 @item below100
6192 @cindex @code{below100} variable attribute, Xstormy16
6193
6194 If a variable has the @code{below100} attribute (@code{BELOW100} is
6195 allowed also), GCC places the variable in the first 0x100 bytes of
6196 memory and use special opcodes to access it. Such variables are
6197 placed in either the @code{.bss_below100} section or the
6198 @code{.data_below100} section.
6199
6200 @end table
6201
6202 @node Type Attributes
6203 @section Specifying Attributes of Types
6204 @cindex attribute of types
6205 @cindex type attributes
6206
6207 The keyword @code{__attribute__} allows you to specify special
6208 attributes of types. Some type attributes apply only to @code{struct}
6209 and @code{union} types, while others can apply to any type defined
6210 via a @code{typedef} declaration. Other attributes are defined for
6211 functions (@pxref{Function Attributes}), labels (@pxref{Label
6212 Attributes}), enumerators (@pxref{Enumerator Attributes}), and for
6213 variables (@pxref{Variable Attributes}).
6214
6215 The @code{__attribute__} keyword is followed by an attribute specification
6216 inside double parentheses.
6217
6218 You may specify type attributes in an enum, struct or union type
6219 declaration or definition by placing them immediately after the
6220 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6221 syntax is to place them just past the closing curly brace of the
6222 definition.
6223
6224 You can also include type attributes in a @code{typedef} declaration.
6225 @xref{Attribute Syntax}, for details of the exact syntax for using
6226 attributes.
6227
6228 @menu
6229 * Common Type Attributes::
6230 * ARM Type Attributes::
6231 * MeP Type Attributes::
6232 * PowerPC Type Attributes::
6233 * SPU Type Attributes::
6234 * x86 Type Attributes::
6235 @end menu
6236
6237 @node Common Type Attributes
6238 @subsection Common Type Attributes
6239
6240 The following type attributes are supported on most targets.
6241
6242 @table @code
6243 @cindex @code{aligned} type attribute
6244 @item aligned (@var{alignment})
6245 This attribute specifies a minimum alignment (in bytes) for variables
6246 of the specified type. For example, the declarations:
6247
6248 @smallexample
6249 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6250 typedef int more_aligned_int __attribute__ ((aligned (8)));
6251 @end smallexample
6252
6253 @noindent
6254 force the compiler to ensure (as far as it can) that each variable whose
6255 type is @code{struct S} or @code{more_aligned_int} is allocated and
6256 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6257 variables of type @code{struct S} aligned to 8-byte boundaries allows
6258 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6259 store) instructions when copying one variable of type @code{struct S} to
6260 another, thus improving run-time efficiency.
6261
6262 Note that the alignment of any given @code{struct} or @code{union} type
6263 is required by the ISO C standard to be at least a perfect multiple of
6264 the lowest common multiple of the alignments of all of the members of
6265 the @code{struct} or @code{union} in question. This means that you @emph{can}
6266 effectively adjust the alignment of a @code{struct} or @code{union}
6267 type by attaching an @code{aligned} attribute to any one of the members
6268 of such a type, but the notation illustrated in the example above is a
6269 more obvious, intuitive, and readable way to request the compiler to
6270 adjust the alignment of an entire @code{struct} or @code{union} type.
6271
6272 As in the preceding example, you can explicitly specify the alignment
6273 (in bytes) that you wish the compiler to use for a given @code{struct}
6274 or @code{union} type. Alternatively, you can leave out the alignment factor
6275 and just ask the compiler to align a type to the maximum
6276 useful alignment for the target machine you are compiling for. For
6277 example, you could write:
6278
6279 @smallexample
6280 struct S @{ short f[3]; @} __attribute__ ((aligned));
6281 @end smallexample
6282
6283 Whenever you leave out the alignment factor in an @code{aligned}
6284 attribute specification, the compiler automatically sets the alignment
6285 for the type to the largest alignment that is ever used for any data
6286 type on the target machine you are compiling for. Doing this can often
6287 make copy operations more efficient, because the compiler can use
6288 whatever instructions copy the biggest chunks of memory when performing
6289 copies to or from the variables that have types that you have aligned
6290 this way.
6291
6292 In the example above, if the size of each @code{short} is 2 bytes, then
6293 the size of the entire @code{struct S} type is 6 bytes. The smallest
6294 power of two that is greater than or equal to that is 8, so the
6295 compiler sets the alignment for the entire @code{struct S} type to 8
6296 bytes.
6297
6298 Note that although you can ask the compiler to select a time-efficient
6299 alignment for a given type and then declare only individual stand-alone
6300 objects of that type, the compiler's ability to select a time-efficient
6301 alignment is primarily useful only when you plan to create arrays of
6302 variables having the relevant (efficiently aligned) type. If you
6303 declare or use arrays of variables of an efficiently-aligned type, then
6304 it is likely that your program also does pointer arithmetic (or
6305 subscripting, which amounts to the same thing) on pointers to the
6306 relevant type, and the code that the compiler generates for these
6307 pointer arithmetic operations is often more efficient for
6308 efficiently-aligned types than for other types.
6309
6310 The @code{aligned} attribute can only increase the alignment; but you
6311 can decrease it by specifying @code{packed} as well. See below.
6312
6313 Note that the effectiveness of @code{aligned} attributes may be limited
6314 by inherent limitations in your linker. On many systems, the linker is
6315 only able to arrange for variables to be aligned up to a certain maximum
6316 alignment. (For some linkers, the maximum supported alignment may
6317 be very very small.) If your linker is only able to align variables
6318 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6319 in an @code{__attribute__} still only provides you with 8-byte
6320 alignment. See your linker documentation for further information.
6321
6322 @opindex fshort-enums
6323 Specifying this attribute for @code{struct} and @code{union} types is
6324 equivalent to specifying the @code{packed} attribute on each of the
6325 structure or union members. Specifying the @option{-fshort-enums}
6326 flag on the line is equivalent to specifying the @code{packed}
6327 attribute on all @code{enum} definitions.
6328
6329 In the following example @code{struct my_packed_struct}'s members are
6330 packed closely together, but the internal layout of its @code{s} member
6331 is not packed---to do that, @code{struct my_unpacked_struct} needs to
6332 be packed too.
6333
6334 @smallexample
6335 struct my_unpacked_struct
6336 @{
6337 char c;
6338 int i;
6339 @};
6340
6341 struct __attribute__ ((__packed__)) my_packed_struct
6342 @{
6343 char c;
6344 int i;
6345 struct my_unpacked_struct s;
6346 @};
6347 @end smallexample
6348
6349 You may only specify this attribute on the definition of an @code{enum},
6350 @code{struct} or @code{union}, not on a @code{typedef} that does not
6351 also define the enumerated type, structure or union.
6352
6353 @item bnd_variable_size
6354 @cindex @code{bnd_variable_size} type attribute
6355 @cindex Pointer Bounds Checker attributes
6356 When applied to a structure field, this attribute tells Pointer
6357 Bounds Checker that the size of this field should not be computed
6358 using static type information. It may be used to mark variably-sized
6359 static array fields placed at the end of a structure.
6360
6361 @smallexample
6362 struct S
6363 @{
6364 int size;
6365 char data[1];
6366 @}
6367 S *p = (S *)malloc (sizeof(S) + 100);
6368 p->data[10] = 0; //Bounds violation
6369 @end smallexample
6370
6371 @noindent
6372 By using an attribute for the field we may avoid unwanted bound
6373 violation checks:
6374
6375 @smallexample
6376 struct S
6377 @{
6378 int size;
6379 char data[1] __attribute__((bnd_variable_size));
6380 @}
6381 S *p = (S *)malloc (sizeof(S) + 100);
6382 p->data[10] = 0; //OK
6383 @end smallexample
6384
6385 @item deprecated
6386 @itemx deprecated (@var{msg})
6387 @cindex @code{deprecated} type attribute
6388 The @code{deprecated} attribute results in a warning if the type
6389 is used anywhere in the source file. This is useful when identifying
6390 types that are expected to be removed in a future version of a program.
6391 If possible, the warning also includes the location of the declaration
6392 of the deprecated type, to enable users to easily find further
6393 information about why the type is deprecated, or what they should do
6394 instead. Note that the warnings only occur for uses and then only
6395 if the type is being applied to an identifier that itself is not being
6396 declared as deprecated.
6397
6398 @smallexample
6399 typedef int T1 __attribute__ ((deprecated));
6400 T1 x;
6401 typedef T1 T2;
6402 T2 y;
6403 typedef T1 T3 __attribute__ ((deprecated));
6404 T3 z __attribute__ ((deprecated));
6405 @end smallexample
6406
6407 @noindent
6408 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
6409 warning is issued for line 4 because T2 is not explicitly
6410 deprecated. Line 5 has no warning because T3 is explicitly
6411 deprecated. Similarly for line 6. The optional @var{msg}
6412 argument, which must be a string, is printed in the warning if
6413 present.
6414
6415 The @code{deprecated} attribute can also be used for functions and
6416 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
6417
6418 @item designated_init
6419 @cindex @code{designated_init} type attribute
6420 This attribute may only be applied to structure types. It indicates
6421 that any initialization of an object of this type must use designated
6422 initializers rather than positional initializers. The intent of this
6423 attribute is to allow the programmer to indicate that a structure's
6424 layout may change, and that therefore relying on positional
6425 initialization will result in future breakage.
6426
6427 GCC emits warnings based on this attribute by default; use
6428 @option{-Wno-designated-init} to suppress them.
6429
6430 @item may_alias
6431 @cindex @code{may_alias} type attribute
6432 Accesses through pointers to types with this attribute are not subject
6433 to type-based alias analysis, but are instead assumed to be able to alias
6434 any other type of objects.
6435 In the context of section 6.5 paragraph 7 of the C99 standard,
6436 an lvalue expression
6437 dereferencing such a pointer is treated like having a character type.
6438 See @option{-fstrict-aliasing} for more information on aliasing issues.
6439 This extension exists to support some vector APIs, in which pointers to
6440 one vector type are permitted to alias pointers to a different vector type.
6441
6442 Note that an object of a type with this attribute does not have any
6443 special semantics.
6444
6445 Example of use:
6446
6447 @smallexample
6448 typedef short __attribute__((__may_alias__)) short_a;
6449
6450 int
6451 main (void)
6452 @{
6453 int a = 0x12345678;
6454 short_a *b = (short_a *) &a;
6455
6456 b[1] = 0;
6457
6458 if (a == 0x12345678)
6459 abort();
6460
6461 exit(0);
6462 @}
6463 @end smallexample
6464
6465 @noindent
6466 If you replaced @code{short_a} with @code{short} in the variable
6467 declaration, the above program would abort when compiled with
6468 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
6469 above.
6470
6471 @item packed
6472 @cindex @code{packed} type attribute
6473 This attribute, attached to @code{struct} or @code{union} type
6474 definition, specifies that each member (other than zero-width bit-fields)
6475 of the structure or union is placed to minimize the memory required. When
6476 attached to an @code{enum} definition, it indicates that the smallest
6477 integral type should be used.
6478
6479 @item scalar_storage_order ("@var{endianness}")
6480 @cindex @code{scalar_storage_order} type attribute
6481 When attached to a @code{union} or a @code{struct}, this attribute sets
6482 the storage order, aka endianness, of the scalar fields of the type, as
6483 well as the array fields whose component is scalar. The supported
6484 endianness are @code{big-endian} and @code{little-endian}. The attribute
6485 has no effects on fields which are themselves a @code{union}, a @code{struct}
6486 or an array whose component is a @code{union} or a @code{struct}, and it is
6487 possible to have fields with a different scalar storage order than the
6488 enclosing type.
6489
6490 This attribute is supported only for targets that use a uniform default
6491 scalar storage order (fortunately, most of them), i.e. targets that store
6492 the scalars either all in big-endian or all in little-endian.
6493
6494 Additional restrictions are enforced for types with the reverse scalar
6495 storage order with regard to the scalar storage order of the target:
6496
6497 @itemize
6498 @item Taking the address of a scalar field of a @code{union} or a
6499 @code{struct} with reverse scalar storage order is not permitted and will
6500 yield an error.
6501 @item Taking the address of an array field, whose component is scalar, of
6502 a @code{union} or a @code{struct} with reverse scalar storage order is
6503 permitted but will yield a warning, unless @option{-Wno-scalar-storage-order}
6504 is specified.
6505 @item Taking the address of a @code{union} or a @code{struct} with reverse
6506 scalar storage order is permitted.
6507 @end itemize
6508
6509 These restrictions exist because the storage order attribute is lost when
6510 the address of a scalar or the address of an array with scalar component
6511 is taken, so storing indirectly through this address will generally not work.
6512 The second case is nevertheless allowed to be able to perform a block copy
6513 from or to the array.
6514
6515 @item transparent_union
6516 @cindex @code{transparent_union} type attribute
6517
6518 This attribute, attached to a @code{union} type definition, indicates
6519 that any function parameter having that union type causes calls to that
6520 function to be treated in a special way.
6521
6522 First, the argument corresponding to a transparent union type can be of
6523 any type in the union; no cast is required. Also, if the union contains
6524 a pointer type, the corresponding argument can be a null pointer
6525 constant or a void pointer expression; and if the union contains a void
6526 pointer type, the corresponding argument can be any pointer expression.
6527 If the union member type is a pointer, qualifiers like @code{const} on
6528 the referenced type must be respected, just as with normal pointer
6529 conversions.
6530
6531 Second, the argument is passed to the function using the calling
6532 conventions of the first member of the transparent union, not the calling
6533 conventions of the union itself. All members of the union must have the
6534 same machine representation; this is necessary for this argument passing
6535 to work properly.
6536
6537 Transparent unions are designed for library functions that have multiple
6538 interfaces for compatibility reasons. For example, suppose the
6539 @code{wait} function must accept either a value of type @code{int *} to
6540 comply with POSIX, or a value of type @code{union wait *} to comply with
6541 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
6542 @code{wait} would accept both kinds of arguments, but it would also
6543 accept any other pointer type and this would make argument type checking
6544 less useful. Instead, @code{<sys/wait.h>} might define the interface
6545 as follows:
6546
6547 @smallexample
6548 typedef union __attribute__ ((__transparent_union__))
6549 @{
6550 int *__ip;
6551 union wait *__up;
6552 @} wait_status_ptr_t;
6553
6554 pid_t wait (wait_status_ptr_t);
6555 @end smallexample
6556
6557 @noindent
6558 This interface allows either @code{int *} or @code{union wait *}
6559 arguments to be passed, using the @code{int *} calling convention.
6560 The program can call @code{wait} with arguments of either type:
6561
6562 @smallexample
6563 int w1 () @{ int w; return wait (&w); @}
6564 int w2 () @{ union wait w; return wait (&w); @}
6565 @end smallexample
6566
6567 @noindent
6568 With this interface, @code{wait}'s implementation might look like this:
6569
6570 @smallexample
6571 pid_t wait (wait_status_ptr_t p)
6572 @{
6573 return waitpid (-1, p.__ip, 0);
6574 @}
6575 @end smallexample
6576
6577 @item unused
6578 @cindex @code{unused} type attribute
6579 When attached to a type (including a @code{union} or a @code{struct}),
6580 this attribute means that variables of that type are meant to appear
6581 possibly unused. GCC does not produce a warning for any variables of
6582 that type, even if the variable appears to do nothing. This is often
6583 the case with lock or thread classes, which are usually defined and then
6584 not referenced, but contain constructors and destructors that have
6585 nontrivial bookkeeping functions.
6586
6587 @item visibility
6588 @cindex @code{visibility} type attribute
6589 In C++, attribute visibility (@pxref{Function Attributes}) can also be
6590 applied to class, struct, union and enum types. Unlike other type
6591 attributes, the attribute must appear between the initial keyword and
6592 the name of the type; it cannot appear after the body of the type.
6593
6594 Note that the type visibility is applied to vague linkage entities
6595 associated with the class (vtable, typeinfo node, etc.). In
6596 particular, if a class is thrown as an exception in one shared object
6597 and caught in another, the class must have default visibility.
6598 Otherwise the two shared objects are unable to use the same
6599 typeinfo node and exception handling will break.
6600
6601 @end table
6602
6603 To specify multiple attributes, separate them by commas within the
6604 double parentheses: for example, @samp{__attribute__ ((aligned (16),
6605 packed))}.
6606
6607 @node ARM Type Attributes
6608 @subsection ARM Type Attributes
6609
6610 @cindex @code{notshared} type attribute, ARM
6611 On those ARM targets that support @code{dllimport} (such as Symbian
6612 OS), you can use the @code{notshared} attribute to indicate that the
6613 virtual table and other similar data for a class should not be
6614 exported from a DLL@. For example:
6615
6616 @smallexample
6617 class __declspec(notshared) C @{
6618 public:
6619 __declspec(dllimport) C();
6620 virtual void f();
6621 @}
6622
6623 __declspec(dllexport)
6624 C::C() @{@}
6625 @end smallexample
6626
6627 @noindent
6628 In this code, @code{C::C} is exported from the current DLL, but the
6629 virtual table for @code{C} is not exported. (You can use
6630 @code{__attribute__} instead of @code{__declspec} if you prefer, but
6631 most Symbian OS code uses @code{__declspec}.)
6632
6633 @node MeP Type Attributes
6634 @subsection MeP Type Attributes
6635
6636 @cindex @code{based} type attribute, MeP
6637 @cindex @code{tiny} type attribute, MeP
6638 @cindex @code{near} type attribute, MeP
6639 @cindex @code{far} type attribute, MeP
6640 Many of the MeP variable attributes may be applied to types as well.
6641 Specifically, the @code{based}, @code{tiny}, @code{near}, and
6642 @code{far} attributes may be applied to either. The @code{io} and
6643 @code{cb} attributes may not be applied to types.
6644
6645 @node PowerPC Type Attributes
6646 @subsection PowerPC Type Attributes
6647
6648 Three attributes currently are defined for PowerPC configurations:
6649 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6650
6651 @cindex @code{ms_struct} type attribute, PowerPC
6652 @cindex @code{gcc_struct} type attribute, PowerPC
6653 For full documentation of the @code{ms_struct} and @code{gcc_struct}
6654 attributes please see the documentation in @ref{x86 Type Attributes}.
6655
6656 @cindex @code{altivec} type attribute, PowerPC
6657 The @code{altivec} attribute allows one to declare AltiVec vector data
6658 types supported by the AltiVec Programming Interface Manual. The
6659 attribute requires an argument to specify one of three vector types:
6660 @code{vector__}, @code{pixel__} (always followed by unsigned short),
6661 and @code{bool__} (always followed by unsigned).
6662
6663 @smallexample
6664 __attribute__((altivec(vector__)))
6665 __attribute__((altivec(pixel__))) unsigned short
6666 __attribute__((altivec(bool__))) unsigned
6667 @end smallexample
6668
6669 These attributes mainly are intended to support the @code{__vector},
6670 @code{__pixel}, and @code{__bool} AltiVec keywords.
6671
6672 @node SPU Type Attributes
6673 @subsection SPU Type Attributes
6674
6675 @cindex @code{spu_vector} type attribute, SPU
6676 The SPU supports the @code{spu_vector} attribute for types. This attribute
6677 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
6678 Language Extensions Specification. It is intended to support the
6679 @code{__vector} keyword.
6680
6681 @node x86 Type Attributes
6682 @subsection x86 Type Attributes
6683
6684 Two attributes are currently defined for x86 configurations:
6685 @code{ms_struct} and @code{gcc_struct}.
6686
6687 @table @code
6688
6689 @item ms_struct
6690 @itemx gcc_struct
6691 @cindex @code{ms_struct} type attribute, x86
6692 @cindex @code{gcc_struct} type attribute, x86
6693
6694 If @code{packed} is used on a structure, or if bit-fields are used
6695 it may be that the Microsoft ABI packs them differently
6696 than GCC normally packs them. Particularly when moving packed
6697 data between functions compiled with GCC and the native Microsoft compiler
6698 (either via function call or as data in a file), it may be necessary to access
6699 either format.
6700
6701 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6702 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6703 command-line options, respectively;
6704 see @ref{x86 Options}, for details of how structure layout is affected.
6705 @xref{x86 Variable Attributes}, for information about the corresponding
6706 attributes on variables.
6707
6708 @end table
6709
6710 @node Label Attributes
6711 @section Label Attributes
6712 @cindex Label Attributes
6713
6714 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
6715 details of the exact syntax for using attributes. Other attributes are
6716 available for functions (@pxref{Function Attributes}), variables
6717 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
6718 and for types (@pxref{Type Attributes}).
6719
6720 This example uses the @code{cold} label attribute to indicate the
6721 @code{ErrorHandling} branch is unlikely to be taken and that the
6722 @code{ErrorHandling} label is unused:
6723
6724 @smallexample
6725
6726 asm goto ("some asm" : : : : NoError);
6727
6728 /* This branch (the fall-through from the asm) is less commonly used */
6729 ErrorHandling:
6730 __attribute__((cold, unused)); /* Semi-colon is required here */
6731 printf("error\n");
6732 return 0;
6733
6734 NoError:
6735 printf("no error\n");
6736 return 1;
6737 @end smallexample
6738
6739 @table @code
6740 @item unused
6741 @cindex @code{unused} label attribute
6742 This feature is intended for program-generated code that may contain
6743 unused labels, but which is compiled with @option{-Wall}. It is
6744 not normally appropriate to use in it human-written code, though it
6745 could be useful in cases where the code that jumps to the label is
6746 contained within an @code{#ifdef} conditional.
6747
6748 @item hot
6749 @cindex @code{hot} label attribute
6750 The @code{hot} attribute on a label is used to inform the compiler that
6751 the path following the label is more likely than paths that are not so
6752 annotated. This attribute is used in cases where @code{__builtin_expect}
6753 cannot be used, for instance with computed goto or @code{asm goto}.
6754
6755 @item cold
6756 @cindex @code{cold} label attribute
6757 The @code{cold} attribute on labels is used to inform the compiler that
6758 the path following the label is unlikely to be executed. This attribute
6759 is used in cases where @code{__builtin_expect} cannot be used, for instance
6760 with computed goto or @code{asm goto}.
6761
6762 @end table
6763
6764 @node Enumerator Attributes
6765 @section Enumerator Attributes
6766 @cindex Enumerator Attributes
6767
6768 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
6769 details of the exact syntax for using attributes. Other attributes are
6770 available for functions (@pxref{Function Attributes}), variables
6771 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}),
6772 and for types (@pxref{Type Attributes}).
6773
6774 This example uses the @code{deprecated} enumerator attribute to indicate the
6775 @code{oldval} enumerator is deprecated:
6776
6777 @smallexample
6778 enum E @{
6779 oldval __attribute__((deprecated)),
6780 newval
6781 @};
6782
6783 int
6784 fn (void)
6785 @{
6786 return oldval;
6787 @}
6788 @end smallexample
6789
6790 @table @code
6791 @item deprecated
6792 @cindex @code{deprecated} enumerator attribute
6793 The @code{deprecated} attribute results in a warning if the enumerator
6794 is used anywhere in the source file. This is useful when identifying
6795 enumerators that are expected to be removed in a future version of a
6796 program. The warning also includes the location of the declaration
6797 of the deprecated enumerator, to enable users to easily find further
6798 information about why the enumerator is deprecated, or what they should
6799 do instead. Note that the warnings only occurs for uses.
6800
6801 @end table
6802
6803 @node Attribute Syntax
6804 @section Attribute Syntax
6805 @cindex attribute syntax
6806
6807 This section describes the syntax with which @code{__attribute__} may be
6808 used, and the constructs to which attribute specifiers bind, for the C
6809 language. Some details may vary for C++ and Objective-C@. Because of
6810 infelicities in the grammar for attributes, some forms described here
6811 may not be successfully parsed in all cases.
6812
6813 There are some problems with the semantics of attributes in C++. For
6814 example, there are no manglings for attributes, although they may affect
6815 code generation, so problems may arise when attributed types are used in
6816 conjunction with templates or overloading. Similarly, @code{typeid}
6817 does not distinguish between types with different attributes. Support
6818 for attributes in C++ may be restricted in future to attributes on
6819 declarations only, but not on nested declarators.
6820
6821 @xref{Function Attributes}, for details of the semantics of attributes
6822 applying to functions. @xref{Variable Attributes}, for details of the
6823 semantics of attributes applying to variables. @xref{Type Attributes},
6824 for details of the semantics of attributes applying to structure, union
6825 and enumerated types.
6826 @xref{Label Attributes}, for details of the semantics of attributes
6827 applying to labels.
6828 @xref{Enumerator Attributes}, for details of the semantics of attributes
6829 applying to enumerators.
6830
6831 An @dfn{attribute specifier} is of the form
6832 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
6833 is a possibly empty comma-separated sequence of @dfn{attributes}, where
6834 each attribute is one of the following:
6835
6836 @itemize @bullet
6837 @item
6838 Empty. Empty attributes are ignored.
6839
6840 @item
6841 An attribute name
6842 (which may be an identifier such as @code{unused}, or a reserved
6843 word such as @code{const}).
6844
6845 @item
6846 An attribute name followed by a parenthesized list of
6847 parameters for the attribute.
6848 These parameters take one of the following forms:
6849
6850 @itemize @bullet
6851 @item
6852 An identifier. For example, @code{mode} attributes use this form.
6853
6854 @item
6855 An identifier followed by a comma and a non-empty comma-separated list
6856 of expressions. For example, @code{format} attributes use this form.
6857
6858 @item
6859 A possibly empty comma-separated list of expressions. For example,
6860 @code{format_arg} attributes use this form with the list being a single
6861 integer constant expression, and @code{alias} attributes use this form
6862 with the list being a single string constant.
6863 @end itemize
6864 @end itemize
6865
6866 An @dfn{attribute specifier list} is a sequence of one or more attribute
6867 specifiers, not separated by any other tokens.
6868
6869 You may optionally specify attribute names with @samp{__}
6870 preceding and following the name.
6871 This allows you to use them in header files without
6872 being concerned about a possible macro of the same name. For example,
6873 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
6874
6875
6876 @subsubheading Label Attributes
6877
6878 In GNU C, an attribute specifier list may appear after the colon following a
6879 label, other than a @code{case} or @code{default} label. GNU C++ only permits
6880 attributes on labels if the attribute specifier is immediately
6881 followed by a semicolon (i.e., the label applies to an empty
6882 statement). If the semicolon is missing, C++ label attributes are
6883 ambiguous, as it is permissible for a declaration, which could begin
6884 with an attribute list, to be labelled in C++. Declarations cannot be
6885 labelled in C90 or C99, so the ambiguity does not arise there.
6886
6887 @subsubheading Enumerator Attributes
6888
6889 In GNU C, an attribute specifier list may appear as part of an enumerator.
6890 The attribute goes after the enumeration constant, before @code{=}, if
6891 present. The optional attribute in the enumerator appertains to the
6892 enumeration constant. It is not possible to place the attribute after
6893 the constant expression, if present.
6894
6895 @subsubheading Type Attributes
6896
6897 An attribute specifier list may appear as part of a @code{struct},
6898 @code{union} or @code{enum} specifier. It may go either immediately
6899 after the @code{struct}, @code{union} or @code{enum} keyword, or after
6900 the closing brace. The former syntax is preferred.
6901 Where attribute specifiers follow the closing brace, they are considered
6902 to relate to the structure, union or enumerated type defined, not to any
6903 enclosing declaration the type specifier appears in, and the type
6904 defined is not complete until after the attribute specifiers.
6905 @c Otherwise, there would be the following problems: a shift/reduce
6906 @c conflict between attributes binding the struct/union/enum and
6907 @c binding to the list of specifiers/qualifiers; and "aligned"
6908 @c attributes could use sizeof for the structure, but the size could be
6909 @c changed later by "packed" attributes.
6910
6911
6912 @subsubheading All other attributes
6913
6914 Otherwise, an attribute specifier appears as part of a declaration,
6915 counting declarations of unnamed parameters and type names, and relates
6916 to that declaration (which may be nested in another declaration, for
6917 example in the case of a parameter declaration), or to a particular declarator
6918 within a declaration. Where an
6919 attribute specifier is applied to a parameter declared as a function or
6920 an array, it should apply to the function or array rather than the
6921 pointer to which the parameter is implicitly converted, but this is not
6922 yet correctly implemented.
6923
6924 Any list of specifiers and qualifiers at the start of a declaration may
6925 contain attribute specifiers, whether or not such a list may in that
6926 context contain storage class specifiers. (Some attributes, however,
6927 are essentially in the nature of storage class specifiers, and only make
6928 sense where storage class specifiers may be used; for example,
6929 @code{section}.) There is one necessary limitation to this syntax: the
6930 first old-style parameter declaration in a function definition cannot
6931 begin with an attribute specifier, because such an attribute applies to
6932 the function instead by syntax described below (which, however, is not
6933 yet implemented in this case). In some other cases, attribute
6934 specifiers are permitted by this grammar but not yet supported by the
6935 compiler. All attribute specifiers in this place relate to the
6936 declaration as a whole. In the obsolescent usage where a type of
6937 @code{int} is implied by the absence of type specifiers, such a list of
6938 specifiers and qualifiers may be an attribute specifier list with no
6939 other specifiers or qualifiers.
6940
6941 At present, the first parameter in a function prototype must have some
6942 type specifier that is not an attribute specifier; this resolves an
6943 ambiguity in the interpretation of @code{void f(int
6944 (__attribute__((foo)) x))}, but is subject to change. At present, if
6945 the parentheses of a function declarator contain only attributes then
6946 those attributes are ignored, rather than yielding an error or warning
6947 or implying a single parameter of type int, but this is subject to
6948 change.
6949
6950 An attribute specifier list may appear immediately before a declarator
6951 (other than the first) in a comma-separated list of declarators in a
6952 declaration of more than one identifier using a single list of
6953 specifiers and qualifiers. Such attribute specifiers apply
6954 only to the identifier before whose declarator they appear. For
6955 example, in
6956
6957 @smallexample
6958 __attribute__((noreturn)) void d0 (void),
6959 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
6960 d2 (void);
6961 @end smallexample
6962
6963 @noindent
6964 the @code{noreturn} attribute applies to all the functions
6965 declared; the @code{format} attribute only applies to @code{d1}.
6966
6967 An attribute specifier list may appear immediately before the comma,
6968 @code{=} or semicolon terminating the declaration of an identifier other
6969 than a function definition. Such attribute specifiers apply
6970 to the declared object or function. Where an
6971 assembler name for an object or function is specified (@pxref{Asm
6972 Labels}), the attribute must follow the @code{asm}
6973 specification.
6974
6975 An attribute specifier list may, in future, be permitted to appear after
6976 the declarator in a function definition (before any old-style parameter
6977 declarations or the function body).
6978
6979 Attribute specifiers may be mixed with type qualifiers appearing inside
6980 the @code{[]} of a parameter array declarator, in the C99 construct by
6981 which such qualifiers are applied to the pointer to which the array is
6982 implicitly converted. Such attribute specifiers apply to the pointer,
6983 not to the array, but at present this is not implemented and they are
6984 ignored.
6985
6986 An attribute specifier list may appear at the start of a nested
6987 declarator. At present, there are some limitations in this usage: the
6988 attributes correctly apply to the declarator, but for most individual
6989 attributes the semantics this implies are not implemented.
6990 When attribute specifiers follow the @code{*} of a pointer
6991 declarator, they may be mixed with any type qualifiers present.
6992 The following describes the formal semantics of this syntax. It makes the
6993 most sense if you are familiar with the formal specification of
6994 declarators in the ISO C standard.
6995
6996 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
6997 D1}, where @code{T} contains declaration specifiers that specify a type
6998 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
6999 contains an identifier @var{ident}. The type specified for @var{ident}
7000 for derived declarators whose type does not include an attribute
7001 specifier is as in the ISO C standard.
7002
7003 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7004 and the declaration @code{T D} specifies the type
7005 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7006 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7007 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7008
7009 If @code{D1} has the form @code{*
7010 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7011 declaration @code{T D} specifies the type
7012 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7013 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7014 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7015 @var{ident}.
7016
7017 For example,
7018
7019 @smallexample
7020 void (__attribute__((noreturn)) ****f) (void);
7021 @end smallexample
7022
7023 @noindent
7024 specifies the type ``pointer to pointer to pointer to pointer to
7025 non-returning function returning @code{void}''. As another example,
7026
7027 @smallexample
7028 char *__attribute__((aligned(8))) *f;
7029 @end smallexample
7030
7031 @noindent
7032 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7033 Note again that this does not work with most attributes; for example,
7034 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7035 is not yet supported.
7036
7037 For compatibility with existing code written for compiler versions that
7038 did not implement attributes on nested declarators, some laxity is
7039 allowed in the placing of attributes. If an attribute that only applies
7040 to types is applied to a declaration, it is treated as applying to
7041 the type of that declaration. If an attribute that only applies to
7042 declarations is applied to the type of a declaration, it is treated
7043 as applying to that declaration; and, for compatibility with code
7044 placing the attributes immediately before the identifier declared, such
7045 an attribute applied to a function return type is treated as
7046 applying to the function type, and such an attribute applied to an array
7047 element type is treated as applying to the array type. If an
7048 attribute that only applies to function types is applied to a
7049 pointer-to-function type, it is treated as applying to the pointer
7050 target type; if such an attribute is applied to a function return type
7051 that is not a pointer-to-function type, it is treated as applying
7052 to the function type.
7053
7054 @node Function Prototypes
7055 @section Prototypes and Old-Style Function Definitions
7056 @cindex function prototype declarations
7057 @cindex old-style function definitions
7058 @cindex promotion of formal parameters
7059
7060 GNU C extends ISO C to allow a function prototype to override a later
7061 old-style non-prototype definition. Consider the following example:
7062
7063 @smallexample
7064 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7065 #ifdef __STDC__
7066 #define P(x) x
7067 #else
7068 #define P(x) ()
7069 #endif
7070
7071 /* @r{Prototype function declaration.} */
7072 int isroot P((uid_t));
7073
7074 /* @r{Old-style function definition.} */
7075 int
7076 isroot (x) /* @r{??? lossage here ???} */
7077 uid_t x;
7078 @{
7079 return x == 0;
7080 @}
7081 @end smallexample
7082
7083 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7084 not allow this example, because subword arguments in old-style
7085 non-prototype definitions are promoted. Therefore in this example the
7086 function definition's argument is really an @code{int}, which does not
7087 match the prototype argument type of @code{short}.
7088
7089 This restriction of ISO C makes it hard to write code that is portable
7090 to traditional C compilers, because the programmer does not know
7091 whether the @code{uid_t} type is @code{short}, @code{int}, or
7092 @code{long}. Therefore, in cases like these GNU C allows a prototype
7093 to override a later old-style definition. More precisely, in GNU C, a
7094 function prototype argument type overrides the argument type specified
7095 by a later old-style definition if the former type is the same as the
7096 latter type before promotion. Thus in GNU C the above example is
7097 equivalent to the following:
7098
7099 @smallexample
7100 int isroot (uid_t);
7101
7102 int
7103 isroot (uid_t x)
7104 @{
7105 return x == 0;
7106 @}
7107 @end smallexample
7108
7109 @noindent
7110 GNU C++ does not support old-style function definitions, so this
7111 extension is irrelevant.
7112
7113 @node C++ Comments
7114 @section C++ Style Comments
7115 @cindex @code{//}
7116 @cindex C++ comments
7117 @cindex comments, C++ style
7118
7119 In GNU C, you may use C++ style comments, which start with @samp{//} and
7120 continue until the end of the line. Many other C implementations allow
7121 such comments, and they are included in the 1999 C standard. However,
7122 C++ style comments are not recognized if you specify an @option{-std}
7123 option specifying a version of ISO C before C99, or @option{-ansi}
7124 (equivalent to @option{-std=c90}).
7125
7126 @node Dollar Signs
7127 @section Dollar Signs in Identifier Names
7128 @cindex $
7129 @cindex dollar signs in identifier names
7130 @cindex identifier names, dollar signs in
7131
7132 In GNU C, you may normally use dollar signs in identifier names.
7133 This is because many traditional C implementations allow such identifiers.
7134 However, dollar signs in identifiers are not supported on a few target
7135 machines, typically because the target assembler does not allow them.
7136
7137 @node Character Escapes
7138 @section The Character @key{ESC} in Constants
7139
7140 You can use the sequence @samp{\e} in a string or character constant to
7141 stand for the ASCII character @key{ESC}.
7142
7143 @node Alignment
7144 @section Inquiring on Alignment of Types or Variables
7145 @cindex alignment
7146 @cindex type alignment
7147 @cindex variable alignment
7148
7149 The keyword @code{__alignof__} allows you to inquire about how an object
7150 is aligned, or the minimum alignment usually required by a type. Its
7151 syntax is just like @code{sizeof}.
7152
7153 For example, if the target machine requires a @code{double} value to be
7154 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7155 This is true on many RISC machines. On more traditional machine
7156 designs, @code{__alignof__ (double)} is 4 or even 2.
7157
7158 Some machines never actually require alignment; they allow reference to any
7159 data type even at an odd address. For these machines, @code{__alignof__}
7160 reports the smallest alignment that GCC gives the data type, usually as
7161 mandated by the target ABI.
7162
7163 If the operand of @code{__alignof__} is an lvalue rather than a type,
7164 its value is the required alignment for its type, taking into account
7165 any minimum alignment specified with GCC's @code{__attribute__}
7166 extension (@pxref{Variable Attributes}). For example, after this
7167 declaration:
7168
7169 @smallexample
7170 struct foo @{ int x; char y; @} foo1;
7171 @end smallexample
7172
7173 @noindent
7174 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7175 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7176
7177 It is an error to ask for the alignment of an incomplete type.
7178
7179
7180 @node Inline
7181 @section An Inline Function is As Fast As a Macro
7182 @cindex inline functions
7183 @cindex integrating function code
7184 @cindex open coding
7185 @cindex macros, inline alternative
7186
7187 By declaring a function inline, you can direct GCC to make
7188 calls to that function faster. One way GCC can achieve this is to
7189 integrate that function's code into the code for its callers. This
7190 makes execution faster by eliminating the function-call overhead; in
7191 addition, if any of the actual argument values are constant, their
7192 known values may permit simplifications at compile time so that not
7193 all of the inline function's code needs to be included. The effect on
7194 code size is less predictable; object code may be larger or smaller
7195 with function inlining, depending on the particular case. You can
7196 also direct GCC to try to integrate all ``simple enough'' functions
7197 into their callers with the option @option{-finline-functions}.
7198
7199 GCC implements three different semantics of declaring a function
7200 inline. One is available with @option{-std=gnu89} or
7201 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7202 on all inline declarations, another when
7203 @option{-std=c99}, @option{-std=c11},
7204 @option{-std=gnu99} or @option{-std=gnu11}
7205 (without @option{-fgnu89-inline}), and the third
7206 is used when compiling C++.
7207
7208 To declare a function inline, use the @code{inline} keyword in its
7209 declaration, like this:
7210
7211 @smallexample
7212 static inline int
7213 inc (int *a)
7214 @{
7215 return (*a)++;
7216 @}
7217 @end smallexample
7218
7219 If you are writing a header file to be included in ISO C90 programs, write
7220 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7221
7222 The three types of inlining behave similarly in two important cases:
7223 when the @code{inline} keyword is used on a @code{static} function,
7224 like the example above, and when a function is first declared without
7225 using the @code{inline} keyword and then is defined with
7226 @code{inline}, like this:
7227
7228 @smallexample
7229 extern int inc (int *a);
7230 inline int
7231 inc (int *a)
7232 @{
7233 return (*a)++;
7234 @}
7235 @end smallexample
7236
7237 In both of these common cases, the program behaves the same as if you
7238 had not used the @code{inline} keyword, except for its speed.
7239
7240 @cindex inline functions, omission of
7241 @opindex fkeep-inline-functions
7242 When a function is both inline and @code{static}, if all calls to the
7243 function are integrated into the caller, and the function's address is
7244 never used, then the function's own assembler code is never referenced.
7245 In this case, GCC does not actually output assembler code for the
7246 function, unless you specify the option @option{-fkeep-inline-functions}.
7247 If there is a nonintegrated call, then the function is compiled to
7248 assembler code as usual. The function must also be compiled as usual if
7249 the program refers to its address, because that can't be inlined.
7250
7251 @opindex Winline
7252 Note that certain usages in a function definition can make it unsuitable
7253 for inline substitution. Among these usages are: variadic functions,
7254 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7255 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7256 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7257 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
7258 function marked @code{inline} could not be substituted, and gives the
7259 reason for the failure.
7260
7261 @cindex automatic @code{inline} for C++ member fns
7262 @cindex @code{inline} automatic for C++ member fns
7263 @cindex member fns, automatically @code{inline}
7264 @cindex C++ member fns, automatically @code{inline}
7265 @opindex fno-default-inline
7266 As required by ISO C++, GCC considers member functions defined within
7267 the body of a class to be marked inline even if they are
7268 not explicitly declared with the @code{inline} keyword. You can
7269 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7270 Options,,Options Controlling C++ Dialect}.
7271
7272 GCC does not inline any functions when not optimizing unless you specify
7273 the @samp{always_inline} attribute for the function, like this:
7274
7275 @smallexample
7276 /* @r{Prototype.} */
7277 inline void foo (const char) __attribute__((always_inline));
7278 @end smallexample
7279
7280 The remainder of this section is specific to GNU C90 inlining.
7281
7282 @cindex non-static inline function
7283 When an inline function is not @code{static}, then the compiler must assume
7284 that there may be calls from other source files; since a global symbol can
7285 be defined only once in any program, the function must not be defined in
7286 the other source files, so the calls therein cannot be integrated.
7287 Therefore, a non-@code{static} inline function is always compiled on its
7288 own in the usual fashion.
7289
7290 If you specify both @code{inline} and @code{extern} in the function
7291 definition, then the definition is used only for inlining. In no case
7292 is the function compiled on its own, not even if you refer to its
7293 address explicitly. Such an address becomes an external reference, as
7294 if you had only declared the function, and had not defined it.
7295
7296 This combination of @code{inline} and @code{extern} has almost the
7297 effect of a macro. The way to use it is to put a function definition in
7298 a header file with these keywords, and put another copy of the
7299 definition (lacking @code{inline} and @code{extern}) in a library file.
7300 The definition in the header file causes most calls to the function
7301 to be inlined. If any uses of the function remain, they refer to
7302 the single copy in the library.
7303
7304 @node Volatiles
7305 @section When is a Volatile Object Accessed?
7306 @cindex accessing volatiles
7307 @cindex volatile read
7308 @cindex volatile write
7309 @cindex volatile access
7310
7311 C has the concept of volatile objects. These are normally accessed by
7312 pointers and used for accessing hardware or inter-thread
7313 communication. The standard encourages compilers to refrain from
7314 optimizations concerning accesses to volatile objects, but leaves it
7315 implementation defined as to what constitutes a volatile access. The
7316 minimum requirement is that at a sequence point all previous accesses
7317 to volatile objects have stabilized and no subsequent accesses have
7318 occurred. Thus an implementation is free to reorder and combine
7319 volatile accesses that occur between sequence points, but cannot do
7320 so for accesses across a sequence point. The use of volatile does
7321 not allow you to violate the restriction on updating objects multiple
7322 times between two sequence points.
7323
7324 Accesses to non-volatile objects are not ordered with respect to
7325 volatile accesses. You cannot use a volatile object as a memory
7326 barrier to order a sequence of writes to non-volatile memory. For
7327 instance:
7328
7329 @smallexample
7330 int *ptr = @var{something};
7331 volatile int vobj;
7332 *ptr = @var{something};
7333 vobj = 1;
7334 @end smallexample
7335
7336 @noindent
7337 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
7338 that the write to @var{*ptr} occurs by the time the update
7339 of @var{vobj} happens. If you need this guarantee, you must use
7340 a stronger memory barrier such as:
7341
7342 @smallexample
7343 int *ptr = @var{something};
7344 volatile int vobj;
7345 *ptr = @var{something};
7346 asm volatile ("" : : : "memory");
7347 vobj = 1;
7348 @end smallexample
7349
7350 A scalar volatile object is read when it is accessed in a void context:
7351
7352 @smallexample
7353 volatile int *src = @var{somevalue};
7354 *src;
7355 @end smallexample
7356
7357 Such expressions are rvalues, and GCC implements this as a
7358 read of the volatile object being pointed to.
7359
7360 Assignments are also expressions and have an rvalue. However when
7361 assigning to a scalar volatile, the volatile object is not reread,
7362 regardless of whether the assignment expression's rvalue is used or
7363 not. If the assignment's rvalue is used, the value is that assigned
7364 to the volatile object. For instance, there is no read of @var{vobj}
7365 in all the following cases:
7366
7367 @smallexample
7368 int obj;
7369 volatile int vobj;
7370 vobj = @var{something};
7371 obj = vobj = @var{something};
7372 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
7373 obj = (@var{something}, vobj = @var{anotherthing});
7374 @end smallexample
7375
7376 If you need to read the volatile object after an assignment has
7377 occurred, you must use a separate expression with an intervening
7378 sequence point.
7379
7380 As bit-fields are not individually addressable, volatile bit-fields may
7381 be implicitly read when written to, or when adjacent bit-fields are
7382 accessed. Bit-field operations may be optimized such that adjacent
7383 bit-fields are only partially accessed, if they straddle a storage unit
7384 boundary. For these reasons it is unwise to use volatile bit-fields to
7385 access hardware.
7386
7387 @node Using Assembly Language with C
7388 @section How to Use Inline Assembly Language in C Code
7389 @cindex @code{asm} keyword
7390 @cindex assembly language in C
7391 @cindex inline assembly language
7392 @cindex mixing assembly language and C
7393
7394 The @code{asm} keyword allows you to embed assembler instructions
7395 within C code. GCC provides two forms of inline @code{asm}
7396 statements. A @dfn{basic @code{asm}} statement is one with no
7397 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
7398 statement (@pxref{Extended Asm}) includes one or more operands.
7399 The extended form is preferred for mixing C and assembly language
7400 within a function, but to include assembly language at
7401 top level you must use basic @code{asm}.
7402
7403 You can also use the @code{asm} keyword to override the assembler name
7404 for a C symbol, or to place a C variable in a specific register.
7405
7406 @menu
7407 * Basic Asm:: Inline assembler without operands.
7408 * Extended Asm:: Inline assembler with operands.
7409 * Constraints:: Constraints for @code{asm} operands
7410 * Asm Labels:: Specifying the assembler name to use for a C symbol.
7411 * Explicit Register Variables:: Defining variables residing in specified
7412 registers.
7413 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
7414 @end menu
7415
7416 @node Basic Asm
7417 @subsection Basic Asm --- Assembler Instructions Without Operands
7418 @cindex basic @code{asm}
7419 @cindex assembly language in C, basic
7420
7421 A basic @code{asm} statement has the following syntax:
7422
7423 @example
7424 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
7425 @end example
7426
7427 The @code{asm} keyword is a GNU extension.
7428 When writing code that can be compiled with @option{-ansi} and the
7429 various @option{-std} options, use @code{__asm__} instead of
7430 @code{asm} (@pxref{Alternate Keywords}).
7431
7432 @subsubheading Qualifiers
7433 @table @code
7434 @item volatile
7435 The optional @code{volatile} qualifier has no effect.
7436 All basic @code{asm} blocks are implicitly volatile.
7437 @end table
7438
7439 @subsubheading Parameters
7440 @table @var
7441
7442 @item AssemblerInstructions
7443 This is a literal string that specifies the assembler code. The string can
7444 contain any instructions recognized by the assembler, including directives.
7445 GCC does not parse the assembler instructions themselves and
7446 does not know what they mean or even whether they are valid assembler input.
7447
7448 You may place multiple assembler instructions together in a single @code{asm}
7449 string, separated by the characters normally used in assembly code for the
7450 system. A combination that works in most places is a newline to break the
7451 line, plus a tab character (written as @samp{\n\t}).
7452 Some assemblers allow semicolons as a line separator. However,
7453 note that some assembler dialects use semicolons to start a comment.
7454 @end table
7455
7456 @subsubheading Remarks
7457 Using extended @code{asm} typically produces smaller, safer, and more
7458 efficient code, and in most cases it is a better solution than basic
7459 @code{asm}. However, there are two situations where only basic @code{asm}
7460 can be used:
7461
7462 @itemize @bullet
7463 @item
7464 Extended @code{asm} statements have to be inside a C
7465 function, so to write inline assembly language at file scope (``top-level''),
7466 outside of C functions, you must use basic @code{asm}.
7467 You can use this technique to emit assembler directives,
7468 define assembly language macros that can be invoked elsewhere in the file,
7469 or write entire functions in assembly language.
7470
7471 @item
7472 Functions declared
7473 with the @code{naked} attribute also require basic @code{asm}
7474 (@pxref{Function Attributes}).
7475 @end itemize
7476
7477 Safely accessing C data and calling functions from basic @code{asm} is more
7478 complex than it may appear. To access C data, it is better to use extended
7479 @code{asm}.
7480
7481 Do not expect a sequence of @code{asm} statements to remain perfectly
7482 consecutive after compilation. If certain instructions need to remain
7483 consecutive in the output, put them in a single multi-instruction @code{asm}
7484 statement. Note that GCC's optimizers can move @code{asm} statements
7485 relative to other code, including across jumps.
7486
7487 @code{asm} statements may not perform jumps into other @code{asm} statements.
7488 GCC does not know about these jumps, and therefore cannot take
7489 account of them when deciding how to optimize. Jumps from @code{asm} to C
7490 labels are only supported in extended @code{asm}.
7491
7492 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7493 assembly code when optimizing. This can lead to unexpected duplicate
7494 symbol errors during compilation if your assembly code defines symbols or
7495 labels.
7496
7497 Since GCC does not parse the @var{AssemblerInstructions}, it has no
7498 visibility of any symbols it references. This may result in GCC discarding
7499 those symbols as unreferenced.
7500
7501 The compiler copies the assembler instructions in a basic @code{asm}
7502 verbatim to the assembly language output file, without
7503 processing dialects or any of the @samp{%} operators that are available with
7504 extended @code{asm}. This results in minor differences between basic
7505 @code{asm} strings and extended @code{asm} templates. For example, to refer to
7506 registers you might use @samp{%eax} in basic @code{asm} and
7507 @samp{%%eax} in extended @code{asm}.
7508
7509 On targets such as x86 that support multiple assembler dialects,
7510 all basic @code{asm} blocks use the assembler dialect specified by the
7511 @option{-masm} command-line option (@pxref{x86 Options}).
7512 Basic @code{asm} provides no
7513 mechanism to provide different assembler strings for different dialects.
7514
7515 Here is an example of basic @code{asm} for i386:
7516
7517 @example
7518 /* Note that this code will not compile with -masm=intel */
7519 #define DebugBreak() asm("int $3")
7520 @end example
7521
7522 @node Extended Asm
7523 @subsection Extended Asm - Assembler Instructions with C Expression Operands
7524 @cindex extended @code{asm}
7525 @cindex assembly language in C, extended
7526
7527 With extended @code{asm} you can read and write C variables from
7528 assembler and perform jumps from assembler code to C labels.
7529 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
7530 the operand parameters after the assembler template:
7531
7532 @example
7533 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
7534 : @var{OutputOperands}
7535 @r{[} : @var{InputOperands}
7536 @r{[} : @var{Clobbers} @r{]} @r{]})
7537
7538 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
7539 :
7540 : @var{InputOperands}
7541 : @var{Clobbers}
7542 : @var{GotoLabels})
7543 @end example
7544
7545 The @code{asm} keyword is a GNU extension.
7546 When writing code that can be compiled with @option{-ansi} and the
7547 various @option{-std} options, use @code{__asm__} instead of
7548 @code{asm} (@pxref{Alternate Keywords}).
7549
7550 @subsubheading Qualifiers
7551 @table @code
7552
7553 @item volatile
7554 The typical use of extended @code{asm} statements is to manipulate input
7555 values to produce output values. However, your @code{asm} statements may
7556 also produce side effects. If so, you may need to use the @code{volatile}
7557 qualifier to disable certain optimizations. @xref{Volatile}.
7558
7559 @item goto
7560 This qualifier informs the compiler that the @code{asm} statement may
7561 perform a jump to one of the labels listed in the @var{GotoLabels}.
7562 @xref{GotoLabels}.
7563 @end table
7564
7565 @subsubheading Parameters
7566 @table @var
7567 @item AssemblerTemplate
7568 This is a literal string that is the template for the assembler code. It is a
7569 combination of fixed text and tokens that refer to the input, output,
7570 and goto parameters. @xref{AssemblerTemplate}.
7571
7572 @item OutputOperands
7573 A comma-separated list of the C variables modified by the instructions in the
7574 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
7575
7576 @item InputOperands
7577 A comma-separated list of C expressions read by the instructions in the
7578 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
7579
7580 @item Clobbers
7581 A comma-separated list of registers or other values changed by the
7582 @var{AssemblerTemplate}, beyond those listed as outputs.
7583 An empty list is permitted. @xref{Clobbers}.
7584
7585 @item GotoLabels
7586 When you are using the @code{goto} form of @code{asm}, this section contains
7587 the list of all C labels to which the code in the
7588 @var{AssemblerTemplate} may jump.
7589 @xref{GotoLabels}.
7590
7591 @code{asm} statements may not perform jumps into other @code{asm} statements,
7592 only to the listed @var{GotoLabels}.
7593 GCC's optimizers do not know about other jumps; therefore they cannot take
7594 account of them when deciding how to optimize.
7595 @end table
7596
7597 The total number of input + output + goto operands is limited to 30.
7598
7599 @subsubheading Remarks
7600 The @code{asm} statement allows you to include assembly instructions directly
7601 within C code. This may help you to maximize performance in time-sensitive
7602 code or to access assembly instructions that are not readily available to C
7603 programs.
7604
7605 Note that extended @code{asm} statements must be inside a function. Only
7606 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
7607 Functions declared with the @code{naked} attribute also require basic
7608 @code{asm} (@pxref{Function Attributes}).
7609
7610 While the uses of @code{asm} are many and varied, it may help to think of an
7611 @code{asm} statement as a series of low-level instructions that convert input
7612 parameters to output parameters. So a simple (if not particularly useful)
7613 example for i386 using @code{asm} might look like this:
7614
7615 @example
7616 int src = 1;
7617 int dst;
7618
7619 asm ("mov %1, %0\n\t"
7620 "add $1, %0"
7621 : "=r" (dst)
7622 : "r" (src));
7623
7624 printf("%d\n", dst);
7625 @end example
7626
7627 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
7628
7629 @anchor{Volatile}
7630 @subsubsection Volatile
7631 @cindex volatile @code{asm}
7632 @cindex @code{asm} volatile
7633
7634 GCC's optimizers sometimes discard @code{asm} statements if they determine
7635 there is no need for the output variables. Also, the optimizers may move
7636 code out of loops if they believe that the code will always return the same
7637 result (i.e. none of its input values change between calls). Using the
7638 @code{volatile} qualifier disables these optimizations. @code{asm} statements
7639 that have no output operands, including @code{asm goto} statements,
7640 are implicitly volatile.
7641
7642 This i386 code demonstrates a case that does not use (or require) the
7643 @code{volatile} qualifier. If it is performing assertion checking, this code
7644 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
7645 unreferenced by any code. As a result, the optimizers can discard the
7646 @code{asm} statement, which in turn removes the need for the entire
7647 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
7648 isn't needed you allow the optimizers to produce the most efficient code
7649 possible.
7650
7651 @example
7652 void DoCheck(uint32_t dwSomeValue)
7653 @{
7654 uint32_t dwRes;
7655
7656 // Assumes dwSomeValue is not zero.
7657 asm ("bsfl %1,%0"
7658 : "=r" (dwRes)
7659 : "r" (dwSomeValue)
7660 : "cc");
7661
7662 assert(dwRes > 3);
7663 @}
7664 @end example
7665
7666 The next example shows a case where the optimizers can recognize that the input
7667 (@code{dwSomeValue}) never changes during the execution of the function and can
7668 therefore move the @code{asm} outside the loop to produce more efficient code.
7669 Again, using @code{volatile} disables this type of optimization.
7670
7671 @example
7672 void do_print(uint32_t dwSomeValue)
7673 @{
7674 uint32_t dwRes;
7675
7676 for (uint32_t x=0; x < 5; x++)
7677 @{
7678 // Assumes dwSomeValue is not zero.
7679 asm ("bsfl %1,%0"
7680 : "=r" (dwRes)
7681 : "r" (dwSomeValue)
7682 : "cc");
7683
7684 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
7685 @}
7686 @}
7687 @end example
7688
7689 The following example demonstrates a case where you need to use the
7690 @code{volatile} qualifier.
7691 It uses the x86 @code{rdtsc} instruction, which reads
7692 the computer's time-stamp counter. Without the @code{volatile} qualifier,
7693 the optimizers might assume that the @code{asm} block will always return the
7694 same value and therefore optimize away the second call.
7695
7696 @example
7697 uint64_t msr;
7698
7699 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7700 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7701 "or %%rdx, %0" // 'Or' in the lower bits.
7702 : "=a" (msr)
7703 :
7704 : "rdx");
7705
7706 printf("msr: %llx\n", msr);
7707
7708 // Do other work...
7709
7710 // Reprint the timestamp
7711 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
7712 "shl $32, %%rdx\n\t" // Shift the upper bits left.
7713 "or %%rdx, %0" // 'Or' in the lower bits.
7714 : "=a" (msr)
7715 :
7716 : "rdx");
7717
7718 printf("msr: %llx\n", msr);
7719 @end example
7720
7721 GCC's optimizers do not treat this code like the non-volatile code in the
7722 earlier examples. They do not move it out of loops or omit it on the
7723 assumption that the result from a previous call is still valid.
7724
7725 Note that the compiler can move even volatile @code{asm} instructions relative
7726 to other code, including across jump instructions. For example, on many
7727 targets there is a system register that controls the rounding mode of
7728 floating-point operations. Setting it with a volatile @code{asm}, as in the
7729 following PowerPC example, does not work reliably.
7730
7731 @example
7732 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
7733 sum = x + y;
7734 @end example
7735
7736 The compiler may move the addition back before the volatile @code{asm}. To
7737 make it work as expected, add an artificial dependency to the @code{asm} by
7738 referencing a variable in the subsequent code, for example:
7739
7740 @example
7741 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
7742 sum = x + y;
7743 @end example
7744
7745 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
7746 assembly code when optimizing. This can lead to unexpected duplicate symbol
7747 errors during compilation if your asm code defines symbols or labels.
7748 Using @samp{%=}
7749 (@pxref{AssemblerTemplate}) may help resolve this problem.
7750
7751 @anchor{AssemblerTemplate}
7752 @subsubsection Assembler Template
7753 @cindex @code{asm} assembler template
7754
7755 An assembler template is a literal string containing assembler instructions.
7756 The compiler replaces tokens in the template that refer
7757 to inputs, outputs, and goto labels,
7758 and then outputs the resulting string to the assembler. The
7759 string can contain any instructions recognized by the assembler, including
7760 directives. GCC does not parse the assembler instructions
7761 themselves and does not know what they mean or even whether they are valid
7762 assembler input. However, it does count the statements
7763 (@pxref{Size of an asm}).
7764
7765 You may place multiple assembler instructions together in a single @code{asm}
7766 string, separated by the characters normally used in assembly code for the
7767 system. A combination that works in most places is a newline to break the
7768 line, plus a tab character to move to the instruction field (written as
7769 @samp{\n\t}).
7770 Some assemblers allow semicolons as a line separator. However, note
7771 that some assembler dialects use semicolons to start a comment.
7772
7773 Do not expect a sequence of @code{asm} statements to remain perfectly
7774 consecutive after compilation, even when you are using the @code{volatile}
7775 qualifier. If certain instructions need to remain consecutive in the output,
7776 put them in a single multi-instruction asm statement.
7777
7778 Accessing data from C programs without using input/output operands (such as
7779 by using global symbols directly from the assembler template) may not work as
7780 expected. Similarly, calling functions directly from an assembler template
7781 requires a detailed understanding of the target assembler and ABI.
7782
7783 Since GCC does not parse the assembler template,
7784 it has no visibility of any
7785 symbols it references. This may result in GCC discarding those symbols as
7786 unreferenced unless they are also listed as input, output, or goto operands.
7787
7788 @subsubheading Special format strings
7789
7790 In addition to the tokens described by the input, output, and goto operands,
7791 these tokens have special meanings in the assembler template:
7792
7793 @table @samp
7794 @item %%
7795 Outputs a single @samp{%} into the assembler code.
7796
7797 @item %=
7798 Outputs a number that is unique to each instance of the @code{asm}
7799 statement in the entire compilation. This option is useful when creating local
7800 labels and referring to them multiple times in a single template that
7801 generates multiple assembler instructions.
7802
7803 @item %@{
7804 @itemx %|
7805 @itemx %@}
7806 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
7807 into the assembler code. When unescaped, these characters have special
7808 meaning to indicate multiple assembler dialects, as described below.
7809 @end table
7810
7811 @subsubheading Multiple assembler dialects in @code{asm} templates
7812
7813 On targets such as x86, GCC supports multiple assembler dialects.
7814 The @option{-masm} option controls which dialect GCC uses as its
7815 default for inline assembler. The target-specific documentation for the
7816 @option{-masm} option contains the list of supported dialects, as well as the
7817 default dialect if the option is not specified. This information may be
7818 important to understand, since assembler code that works correctly when
7819 compiled using one dialect will likely fail if compiled using another.
7820 @xref{x86 Options}.
7821
7822 If your code needs to support multiple assembler dialects (for example, if
7823 you are writing public headers that need to support a variety of compilation
7824 options), use constructs of this form:
7825
7826 @example
7827 @{ dialect0 | dialect1 | dialect2... @}
7828 @end example
7829
7830 This construct outputs @code{dialect0}
7831 when using dialect #0 to compile the code,
7832 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
7833 braces than the number of dialects the compiler supports, the construct
7834 outputs nothing.
7835
7836 For example, if an x86 compiler supports two dialects
7837 (@samp{att}, @samp{intel}), an
7838 assembler template such as this:
7839
7840 @example
7841 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
7842 @end example
7843
7844 @noindent
7845 is equivalent to one of
7846
7847 @example
7848 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
7849 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
7850 @end example
7851
7852 Using that same compiler, this code:
7853
7854 @example
7855 "xchg@{l@}\t@{%%@}ebx, %1"
7856 @end example
7857
7858 @noindent
7859 corresponds to either
7860
7861 @example
7862 "xchgl\t%%ebx, %1" @r{/* att dialect */}
7863 "xchg\tebx, %1" @r{/* intel dialect */}
7864 @end example
7865
7866 There is no support for nesting dialect alternatives.
7867
7868 @anchor{OutputOperands}
7869 @subsubsection Output Operands
7870 @cindex @code{asm} output operands
7871
7872 An @code{asm} statement has zero or more output operands indicating the names
7873 of C variables modified by the assembler code.
7874
7875 In this i386 example, @code{old} (referred to in the template string as
7876 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
7877 (@code{%2}) is an input:
7878
7879 @example
7880 bool old;
7881
7882 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
7883 "sbb %0,%0" // Use the CF to calculate old.
7884 : "=r" (old), "+rm" (*Base)
7885 : "Ir" (Offset)
7886 : "cc");
7887
7888 return old;
7889 @end example
7890
7891 Operands are separated by commas. Each operand has this format:
7892
7893 @example
7894 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
7895 @end example
7896
7897 @table @var
7898 @item asmSymbolicName
7899 Specifies a symbolic name for the operand.
7900 Reference the name in the assembler template
7901 by enclosing it in square brackets
7902 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
7903 that contains the definition. Any valid C variable name is acceptable,
7904 including names already defined in the surrounding code. No two operands
7905 within the same @code{asm} statement can use the same symbolic name.
7906
7907 When not using an @var{asmSymbolicName}, use the (zero-based) position
7908 of the operand
7909 in the list of operands in the assembler template. For example if there are
7910 three output operands, use @samp{%0} in the template to refer to the first,
7911 @samp{%1} for the second, and @samp{%2} for the third.
7912
7913 @item constraint
7914 A string constant specifying constraints on the placement of the operand;
7915 @xref{Constraints}, for details.
7916
7917 Output constraints must begin with either @samp{=} (a variable overwriting an
7918 existing value) or @samp{+} (when reading and writing). When using
7919 @samp{=}, do not assume the location contains the existing value
7920 on entry to the @code{asm}, except
7921 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
7922
7923 After the prefix, there must be one or more additional constraints
7924 (@pxref{Constraints}) that describe where the value resides. Common
7925 constraints include @samp{r} for register and @samp{m} for memory.
7926 When you list more than one possible location (for example, @code{"=rm"}),
7927 the compiler chooses the most efficient one based on the current context.
7928 If you list as many alternates as the @code{asm} statement allows, you permit
7929 the optimizers to produce the best possible code.
7930 If you must use a specific register, but your Machine Constraints do not
7931 provide sufficient control to select the specific register you want,
7932 local register variables may provide a solution (@pxref{Local Register
7933 Variables}).
7934
7935 @item cvariablename
7936 Specifies a C lvalue expression to hold the output, typically a variable name.
7937 The enclosing parentheses are a required part of the syntax.
7938
7939 @end table
7940
7941 When the compiler selects the registers to use to
7942 represent the output operands, it does not use any of the clobbered registers
7943 (@pxref{Clobbers}).
7944
7945 Output operand expressions must be lvalues. The compiler cannot check whether
7946 the operands have data types that are reasonable for the instruction being
7947 executed. For output expressions that are not directly addressable (for
7948 example a bit-field), the constraint must allow a register. In that case, GCC
7949 uses the register as the output of the @code{asm}, and then stores that
7950 register into the output.
7951
7952 Operands using the @samp{+} constraint modifier count as two operands
7953 (that is, both as input and output) towards the total maximum of 30 operands
7954 per @code{asm} statement.
7955
7956 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
7957 operands that must not overlap an input. Otherwise,
7958 GCC may allocate the output operand in the same register as an unrelated
7959 input operand, on the assumption that the assembler code consumes its
7960 inputs before producing outputs. This assumption may be false if the assembler
7961 code actually consists of more than one instruction.
7962
7963 The same problem can occur if one output parameter (@var{a}) allows a register
7964 constraint and another output parameter (@var{b}) allows a memory constraint.
7965 The code generated by GCC to access the memory address in @var{b} can contain
7966 registers which @emph{might} be shared by @var{a}, and GCC considers those
7967 registers to be inputs to the asm. As above, GCC assumes that such input
7968 registers are consumed before any outputs are written. This assumption may
7969 result in incorrect behavior if the asm writes to @var{a} before using
7970 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
7971 ensures that modifying @var{a} does not affect the address referenced by
7972 @var{b}. Otherwise, the location of @var{b}
7973 is undefined if @var{a} is modified before using @var{b}.
7974
7975 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
7976 instead of simply @samp{%2}). Typically these qualifiers are hardware
7977 dependent. The list of supported modifiers for x86 is found at
7978 @ref{x86Operandmodifiers,x86 Operand modifiers}.
7979
7980 If the C code that follows the @code{asm} makes no use of any of the output
7981 operands, use @code{volatile} for the @code{asm} statement to prevent the
7982 optimizers from discarding the @code{asm} statement as unneeded
7983 (see @ref{Volatile}).
7984
7985 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
7986 references the first output operand as @code{%0} (were there a second, it
7987 would be @code{%1}, etc). The number of the first input operand is one greater
7988 than that of the last output operand. In this i386 example, that makes
7989 @code{Mask} referenced as @code{%1}:
7990
7991 @example
7992 uint32_t Mask = 1234;
7993 uint32_t Index;
7994
7995 asm ("bsfl %1, %0"
7996 : "=r" (Index)
7997 : "r" (Mask)
7998 : "cc");
7999 @end example
8000
8001 That code overwrites the variable @code{Index} (@samp{=}),
8002 placing the value in a register (@samp{r}).
8003 Using the generic @samp{r} constraint instead of a constraint for a specific
8004 register allows the compiler to pick the register to use, which can result
8005 in more efficient code. This may not be possible if an assembler instruction
8006 requires a specific register.
8007
8008 The following i386 example uses the @var{asmSymbolicName} syntax.
8009 It produces the
8010 same result as the code above, but some may consider it more readable or more
8011 maintainable since reordering index numbers is not necessary when adding or
8012 removing operands. The names @code{aIndex} and @code{aMask}
8013 are only used in this example to emphasize which
8014 names get used where.
8015 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8016
8017 @example
8018 uint32_t Mask = 1234;
8019 uint32_t Index;
8020
8021 asm ("bsfl %[aMask], %[aIndex]"
8022 : [aIndex] "=r" (Index)
8023 : [aMask] "r" (Mask)
8024 : "cc");
8025 @end example
8026
8027 Here are some more examples of output operands.
8028
8029 @example
8030 uint32_t c = 1;
8031 uint32_t d;
8032 uint32_t *e = &c;
8033
8034 asm ("mov %[e], %[d]"
8035 : [d] "=rm" (d)
8036 : [e] "rm" (*e));
8037 @end example
8038
8039 Here, @code{d} may either be in a register or in memory. Since the compiler
8040 might already have the current value of the @code{uint32_t} location
8041 pointed to by @code{e}
8042 in a register, you can enable it to choose the best location
8043 for @code{d} by specifying both constraints.
8044
8045 @anchor{FlagOutputOperands}
8046 @subsection Flag Output Operands
8047 @cindex @code{asm} flag output operands
8048
8049 Some targets have a special register that holds the ``flags'' for the
8050 result of an operation or comparison. Normally, the contents of that
8051 register are either unmodifed by the asm, or the asm is considered to
8052 clobber the contents.
8053
8054 On some targets, a special form of output operand exists by which
8055 conditions in the flags register may be outputs of the asm. The set of
8056 conditions supported are target specific, but the general rule is that
8057 the output variable must be a scalar integer, and the value will be boolean.
8058 When supported, the target will define the preprocessor symbol
8059 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8060
8061 Because of the special nature of the flag output operands, the constraint
8062 may not include alternatives.
8063
8064 Most often, the target has only one flags register, and thus is an implied
8065 operand of many instructions. In this case, the operand should not be
8066 referenced within the assembler template via @code{%0} etc, as there's
8067 no corresponding text in the assembly language.
8068
8069 @table @asis
8070 @item x86 family
8071 The flag output constraints for the x86 family are of the form
8072 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8073 conditions defined in the ISA manual for @code{j@var{cc}} or
8074 @code{set@var{cc}}.
8075
8076 @table @code
8077 @item a
8078 ``above'' or unsigned greater than
8079 @item ae
8080 ``above or equal'' or unsigned greater than or equal
8081 @item b
8082 ``below'' or unsigned less than
8083 @item be
8084 ``below or equal'' or unsigned less than or equal
8085 @item c
8086 carry flag set
8087 @item e
8088 @itemx z
8089 ``equal'' or zero flag set
8090 @item g
8091 signed greater than
8092 @item ge
8093 signed greater than or equal
8094 @item l
8095 signed less than
8096 @item le
8097 signed less than or equal
8098 @item o
8099 overflow flag set
8100 @item p
8101 parity flag set
8102 @item s
8103 sign flag set
8104 @item na
8105 @itemx nae
8106 @itemx nb
8107 @itemx nbe
8108 @itemx nc
8109 @itemx ne
8110 @itemx ng
8111 @itemx nge
8112 @itemx nl
8113 @itemx nle
8114 @itemx no
8115 @itemx np
8116 @itemx ns
8117 @itemx nz
8118 ``not'' @var{flag}, or inverted versions of those above
8119 @end table
8120
8121 @end table
8122
8123 @anchor{InputOperands}
8124 @subsubsection Input Operands
8125 @cindex @code{asm} input operands
8126 @cindex @code{asm} expressions
8127
8128 Input operands make values from C variables and expressions available to the
8129 assembly code.
8130
8131 Operands are separated by commas. Each operand has this format:
8132
8133 @example
8134 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8135 @end example
8136
8137 @table @var
8138 @item asmSymbolicName
8139 Specifies a symbolic name for the operand.
8140 Reference the name in the assembler template
8141 by enclosing it in square brackets
8142 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8143 that contains the definition. Any valid C variable name is acceptable,
8144 including names already defined in the surrounding code. No two operands
8145 within the same @code{asm} statement can use the same symbolic name.
8146
8147 When not using an @var{asmSymbolicName}, use the (zero-based) position
8148 of the operand
8149 in the list of operands in the assembler template. For example if there are
8150 two output operands and three inputs,
8151 use @samp{%2} in the template to refer to the first input operand,
8152 @samp{%3} for the second, and @samp{%4} for the third.
8153
8154 @item constraint
8155 A string constant specifying constraints on the placement of the operand;
8156 @xref{Constraints}, for details.
8157
8158 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8159 When you list more than one possible location (for example, @samp{"irm"}),
8160 the compiler chooses the most efficient one based on the current context.
8161 If you must use a specific register, but your Machine Constraints do not
8162 provide sufficient control to select the specific register you want,
8163 local register variables may provide a solution (@pxref{Local Register
8164 Variables}).
8165
8166 Input constraints can also be digits (for example, @code{"0"}). This indicates
8167 that the specified input must be in the same place as the output constraint
8168 at the (zero-based) index in the output constraint list.
8169 When using @var{asmSymbolicName} syntax for the output operands,
8170 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8171
8172 @item cexpression
8173 This is the C variable or expression being passed to the @code{asm} statement
8174 as input. The enclosing parentheses are a required part of the syntax.
8175
8176 @end table
8177
8178 When the compiler selects the registers to use to represent the input
8179 operands, it does not use any of the clobbered registers (@pxref{Clobbers}).
8180
8181 If there are no output operands but there are input operands, place two
8182 consecutive colons where the output operands would go:
8183
8184 @example
8185 __asm__ ("some instructions"
8186 : /* No outputs. */
8187 : "r" (Offset / 8));
8188 @end example
8189
8190 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8191 (except for inputs tied to outputs). The compiler assumes that on exit from
8192 the @code{asm} statement these operands contain the same values as they
8193 had before executing the statement.
8194 It is @emph{not} possible to use clobbers
8195 to inform the compiler that the values in these inputs are changing. One
8196 common work-around is to tie the changing input variable to an output variable
8197 that never gets used. Note, however, that if the code that follows the
8198 @code{asm} statement makes no use of any of the output operands, the GCC
8199 optimizers may discard the @code{asm} statement as unneeded
8200 (see @ref{Volatile}).
8201
8202 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8203 instead of simply @samp{%2}). Typically these qualifiers are hardware
8204 dependent. The list of supported modifiers for x86 is found at
8205 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8206
8207 In this example using the fictitious @code{combine} instruction, the
8208 constraint @code{"0"} for input operand 1 says that it must occupy the same
8209 location as output operand 0. Only input operands may use numbers in
8210 constraints, and they must each refer to an output operand. Only a number (or
8211 the symbolic assembler name) in the constraint can guarantee that one operand
8212 is in the same place as another. The mere fact that @code{foo} is the value of
8213 both operands is not enough to guarantee that they are in the same place in
8214 the generated assembler code.
8215
8216 @example
8217 asm ("combine %2, %0"
8218 : "=r" (foo)
8219 : "0" (foo), "g" (bar));
8220 @end example
8221
8222 Here is an example using symbolic names.
8223
8224 @example
8225 asm ("cmoveq %1, %2, %[result]"
8226 : [result] "=r"(result)
8227 : "r" (test), "r" (new), "[result]" (old));
8228 @end example
8229
8230 @anchor{Clobbers}
8231 @subsubsection Clobbers
8232 @cindex @code{asm} clobbers
8233
8234 While the compiler is aware of changes to entries listed in the output
8235 operands, the inline @code{asm} code may modify more than just the outputs. For
8236 example, calculations may require additional registers, or the processor may
8237 overwrite a register as a side effect of a particular assembler instruction.
8238 In order to inform the compiler of these changes, list them in the clobber
8239 list. Clobber list items are either register names or the special clobbers
8240 (listed below). Each clobber list item is a string constant
8241 enclosed in double quotes and separated by commas.
8242
8243 Clobber descriptions may not in any way overlap with an input or output
8244 operand. For example, you may not have an operand describing a register class
8245 with one member when listing that register in the clobber list. Variables
8246 declared to live in specific registers (@pxref{Explicit Register
8247 Variables}) and used
8248 as @code{asm} input or output operands must have no part mentioned in the
8249 clobber description. In particular, there is no way to specify that input
8250 operands get modified without also specifying them as output operands.
8251
8252 When the compiler selects which registers to use to represent input and output
8253 operands, it does not use any of the clobbered registers. As a result,
8254 clobbered registers are available for any use in the assembler code.
8255
8256 Here is a realistic example for the VAX showing the use of clobbered
8257 registers:
8258
8259 @example
8260 asm volatile ("movc3 %0, %1, %2"
8261 : /* No outputs. */
8262 : "g" (from), "g" (to), "g" (count)
8263 : "r0", "r1", "r2", "r3", "r4", "r5");
8264 @end example
8265
8266 Also, there are two special clobber arguments:
8267
8268 @table @code
8269 @item "cc"
8270 The @code{"cc"} clobber indicates that the assembler code modifies the flags
8271 register. On some machines, GCC represents the condition codes as a specific
8272 hardware register; @code{"cc"} serves to name this register.
8273 On other machines, condition code handling is different,
8274 and specifying @code{"cc"} has no effect. But
8275 it is valid no matter what the target.
8276
8277 @item "memory"
8278 The @code{"memory"} clobber tells the compiler that the assembly code
8279 performs memory
8280 reads or writes to items other than those listed in the input and output
8281 operands (for example, accessing the memory pointed to by one of the input
8282 parameters). To ensure memory contains correct values, GCC may need to flush
8283 specific register values to memory before executing the @code{asm}. Further,
8284 the compiler does not assume that any values read from memory before an
8285 @code{asm} remain unchanged after that @code{asm}; it reloads them as
8286 needed.
8287 Using the @code{"memory"} clobber effectively forms a read/write
8288 memory barrier for the compiler.
8289
8290 Note that this clobber does not prevent the @emph{processor} from doing
8291 speculative reads past the @code{asm} statement. To prevent that, you need
8292 processor-specific fence instructions.
8293
8294 Flushing registers to memory has performance implications and may be an issue
8295 for time-sensitive code. You can use a trick to avoid this if the size of
8296 the memory being accessed is known at compile time. For example, if accessing
8297 ten bytes of a string, use a memory input like:
8298
8299 @code{@{"m"( (@{ struct @{ char x[10]; @} *p = (void *)ptr ; *p; @}) )@}}.
8300
8301 @end table
8302
8303 @anchor{GotoLabels}
8304 @subsubsection Goto Labels
8305 @cindex @code{asm} goto labels
8306
8307 @code{asm goto} allows assembly code to jump to one or more C labels. The
8308 @var{GotoLabels} section in an @code{asm goto} statement contains
8309 a comma-separated
8310 list of all C labels to which the assembler code may jump. GCC assumes that
8311 @code{asm} execution falls through to the next statement (if this is not the
8312 case, consider using the @code{__builtin_unreachable} intrinsic after the
8313 @code{asm} statement). Optimization of @code{asm goto} may be improved by
8314 using the @code{hot} and @code{cold} label attributes (@pxref{Label
8315 Attributes}).
8316
8317 An @code{asm goto} statement cannot have outputs.
8318 This is due to an internal restriction of
8319 the compiler: control transfer instructions cannot have outputs.
8320 If the assembler code does modify anything, use the @code{"memory"} clobber
8321 to force the
8322 optimizers to flush all register values to memory and reload them if
8323 necessary after the @code{asm} statement.
8324
8325 Also note that an @code{asm goto} statement is always implicitly
8326 considered volatile.
8327
8328 To reference a label in the assembler template,
8329 prefix it with @samp{%l} (lowercase @samp{L}) followed
8330 by its (zero-based) position in @var{GotoLabels} plus the number of input
8331 operands. For example, if the @code{asm} has three inputs and references two
8332 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
8333
8334 Alternately, you can reference labels using the actual C label name enclosed
8335 in brackets. For example, to reference a label named @code{carry}, you can
8336 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
8337 section when using this approach.
8338
8339 Here is an example of @code{asm goto} for i386:
8340
8341 @example
8342 asm goto (
8343 "btl %1, %0\n\t"
8344 "jc %l2"
8345 : /* No outputs. */
8346 : "r" (p1), "r" (p2)
8347 : "cc"
8348 : carry);
8349
8350 return 0;
8351
8352 carry:
8353 return 1;
8354 @end example
8355
8356 The following example shows an @code{asm goto} that uses a memory clobber.
8357
8358 @example
8359 int frob(int x)
8360 @{
8361 int y;
8362 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
8363 : /* No outputs. */
8364 : "r"(x), "r"(&y)
8365 : "r5", "memory"
8366 : error);
8367 return y;
8368 error:
8369 return -1;
8370 @}
8371 @end example
8372
8373 @anchor{x86Operandmodifiers}
8374 @subsubsection x86 Operand Modifiers
8375
8376 References to input, output, and goto operands in the assembler template
8377 of extended @code{asm} statements can use
8378 modifiers to affect the way the operands are formatted in
8379 the code output to the assembler. For example, the
8380 following code uses the @samp{h} and @samp{b} modifiers for x86:
8381
8382 @example
8383 uint16_t num;
8384 asm volatile ("xchg %h0, %b0" : "+a" (num) );
8385 @end example
8386
8387 @noindent
8388 These modifiers generate this assembler code:
8389
8390 @example
8391 xchg %ah, %al
8392 @end example
8393
8394 The rest of this discussion uses the following code for illustrative purposes.
8395
8396 @example
8397 int main()
8398 @{
8399 int iInt = 1;
8400
8401 top:
8402
8403 asm volatile goto ("some assembler instructions here"
8404 : /* No outputs. */
8405 : "q" (iInt), "X" (sizeof(unsigned char) + 1)
8406 : /* No clobbers. */
8407 : top);
8408 @}
8409 @end example
8410
8411 With no modifiers, this is what the output from the operands would be for the
8412 @samp{att} and @samp{intel} dialects of assembler:
8413
8414 @multitable {Operand} {masm=att} {OFFSET FLAT:.L2}
8415 @headitem Operand @tab masm=att @tab masm=intel
8416 @item @code{%0}
8417 @tab @code{%eax}
8418 @tab @code{eax}
8419 @item @code{%1}
8420 @tab @code{$2}
8421 @tab @code{2}
8422 @item @code{%2}
8423 @tab @code{$.L2}
8424 @tab @code{OFFSET FLAT:.L2}
8425 @end multitable
8426
8427 The table below shows the list of supported modifiers and their effects.
8428
8429 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {masm=att} {masm=intel}
8430 @headitem Modifier @tab Description @tab Operand @tab @option{masm=att} @tab @option{masm=intel}
8431 @item @code{z}
8432 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
8433 @tab @code{%z0}
8434 @tab @code{l}
8435 @tab
8436 @item @code{b}
8437 @tab Print the QImode name of the register.
8438 @tab @code{%b0}
8439 @tab @code{%al}
8440 @tab @code{al}
8441 @item @code{h}
8442 @tab Print the QImode name for a ``high'' register.
8443 @tab @code{%h0}
8444 @tab @code{%ah}
8445 @tab @code{ah}
8446 @item @code{w}
8447 @tab Print the HImode name of the register.
8448 @tab @code{%w0}
8449 @tab @code{%ax}
8450 @tab @code{ax}
8451 @item @code{k}
8452 @tab Print the SImode name of the register.
8453 @tab @code{%k0}
8454 @tab @code{%eax}
8455 @tab @code{eax}
8456 @item @code{q}
8457 @tab Print the DImode name of the register.
8458 @tab @code{%q0}
8459 @tab @code{%rax}
8460 @tab @code{rax}
8461 @item @code{l}
8462 @tab Print the label name with no punctuation.
8463 @tab @code{%l2}
8464 @tab @code{.L2}
8465 @tab @code{.L2}
8466 @item @code{c}
8467 @tab Require a constant operand and print the constant expression with no punctuation.
8468 @tab @code{%c1}
8469 @tab @code{2}
8470 @tab @code{2}
8471 @end multitable
8472
8473 @anchor{x86floatingpointasmoperands}
8474 @subsubsection x86 Floating-Point @code{asm} Operands
8475
8476 On x86 targets, there are several rules on the usage of stack-like registers
8477 in the operands of an @code{asm}. These rules apply only to the operands
8478 that are stack-like registers:
8479
8480 @enumerate
8481 @item
8482 Given a set of input registers that die in an @code{asm}, it is
8483 necessary to know which are implicitly popped by the @code{asm}, and
8484 which must be explicitly popped by GCC@.
8485
8486 An input register that is implicitly popped by the @code{asm} must be
8487 explicitly clobbered, unless it is constrained to match an
8488 output operand.
8489
8490 @item
8491 For any input register that is implicitly popped by an @code{asm}, it is
8492 necessary to know how to adjust the stack to compensate for the pop.
8493 If any non-popped input is closer to the top of the reg-stack than
8494 the implicitly popped register, it would not be possible to know what the
8495 stack looked like---it's not clear how the rest of the stack ``slides
8496 up''.
8497
8498 All implicitly popped input registers must be closer to the top of
8499 the reg-stack than any input that is not implicitly popped.
8500
8501 It is possible that if an input dies in an @code{asm}, the compiler might
8502 use the input register for an output reload. Consider this example:
8503
8504 @smallexample
8505 asm ("foo" : "=t" (a) : "f" (b));
8506 @end smallexample
8507
8508 @noindent
8509 This code says that input @code{b} is not popped by the @code{asm}, and that
8510 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
8511 deeper after the @code{asm} than it was before. But, it is possible that
8512 reload may think that it can use the same register for both the input and
8513 the output.
8514
8515 To prevent this from happening,
8516 if any input operand uses the @samp{f} constraint, all output register
8517 constraints must use the @samp{&} early-clobber modifier.
8518
8519 The example above is correctly written as:
8520
8521 @smallexample
8522 asm ("foo" : "=&t" (a) : "f" (b));
8523 @end smallexample
8524
8525 @item
8526 Some operands need to be in particular places on the stack. All
8527 output operands fall in this category---GCC has no other way to
8528 know which registers the outputs appear in unless you indicate
8529 this in the constraints.
8530
8531 Output operands must specifically indicate which register an output
8532 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
8533 constraints must select a class with a single register.
8534
8535 @item
8536 Output operands may not be ``inserted'' between existing stack registers.
8537 Since no 387 opcode uses a read/write operand, all output operands
8538 are dead before the @code{asm}, and are pushed by the @code{asm}.
8539 It makes no sense to push anywhere but the top of the reg-stack.
8540
8541 Output operands must start at the top of the reg-stack: output
8542 operands may not ``skip'' a register.
8543
8544 @item
8545 Some @code{asm} statements may need extra stack space for internal
8546 calculations. This can be guaranteed by clobbering stack registers
8547 unrelated to the inputs and outputs.
8548
8549 @end enumerate
8550
8551 This @code{asm}
8552 takes one input, which is internally popped, and produces two outputs.
8553
8554 @smallexample
8555 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
8556 @end smallexample
8557
8558 @noindent
8559 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
8560 and replaces them with one output. The @code{st(1)} clobber is necessary
8561 for the compiler to know that @code{fyl2xp1} pops both inputs.
8562
8563 @smallexample
8564 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
8565 @end smallexample
8566
8567 @lowersections
8568 @include md.texi
8569 @raisesections
8570
8571 @node Asm Labels
8572 @subsection Controlling Names Used in Assembler Code
8573 @cindex assembler names for identifiers
8574 @cindex names used in assembler code
8575 @cindex identifiers, names in assembler code
8576
8577 You can specify the name to be used in the assembler code for a C
8578 function or variable by writing the @code{asm} (or @code{__asm__})
8579 keyword after the declarator.
8580 It is up to you to make sure that the assembler names you choose do not
8581 conflict with any other assembler symbols, or reference registers.
8582
8583 @subsubheading Assembler names for data:
8584
8585 This sample shows how to specify the assembler name for data:
8586
8587 @smallexample
8588 int foo asm ("myfoo") = 2;
8589 @end smallexample
8590
8591 @noindent
8592 This specifies that the name to be used for the variable @code{foo} in
8593 the assembler code should be @samp{myfoo} rather than the usual
8594 @samp{_foo}.
8595
8596 On systems where an underscore is normally prepended to the name of a C
8597 variable, this feature allows you to define names for the
8598 linker that do not start with an underscore.
8599
8600 GCC does not support using this feature with a non-static local variable
8601 since such variables do not have assembler names. If you are
8602 trying to put the variable in a particular register, see
8603 @ref{Explicit Register Variables}.
8604
8605 @subsubheading Assembler names for functions:
8606
8607 To specify the assembler name for functions, write a declaration for the
8608 function before its definition and put @code{asm} there, like this:
8609
8610 @smallexample
8611 int func (int x, int y) asm ("MYFUNC");
8612
8613 int func (int x, int y)
8614 @{
8615 /* @r{@dots{}} */
8616 @end smallexample
8617
8618 @noindent
8619 This specifies that the name to be used for the function @code{func} in
8620 the assembler code should be @code{MYFUNC}.
8621
8622 @node Explicit Register Variables
8623 @subsection Variables in Specified Registers
8624 @anchor{Explicit Reg Vars}
8625 @cindex explicit register variables
8626 @cindex variables in specified registers
8627 @cindex specified registers
8628
8629 GNU C allows you to associate specific hardware registers with C
8630 variables. In almost all cases, allowing the compiler to assign
8631 registers produces the best code. However under certain unusual
8632 circumstances, more precise control over the variable storage is
8633 required.
8634
8635 Both global and local variables can be associated with a register. The
8636 consequences of performing this association are very different between
8637 the two, as explained in the sections below.
8638
8639 @menu
8640 * Global Register Variables:: Variables declared at global scope.
8641 * Local Register Variables:: Variables declared within a function.
8642 @end menu
8643
8644 @node Global Register Variables
8645 @subsubsection Defining Global Register Variables
8646 @anchor{Global Reg Vars}
8647 @cindex global register variables
8648 @cindex registers, global variables in
8649 @cindex registers, global allocation
8650
8651 You can define a global register variable and associate it with a specified
8652 register like this:
8653
8654 @smallexample
8655 register int *foo asm ("r12");
8656 @end smallexample
8657
8658 @noindent
8659 Here @code{r12} is the name of the register that should be used. Note that
8660 this is the same syntax used for defining local register variables, but for
8661 a global variable the declaration appears outside a function. The
8662 @code{register} keyword is required, and cannot be combined with
8663 @code{static}. The register name must be a valid register name for the
8664 target platform.
8665
8666 Registers are a scarce resource on most systems and allowing the
8667 compiler to manage their usage usually results in the best code. However,
8668 under special circumstances it can make sense to reserve some globally.
8669 For example this may be useful in programs such as programming language
8670 interpreters that have a couple of global variables that are accessed
8671 very often.
8672
8673 After defining a global register variable, for the current compilation
8674 unit:
8675
8676 @itemize @bullet
8677 @item The register is reserved entirely for this use, and will not be
8678 allocated for any other purpose.
8679 @item The register is not saved and restored by any functions.
8680 @item Stores into this register are never deleted even if they appear to be
8681 dead, but references may be deleted, moved or simplified.
8682 @end itemize
8683
8684 Note that these points @emph{only} apply to code that is compiled with the
8685 definition. The behavior of code that is merely linked in (for example
8686 code from libraries) is not affected.
8687
8688 If you want to recompile source files that do not actually use your global
8689 register variable so they do not use the specified register for any other
8690 purpose, you need not actually add the global register declaration to
8691 their source code. It suffices to specify the compiler option
8692 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
8693 register.
8694
8695 @subsubheading Declaring the variable
8696
8697 Global register variables can not have initial values, because an
8698 executable file has no means to supply initial contents for a register.
8699
8700 When selecting a register, choose one that is normally saved and
8701 restored by function calls on your machine. This ensures that code
8702 which is unaware of this reservation (such as library routines) will
8703 restore it before returning.
8704
8705 On machines with register windows, be sure to choose a global
8706 register that is not affected magically by the function call mechanism.
8707
8708 @subsubheading Using the variable
8709
8710 @cindex @code{qsort}, and global register variables
8711 When calling routines that are not aware of the reservation, be
8712 cautious if those routines call back into code which uses them. As an
8713 example, if you call the system library version of @code{qsort}, it may
8714 clobber your registers during execution, but (if you have selected
8715 appropriate registers) it will restore them before returning. However
8716 it will @emph{not} restore them before calling @code{qsort}'s comparison
8717 function. As a result, global values will not reliably be available to
8718 the comparison function unless the @code{qsort} function itself is rebuilt.
8719
8720 Similarly, it is not safe to access the global register variables from signal
8721 handlers or from more than one thread of control. Unless you recompile
8722 them specially for the task at hand, the system library routines may
8723 temporarily use the register for other things.
8724
8725 @cindex register variable after @code{longjmp}
8726 @cindex global register after @code{longjmp}
8727 @cindex value after @code{longjmp}
8728 @findex longjmp
8729 @findex setjmp
8730 On most machines, @code{longjmp} restores to each global register
8731 variable the value it had at the time of the @code{setjmp}. On some
8732 machines, however, @code{longjmp} does not change the value of global
8733 register variables. To be portable, the function that called @code{setjmp}
8734 should make other arrangements to save the values of the global register
8735 variables, and to restore them in a @code{longjmp}. This way, the same
8736 thing happens regardless of what @code{longjmp} does.
8737
8738 Eventually there may be a way of asking the compiler to choose a register
8739 automatically, but first we need to figure out how it should choose and
8740 how to enable you to guide the choice. No solution is evident.
8741
8742 @node Local Register Variables
8743 @subsubsection Specifying Registers for Local Variables
8744 @anchor{Local Reg Vars}
8745 @cindex local variables, specifying registers
8746 @cindex specifying registers for local variables
8747 @cindex registers for local variables
8748
8749 You can define a local register variable and associate it with a specified
8750 register like this:
8751
8752 @smallexample
8753 register int *foo asm ("r12");
8754 @end smallexample
8755
8756 @noindent
8757 Here @code{r12} is the name of the register that should be used. Note
8758 that this is the same syntax used for defining global register variables,
8759 but for a local variable the declaration appears within a function. The
8760 @code{register} keyword is required, and cannot be combined with
8761 @code{static}. The register name must be a valid register name for the
8762 target platform.
8763
8764 As with global register variables, it is recommended that you choose
8765 a register that is normally saved and restored by function calls on your
8766 machine, so that calls to library routines will not clobber it.
8767
8768 The only supported use for this feature is to specify registers
8769 for input and output operands when calling Extended @code{asm}
8770 (@pxref{Extended Asm}). This may be necessary if the constraints for a
8771 particular machine don't provide sufficient control to select the desired
8772 register. To force an operand into a register, create a local variable
8773 and specify the register name after the variable's declaration. Then use
8774 the local variable for the @code{asm} operand and specify any constraint
8775 letter that matches the register:
8776
8777 @smallexample
8778 register int *p1 asm ("r0") = @dots{};
8779 register int *p2 asm ("r1") = @dots{};
8780 register int *result asm ("r0");
8781 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8782 @end smallexample
8783
8784 @emph{Warning:} In the above example, be aware that a register (for example
8785 @code{r0}) can be call-clobbered by subsequent code, including function
8786 calls and library calls for arithmetic operators on other variables (for
8787 example the initialization of @code{p2}). In this case, use temporary
8788 variables for expressions between the register assignments:
8789
8790 @smallexample
8791 int t1 = @dots{};
8792 register int *p1 asm ("r0") = @dots{};
8793 register int *p2 asm ("r1") = t1;
8794 register int *result asm ("r0");
8795 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
8796 @end smallexample
8797
8798 Defining a register variable does not reserve the register. Other than
8799 when invoking the Extended @code{asm}, the contents of the specified
8800 register are not guaranteed. For this reason, the following uses
8801 are explicitly @emph{not} supported. If they appear to work, it is only
8802 happenstance, and may stop working as intended due to (seemingly)
8803 unrelated changes in surrounding code, or even minor changes in the
8804 optimization of a future version of gcc:
8805
8806 @itemize @bullet
8807 @item Passing parameters to or from Basic @code{asm}
8808 @item Passing parameters to or from Extended @code{asm} without using input
8809 or output operands.
8810 @item Passing parameters to or from routines written in assembler (or
8811 other languages) using non-standard calling conventions.
8812 @end itemize
8813
8814 Some developers use Local Register Variables in an attempt to improve
8815 gcc's allocation of registers, especially in large functions. In this
8816 case the register name is essentially a hint to the register allocator.
8817 While in some instances this can generate better code, improvements are
8818 subject to the whims of the allocator/optimizers. Since there are no
8819 guarantees that your improvements won't be lost, this usage of Local
8820 Register Variables is discouraged.
8821
8822 On the MIPS platform, there is related use for local register variables
8823 with slightly different characteristics (@pxref{MIPS Coprocessors,,
8824 Defining coprocessor specifics for MIPS targets, gccint,
8825 GNU Compiler Collection (GCC) Internals}).
8826
8827 @node Size of an asm
8828 @subsection Size of an @code{asm}
8829
8830 Some targets require that GCC track the size of each instruction used
8831 in order to generate correct code. Because the final length of the
8832 code produced by an @code{asm} statement is only known by the
8833 assembler, GCC must make an estimate as to how big it will be. It
8834 does this by counting the number of instructions in the pattern of the
8835 @code{asm} and multiplying that by the length of the longest
8836 instruction supported by that processor. (When working out the number
8837 of instructions, it assumes that any occurrence of a newline or of
8838 whatever statement separator character is supported by the assembler --
8839 typically @samp{;} --- indicates the end of an instruction.)
8840
8841 Normally, GCC's estimate is adequate to ensure that correct
8842 code is generated, but it is possible to confuse the compiler if you use
8843 pseudo instructions or assembler macros that expand into multiple real
8844 instructions, or if you use assembler directives that expand to more
8845 space in the object file than is needed for a single instruction.
8846 If this happens then the assembler may produce a diagnostic saying that
8847 a label is unreachable.
8848
8849 @node Alternate Keywords
8850 @section Alternate Keywords
8851 @cindex alternate keywords
8852 @cindex keywords, alternate
8853
8854 @option{-ansi} and the various @option{-std} options disable certain
8855 keywords. This causes trouble when you want to use GNU C extensions, or
8856 a general-purpose header file that should be usable by all programs,
8857 including ISO C programs. The keywords @code{asm}, @code{typeof} and
8858 @code{inline} are not available in programs compiled with
8859 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
8860 program compiled with @option{-std=c99} or @option{-std=c11}). The
8861 ISO C99 keyword
8862 @code{restrict} is only available when @option{-std=gnu99} (which will
8863 eventually be the default) or @option{-std=c99} (or the equivalent
8864 @option{-std=iso9899:1999}), or an option for a later standard
8865 version, is used.
8866
8867 The way to solve these problems is to put @samp{__} at the beginning and
8868 end of each problematical keyword. For example, use @code{__asm__}
8869 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
8870
8871 Other C compilers won't accept these alternative keywords; if you want to
8872 compile with another compiler, you can define the alternate keywords as
8873 macros to replace them with the customary keywords. It looks like this:
8874
8875 @smallexample
8876 #ifndef __GNUC__
8877 #define __asm__ asm
8878 #endif
8879 @end smallexample
8880
8881 @findex __extension__
8882 @opindex pedantic
8883 @option{-pedantic} and other options cause warnings for many GNU C extensions.
8884 You can
8885 prevent such warnings within one expression by writing
8886 @code{__extension__} before the expression. @code{__extension__} has no
8887 effect aside from this.
8888
8889 @node Incomplete Enums
8890 @section Incomplete @code{enum} Types
8891
8892 You can define an @code{enum} tag without specifying its possible values.
8893 This results in an incomplete type, much like what you get if you write
8894 @code{struct foo} without describing the elements. A later declaration
8895 that does specify the possible values completes the type.
8896
8897 You can't allocate variables or storage using the type while it is
8898 incomplete. However, you can work with pointers to that type.
8899
8900 This extension may not be very useful, but it makes the handling of
8901 @code{enum} more consistent with the way @code{struct} and @code{union}
8902 are handled.
8903
8904 This extension is not supported by GNU C++.
8905
8906 @node Function Names
8907 @section Function Names as Strings
8908 @cindex @code{__func__} identifier
8909 @cindex @code{__FUNCTION__} identifier
8910 @cindex @code{__PRETTY_FUNCTION__} identifier
8911
8912 GCC provides three magic variables that hold the name of the current
8913 function, as a string. The first of these is @code{__func__}, which
8914 is part of the C99 standard:
8915
8916 The identifier @code{__func__} is implicitly declared by the translator
8917 as if, immediately following the opening brace of each function
8918 definition, the declaration
8919
8920 @smallexample
8921 static const char __func__[] = "function-name";
8922 @end smallexample
8923
8924 @noindent
8925 appeared, where function-name is the name of the lexically-enclosing
8926 function. This name is the unadorned name of the function.
8927
8928 @code{__FUNCTION__} is another name for @code{__func__}, provided for
8929 backward compatibility with old versions of GCC.
8930
8931 In C, @code{__PRETTY_FUNCTION__} is yet another name for
8932 @code{__func__}. However, in C++, @code{__PRETTY_FUNCTION__} contains
8933 the type signature of the function as well as its bare name. For
8934 example, this program:
8935
8936 @smallexample
8937 extern "C" @{
8938 extern int printf (char *, ...);
8939 @}
8940
8941 class a @{
8942 public:
8943 void sub (int i)
8944 @{
8945 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
8946 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
8947 @}
8948 @};
8949
8950 int
8951 main (void)
8952 @{
8953 a ax;
8954 ax.sub (0);
8955 return 0;
8956 @}
8957 @end smallexample
8958
8959 @noindent
8960 gives this output:
8961
8962 @smallexample
8963 __FUNCTION__ = sub
8964 __PRETTY_FUNCTION__ = void a::sub(int)
8965 @end smallexample
8966
8967 These identifiers are variables, not preprocessor macros, and may not
8968 be used to initialize @code{char} arrays or be concatenated with other string
8969 literals.
8970
8971 @node Return Address
8972 @section Getting the Return or Frame Address of a Function
8973
8974 These functions may be used to get information about the callers of a
8975 function.
8976
8977 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
8978 This function returns the return address of the current function, or of
8979 one of its callers. The @var{level} argument is number of frames to
8980 scan up the call stack. A value of @code{0} yields the return address
8981 of the current function, a value of @code{1} yields the return address
8982 of the caller of the current function, and so forth. When inlining
8983 the expected behavior is that the function returns the address of
8984 the function that is returned to. To work around this behavior use
8985 the @code{noinline} function attribute.
8986
8987 The @var{level} argument must be a constant integer.
8988
8989 On some machines it may be impossible to determine the return address of
8990 any function other than the current one; in such cases, or when the top
8991 of the stack has been reached, this function returns @code{0} or a
8992 random value. In addition, @code{__builtin_frame_address} may be used
8993 to determine if the top of the stack has been reached.
8994
8995 Additional post-processing of the returned value may be needed, see
8996 @code{__builtin_extract_return_addr}.
8997
8998 Calling this function with a nonzero argument can have unpredictable
8999 effects, including crashing the calling program. As a result, calls
9000 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9001 option is in effect. Such calls should only be made in debugging
9002 situations.
9003 @end deftypefn
9004
9005 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9006 The address as returned by @code{__builtin_return_address} may have to be fed
9007 through this function to get the actual encoded address. For example, on the
9008 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9009 platforms an offset has to be added for the true next instruction to be
9010 executed.
9011
9012 If no fixup is needed, this function simply passes through @var{addr}.
9013 @end deftypefn
9014
9015 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9016 This function does the reverse of @code{__builtin_extract_return_addr}.
9017 @end deftypefn
9018
9019 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9020 This function is similar to @code{__builtin_return_address}, but it
9021 returns the address of the function frame rather than the return address
9022 of the function. Calling @code{__builtin_frame_address} with a value of
9023 @code{0} yields the frame address of the current function, a value of
9024 @code{1} yields the frame address of the caller of the current function,
9025 and so forth.
9026
9027 The frame is the area on the stack that holds local variables and saved
9028 registers. The frame address is normally the address of the first word
9029 pushed on to the stack by the function. However, the exact definition
9030 depends upon the processor and the calling convention. If the processor
9031 has a dedicated frame pointer register, and the function has a frame,
9032 then @code{__builtin_frame_address} returns the value of the frame
9033 pointer register.
9034
9035 On some machines it may be impossible to determine the frame address of
9036 any function other than the current one; in such cases, or when the top
9037 of the stack has been reached, this function returns @code{0} if
9038 the first frame pointer is properly initialized by the startup code.
9039
9040 Calling this function with a nonzero argument can have unpredictable
9041 effects, including crashing the calling program. As a result, calls
9042 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9043 option is in effect. Such calls should only be made in debugging
9044 situations.
9045 @end deftypefn
9046
9047 @node Vector Extensions
9048 @section Using Vector Instructions through Built-in Functions
9049
9050 On some targets, the instruction set contains SIMD vector instructions which
9051 operate on multiple values contained in one large register at the same time.
9052 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9053 this way.
9054
9055 The first step in using these extensions is to provide the necessary data
9056 types. This should be done using an appropriate @code{typedef}:
9057
9058 @smallexample
9059 typedef int v4si __attribute__ ((vector_size (16)));
9060 @end smallexample
9061
9062 @noindent
9063 The @code{int} type specifies the base type, while the attribute specifies
9064 the vector size for the variable, measured in bytes. For example, the
9065 declaration above causes the compiler to set the mode for the @code{v4si}
9066 type to be 16 bytes wide and divided into @code{int} sized units. For
9067 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9068 corresponding mode of @code{foo} is @acronym{V4SI}.
9069
9070 The @code{vector_size} attribute is only applicable to integral and
9071 float scalars, although arrays, pointers, and function return values
9072 are allowed in conjunction with this construct. Only sizes that are
9073 a power of two are currently allowed.
9074
9075 All the basic integer types can be used as base types, both as signed
9076 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9077 @code{long long}. In addition, @code{float} and @code{double} can be
9078 used to build floating-point vector types.
9079
9080 Specifying a combination that is not valid for the current architecture
9081 causes GCC to synthesize the instructions using a narrower mode.
9082 For example, if you specify a variable of type @code{V4SI} and your
9083 architecture does not allow for this specific SIMD type, GCC
9084 produces code that uses 4 @code{SIs}.
9085
9086 The types defined in this manner can be used with a subset of normal C
9087 operations. Currently, GCC allows using the following operators
9088 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9089
9090 The operations behave like C++ @code{valarrays}. Addition is defined as
9091 the addition of the corresponding elements of the operands. For
9092 example, in the code below, each of the 4 elements in @var{a} is
9093 added to the corresponding 4 elements in @var{b} and the resulting
9094 vector is stored in @var{c}.
9095
9096 @smallexample
9097 typedef int v4si __attribute__ ((vector_size (16)));
9098
9099 v4si a, b, c;
9100
9101 c = a + b;
9102 @end smallexample
9103
9104 Subtraction, multiplication, division, and the logical operations
9105 operate in a similar manner. Likewise, the result of using the unary
9106 minus or complement operators on a vector type is a vector whose
9107 elements are the negative or complemented values of the corresponding
9108 elements in the operand.
9109
9110 It is possible to use shifting operators @code{<<}, @code{>>} on
9111 integer-type vectors. The operation is defined as following: @code{@{a0,
9112 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9113 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9114 elements.
9115
9116 For convenience, it is allowed to use a binary vector operation
9117 where one operand is a scalar. In that case the compiler transforms
9118 the scalar operand into a vector where each element is the scalar from
9119 the operation. The transformation happens only if the scalar could be
9120 safely converted to the vector-element type.
9121 Consider the following code.
9122
9123 @smallexample
9124 typedef int v4si __attribute__ ((vector_size (16)));
9125
9126 v4si a, b, c;
9127 long l;
9128
9129 a = b + 1; /* a = b + @{1,1,1,1@}; */
9130 a = 2 * b; /* a = @{2,2,2,2@} * b; */
9131
9132 a = l + a; /* Error, cannot convert long to int. */
9133 @end smallexample
9134
9135 Vectors can be subscripted as if the vector were an array with
9136 the same number of elements and base type. Out of bound accesses
9137 invoke undefined behavior at run time. Warnings for out of bound
9138 accesses for vector subscription can be enabled with
9139 @option{-Warray-bounds}.
9140
9141 Vector comparison is supported with standard comparison
9142 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9143 vector expressions of integer-type or real-type. Comparison between
9144 integer-type vectors and real-type vectors are not supported. The
9145 result of the comparison is a vector of the same width and number of
9146 elements as the comparison operands with a signed integral element
9147 type.
9148
9149 Vectors are compared element-wise producing 0 when comparison is false
9150 and -1 (constant of the appropriate type where all bits are set)
9151 otherwise. Consider the following example.
9152
9153 @smallexample
9154 typedef int v4si __attribute__ ((vector_size (16)));
9155
9156 v4si a = @{1,2,3,4@};
9157 v4si b = @{3,2,1,4@};
9158 v4si c;
9159
9160 c = a > b; /* The result would be @{0, 0,-1, 0@} */
9161 c = a == b; /* The result would be @{0,-1, 0,-1@} */
9162 @end smallexample
9163
9164 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9165 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9166 integer vector with the same number of elements of the same size as @code{b}
9167 and @code{c}, computes all three arguments and creates a vector
9168 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
9169 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9170 As in the case of binary operations, this syntax is also accepted when
9171 one of @code{b} or @code{c} is a scalar that is then transformed into a
9172 vector. If both @code{b} and @code{c} are scalars and the type of
9173 @code{true?b:c} has the same size as the element type of @code{a}, then
9174 @code{b} and @code{c} are converted to a vector type whose elements have
9175 this type and with the same number of elements as @code{a}.
9176
9177 In C++, the logic operators @code{!, &&, ||} are available for vectors.
9178 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
9179 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
9180 For mixed operations between a scalar @code{s} and a vector @code{v},
9181 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
9182 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
9183
9184 Vector shuffling is available using functions
9185 @code{__builtin_shuffle (vec, mask)} and
9186 @code{__builtin_shuffle (vec0, vec1, mask)}.
9187 Both functions construct a permutation of elements from one or two
9188 vectors and return a vector of the same type as the input vector(s).
9189 The @var{mask} is an integral vector with the same width (@var{W})
9190 and element count (@var{N}) as the output vector.
9191
9192 The elements of the input vectors are numbered in memory ordering of
9193 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
9194 elements of @var{mask} are considered modulo @var{N} in the single-operand
9195 case and modulo @math{2*@var{N}} in the two-operand case.
9196
9197 Consider the following example,
9198
9199 @smallexample
9200 typedef int v4si __attribute__ ((vector_size (16)));
9201
9202 v4si a = @{1,2,3,4@};
9203 v4si b = @{5,6,7,8@};
9204 v4si mask1 = @{0,1,1,3@};
9205 v4si mask2 = @{0,4,2,5@};
9206 v4si res;
9207
9208 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
9209 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
9210 @end smallexample
9211
9212 Note that @code{__builtin_shuffle} is intentionally semantically
9213 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
9214
9215 You can declare variables and use them in function calls and returns, as
9216 well as in assignments and some casts. You can specify a vector type as
9217 a return type for a function. Vector types can also be used as function
9218 arguments. It is possible to cast from one vector type to another,
9219 provided they are of the same size (in fact, you can also cast vectors
9220 to and from other datatypes of the same size).
9221
9222 You cannot operate between vectors of different lengths or different
9223 signedness without a cast.
9224
9225 @node Offsetof
9226 @section Support for @code{offsetof}
9227 @findex __builtin_offsetof
9228
9229 GCC implements for both C and C++ a syntactic extension to implement
9230 the @code{offsetof} macro.
9231
9232 @smallexample
9233 primary:
9234 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
9235
9236 offsetof_member_designator:
9237 @code{identifier}
9238 | offsetof_member_designator "." @code{identifier}
9239 | offsetof_member_designator "[" @code{expr} "]"
9240 @end smallexample
9241
9242 This extension is sufficient such that
9243
9244 @smallexample
9245 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
9246 @end smallexample
9247
9248 @noindent
9249 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
9250 may be dependent. In either case, @var{member} may consist of a single
9251 identifier, or a sequence of member accesses and array references.
9252
9253 @node __sync Builtins
9254 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
9255
9256 The following built-in functions
9257 are intended to be compatible with those described
9258 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
9259 section 7.4. As such, they depart from normal GCC practice by not using
9260 the @samp{__builtin_} prefix and also by being overloaded so that they
9261 work on multiple types.
9262
9263 The definition given in the Intel documentation allows only for the use of
9264 the types @code{int}, @code{long}, @code{long long} or their unsigned
9265 counterparts. GCC allows any integral scalar or pointer type that is
9266 1, 2, 4 or 8 bytes in length.
9267
9268 These functions are implemented in terms of the @samp{__atomic}
9269 builtins (@pxref{__atomic Builtins}). They should not be used for new
9270 code which should use the @samp{__atomic} builtins instead.
9271
9272 Not all operations are supported by all target processors. If a particular
9273 operation cannot be implemented on the target processor, a warning is
9274 generated and a call to an external function is generated. The external
9275 function carries the same name as the built-in version,
9276 with an additional suffix
9277 @samp{_@var{n}} where @var{n} is the size of the data type.
9278
9279 @c ??? Should we have a mechanism to suppress this warning? This is almost
9280 @c useful for implementing the operation under the control of an external
9281 @c mutex.
9282
9283 In most cases, these built-in functions are considered a @dfn{full barrier}.
9284 That is,
9285 no memory operand is moved across the operation, either forward or
9286 backward. Further, instructions are issued as necessary to prevent the
9287 processor from speculating loads across the operation and from queuing stores
9288 after the operation.
9289
9290 All of the routines are described in the Intel documentation to take
9291 ``an optional list of variables protected by the memory barrier''. It's
9292 not clear what is meant by that; it could mean that @emph{only} the
9293 listed variables are protected, or it could mean a list of additional
9294 variables to be protected. The list is ignored by GCC which treats it as
9295 empty. GCC interprets an empty list as meaning that all globally
9296 accessible variables should be protected.
9297
9298 @table @code
9299 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
9300 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
9301 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
9302 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
9303 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
9304 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
9305 @findex __sync_fetch_and_add
9306 @findex __sync_fetch_and_sub
9307 @findex __sync_fetch_and_or
9308 @findex __sync_fetch_and_and
9309 @findex __sync_fetch_and_xor
9310 @findex __sync_fetch_and_nand
9311 These built-in functions perform the operation suggested by the name, and
9312 returns the value that had previously been in memory. That is,
9313
9314 @smallexample
9315 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
9316 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
9317 @end smallexample
9318
9319 The object pointed to by the first argument must be of integer or pointer
9320 type. It must not be a Boolean type.
9321
9322 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
9323 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
9324
9325 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
9326 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
9327 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
9328 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
9329 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
9330 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
9331 @findex __sync_add_and_fetch
9332 @findex __sync_sub_and_fetch
9333 @findex __sync_or_and_fetch
9334 @findex __sync_and_and_fetch
9335 @findex __sync_xor_and_fetch
9336 @findex __sync_nand_and_fetch
9337 These built-in functions perform the operation suggested by the name, and
9338 return the new value. That is,
9339
9340 @smallexample
9341 @{ *ptr @var{op}= value; return *ptr; @}
9342 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
9343 @end smallexample
9344
9345 The same constraints on arguments apply as for the corresponding
9346 @code{__sync_op_and_fetch} built-in functions.
9347
9348 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
9349 as @code{*ptr = ~(*ptr & value)} instead of
9350 @code{*ptr = ~*ptr & value}.
9351
9352 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9353 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
9354 @findex __sync_bool_compare_and_swap
9355 @findex __sync_val_compare_and_swap
9356 These built-in functions perform an atomic compare and swap.
9357 That is, if the current
9358 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
9359 @code{*@var{ptr}}.
9360
9361 The ``bool'' version returns true if the comparison is successful and
9362 @var{newval} is written. The ``val'' version returns the contents
9363 of @code{*@var{ptr}} before the operation.
9364
9365 @item __sync_synchronize (...)
9366 @findex __sync_synchronize
9367 This built-in function issues a full memory barrier.
9368
9369 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
9370 @findex __sync_lock_test_and_set
9371 This built-in function, as described by Intel, is not a traditional test-and-set
9372 operation, but rather an atomic exchange operation. It writes @var{value}
9373 into @code{*@var{ptr}}, and returns the previous contents of
9374 @code{*@var{ptr}}.
9375
9376 Many targets have only minimal support for such locks, and do not support
9377 a full exchange operation. In this case, a target may support reduced
9378 functionality here by which the @emph{only} valid value to store is the
9379 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
9380 is implementation defined.
9381
9382 This built-in function is not a full barrier,
9383 but rather an @dfn{acquire barrier}.
9384 This means that references after the operation cannot move to (or be
9385 speculated to) before the operation, but previous memory stores may not
9386 be globally visible yet, and previous memory loads may not yet be
9387 satisfied.
9388
9389 @item void __sync_lock_release (@var{type} *ptr, ...)
9390 @findex __sync_lock_release
9391 This built-in function releases the lock acquired by
9392 @code{__sync_lock_test_and_set}.
9393 Normally this means writing the constant 0 to @code{*@var{ptr}}.
9394
9395 This built-in function is not a full barrier,
9396 but rather a @dfn{release barrier}.
9397 This means that all previous memory stores are globally visible, and all
9398 previous memory loads have been satisfied, but following memory reads
9399 are not prevented from being speculated to before the barrier.
9400 @end table
9401
9402 @node __atomic Builtins
9403 @section Built-in Functions for Memory Model Aware Atomic Operations
9404
9405 The following built-in functions approximately match the requirements
9406 for the C++11 memory model. They are all
9407 identified by being prefixed with @samp{__atomic} and most are
9408 overloaded so that they work with multiple types.
9409
9410 These functions are intended to replace the legacy @samp{__sync}
9411 builtins. The main difference is that the memory order that is requested
9412 is a parameter to the functions. New code should always use the
9413 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
9414
9415 Note that the @samp{__atomic} builtins assume that programs will
9416 conform to the C++11 memory model. In particular, they assume
9417 that programs are free of data races. See the C++11 standard for
9418 detailed requirements.
9419
9420 The @samp{__atomic} builtins can be used with any integral scalar or
9421 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
9422 types are also allowed if @samp{__int128} (@pxref{__int128}) is
9423 supported by the architecture.
9424
9425 The four non-arithmetic functions (load, store, exchange, and
9426 compare_exchange) all have a generic version as well. This generic
9427 version works on any data type. It uses the lock-free built-in function
9428 if the specific data type size makes that possible; otherwise, an
9429 external call is left to be resolved at run time. This external call is
9430 the same format with the addition of a @samp{size_t} parameter inserted
9431 as the first parameter indicating the size of the object being pointed to.
9432 All objects must be the same size.
9433
9434 There are 6 different memory orders that can be specified. These map
9435 to the C++11 memory orders with the same names, see the C++11 standard
9436 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
9437 on atomic synchronization} for detailed definitions. Individual
9438 targets may also support additional memory orders for use on specific
9439 architectures. Refer to the target documentation for details of
9440 these.
9441
9442 An atomic operation can both constrain code motion and
9443 be mapped to hardware instructions for synchronization between threads
9444 (e.g., a fence). To which extent this happens is controlled by the
9445 memory orders, which are listed here in approximately ascending order of
9446 strength. The description of each memory order is only meant to roughly
9447 illustrate the effects and is not a specification; see the C++11
9448 memory model for precise semantics.
9449
9450 @table @code
9451 @item __ATOMIC_RELAXED
9452 Implies no inter-thread ordering constraints.
9453 @item __ATOMIC_CONSUME
9454 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
9455 memory order because of a deficiency in C++11's semantics for
9456 @code{memory_order_consume}.
9457 @item __ATOMIC_ACQUIRE
9458 Creates an inter-thread happens-before constraint from the release (or
9459 stronger) semantic store to this acquire load. Can prevent hoisting
9460 of code to before the operation.
9461 @item __ATOMIC_RELEASE
9462 Creates an inter-thread happens-before constraint to acquire (or stronger)
9463 semantic loads that read from this release store. Can prevent sinking
9464 of code to after the operation.
9465 @item __ATOMIC_ACQ_REL
9466 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
9467 @code{__ATOMIC_RELEASE}.
9468 @item __ATOMIC_SEQ_CST
9469 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
9470 @end table
9471
9472 Note that in the C++11 memory model, @emph{fences} (e.g.,
9473 @samp{__atomic_thread_fence}) take effect in combination with other
9474 atomic operations on specific memory locations (e.g., atomic loads);
9475 operations on specific memory locations do not necessarily affect other
9476 operations in the same way.
9477
9478 Target architectures are encouraged to provide their own patterns for
9479 each of the atomic built-in functions. If no target is provided, the original
9480 non-memory model set of @samp{__sync} atomic built-in functions are
9481 used, along with any required synchronization fences surrounding it in
9482 order to achieve the proper behavior. Execution in this case is subject
9483 to the same restrictions as those built-in functions.
9484
9485 If there is no pattern or mechanism to provide a lock-free instruction
9486 sequence, a call is made to an external routine with the same parameters
9487 to be resolved at run time.
9488
9489 When implementing patterns for these built-in functions, the memory order
9490 parameter can be ignored as long as the pattern implements the most
9491 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
9492 orders execute correctly with this memory order but they may not execute as
9493 efficiently as they could with a more appropriate implementation of the
9494 relaxed requirements.
9495
9496 Note that the C++11 standard allows for the memory order parameter to be
9497 determined at run time rather than at compile time. These built-in
9498 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
9499 than invoke a runtime library call or inline a switch statement. This is
9500 standard compliant, safe, and the simplest approach for now.
9501
9502 The memory order parameter is a signed int, but only the lower 16 bits are
9503 reserved for the memory order. The remainder of the signed int is reserved
9504 for target use and should be 0. Use of the predefined atomic values
9505 ensures proper usage.
9506
9507 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
9508 This built-in function implements an atomic load operation. It returns the
9509 contents of @code{*@var{ptr}}.
9510
9511 The valid memory order variants are
9512 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9513 and @code{__ATOMIC_CONSUME}.
9514
9515 @end deftypefn
9516
9517 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
9518 This is the generic version of an atomic load. It returns the
9519 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
9520
9521 @end deftypefn
9522
9523 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
9524 This built-in function implements an atomic store operation. It writes
9525 @code{@var{val}} into @code{*@var{ptr}}.
9526
9527 The valid memory order variants are
9528 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
9529
9530 @end deftypefn
9531
9532 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
9533 This is the generic version of an atomic store. It stores the value
9534 of @code{*@var{val}} into @code{*@var{ptr}}.
9535
9536 @end deftypefn
9537
9538 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
9539 This built-in function implements an atomic exchange operation. It writes
9540 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
9541 @code{*@var{ptr}}.
9542
9543 The valid memory order variants are
9544 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
9545 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
9546
9547 @end deftypefn
9548
9549 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
9550 This is the generic version of an atomic exchange. It stores the
9551 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
9552 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
9553
9554 @end deftypefn
9555
9556 @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)
9557 This built-in function implements an atomic compare and exchange operation.
9558 This compares the contents of @code{*@var{ptr}} with the contents of
9559 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
9560 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
9561 equal, the operation is a @emph{read} and the current contents of
9562 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
9563 for weak compare_exchange, which may fail spuriously, and false for
9564 the strong variation, which never fails spuriously. Many targets
9565 only offer the strong variation and ignore the parameter. When in doubt, use
9566 the strong variation.
9567
9568 If @var{desired} is written into @code{*@var{ptr}} then true is returned
9569 and memory is affected according to the
9570 memory order specified by @var{success_memorder}. There are no
9571 restrictions on what memory order can be used here.
9572
9573 Otherwise, false is returned and memory is affected according
9574 to @var{failure_memorder}. This memory order cannot be
9575 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
9576 stronger order than that specified by @var{success_memorder}.
9577
9578 @end deftypefn
9579
9580 @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)
9581 This built-in function implements the generic version of
9582 @code{__atomic_compare_exchange}. The function is virtually identical to
9583 @code{__atomic_compare_exchange_n}, except the desired value is also a
9584 pointer.
9585
9586 @end deftypefn
9587
9588 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
9589 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
9590 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
9591 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
9592 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
9593 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
9594 These built-in functions perform the operation suggested by the name, and
9595 return the result of the operation. That is,
9596
9597 @smallexample
9598 @{ *ptr @var{op}= val; return *ptr; @}
9599 @end smallexample
9600
9601 The object pointed to by the first argument must be of integer or pointer
9602 type. It must not be a Boolean type. All memory orders are valid.
9603
9604 @end deftypefn
9605
9606 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
9607 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
9608 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
9609 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
9610 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
9611 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
9612 These built-in functions perform the operation suggested by the name, and
9613 return the value that had previously been in @code{*@var{ptr}}. That is,
9614
9615 @smallexample
9616 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
9617 @end smallexample
9618
9619 The same constraints on arguments apply as for the corresponding
9620 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
9621
9622 @end deftypefn
9623
9624 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
9625
9626 This built-in function performs an atomic test-and-set operation on
9627 the byte at @code{*@var{ptr}}. The byte is set to some implementation
9628 defined nonzero ``set'' value and the return value is @code{true} if and only
9629 if the previous contents were ``set''.
9630 It should be only used for operands of type @code{bool} or @code{char}. For
9631 other types only part of the value may be set.
9632
9633 All memory orders are valid.
9634
9635 @end deftypefn
9636
9637 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
9638
9639 This built-in function performs an atomic clear operation on
9640 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
9641 It should be only used for operands of type @code{bool} or @code{char} and
9642 in conjunction with @code{__atomic_test_and_set}.
9643 For other types it may only clear partially. If the type is not @code{bool}
9644 prefer using @code{__atomic_store}.
9645
9646 The valid memory order variants are
9647 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
9648 @code{__ATOMIC_RELEASE}.
9649
9650 @end deftypefn
9651
9652 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
9653
9654 This built-in function acts as a synchronization fence between threads
9655 based on the specified memory order.
9656
9657 All memory orders are valid.
9658
9659 @end deftypefn
9660
9661 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
9662
9663 This built-in function acts as a synchronization fence between a thread
9664 and signal handlers based in the same thread.
9665
9666 All memory orders are valid.
9667
9668 @end deftypefn
9669
9670 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
9671
9672 This built-in function returns true if objects of @var{size} bytes always
9673 generate lock-free atomic instructions for the target architecture.
9674 @var{size} must resolve to a compile-time constant and the result also
9675 resolves to a compile-time constant.
9676
9677 @var{ptr} is an optional pointer to the object that may be used to determine
9678 alignment. A value of 0 indicates typical alignment should be used. The
9679 compiler may also ignore this parameter.
9680
9681 @smallexample
9682 if (__atomic_always_lock_free (sizeof (long long), 0))
9683 @end smallexample
9684
9685 @end deftypefn
9686
9687 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
9688
9689 This built-in function returns true if objects of @var{size} bytes always
9690 generate lock-free atomic instructions for the target architecture. If
9691 the built-in function is not known to be lock-free, a call is made to a
9692 runtime routine named @code{__atomic_is_lock_free}.
9693
9694 @var{ptr} is an optional pointer to the object that may be used to determine
9695 alignment. A value of 0 indicates typical alignment should be used. The
9696 compiler may also ignore this parameter.
9697 @end deftypefn
9698
9699 @node Integer Overflow Builtins
9700 @section Built-in Functions to Perform Arithmetic with Overflow Checking
9701
9702 The following built-in functions allow performing simple arithmetic operations
9703 together with checking whether the operations overflowed.
9704
9705 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9706 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
9707 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
9708 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res)
9709 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
9710 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9711 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9712
9713 These built-in functions promote the first two operands into infinite precision signed
9714 type and perform addition on those promoted operands. The result is then
9715 cast to the type the third pointer argument points to and stored there.
9716 If the stored result is equal to the infinite precision result, the built-in
9717 functions return false, otherwise they return true. As the addition is
9718 performed in infinite signed precision, these built-in functions have fully defined
9719 behavior for all argument values.
9720
9721 The first built-in function allows arbitrary integral types for operands and
9722 the result type must be pointer to some integer type, the rest of the built-in
9723 functions have explicit integer types.
9724
9725 The compiler will attempt to use hardware instructions to implement
9726 these built-in functions where possible, like conditional jump on overflow
9727 after addition, conditional jump on carry etc.
9728
9729 @end deftypefn
9730
9731 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9732 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
9733 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
9734 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res)
9735 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
9736 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9737 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9738
9739 These built-in functions are similar to the add overflow checking built-in
9740 functions above, except they perform subtraction, subtract the second argument
9741 from the first one, instead of addition.
9742
9743 @end deftypefn
9744
9745 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
9746 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
9747 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
9748 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res)
9749 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
9750 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
9751 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res)
9752
9753 These built-in functions are similar to the add overflow checking built-in
9754 functions above, except they perform multiplication, instead of addition.
9755
9756 @end deftypefn
9757
9758 @node x86 specific memory model extensions for transactional memory
9759 @section x86-Specific Memory Model Extensions for Transactional Memory
9760
9761 The x86 architecture supports additional memory ordering flags
9762 to mark lock critical sections for hardware lock elision.
9763 These must be specified in addition to an existing memory order to
9764 atomic intrinsics.
9765
9766 @table @code
9767 @item __ATOMIC_HLE_ACQUIRE
9768 Start lock elision on a lock variable.
9769 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
9770 @item __ATOMIC_HLE_RELEASE
9771 End lock elision on a lock variable.
9772 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
9773 @end table
9774
9775 When a lock acquire fails, it is required for good performance to abort
9776 the transaction quickly. This can be done with a @code{_mm_pause}.
9777
9778 @smallexample
9779 #include <immintrin.h> // For _mm_pause
9780
9781 int lockvar;
9782
9783 /* Acquire lock with lock elision */
9784 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
9785 _mm_pause(); /* Abort failed transaction */
9786 ...
9787 /* Free lock with lock elision */
9788 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
9789 @end smallexample
9790
9791 @node Object Size Checking
9792 @section Object Size Checking Built-in Functions
9793 @findex __builtin_object_size
9794 @findex __builtin___memcpy_chk
9795 @findex __builtin___mempcpy_chk
9796 @findex __builtin___memmove_chk
9797 @findex __builtin___memset_chk
9798 @findex __builtin___strcpy_chk
9799 @findex __builtin___stpcpy_chk
9800 @findex __builtin___strncpy_chk
9801 @findex __builtin___strcat_chk
9802 @findex __builtin___strncat_chk
9803 @findex __builtin___sprintf_chk
9804 @findex __builtin___snprintf_chk
9805 @findex __builtin___vsprintf_chk
9806 @findex __builtin___vsnprintf_chk
9807 @findex __builtin___printf_chk
9808 @findex __builtin___vprintf_chk
9809 @findex __builtin___fprintf_chk
9810 @findex __builtin___vfprintf_chk
9811
9812 GCC implements a limited buffer overflow protection mechanism
9813 that can prevent some buffer overflow attacks.
9814
9815 @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type})
9816 is a built-in construct that returns a constant number of bytes from
9817 @var{ptr} to the end of the object @var{ptr} pointer points to
9818 (if known at compile time). @code{__builtin_object_size} never evaluates
9819 its arguments for side-effects. If there are any side-effects in them, it
9820 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9821 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
9822 point to and all of them are known at compile time, the returned number
9823 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
9824 0 and minimum if nonzero. If it is not possible to determine which objects
9825 @var{ptr} points to at compile time, @code{__builtin_object_size} should
9826 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
9827 for @var{type} 2 or 3.
9828
9829 @var{type} is an integer constant from 0 to 3. If the least significant
9830 bit is clear, objects are whole variables, if it is set, a closest
9831 surrounding subobject is considered the object a pointer points to.
9832 The second bit determines if maximum or minimum of remaining bytes
9833 is computed.
9834
9835 @smallexample
9836 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
9837 char *p = &var.buf1[1], *q = &var.b;
9838
9839 /* Here the object p points to is var. */
9840 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
9841 /* The subobject p points to is var.buf1. */
9842 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
9843 /* The object q points to is var. */
9844 assert (__builtin_object_size (q, 0)
9845 == (char *) (&var + 1) - (char *) &var.b);
9846 /* The subobject q points to is var.b. */
9847 assert (__builtin_object_size (q, 1) == sizeof (var.b));
9848 @end smallexample
9849 @end deftypefn
9850
9851 There are built-in functions added for many common string operation
9852 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
9853 built-in is provided. This built-in has an additional last argument,
9854 which is the number of bytes remaining in object the @var{dest}
9855 argument points to or @code{(size_t) -1} if the size is not known.
9856
9857 The built-in functions are optimized into the normal string functions
9858 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
9859 it is known at compile time that the destination object will not
9860 be overflown. If the compiler can determine at compile time the
9861 object will be always overflown, it issues a warning.
9862
9863 The intended use can be e.g.@:
9864
9865 @smallexample
9866 #undef memcpy
9867 #define bos0(dest) __builtin_object_size (dest, 0)
9868 #define memcpy(dest, src, n) \
9869 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
9870
9871 char *volatile p;
9872 char buf[10];
9873 /* It is unknown what object p points to, so this is optimized
9874 into plain memcpy - no checking is possible. */
9875 memcpy (p, "abcde", n);
9876 /* Destination is known and length too. It is known at compile
9877 time there will be no overflow. */
9878 memcpy (&buf[5], "abcde", 5);
9879 /* Destination is known, but the length is not known at compile time.
9880 This will result in __memcpy_chk call that can check for overflow
9881 at run time. */
9882 memcpy (&buf[5], "abcde", n);
9883 /* Destination is known and it is known at compile time there will
9884 be overflow. There will be a warning and __memcpy_chk call that
9885 will abort the program at run time. */
9886 memcpy (&buf[6], "abcde", 5);
9887 @end smallexample
9888
9889 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
9890 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
9891 @code{strcat} and @code{strncat}.
9892
9893 There are also checking built-in functions for formatted output functions.
9894 @smallexample
9895 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
9896 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9897 const char *fmt, ...);
9898 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
9899 va_list ap);
9900 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
9901 const char *fmt, va_list ap);
9902 @end smallexample
9903
9904 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
9905 etc.@: functions and can contain implementation specific flags on what
9906 additional security measures the checking function might take, such as
9907 handling @code{%n} differently.
9908
9909 The @var{os} argument is the object size @var{s} points to, like in the
9910 other built-in functions. There is a small difference in the behavior
9911 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
9912 optimized into the non-checking functions only if @var{flag} is 0, otherwise
9913 the checking function is called with @var{os} argument set to
9914 @code{(size_t) -1}.
9915
9916 In addition to this, there are checking built-in functions
9917 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
9918 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
9919 These have just one additional argument, @var{flag}, right before
9920 format string @var{fmt}. If the compiler is able to optimize them to
9921 @code{fputc} etc.@: functions, it does, otherwise the checking function
9922 is called and the @var{flag} argument passed to it.
9923
9924 @node Pointer Bounds Checker builtins
9925 @section Pointer Bounds Checker Built-in Functions
9926 @cindex Pointer Bounds Checker builtins
9927 @findex __builtin___bnd_set_ptr_bounds
9928 @findex __builtin___bnd_narrow_ptr_bounds
9929 @findex __builtin___bnd_copy_ptr_bounds
9930 @findex __builtin___bnd_init_ptr_bounds
9931 @findex __builtin___bnd_null_ptr_bounds
9932 @findex __builtin___bnd_store_ptr_bounds
9933 @findex __builtin___bnd_chk_ptr_lbounds
9934 @findex __builtin___bnd_chk_ptr_ubounds
9935 @findex __builtin___bnd_chk_ptr_bounds
9936 @findex __builtin___bnd_get_ptr_lbound
9937 @findex __builtin___bnd_get_ptr_ubound
9938
9939 GCC provides a set of built-in functions to control Pointer Bounds Checker
9940 instrumentation. Note that all Pointer Bounds Checker builtins can be used
9941 even if you compile with Pointer Bounds Checker off
9942 (@option{-fno-check-pointer-bounds}).
9943 The behavior may differ in such case as documented below.
9944
9945 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
9946
9947 This built-in function returns a new pointer with the value of @var{q}, and
9948 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
9949 Bounds Checker off, the built-in function just returns the first argument.
9950
9951 @smallexample
9952 extern void *__wrap_malloc (size_t n)
9953 @{
9954 void *p = (void *)__real_malloc (n);
9955 if (!p) return __builtin___bnd_null_ptr_bounds (p);
9956 return __builtin___bnd_set_ptr_bounds (p, n);
9957 @}
9958 @end smallexample
9959
9960 @end deftypefn
9961
9962 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
9963
9964 This built-in function returns a new pointer with the value of @var{p}
9965 and associates it with the narrowed bounds formed by the intersection
9966 of bounds associated with @var{q} and the bounds
9967 [@var{p}, @var{p} + @var{size} - 1].
9968 With Pointer Bounds Checker off, the built-in function just returns the first
9969 argument.
9970
9971 @smallexample
9972 void init_objects (object *objs, size_t size)
9973 @{
9974 size_t i;
9975 /* Initialize objects one-by-one passing pointers with bounds of
9976 an object, not the full array of objects. */
9977 for (i = 0; i < size; i++)
9978 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
9979 sizeof(object)));
9980 @}
9981 @end smallexample
9982
9983 @end deftypefn
9984
9985 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
9986
9987 This built-in function returns a new pointer with the value of @var{q},
9988 and associates it with the bounds already associated with pointer @var{r}.
9989 With Pointer Bounds Checker off, the built-in function just returns the first
9990 argument.
9991
9992 @smallexample
9993 /* Here is a way to get pointer to object's field but
9994 still with the full object's bounds. */
9995 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
9996 objptr);
9997 @end smallexample
9998
9999 @end deftypefn
10000
10001 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10002
10003 This built-in function returns a new pointer with the value of @var{q}, and
10004 associates it with INIT (allowing full memory access) bounds. With Pointer
10005 Bounds Checker off, the built-in function just returns the first argument.
10006
10007 @end deftypefn
10008
10009 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10010
10011 This built-in function returns a new pointer with the value of @var{q}, and
10012 associates it with NULL (allowing no memory access) bounds. With Pointer
10013 Bounds Checker off, the built-in function just returns the first argument.
10014
10015 @end deftypefn
10016
10017 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10018
10019 This built-in function stores the bounds associated with pointer @var{ptr_val}
10020 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
10021 bounds from legacy code without touching the associated pointer's memory when
10022 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
10023 function call is ignored.
10024
10025 @end deftypefn
10026
10027 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10028
10029 This built-in function checks if the pointer @var{q} is within the lower
10030 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10031 function call is ignored.
10032
10033 @smallexample
10034 extern void *__wrap_memset (void *dst, int c, size_t len)
10035 @{
10036 if (len > 0)
10037 @{
10038 __builtin___bnd_chk_ptr_lbounds (dst);
10039 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10040 __real_memset (dst, c, len);
10041 @}
10042 return dst;
10043 @}
10044 @end smallexample
10045
10046 @end deftypefn
10047
10048 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10049
10050 This built-in function checks if the pointer @var{q} is within the upper
10051 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
10052 function call is ignored.
10053
10054 @end deftypefn
10055
10056 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10057
10058 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10059 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
10060 off, the built-in function call is ignored.
10061
10062 @smallexample
10063 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10064 @{
10065 if (n > 0)
10066 @{
10067 __bnd_chk_ptr_bounds (dst, n);
10068 __bnd_chk_ptr_bounds (src, n);
10069 __real_memcpy (dst, src, n);
10070 @}
10071 return dst;
10072 @}
10073 @end smallexample
10074
10075 @end deftypefn
10076
10077 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10078
10079 This built-in function returns the lower bound associated
10080 with the pointer @var{q}, as a pointer value.
10081 This is useful for debugging using @code{printf}.
10082 With Pointer Bounds Checker off, the built-in function returns 0.
10083
10084 @smallexample
10085 void *lb = __builtin___bnd_get_ptr_lbound (q);
10086 void *ub = __builtin___bnd_get_ptr_ubound (q);
10087 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
10088 @end smallexample
10089
10090 @end deftypefn
10091
10092 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10093
10094 This built-in function returns the upper bound (which is a pointer) associated
10095 with the pointer @var{q}. With Pointer Bounds Checker off,
10096 the built-in function returns -1.
10097
10098 @end deftypefn
10099
10100 @node Cilk Plus Builtins
10101 @section Cilk Plus C/C++ Language Extension Built-in Functions
10102
10103 GCC provides support for the following built-in reduction functions if Cilk Plus
10104 is enabled. Cilk Plus can be enabled using the @option{-fcilkplus} flag.
10105
10106 @itemize @bullet
10107 @item @code{__sec_implicit_index}
10108 @item @code{__sec_reduce}
10109 @item @code{__sec_reduce_add}
10110 @item @code{__sec_reduce_all_nonzero}
10111 @item @code{__sec_reduce_all_zero}
10112 @item @code{__sec_reduce_any_nonzero}
10113 @item @code{__sec_reduce_any_zero}
10114 @item @code{__sec_reduce_max}
10115 @item @code{__sec_reduce_min}
10116 @item @code{__sec_reduce_max_ind}
10117 @item @code{__sec_reduce_min_ind}
10118 @item @code{__sec_reduce_mul}
10119 @item @code{__sec_reduce_mutating}
10120 @end itemize
10121
10122 Further details and examples about these built-in functions are described
10123 in the Cilk Plus language manual which can be found at
10124 @uref{http://www.cilkplus.org}.
10125
10126 @node Other Builtins
10127 @section Other Built-in Functions Provided by GCC
10128 @cindex built-in functions
10129 @findex __builtin_call_with_static_chain
10130 @findex __builtin_fpclassify
10131 @findex __builtin_isfinite
10132 @findex __builtin_isnormal
10133 @findex __builtin_isgreater
10134 @findex __builtin_isgreaterequal
10135 @findex __builtin_isinf_sign
10136 @findex __builtin_isless
10137 @findex __builtin_islessequal
10138 @findex __builtin_islessgreater
10139 @findex __builtin_isunordered
10140 @findex __builtin_powi
10141 @findex __builtin_powif
10142 @findex __builtin_powil
10143 @findex _Exit
10144 @findex _exit
10145 @findex abort
10146 @findex abs
10147 @findex acos
10148 @findex acosf
10149 @findex acosh
10150 @findex acoshf
10151 @findex acoshl
10152 @findex acosl
10153 @findex alloca
10154 @findex asin
10155 @findex asinf
10156 @findex asinh
10157 @findex asinhf
10158 @findex asinhl
10159 @findex asinl
10160 @findex atan
10161 @findex atan2
10162 @findex atan2f
10163 @findex atan2l
10164 @findex atanf
10165 @findex atanh
10166 @findex atanhf
10167 @findex atanhl
10168 @findex atanl
10169 @findex bcmp
10170 @findex bzero
10171 @findex cabs
10172 @findex cabsf
10173 @findex cabsl
10174 @findex cacos
10175 @findex cacosf
10176 @findex cacosh
10177 @findex cacoshf
10178 @findex cacoshl
10179 @findex cacosl
10180 @findex calloc
10181 @findex carg
10182 @findex cargf
10183 @findex cargl
10184 @findex casin
10185 @findex casinf
10186 @findex casinh
10187 @findex casinhf
10188 @findex casinhl
10189 @findex casinl
10190 @findex catan
10191 @findex catanf
10192 @findex catanh
10193 @findex catanhf
10194 @findex catanhl
10195 @findex catanl
10196 @findex cbrt
10197 @findex cbrtf
10198 @findex cbrtl
10199 @findex ccos
10200 @findex ccosf
10201 @findex ccosh
10202 @findex ccoshf
10203 @findex ccoshl
10204 @findex ccosl
10205 @findex ceil
10206 @findex ceilf
10207 @findex ceill
10208 @findex cexp
10209 @findex cexpf
10210 @findex cexpl
10211 @findex cimag
10212 @findex cimagf
10213 @findex cimagl
10214 @findex clog
10215 @findex clogf
10216 @findex clogl
10217 @findex conj
10218 @findex conjf
10219 @findex conjl
10220 @findex copysign
10221 @findex copysignf
10222 @findex copysignl
10223 @findex cos
10224 @findex cosf
10225 @findex cosh
10226 @findex coshf
10227 @findex coshl
10228 @findex cosl
10229 @findex cpow
10230 @findex cpowf
10231 @findex cpowl
10232 @findex cproj
10233 @findex cprojf
10234 @findex cprojl
10235 @findex creal
10236 @findex crealf
10237 @findex creall
10238 @findex csin
10239 @findex csinf
10240 @findex csinh
10241 @findex csinhf
10242 @findex csinhl
10243 @findex csinl
10244 @findex csqrt
10245 @findex csqrtf
10246 @findex csqrtl
10247 @findex ctan
10248 @findex ctanf
10249 @findex ctanh
10250 @findex ctanhf
10251 @findex ctanhl
10252 @findex ctanl
10253 @findex dcgettext
10254 @findex dgettext
10255 @findex drem
10256 @findex dremf
10257 @findex dreml
10258 @findex erf
10259 @findex erfc
10260 @findex erfcf
10261 @findex erfcl
10262 @findex erff
10263 @findex erfl
10264 @findex exit
10265 @findex exp
10266 @findex exp10
10267 @findex exp10f
10268 @findex exp10l
10269 @findex exp2
10270 @findex exp2f
10271 @findex exp2l
10272 @findex expf
10273 @findex expl
10274 @findex expm1
10275 @findex expm1f
10276 @findex expm1l
10277 @findex fabs
10278 @findex fabsf
10279 @findex fabsl
10280 @findex fdim
10281 @findex fdimf
10282 @findex fdiml
10283 @findex ffs
10284 @findex floor
10285 @findex floorf
10286 @findex floorl
10287 @findex fma
10288 @findex fmaf
10289 @findex fmal
10290 @findex fmax
10291 @findex fmaxf
10292 @findex fmaxl
10293 @findex fmin
10294 @findex fminf
10295 @findex fminl
10296 @findex fmod
10297 @findex fmodf
10298 @findex fmodl
10299 @findex fprintf
10300 @findex fprintf_unlocked
10301 @findex fputs
10302 @findex fputs_unlocked
10303 @findex frexp
10304 @findex frexpf
10305 @findex frexpl
10306 @findex fscanf
10307 @findex gamma
10308 @findex gammaf
10309 @findex gammal
10310 @findex gamma_r
10311 @findex gammaf_r
10312 @findex gammal_r
10313 @findex gettext
10314 @findex hypot
10315 @findex hypotf
10316 @findex hypotl
10317 @findex ilogb
10318 @findex ilogbf
10319 @findex ilogbl
10320 @findex imaxabs
10321 @findex index
10322 @findex isalnum
10323 @findex isalpha
10324 @findex isascii
10325 @findex isblank
10326 @findex iscntrl
10327 @findex isdigit
10328 @findex isgraph
10329 @findex islower
10330 @findex isprint
10331 @findex ispunct
10332 @findex isspace
10333 @findex isupper
10334 @findex iswalnum
10335 @findex iswalpha
10336 @findex iswblank
10337 @findex iswcntrl
10338 @findex iswdigit
10339 @findex iswgraph
10340 @findex iswlower
10341 @findex iswprint
10342 @findex iswpunct
10343 @findex iswspace
10344 @findex iswupper
10345 @findex iswxdigit
10346 @findex isxdigit
10347 @findex j0
10348 @findex j0f
10349 @findex j0l
10350 @findex j1
10351 @findex j1f
10352 @findex j1l
10353 @findex jn
10354 @findex jnf
10355 @findex jnl
10356 @findex labs
10357 @findex ldexp
10358 @findex ldexpf
10359 @findex ldexpl
10360 @findex lgamma
10361 @findex lgammaf
10362 @findex lgammal
10363 @findex lgamma_r
10364 @findex lgammaf_r
10365 @findex lgammal_r
10366 @findex llabs
10367 @findex llrint
10368 @findex llrintf
10369 @findex llrintl
10370 @findex llround
10371 @findex llroundf
10372 @findex llroundl
10373 @findex log
10374 @findex log10
10375 @findex log10f
10376 @findex log10l
10377 @findex log1p
10378 @findex log1pf
10379 @findex log1pl
10380 @findex log2
10381 @findex log2f
10382 @findex log2l
10383 @findex logb
10384 @findex logbf
10385 @findex logbl
10386 @findex logf
10387 @findex logl
10388 @findex lrint
10389 @findex lrintf
10390 @findex lrintl
10391 @findex lround
10392 @findex lroundf
10393 @findex lroundl
10394 @findex malloc
10395 @findex memchr
10396 @findex memcmp
10397 @findex memcpy
10398 @findex mempcpy
10399 @findex memset
10400 @findex modf
10401 @findex modff
10402 @findex modfl
10403 @findex nearbyint
10404 @findex nearbyintf
10405 @findex nearbyintl
10406 @findex nextafter
10407 @findex nextafterf
10408 @findex nextafterl
10409 @findex nexttoward
10410 @findex nexttowardf
10411 @findex nexttowardl
10412 @findex pow
10413 @findex pow10
10414 @findex pow10f
10415 @findex pow10l
10416 @findex powf
10417 @findex powl
10418 @findex printf
10419 @findex printf_unlocked
10420 @findex putchar
10421 @findex puts
10422 @findex remainder
10423 @findex remainderf
10424 @findex remainderl
10425 @findex remquo
10426 @findex remquof
10427 @findex remquol
10428 @findex rindex
10429 @findex rint
10430 @findex rintf
10431 @findex rintl
10432 @findex round
10433 @findex roundf
10434 @findex roundl
10435 @findex scalb
10436 @findex scalbf
10437 @findex scalbl
10438 @findex scalbln
10439 @findex scalblnf
10440 @findex scalblnf
10441 @findex scalbn
10442 @findex scalbnf
10443 @findex scanfnl
10444 @findex signbit
10445 @findex signbitf
10446 @findex signbitl
10447 @findex signbitd32
10448 @findex signbitd64
10449 @findex signbitd128
10450 @findex significand
10451 @findex significandf
10452 @findex significandl
10453 @findex sin
10454 @findex sincos
10455 @findex sincosf
10456 @findex sincosl
10457 @findex sinf
10458 @findex sinh
10459 @findex sinhf
10460 @findex sinhl
10461 @findex sinl
10462 @findex snprintf
10463 @findex sprintf
10464 @findex sqrt
10465 @findex sqrtf
10466 @findex sqrtl
10467 @findex sscanf
10468 @findex stpcpy
10469 @findex stpncpy
10470 @findex strcasecmp
10471 @findex strcat
10472 @findex strchr
10473 @findex strcmp
10474 @findex strcpy
10475 @findex strcspn
10476 @findex strdup
10477 @findex strfmon
10478 @findex strftime
10479 @findex strlen
10480 @findex strncasecmp
10481 @findex strncat
10482 @findex strncmp
10483 @findex strncpy
10484 @findex strndup
10485 @findex strpbrk
10486 @findex strrchr
10487 @findex strspn
10488 @findex strstr
10489 @findex tan
10490 @findex tanf
10491 @findex tanh
10492 @findex tanhf
10493 @findex tanhl
10494 @findex tanl
10495 @findex tgamma
10496 @findex tgammaf
10497 @findex tgammal
10498 @findex toascii
10499 @findex tolower
10500 @findex toupper
10501 @findex towlower
10502 @findex towupper
10503 @findex trunc
10504 @findex truncf
10505 @findex truncl
10506 @findex vfprintf
10507 @findex vfscanf
10508 @findex vprintf
10509 @findex vscanf
10510 @findex vsnprintf
10511 @findex vsprintf
10512 @findex vsscanf
10513 @findex y0
10514 @findex y0f
10515 @findex y0l
10516 @findex y1
10517 @findex y1f
10518 @findex y1l
10519 @findex yn
10520 @findex ynf
10521 @findex ynl
10522
10523 GCC provides a large number of built-in functions other than the ones
10524 mentioned above. Some of these are for internal use in the processing
10525 of exceptions or variable-length argument lists and are not
10526 documented here because they may change from time to time; we do not
10527 recommend general use of these functions.
10528
10529 The remaining functions are provided for optimization purposes.
10530
10531 With the exception of built-ins that have library equivalents such as
10532 the standard C library functions discussed below, or that expand to
10533 library calls, GCC built-in functions are always expanded inline and
10534 thus do not have corresponding entry points and their address cannot
10535 be obtained. Attempting to use them in an expression other than
10536 a function call results in a compile-time error.
10537
10538 @opindex fno-builtin
10539 GCC includes built-in versions of many of the functions in the standard
10540 C library. These functions come in two forms: one whose names start with
10541 the @code{__builtin_} prefix, and the other without. Both forms have the
10542 same type (including prototype), the same address (when their address is
10543 taken), and the same meaning as the C library functions even if you specify
10544 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
10545 functions are only optimized in certain cases; if they are not optimized in
10546 a particular case, a call to the library function is emitted.
10547
10548 @opindex ansi
10549 @opindex std
10550 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
10551 @option{-std=c99} or @option{-std=c11}), the functions
10552 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
10553 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
10554 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
10555 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
10556 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
10557 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
10558 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
10559 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
10560 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
10561 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
10562 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
10563 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
10564 @code{signbitd64}, @code{signbitd128}, @code{significandf},
10565 @code{significandl}, @code{significand}, @code{sincosf},
10566 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
10567 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
10568 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
10569 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
10570 @code{yn}
10571 may be handled as built-in functions.
10572 All these functions have corresponding versions
10573 prefixed with @code{__builtin_}, which may be used even in strict C90
10574 mode.
10575
10576 The ISO C99 functions
10577 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
10578 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
10579 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
10580 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
10581 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
10582 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
10583 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
10584 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
10585 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
10586 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
10587 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
10588 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
10589 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
10590 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
10591 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
10592 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
10593 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
10594 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
10595 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
10596 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
10597 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
10598 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
10599 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
10600 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
10601 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
10602 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
10603 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
10604 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
10605 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
10606 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
10607 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
10608 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
10609 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
10610 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
10611 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
10612 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
10613 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
10614 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
10615 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
10616 are handled as built-in functions
10617 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10618
10619 There are also built-in versions of the ISO C99 functions
10620 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
10621 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
10622 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
10623 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
10624 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
10625 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
10626 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
10627 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
10628 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
10629 that are recognized in any mode since ISO C90 reserves these names for
10630 the purpose to which ISO C99 puts them. All these functions have
10631 corresponding versions prefixed with @code{__builtin_}.
10632
10633 The ISO C94 functions
10634 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
10635 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
10636 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
10637 @code{towupper}
10638 are handled as built-in functions
10639 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
10640
10641 The ISO C90 functions
10642 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
10643 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
10644 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
10645 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
10646 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
10647 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
10648 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
10649 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
10650 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
10651 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
10652 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
10653 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
10654 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
10655 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
10656 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
10657 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
10658 are all recognized as built-in functions unless
10659 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
10660 is specified for an individual function). All of these functions have
10661 corresponding versions prefixed with @code{__builtin_}.
10662
10663 GCC provides built-in versions of the ISO C99 floating-point comparison
10664 macros that avoid raising exceptions for unordered operands. They have
10665 the same names as the standard macros ( @code{isgreater},
10666 @code{isgreaterequal}, @code{isless}, @code{islessequal},
10667 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
10668 prefixed. We intend for a library implementor to be able to simply
10669 @code{#define} each standard macro to its built-in equivalent.
10670 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
10671 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
10672 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
10673 built-in functions appear both with and without the @code{__builtin_} prefix.
10674
10675 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
10676
10677 You can use the built-in function @code{__builtin_types_compatible_p} to
10678 determine whether two types are the same.
10679
10680 This built-in function returns 1 if the unqualified versions of the
10681 types @var{type1} and @var{type2} (which are types, not expressions) are
10682 compatible, 0 otherwise. The result of this built-in function can be
10683 used in integer constant expressions.
10684
10685 This built-in function ignores top level qualifiers (e.g., @code{const},
10686 @code{volatile}). For example, @code{int} is equivalent to @code{const
10687 int}.
10688
10689 The type @code{int[]} and @code{int[5]} are compatible. On the other
10690 hand, @code{int} and @code{char *} are not compatible, even if the size
10691 of their types, on the particular architecture are the same. Also, the
10692 amount of pointer indirection is taken into account when determining
10693 similarity. Consequently, @code{short *} is not similar to
10694 @code{short **}. Furthermore, two types that are typedefed are
10695 considered compatible if their underlying types are compatible.
10696
10697 An @code{enum} type is not considered to be compatible with another
10698 @code{enum} type even if both are compatible with the same integer
10699 type; this is what the C standard specifies.
10700 For example, @code{enum @{foo, bar@}} is not similar to
10701 @code{enum @{hot, dog@}}.
10702
10703 You typically use this function in code whose execution varies
10704 depending on the arguments' types. For example:
10705
10706 @smallexample
10707 #define foo(x) \
10708 (@{ \
10709 typeof (x) tmp = (x); \
10710 if (__builtin_types_compatible_p (typeof (x), long double)) \
10711 tmp = foo_long_double (tmp); \
10712 else if (__builtin_types_compatible_p (typeof (x), double)) \
10713 tmp = foo_double (tmp); \
10714 else if (__builtin_types_compatible_p (typeof (x), float)) \
10715 tmp = foo_float (tmp); \
10716 else \
10717 abort (); \
10718 tmp; \
10719 @})
10720 @end smallexample
10721
10722 @emph{Note:} This construct is only available for C@.
10723
10724 @end deftypefn
10725
10726 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
10727
10728 The @var{call_exp} expression must be a function call, and the
10729 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
10730 is passed to the function call in the target's static chain location.
10731 The result of builtin is the result of the function call.
10732
10733 @emph{Note:} This builtin is only available for C@.
10734 This builtin can be used to call Go closures from C.
10735
10736 @end deftypefn
10737
10738 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
10739
10740 You can use the built-in function @code{__builtin_choose_expr} to
10741 evaluate code depending on the value of a constant expression. This
10742 built-in function returns @var{exp1} if @var{const_exp}, which is an
10743 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
10744
10745 This built-in function is analogous to the @samp{? :} operator in C,
10746 except that the expression returned has its type unaltered by promotion
10747 rules. Also, the built-in function does not evaluate the expression
10748 that is not chosen. For example, if @var{const_exp} evaluates to true,
10749 @var{exp2} is not evaluated even if it has side-effects.
10750
10751 This built-in function can return an lvalue if the chosen argument is an
10752 lvalue.
10753
10754 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
10755 type. Similarly, if @var{exp2} is returned, its return type is the same
10756 as @var{exp2}.
10757
10758 Example:
10759
10760 @smallexample
10761 #define foo(x) \
10762 __builtin_choose_expr ( \
10763 __builtin_types_compatible_p (typeof (x), double), \
10764 foo_double (x), \
10765 __builtin_choose_expr ( \
10766 __builtin_types_compatible_p (typeof (x), float), \
10767 foo_float (x), \
10768 /* @r{The void expression results in a compile-time error} \
10769 @r{when assigning the result to something.} */ \
10770 (void)0))
10771 @end smallexample
10772
10773 @emph{Note:} This construct is only available for C@. Furthermore, the
10774 unused expression (@var{exp1} or @var{exp2} depending on the value of
10775 @var{const_exp}) may still generate syntax errors. This may change in
10776 future revisions.
10777
10778 @end deftypefn
10779
10780 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
10781
10782 The built-in function @code{__builtin_complex} is provided for use in
10783 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
10784 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
10785 real binary floating-point type, and the result has the corresponding
10786 complex type with real and imaginary parts @var{real} and @var{imag}.
10787 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
10788 infinities, NaNs and negative zeros are involved.
10789
10790 @end deftypefn
10791
10792 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
10793 You can use the built-in function @code{__builtin_constant_p} to
10794 determine if a value is known to be constant at compile time and hence
10795 that GCC can perform constant-folding on expressions involving that
10796 value. The argument of the function is the value to test. The function
10797 returns the integer 1 if the argument is known to be a compile-time
10798 constant and 0 if it is not known to be a compile-time constant. A
10799 return of 0 does not indicate that the value is @emph{not} a constant,
10800 but merely that GCC cannot prove it is a constant with the specified
10801 value of the @option{-O} option.
10802
10803 You typically use this function in an embedded application where
10804 memory is a critical resource. If you have some complex calculation,
10805 you may want it to be folded if it involves constants, but need to call
10806 a function if it does not. For example:
10807
10808 @smallexample
10809 #define Scale_Value(X) \
10810 (__builtin_constant_p (X) \
10811 ? ((X) * SCALE + OFFSET) : Scale (X))
10812 @end smallexample
10813
10814 You may use this built-in function in either a macro or an inline
10815 function. However, if you use it in an inlined function and pass an
10816 argument of the function as the argument to the built-in, GCC
10817 never returns 1 when you call the inline function with a string constant
10818 or compound literal (@pxref{Compound Literals}) and does not return 1
10819 when you pass a constant numeric value to the inline function unless you
10820 specify the @option{-O} option.
10821
10822 You may also use @code{__builtin_constant_p} in initializers for static
10823 data. For instance, you can write
10824
10825 @smallexample
10826 static const int table[] = @{
10827 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
10828 /* @r{@dots{}} */
10829 @};
10830 @end smallexample
10831
10832 @noindent
10833 This is an acceptable initializer even if @var{EXPRESSION} is not a
10834 constant expression, including the case where
10835 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
10836 folded to a constant but @var{EXPRESSION} contains operands that are
10837 not otherwise permitted in a static initializer (for example,
10838 @code{0 && foo ()}). GCC must be more conservative about evaluating the
10839 built-in in this case, because it has no opportunity to perform
10840 optimization.
10841 @end deftypefn
10842
10843 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
10844 @opindex fprofile-arcs
10845 You may use @code{__builtin_expect} to provide the compiler with
10846 branch prediction information. In general, you should prefer to
10847 use actual profile feedback for this (@option{-fprofile-arcs}), as
10848 programmers are notoriously bad at predicting how their programs
10849 actually perform. However, there are applications in which this
10850 data is hard to collect.
10851
10852 The return value is the value of @var{exp}, which should be an integral
10853 expression. The semantics of the built-in are that it is expected that
10854 @var{exp} == @var{c}. For example:
10855
10856 @smallexample
10857 if (__builtin_expect (x, 0))
10858 foo ();
10859 @end smallexample
10860
10861 @noindent
10862 indicates that we do not expect to call @code{foo}, since
10863 we expect @code{x} to be zero. Since you are limited to integral
10864 expressions for @var{exp}, you should use constructions such as
10865
10866 @smallexample
10867 if (__builtin_expect (ptr != NULL, 1))
10868 foo (*ptr);
10869 @end smallexample
10870
10871 @noindent
10872 when testing pointer or floating-point values.
10873 @end deftypefn
10874
10875 @deftypefn {Built-in Function} void __builtin_trap (void)
10876 This function causes the program to exit abnormally. GCC implements
10877 this function by using a target-dependent mechanism (such as
10878 intentionally executing an illegal instruction) or by calling
10879 @code{abort}. The mechanism used may vary from release to release so
10880 you should not rely on any particular implementation.
10881 @end deftypefn
10882
10883 @deftypefn {Built-in Function} void __builtin_unreachable (void)
10884 If control flow reaches the point of the @code{__builtin_unreachable},
10885 the program is undefined. It is useful in situations where the
10886 compiler cannot deduce the unreachability of the code.
10887
10888 One such case is immediately following an @code{asm} statement that
10889 either never terminates, or one that transfers control elsewhere
10890 and never returns. In this example, without the
10891 @code{__builtin_unreachable}, GCC issues a warning that control
10892 reaches the end of a non-void function. It also generates code
10893 to return after the @code{asm}.
10894
10895 @smallexample
10896 int f (int c, int v)
10897 @{
10898 if (c)
10899 @{
10900 return v;
10901 @}
10902 else
10903 @{
10904 asm("jmp error_handler");
10905 __builtin_unreachable ();
10906 @}
10907 @}
10908 @end smallexample
10909
10910 @noindent
10911 Because the @code{asm} statement unconditionally transfers control out
10912 of the function, control never reaches the end of the function
10913 body. The @code{__builtin_unreachable} is in fact unreachable and
10914 communicates this fact to the compiler.
10915
10916 Another use for @code{__builtin_unreachable} is following a call a
10917 function that never returns but that is not declared
10918 @code{__attribute__((noreturn))}, as in this example:
10919
10920 @smallexample
10921 void function_that_never_returns (void);
10922
10923 int g (int c)
10924 @{
10925 if (c)
10926 @{
10927 return 1;
10928 @}
10929 else
10930 @{
10931 function_that_never_returns ();
10932 __builtin_unreachable ();
10933 @}
10934 @}
10935 @end smallexample
10936
10937 @end deftypefn
10938
10939 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
10940 This function returns its first argument, and allows the compiler
10941 to assume that the returned pointer is at least @var{align} bytes
10942 aligned. This built-in can have either two or three arguments,
10943 if it has three, the third argument should have integer type, and
10944 if it is nonzero means misalignment offset. For example:
10945
10946 @smallexample
10947 void *x = __builtin_assume_aligned (arg, 16);
10948 @end smallexample
10949
10950 @noindent
10951 means that the compiler can assume @code{x}, set to @code{arg}, is at least
10952 16-byte aligned, while:
10953
10954 @smallexample
10955 void *x = __builtin_assume_aligned (arg, 32, 8);
10956 @end smallexample
10957
10958 @noindent
10959 means that the compiler can assume for @code{x}, set to @code{arg}, that
10960 @code{(char *) x - 8} is 32-byte aligned.
10961 @end deftypefn
10962
10963 @deftypefn {Built-in Function} int __builtin_LINE ()
10964 This function is the equivalent to the preprocessor @code{__LINE__}
10965 macro and returns the line number of the invocation of the built-in.
10966 In a C++ default argument for a function @var{F}, it gets the line number of
10967 the call to @var{F}.
10968 @end deftypefn
10969
10970 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
10971 This function is the equivalent to the preprocessor @code{__FUNCTION__}
10972 macro and returns the function name the invocation of the built-in is in.
10973 @end deftypefn
10974
10975 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
10976 This function is the equivalent to the preprocessor @code{__FILE__}
10977 macro and returns the file name the invocation of the built-in is in.
10978 In a C++ default argument for a function @var{F}, it gets the file name of
10979 the call to @var{F}.
10980 @end deftypefn
10981
10982 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
10983 This function is used to flush the processor's instruction cache for
10984 the region of memory between @var{begin} inclusive and @var{end}
10985 exclusive. Some targets require that the instruction cache be
10986 flushed, after modifying memory containing code, in order to obtain
10987 deterministic behavior.
10988
10989 If the target does not require instruction cache flushes,
10990 @code{__builtin___clear_cache} has no effect. Otherwise either
10991 instructions are emitted in-line to clear the instruction cache or a
10992 call to the @code{__clear_cache} function in libgcc is made.
10993 @end deftypefn
10994
10995 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
10996 This function is used to minimize cache-miss latency by moving data into
10997 a cache before it is accessed.
10998 You can insert calls to @code{__builtin_prefetch} into code for which
10999 you know addresses of data in memory that is likely to be accessed soon.
11000 If the target supports them, data prefetch instructions are generated.
11001 If the prefetch is done early enough before the access then the data will
11002 be in the cache by the time it is accessed.
11003
11004 The value of @var{addr} is the address of the memory to prefetch.
11005 There are two optional arguments, @var{rw} and @var{locality}.
11006 The value of @var{rw} is a compile-time constant one or zero; one
11007 means that the prefetch is preparing for a write to the memory address
11008 and zero, the default, means that the prefetch is preparing for a read.
11009 The value @var{locality} must be a compile-time constant integer between
11010 zero and three. A value of zero means that the data has no temporal
11011 locality, so it need not be left in the cache after the access. A value
11012 of three means that the data has a high degree of temporal locality and
11013 should be left in all levels of cache possible. Values of one and two
11014 mean, respectively, a low or moderate degree of temporal locality. The
11015 default is three.
11016
11017 @smallexample
11018 for (i = 0; i < n; i++)
11019 @{
11020 a[i] = a[i] + b[i];
11021 __builtin_prefetch (&a[i+j], 1, 1);
11022 __builtin_prefetch (&b[i+j], 0, 1);
11023 /* @r{@dots{}} */
11024 @}
11025 @end smallexample
11026
11027 Data prefetch does not generate faults if @var{addr} is invalid, but
11028 the address expression itself must be valid. For example, a prefetch
11029 of @code{p->next} does not fault if @code{p->next} is not a valid
11030 address, but evaluation faults if @code{p} is not a valid address.
11031
11032 If the target does not support data prefetch, the address expression
11033 is evaluated if it includes side effects but no other code is generated
11034 and GCC does not issue a warning.
11035 @end deftypefn
11036
11037 @deftypefn {Built-in Function} double __builtin_huge_val (void)
11038 Returns a positive infinity, if supported by the floating-point format,
11039 else @code{DBL_MAX}. This function is suitable for implementing the
11040 ISO C macro @code{HUGE_VAL}.
11041 @end deftypefn
11042
11043 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
11044 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
11045 @end deftypefn
11046
11047 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
11048 Similar to @code{__builtin_huge_val}, except the return
11049 type is @code{long double}.
11050 @end deftypefn
11051
11052 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
11053 This built-in implements the C99 fpclassify functionality. The first
11054 five int arguments should be the target library's notion of the
11055 possible FP classes and are used for return values. They must be
11056 constant values and they must appear in this order: @code{FP_NAN},
11057 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
11058 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
11059 to classify. GCC treats the last argument as type-generic, which
11060 means it does not do default promotion from float to double.
11061 @end deftypefn
11062
11063 @deftypefn {Built-in Function} double __builtin_inf (void)
11064 Similar to @code{__builtin_huge_val}, except a warning is generated
11065 if the target floating-point format does not support infinities.
11066 @end deftypefn
11067
11068 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
11069 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
11070 @end deftypefn
11071
11072 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
11073 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
11074 @end deftypefn
11075
11076 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
11077 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
11078 @end deftypefn
11079
11080 @deftypefn {Built-in Function} float __builtin_inff (void)
11081 Similar to @code{__builtin_inf}, except the return type is @code{float}.
11082 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
11083 @end deftypefn
11084
11085 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
11086 Similar to @code{__builtin_inf}, except the return
11087 type is @code{long double}.
11088 @end deftypefn
11089
11090 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
11091 Similar to @code{isinf}, except the return value is -1 for
11092 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
11093 Note while the parameter list is an
11094 ellipsis, this function only accepts exactly one floating-point
11095 argument. GCC treats this parameter as type-generic, which means it
11096 does not do default promotion from float to double.
11097 @end deftypefn
11098
11099 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
11100 This is an implementation of the ISO C99 function @code{nan}.
11101
11102 Since ISO C99 defines this function in terms of @code{strtod}, which we
11103 do not implement, a description of the parsing is in order. The string
11104 is parsed as by @code{strtol}; that is, the base is recognized by
11105 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
11106 in the significand such that the least significant bit of the number
11107 is at the least significant bit of the significand. The number is
11108 truncated to fit the significand field provided. The significand is
11109 forced to be a quiet NaN@.
11110
11111 This function, if given a string literal all of which would have been
11112 consumed by @code{strtol}, is evaluated early enough that it is considered a
11113 compile-time constant.
11114 @end deftypefn
11115
11116 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
11117 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
11118 @end deftypefn
11119
11120 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
11121 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
11122 @end deftypefn
11123
11124 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
11125 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
11126 @end deftypefn
11127
11128 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
11129 Similar to @code{__builtin_nan}, except the return type is @code{float}.
11130 @end deftypefn
11131
11132 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
11133 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
11134 @end deftypefn
11135
11136 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
11137 Similar to @code{__builtin_nan}, except the significand is forced
11138 to be a signaling NaN@. The @code{nans} function is proposed by
11139 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
11140 @end deftypefn
11141
11142 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
11143 Similar to @code{__builtin_nans}, except the return type is @code{float}.
11144 @end deftypefn
11145
11146 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
11147 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
11148 @end deftypefn
11149
11150 @deftypefn {Built-in Function} int __builtin_ffs (int x)
11151 Returns one plus the index of the least significant 1-bit of @var{x}, or
11152 if @var{x} is zero, returns zero.
11153 @end deftypefn
11154
11155 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
11156 Returns the number of leading 0-bits in @var{x}, starting at the most
11157 significant bit position. If @var{x} is 0, the result is undefined.
11158 @end deftypefn
11159
11160 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
11161 Returns the number of trailing 0-bits in @var{x}, starting at the least
11162 significant bit position. If @var{x} is 0, the result is undefined.
11163 @end deftypefn
11164
11165 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
11166 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
11167 number of bits following the most significant bit that are identical
11168 to it. There are no special cases for 0 or other values.
11169 @end deftypefn
11170
11171 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
11172 Returns the number of 1-bits in @var{x}.
11173 @end deftypefn
11174
11175 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
11176 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
11177 modulo 2.
11178 @end deftypefn
11179
11180 @deftypefn {Built-in Function} int __builtin_ffsl (long)
11181 Similar to @code{__builtin_ffs}, except the argument type is
11182 @code{long}.
11183 @end deftypefn
11184
11185 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
11186 Similar to @code{__builtin_clz}, except the argument type is
11187 @code{unsigned long}.
11188 @end deftypefn
11189
11190 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
11191 Similar to @code{__builtin_ctz}, except the argument type is
11192 @code{unsigned long}.
11193 @end deftypefn
11194
11195 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
11196 Similar to @code{__builtin_clrsb}, except the argument type is
11197 @code{long}.
11198 @end deftypefn
11199
11200 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
11201 Similar to @code{__builtin_popcount}, except the argument type is
11202 @code{unsigned long}.
11203 @end deftypefn
11204
11205 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
11206 Similar to @code{__builtin_parity}, except the argument type is
11207 @code{unsigned long}.
11208 @end deftypefn
11209
11210 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
11211 Similar to @code{__builtin_ffs}, except the argument type is
11212 @code{long long}.
11213 @end deftypefn
11214
11215 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
11216 Similar to @code{__builtin_clz}, except the argument type is
11217 @code{unsigned long long}.
11218 @end deftypefn
11219
11220 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
11221 Similar to @code{__builtin_ctz}, except the argument type is
11222 @code{unsigned long long}.
11223 @end deftypefn
11224
11225 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
11226 Similar to @code{__builtin_clrsb}, except the argument type is
11227 @code{long long}.
11228 @end deftypefn
11229
11230 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
11231 Similar to @code{__builtin_popcount}, except the argument type is
11232 @code{unsigned long long}.
11233 @end deftypefn
11234
11235 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
11236 Similar to @code{__builtin_parity}, except the argument type is
11237 @code{unsigned long long}.
11238 @end deftypefn
11239
11240 @deftypefn {Built-in Function} double __builtin_powi (double, int)
11241 Returns the first argument raised to the power of the second. Unlike the
11242 @code{pow} function no guarantees about precision and rounding are made.
11243 @end deftypefn
11244
11245 @deftypefn {Built-in Function} float __builtin_powif (float, int)
11246 Similar to @code{__builtin_powi}, except the argument and return types
11247 are @code{float}.
11248 @end deftypefn
11249
11250 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
11251 Similar to @code{__builtin_powi}, except the argument and return types
11252 are @code{long double}.
11253 @end deftypefn
11254
11255 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
11256 Returns @var{x} with the order of the bytes reversed; for example,
11257 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
11258 exactly 8 bits.
11259 @end deftypefn
11260
11261 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
11262 Similar to @code{__builtin_bswap16}, except the argument and return types
11263 are 32 bit.
11264 @end deftypefn
11265
11266 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
11267 Similar to @code{__builtin_bswap32}, except the argument and return types
11268 are 64 bit.
11269 @end deftypefn
11270
11271 @node Target Builtins
11272 @section Built-in Functions Specific to Particular Target Machines
11273
11274 On some target machines, GCC supports many built-in functions specific
11275 to those machines. Generally these generate calls to specific machine
11276 instructions, but allow the compiler to schedule those calls.
11277
11278 @menu
11279 * AArch64 Built-in Functions::
11280 * Alpha Built-in Functions::
11281 * Altera Nios II Built-in Functions::
11282 * ARC Built-in Functions::
11283 * ARC SIMD Built-in Functions::
11284 * ARM iWMMXt Built-in Functions::
11285 * ARM C Language Extensions (ACLE)::
11286 * ARM Floating Point Status and Control Intrinsics::
11287 * AVR Built-in Functions::
11288 * Blackfin Built-in Functions::
11289 * FR-V Built-in Functions::
11290 * MIPS DSP Built-in Functions::
11291 * MIPS Paired-Single Support::
11292 * MIPS Loongson Built-in Functions::
11293 * Other MIPS Built-in Functions::
11294 * MSP430 Built-in Functions::
11295 * NDS32 Built-in Functions::
11296 * picoChip Built-in Functions::
11297 * PowerPC Built-in Functions::
11298 * PowerPC AltiVec/VSX Built-in Functions::
11299 * PowerPC Hardware Transactional Memory Built-in Functions::
11300 * RX Built-in Functions::
11301 * S/390 System z Built-in Functions::
11302 * SH Built-in Functions::
11303 * SPARC VIS Built-in Functions::
11304 * SPU Built-in Functions::
11305 * TI C6X Built-in Functions::
11306 * TILE-Gx Built-in Functions::
11307 * TILEPro Built-in Functions::
11308 * x86 Built-in Functions::
11309 * x86 transactional memory intrinsics::
11310 @end menu
11311
11312 @node AArch64 Built-in Functions
11313 @subsection AArch64 Built-in Functions
11314
11315 These built-in functions are available for the AArch64 family of
11316 processors.
11317 @smallexample
11318 unsigned int __builtin_aarch64_get_fpcr ()
11319 void __builtin_aarch64_set_fpcr (unsigned int)
11320 unsigned int __builtin_aarch64_get_fpsr ()
11321 void __builtin_aarch64_set_fpsr (unsigned int)
11322 @end smallexample
11323
11324 @node Alpha Built-in Functions
11325 @subsection Alpha Built-in Functions
11326
11327 These built-in functions are available for the Alpha family of
11328 processors, depending on the command-line switches used.
11329
11330 The following built-in functions are always available. They
11331 all generate the machine instruction that is part of the name.
11332
11333 @smallexample
11334 long __builtin_alpha_implver (void)
11335 long __builtin_alpha_rpcc (void)
11336 long __builtin_alpha_amask (long)
11337 long __builtin_alpha_cmpbge (long, long)
11338 long __builtin_alpha_extbl (long, long)
11339 long __builtin_alpha_extwl (long, long)
11340 long __builtin_alpha_extll (long, long)
11341 long __builtin_alpha_extql (long, long)
11342 long __builtin_alpha_extwh (long, long)
11343 long __builtin_alpha_extlh (long, long)
11344 long __builtin_alpha_extqh (long, long)
11345 long __builtin_alpha_insbl (long, long)
11346 long __builtin_alpha_inswl (long, long)
11347 long __builtin_alpha_insll (long, long)
11348 long __builtin_alpha_insql (long, long)
11349 long __builtin_alpha_inswh (long, long)
11350 long __builtin_alpha_inslh (long, long)
11351 long __builtin_alpha_insqh (long, long)
11352 long __builtin_alpha_mskbl (long, long)
11353 long __builtin_alpha_mskwl (long, long)
11354 long __builtin_alpha_mskll (long, long)
11355 long __builtin_alpha_mskql (long, long)
11356 long __builtin_alpha_mskwh (long, long)
11357 long __builtin_alpha_msklh (long, long)
11358 long __builtin_alpha_mskqh (long, long)
11359 long __builtin_alpha_umulh (long, long)
11360 long __builtin_alpha_zap (long, long)
11361 long __builtin_alpha_zapnot (long, long)
11362 @end smallexample
11363
11364 The following built-in functions are always with @option{-mmax}
11365 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
11366 later. They all generate the machine instruction that is part
11367 of the name.
11368
11369 @smallexample
11370 long __builtin_alpha_pklb (long)
11371 long __builtin_alpha_pkwb (long)
11372 long __builtin_alpha_unpkbl (long)
11373 long __builtin_alpha_unpkbw (long)
11374 long __builtin_alpha_minub8 (long, long)
11375 long __builtin_alpha_minsb8 (long, long)
11376 long __builtin_alpha_minuw4 (long, long)
11377 long __builtin_alpha_minsw4 (long, long)
11378 long __builtin_alpha_maxub8 (long, long)
11379 long __builtin_alpha_maxsb8 (long, long)
11380 long __builtin_alpha_maxuw4 (long, long)
11381 long __builtin_alpha_maxsw4 (long, long)
11382 long __builtin_alpha_perr (long, long)
11383 @end smallexample
11384
11385 The following built-in functions are always with @option{-mcix}
11386 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
11387 later. They all generate the machine instruction that is part
11388 of the name.
11389
11390 @smallexample
11391 long __builtin_alpha_cttz (long)
11392 long __builtin_alpha_ctlz (long)
11393 long __builtin_alpha_ctpop (long)
11394 @end smallexample
11395
11396 The following built-in functions are available on systems that use the OSF/1
11397 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
11398 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
11399 @code{rdval} and @code{wrval}.
11400
11401 @smallexample
11402 void *__builtin_thread_pointer (void)
11403 void __builtin_set_thread_pointer (void *)
11404 @end smallexample
11405
11406 @node Altera Nios II Built-in Functions
11407 @subsection Altera Nios II Built-in Functions
11408
11409 These built-in functions are available for the Altera Nios II
11410 family of processors.
11411
11412 The following built-in functions are always available. They
11413 all generate the machine instruction that is part of the name.
11414
11415 @example
11416 int __builtin_ldbio (volatile const void *)
11417 int __builtin_ldbuio (volatile const void *)
11418 int __builtin_ldhio (volatile const void *)
11419 int __builtin_ldhuio (volatile const void *)
11420 int __builtin_ldwio (volatile const void *)
11421 void __builtin_stbio (volatile void *, int)
11422 void __builtin_sthio (volatile void *, int)
11423 void __builtin_stwio (volatile void *, int)
11424 void __builtin_sync (void)
11425 int __builtin_rdctl (int)
11426 int __builtin_rdprs (int, int)
11427 void __builtin_wrctl (int, int)
11428 void __builtin_flushd (volatile void *)
11429 void __builtin_flushda (volatile void *)
11430 int __builtin_wrpie (int);
11431 void __builtin_eni (int);
11432 int __builtin_ldex (volatile const void *)
11433 int __builtin_stex (volatile void *, int)
11434 int __builtin_ldsex (volatile const void *)
11435 int __builtin_stsex (volatile void *, int)
11436 @end example
11437
11438 The following built-in functions are always available. They
11439 all generate a Nios II Custom Instruction. The name of the
11440 function represents the types that the function takes and
11441 returns. The letter before the @code{n} is the return type
11442 or void if absent. The @code{n} represents the first parameter
11443 to all the custom instructions, the custom instruction number.
11444 The two letters after the @code{n} represent the up to two
11445 parameters to the function.
11446
11447 The letters represent the following data types:
11448 @table @code
11449 @item <no letter>
11450 @code{void} for return type and no parameter for parameter types.
11451
11452 @item i
11453 @code{int} for return type and parameter type
11454
11455 @item f
11456 @code{float} for return type and parameter type
11457
11458 @item p
11459 @code{void *} for return type and parameter type
11460
11461 @end table
11462
11463 And the function names are:
11464 @example
11465 void __builtin_custom_n (void)
11466 void __builtin_custom_ni (int)
11467 void __builtin_custom_nf (float)
11468 void __builtin_custom_np (void *)
11469 void __builtin_custom_nii (int, int)
11470 void __builtin_custom_nif (int, float)
11471 void __builtin_custom_nip (int, void *)
11472 void __builtin_custom_nfi (float, int)
11473 void __builtin_custom_nff (float, float)
11474 void __builtin_custom_nfp (float, void *)
11475 void __builtin_custom_npi (void *, int)
11476 void __builtin_custom_npf (void *, float)
11477 void __builtin_custom_npp (void *, void *)
11478 int __builtin_custom_in (void)
11479 int __builtin_custom_ini (int)
11480 int __builtin_custom_inf (float)
11481 int __builtin_custom_inp (void *)
11482 int __builtin_custom_inii (int, int)
11483 int __builtin_custom_inif (int, float)
11484 int __builtin_custom_inip (int, void *)
11485 int __builtin_custom_infi (float, int)
11486 int __builtin_custom_inff (float, float)
11487 int __builtin_custom_infp (float, void *)
11488 int __builtin_custom_inpi (void *, int)
11489 int __builtin_custom_inpf (void *, float)
11490 int __builtin_custom_inpp (void *, void *)
11491 float __builtin_custom_fn (void)
11492 float __builtin_custom_fni (int)
11493 float __builtin_custom_fnf (float)
11494 float __builtin_custom_fnp (void *)
11495 float __builtin_custom_fnii (int, int)
11496 float __builtin_custom_fnif (int, float)
11497 float __builtin_custom_fnip (int, void *)
11498 float __builtin_custom_fnfi (float, int)
11499 float __builtin_custom_fnff (float, float)
11500 float __builtin_custom_fnfp (float, void *)
11501 float __builtin_custom_fnpi (void *, int)
11502 float __builtin_custom_fnpf (void *, float)
11503 float __builtin_custom_fnpp (void *, void *)
11504 void * __builtin_custom_pn (void)
11505 void * __builtin_custom_pni (int)
11506 void * __builtin_custom_pnf (float)
11507 void * __builtin_custom_pnp (void *)
11508 void * __builtin_custom_pnii (int, int)
11509 void * __builtin_custom_pnif (int, float)
11510 void * __builtin_custom_pnip (int, void *)
11511 void * __builtin_custom_pnfi (float, int)
11512 void * __builtin_custom_pnff (float, float)
11513 void * __builtin_custom_pnfp (float, void *)
11514 void * __builtin_custom_pnpi (void *, int)
11515 void * __builtin_custom_pnpf (void *, float)
11516 void * __builtin_custom_pnpp (void *, void *)
11517 @end example
11518
11519 @node ARC Built-in Functions
11520 @subsection ARC Built-in Functions
11521
11522 The following built-in functions are provided for ARC targets. The
11523 built-ins generate the corresponding assembly instructions. In the
11524 examples given below, the generated code often requires an operand or
11525 result to be in a register. Where necessary further code will be
11526 generated to ensure this is true, but for brevity this is not
11527 described in each case.
11528
11529 @emph{Note:} Using a built-in to generate an instruction not supported
11530 by a target may cause problems. At present the compiler is not
11531 guaranteed to detect such misuse, and as a result an internal compiler
11532 error may be generated.
11533
11534 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
11535 Return 1 if @var{val} is known to have the byte alignment given
11536 by @var{alignval}, otherwise return 0.
11537 Note that this is different from
11538 @smallexample
11539 __alignof__(*(char *)@var{val}) >= alignval
11540 @end smallexample
11541 because __alignof__ sees only the type of the dereference, whereas
11542 __builtin_arc_align uses alignment information from the pointer
11543 as well as from the pointed-to type.
11544 The information available will depend on optimization level.
11545 @end deftypefn
11546
11547 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
11548 Generates
11549 @example
11550 brk
11551 @end example
11552 @end deftypefn
11553
11554 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
11555 The operand is the number of a register to be read. Generates:
11556 @example
11557 mov @var{dest}, r@var{regno}
11558 @end example
11559 where the value in @var{dest} will be the result returned from the
11560 built-in.
11561 @end deftypefn
11562
11563 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
11564 The first operand is the number of a register to be written, the
11565 second operand is a compile time constant to write into that
11566 register. Generates:
11567 @example
11568 mov r@var{regno}, @var{val}
11569 @end example
11570 @end deftypefn
11571
11572 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
11573 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
11574 Generates:
11575 @example
11576 divaw @var{dest}, @var{a}, @var{b}
11577 @end example
11578 where the value in @var{dest} will be the result returned from the
11579 built-in.
11580 @end deftypefn
11581
11582 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
11583 Generates
11584 @example
11585 flag @var{a}
11586 @end example
11587 @end deftypefn
11588
11589 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
11590 The operand, @var{auxv}, is the address of an auxiliary register and
11591 must be a compile time constant. Generates:
11592 @example
11593 lr @var{dest}, [@var{auxr}]
11594 @end example
11595 Where the value in @var{dest} will be the result returned from the
11596 built-in.
11597 @end deftypefn
11598
11599 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
11600 Only available with @option{-mmul64}. Generates:
11601 @example
11602 mul64 @var{a}, @var{b}
11603 @end example
11604 @end deftypefn
11605
11606 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
11607 Only available with @option{-mmul64}. Generates:
11608 @example
11609 mulu64 @var{a}, @var{b}
11610 @end example
11611 @end deftypefn
11612
11613 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
11614 Generates:
11615 @example
11616 nop
11617 @end example
11618 @end deftypefn
11619
11620 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
11621 Only valid if the @samp{norm} instruction is available through the
11622 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11623 Generates:
11624 @example
11625 norm @var{dest}, @var{src}
11626 @end example
11627 Where the value in @var{dest} will be the result returned from the
11628 built-in.
11629 @end deftypefn
11630
11631 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
11632 Only valid if the @samp{normw} instruction is available through the
11633 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
11634 Generates:
11635 @example
11636 normw @var{dest}, @var{src}
11637 @end example
11638 Where the value in @var{dest} will be the result returned from the
11639 built-in.
11640 @end deftypefn
11641
11642 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
11643 Generates:
11644 @example
11645 rtie
11646 @end example
11647 @end deftypefn
11648
11649 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
11650 Generates:
11651 @example
11652 sleep @var{a}
11653 @end example
11654 @end deftypefn
11655
11656 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
11657 The first argument, @var{auxv}, is the address of an auxiliary
11658 register, the second argument, @var{val}, is a compile time constant
11659 to be written to the register. Generates:
11660 @example
11661 sr @var{auxr}, [@var{val}]
11662 @end example
11663 @end deftypefn
11664
11665 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
11666 Only valid with @option{-mswap}. Generates:
11667 @example
11668 swap @var{dest}, @var{src}
11669 @end example
11670 Where the value in @var{dest} will be the result returned from the
11671 built-in.
11672 @end deftypefn
11673
11674 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
11675 Generates:
11676 @example
11677 swi
11678 @end example
11679 @end deftypefn
11680
11681 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
11682 Only available with @option{-mcpu=ARC700}. Generates:
11683 @example
11684 sync
11685 @end example
11686 @end deftypefn
11687
11688 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
11689 Only available with @option{-mcpu=ARC700}. Generates:
11690 @example
11691 trap_s @var{c}
11692 @end example
11693 @end deftypefn
11694
11695 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
11696 Only available with @option{-mcpu=ARC700}. Generates:
11697 @example
11698 unimp_s
11699 @end example
11700 @end deftypefn
11701
11702 The instructions generated by the following builtins are not
11703 considered as candidates for scheduling. They are not moved around by
11704 the compiler during scheduling, and thus can be expected to appear
11705 where they are put in the C code:
11706 @example
11707 __builtin_arc_brk()
11708 __builtin_arc_core_read()
11709 __builtin_arc_core_write()
11710 __builtin_arc_flag()
11711 __builtin_arc_lr()
11712 __builtin_arc_sleep()
11713 __builtin_arc_sr()
11714 __builtin_arc_swi()
11715 @end example
11716
11717 @node ARC SIMD Built-in Functions
11718 @subsection ARC SIMD Built-in Functions
11719
11720 SIMD builtins provided by the compiler can be used to generate the
11721 vector instructions. This section describes the available builtins
11722 and their usage in programs. With the @option{-msimd} option, the
11723 compiler provides 128-bit vector types, which can be specified using
11724 the @code{vector_size} attribute. The header file @file{arc-simd.h}
11725 can be included to use the following predefined types:
11726 @example
11727 typedef int __v4si __attribute__((vector_size(16)));
11728 typedef short __v8hi __attribute__((vector_size(16)));
11729 @end example
11730
11731 These types can be used to define 128-bit variables. The built-in
11732 functions listed in the following section can be used on these
11733 variables to generate the vector operations.
11734
11735 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
11736 @file{arc-simd.h} also provides equivalent macros called
11737 @code{_@var{someinsn}} that can be used for programming ease and
11738 improved readability. The following macros for DMA control are also
11739 provided:
11740 @example
11741 #define _setup_dma_in_channel_reg _vdiwr
11742 #define _setup_dma_out_channel_reg _vdowr
11743 @end example
11744
11745 The following is a complete list of all the SIMD built-ins provided
11746 for ARC, grouped by calling signature.
11747
11748 The following take two @code{__v8hi} arguments and return a
11749 @code{__v8hi} result:
11750 @example
11751 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
11752 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
11753 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
11754 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
11755 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
11756 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
11757 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
11758 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
11759 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
11760 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
11761 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
11762 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
11763 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
11764 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
11765 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
11766 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
11767 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
11768 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
11769 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
11770 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
11771 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
11772 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
11773 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
11774 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
11775 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
11776 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
11777 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
11778 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
11779 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
11780 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
11781 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
11782 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
11783 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
11784 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
11785 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
11786 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
11787 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
11788 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
11789 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
11790 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
11791 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
11792 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
11793 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
11794 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
11795 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
11796 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
11797 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
11798 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
11799 @end example
11800
11801 The following take one @code{__v8hi} and one @code{int} argument and return a
11802 @code{__v8hi} result:
11803
11804 @example
11805 __v8hi __builtin_arc_vbaddw (__v8hi, int)
11806 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
11807 __v8hi __builtin_arc_vbminw (__v8hi, int)
11808 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
11809 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
11810 __v8hi __builtin_arc_vbmulw (__v8hi, int)
11811 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
11812 __v8hi __builtin_arc_vbsubw (__v8hi, int)
11813 @end example
11814
11815 The following take one @code{__v8hi} argument and one @code{int} argument which
11816 must be a 3-bit compile time constant indicating a register number
11817 I0-I7. They return a @code{__v8hi} result.
11818 @example
11819 __v8hi __builtin_arc_vasrw (__v8hi, const int)
11820 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
11821 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
11822 @end example
11823
11824 The following take one @code{__v8hi} argument and one @code{int}
11825 argument which must be a 6-bit compile time constant. They return a
11826 @code{__v8hi} result.
11827 @example
11828 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
11829 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
11830 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
11831 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
11832 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
11833 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
11834 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
11835 @end example
11836
11837 The following take one @code{__v8hi} argument and one @code{int} argument which
11838 must be a 8-bit compile time constant. They return a @code{__v8hi}
11839 result.
11840 @example
11841 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
11842 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
11843 __v8hi __builtin_arc_vmvw (__v8hi, const int)
11844 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
11845 @end example
11846
11847 The following take two @code{int} arguments, the second of which which
11848 must be a 8-bit compile time constant. They return a @code{__v8hi}
11849 result:
11850 @example
11851 __v8hi __builtin_arc_vmovaw (int, const int)
11852 __v8hi __builtin_arc_vmovw (int, const int)
11853 __v8hi __builtin_arc_vmovzw (int, const int)
11854 @end example
11855
11856 The following take a single @code{__v8hi} argument and return a
11857 @code{__v8hi} result:
11858 @example
11859 __v8hi __builtin_arc_vabsaw (__v8hi)
11860 __v8hi __builtin_arc_vabsw (__v8hi)
11861 __v8hi __builtin_arc_vaddsuw (__v8hi)
11862 __v8hi __builtin_arc_vexch1 (__v8hi)
11863 __v8hi __builtin_arc_vexch2 (__v8hi)
11864 __v8hi __builtin_arc_vexch4 (__v8hi)
11865 __v8hi __builtin_arc_vsignw (__v8hi)
11866 __v8hi __builtin_arc_vupbaw (__v8hi)
11867 __v8hi __builtin_arc_vupbw (__v8hi)
11868 __v8hi __builtin_arc_vupsbaw (__v8hi)
11869 __v8hi __builtin_arc_vupsbw (__v8hi)
11870 @end example
11871
11872 The following take two @code{int} arguments and return no result:
11873 @example
11874 void __builtin_arc_vdirun (int, int)
11875 void __builtin_arc_vdorun (int, int)
11876 @end example
11877
11878 The following take two @code{int} arguments and return no result. The
11879 first argument must a 3-bit compile time constant indicating one of
11880 the DR0-DR7 DMA setup channels:
11881 @example
11882 void __builtin_arc_vdiwr (const int, int)
11883 void __builtin_arc_vdowr (const int, int)
11884 @end example
11885
11886 The following take an @code{int} argument and return no result:
11887 @example
11888 void __builtin_arc_vendrec (int)
11889 void __builtin_arc_vrec (int)
11890 void __builtin_arc_vrecrun (int)
11891 void __builtin_arc_vrun (int)
11892 @end example
11893
11894 The following take a @code{__v8hi} argument and two @code{int}
11895 arguments and return a @code{__v8hi} result. The second argument must
11896 be a 3-bit compile time constants, indicating one the registers I0-I7,
11897 and the third argument must be an 8-bit compile time constant.
11898
11899 @emph{Note:} Although the equivalent hardware instructions do not take
11900 an SIMD register as an operand, these builtins overwrite the relevant
11901 bits of the @code{__v8hi} register provided as the first argument with
11902 the value loaded from the @code{[Ib, u8]} location in the SDM.
11903
11904 @example
11905 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
11906 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
11907 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
11908 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
11909 @end example
11910
11911 The following take two @code{int} arguments and return a @code{__v8hi}
11912 result. The first argument must be a 3-bit compile time constants,
11913 indicating one the registers I0-I7, and the second argument must be an
11914 8-bit compile time constant.
11915
11916 @example
11917 __v8hi __builtin_arc_vld128 (const int, const int)
11918 __v8hi __builtin_arc_vld64w (const int, const int)
11919 @end example
11920
11921 The following take a @code{__v8hi} argument and two @code{int}
11922 arguments and return no result. The second argument must be a 3-bit
11923 compile time constants, indicating one the registers I0-I7, and the
11924 third argument must be an 8-bit compile time constant.
11925
11926 @example
11927 void __builtin_arc_vst128 (__v8hi, const int, const int)
11928 void __builtin_arc_vst64 (__v8hi, const int, const int)
11929 @end example
11930
11931 The following take a @code{__v8hi} argument and three @code{int}
11932 arguments and return no result. The second argument must be a 3-bit
11933 compile-time constant, identifying the 16-bit sub-register to be
11934 stored, the third argument must be a 3-bit compile time constants,
11935 indicating one the registers I0-I7, and the fourth argument must be an
11936 8-bit compile time constant.
11937
11938 @example
11939 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
11940 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
11941 @end example
11942
11943 @node ARM iWMMXt Built-in Functions
11944 @subsection ARM iWMMXt Built-in Functions
11945
11946 These built-in functions are available for the ARM family of
11947 processors when the @option{-mcpu=iwmmxt} switch is used:
11948
11949 @smallexample
11950 typedef int v2si __attribute__ ((vector_size (8)));
11951 typedef short v4hi __attribute__ ((vector_size (8)));
11952 typedef char v8qi __attribute__ ((vector_size (8)));
11953
11954 int __builtin_arm_getwcgr0 (void)
11955 void __builtin_arm_setwcgr0 (int)
11956 int __builtin_arm_getwcgr1 (void)
11957 void __builtin_arm_setwcgr1 (int)
11958 int __builtin_arm_getwcgr2 (void)
11959 void __builtin_arm_setwcgr2 (int)
11960 int __builtin_arm_getwcgr3 (void)
11961 void __builtin_arm_setwcgr3 (int)
11962 int __builtin_arm_textrmsb (v8qi, int)
11963 int __builtin_arm_textrmsh (v4hi, int)
11964 int __builtin_arm_textrmsw (v2si, int)
11965 int __builtin_arm_textrmub (v8qi, int)
11966 int __builtin_arm_textrmuh (v4hi, int)
11967 int __builtin_arm_textrmuw (v2si, int)
11968 v8qi __builtin_arm_tinsrb (v8qi, int, int)
11969 v4hi __builtin_arm_tinsrh (v4hi, int, int)
11970 v2si __builtin_arm_tinsrw (v2si, int, int)
11971 long long __builtin_arm_tmia (long long, int, int)
11972 long long __builtin_arm_tmiabb (long long, int, int)
11973 long long __builtin_arm_tmiabt (long long, int, int)
11974 long long __builtin_arm_tmiaph (long long, int, int)
11975 long long __builtin_arm_tmiatb (long long, int, int)
11976 long long __builtin_arm_tmiatt (long long, int, int)
11977 int __builtin_arm_tmovmskb (v8qi)
11978 int __builtin_arm_tmovmskh (v4hi)
11979 int __builtin_arm_tmovmskw (v2si)
11980 long long __builtin_arm_waccb (v8qi)
11981 long long __builtin_arm_wacch (v4hi)
11982 long long __builtin_arm_waccw (v2si)
11983 v8qi __builtin_arm_waddb (v8qi, v8qi)
11984 v8qi __builtin_arm_waddbss (v8qi, v8qi)
11985 v8qi __builtin_arm_waddbus (v8qi, v8qi)
11986 v4hi __builtin_arm_waddh (v4hi, v4hi)
11987 v4hi __builtin_arm_waddhss (v4hi, v4hi)
11988 v4hi __builtin_arm_waddhus (v4hi, v4hi)
11989 v2si __builtin_arm_waddw (v2si, v2si)
11990 v2si __builtin_arm_waddwss (v2si, v2si)
11991 v2si __builtin_arm_waddwus (v2si, v2si)
11992 v8qi __builtin_arm_walign (v8qi, v8qi, int)
11993 long long __builtin_arm_wand(long long, long long)
11994 long long __builtin_arm_wandn (long long, long long)
11995 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
11996 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
11997 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
11998 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
11999 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
12000 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
12001 v2si __builtin_arm_wcmpeqw (v2si, v2si)
12002 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
12003 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
12004 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
12005 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
12006 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
12007 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
12008 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
12009 long long __builtin_arm_wmacsz (v4hi, v4hi)
12010 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
12011 long long __builtin_arm_wmacuz (v4hi, v4hi)
12012 v4hi __builtin_arm_wmadds (v4hi, v4hi)
12013 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
12014 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
12015 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
12016 v2si __builtin_arm_wmaxsw (v2si, v2si)
12017 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
12018 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
12019 v2si __builtin_arm_wmaxuw (v2si, v2si)
12020 v8qi __builtin_arm_wminsb (v8qi, v8qi)
12021 v4hi __builtin_arm_wminsh (v4hi, v4hi)
12022 v2si __builtin_arm_wminsw (v2si, v2si)
12023 v8qi __builtin_arm_wminub (v8qi, v8qi)
12024 v4hi __builtin_arm_wminuh (v4hi, v4hi)
12025 v2si __builtin_arm_wminuw (v2si, v2si)
12026 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
12027 v4hi __builtin_arm_wmulul (v4hi, v4hi)
12028 v4hi __builtin_arm_wmulum (v4hi, v4hi)
12029 long long __builtin_arm_wor (long long, long long)
12030 v2si __builtin_arm_wpackdss (long long, long long)
12031 v2si __builtin_arm_wpackdus (long long, long long)
12032 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
12033 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
12034 v4hi __builtin_arm_wpackwss (v2si, v2si)
12035 v4hi __builtin_arm_wpackwus (v2si, v2si)
12036 long long __builtin_arm_wrord (long long, long long)
12037 long long __builtin_arm_wrordi (long long, int)
12038 v4hi __builtin_arm_wrorh (v4hi, long long)
12039 v4hi __builtin_arm_wrorhi (v4hi, int)
12040 v2si __builtin_arm_wrorw (v2si, long long)
12041 v2si __builtin_arm_wrorwi (v2si, int)
12042 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
12043 v2si __builtin_arm_wsadbz (v8qi, v8qi)
12044 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
12045 v2si __builtin_arm_wsadhz (v4hi, v4hi)
12046 v4hi __builtin_arm_wshufh (v4hi, int)
12047 long long __builtin_arm_wslld (long long, long long)
12048 long long __builtin_arm_wslldi (long long, int)
12049 v4hi __builtin_arm_wsllh (v4hi, long long)
12050 v4hi __builtin_arm_wsllhi (v4hi, int)
12051 v2si __builtin_arm_wsllw (v2si, long long)
12052 v2si __builtin_arm_wsllwi (v2si, int)
12053 long long __builtin_arm_wsrad (long long, long long)
12054 long long __builtin_arm_wsradi (long long, int)
12055 v4hi __builtin_arm_wsrah (v4hi, long long)
12056 v4hi __builtin_arm_wsrahi (v4hi, int)
12057 v2si __builtin_arm_wsraw (v2si, long long)
12058 v2si __builtin_arm_wsrawi (v2si, int)
12059 long long __builtin_arm_wsrld (long long, long long)
12060 long long __builtin_arm_wsrldi (long long, int)
12061 v4hi __builtin_arm_wsrlh (v4hi, long long)
12062 v4hi __builtin_arm_wsrlhi (v4hi, int)
12063 v2si __builtin_arm_wsrlw (v2si, long long)
12064 v2si __builtin_arm_wsrlwi (v2si, int)
12065 v8qi __builtin_arm_wsubb (v8qi, v8qi)
12066 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
12067 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
12068 v4hi __builtin_arm_wsubh (v4hi, v4hi)
12069 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
12070 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
12071 v2si __builtin_arm_wsubw (v2si, v2si)
12072 v2si __builtin_arm_wsubwss (v2si, v2si)
12073 v2si __builtin_arm_wsubwus (v2si, v2si)
12074 v4hi __builtin_arm_wunpckehsb (v8qi)
12075 v2si __builtin_arm_wunpckehsh (v4hi)
12076 long long __builtin_arm_wunpckehsw (v2si)
12077 v4hi __builtin_arm_wunpckehub (v8qi)
12078 v2si __builtin_arm_wunpckehuh (v4hi)
12079 long long __builtin_arm_wunpckehuw (v2si)
12080 v4hi __builtin_arm_wunpckelsb (v8qi)
12081 v2si __builtin_arm_wunpckelsh (v4hi)
12082 long long __builtin_arm_wunpckelsw (v2si)
12083 v4hi __builtin_arm_wunpckelub (v8qi)
12084 v2si __builtin_arm_wunpckeluh (v4hi)
12085 long long __builtin_arm_wunpckeluw (v2si)
12086 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
12087 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
12088 v2si __builtin_arm_wunpckihw (v2si, v2si)
12089 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
12090 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
12091 v2si __builtin_arm_wunpckilw (v2si, v2si)
12092 long long __builtin_arm_wxor (long long, long long)
12093 long long __builtin_arm_wzero ()
12094 @end smallexample
12095
12096
12097 @node ARM C Language Extensions (ACLE)
12098 @subsection ARM C Language Extensions (ACLE)
12099
12100 GCC implements extensions for C as described in the ARM C Language
12101 Extensions (ACLE) specification, which can be found at
12102 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
12103
12104 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
12105 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
12106 intrinsics can be found at
12107 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
12108 The built-in intrinsics for the Advanced SIMD extension are available when
12109 NEON is enabled.
12110
12111 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
12112 back ends support CRC32 intrinsics from @file{arm_acle.h}. The ARM back end's
12113 16-bit floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
12114 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
12115 intrinsics yet.
12116
12117 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
12118 availability of extensions.
12119
12120 @node ARM Floating Point Status and Control Intrinsics
12121 @subsection ARM Floating Point Status and Control Intrinsics
12122
12123 These built-in functions are available for the ARM family of
12124 processors with floating-point unit.
12125
12126 @smallexample
12127 unsigned int __builtin_arm_get_fpscr ()
12128 void __builtin_arm_set_fpscr (unsigned int)
12129 @end smallexample
12130
12131 @node AVR Built-in Functions
12132 @subsection AVR Built-in Functions
12133
12134 For each built-in function for AVR, there is an equally named,
12135 uppercase built-in macro defined. That way users can easily query if
12136 or if not a specific built-in is implemented or not. For example, if
12137 @code{__builtin_avr_nop} is available the macro
12138 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
12139
12140 The following built-in functions map to the respective machine
12141 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
12142 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
12143 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
12144 as library call if no hardware multiplier is available.
12145
12146 @smallexample
12147 void __builtin_avr_nop (void)
12148 void __builtin_avr_sei (void)
12149 void __builtin_avr_cli (void)
12150 void __builtin_avr_sleep (void)
12151 void __builtin_avr_wdr (void)
12152 unsigned char __builtin_avr_swap (unsigned char)
12153 unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
12154 int __builtin_avr_fmuls (char, char)
12155 int __builtin_avr_fmulsu (char, unsigned char)
12156 @end smallexample
12157
12158 In order to delay execution for a specific number of cycles, GCC
12159 implements
12160 @smallexample
12161 void __builtin_avr_delay_cycles (unsigned long ticks)
12162 @end smallexample
12163
12164 @noindent
12165 @code{ticks} is the number of ticks to delay execution. Note that this
12166 built-in does not take into account the effect of interrupts that
12167 might increase delay time. @code{ticks} must be a compile-time
12168 integer constant; delays with a variable number of cycles are not supported.
12169
12170 @smallexample
12171 char __builtin_avr_flash_segment (const __memx void*)
12172 @end smallexample
12173
12174 @noindent
12175 This built-in takes a byte address to the 24-bit
12176 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
12177 the number of the flash segment (the 64 KiB chunk) where the address
12178 points to. Counting starts at @code{0}.
12179 If the address does not point to flash memory, return @code{-1}.
12180
12181 @smallexample
12182 unsigned char __builtin_avr_insert_bits (unsigned long map, unsigned char bits, unsigned char val)
12183 @end smallexample
12184
12185 @noindent
12186 Insert bits from @var{bits} into @var{val} and return the resulting
12187 value. The nibbles of @var{map} determine how the insertion is
12188 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
12189 @enumerate
12190 @item If @var{X} is @code{0xf},
12191 then the @var{n}-th bit of @var{val} is returned unaltered.
12192
12193 @item If X is in the range 0@dots{}7,
12194 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
12195
12196 @item If X is in the range 8@dots{}@code{0xe},
12197 then the @var{n}-th result bit is undefined.
12198 @end enumerate
12199
12200 @noindent
12201 One typical use case for this built-in is adjusting input and
12202 output values to non-contiguous port layouts. Some examples:
12203
12204 @smallexample
12205 // same as val, bits is unused
12206 __builtin_avr_insert_bits (0xffffffff, bits, val)
12207 @end smallexample
12208
12209 @smallexample
12210 // same as bits, val is unused
12211 __builtin_avr_insert_bits (0x76543210, bits, val)
12212 @end smallexample
12213
12214 @smallexample
12215 // same as rotating bits by 4
12216 __builtin_avr_insert_bits (0x32107654, bits, 0)
12217 @end smallexample
12218
12219 @smallexample
12220 // high nibble of result is the high nibble of val
12221 // low nibble of result is the low nibble of bits
12222 __builtin_avr_insert_bits (0xffff3210, bits, val)
12223 @end smallexample
12224
12225 @smallexample
12226 // reverse the bit order of bits
12227 __builtin_avr_insert_bits (0x01234567, bits, 0)
12228 @end smallexample
12229
12230 @node Blackfin Built-in Functions
12231 @subsection Blackfin Built-in Functions
12232
12233 Currently, there are two Blackfin-specific built-in functions. These are
12234 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
12235 using inline assembly; by using these built-in functions the compiler can
12236 automatically add workarounds for hardware errata involving these
12237 instructions. These functions are named as follows:
12238
12239 @smallexample
12240 void __builtin_bfin_csync (void)
12241 void __builtin_bfin_ssync (void)
12242 @end smallexample
12243
12244 @node FR-V Built-in Functions
12245 @subsection FR-V Built-in Functions
12246
12247 GCC provides many FR-V-specific built-in functions. In general,
12248 these functions are intended to be compatible with those described
12249 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
12250 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
12251 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
12252 pointer rather than by value.
12253
12254 Most of the functions are named after specific FR-V instructions.
12255 Such functions are said to be ``directly mapped'' and are summarized
12256 here in tabular form.
12257
12258 @menu
12259 * Argument Types::
12260 * Directly-mapped Integer Functions::
12261 * Directly-mapped Media Functions::
12262 * Raw read/write Functions::
12263 * Other Built-in Functions::
12264 @end menu
12265
12266 @node Argument Types
12267 @subsubsection Argument Types
12268
12269 The arguments to the built-in functions can be divided into three groups:
12270 register numbers, compile-time constants and run-time values. In order
12271 to make this classification clear at a glance, the arguments and return
12272 values are given the following pseudo types:
12273
12274 @multitable @columnfractions .20 .30 .15 .35
12275 @item Pseudo type @tab Real C type @tab Constant? @tab Description
12276 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
12277 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
12278 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
12279 @item @code{uw2} @tab @code{unsigned long long} @tab No
12280 @tab an unsigned doubleword
12281 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
12282 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
12283 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
12284 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
12285 @end multitable
12286
12287 These pseudo types are not defined by GCC, they are simply a notational
12288 convenience used in this manual.
12289
12290 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
12291 and @code{sw2} are evaluated at run time. They correspond to
12292 register operands in the underlying FR-V instructions.
12293
12294 @code{const} arguments represent immediate operands in the underlying
12295 FR-V instructions. They must be compile-time constants.
12296
12297 @code{acc} arguments are evaluated at compile time and specify the number
12298 of an accumulator register. For example, an @code{acc} argument of 2
12299 selects the ACC2 register.
12300
12301 @code{iacc} arguments are similar to @code{acc} arguments but specify the
12302 number of an IACC register. See @pxref{Other Built-in Functions}
12303 for more details.
12304
12305 @node Directly-mapped Integer Functions
12306 @subsubsection Directly-Mapped Integer Functions
12307
12308 The functions listed below map directly to FR-V I-type instructions.
12309
12310 @multitable @columnfractions .45 .32 .23
12311 @item Function prototype @tab Example usage @tab Assembly output
12312 @item @code{sw1 __ADDSS (sw1, sw1)}
12313 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
12314 @tab @code{ADDSS @var{a},@var{b},@var{c}}
12315 @item @code{sw1 __SCAN (sw1, sw1)}
12316 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
12317 @tab @code{SCAN @var{a},@var{b},@var{c}}
12318 @item @code{sw1 __SCUTSS (sw1)}
12319 @tab @code{@var{b} = __SCUTSS (@var{a})}
12320 @tab @code{SCUTSS @var{a},@var{b}}
12321 @item @code{sw1 __SLASS (sw1, sw1)}
12322 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
12323 @tab @code{SLASS @var{a},@var{b},@var{c}}
12324 @item @code{void __SMASS (sw1, sw1)}
12325 @tab @code{__SMASS (@var{a}, @var{b})}
12326 @tab @code{SMASS @var{a},@var{b}}
12327 @item @code{void __SMSSS (sw1, sw1)}
12328 @tab @code{__SMSSS (@var{a}, @var{b})}
12329 @tab @code{SMSSS @var{a},@var{b}}
12330 @item @code{void __SMU (sw1, sw1)}
12331 @tab @code{__SMU (@var{a}, @var{b})}
12332 @tab @code{SMU @var{a},@var{b}}
12333 @item @code{sw2 __SMUL (sw1, sw1)}
12334 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
12335 @tab @code{SMUL @var{a},@var{b},@var{c}}
12336 @item @code{sw1 __SUBSS (sw1, sw1)}
12337 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
12338 @tab @code{SUBSS @var{a},@var{b},@var{c}}
12339 @item @code{uw2 __UMUL (uw1, uw1)}
12340 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
12341 @tab @code{UMUL @var{a},@var{b},@var{c}}
12342 @end multitable
12343
12344 @node Directly-mapped Media Functions
12345 @subsubsection Directly-Mapped Media Functions
12346
12347 The functions listed below map directly to FR-V M-type instructions.
12348
12349 @multitable @columnfractions .45 .32 .23
12350 @item Function prototype @tab Example usage @tab Assembly output
12351 @item @code{uw1 __MABSHS (sw1)}
12352 @tab @code{@var{b} = __MABSHS (@var{a})}
12353 @tab @code{MABSHS @var{a},@var{b}}
12354 @item @code{void __MADDACCS (acc, acc)}
12355 @tab @code{__MADDACCS (@var{b}, @var{a})}
12356 @tab @code{MADDACCS @var{a},@var{b}}
12357 @item @code{sw1 __MADDHSS (sw1, sw1)}
12358 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
12359 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
12360 @item @code{uw1 __MADDHUS (uw1, uw1)}
12361 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
12362 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
12363 @item @code{uw1 __MAND (uw1, uw1)}
12364 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
12365 @tab @code{MAND @var{a},@var{b},@var{c}}
12366 @item @code{void __MASACCS (acc, acc)}
12367 @tab @code{__MASACCS (@var{b}, @var{a})}
12368 @tab @code{MASACCS @var{a},@var{b}}
12369 @item @code{uw1 __MAVEH (uw1, uw1)}
12370 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
12371 @tab @code{MAVEH @var{a},@var{b},@var{c}}
12372 @item @code{uw2 __MBTOH (uw1)}
12373 @tab @code{@var{b} = __MBTOH (@var{a})}
12374 @tab @code{MBTOH @var{a},@var{b}}
12375 @item @code{void __MBTOHE (uw1 *, uw1)}
12376 @tab @code{__MBTOHE (&@var{b}, @var{a})}
12377 @tab @code{MBTOHE @var{a},@var{b}}
12378 @item @code{void __MCLRACC (acc)}
12379 @tab @code{__MCLRACC (@var{a})}
12380 @tab @code{MCLRACC @var{a}}
12381 @item @code{void __MCLRACCA (void)}
12382 @tab @code{__MCLRACCA ()}
12383 @tab @code{MCLRACCA}
12384 @item @code{uw1 __Mcop1 (uw1, uw1)}
12385 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
12386 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
12387 @item @code{uw1 __Mcop2 (uw1, uw1)}
12388 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
12389 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
12390 @item @code{uw1 __MCPLHI (uw2, const)}
12391 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
12392 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
12393 @item @code{uw1 __MCPLI (uw2, const)}
12394 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
12395 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
12396 @item @code{void __MCPXIS (acc, sw1, sw1)}
12397 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
12398 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
12399 @item @code{void __MCPXIU (acc, uw1, uw1)}
12400 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
12401 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
12402 @item @code{void __MCPXRS (acc, sw1, sw1)}
12403 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
12404 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
12405 @item @code{void __MCPXRU (acc, uw1, uw1)}
12406 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
12407 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
12408 @item @code{uw1 __MCUT (acc, uw1)}
12409 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
12410 @tab @code{MCUT @var{a},@var{b},@var{c}}
12411 @item @code{uw1 __MCUTSS (acc, sw1)}
12412 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
12413 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
12414 @item @code{void __MDADDACCS (acc, acc)}
12415 @tab @code{__MDADDACCS (@var{b}, @var{a})}
12416 @tab @code{MDADDACCS @var{a},@var{b}}
12417 @item @code{void __MDASACCS (acc, acc)}
12418 @tab @code{__MDASACCS (@var{b}, @var{a})}
12419 @tab @code{MDASACCS @var{a},@var{b}}
12420 @item @code{uw2 __MDCUTSSI (acc, const)}
12421 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
12422 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
12423 @item @code{uw2 __MDPACKH (uw2, uw2)}
12424 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
12425 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
12426 @item @code{uw2 __MDROTLI (uw2, const)}
12427 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
12428 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
12429 @item @code{void __MDSUBACCS (acc, acc)}
12430 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
12431 @tab @code{MDSUBACCS @var{a},@var{b}}
12432 @item @code{void __MDUNPACKH (uw1 *, uw2)}
12433 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
12434 @tab @code{MDUNPACKH @var{a},@var{b}}
12435 @item @code{uw2 __MEXPDHD (uw1, const)}
12436 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
12437 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
12438 @item @code{uw1 __MEXPDHW (uw1, const)}
12439 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
12440 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
12441 @item @code{uw1 __MHDSETH (uw1, const)}
12442 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
12443 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
12444 @item @code{sw1 __MHDSETS (const)}
12445 @tab @code{@var{b} = __MHDSETS (@var{a})}
12446 @tab @code{MHDSETS #@var{a},@var{b}}
12447 @item @code{uw1 __MHSETHIH (uw1, const)}
12448 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
12449 @tab @code{MHSETHIH #@var{a},@var{b}}
12450 @item @code{sw1 __MHSETHIS (sw1, const)}
12451 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
12452 @tab @code{MHSETHIS #@var{a},@var{b}}
12453 @item @code{uw1 __MHSETLOH (uw1, const)}
12454 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
12455 @tab @code{MHSETLOH #@var{a},@var{b}}
12456 @item @code{sw1 __MHSETLOS (sw1, const)}
12457 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
12458 @tab @code{MHSETLOS #@var{a},@var{b}}
12459 @item @code{uw1 __MHTOB (uw2)}
12460 @tab @code{@var{b} = __MHTOB (@var{a})}
12461 @tab @code{MHTOB @var{a},@var{b}}
12462 @item @code{void __MMACHS (acc, sw1, sw1)}
12463 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
12464 @tab @code{MMACHS @var{a},@var{b},@var{c}}
12465 @item @code{void __MMACHU (acc, uw1, uw1)}
12466 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
12467 @tab @code{MMACHU @var{a},@var{b},@var{c}}
12468 @item @code{void __MMRDHS (acc, sw1, sw1)}
12469 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
12470 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
12471 @item @code{void __MMRDHU (acc, uw1, uw1)}
12472 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
12473 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
12474 @item @code{void __MMULHS (acc, sw1, sw1)}
12475 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
12476 @tab @code{MMULHS @var{a},@var{b},@var{c}}
12477 @item @code{void __MMULHU (acc, uw1, uw1)}
12478 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
12479 @tab @code{MMULHU @var{a},@var{b},@var{c}}
12480 @item @code{void __MMULXHS (acc, sw1, sw1)}
12481 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
12482 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
12483 @item @code{void __MMULXHU (acc, uw1, uw1)}
12484 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
12485 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
12486 @item @code{uw1 __MNOT (uw1)}
12487 @tab @code{@var{b} = __MNOT (@var{a})}
12488 @tab @code{MNOT @var{a},@var{b}}
12489 @item @code{uw1 __MOR (uw1, uw1)}
12490 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
12491 @tab @code{MOR @var{a},@var{b},@var{c}}
12492 @item @code{uw1 __MPACKH (uh, uh)}
12493 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
12494 @tab @code{MPACKH @var{a},@var{b},@var{c}}
12495 @item @code{sw2 __MQADDHSS (sw2, sw2)}
12496 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
12497 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
12498 @item @code{uw2 __MQADDHUS (uw2, uw2)}
12499 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
12500 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
12501 @item @code{void __MQCPXIS (acc, sw2, sw2)}
12502 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
12503 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
12504 @item @code{void __MQCPXIU (acc, uw2, uw2)}
12505 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
12506 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
12507 @item @code{void __MQCPXRS (acc, sw2, sw2)}
12508 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
12509 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
12510 @item @code{void __MQCPXRU (acc, uw2, uw2)}
12511 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
12512 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
12513 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
12514 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
12515 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
12516 @item @code{sw2 __MQLMTHS (sw2, sw2)}
12517 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
12518 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
12519 @item @code{void __MQMACHS (acc, sw2, sw2)}
12520 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
12521 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
12522 @item @code{void __MQMACHU (acc, uw2, uw2)}
12523 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
12524 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
12525 @item @code{void __MQMACXHS (acc, sw2, sw2)}
12526 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
12527 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
12528 @item @code{void __MQMULHS (acc, sw2, sw2)}
12529 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
12530 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
12531 @item @code{void __MQMULHU (acc, uw2, uw2)}
12532 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
12533 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
12534 @item @code{void __MQMULXHS (acc, sw2, sw2)}
12535 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
12536 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
12537 @item @code{void __MQMULXHU (acc, uw2, uw2)}
12538 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
12539 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
12540 @item @code{sw2 __MQSATHS (sw2, sw2)}
12541 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
12542 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
12543 @item @code{uw2 __MQSLLHI (uw2, int)}
12544 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
12545 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
12546 @item @code{sw2 __MQSRAHI (sw2, int)}
12547 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
12548 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
12549 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
12550 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
12551 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
12552 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
12553 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
12554 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
12555 @item @code{void __MQXMACHS (acc, sw2, sw2)}
12556 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
12557 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
12558 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
12559 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
12560 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
12561 @item @code{uw1 __MRDACC (acc)}
12562 @tab @code{@var{b} = __MRDACC (@var{a})}
12563 @tab @code{MRDACC @var{a},@var{b}}
12564 @item @code{uw1 __MRDACCG (acc)}
12565 @tab @code{@var{b} = __MRDACCG (@var{a})}
12566 @tab @code{MRDACCG @var{a},@var{b}}
12567 @item @code{uw1 __MROTLI (uw1, const)}
12568 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
12569 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
12570 @item @code{uw1 __MROTRI (uw1, const)}
12571 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
12572 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
12573 @item @code{sw1 __MSATHS (sw1, sw1)}
12574 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
12575 @tab @code{MSATHS @var{a},@var{b},@var{c}}
12576 @item @code{uw1 __MSATHU (uw1, uw1)}
12577 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
12578 @tab @code{MSATHU @var{a},@var{b},@var{c}}
12579 @item @code{uw1 __MSLLHI (uw1, const)}
12580 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
12581 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
12582 @item @code{sw1 __MSRAHI (sw1, const)}
12583 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
12584 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
12585 @item @code{uw1 __MSRLHI (uw1, const)}
12586 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
12587 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
12588 @item @code{void __MSUBACCS (acc, acc)}
12589 @tab @code{__MSUBACCS (@var{b}, @var{a})}
12590 @tab @code{MSUBACCS @var{a},@var{b}}
12591 @item @code{sw1 __MSUBHSS (sw1, sw1)}
12592 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
12593 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
12594 @item @code{uw1 __MSUBHUS (uw1, uw1)}
12595 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
12596 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
12597 @item @code{void __MTRAP (void)}
12598 @tab @code{__MTRAP ()}
12599 @tab @code{MTRAP}
12600 @item @code{uw2 __MUNPACKH (uw1)}
12601 @tab @code{@var{b} = __MUNPACKH (@var{a})}
12602 @tab @code{MUNPACKH @var{a},@var{b}}
12603 @item @code{uw1 __MWCUT (uw2, uw1)}
12604 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
12605 @tab @code{MWCUT @var{a},@var{b},@var{c}}
12606 @item @code{void __MWTACC (acc, uw1)}
12607 @tab @code{__MWTACC (@var{b}, @var{a})}
12608 @tab @code{MWTACC @var{a},@var{b}}
12609 @item @code{void __MWTACCG (acc, uw1)}
12610 @tab @code{__MWTACCG (@var{b}, @var{a})}
12611 @tab @code{MWTACCG @var{a},@var{b}}
12612 @item @code{uw1 __MXOR (uw1, uw1)}
12613 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
12614 @tab @code{MXOR @var{a},@var{b},@var{c}}
12615 @end multitable
12616
12617 @node Raw read/write Functions
12618 @subsubsection Raw Read/Write Functions
12619
12620 This sections describes built-in functions related to read and write
12621 instructions to access memory. These functions generate
12622 @code{membar} instructions to flush the I/O load and stores where
12623 appropriate, as described in Fujitsu's manual described above.
12624
12625 @table @code
12626
12627 @item unsigned char __builtin_read8 (void *@var{data})
12628 @item unsigned short __builtin_read16 (void *@var{data})
12629 @item unsigned long __builtin_read32 (void *@var{data})
12630 @item unsigned long long __builtin_read64 (void *@var{data})
12631
12632 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
12633 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
12634 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
12635 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
12636 @end table
12637
12638 @node Other Built-in Functions
12639 @subsubsection Other Built-in Functions
12640
12641 This section describes built-in functions that are not named after
12642 a specific FR-V instruction.
12643
12644 @table @code
12645 @item sw2 __IACCreadll (iacc @var{reg})
12646 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
12647 for future expansion and must be 0.
12648
12649 @item sw1 __IACCreadl (iacc @var{reg})
12650 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
12651 Other values of @var{reg} are rejected as invalid.
12652
12653 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
12654 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
12655 is reserved for future expansion and must be 0.
12656
12657 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
12658 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
12659 is 1. Other values of @var{reg} are rejected as invalid.
12660
12661 @item void __data_prefetch0 (const void *@var{x})
12662 Use the @code{dcpl} instruction to load the contents of address @var{x}
12663 into the data cache.
12664
12665 @item void __data_prefetch (const void *@var{x})
12666 Use the @code{nldub} instruction to load the contents of address @var{x}
12667 into the data cache. The instruction is issued in slot I1@.
12668 @end table
12669
12670 @node MIPS DSP Built-in Functions
12671 @subsection MIPS DSP Built-in Functions
12672
12673 The MIPS DSP Application-Specific Extension (ASE) includes new
12674 instructions that are designed to improve the performance of DSP and
12675 media applications. It provides instructions that operate on packed
12676 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
12677
12678 GCC supports MIPS DSP operations using both the generic
12679 vector extensions (@pxref{Vector Extensions}) and a collection of
12680 MIPS-specific built-in functions. Both kinds of support are
12681 enabled by the @option{-mdsp} command-line option.
12682
12683 Revision 2 of the ASE was introduced in the second half of 2006.
12684 This revision adds extra instructions to the original ASE, but is
12685 otherwise backwards-compatible with it. You can select revision 2
12686 using the command-line option @option{-mdspr2}; this option implies
12687 @option{-mdsp}.
12688
12689 The SCOUNT and POS bits of the DSP control register are global. The
12690 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
12691 POS bits. During optimization, the compiler does not delete these
12692 instructions and it does not delete calls to functions containing
12693 these instructions.
12694
12695 At present, GCC only provides support for operations on 32-bit
12696 vectors. The vector type associated with 8-bit integer data is
12697 usually called @code{v4i8}, the vector type associated with Q7
12698 is usually called @code{v4q7}, the vector type associated with 16-bit
12699 integer data is usually called @code{v2i16}, and the vector type
12700 associated with Q15 is usually called @code{v2q15}. They can be
12701 defined in C as follows:
12702
12703 @smallexample
12704 typedef signed char v4i8 __attribute__ ((vector_size(4)));
12705 typedef signed char v4q7 __attribute__ ((vector_size(4)));
12706 typedef short v2i16 __attribute__ ((vector_size(4)));
12707 typedef short v2q15 __attribute__ ((vector_size(4)));
12708 @end smallexample
12709
12710 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
12711 initialized in the same way as aggregates. For example:
12712
12713 @smallexample
12714 v4i8 a = @{1, 2, 3, 4@};
12715 v4i8 b;
12716 b = (v4i8) @{5, 6, 7, 8@};
12717
12718 v2q15 c = @{0x0fcb, 0x3a75@};
12719 v2q15 d;
12720 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
12721 @end smallexample
12722
12723 @emph{Note:} The CPU's endianness determines the order in which values
12724 are packed. On little-endian targets, the first value is the least
12725 significant and the last value is the most significant. The opposite
12726 order applies to big-endian targets. For example, the code above
12727 sets the lowest byte of @code{a} to @code{1} on little-endian targets
12728 and @code{4} on big-endian targets.
12729
12730 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
12731 representation. As shown in this example, the integer representation
12732 of a Q7 value can be obtained by multiplying the fractional value by
12733 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
12734 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
12735 @code{0x1.0p31}.
12736
12737 The table below lists the @code{v4i8} and @code{v2q15} operations for which
12738 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
12739 and @code{c} and @code{d} are @code{v2q15} values.
12740
12741 @multitable @columnfractions .50 .50
12742 @item C code @tab MIPS instruction
12743 @item @code{a + b} @tab @code{addu.qb}
12744 @item @code{c + d} @tab @code{addq.ph}
12745 @item @code{a - b} @tab @code{subu.qb}
12746 @item @code{c - d} @tab @code{subq.ph}
12747 @end multitable
12748
12749 The table below lists the @code{v2i16} operation for which
12750 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
12751 @code{v2i16} values.
12752
12753 @multitable @columnfractions .50 .50
12754 @item C code @tab MIPS instruction
12755 @item @code{e * f} @tab @code{mul.ph}
12756 @end multitable
12757
12758 It is easier to describe the DSP built-in functions if we first define
12759 the following types:
12760
12761 @smallexample
12762 typedef int q31;
12763 typedef int i32;
12764 typedef unsigned int ui32;
12765 typedef long long a64;
12766 @end smallexample
12767
12768 @code{q31} and @code{i32} are actually the same as @code{int}, but we
12769 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
12770 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
12771 @code{long long}, but we use @code{a64} to indicate values that are
12772 placed in one of the four DSP accumulators (@code{$ac0},
12773 @code{$ac1}, @code{$ac2} or @code{$ac3}).
12774
12775 Also, some built-in functions prefer or require immediate numbers as
12776 parameters, because the corresponding DSP instructions accept both immediate
12777 numbers and register operands, or accept immediate numbers only. The
12778 immediate parameters are listed as follows.
12779
12780 @smallexample
12781 imm0_3: 0 to 3.
12782 imm0_7: 0 to 7.
12783 imm0_15: 0 to 15.
12784 imm0_31: 0 to 31.
12785 imm0_63: 0 to 63.
12786 imm0_255: 0 to 255.
12787 imm_n32_31: -32 to 31.
12788 imm_n512_511: -512 to 511.
12789 @end smallexample
12790
12791 The following built-in functions map directly to a particular MIPS DSP
12792 instruction. Please refer to the architecture specification
12793 for details on what each instruction does.
12794
12795 @smallexample
12796 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
12797 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
12798 q31 __builtin_mips_addq_s_w (q31, q31)
12799 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
12800 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
12801 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
12802 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
12803 q31 __builtin_mips_subq_s_w (q31, q31)
12804 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
12805 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
12806 i32 __builtin_mips_addsc (i32, i32)
12807 i32 __builtin_mips_addwc (i32, i32)
12808 i32 __builtin_mips_modsub (i32, i32)
12809 i32 __builtin_mips_raddu_w_qb (v4i8)
12810 v2q15 __builtin_mips_absq_s_ph (v2q15)
12811 q31 __builtin_mips_absq_s_w (q31)
12812 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
12813 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
12814 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
12815 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
12816 q31 __builtin_mips_preceq_w_phl (v2q15)
12817 q31 __builtin_mips_preceq_w_phr (v2q15)
12818 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
12819 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
12820 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
12821 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
12822 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
12823 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
12824 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
12825 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
12826 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
12827 v4i8 __builtin_mips_shll_qb (v4i8, i32)
12828 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
12829 v2q15 __builtin_mips_shll_ph (v2q15, i32)
12830 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
12831 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
12832 q31 __builtin_mips_shll_s_w (q31, imm0_31)
12833 q31 __builtin_mips_shll_s_w (q31, i32)
12834 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
12835 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
12836 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
12837 v2q15 __builtin_mips_shra_ph (v2q15, i32)
12838 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
12839 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
12840 q31 __builtin_mips_shra_r_w (q31, imm0_31)
12841 q31 __builtin_mips_shra_r_w (q31, i32)
12842 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
12843 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
12844 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
12845 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
12846 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
12847 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
12848 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
12849 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
12850 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
12851 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
12852 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
12853 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
12854 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
12855 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
12856 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
12857 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
12858 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
12859 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
12860 i32 __builtin_mips_bitrev (i32)
12861 i32 __builtin_mips_insv (i32, i32)
12862 v4i8 __builtin_mips_repl_qb (imm0_255)
12863 v4i8 __builtin_mips_repl_qb (i32)
12864 v2q15 __builtin_mips_repl_ph (imm_n512_511)
12865 v2q15 __builtin_mips_repl_ph (i32)
12866 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
12867 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
12868 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
12869 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
12870 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
12871 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
12872 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
12873 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
12874 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
12875 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
12876 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
12877 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
12878 i32 __builtin_mips_extr_w (a64, imm0_31)
12879 i32 __builtin_mips_extr_w (a64, i32)
12880 i32 __builtin_mips_extr_r_w (a64, imm0_31)
12881 i32 __builtin_mips_extr_s_h (a64, i32)
12882 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
12883 i32 __builtin_mips_extr_rs_w (a64, i32)
12884 i32 __builtin_mips_extr_s_h (a64, imm0_31)
12885 i32 __builtin_mips_extr_r_w (a64, i32)
12886 i32 __builtin_mips_extp (a64, imm0_31)
12887 i32 __builtin_mips_extp (a64, i32)
12888 i32 __builtin_mips_extpdp (a64, imm0_31)
12889 i32 __builtin_mips_extpdp (a64, i32)
12890 a64 __builtin_mips_shilo (a64, imm_n32_31)
12891 a64 __builtin_mips_shilo (a64, i32)
12892 a64 __builtin_mips_mthlip (a64, i32)
12893 void __builtin_mips_wrdsp (i32, imm0_63)
12894 i32 __builtin_mips_rddsp (imm0_63)
12895 i32 __builtin_mips_lbux (void *, i32)
12896 i32 __builtin_mips_lhx (void *, i32)
12897 i32 __builtin_mips_lwx (void *, i32)
12898 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
12899 i32 __builtin_mips_bposge32 (void)
12900 a64 __builtin_mips_madd (a64, i32, i32);
12901 a64 __builtin_mips_maddu (a64, ui32, ui32);
12902 a64 __builtin_mips_msub (a64, i32, i32);
12903 a64 __builtin_mips_msubu (a64, ui32, ui32);
12904 a64 __builtin_mips_mult (i32, i32);
12905 a64 __builtin_mips_multu (ui32, ui32);
12906 @end smallexample
12907
12908 The following built-in functions map directly to a particular MIPS DSP REV 2
12909 instruction. Please refer to the architecture specification
12910 for details on what each instruction does.
12911
12912 @smallexample
12913 v4q7 __builtin_mips_absq_s_qb (v4q7);
12914 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
12915 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
12916 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
12917 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
12918 i32 __builtin_mips_append (i32, i32, imm0_31);
12919 i32 __builtin_mips_balign (i32, i32, imm0_3);
12920 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
12921 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
12922 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
12923 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
12924 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
12925 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
12926 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
12927 q31 __builtin_mips_mulq_rs_w (q31, q31);
12928 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
12929 q31 __builtin_mips_mulq_s_w (q31, q31);
12930 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
12931 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
12932 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
12933 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
12934 i32 __builtin_mips_prepend (i32, i32, imm0_31);
12935 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
12936 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
12937 v4i8 __builtin_mips_shra_qb (v4i8, i32);
12938 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
12939 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
12940 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
12941 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
12942 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
12943 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
12944 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
12945 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
12946 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
12947 q31 __builtin_mips_addqh_w (q31, q31);
12948 q31 __builtin_mips_addqh_r_w (q31, q31);
12949 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
12950 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
12951 q31 __builtin_mips_subqh_w (q31, q31);
12952 q31 __builtin_mips_subqh_r_w (q31, q31);
12953 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
12954 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
12955 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
12956 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
12957 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
12958 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
12959 @end smallexample
12960
12961
12962 @node MIPS Paired-Single Support
12963 @subsection MIPS Paired-Single Support
12964
12965 The MIPS64 architecture includes a number of instructions that
12966 operate on pairs of single-precision floating-point values.
12967 Each pair is packed into a 64-bit floating-point register,
12968 with one element being designated the ``upper half'' and
12969 the other being designated the ``lower half''.
12970
12971 GCC supports paired-single operations using both the generic
12972 vector extensions (@pxref{Vector Extensions}) and a collection of
12973 MIPS-specific built-in functions. Both kinds of support are
12974 enabled by the @option{-mpaired-single} command-line option.
12975
12976 The vector type associated with paired-single values is usually
12977 called @code{v2sf}. It can be defined in C as follows:
12978
12979 @smallexample
12980 typedef float v2sf __attribute__ ((vector_size (8)));
12981 @end smallexample
12982
12983 @code{v2sf} values are initialized in the same way as aggregates.
12984 For example:
12985
12986 @smallexample
12987 v2sf a = @{1.5, 9.1@};
12988 v2sf b;
12989 float e, f;
12990 b = (v2sf) @{e, f@};
12991 @end smallexample
12992
12993 @emph{Note:} The CPU's endianness determines which value is stored in
12994 the upper half of a register and which value is stored in the lower half.
12995 On little-endian targets, the first value is the lower one and the second
12996 value is the upper one. The opposite order applies to big-endian targets.
12997 For example, the code above sets the lower half of @code{a} to
12998 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
12999
13000 @node MIPS Loongson Built-in Functions
13001 @subsection MIPS Loongson Built-in Functions
13002
13003 GCC provides intrinsics to access the SIMD instructions provided by the
13004 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
13005 available after inclusion of the @code{loongson.h} header file,
13006 operate on the following 64-bit vector types:
13007
13008 @itemize
13009 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
13010 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
13011 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
13012 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
13013 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
13014 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
13015 @end itemize
13016
13017 The intrinsics provided are listed below; each is named after the
13018 machine instruction to which it corresponds, with suffixes added as
13019 appropriate to distinguish intrinsics that expand to the same machine
13020 instruction yet have different argument types. Refer to the architecture
13021 documentation for a description of the functionality of each
13022 instruction.
13023
13024 @smallexample
13025 int16x4_t packsswh (int32x2_t s, int32x2_t t);
13026 int8x8_t packsshb (int16x4_t s, int16x4_t t);
13027 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
13028 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
13029 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
13030 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
13031 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
13032 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
13033 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
13034 uint64_t paddd_u (uint64_t s, uint64_t t);
13035 int64_t paddd_s (int64_t s, int64_t t);
13036 int16x4_t paddsh (int16x4_t s, int16x4_t t);
13037 int8x8_t paddsb (int8x8_t s, int8x8_t t);
13038 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
13039 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
13040 uint64_t pandn_ud (uint64_t s, uint64_t t);
13041 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
13042 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
13043 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
13044 int64_t pandn_sd (int64_t s, int64_t t);
13045 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
13046 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
13047 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
13048 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
13049 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
13050 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
13051 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
13052 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
13053 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
13054 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
13055 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
13056 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
13057 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
13058 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
13059 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
13060 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
13061 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
13062 uint16x4_t pextrh_u (uint16x4_t s, int field);
13063 int16x4_t pextrh_s (int16x4_t s, int field);
13064 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
13065 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
13066 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
13067 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
13068 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
13069 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
13070 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
13071 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
13072 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
13073 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
13074 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
13075 int16x4_t pminsh (int16x4_t s, int16x4_t t);
13076 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
13077 uint8x8_t pmovmskb_u (uint8x8_t s);
13078 int8x8_t pmovmskb_s (int8x8_t s);
13079 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
13080 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
13081 int16x4_t pmullh (int16x4_t s, int16x4_t t);
13082 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
13083 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
13084 uint16x4_t biadd (uint8x8_t s);
13085 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
13086 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
13087 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
13088 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
13089 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
13090 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
13091 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
13092 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
13093 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
13094 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
13095 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
13096 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
13097 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
13098 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
13099 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
13100 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
13101 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
13102 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
13103 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
13104 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
13105 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
13106 uint64_t psubd_u (uint64_t s, uint64_t t);
13107 int64_t psubd_s (int64_t s, int64_t t);
13108 int16x4_t psubsh (int16x4_t s, int16x4_t t);
13109 int8x8_t psubsb (int8x8_t s, int8x8_t t);
13110 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
13111 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
13112 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
13113 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
13114 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
13115 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
13116 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
13117 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
13118 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
13119 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
13120 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
13121 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
13122 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
13123 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
13124 @end smallexample
13125
13126 @menu
13127 * Paired-Single Arithmetic::
13128 * Paired-Single Built-in Functions::
13129 * MIPS-3D Built-in Functions::
13130 @end menu
13131
13132 @node Paired-Single Arithmetic
13133 @subsubsection Paired-Single Arithmetic
13134
13135 The table below lists the @code{v2sf} operations for which hardware
13136 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
13137 values and @code{x} is an integral value.
13138
13139 @multitable @columnfractions .50 .50
13140 @item C code @tab MIPS instruction
13141 @item @code{a + b} @tab @code{add.ps}
13142 @item @code{a - b} @tab @code{sub.ps}
13143 @item @code{-a} @tab @code{neg.ps}
13144 @item @code{a * b} @tab @code{mul.ps}
13145 @item @code{a * b + c} @tab @code{madd.ps}
13146 @item @code{a * b - c} @tab @code{msub.ps}
13147 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
13148 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
13149 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
13150 @end multitable
13151
13152 Note that the multiply-accumulate instructions can be disabled
13153 using the command-line option @code{-mno-fused-madd}.
13154
13155 @node Paired-Single Built-in Functions
13156 @subsubsection Paired-Single Built-in Functions
13157
13158 The following paired-single functions map directly to a particular
13159 MIPS instruction. Please refer to the architecture specification
13160 for details on what each instruction does.
13161
13162 @table @code
13163 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
13164 Pair lower lower (@code{pll.ps}).
13165
13166 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
13167 Pair upper lower (@code{pul.ps}).
13168
13169 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
13170 Pair lower upper (@code{plu.ps}).
13171
13172 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
13173 Pair upper upper (@code{puu.ps}).
13174
13175 @item v2sf __builtin_mips_cvt_ps_s (float, float)
13176 Convert pair to paired single (@code{cvt.ps.s}).
13177
13178 @item float __builtin_mips_cvt_s_pl (v2sf)
13179 Convert pair lower to single (@code{cvt.s.pl}).
13180
13181 @item float __builtin_mips_cvt_s_pu (v2sf)
13182 Convert pair upper to single (@code{cvt.s.pu}).
13183
13184 @item v2sf __builtin_mips_abs_ps (v2sf)
13185 Absolute value (@code{abs.ps}).
13186
13187 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
13188 Align variable (@code{alnv.ps}).
13189
13190 @emph{Note:} The value of the third parameter must be 0 or 4
13191 modulo 8, otherwise the result is unpredictable. Please read the
13192 instruction description for details.
13193 @end table
13194
13195 The following multi-instruction functions are also available.
13196 In each case, @var{cond} can be any of the 16 floating-point conditions:
13197 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13198 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
13199 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13200
13201 @table @code
13202 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13203 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13204 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
13205 @code{movt.ps}/@code{movf.ps}).
13206
13207 The @code{movt} functions return the value @var{x} computed by:
13208
13209 @smallexample
13210 c.@var{cond}.ps @var{cc},@var{a},@var{b}
13211 mov.ps @var{x},@var{c}
13212 movt.ps @var{x},@var{d},@var{cc}
13213 @end smallexample
13214
13215 The @code{movf} functions are similar but use @code{movf.ps} instead
13216 of @code{movt.ps}.
13217
13218 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13219 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13220 Comparison of two paired-single values (@code{c.@var{cond}.ps},
13221 @code{bc1t}/@code{bc1f}).
13222
13223 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13224 and return either the upper or lower half of the result. For example:
13225
13226 @smallexample
13227 v2sf a, b;
13228 if (__builtin_mips_upper_c_eq_ps (a, b))
13229 upper_halves_are_equal ();
13230 else
13231 upper_halves_are_unequal ();
13232
13233 if (__builtin_mips_lower_c_eq_ps (a, b))
13234 lower_halves_are_equal ();
13235 else
13236 lower_halves_are_unequal ();
13237 @end smallexample
13238 @end table
13239
13240 @node MIPS-3D Built-in Functions
13241 @subsubsection MIPS-3D Built-in Functions
13242
13243 The MIPS-3D Application-Specific Extension (ASE) includes additional
13244 paired-single instructions that are designed to improve the performance
13245 of 3D graphics operations. Support for these instructions is controlled
13246 by the @option{-mips3d} command-line option.
13247
13248 The functions listed below map directly to a particular MIPS-3D
13249 instruction. Please refer to the architecture specification for
13250 more details on what each instruction does.
13251
13252 @table @code
13253 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
13254 Reduction add (@code{addr.ps}).
13255
13256 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
13257 Reduction multiply (@code{mulr.ps}).
13258
13259 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
13260 Convert paired single to paired word (@code{cvt.pw.ps}).
13261
13262 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
13263 Convert paired word to paired single (@code{cvt.ps.pw}).
13264
13265 @item float __builtin_mips_recip1_s (float)
13266 @itemx double __builtin_mips_recip1_d (double)
13267 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
13268 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
13269
13270 @item float __builtin_mips_recip2_s (float, float)
13271 @itemx double __builtin_mips_recip2_d (double, double)
13272 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
13273 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
13274
13275 @item float __builtin_mips_rsqrt1_s (float)
13276 @itemx double __builtin_mips_rsqrt1_d (double)
13277 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
13278 Reduced-precision reciprocal square root (sequence step 1)
13279 (@code{rsqrt1.@var{fmt}}).
13280
13281 @item float __builtin_mips_rsqrt2_s (float, float)
13282 @itemx double __builtin_mips_rsqrt2_d (double, double)
13283 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
13284 Reduced-precision reciprocal square root (sequence step 2)
13285 (@code{rsqrt2.@var{fmt}}).
13286 @end table
13287
13288 The following multi-instruction functions are also available.
13289 In each case, @var{cond} can be any of the 16 floating-point conditions:
13290 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
13291 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
13292 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
13293
13294 @table @code
13295 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
13296 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
13297 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
13298 @code{bc1t}/@code{bc1f}).
13299
13300 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
13301 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
13302 For example:
13303
13304 @smallexample
13305 float a, b;
13306 if (__builtin_mips_cabs_eq_s (a, b))
13307 true ();
13308 else
13309 false ();
13310 @end smallexample
13311
13312 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13313 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13314 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
13315 @code{bc1t}/@code{bc1f}).
13316
13317 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
13318 and return either the upper or lower half of the result. For example:
13319
13320 @smallexample
13321 v2sf a, b;
13322 if (__builtin_mips_upper_cabs_eq_ps (a, b))
13323 upper_halves_are_equal ();
13324 else
13325 upper_halves_are_unequal ();
13326
13327 if (__builtin_mips_lower_cabs_eq_ps (a, b))
13328 lower_halves_are_equal ();
13329 else
13330 lower_halves_are_unequal ();
13331 @end smallexample
13332
13333 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13334 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13335 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
13336 @code{movt.ps}/@code{movf.ps}).
13337
13338 The @code{movt} functions return the value @var{x} computed by:
13339
13340 @smallexample
13341 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
13342 mov.ps @var{x},@var{c}
13343 movt.ps @var{x},@var{d},@var{cc}
13344 @end smallexample
13345
13346 The @code{movf} functions are similar but use @code{movf.ps} instead
13347 of @code{movt.ps}.
13348
13349 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13350 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13351 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13352 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
13353 Comparison of two paired-single values
13354 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13355 @code{bc1any2t}/@code{bc1any2f}).
13356
13357 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
13358 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
13359 result is true and the @code{all} forms return true if both results are true.
13360 For example:
13361
13362 @smallexample
13363 v2sf a, b;
13364 if (__builtin_mips_any_c_eq_ps (a, b))
13365 one_is_true ();
13366 else
13367 both_are_false ();
13368
13369 if (__builtin_mips_all_c_eq_ps (a, b))
13370 both_are_true ();
13371 else
13372 one_is_false ();
13373 @end smallexample
13374
13375 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13376 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13377 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13378 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
13379 Comparison of four paired-single values
13380 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
13381 @code{bc1any4t}/@code{bc1any4f}).
13382
13383 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
13384 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
13385 The @code{any} forms return true if any of the four results are true
13386 and the @code{all} forms return true if all four results are true.
13387 For example:
13388
13389 @smallexample
13390 v2sf a, b, c, d;
13391 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
13392 some_are_true ();
13393 else
13394 all_are_false ();
13395
13396 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
13397 all_are_true ();
13398 else
13399 some_are_false ();
13400 @end smallexample
13401 @end table
13402
13403 @node Other MIPS Built-in Functions
13404 @subsection Other MIPS Built-in Functions
13405
13406 GCC provides other MIPS-specific built-in functions:
13407
13408 @table @code
13409 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
13410 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
13411 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
13412 when this function is available.
13413
13414 @item unsigned int __builtin_mips_get_fcsr (void)
13415 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
13416 Get and set the contents of the floating-point control and status register
13417 (FPU control register 31). These functions are only available in hard-float
13418 code but can be called in both MIPS16 and non-MIPS16 contexts.
13419
13420 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
13421 register except the condition codes, which GCC assumes are preserved.
13422 @end table
13423
13424 @node MSP430 Built-in Functions
13425 @subsection MSP430 Built-in Functions
13426
13427 GCC provides a couple of special builtin functions to aid in the
13428 writing of interrupt handlers in C.
13429
13430 @table @code
13431 @item __bic_SR_register_on_exit (int @var{mask})
13432 This clears the indicated bits in the saved copy of the status register
13433 currently residing on the stack. This only works inside interrupt
13434 handlers and the changes to the status register will only take affect
13435 once the handler returns.
13436
13437 @item __bis_SR_register_on_exit (int @var{mask})
13438 This sets the indicated bits in the saved copy of the status register
13439 currently residing on the stack. This only works inside interrupt
13440 handlers and the changes to the status register will only take affect
13441 once the handler returns.
13442
13443 @item __delay_cycles (long long @var{cycles})
13444 This inserts an instruction sequence that takes exactly @var{cycles}
13445 cycles (between 0 and about 17E9) to complete. The inserted sequence
13446 may use jumps, loops, or no-ops, and does not interfere with any other
13447 instructions. Note that @var{cycles} must be a compile-time constant
13448 integer - that is, you must pass a number, not a variable that may be
13449 optimized to a constant later. The number of cycles delayed by this
13450 builtin is exact.
13451 @end table
13452
13453 @node NDS32 Built-in Functions
13454 @subsection NDS32 Built-in Functions
13455
13456 These built-in functions are available for the NDS32 target:
13457
13458 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
13459 Insert an ISYNC instruction into the instruction stream where
13460 @var{addr} is an instruction address for serialization.
13461 @end deftypefn
13462
13463 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
13464 Insert an ISB instruction into the instruction stream.
13465 @end deftypefn
13466
13467 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
13468 Return the content of a system register which is mapped by @var{sr}.
13469 @end deftypefn
13470
13471 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
13472 Return the content of a user space register which is mapped by @var{usr}.
13473 @end deftypefn
13474
13475 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
13476 Move the @var{value} to a system register which is mapped by @var{sr}.
13477 @end deftypefn
13478
13479 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
13480 Move the @var{value} to a user space register which is mapped by @var{usr}.
13481 @end deftypefn
13482
13483 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
13484 Enable global interrupt.
13485 @end deftypefn
13486
13487 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
13488 Disable global interrupt.
13489 @end deftypefn
13490
13491 @node picoChip Built-in Functions
13492 @subsection picoChip Built-in Functions
13493
13494 GCC provides an interface to selected machine instructions from the
13495 picoChip instruction set.
13496
13497 @table @code
13498 @item int __builtin_sbc (int @var{value})
13499 Sign bit count. Return the number of consecutive bits in @var{value}
13500 that have the same value as the sign bit. The result is the number of
13501 leading sign bits minus one, giving the number of redundant sign bits in
13502 @var{value}.
13503
13504 @item int __builtin_byteswap (int @var{value})
13505 Byte swap. Return the result of swapping the upper and lower bytes of
13506 @var{value}.
13507
13508 @item int __builtin_brev (int @var{value})
13509 Bit reversal. Return the result of reversing the bits in
13510 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
13511 and so on.
13512
13513 @item int __builtin_adds (int @var{x}, int @var{y})
13514 Saturating addition. Return the result of adding @var{x} and @var{y},
13515 storing the value 32767 if the result overflows.
13516
13517 @item int __builtin_subs (int @var{x}, int @var{y})
13518 Saturating subtraction. Return the result of subtracting @var{y} from
13519 @var{x}, storing the value @minus{}32768 if the result overflows.
13520
13521 @item void __builtin_halt (void)
13522 Halt. The processor stops execution. This built-in is useful for
13523 implementing assertions.
13524
13525 @end table
13526
13527 @node PowerPC Built-in Functions
13528 @subsection PowerPC Built-in Functions
13529
13530 These built-in functions are available for the PowerPC family of
13531 processors:
13532 @smallexample
13533 float __builtin_recipdivf (float, float);
13534 float __builtin_rsqrtf (float);
13535 double __builtin_recipdiv (double, double);
13536 double __builtin_rsqrt (double);
13537 uint64_t __builtin_ppc_get_timebase ();
13538 unsigned long __builtin_ppc_mftb ();
13539 double __builtin_unpack_longdouble (long double, int);
13540 long double __builtin_pack_longdouble (double, double);
13541 double __builtin_unpack_ibm128 (__ibm128, int);
13542 __ibm128 __builtin_pack_ibm128 (double, double);
13543 @end smallexample
13544
13545 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
13546 @code{__builtin_rsqrtf} functions generate multiple instructions to
13547 implement the reciprocal sqrt functionality using reciprocal sqrt
13548 estimate instructions.
13549
13550 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
13551 functions generate multiple instructions to implement division using
13552 the reciprocal estimate instructions.
13553
13554 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
13555 functions generate instructions to read the Time Base Register. The
13556 @code{__builtin_ppc_get_timebase} function may generate multiple
13557 instructions and always returns the 64 bits of the Time Base Register.
13558 The @code{__builtin_ppc_mftb} function always generates one instruction and
13559 returns the Time Base Register value as an unsigned long, throwing away
13560 the most significant word on 32-bit environments.
13561
13562 The following built-in functions are available for the PowerPC family
13563 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
13564 or @option{-mpopcntd}):
13565 @smallexample
13566 long __builtin_bpermd (long, long);
13567 int __builtin_divwe (int, int);
13568 int __builtin_divweo (int, int);
13569 unsigned int __builtin_divweu (unsigned int, unsigned int);
13570 unsigned int __builtin_divweuo (unsigned int, unsigned int);
13571 long __builtin_divde (long, long);
13572 long __builtin_divdeo (long, long);
13573 unsigned long __builtin_divdeu (unsigned long, unsigned long);
13574 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
13575 unsigned int cdtbcd (unsigned int);
13576 unsigned int cbcdtd (unsigned int);
13577 unsigned int addg6s (unsigned int, unsigned int);
13578 @end smallexample
13579
13580 The @code{__builtin_divde}, @code{__builtin_divdeo},
13581 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
13582 64-bit environment support ISA 2.06 or later.
13583
13584 The following built-in functions are available for the PowerPC family
13585 of processors when hardware decimal floating point
13586 (@option{-mhard-dfp}) is available:
13587 @smallexample
13588 _Decimal64 __builtin_dxex (_Decimal64);
13589 _Decimal128 __builtin_dxexq (_Decimal128);
13590 _Decimal64 __builtin_ddedpd (int, _Decimal64);
13591 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
13592 _Decimal64 __builtin_denbcd (int, _Decimal64);
13593 _Decimal128 __builtin_denbcdq (int, _Decimal128);
13594 _Decimal64 __builtin_diex (_Decimal64, _Decimal64);
13595 _Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
13596 _Decimal64 __builtin_dscli (_Decimal64, int);
13597 _Decimal128 __builtin_dscliq (_Decimal128, int);
13598 _Decimal64 __builtin_dscri (_Decimal64, int);
13599 _Decimal128 __builtin_dscriq (_Decimal128, int);
13600 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
13601 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
13602 @end smallexample
13603
13604 The following built-in functions are available for the PowerPC family
13605 of processors when the Vector Scalar (vsx) instruction set is
13606 available:
13607 @smallexample
13608 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
13609 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
13610 unsigned long long);
13611 @end smallexample
13612
13613 @node PowerPC AltiVec/VSX Built-in Functions
13614 @subsection PowerPC AltiVec Built-in Functions
13615
13616 GCC provides an interface for the PowerPC family of processors to access
13617 the AltiVec operations described in Motorola's AltiVec Programming
13618 Interface Manual. The interface is made available by including
13619 @code{<altivec.h>} and using @option{-maltivec} and
13620 @option{-mabi=altivec}. The interface supports the following vector
13621 types.
13622
13623 @smallexample
13624 vector unsigned char
13625 vector signed char
13626 vector bool char
13627
13628 vector unsigned short
13629 vector signed short
13630 vector bool short
13631 vector pixel
13632
13633 vector unsigned int
13634 vector signed int
13635 vector bool int
13636 vector float
13637 @end smallexample
13638
13639 If @option{-mvsx} is used the following additional vector types are
13640 implemented.
13641
13642 @smallexample
13643 vector unsigned long
13644 vector signed long
13645 vector double
13646 @end smallexample
13647
13648 The long types are only implemented for 64-bit code generation, and
13649 the long type is only used in the floating point/integer conversion
13650 instructions.
13651
13652 GCC's implementation of the high-level language interface available from
13653 C and C++ code differs from Motorola's documentation in several ways.
13654
13655 @itemize @bullet
13656
13657 @item
13658 A vector constant is a list of constant expressions within curly braces.
13659
13660 @item
13661 A vector initializer requires no cast if the vector constant is of the
13662 same type as the variable it is initializing.
13663
13664 @item
13665 If @code{signed} or @code{unsigned} is omitted, the signedness of the
13666 vector type is the default signedness of the base type. The default
13667 varies depending on the operating system, so a portable program should
13668 always specify the signedness.
13669
13670 @item
13671 Compiling with @option{-maltivec} adds keywords @code{__vector},
13672 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
13673 @code{bool}. When compiling ISO C, the context-sensitive substitution
13674 of the keywords @code{vector}, @code{pixel} and @code{bool} is
13675 disabled. To use them, you must include @code{<altivec.h>} instead.
13676
13677 @item
13678 GCC allows using a @code{typedef} name as the type specifier for a
13679 vector type.
13680
13681 @item
13682 For C, overloaded functions are implemented with macros so the following
13683 does not work:
13684
13685 @smallexample
13686 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
13687 @end smallexample
13688
13689 @noindent
13690 Since @code{vec_add} is a macro, the vector constant in the example
13691 is treated as four separate arguments. Wrap the entire argument in
13692 parentheses for this to work.
13693 @end itemize
13694
13695 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
13696 Internally, GCC uses built-in functions to achieve the functionality in
13697 the aforementioned header file, but they are not supported and are
13698 subject to change without notice.
13699
13700 The following interfaces are supported for the generic and specific
13701 AltiVec operations and the AltiVec predicates. In cases where there
13702 is a direct mapping between generic and specific operations, only the
13703 generic names are shown here, although the specific operations can also
13704 be used.
13705
13706 Arguments that are documented as @code{const int} require literal
13707 integral values within the range required for that operation.
13708
13709 @smallexample
13710 vector signed char vec_abs (vector signed char);
13711 vector signed short vec_abs (vector signed short);
13712 vector signed int vec_abs (vector signed int);
13713 vector float vec_abs (vector float);
13714
13715 vector signed char vec_abss (vector signed char);
13716 vector signed short vec_abss (vector signed short);
13717 vector signed int vec_abss (vector signed int);
13718
13719 vector signed char vec_add (vector bool char, vector signed char);
13720 vector signed char vec_add (vector signed char, vector bool char);
13721 vector signed char vec_add (vector signed char, vector signed char);
13722 vector unsigned char vec_add (vector bool char, vector unsigned char);
13723 vector unsigned char vec_add (vector unsigned char, vector bool char);
13724 vector unsigned char vec_add (vector unsigned char,
13725 vector unsigned char);
13726 vector signed short vec_add (vector bool short, vector signed short);
13727 vector signed short vec_add (vector signed short, vector bool short);
13728 vector signed short vec_add (vector signed short, vector signed short);
13729 vector unsigned short vec_add (vector bool short,
13730 vector unsigned short);
13731 vector unsigned short vec_add (vector unsigned short,
13732 vector bool short);
13733 vector unsigned short vec_add (vector unsigned short,
13734 vector unsigned short);
13735 vector signed int vec_add (vector bool int, vector signed int);
13736 vector signed int vec_add (vector signed int, vector bool int);
13737 vector signed int vec_add (vector signed int, vector signed int);
13738 vector unsigned int vec_add (vector bool int, vector unsigned int);
13739 vector unsigned int vec_add (vector unsigned int, vector bool int);
13740 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
13741 vector float vec_add (vector float, vector float);
13742
13743 vector float vec_vaddfp (vector float, vector float);
13744
13745 vector signed int vec_vadduwm (vector bool int, vector signed int);
13746 vector signed int vec_vadduwm (vector signed int, vector bool int);
13747 vector signed int vec_vadduwm (vector signed int, vector signed int);
13748 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
13749 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
13750 vector unsigned int vec_vadduwm (vector unsigned int,
13751 vector unsigned int);
13752
13753 vector signed short vec_vadduhm (vector bool short,
13754 vector signed short);
13755 vector signed short vec_vadduhm (vector signed short,
13756 vector bool short);
13757 vector signed short vec_vadduhm (vector signed short,
13758 vector signed short);
13759 vector unsigned short vec_vadduhm (vector bool short,
13760 vector unsigned short);
13761 vector unsigned short vec_vadduhm (vector unsigned short,
13762 vector bool short);
13763 vector unsigned short vec_vadduhm (vector unsigned short,
13764 vector unsigned short);
13765
13766 vector signed char vec_vaddubm (vector bool char, vector signed char);
13767 vector signed char vec_vaddubm (vector signed char, vector bool char);
13768 vector signed char vec_vaddubm (vector signed char, vector signed char);
13769 vector unsigned char vec_vaddubm (vector bool char,
13770 vector unsigned char);
13771 vector unsigned char vec_vaddubm (vector unsigned char,
13772 vector bool char);
13773 vector unsigned char vec_vaddubm (vector unsigned char,
13774 vector unsigned char);
13775
13776 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
13777
13778 vector unsigned char vec_adds (vector bool char, vector unsigned char);
13779 vector unsigned char vec_adds (vector unsigned char, vector bool char);
13780 vector unsigned char vec_adds (vector unsigned char,
13781 vector unsigned char);
13782 vector signed char vec_adds (vector bool char, vector signed char);
13783 vector signed char vec_adds (vector signed char, vector bool char);
13784 vector signed char vec_adds (vector signed char, vector signed char);
13785 vector unsigned short vec_adds (vector bool short,
13786 vector unsigned short);
13787 vector unsigned short vec_adds (vector unsigned short,
13788 vector bool short);
13789 vector unsigned short vec_adds (vector unsigned short,
13790 vector unsigned short);
13791 vector signed short vec_adds (vector bool short, vector signed short);
13792 vector signed short vec_adds (vector signed short, vector bool short);
13793 vector signed short vec_adds (vector signed short, vector signed short);
13794 vector unsigned int vec_adds (vector bool int, vector unsigned int);
13795 vector unsigned int vec_adds (vector unsigned int, vector bool int);
13796 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
13797 vector signed int vec_adds (vector bool int, vector signed int);
13798 vector signed int vec_adds (vector signed int, vector bool int);
13799 vector signed int vec_adds (vector signed int, vector signed int);
13800
13801 vector signed int vec_vaddsws (vector bool int, vector signed int);
13802 vector signed int vec_vaddsws (vector signed int, vector bool int);
13803 vector signed int vec_vaddsws (vector signed int, vector signed int);
13804
13805 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
13806 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
13807 vector unsigned int vec_vadduws (vector unsigned int,
13808 vector unsigned int);
13809
13810 vector signed short vec_vaddshs (vector bool short,
13811 vector signed short);
13812 vector signed short vec_vaddshs (vector signed short,
13813 vector bool short);
13814 vector signed short vec_vaddshs (vector signed short,
13815 vector signed short);
13816
13817 vector unsigned short vec_vadduhs (vector bool short,
13818 vector unsigned short);
13819 vector unsigned short vec_vadduhs (vector unsigned short,
13820 vector bool short);
13821 vector unsigned short vec_vadduhs (vector unsigned short,
13822 vector unsigned short);
13823
13824 vector signed char vec_vaddsbs (vector bool char, vector signed char);
13825 vector signed char vec_vaddsbs (vector signed char, vector bool char);
13826 vector signed char vec_vaddsbs (vector signed char, vector signed char);
13827
13828 vector unsigned char vec_vaddubs (vector bool char,
13829 vector unsigned char);
13830 vector unsigned char vec_vaddubs (vector unsigned char,
13831 vector bool char);
13832 vector unsigned char vec_vaddubs (vector unsigned char,
13833 vector unsigned char);
13834
13835 vector float vec_and (vector float, vector float);
13836 vector float vec_and (vector float, vector bool int);
13837 vector float vec_and (vector bool int, vector float);
13838 vector bool int vec_and (vector bool int, vector bool int);
13839 vector signed int vec_and (vector bool int, vector signed int);
13840 vector signed int vec_and (vector signed int, vector bool int);
13841 vector signed int vec_and (vector signed int, vector signed int);
13842 vector unsigned int vec_and (vector bool int, vector unsigned int);
13843 vector unsigned int vec_and (vector unsigned int, vector bool int);
13844 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
13845 vector bool short vec_and (vector bool short, vector bool short);
13846 vector signed short vec_and (vector bool short, vector signed short);
13847 vector signed short vec_and (vector signed short, vector bool short);
13848 vector signed short vec_and (vector signed short, vector signed short);
13849 vector unsigned short vec_and (vector bool short,
13850 vector unsigned short);
13851 vector unsigned short vec_and (vector unsigned short,
13852 vector bool short);
13853 vector unsigned short vec_and (vector unsigned short,
13854 vector unsigned short);
13855 vector signed char vec_and (vector bool char, vector signed char);
13856 vector bool char vec_and (vector bool char, vector bool char);
13857 vector signed char vec_and (vector signed char, vector bool char);
13858 vector signed char vec_and (vector signed char, vector signed char);
13859 vector unsigned char vec_and (vector bool char, vector unsigned char);
13860 vector unsigned char vec_and (vector unsigned char, vector bool char);
13861 vector unsigned char vec_and (vector unsigned char,
13862 vector unsigned char);
13863
13864 vector float vec_andc (vector float, vector float);
13865 vector float vec_andc (vector float, vector bool int);
13866 vector float vec_andc (vector bool int, vector float);
13867 vector bool int vec_andc (vector bool int, vector bool int);
13868 vector signed int vec_andc (vector bool int, vector signed int);
13869 vector signed int vec_andc (vector signed int, vector bool int);
13870 vector signed int vec_andc (vector signed int, vector signed int);
13871 vector unsigned int vec_andc (vector bool int, vector unsigned int);
13872 vector unsigned int vec_andc (vector unsigned int, vector bool int);
13873 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
13874 vector bool short vec_andc (vector bool short, vector bool short);
13875 vector signed short vec_andc (vector bool short, vector signed short);
13876 vector signed short vec_andc (vector signed short, vector bool short);
13877 vector signed short vec_andc (vector signed short, vector signed short);
13878 vector unsigned short vec_andc (vector bool short,
13879 vector unsigned short);
13880 vector unsigned short vec_andc (vector unsigned short,
13881 vector bool short);
13882 vector unsigned short vec_andc (vector unsigned short,
13883 vector unsigned short);
13884 vector signed char vec_andc (vector bool char, vector signed char);
13885 vector bool char vec_andc (vector bool char, vector bool char);
13886 vector signed char vec_andc (vector signed char, vector bool char);
13887 vector signed char vec_andc (vector signed char, vector signed char);
13888 vector unsigned char vec_andc (vector bool char, vector unsigned char);
13889 vector unsigned char vec_andc (vector unsigned char, vector bool char);
13890 vector unsigned char vec_andc (vector unsigned char,
13891 vector unsigned char);
13892
13893 vector unsigned char vec_avg (vector unsigned char,
13894 vector unsigned char);
13895 vector signed char vec_avg (vector signed char, vector signed char);
13896 vector unsigned short vec_avg (vector unsigned short,
13897 vector unsigned short);
13898 vector signed short vec_avg (vector signed short, vector signed short);
13899 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
13900 vector signed int vec_avg (vector signed int, vector signed int);
13901
13902 vector signed int vec_vavgsw (vector signed int, vector signed int);
13903
13904 vector unsigned int vec_vavguw (vector unsigned int,
13905 vector unsigned int);
13906
13907 vector signed short vec_vavgsh (vector signed short,
13908 vector signed short);
13909
13910 vector unsigned short vec_vavguh (vector unsigned short,
13911 vector unsigned short);
13912
13913 vector signed char vec_vavgsb (vector signed char, vector signed char);
13914
13915 vector unsigned char vec_vavgub (vector unsigned char,
13916 vector unsigned char);
13917
13918 vector float vec_copysign (vector float);
13919
13920 vector float vec_ceil (vector float);
13921
13922 vector signed int vec_cmpb (vector float, vector float);
13923
13924 vector bool char vec_cmpeq (vector signed char, vector signed char);
13925 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
13926 vector bool short vec_cmpeq (vector signed short, vector signed short);
13927 vector bool short vec_cmpeq (vector unsigned short,
13928 vector unsigned short);
13929 vector bool int vec_cmpeq (vector signed int, vector signed int);
13930 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
13931 vector bool int vec_cmpeq (vector float, vector float);
13932
13933 vector bool int vec_vcmpeqfp (vector float, vector float);
13934
13935 vector bool int vec_vcmpequw (vector signed int, vector signed int);
13936 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
13937
13938 vector bool short vec_vcmpequh (vector signed short,
13939 vector signed short);
13940 vector bool short vec_vcmpequh (vector unsigned short,
13941 vector unsigned short);
13942
13943 vector bool char vec_vcmpequb (vector signed char, vector signed char);
13944 vector bool char vec_vcmpequb (vector unsigned char,
13945 vector unsigned char);
13946
13947 vector bool int vec_cmpge (vector float, vector float);
13948
13949 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
13950 vector bool char vec_cmpgt (vector signed char, vector signed char);
13951 vector bool short vec_cmpgt (vector unsigned short,
13952 vector unsigned short);
13953 vector bool short vec_cmpgt (vector signed short, vector signed short);
13954 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
13955 vector bool int vec_cmpgt (vector signed int, vector signed int);
13956 vector bool int vec_cmpgt (vector float, vector float);
13957
13958 vector bool int vec_vcmpgtfp (vector float, vector float);
13959
13960 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
13961
13962 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
13963
13964 vector bool short vec_vcmpgtsh (vector signed short,
13965 vector signed short);
13966
13967 vector bool short vec_vcmpgtuh (vector unsigned short,
13968 vector unsigned short);
13969
13970 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
13971
13972 vector bool char vec_vcmpgtub (vector unsigned char,
13973 vector unsigned char);
13974
13975 vector bool int vec_cmple (vector float, vector float);
13976
13977 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
13978 vector bool char vec_cmplt (vector signed char, vector signed char);
13979 vector bool short vec_cmplt (vector unsigned short,
13980 vector unsigned short);
13981 vector bool short vec_cmplt (vector signed short, vector signed short);
13982 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
13983 vector bool int vec_cmplt (vector signed int, vector signed int);
13984 vector bool int vec_cmplt (vector float, vector float);
13985
13986 vector float vec_cpsgn (vector float, vector float);
13987
13988 vector float vec_ctf (vector unsigned int, const int);
13989 vector float vec_ctf (vector signed int, const int);
13990 vector double vec_ctf (vector unsigned long, const int);
13991 vector double vec_ctf (vector signed long, const int);
13992
13993 vector float vec_vcfsx (vector signed int, const int);
13994
13995 vector float vec_vcfux (vector unsigned int, const int);
13996
13997 vector signed int vec_cts (vector float, const int);
13998 vector signed long vec_cts (vector double, const int);
13999
14000 vector unsigned int vec_ctu (vector float, const int);
14001 vector unsigned long vec_ctu (vector double, const int);
14002
14003 void vec_dss (const int);
14004
14005 void vec_dssall (void);
14006
14007 void vec_dst (const vector unsigned char *, int, const int);
14008 void vec_dst (const vector signed char *, int, const int);
14009 void vec_dst (const vector bool char *, int, const int);
14010 void vec_dst (const vector unsigned short *, int, const int);
14011 void vec_dst (const vector signed short *, int, const int);
14012 void vec_dst (const vector bool short *, int, const int);
14013 void vec_dst (const vector pixel *, int, const int);
14014 void vec_dst (const vector unsigned int *, int, const int);
14015 void vec_dst (const vector signed int *, int, const int);
14016 void vec_dst (const vector bool int *, int, const int);
14017 void vec_dst (const vector float *, int, const int);
14018 void vec_dst (const unsigned char *, int, const int);
14019 void vec_dst (const signed char *, int, const int);
14020 void vec_dst (const unsigned short *, int, const int);
14021 void vec_dst (const short *, int, const int);
14022 void vec_dst (const unsigned int *, int, const int);
14023 void vec_dst (const int *, int, const int);
14024 void vec_dst (const unsigned long *, int, const int);
14025 void vec_dst (const long *, int, const int);
14026 void vec_dst (const float *, int, const int);
14027
14028 void vec_dstst (const vector unsigned char *, int, const int);
14029 void vec_dstst (const vector signed char *, int, const int);
14030 void vec_dstst (const vector bool char *, int, const int);
14031 void vec_dstst (const vector unsigned short *, int, const int);
14032 void vec_dstst (const vector signed short *, int, const int);
14033 void vec_dstst (const vector bool short *, int, const int);
14034 void vec_dstst (const vector pixel *, int, const int);
14035 void vec_dstst (const vector unsigned int *, int, const int);
14036 void vec_dstst (const vector signed int *, int, const int);
14037 void vec_dstst (const vector bool int *, int, const int);
14038 void vec_dstst (const vector float *, int, const int);
14039 void vec_dstst (const unsigned char *, int, const int);
14040 void vec_dstst (const signed char *, int, const int);
14041 void vec_dstst (const unsigned short *, int, const int);
14042 void vec_dstst (const short *, int, const int);
14043 void vec_dstst (const unsigned int *, int, const int);
14044 void vec_dstst (const int *, int, const int);
14045 void vec_dstst (const unsigned long *, int, const int);
14046 void vec_dstst (const long *, int, const int);
14047 void vec_dstst (const float *, int, const int);
14048
14049 void vec_dststt (const vector unsigned char *, int, const int);
14050 void vec_dststt (const vector signed char *, int, const int);
14051 void vec_dststt (const vector bool char *, int, const int);
14052 void vec_dststt (const vector unsigned short *, int, const int);
14053 void vec_dststt (const vector signed short *, int, const int);
14054 void vec_dststt (const vector bool short *, int, const int);
14055 void vec_dststt (const vector pixel *, int, const int);
14056 void vec_dststt (const vector unsigned int *, int, const int);
14057 void vec_dststt (const vector signed int *, int, const int);
14058 void vec_dststt (const vector bool int *, int, const int);
14059 void vec_dststt (const vector float *, int, const int);
14060 void vec_dststt (const unsigned char *, int, const int);
14061 void vec_dststt (const signed char *, int, const int);
14062 void vec_dststt (const unsigned short *, int, const int);
14063 void vec_dststt (const short *, int, const int);
14064 void vec_dststt (const unsigned int *, int, const int);
14065 void vec_dststt (const int *, int, const int);
14066 void vec_dststt (const unsigned long *, int, const int);
14067 void vec_dststt (const long *, int, const int);
14068 void vec_dststt (const float *, int, const int);
14069
14070 void vec_dstt (const vector unsigned char *, int, const int);
14071 void vec_dstt (const vector signed char *, int, const int);
14072 void vec_dstt (const vector bool char *, int, const int);
14073 void vec_dstt (const vector unsigned short *, int, const int);
14074 void vec_dstt (const vector signed short *, int, const int);
14075 void vec_dstt (const vector bool short *, int, const int);
14076 void vec_dstt (const vector pixel *, int, const int);
14077 void vec_dstt (const vector unsigned int *, int, const int);
14078 void vec_dstt (const vector signed int *, int, const int);
14079 void vec_dstt (const vector bool int *, int, const int);
14080 void vec_dstt (const vector float *, int, const int);
14081 void vec_dstt (const unsigned char *, int, const int);
14082 void vec_dstt (const signed char *, int, const int);
14083 void vec_dstt (const unsigned short *, int, const int);
14084 void vec_dstt (const short *, int, const int);
14085 void vec_dstt (const unsigned int *, int, const int);
14086 void vec_dstt (const int *, int, const int);
14087 void vec_dstt (const unsigned long *, int, const int);
14088 void vec_dstt (const long *, int, const int);
14089 void vec_dstt (const float *, int, const int);
14090
14091 vector float vec_expte (vector float);
14092
14093 vector float vec_floor (vector float);
14094
14095 vector float vec_ld (int, const vector float *);
14096 vector float vec_ld (int, const float *);
14097 vector bool int vec_ld (int, const vector bool int *);
14098 vector signed int vec_ld (int, const vector signed int *);
14099 vector signed int vec_ld (int, const int *);
14100 vector signed int vec_ld (int, const long *);
14101 vector unsigned int vec_ld (int, const vector unsigned int *);
14102 vector unsigned int vec_ld (int, const unsigned int *);
14103 vector unsigned int vec_ld (int, const unsigned long *);
14104 vector bool short vec_ld (int, const vector bool short *);
14105 vector pixel vec_ld (int, const vector pixel *);
14106 vector signed short vec_ld (int, const vector signed short *);
14107 vector signed short vec_ld (int, const short *);
14108 vector unsigned short vec_ld (int, const vector unsigned short *);
14109 vector unsigned short vec_ld (int, const unsigned short *);
14110 vector bool char vec_ld (int, const vector bool char *);
14111 vector signed char vec_ld (int, const vector signed char *);
14112 vector signed char vec_ld (int, const signed char *);
14113 vector unsigned char vec_ld (int, const vector unsigned char *);
14114 vector unsigned char vec_ld (int, const unsigned char *);
14115
14116 vector signed char vec_lde (int, const signed char *);
14117 vector unsigned char vec_lde (int, const unsigned char *);
14118 vector signed short vec_lde (int, const short *);
14119 vector unsigned short vec_lde (int, const unsigned short *);
14120 vector float vec_lde (int, const float *);
14121 vector signed int vec_lde (int, const int *);
14122 vector unsigned int vec_lde (int, const unsigned int *);
14123 vector signed int vec_lde (int, const long *);
14124 vector unsigned int vec_lde (int, const unsigned long *);
14125
14126 vector float vec_lvewx (int, float *);
14127 vector signed int vec_lvewx (int, int *);
14128 vector unsigned int vec_lvewx (int, unsigned int *);
14129 vector signed int vec_lvewx (int, long *);
14130 vector unsigned int vec_lvewx (int, unsigned long *);
14131
14132 vector signed short vec_lvehx (int, short *);
14133 vector unsigned short vec_lvehx (int, unsigned short *);
14134
14135 vector signed char vec_lvebx (int, char *);
14136 vector unsigned char vec_lvebx (int, unsigned char *);
14137
14138 vector float vec_ldl (int, const vector float *);
14139 vector float vec_ldl (int, const float *);
14140 vector bool int vec_ldl (int, const vector bool int *);
14141 vector signed int vec_ldl (int, const vector signed int *);
14142 vector signed int vec_ldl (int, const int *);
14143 vector signed int vec_ldl (int, const long *);
14144 vector unsigned int vec_ldl (int, const vector unsigned int *);
14145 vector unsigned int vec_ldl (int, const unsigned int *);
14146 vector unsigned int vec_ldl (int, const unsigned long *);
14147 vector bool short vec_ldl (int, const vector bool short *);
14148 vector pixel vec_ldl (int, const vector pixel *);
14149 vector signed short vec_ldl (int, const vector signed short *);
14150 vector signed short vec_ldl (int, const short *);
14151 vector unsigned short vec_ldl (int, const vector unsigned short *);
14152 vector unsigned short vec_ldl (int, const unsigned short *);
14153 vector bool char vec_ldl (int, const vector bool char *);
14154 vector signed char vec_ldl (int, const vector signed char *);
14155 vector signed char vec_ldl (int, const signed char *);
14156 vector unsigned char vec_ldl (int, const vector unsigned char *);
14157 vector unsigned char vec_ldl (int, const unsigned char *);
14158
14159 vector float vec_loge (vector float);
14160
14161 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
14162 vector unsigned char vec_lvsl (int, const volatile signed char *);
14163 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
14164 vector unsigned char vec_lvsl (int, const volatile short *);
14165 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
14166 vector unsigned char vec_lvsl (int, const volatile int *);
14167 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
14168 vector unsigned char vec_lvsl (int, const volatile long *);
14169 vector unsigned char vec_lvsl (int, const volatile float *);
14170
14171 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
14172 vector unsigned char vec_lvsr (int, const volatile signed char *);
14173 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
14174 vector unsigned char vec_lvsr (int, const volatile short *);
14175 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
14176 vector unsigned char vec_lvsr (int, const volatile int *);
14177 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
14178 vector unsigned char vec_lvsr (int, const volatile long *);
14179 vector unsigned char vec_lvsr (int, const volatile float *);
14180
14181 vector float vec_madd (vector float, vector float, vector float);
14182
14183 vector signed short vec_madds (vector signed short,
14184 vector signed short,
14185 vector signed short);
14186
14187 vector unsigned char vec_max (vector bool char, vector unsigned char);
14188 vector unsigned char vec_max (vector unsigned char, vector bool char);
14189 vector unsigned char vec_max (vector unsigned char,
14190 vector unsigned char);
14191 vector signed char vec_max (vector bool char, vector signed char);
14192 vector signed char vec_max (vector signed char, vector bool char);
14193 vector signed char vec_max (vector signed char, vector signed char);
14194 vector unsigned short vec_max (vector bool short,
14195 vector unsigned short);
14196 vector unsigned short vec_max (vector unsigned short,
14197 vector bool short);
14198 vector unsigned short vec_max (vector unsigned short,
14199 vector unsigned short);
14200 vector signed short vec_max (vector bool short, vector signed short);
14201 vector signed short vec_max (vector signed short, vector bool short);
14202 vector signed short vec_max (vector signed short, vector signed short);
14203 vector unsigned int vec_max (vector bool int, vector unsigned int);
14204 vector unsigned int vec_max (vector unsigned int, vector bool int);
14205 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
14206 vector signed int vec_max (vector bool int, vector signed int);
14207 vector signed int vec_max (vector signed int, vector bool int);
14208 vector signed int vec_max (vector signed int, vector signed int);
14209 vector float vec_max (vector float, vector float);
14210
14211 vector float vec_vmaxfp (vector float, vector float);
14212
14213 vector signed int vec_vmaxsw (vector bool int, vector signed int);
14214 vector signed int vec_vmaxsw (vector signed int, vector bool int);
14215 vector signed int vec_vmaxsw (vector signed int, vector signed int);
14216
14217 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
14218 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
14219 vector unsigned int vec_vmaxuw (vector unsigned int,
14220 vector unsigned int);
14221
14222 vector signed short vec_vmaxsh (vector bool short, vector signed short);
14223 vector signed short vec_vmaxsh (vector signed short, vector bool short);
14224 vector signed short vec_vmaxsh (vector signed short,
14225 vector signed short);
14226
14227 vector unsigned short vec_vmaxuh (vector bool short,
14228 vector unsigned short);
14229 vector unsigned short vec_vmaxuh (vector unsigned short,
14230 vector bool short);
14231 vector unsigned short vec_vmaxuh (vector unsigned short,
14232 vector unsigned short);
14233
14234 vector signed char vec_vmaxsb (vector bool char, vector signed char);
14235 vector signed char vec_vmaxsb (vector signed char, vector bool char);
14236 vector signed char vec_vmaxsb (vector signed char, vector signed char);
14237
14238 vector unsigned char vec_vmaxub (vector bool char,
14239 vector unsigned char);
14240 vector unsigned char vec_vmaxub (vector unsigned char,
14241 vector bool char);
14242 vector unsigned char vec_vmaxub (vector unsigned char,
14243 vector unsigned char);
14244
14245 vector bool char vec_mergeh (vector bool char, vector bool char);
14246 vector signed char vec_mergeh (vector signed char, vector signed char);
14247 vector unsigned char vec_mergeh (vector unsigned char,
14248 vector unsigned char);
14249 vector bool short vec_mergeh (vector bool short, vector bool short);
14250 vector pixel vec_mergeh (vector pixel, vector pixel);
14251 vector signed short vec_mergeh (vector signed short,
14252 vector signed short);
14253 vector unsigned short vec_mergeh (vector unsigned short,
14254 vector unsigned short);
14255 vector float vec_mergeh (vector float, vector float);
14256 vector bool int vec_mergeh (vector bool int, vector bool int);
14257 vector signed int vec_mergeh (vector signed int, vector signed int);
14258 vector unsigned int vec_mergeh (vector unsigned int,
14259 vector unsigned int);
14260
14261 vector float vec_vmrghw (vector float, vector float);
14262 vector bool int vec_vmrghw (vector bool int, vector bool int);
14263 vector signed int vec_vmrghw (vector signed int, vector signed int);
14264 vector unsigned int vec_vmrghw (vector unsigned int,
14265 vector unsigned int);
14266
14267 vector bool short vec_vmrghh (vector bool short, vector bool short);
14268 vector signed short vec_vmrghh (vector signed short,
14269 vector signed short);
14270 vector unsigned short vec_vmrghh (vector unsigned short,
14271 vector unsigned short);
14272 vector pixel vec_vmrghh (vector pixel, vector pixel);
14273
14274 vector bool char vec_vmrghb (vector bool char, vector bool char);
14275 vector signed char vec_vmrghb (vector signed char, vector signed char);
14276 vector unsigned char vec_vmrghb (vector unsigned char,
14277 vector unsigned char);
14278
14279 vector bool char vec_mergel (vector bool char, vector bool char);
14280 vector signed char vec_mergel (vector signed char, vector signed char);
14281 vector unsigned char vec_mergel (vector unsigned char,
14282 vector unsigned char);
14283 vector bool short vec_mergel (vector bool short, vector bool short);
14284 vector pixel vec_mergel (vector pixel, vector pixel);
14285 vector signed short vec_mergel (vector signed short,
14286 vector signed short);
14287 vector unsigned short vec_mergel (vector unsigned short,
14288 vector unsigned short);
14289 vector float vec_mergel (vector float, vector float);
14290 vector bool int vec_mergel (vector bool int, vector bool int);
14291 vector signed int vec_mergel (vector signed int, vector signed int);
14292 vector unsigned int vec_mergel (vector unsigned int,
14293 vector unsigned int);
14294
14295 vector float vec_vmrglw (vector float, vector float);
14296 vector signed int vec_vmrglw (vector signed int, vector signed int);
14297 vector unsigned int vec_vmrglw (vector unsigned int,
14298 vector unsigned int);
14299 vector bool int vec_vmrglw (vector bool int, vector bool int);
14300
14301 vector bool short vec_vmrglh (vector bool short, vector bool short);
14302 vector signed short vec_vmrglh (vector signed short,
14303 vector signed short);
14304 vector unsigned short vec_vmrglh (vector unsigned short,
14305 vector unsigned short);
14306 vector pixel vec_vmrglh (vector pixel, vector pixel);
14307
14308 vector bool char vec_vmrglb (vector bool char, vector bool char);
14309 vector signed char vec_vmrglb (vector signed char, vector signed char);
14310 vector unsigned char vec_vmrglb (vector unsigned char,
14311 vector unsigned char);
14312
14313 vector unsigned short vec_mfvscr (void);
14314
14315 vector unsigned char vec_min (vector bool char, vector unsigned char);
14316 vector unsigned char vec_min (vector unsigned char, vector bool char);
14317 vector unsigned char vec_min (vector unsigned char,
14318 vector unsigned char);
14319 vector signed char vec_min (vector bool char, vector signed char);
14320 vector signed char vec_min (vector signed char, vector bool char);
14321 vector signed char vec_min (vector signed char, vector signed char);
14322 vector unsigned short vec_min (vector bool short,
14323 vector unsigned short);
14324 vector unsigned short vec_min (vector unsigned short,
14325 vector bool short);
14326 vector unsigned short vec_min (vector unsigned short,
14327 vector unsigned short);
14328 vector signed short vec_min (vector bool short, vector signed short);
14329 vector signed short vec_min (vector signed short, vector bool short);
14330 vector signed short vec_min (vector signed short, vector signed short);
14331 vector unsigned int vec_min (vector bool int, vector unsigned int);
14332 vector unsigned int vec_min (vector unsigned int, vector bool int);
14333 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
14334 vector signed int vec_min (vector bool int, vector signed int);
14335 vector signed int vec_min (vector signed int, vector bool int);
14336 vector signed int vec_min (vector signed int, vector signed int);
14337 vector float vec_min (vector float, vector float);
14338
14339 vector float vec_vminfp (vector float, vector float);
14340
14341 vector signed int vec_vminsw (vector bool int, vector signed int);
14342 vector signed int vec_vminsw (vector signed int, vector bool int);
14343 vector signed int vec_vminsw (vector signed int, vector signed int);
14344
14345 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
14346 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
14347 vector unsigned int vec_vminuw (vector unsigned int,
14348 vector unsigned int);
14349
14350 vector signed short vec_vminsh (vector bool short, vector signed short);
14351 vector signed short vec_vminsh (vector signed short, vector bool short);
14352 vector signed short vec_vminsh (vector signed short,
14353 vector signed short);
14354
14355 vector unsigned short vec_vminuh (vector bool short,
14356 vector unsigned short);
14357 vector unsigned short vec_vminuh (vector unsigned short,
14358 vector bool short);
14359 vector unsigned short vec_vminuh (vector unsigned short,
14360 vector unsigned short);
14361
14362 vector signed char vec_vminsb (vector bool char, vector signed char);
14363 vector signed char vec_vminsb (vector signed char, vector bool char);
14364 vector signed char vec_vminsb (vector signed char, vector signed char);
14365
14366 vector unsigned char vec_vminub (vector bool char,
14367 vector unsigned char);
14368 vector unsigned char vec_vminub (vector unsigned char,
14369 vector bool char);
14370 vector unsigned char vec_vminub (vector unsigned char,
14371 vector unsigned char);
14372
14373 vector signed short vec_mladd (vector signed short,
14374 vector signed short,
14375 vector signed short);
14376 vector signed short vec_mladd (vector signed short,
14377 vector unsigned short,
14378 vector unsigned short);
14379 vector signed short vec_mladd (vector unsigned short,
14380 vector signed short,
14381 vector signed short);
14382 vector unsigned short vec_mladd (vector unsigned short,
14383 vector unsigned short,
14384 vector unsigned short);
14385
14386 vector signed short vec_mradds (vector signed short,
14387 vector signed short,
14388 vector signed short);
14389
14390 vector unsigned int vec_msum (vector unsigned char,
14391 vector unsigned char,
14392 vector unsigned int);
14393 vector signed int vec_msum (vector signed char,
14394 vector unsigned char,
14395 vector signed int);
14396 vector unsigned int vec_msum (vector unsigned short,
14397 vector unsigned short,
14398 vector unsigned int);
14399 vector signed int vec_msum (vector signed short,
14400 vector signed short,
14401 vector signed int);
14402
14403 vector signed int vec_vmsumshm (vector signed short,
14404 vector signed short,
14405 vector signed int);
14406
14407 vector unsigned int vec_vmsumuhm (vector unsigned short,
14408 vector unsigned short,
14409 vector unsigned int);
14410
14411 vector signed int vec_vmsummbm (vector signed char,
14412 vector unsigned char,
14413 vector signed int);
14414
14415 vector unsigned int vec_vmsumubm (vector unsigned char,
14416 vector unsigned char,
14417 vector unsigned int);
14418
14419 vector unsigned int vec_msums (vector unsigned short,
14420 vector unsigned short,
14421 vector unsigned int);
14422 vector signed int vec_msums (vector signed short,
14423 vector signed short,
14424 vector signed int);
14425
14426 vector signed int vec_vmsumshs (vector signed short,
14427 vector signed short,
14428 vector signed int);
14429
14430 vector unsigned int vec_vmsumuhs (vector unsigned short,
14431 vector unsigned short,
14432 vector unsigned int);
14433
14434 void vec_mtvscr (vector signed int);
14435 void vec_mtvscr (vector unsigned int);
14436 void vec_mtvscr (vector bool int);
14437 void vec_mtvscr (vector signed short);
14438 void vec_mtvscr (vector unsigned short);
14439 void vec_mtvscr (vector bool short);
14440 void vec_mtvscr (vector pixel);
14441 void vec_mtvscr (vector signed char);
14442 void vec_mtvscr (vector unsigned char);
14443 void vec_mtvscr (vector bool char);
14444
14445 vector unsigned short vec_mule (vector unsigned char,
14446 vector unsigned char);
14447 vector signed short vec_mule (vector signed char,
14448 vector signed char);
14449 vector unsigned int vec_mule (vector unsigned short,
14450 vector unsigned short);
14451 vector signed int vec_mule (vector signed short, vector signed short);
14452
14453 vector signed int vec_vmulesh (vector signed short,
14454 vector signed short);
14455
14456 vector unsigned int vec_vmuleuh (vector unsigned short,
14457 vector unsigned short);
14458
14459 vector signed short vec_vmulesb (vector signed char,
14460 vector signed char);
14461
14462 vector unsigned short vec_vmuleub (vector unsigned char,
14463 vector unsigned char);
14464
14465 vector unsigned short vec_mulo (vector unsigned char,
14466 vector unsigned char);
14467 vector signed short vec_mulo (vector signed char, vector signed char);
14468 vector unsigned int vec_mulo (vector unsigned short,
14469 vector unsigned short);
14470 vector signed int vec_mulo (vector signed short, vector signed short);
14471
14472 vector signed int vec_vmulosh (vector signed short,
14473 vector signed short);
14474
14475 vector unsigned int vec_vmulouh (vector unsigned short,
14476 vector unsigned short);
14477
14478 vector signed short vec_vmulosb (vector signed char,
14479 vector signed char);
14480
14481 vector unsigned short vec_vmuloub (vector unsigned char,
14482 vector unsigned char);
14483
14484 vector float vec_nmsub (vector float, vector float, vector float);
14485
14486 vector float vec_nor (vector float, vector float);
14487 vector signed int vec_nor (vector signed int, vector signed int);
14488 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
14489 vector bool int vec_nor (vector bool int, vector bool int);
14490 vector signed short vec_nor (vector signed short, vector signed short);
14491 vector unsigned short vec_nor (vector unsigned short,
14492 vector unsigned short);
14493 vector bool short vec_nor (vector bool short, vector bool short);
14494 vector signed char vec_nor (vector signed char, vector signed char);
14495 vector unsigned char vec_nor (vector unsigned char,
14496 vector unsigned char);
14497 vector bool char vec_nor (vector bool char, vector bool char);
14498
14499 vector float vec_or (vector float, vector float);
14500 vector float vec_or (vector float, vector bool int);
14501 vector float vec_or (vector bool int, vector float);
14502 vector bool int vec_or (vector bool int, vector bool int);
14503 vector signed int vec_or (vector bool int, vector signed int);
14504 vector signed int vec_or (vector signed int, vector bool int);
14505 vector signed int vec_or (vector signed int, vector signed int);
14506 vector unsigned int vec_or (vector bool int, vector unsigned int);
14507 vector unsigned int vec_or (vector unsigned int, vector bool int);
14508 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
14509 vector bool short vec_or (vector bool short, vector bool short);
14510 vector signed short vec_or (vector bool short, vector signed short);
14511 vector signed short vec_or (vector signed short, vector bool short);
14512 vector signed short vec_or (vector signed short, vector signed short);
14513 vector unsigned short vec_or (vector bool short, vector unsigned short);
14514 vector unsigned short vec_or (vector unsigned short, vector bool short);
14515 vector unsigned short vec_or (vector unsigned short,
14516 vector unsigned short);
14517 vector signed char vec_or (vector bool char, vector signed char);
14518 vector bool char vec_or (vector bool char, vector bool char);
14519 vector signed char vec_or (vector signed char, vector bool char);
14520 vector signed char vec_or (vector signed char, vector signed char);
14521 vector unsigned char vec_or (vector bool char, vector unsigned char);
14522 vector unsigned char vec_or (vector unsigned char, vector bool char);
14523 vector unsigned char vec_or (vector unsigned char,
14524 vector unsigned char);
14525
14526 vector signed char vec_pack (vector signed short, vector signed short);
14527 vector unsigned char vec_pack (vector unsigned short,
14528 vector unsigned short);
14529 vector bool char vec_pack (vector bool short, vector bool short);
14530 vector signed short vec_pack (vector signed int, vector signed int);
14531 vector unsigned short vec_pack (vector unsigned int,
14532 vector unsigned int);
14533 vector bool short vec_pack (vector bool int, vector bool int);
14534
14535 vector bool short vec_vpkuwum (vector bool int, vector bool int);
14536 vector signed short vec_vpkuwum (vector signed int, vector signed int);
14537 vector unsigned short vec_vpkuwum (vector unsigned int,
14538 vector unsigned int);
14539
14540 vector bool char vec_vpkuhum (vector bool short, vector bool short);
14541 vector signed char vec_vpkuhum (vector signed short,
14542 vector signed short);
14543 vector unsigned char vec_vpkuhum (vector unsigned short,
14544 vector unsigned short);
14545
14546 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
14547
14548 vector unsigned char vec_packs (vector unsigned short,
14549 vector unsigned short);
14550 vector signed char vec_packs (vector signed short, vector signed short);
14551 vector unsigned short vec_packs (vector unsigned int,
14552 vector unsigned int);
14553 vector signed short vec_packs (vector signed int, vector signed int);
14554
14555 vector signed short vec_vpkswss (vector signed int, vector signed int);
14556
14557 vector unsigned short vec_vpkuwus (vector unsigned int,
14558 vector unsigned int);
14559
14560 vector signed char vec_vpkshss (vector signed short,
14561 vector signed short);
14562
14563 vector unsigned char vec_vpkuhus (vector unsigned short,
14564 vector unsigned short);
14565
14566 vector unsigned char vec_packsu (vector unsigned short,
14567 vector unsigned short);
14568 vector unsigned char vec_packsu (vector signed short,
14569 vector signed short);
14570 vector unsigned short vec_packsu (vector unsigned int,
14571 vector unsigned int);
14572 vector unsigned short vec_packsu (vector signed int, vector signed int);
14573
14574 vector unsigned short vec_vpkswus (vector signed int,
14575 vector signed int);
14576
14577 vector unsigned char vec_vpkshus (vector signed short,
14578 vector signed short);
14579
14580 vector float vec_perm (vector float,
14581 vector float,
14582 vector unsigned char);
14583 vector signed int vec_perm (vector signed int,
14584 vector signed int,
14585 vector unsigned char);
14586 vector unsigned int vec_perm (vector unsigned int,
14587 vector unsigned int,
14588 vector unsigned char);
14589 vector bool int vec_perm (vector bool int,
14590 vector bool int,
14591 vector unsigned char);
14592 vector signed short vec_perm (vector signed short,
14593 vector signed short,
14594 vector unsigned char);
14595 vector unsigned short vec_perm (vector unsigned short,
14596 vector unsigned short,
14597 vector unsigned char);
14598 vector bool short vec_perm (vector bool short,
14599 vector bool short,
14600 vector unsigned char);
14601 vector pixel vec_perm (vector pixel,
14602 vector pixel,
14603 vector unsigned char);
14604 vector signed char vec_perm (vector signed char,
14605 vector signed char,
14606 vector unsigned char);
14607 vector unsigned char vec_perm (vector unsigned char,
14608 vector unsigned char,
14609 vector unsigned char);
14610 vector bool char vec_perm (vector bool char,
14611 vector bool char,
14612 vector unsigned char);
14613
14614 vector float vec_re (vector float);
14615
14616 vector signed char vec_rl (vector signed char,
14617 vector unsigned char);
14618 vector unsigned char vec_rl (vector unsigned char,
14619 vector unsigned char);
14620 vector signed short vec_rl (vector signed short, vector unsigned short);
14621 vector unsigned short vec_rl (vector unsigned short,
14622 vector unsigned short);
14623 vector signed int vec_rl (vector signed int, vector unsigned int);
14624 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
14625
14626 vector signed int vec_vrlw (vector signed int, vector unsigned int);
14627 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
14628
14629 vector signed short vec_vrlh (vector signed short,
14630 vector unsigned short);
14631 vector unsigned short vec_vrlh (vector unsigned short,
14632 vector unsigned short);
14633
14634 vector signed char vec_vrlb (vector signed char, vector unsigned char);
14635 vector unsigned char vec_vrlb (vector unsigned char,
14636 vector unsigned char);
14637
14638 vector float vec_round (vector float);
14639
14640 vector float vec_recip (vector float, vector float);
14641
14642 vector float vec_rsqrt (vector float);
14643
14644 vector float vec_rsqrte (vector float);
14645
14646 vector float vec_sel (vector float, vector float, vector bool int);
14647 vector float vec_sel (vector float, vector float, vector unsigned int);
14648 vector signed int vec_sel (vector signed int,
14649 vector signed int,
14650 vector bool int);
14651 vector signed int vec_sel (vector signed int,
14652 vector signed int,
14653 vector unsigned int);
14654 vector unsigned int vec_sel (vector unsigned int,
14655 vector unsigned int,
14656 vector bool int);
14657 vector unsigned int vec_sel (vector unsigned int,
14658 vector unsigned int,
14659 vector unsigned int);
14660 vector bool int vec_sel (vector bool int,
14661 vector bool int,
14662 vector bool int);
14663 vector bool int vec_sel (vector bool int,
14664 vector bool int,
14665 vector unsigned int);
14666 vector signed short vec_sel (vector signed short,
14667 vector signed short,
14668 vector bool short);
14669 vector signed short vec_sel (vector signed short,
14670 vector signed short,
14671 vector unsigned short);
14672 vector unsigned short vec_sel (vector unsigned short,
14673 vector unsigned short,
14674 vector bool short);
14675 vector unsigned short vec_sel (vector unsigned short,
14676 vector unsigned short,
14677 vector unsigned short);
14678 vector bool short vec_sel (vector bool short,
14679 vector bool short,
14680 vector bool short);
14681 vector bool short vec_sel (vector bool short,
14682 vector bool short,
14683 vector unsigned short);
14684 vector signed char vec_sel (vector signed char,
14685 vector signed char,
14686 vector bool char);
14687 vector signed char vec_sel (vector signed char,
14688 vector signed char,
14689 vector unsigned char);
14690 vector unsigned char vec_sel (vector unsigned char,
14691 vector unsigned char,
14692 vector bool char);
14693 vector unsigned char vec_sel (vector unsigned char,
14694 vector unsigned char,
14695 vector unsigned char);
14696 vector bool char vec_sel (vector bool char,
14697 vector bool char,
14698 vector bool char);
14699 vector bool char vec_sel (vector bool char,
14700 vector bool char,
14701 vector unsigned char);
14702
14703 vector signed char vec_sl (vector signed char,
14704 vector unsigned char);
14705 vector unsigned char vec_sl (vector unsigned char,
14706 vector unsigned char);
14707 vector signed short vec_sl (vector signed short, vector unsigned short);
14708 vector unsigned short vec_sl (vector unsigned short,
14709 vector unsigned short);
14710 vector signed int vec_sl (vector signed int, vector unsigned int);
14711 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
14712
14713 vector signed int vec_vslw (vector signed int, vector unsigned int);
14714 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
14715
14716 vector signed short vec_vslh (vector signed short,
14717 vector unsigned short);
14718 vector unsigned short vec_vslh (vector unsigned short,
14719 vector unsigned short);
14720
14721 vector signed char vec_vslb (vector signed char, vector unsigned char);
14722 vector unsigned char vec_vslb (vector unsigned char,
14723 vector unsigned char);
14724
14725 vector float vec_sld (vector float, vector float, const int);
14726 vector signed int vec_sld (vector signed int,
14727 vector signed int,
14728 const int);
14729 vector unsigned int vec_sld (vector unsigned int,
14730 vector unsigned int,
14731 const int);
14732 vector bool int vec_sld (vector bool int,
14733 vector bool int,
14734 const int);
14735 vector signed short vec_sld (vector signed short,
14736 vector signed short,
14737 const int);
14738 vector unsigned short vec_sld (vector unsigned short,
14739 vector unsigned short,
14740 const int);
14741 vector bool short vec_sld (vector bool short,
14742 vector bool short,
14743 const int);
14744 vector pixel vec_sld (vector pixel,
14745 vector pixel,
14746 const int);
14747 vector signed char vec_sld (vector signed char,
14748 vector signed char,
14749 const int);
14750 vector unsigned char vec_sld (vector unsigned char,
14751 vector unsigned char,
14752 const int);
14753 vector bool char vec_sld (vector bool char,
14754 vector bool char,
14755 const int);
14756
14757 vector signed int vec_sll (vector signed int,
14758 vector unsigned int);
14759 vector signed int vec_sll (vector signed int,
14760 vector unsigned short);
14761 vector signed int vec_sll (vector signed int,
14762 vector unsigned char);
14763 vector unsigned int vec_sll (vector unsigned int,
14764 vector unsigned int);
14765 vector unsigned int vec_sll (vector unsigned int,
14766 vector unsigned short);
14767 vector unsigned int vec_sll (vector unsigned int,
14768 vector unsigned char);
14769 vector bool int vec_sll (vector bool int,
14770 vector unsigned int);
14771 vector bool int vec_sll (vector bool int,
14772 vector unsigned short);
14773 vector bool int vec_sll (vector bool int,
14774 vector unsigned char);
14775 vector signed short vec_sll (vector signed short,
14776 vector unsigned int);
14777 vector signed short vec_sll (vector signed short,
14778 vector unsigned short);
14779 vector signed short vec_sll (vector signed short,
14780 vector unsigned char);
14781 vector unsigned short vec_sll (vector unsigned short,
14782 vector unsigned int);
14783 vector unsigned short vec_sll (vector unsigned short,
14784 vector unsigned short);
14785 vector unsigned short vec_sll (vector unsigned short,
14786 vector unsigned char);
14787 vector bool short vec_sll (vector bool short, vector unsigned int);
14788 vector bool short vec_sll (vector bool short, vector unsigned short);
14789 vector bool short vec_sll (vector bool short, vector unsigned char);
14790 vector pixel vec_sll (vector pixel, vector unsigned int);
14791 vector pixel vec_sll (vector pixel, vector unsigned short);
14792 vector pixel vec_sll (vector pixel, vector unsigned char);
14793 vector signed char vec_sll (vector signed char, vector unsigned int);
14794 vector signed char vec_sll (vector signed char, vector unsigned short);
14795 vector signed char vec_sll (vector signed char, vector unsigned char);
14796 vector unsigned char vec_sll (vector unsigned char,
14797 vector unsigned int);
14798 vector unsigned char vec_sll (vector unsigned char,
14799 vector unsigned short);
14800 vector unsigned char vec_sll (vector unsigned char,
14801 vector unsigned char);
14802 vector bool char vec_sll (vector bool char, vector unsigned int);
14803 vector bool char vec_sll (vector bool char, vector unsigned short);
14804 vector bool char vec_sll (vector bool char, vector unsigned char);
14805
14806 vector float vec_slo (vector float, vector signed char);
14807 vector float vec_slo (vector float, vector unsigned char);
14808 vector signed int vec_slo (vector signed int, vector signed char);
14809 vector signed int vec_slo (vector signed int, vector unsigned char);
14810 vector unsigned int vec_slo (vector unsigned int, vector signed char);
14811 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
14812 vector signed short vec_slo (vector signed short, vector signed char);
14813 vector signed short vec_slo (vector signed short, vector unsigned char);
14814 vector unsigned short vec_slo (vector unsigned short,
14815 vector signed char);
14816 vector unsigned short vec_slo (vector unsigned short,
14817 vector unsigned char);
14818 vector pixel vec_slo (vector pixel, vector signed char);
14819 vector pixel vec_slo (vector pixel, vector unsigned char);
14820 vector signed char vec_slo (vector signed char, vector signed char);
14821 vector signed char vec_slo (vector signed char, vector unsigned char);
14822 vector unsigned char vec_slo (vector unsigned char, vector signed char);
14823 vector unsigned char vec_slo (vector unsigned char,
14824 vector unsigned char);
14825
14826 vector signed char vec_splat (vector signed char, const int);
14827 vector unsigned char vec_splat (vector unsigned char, const int);
14828 vector bool char vec_splat (vector bool char, const int);
14829 vector signed short vec_splat (vector signed short, const int);
14830 vector unsigned short vec_splat (vector unsigned short, const int);
14831 vector bool short vec_splat (vector bool short, const int);
14832 vector pixel vec_splat (vector pixel, const int);
14833 vector float vec_splat (vector float, const int);
14834 vector signed int vec_splat (vector signed int, const int);
14835 vector unsigned int vec_splat (vector unsigned int, const int);
14836 vector bool int vec_splat (vector bool int, const int);
14837 vector signed long vec_splat (vector signed long, const int);
14838 vector unsigned long vec_splat (vector unsigned long, const int);
14839
14840 vector signed char vec_splats (signed char);
14841 vector unsigned char vec_splats (unsigned char);
14842 vector signed short vec_splats (signed short);
14843 vector unsigned short vec_splats (unsigned short);
14844 vector signed int vec_splats (signed int);
14845 vector unsigned int vec_splats (unsigned int);
14846 vector float vec_splats (float);
14847
14848 vector float vec_vspltw (vector float, const int);
14849 vector signed int vec_vspltw (vector signed int, const int);
14850 vector unsigned int vec_vspltw (vector unsigned int, const int);
14851 vector bool int vec_vspltw (vector bool int, const int);
14852
14853 vector bool short vec_vsplth (vector bool short, const int);
14854 vector signed short vec_vsplth (vector signed short, const int);
14855 vector unsigned short vec_vsplth (vector unsigned short, const int);
14856 vector pixel vec_vsplth (vector pixel, const int);
14857
14858 vector signed char vec_vspltb (vector signed char, const int);
14859 vector unsigned char vec_vspltb (vector unsigned char, const int);
14860 vector bool char vec_vspltb (vector bool char, const int);
14861
14862 vector signed char vec_splat_s8 (const int);
14863
14864 vector signed short vec_splat_s16 (const int);
14865
14866 vector signed int vec_splat_s32 (const int);
14867
14868 vector unsigned char vec_splat_u8 (const int);
14869
14870 vector unsigned short vec_splat_u16 (const int);
14871
14872 vector unsigned int vec_splat_u32 (const int);
14873
14874 vector signed char vec_sr (vector signed char, vector unsigned char);
14875 vector unsigned char vec_sr (vector unsigned char,
14876 vector unsigned char);
14877 vector signed short vec_sr (vector signed short,
14878 vector unsigned short);
14879 vector unsigned short vec_sr (vector unsigned short,
14880 vector unsigned short);
14881 vector signed int vec_sr (vector signed int, vector unsigned int);
14882 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
14883
14884 vector signed int vec_vsrw (vector signed int, vector unsigned int);
14885 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
14886
14887 vector signed short vec_vsrh (vector signed short,
14888 vector unsigned short);
14889 vector unsigned short vec_vsrh (vector unsigned short,
14890 vector unsigned short);
14891
14892 vector signed char vec_vsrb (vector signed char, vector unsigned char);
14893 vector unsigned char vec_vsrb (vector unsigned char,
14894 vector unsigned char);
14895
14896 vector signed char vec_sra (vector signed char, vector unsigned char);
14897 vector unsigned char vec_sra (vector unsigned char,
14898 vector unsigned char);
14899 vector signed short vec_sra (vector signed short,
14900 vector unsigned short);
14901 vector unsigned short vec_sra (vector unsigned short,
14902 vector unsigned short);
14903 vector signed int vec_sra (vector signed int, vector unsigned int);
14904 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
14905
14906 vector signed int vec_vsraw (vector signed int, vector unsigned int);
14907 vector unsigned int vec_vsraw (vector unsigned int,
14908 vector unsigned int);
14909
14910 vector signed short vec_vsrah (vector signed short,
14911 vector unsigned short);
14912 vector unsigned short vec_vsrah (vector unsigned short,
14913 vector unsigned short);
14914
14915 vector signed char vec_vsrab (vector signed char, vector unsigned char);
14916 vector unsigned char vec_vsrab (vector unsigned char,
14917 vector unsigned char);
14918
14919 vector signed int vec_srl (vector signed int, vector unsigned int);
14920 vector signed int vec_srl (vector signed int, vector unsigned short);
14921 vector signed int vec_srl (vector signed int, vector unsigned char);
14922 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
14923 vector unsigned int vec_srl (vector unsigned int,
14924 vector unsigned short);
14925 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
14926 vector bool int vec_srl (vector bool int, vector unsigned int);
14927 vector bool int vec_srl (vector bool int, vector unsigned short);
14928 vector bool int vec_srl (vector bool int, vector unsigned char);
14929 vector signed short vec_srl (vector signed short, vector unsigned int);
14930 vector signed short vec_srl (vector signed short,
14931 vector unsigned short);
14932 vector signed short vec_srl (vector signed short, vector unsigned char);
14933 vector unsigned short vec_srl (vector unsigned short,
14934 vector unsigned int);
14935 vector unsigned short vec_srl (vector unsigned short,
14936 vector unsigned short);
14937 vector unsigned short vec_srl (vector unsigned short,
14938 vector unsigned char);
14939 vector bool short vec_srl (vector bool short, vector unsigned int);
14940 vector bool short vec_srl (vector bool short, vector unsigned short);
14941 vector bool short vec_srl (vector bool short, vector unsigned char);
14942 vector pixel vec_srl (vector pixel, vector unsigned int);
14943 vector pixel vec_srl (vector pixel, vector unsigned short);
14944 vector pixel vec_srl (vector pixel, vector unsigned char);
14945 vector signed char vec_srl (vector signed char, vector unsigned int);
14946 vector signed char vec_srl (vector signed char, vector unsigned short);
14947 vector signed char vec_srl (vector signed char, vector unsigned char);
14948 vector unsigned char vec_srl (vector unsigned char,
14949 vector unsigned int);
14950 vector unsigned char vec_srl (vector unsigned char,
14951 vector unsigned short);
14952 vector unsigned char vec_srl (vector unsigned char,
14953 vector unsigned char);
14954 vector bool char vec_srl (vector bool char, vector unsigned int);
14955 vector bool char vec_srl (vector bool char, vector unsigned short);
14956 vector bool char vec_srl (vector bool char, vector unsigned char);
14957
14958 vector float vec_sro (vector float, vector signed char);
14959 vector float vec_sro (vector float, vector unsigned char);
14960 vector signed int vec_sro (vector signed int, vector signed char);
14961 vector signed int vec_sro (vector signed int, vector unsigned char);
14962 vector unsigned int vec_sro (vector unsigned int, vector signed char);
14963 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
14964 vector signed short vec_sro (vector signed short, vector signed char);
14965 vector signed short vec_sro (vector signed short, vector unsigned char);
14966 vector unsigned short vec_sro (vector unsigned short,
14967 vector signed char);
14968 vector unsigned short vec_sro (vector unsigned short,
14969 vector unsigned char);
14970 vector pixel vec_sro (vector pixel, vector signed char);
14971 vector pixel vec_sro (vector pixel, vector unsigned char);
14972 vector signed char vec_sro (vector signed char, vector signed char);
14973 vector signed char vec_sro (vector signed char, vector unsigned char);
14974 vector unsigned char vec_sro (vector unsigned char, vector signed char);
14975 vector unsigned char vec_sro (vector unsigned char,
14976 vector unsigned char);
14977
14978 void vec_st (vector float, int, vector float *);
14979 void vec_st (vector float, int, float *);
14980 void vec_st (vector signed int, int, vector signed int *);
14981 void vec_st (vector signed int, int, int *);
14982 void vec_st (vector unsigned int, int, vector unsigned int *);
14983 void vec_st (vector unsigned int, int, unsigned int *);
14984 void vec_st (vector bool int, int, vector bool int *);
14985 void vec_st (vector bool int, int, unsigned int *);
14986 void vec_st (vector bool int, int, int *);
14987 void vec_st (vector signed short, int, vector signed short *);
14988 void vec_st (vector signed short, int, short *);
14989 void vec_st (vector unsigned short, int, vector unsigned short *);
14990 void vec_st (vector unsigned short, int, unsigned short *);
14991 void vec_st (vector bool short, int, vector bool short *);
14992 void vec_st (vector bool short, int, unsigned short *);
14993 void vec_st (vector pixel, int, vector pixel *);
14994 void vec_st (vector pixel, int, unsigned short *);
14995 void vec_st (vector pixel, int, short *);
14996 void vec_st (vector bool short, int, short *);
14997 void vec_st (vector signed char, int, vector signed char *);
14998 void vec_st (vector signed char, int, signed char *);
14999 void vec_st (vector unsigned char, int, vector unsigned char *);
15000 void vec_st (vector unsigned char, int, unsigned char *);
15001 void vec_st (vector bool char, int, vector bool char *);
15002 void vec_st (vector bool char, int, unsigned char *);
15003 void vec_st (vector bool char, int, signed char *);
15004
15005 void vec_ste (vector signed char, int, signed char *);
15006 void vec_ste (vector unsigned char, int, unsigned char *);
15007 void vec_ste (vector bool char, int, signed char *);
15008 void vec_ste (vector bool char, int, unsigned char *);
15009 void vec_ste (vector signed short, int, short *);
15010 void vec_ste (vector unsigned short, int, unsigned short *);
15011 void vec_ste (vector bool short, int, short *);
15012 void vec_ste (vector bool short, int, unsigned short *);
15013 void vec_ste (vector pixel, int, short *);
15014 void vec_ste (vector pixel, int, unsigned short *);
15015 void vec_ste (vector float, int, float *);
15016 void vec_ste (vector signed int, int, int *);
15017 void vec_ste (vector unsigned int, int, unsigned int *);
15018 void vec_ste (vector bool int, int, int *);
15019 void vec_ste (vector bool int, int, unsigned int *);
15020
15021 void vec_stvewx (vector float, int, float *);
15022 void vec_stvewx (vector signed int, int, int *);
15023 void vec_stvewx (vector unsigned int, int, unsigned int *);
15024 void vec_stvewx (vector bool int, int, int *);
15025 void vec_stvewx (vector bool int, int, unsigned int *);
15026
15027 void vec_stvehx (vector signed short, int, short *);
15028 void vec_stvehx (vector unsigned short, int, unsigned short *);
15029 void vec_stvehx (vector bool short, int, short *);
15030 void vec_stvehx (vector bool short, int, unsigned short *);
15031 void vec_stvehx (vector pixel, int, short *);
15032 void vec_stvehx (vector pixel, int, unsigned short *);
15033
15034 void vec_stvebx (vector signed char, int, signed char *);
15035 void vec_stvebx (vector unsigned char, int, unsigned char *);
15036 void vec_stvebx (vector bool char, int, signed char *);
15037 void vec_stvebx (vector bool char, int, unsigned char *);
15038
15039 void vec_stl (vector float, int, vector float *);
15040 void vec_stl (vector float, int, float *);
15041 void vec_stl (vector signed int, int, vector signed int *);
15042 void vec_stl (vector signed int, int, int *);
15043 void vec_stl (vector unsigned int, int, vector unsigned int *);
15044 void vec_stl (vector unsigned int, int, unsigned int *);
15045 void vec_stl (vector bool int, int, vector bool int *);
15046 void vec_stl (vector bool int, int, unsigned int *);
15047 void vec_stl (vector bool int, int, int *);
15048 void vec_stl (vector signed short, int, vector signed short *);
15049 void vec_stl (vector signed short, int, short *);
15050 void vec_stl (vector unsigned short, int, vector unsigned short *);
15051 void vec_stl (vector unsigned short, int, unsigned short *);
15052 void vec_stl (vector bool short, int, vector bool short *);
15053 void vec_stl (vector bool short, int, unsigned short *);
15054 void vec_stl (vector bool short, int, short *);
15055 void vec_stl (vector pixel, int, vector pixel *);
15056 void vec_stl (vector pixel, int, unsigned short *);
15057 void vec_stl (vector pixel, int, short *);
15058 void vec_stl (vector signed char, int, vector signed char *);
15059 void vec_stl (vector signed char, int, signed char *);
15060 void vec_stl (vector unsigned char, int, vector unsigned char *);
15061 void vec_stl (vector unsigned char, int, unsigned char *);
15062 void vec_stl (vector bool char, int, vector bool char *);
15063 void vec_stl (vector bool char, int, unsigned char *);
15064 void vec_stl (vector bool char, int, signed char *);
15065
15066 vector signed char vec_sub (vector bool char, vector signed char);
15067 vector signed char vec_sub (vector signed char, vector bool char);
15068 vector signed char vec_sub (vector signed char, vector signed char);
15069 vector unsigned char vec_sub (vector bool char, vector unsigned char);
15070 vector unsigned char vec_sub (vector unsigned char, vector bool char);
15071 vector unsigned char vec_sub (vector unsigned char,
15072 vector unsigned char);
15073 vector signed short vec_sub (vector bool short, vector signed short);
15074 vector signed short vec_sub (vector signed short, vector bool short);
15075 vector signed short vec_sub (vector signed short, vector signed short);
15076 vector unsigned short vec_sub (vector bool short,
15077 vector unsigned short);
15078 vector unsigned short vec_sub (vector unsigned short,
15079 vector bool short);
15080 vector unsigned short vec_sub (vector unsigned short,
15081 vector unsigned short);
15082 vector signed int vec_sub (vector bool int, vector signed int);
15083 vector signed int vec_sub (vector signed int, vector bool int);
15084 vector signed int vec_sub (vector signed int, vector signed int);
15085 vector unsigned int vec_sub (vector bool int, vector unsigned int);
15086 vector unsigned int vec_sub (vector unsigned int, vector bool int);
15087 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
15088 vector float vec_sub (vector float, vector float);
15089
15090 vector float vec_vsubfp (vector float, vector float);
15091
15092 vector signed int vec_vsubuwm (vector bool int, vector signed int);
15093 vector signed int vec_vsubuwm (vector signed int, vector bool int);
15094 vector signed int vec_vsubuwm (vector signed int, vector signed int);
15095 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
15096 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
15097 vector unsigned int vec_vsubuwm (vector unsigned int,
15098 vector unsigned int);
15099
15100 vector signed short vec_vsubuhm (vector bool short,
15101 vector signed short);
15102 vector signed short vec_vsubuhm (vector signed short,
15103 vector bool short);
15104 vector signed short vec_vsubuhm (vector signed short,
15105 vector signed short);
15106 vector unsigned short vec_vsubuhm (vector bool short,
15107 vector unsigned short);
15108 vector unsigned short vec_vsubuhm (vector unsigned short,
15109 vector bool short);
15110 vector unsigned short vec_vsubuhm (vector unsigned short,
15111 vector unsigned short);
15112
15113 vector signed char vec_vsububm (vector bool char, vector signed char);
15114 vector signed char vec_vsububm (vector signed char, vector bool char);
15115 vector signed char vec_vsububm (vector signed char, vector signed char);
15116 vector unsigned char vec_vsububm (vector bool char,
15117 vector unsigned char);
15118 vector unsigned char vec_vsububm (vector unsigned char,
15119 vector bool char);
15120 vector unsigned char vec_vsububm (vector unsigned char,
15121 vector unsigned char);
15122
15123 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
15124
15125 vector unsigned char vec_subs (vector bool char, vector unsigned char);
15126 vector unsigned char vec_subs (vector unsigned char, vector bool char);
15127 vector unsigned char vec_subs (vector unsigned char,
15128 vector unsigned char);
15129 vector signed char vec_subs (vector bool char, vector signed char);
15130 vector signed char vec_subs (vector signed char, vector bool char);
15131 vector signed char vec_subs (vector signed char, vector signed char);
15132 vector unsigned short vec_subs (vector bool short,
15133 vector unsigned short);
15134 vector unsigned short vec_subs (vector unsigned short,
15135 vector bool short);
15136 vector unsigned short vec_subs (vector unsigned short,
15137 vector unsigned short);
15138 vector signed short vec_subs (vector bool short, vector signed short);
15139 vector signed short vec_subs (vector signed short, vector bool short);
15140 vector signed short vec_subs (vector signed short, vector signed short);
15141 vector unsigned int vec_subs (vector bool int, vector unsigned int);
15142 vector unsigned int vec_subs (vector unsigned int, vector bool int);
15143 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
15144 vector signed int vec_subs (vector bool int, vector signed int);
15145 vector signed int vec_subs (vector signed int, vector bool int);
15146 vector signed int vec_subs (vector signed int, vector signed int);
15147
15148 vector signed int vec_vsubsws (vector bool int, vector signed int);
15149 vector signed int vec_vsubsws (vector signed int, vector bool int);
15150 vector signed int vec_vsubsws (vector signed int, vector signed int);
15151
15152 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
15153 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
15154 vector unsigned int vec_vsubuws (vector unsigned int,
15155 vector unsigned int);
15156
15157 vector signed short vec_vsubshs (vector bool short,
15158 vector signed short);
15159 vector signed short vec_vsubshs (vector signed short,
15160 vector bool short);
15161 vector signed short vec_vsubshs (vector signed short,
15162 vector signed short);
15163
15164 vector unsigned short vec_vsubuhs (vector bool short,
15165 vector unsigned short);
15166 vector unsigned short vec_vsubuhs (vector unsigned short,
15167 vector bool short);
15168 vector unsigned short vec_vsubuhs (vector unsigned short,
15169 vector unsigned short);
15170
15171 vector signed char vec_vsubsbs (vector bool char, vector signed char);
15172 vector signed char vec_vsubsbs (vector signed char, vector bool char);
15173 vector signed char vec_vsubsbs (vector signed char, vector signed char);
15174
15175 vector unsigned char vec_vsububs (vector bool char,
15176 vector unsigned char);
15177 vector unsigned char vec_vsububs (vector unsigned char,
15178 vector bool char);
15179 vector unsigned char vec_vsububs (vector unsigned char,
15180 vector unsigned char);
15181
15182 vector unsigned int vec_sum4s (vector unsigned char,
15183 vector unsigned int);
15184 vector signed int vec_sum4s (vector signed char, vector signed int);
15185 vector signed int vec_sum4s (vector signed short, vector signed int);
15186
15187 vector signed int vec_vsum4shs (vector signed short, vector signed int);
15188
15189 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
15190
15191 vector unsigned int vec_vsum4ubs (vector unsigned char,
15192 vector unsigned int);
15193
15194 vector signed int vec_sum2s (vector signed int, vector signed int);
15195
15196 vector signed int vec_sums (vector signed int, vector signed int);
15197
15198 vector float vec_trunc (vector float);
15199
15200 vector signed short vec_unpackh (vector signed char);
15201 vector bool short vec_unpackh (vector bool char);
15202 vector signed int vec_unpackh (vector signed short);
15203 vector bool int vec_unpackh (vector bool short);
15204 vector unsigned int vec_unpackh (vector pixel);
15205
15206 vector bool int vec_vupkhsh (vector bool short);
15207 vector signed int vec_vupkhsh (vector signed short);
15208
15209 vector unsigned int vec_vupkhpx (vector pixel);
15210
15211 vector bool short vec_vupkhsb (vector bool char);
15212 vector signed short vec_vupkhsb (vector signed char);
15213
15214 vector signed short vec_unpackl (vector signed char);
15215 vector bool short vec_unpackl (vector bool char);
15216 vector unsigned int vec_unpackl (vector pixel);
15217 vector signed int vec_unpackl (vector signed short);
15218 vector bool int vec_unpackl (vector bool short);
15219
15220 vector unsigned int vec_vupklpx (vector pixel);
15221
15222 vector bool int vec_vupklsh (vector bool short);
15223 vector signed int vec_vupklsh (vector signed short);
15224
15225 vector bool short vec_vupklsb (vector bool char);
15226 vector signed short vec_vupklsb (vector signed char);
15227
15228 vector float vec_xor (vector float, vector float);
15229 vector float vec_xor (vector float, vector bool int);
15230 vector float vec_xor (vector bool int, vector float);
15231 vector bool int vec_xor (vector bool int, vector bool int);
15232 vector signed int vec_xor (vector bool int, vector signed int);
15233 vector signed int vec_xor (vector signed int, vector bool int);
15234 vector signed int vec_xor (vector signed int, vector signed int);
15235 vector unsigned int vec_xor (vector bool int, vector unsigned int);
15236 vector unsigned int vec_xor (vector unsigned int, vector bool int);
15237 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
15238 vector bool short vec_xor (vector bool short, vector bool short);
15239 vector signed short vec_xor (vector bool short, vector signed short);
15240 vector signed short vec_xor (vector signed short, vector bool short);
15241 vector signed short vec_xor (vector signed short, vector signed short);
15242 vector unsigned short vec_xor (vector bool short,
15243 vector unsigned short);
15244 vector unsigned short vec_xor (vector unsigned short,
15245 vector bool short);
15246 vector unsigned short vec_xor (vector unsigned short,
15247 vector unsigned short);
15248 vector signed char vec_xor (vector bool char, vector signed char);
15249 vector bool char vec_xor (vector bool char, vector bool char);
15250 vector signed char vec_xor (vector signed char, vector bool char);
15251 vector signed char vec_xor (vector signed char, vector signed char);
15252 vector unsigned char vec_xor (vector bool char, vector unsigned char);
15253 vector unsigned char vec_xor (vector unsigned char, vector bool char);
15254 vector unsigned char vec_xor (vector unsigned char,
15255 vector unsigned char);
15256
15257 int vec_all_eq (vector signed char, vector bool char);
15258 int vec_all_eq (vector signed char, vector signed char);
15259 int vec_all_eq (vector unsigned char, vector bool char);
15260 int vec_all_eq (vector unsigned char, vector unsigned char);
15261 int vec_all_eq (vector bool char, vector bool char);
15262 int vec_all_eq (vector bool char, vector unsigned char);
15263 int vec_all_eq (vector bool char, vector signed char);
15264 int vec_all_eq (vector signed short, vector bool short);
15265 int vec_all_eq (vector signed short, vector signed short);
15266 int vec_all_eq (vector unsigned short, vector bool short);
15267 int vec_all_eq (vector unsigned short, vector unsigned short);
15268 int vec_all_eq (vector bool short, vector bool short);
15269 int vec_all_eq (vector bool short, vector unsigned short);
15270 int vec_all_eq (vector bool short, vector signed short);
15271 int vec_all_eq (vector pixel, vector pixel);
15272 int vec_all_eq (vector signed int, vector bool int);
15273 int vec_all_eq (vector signed int, vector signed int);
15274 int vec_all_eq (vector unsigned int, vector bool int);
15275 int vec_all_eq (vector unsigned int, vector unsigned int);
15276 int vec_all_eq (vector bool int, vector bool int);
15277 int vec_all_eq (vector bool int, vector unsigned int);
15278 int vec_all_eq (vector bool int, vector signed int);
15279 int vec_all_eq (vector float, vector float);
15280
15281 int vec_all_ge (vector bool char, vector unsigned char);
15282 int vec_all_ge (vector unsigned char, vector bool char);
15283 int vec_all_ge (vector unsigned char, vector unsigned char);
15284 int vec_all_ge (vector bool char, vector signed char);
15285 int vec_all_ge (vector signed char, vector bool char);
15286 int vec_all_ge (vector signed char, vector signed char);
15287 int vec_all_ge (vector bool short, vector unsigned short);
15288 int vec_all_ge (vector unsigned short, vector bool short);
15289 int vec_all_ge (vector unsigned short, vector unsigned short);
15290 int vec_all_ge (vector signed short, vector signed short);
15291 int vec_all_ge (vector bool short, vector signed short);
15292 int vec_all_ge (vector signed short, vector bool short);
15293 int vec_all_ge (vector bool int, vector unsigned int);
15294 int vec_all_ge (vector unsigned int, vector bool int);
15295 int vec_all_ge (vector unsigned int, vector unsigned int);
15296 int vec_all_ge (vector bool int, vector signed int);
15297 int vec_all_ge (vector signed int, vector bool int);
15298 int vec_all_ge (vector signed int, vector signed int);
15299 int vec_all_ge (vector float, vector float);
15300
15301 int vec_all_gt (vector bool char, vector unsigned char);
15302 int vec_all_gt (vector unsigned char, vector bool char);
15303 int vec_all_gt (vector unsigned char, vector unsigned char);
15304 int vec_all_gt (vector bool char, vector signed char);
15305 int vec_all_gt (vector signed char, vector bool char);
15306 int vec_all_gt (vector signed char, vector signed char);
15307 int vec_all_gt (vector bool short, vector unsigned short);
15308 int vec_all_gt (vector unsigned short, vector bool short);
15309 int vec_all_gt (vector unsigned short, vector unsigned short);
15310 int vec_all_gt (vector bool short, vector signed short);
15311 int vec_all_gt (vector signed short, vector bool short);
15312 int vec_all_gt (vector signed short, vector signed short);
15313 int vec_all_gt (vector bool int, vector unsigned int);
15314 int vec_all_gt (vector unsigned int, vector bool int);
15315 int vec_all_gt (vector unsigned int, vector unsigned int);
15316 int vec_all_gt (vector bool int, vector signed int);
15317 int vec_all_gt (vector signed int, vector bool int);
15318 int vec_all_gt (vector signed int, vector signed int);
15319 int vec_all_gt (vector float, vector float);
15320
15321 int vec_all_in (vector float, vector float);
15322
15323 int vec_all_le (vector bool char, vector unsigned char);
15324 int vec_all_le (vector unsigned char, vector bool char);
15325 int vec_all_le (vector unsigned char, vector unsigned char);
15326 int vec_all_le (vector bool char, vector signed char);
15327 int vec_all_le (vector signed char, vector bool char);
15328 int vec_all_le (vector signed char, vector signed char);
15329 int vec_all_le (vector bool short, vector unsigned short);
15330 int vec_all_le (vector unsigned short, vector bool short);
15331 int vec_all_le (vector unsigned short, vector unsigned short);
15332 int vec_all_le (vector bool short, vector signed short);
15333 int vec_all_le (vector signed short, vector bool short);
15334 int vec_all_le (vector signed short, vector signed short);
15335 int vec_all_le (vector bool int, vector unsigned int);
15336 int vec_all_le (vector unsigned int, vector bool int);
15337 int vec_all_le (vector unsigned int, vector unsigned int);
15338 int vec_all_le (vector bool int, vector signed int);
15339 int vec_all_le (vector signed int, vector bool int);
15340 int vec_all_le (vector signed int, vector signed int);
15341 int vec_all_le (vector float, vector float);
15342
15343 int vec_all_lt (vector bool char, vector unsigned char);
15344 int vec_all_lt (vector unsigned char, vector bool char);
15345 int vec_all_lt (vector unsigned char, vector unsigned char);
15346 int vec_all_lt (vector bool char, vector signed char);
15347 int vec_all_lt (vector signed char, vector bool char);
15348 int vec_all_lt (vector signed char, vector signed char);
15349 int vec_all_lt (vector bool short, vector unsigned short);
15350 int vec_all_lt (vector unsigned short, vector bool short);
15351 int vec_all_lt (vector unsigned short, vector unsigned short);
15352 int vec_all_lt (vector bool short, vector signed short);
15353 int vec_all_lt (vector signed short, vector bool short);
15354 int vec_all_lt (vector signed short, vector signed short);
15355 int vec_all_lt (vector bool int, vector unsigned int);
15356 int vec_all_lt (vector unsigned int, vector bool int);
15357 int vec_all_lt (vector unsigned int, vector unsigned int);
15358 int vec_all_lt (vector bool int, vector signed int);
15359 int vec_all_lt (vector signed int, vector bool int);
15360 int vec_all_lt (vector signed int, vector signed int);
15361 int vec_all_lt (vector float, vector float);
15362
15363 int vec_all_nan (vector float);
15364
15365 int vec_all_ne (vector signed char, vector bool char);
15366 int vec_all_ne (vector signed char, vector signed char);
15367 int vec_all_ne (vector unsigned char, vector bool char);
15368 int vec_all_ne (vector unsigned char, vector unsigned char);
15369 int vec_all_ne (vector bool char, vector bool char);
15370 int vec_all_ne (vector bool char, vector unsigned char);
15371 int vec_all_ne (vector bool char, vector signed char);
15372 int vec_all_ne (vector signed short, vector bool short);
15373 int vec_all_ne (vector signed short, vector signed short);
15374 int vec_all_ne (vector unsigned short, vector bool short);
15375 int vec_all_ne (vector unsigned short, vector unsigned short);
15376 int vec_all_ne (vector bool short, vector bool short);
15377 int vec_all_ne (vector bool short, vector unsigned short);
15378 int vec_all_ne (vector bool short, vector signed short);
15379 int vec_all_ne (vector pixel, vector pixel);
15380 int vec_all_ne (vector signed int, vector bool int);
15381 int vec_all_ne (vector signed int, vector signed int);
15382 int vec_all_ne (vector unsigned int, vector bool int);
15383 int vec_all_ne (vector unsigned int, vector unsigned int);
15384 int vec_all_ne (vector bool int, vector bool int);
15385 int vec_all_ne (vector bool int, vector unsigned int);
15386 int vec_all_ne (vector bool int, vector signed int);
15387 int vec_all_ne (vector float, vector float);
15388
15389 int vec_all_nge (vector float, vector float);
15390
15391 int vec_all_ngt (vector float, vector float);
15392
15393 int vec_all_nle (vector float, vector float);
15394
15395 int vec_all_nlt (vector float, vector float);
15396
15397 int vec_all_numeric (vector float);
15398
15399 int vec_any_eq (vector signed char, vector bool char);
15400 int vec_any_eq (vector signed char, vector signed char);
15401 int vec_any_eq (vector unsigned char, vector bool char);
15402 int vec_any_eq (vector unsigned char, vector unsigned char);
15403 int vec_any_eq (vector bool char, vector bool char);
15404 int vec_any_eq (vector bool char, vector unsigned char);
15405 int vec_any_eq (vector bool char, vector signed char);
15406 int vec_any_eq (vector signed short, vector bool short);
15407 int vec_any_eq (vector signed short, vector signed short);
15408 int vec_any_eq (vector unsigned short, vector bool short);
15409 int vec_any_eq (vector unsigned short, vector unsigned short);
15410 int vec_any_eq (vector bool short, vector bool short);
15411 int vec_any_eq (vector bool short, vector unsigned short);
15412 int vec_any_eq (vector bool short, vector signed short);
15413 int vec_any_eq (vector pixel, vector pixel);
15414 int vec_any_eq (vector signed int, vector bool int);
15415 int vec_any_eq (vector signed int, vector signed int);
15416 int vec_any_eq (vector unsigned int, vector bool int);
15417 int vec_any_eq (vector unsigned int, vector unsigned int);
15418 int vec_any_eq (vector bool int, vector bool int);
15419 int vec_any_eq (vector bool int, vector unsigned int);
15420 int vec_any_eq (vector bool int, vector signed int);
15421 int vec_any_eq (vector float, vector float);
15422
15423 int vec_any_ge (vector signed char, vector bool char);
15424 int vec_any_ge (vector unsigned char, vector bool char);
15425 int vec_any_ge (vector unsigned char, vector unsigned char);
15426 int vec_any_ge (vector signed char, vector signed char);
15427 int vec_any_ge (vector bool char, vector unsigned char);
15428 int vec_any_ge (vector bool char, vector signed char);
15429 int vec_any_ge (vector unsigned short, vector bool short);
15430 int vec_any_ge (vector unsigned short, vector unsigned short);
15431 int vec_any_ge (vector signed short, vector signed short);
15432 int vec_any_ge (vector signed short, vector bool short);
15433 int vec_any_ge (vector bool short, vector unsigned short);
15434 int vec_any_ge (vector bool short, vector signed short);
15435 int vec_any_ge (vector signed int, vector bool int);
15436 int vec_any_ge (vector unsigned int, vector bool int);
15437 int vec_any_ge (vector unsigned int, vector unsigned int);
15438 int vec_any_ge (vector signed int, vector signed int);
15439 int vec_any_ge (vector bool int, vector unsigned int);
15440 int vec_any_ge (vector bool int, vector signed int);
15441 int vec_any_ge (vector float, vector float);
15442
15443 int vec_any_gt (vector bool char, vector unsigned char);
15444 int vec_any_gt (vector unsigned char, vector bool char);
15445 int vec_any_gt (vector unsigned char, vector unsigned char);
15446 int vec_any_gt (vector bool char, vector signed char);
15447 int vec_any_gt (vector signed char, vector bool char);
15448 int vec_any_gt (vector signed char, vector signed char);
15449 int vec_any_gt (vector bool short, vector unsigned short);
15450 int vec_any_gt (vector unsigned short, vector bool short);
15451 int vec_any_gt (vector unsigned short, vector unsigned short);
15452 int vec_any_gt (vector bool short, vector signed short);
15453 int vec_any_gt (vector signed short, vector bool short);
15454 int vec_any_gt (vector signed short, vector signed short);
15455 int vec_any_gt (vector bool int, vector unsigned int);
15456 int vec_any_gt (vector unsigned int, vector bool int);
15457 int vec_any_gt (vector unsigned int, vector unsigned int);
15458 int vec_any_gt (vector bool int, vector signed int);
15459 int vec_any_gt (vector signed int, vector bool int);
15460 int vec_any_gt (vector signed int, vector signed int);
15461 int vec_any_gt (vector float, vector float);
15462
15463 int vec_any_le (vector bool char, vector unsigned char);
15464 int vec_any_le (vector unsigned char, vector bool char);
15465 int vec_any_le (vector unsigned char, vector unsigned char);
15466 int vec_any_le (vector bool char, vector signed char);
15467 int vec_any_le (vector signed char, vector bool char);
15468 int vec_any_le (vector signed char, vector signed char);
15469 int vec_any_le (vector bool short, vector unsigned short);
15470 int vec_any_le (vector unsigned short, vector bool short);
15471 int vec_any_le (vector unsigned short, vector unsigned short);
15472 int vec_any_le (vector bool short, vector signed short);
15473 int vec_any_le (vector signed short, vector bool short);
15474 int vec_any_le (vector signed short, vector signed short);
15475 int vec_any_le (vector bool int, vector unsigned int);
15476 int vec_any_le (vector unsigned int, vector bool int);
15477 int vec_any_le (vector unsigned int, vector unsigned int);
15478 int vec_any_le (vector bool int, vector signed int);
15479 int vec_any_le (vector signed int, vector bool int);
15480 int vec_any_le (vector signed int, vector signed int);
15481 int vec_any_le (vector float, vector float);
15482
15483 int vec_any_lt (vector bool char, vector unsigned char);
15484 int vec_any_lt (vector unsigned char, vector bool char);
15485 int vec_any_lt (vector unsigned char, vector unsigned char);
15486 int vec_any_lt (vector bool char, vector signed char);
15487 int vec_any_lt (vector signed char, vector bool char);
15488 int vec_any_lt (vector signed char, vector signed char);
15489 int vec_any_lt (vector bool short, vector unsigned short);
15490 int vec_any_lt (vector unsigned short, vector bool short);
15491 int vec_any_lt (vector unsigned short, vector unsigned short);
15492 int vec_any_lt (vector bool short, vector signed short);
15493 int vec_any_lt (vector signed short, vector bool short);
15494 int vec_any_lt (vector signed short, vector signed short);
15495 int vec_any_lt (vector bool int, vector unsigned int);
15496 int vec_any_lt (vector unsigned int, vector bool int);
15497 int vec_any_lt (vector unsigned int, vector unsigned int);
15498 int vec_any_lt (vector bool int, vector signed int);
15499 int vec_any_lt (vector signed int, vector bool int);
15500 int vec_any_lt (vector signed int, vector signed int);
15501 int vec_any_lt (vector float, vector float);
15502
15503 int vec_any_nan (vector float);
15504
15505 int vec_any_ne (vector signed char, vector bool char);
15506 int vec_any_ne (vector signed char, vector signed char);
15507 int vec_any_ne (vector unsigned char, vector bool char);
15508 int vec_any_ne (vector unsigned char, vector unsigned char);
15509 int vec_any_ne (vector bool char, vector bool char);
15510 int vec_any_ne (vector bool char, vector unsigned char);
15511 int vec_any_ne (vector bool char, vector signed char);
15512 int vec_any_ne (vector signed short, vector bool short);
15513 int vec_any_ne (vector signed short, vector signed short);
15514 int vec_any_ne (vector unsigned short, vector bool short);
15515 int vec_any_ne (vector unsigned short, vector unsigned short);
15516 int vec_any_ne (vector bool short, vector bool short);
15517 int vec_any_ne (vector bool short, vector unsigned short);
15518 int vec_any_ne (vector bool short, vector signed short);
15519 int vec_any_ne (vector pixel, vector pixel);
15520 int vec_any_ne (vector signed int, vector bool int);
15521 int vec_any_ne (vector signed int, vector signed int);
15522 int vec_any_ne (vector unsigned int, vector bool int);
15523 int vec_any_ne (vector unsigned int, vector unsigned int);
15524 int vec_any_ne (vector bool int, vector bool int);
15525 int vec_any_ne (vector bool int, vector unsigned int);
15526 int vec_any_ne (vector bool int, vector signed int);
15527 int vec_any_ne (vector float, vector float);
15528
15529 int vec_any_nge (vector float, vector float);
15530
15531 int vec_any_ngt (vector float, vector float);
15532
15533 int vec_any_nle (vector float, vector float);
15534
15535 int vec_any_nlt (vector float, vector float);
15536
15537 int vec_any_numeric (vector float);
15538
15539 int vec_any_out (vector float, vector float);
15540 @end smallexample
15541
15542 If the vector/scalar (VSX) instruction set is available, the following
15543 additional functions are available:
15544
15545 @smallexample
15546 vector double vec_abs (vector double);
15547 vector double vec_add (vector double, vector double);
15548 vector double vec_and (vector double, vector double);
15549 vector double vec_and (vector double, vector bool long);
15550 vector double vec_and (vector bool long, vector double);
15551 vector long vec_and (vector long, vector long);
15552 vector long vec_and (vector long, vector bool long);
15553 vector long vec_and (vector bool long, vector long);
15554 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
15555 vector unsigned long vec_and (vector unsigned long, vector bool long);
15556 vector unsigned long vec_and (vector bool long, vector unsigned long);
15557 vector double vec_andc (vector double, vector double);
15558 vector double vec_andc (vector double, vector bool long);
15559 vector double vec_andc (vector bool long, vector double);
15560 vector long vec_andc (vector long, vector long);
15561 vector long vec_andc (vector long, vector bool long);
15562 vector long vec_andc (vector bool long, vector long);
15563 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
15564 vector unsigned long vec_andc (vector unsigned long, vector bool long);
15565 vector unsigned long vec_andc (vector bool long, vector unsigned long);
15566 vector double vec_ceil (vector double);
15567 vector bool long vec_cmpeq (vector double, vector double);
15568 vector bool long vec_cmpge (vector double, vector double);
15569 vector bool long vec_cmpgt (vector double, vector double);
15570 vector bool long vec_cmple (vector double, vector double);
15571 vector bool long vec_cmplt (vector double, vector double);
15572 vector double vec_cpsgn (vector double, vector double);
15573 vector float vec_div (vector float, vector float);
15574 vector double vec_div (vector double, vector double);
15575 vector long vec_div (vector long, vector long);
15576 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
15577 vector double vec_floor (vector double);
15578 vector double vec_ld (int, const vector double *);
15579 vector double vec_ld (int, const double *);
15580 vector double vec_ldl (int, const vector double *);
15581 vector double vec_ldl (int, const double *);
15582 vector unsigned char vec_lvsl (int, const volatile double *);
15583 vector unsigned char vec_lvsr (int, const volatile double *);
15584 vector double vec_madd (vector double, vector double, vector double);
15585 vector double vec_max (vector double, vector double);
15586 vector signed long vec_mergeh (vector signed long, vector signed long);
15587 vector signed long vec_mergeh (vector signed long, vector bool long);
15588 vector signed long vec_mergeh (vector bool long, vector signed long);
15589 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
15590 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
15591 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
15592 vector signed long vec_mergel (vector signed long, vector signed long);
15593 vector signed long vec_mergel (vector signed long, vector bool long);
15594 vector signed long vec_mergel (vector bool long, vector signed long);
15595 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
15596 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
15597 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
15598 vector double vec_min (vector double, vector double);
15599 vector float vec_msub (vector float, vector float, vector float);
15600 vector double vec_msub (vector double, vector double, vector double);
15601 vector float vec_mul (vector float, vector float);
15602 vector double vec_mul (vector double, vector double);
15603 vector long vec_mul (vector long, vector long);
15604 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
15605 vector float vec_nearbyint (vector float);
15606 vector double vec_nearbyint (vector double);
15607 vector float vec_nmadd (vector float, vector float, vector float);
15608 vector double vec_nmadd (vector double, vector double, vector double);
15609 vector double vec_nmsub (vector double, vector double, vector double);
15610 vector double vec_nor (vector double, vector double);
15611 vector long vec_nor (vector long, vector long);
15612 vector long vec_nor (vector long, vector bool long);
15613 vector long vec_nor (vector bool long, vector long);
15614 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
15615 vector unsigned long vec_nor (vector unsigned long, vector bool long);
15616 vector unsigned long vec_nor (vector bool long, vector unsigned long);
15617 vector double vec_or (vector double, vector double);
15618 vector double vec_or (vector double, vector bool long);
15619 vector double vec_or (vector bool long, vector double);
15620 vector long vec_or (vector long, vector long);
15621 vector long vec_or (vector long, vector bool long);
15622 vector long vec_or (vector bool long, vector long);
15623 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
15624 vector unsigned long vec_or (vector unsigned long, vector bool long);
15625 vector unsigned long vec_or (vector bool long, vector unsigned long);
15626 vector double vec_perm (vector double, vector double, vector unsigned char);
15627 vector long vec_perm (vector long, vector long, vector unsigned char);
15628 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
15629 vector unsigned char);
15630 vector double vec_rint (vector double);
15631 vector double vec_recip (vector double, vector double);
15632 vector double vec_rsqrt (vector double);
15633 vector double vec_rsqrte (vector double);
15634 vector double vec_sel (vector double, vector double, vector bool long);
15635 vector double vec_sel (vector double, vector double, vector unsigned long);
15636 vector long vec_sel (vector long, vector long, vector long);
15637 vector long vec_sel (vector long, vector long, vector unsigned long);
15638 vector long vec_sel (vector long, vector long, vector bool long);
15639 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15640 vector long);
15641 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15642 vector unsigned long);
15643 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
15644 vector bool long);
15645 vector double vec_splats (double);
15646 vector signed long vec_splats (signed long);
15647 vector unsigned long vec_splats (unsigned long);
15648 vector float vec_sqrt (vector float);
15649 vector double vec_sqrt (vector double);
15650 void vec_st (vector double, int, vector double *);
15651 void vec_st (vector double, int, double *);
15652 vector double vec_sub (vector double, vector double);
15653 vector double vec_trunc (vector double);
15654 vector double vec_xor (vector double, vector double);
15655 vector double vec_xor (vector double, vector bool long);
15656 vector double vec_xor (vector bool long, vector double);
15657 vector long vec_xor (vector long, vector long);
15658 vector long vec_xor (vector long, vector bool long);
15659 vector long vec_xor (vector bool long, vector long);
15660 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
15661 vector unsigned long vec_xor (vector unsigned long, vector bool long);
15662 vector unsigned long vec_xor (vector bool long, vector unsigned long);
15663 int vec_all_eq (vector double, vector double);
15664 int vec_all_ge (vector double, vector double);
15665 int vec_all_gt (vector double, vector double);
15666 int vec_all_le (vector double, vector double);
15667 int vec_all_lt (vector double, vector double);
15668 int vec_all_nan (vector double);
15669 int vec_all_ne (vector double, vector double);
15670 int vec_all_nge (vector double, vector double);
15671 int vec_all_ngt (vector double, vector double);
15672 int vec_all_nle (vector double, vector double);
15673 int vec_all_nlt (vector double, vector double);
15674 int vec_all_numeric (vector double);
15675 int vec_any_eq (vector double, vector double);
15676 int vec_any_ge (vector double, vector double);
15677 int vec_any_gt (vector double, vector double);
15678 int vec_any_le (vector double, vector double);
15679 int vec_any_lt (vector double, vector double);
15680 int vec_any_nan (vector double);
15681 int vec_any_ne (vector double, vector double);
15682 int vec_any_nge (vector double, vector double);
15683 int vec_any_ngt (vector double, vector double);
15684 int vec_any_nle (vector double, vector double);
15685 int vec_any_nlt (vector double, vector double);
15686 int vec_any_numeric (vector double);
15687
15688 vector double vec_vsx_ld (int, const vector double *);
15689 vector double vec_vsx_ld (int, const double *);
15690 vector float vec_vsx_ld (int, const vector float *);
15691 vector float vec_vsx_ld (int, const float *);
15692 vector bool int vec_vsx_ld (int, const vector bool int *);
15693 vector signed int vec_vsx_ld (int, const vector signed int *);
15694 vector signed int vec_vsx_ld (int, const int *);
15695 vector signed int vec_vsx_ld (int, const long *);
15696 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
15697 vector unsigned int vec_vsx_ld (int, const unsigned int *);
15698 vector unsigned int vec_vsx_ld (int, const unsigned long *);
15699 vector bool short vec_vsx_ld (int, const vector bool short *);
15700 vector pixel vec_vsx_ld (int, const vector pixel *);
15701 vector signed short vec_vsx_ld (int, const vector signed short *);
15702 vector signed short vec_vsx_ld (int, const short *);
15703 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
15704 vector unsigned short vec_vsx_ld (int, const unsigned short *);
15705 vector bool char vec_vsx_ld (int, const vector bool char *);
15706 vector signed char vec_vsx_ld (int, const vector signed char *);
15707 vector signed char vec_vsx_ld (int, const signed char *);
15708 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
15709 vector unsigned char vec_vsx_ld (int, const unsigned char *);
15710
15711 void vec_vsx_st (vector double, int, vector double *);
15712 void vec_vsx_st (vector double, int, double *);
15713 void vec_vsx_st (vector float, int, vector float *);
15714 void vec_vsx_st (vector float, int, float *);
15715 void vec_vsx_st (vector signed int, int, vector signed int *);
15716 void vec_vsx_st (vector signed int, int, int *);
15717 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
15718 void vec_vsx_st (vector unsigned int, int, unsigned int *);
15719 void vec_vsx_st (vector bool int, int, vector bool int *);
15720 void vec_vsx_st (vector bool int, int, unsigned int *);
15721 void vec_vsx_st (vector bool int, int, int *);
15722 void vec_vsx_st (vector signed short, int, vector signed short *);
15723 void vec_vsx_st (vector signed short, int, short *);
15724 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
15725 void vec_vsx_st (vector unsigned short, int, unsigned short *);
15726 void vec_vsx_st (vector bool short, int, vector bool short *);
15727 void vec_vsx_st (vector bool short, int, unsigned short *);
15728 void vec_vsx_st (vector pixel, int, vector pixel *);
15729 void vec_vsx_st (vector pixel, int, unsigned short *);
15730 void vec_vsx_st (vector pixel, int, short *);
15731 void vec_vsx_st (vector bool short, int, short *);
15732 void vec_vsx_st (vector signed char, int, vector signed char *);
15733 void vec_vsx_st (vector signed char, int, signed char *);
15734 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
15735 void vec_vsx_st (vector unsigned char, int, unsigned char *);
15736 void vec_vsx_st (vector bool char, int, vector bool char *);
15737 void vec_vsx_st (vector bool char, int, unsigned char *);
15738 void vec_vsx_st (vector bool char, int, signed char *);
15739
15740 vector double vec_xxpermdi (vector double, vector double, int);
15741 vector float vec_xxpermdi (vector float, vector float, int);
15742 vector long long vec_xxpermdi (vector long long, vector long long, int);
15743 vector unsigned long long vec_xxpermdi (vector unsigned long long,
15744 vector unsigned long long, int);
15745 vector int vec_xxpermdi (vector int, vector int, int);
15746 vector unsigned int vec_xxpermdi (vector unsigned int,
15747 vector unsigned int, int);
15748 vector short vec_xxpermdi (vector short, vector short, int);
15749 vector unsigned short vec_xxpermdi (vector unsigned short,
15750 vector unsigned short, int);
15751 vector signed char vec_xxpermdi (vector signed char, vector signed char, int);
15752 vector unsigned char vec_xxpermdi (vector unsigned char,
15753 vector unsigned char, int);
15754
15755 vector double vec_xxsldi (vector double, vector double, int);
15756 vector float vec_xxsldi (vector float, vector float, int);
15757 vector long long vec_xxsldi (vector long long, vector long long, int);
15758 vector unsigned long long vec_xxsldi (vector unsigned long long,
15759 vector unsigned long long, int);
15760 vector int vec_xxsldi (vector int, vector int, int);
15761 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
15762 vector short vec_xxsldi (vector short, vector short, int);
15763 vector unsigned short vec_xxsldi (vector unsigned short,
15764 vector unsigned short, int);
15765 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
15766 vector unsigned char vec_xxsldi (vector unsigned char,
15767 vector unsigned char, int);
15768 @end smallexample
15769
15770 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
15771 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
15772 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
15773 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
15774 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
15775
15776 If the ISA 2.07 additions to the vector/scalar (power8-vector)
15777 instruction set is available, the following additional functions are
15778 available for both 32-bit and 64-bit targets. For 64-bit targets, you
15779 can use @var{vector long} instead of @var{vector long long},
15780 @var{vector bool long} instead of @var{vector bool long long}, and
15781 @var{vector unsigned long} instead of @var{vector unsigned long long}.
15782
15783 @smallexample
15784 vector long long vec_abs (vector long long);
15785
15786 vector long long vec_add (vector long long, vector long long);
15787 vector unsigned long long vec_add (vector unsigned long long,
15788 vector unsigned long long);
15789
15790 int vec_all_eq (vector long long, vector long long);
15791 int vec_all_eq (vector unsigned long long, vector unsigned long long);
15792 int vec_all_ge (vector long long, vector long long);
15793 int vec_all_ge (vector unsigned long long, vector unsigned long long);
15794 int vec_all_gt (vector long long, vector long long);
15795 int vec_all_gt (vector unsigned long long, vector unsigned long long);
15796 int vec_all_le (vector long long, vector long long);
15797 int vec_all_le (vector unsigned long long, vector unsigned long long);
15798 int vec_all_lt (vector long long, vector long long);
15799 int vec_all_lt (vector unsigned long long, vector unsigned long long);
15800 int vec_all_ne (vector long long, vector long long);
15801 int vec_all_ne (vector unsigned long long, vector unsigned long long);
15802
15803 int vec_any_eq (vector long long, vector long long);
15804 int vec_any_eq (vector unsigned long long, vector unsigned long long);
15805 int vec_any_ge (vector long long, vector long long);
15806 int vec_any_ge (vector unsigned long long, vector unsigned long long);
15807 int vec_any_gt (vector long long, vector long long);
15808 int vec_any_gt (vector unsigned long long, vector unsigned long long);
15809 int vec_any_le (vector long long, vector long long);
15810 int vec_any_le (vector unsigned long long, vector unsigned long long);
15811 int vec_any_lt (vector long long, vector long long);
15812 int vec_any_lt (vector unsigned long long, vector unsigned long long);
15813 int vec_any_ne (vector long long, vector long long);
15814 int vec_any_ne (vector unsigned long long, vector unsigned long long);
15815
15816 vector long long vec_eqv (vector long long, vector long long);
15817 vector long long vec_eqv (vector bool long long, vector long long);
15818 vector long long vec_eqv (vector long long, vector bool long long);
15819 vector unsigned long long vec_eqv (vector unsigned long long,
15820 vector unsigned long long);
15821 vector unsigned long long vec_eqv (vector bool long long,
15822 vector unsigned long long);
15823 vector unsigned long long vec_eqv (vector unsigned long long,
15824 vector bool long long);
15825 vector int vec_eqv (vector int, vector int);
15826 vector int vec_eqv (vector bool int, vector int);
15827 vector int vec_eqv (vector int, vector bool int);
15828 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
15829 vector unsigned int vec_eqv (vector bool unsigned int,
15830 vector unsigned int);
15831 vector unsigned int vec_eqv (vector unsigned int,
15832 vector bool unsigned int);
15833 vector short vec_eqv (vector short, vector short);
15834 vector short vec_eqv (vector bool short, vector short);
15835 vector short vec_eqv (vector short, vector bool short);
15836 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
15837 vector unsigned short vec_eqv (vector bool unsigned short,
15838 vector unsigned short);
15839 vector unsigned short vec_eqv (vector unsigned short,
15840 vector bool unsigned short);
15841 vector signed char vec_eqv (vector signed char, vector signed char);
15842 vector signed char vec_eqv (vector bool signed char, vector signed char);
15843 vector signed char vec_eqv (vector signed char, vector bool signed char);
15844 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
15845 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
15846 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
15847
15848 vector long long vec_max (vector long long, vector long long);
15849 vector unsigned long long vec_max (vector unsigned long long,
15850 vector unsigned long long);
15851
15852 vector signed int vec_mergee (vector signed int, vector signed int);
15853 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
15854 vector bool int vec_mergee (vector bool int, vector bool int);
15855
15856 vector signed int vec_mergeo (vector signed int, vector signed int);
15857 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
15858 vector bool int vec_mergeo (vector bool int, vector bool int);
15859
15860 vector long long vec_min (vector long long, vector long long);
15861 vector unsigned long long vec_min (vector unsigned long long,
15862 vector unsigned long long);
15863
15864 vector long long vec_nand (vector long long, vector long long);
15865 vector long long vec_nand (vector bool long long, vector long long);
15866 vector long long vec_nand (vector long long, vector bool long long);
15867 vector unsigned long long vec_nand (vector unsigned long long,
15868 vector unsigned long long);
15869 vector unsigned long long vec_nand (vector bool long long,
15870 vector unsigned long long);
15871 vector unsigned long long vec_nand (vector unsigned long long,
15872 vector bool long long);
15873 vector int vec_nand (vector int, vector int);
15874 vector int vec_nand (vector bool int, vector int);
15875 vector int vec_nand (vector int, vector bool int);
15876 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
15877 vector unsigned int vec_nand (vector bool unsigned int,
15878 vector unsigned int);
15879 vector unsigned int vec_nand (vector unsigned int,
15880 vector bool unsigned int);
15881 vector short vec_nand (vector short, vector short);
15882 vector short vec_nand (vector bool short, vector short);
15883 vector short vec_nand (vector short, vector bool short);
15884 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
15885 vector unsigned short vec_nand (vector bool unsigned short,
15886 vector unsigned short);
15887 vector unsigned short vec_nand (vector unsigned short,
15888 vector bool unsigned short);
15889 vector signed char vec_nand (vector signed char, vector signed char);
15890 vector signed char vec_nand (vector bool signed char, vector signed char);
15891 vector signed char vec_nand (vector signed char, vector bool signed char);
15892 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
15893 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
15894 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
15895
15896 vector long long vec_orc (vector long long, vector long long);
15897 vector long long vec_orc (vector bool long long, vector long long);
15898 vector long long vec_orc (vector long long, vector bool long long);
15899 vector unsigned long long vec_orc (vector unsigned long long,
15900 vector unsigned long long);
15901 vector unsigned long long vec_orc (vector bool long long,
15902 vector unsigned long long);
15903 vector unsigned long long vec_orc (vector unsigned long long,
15904 vector bool long long);
15905 vector int vec_orc (vector int, vector int);
15906 vector int vec_orc (vector bool int, vector int);
15907 vector int vec_orc (vector int, vector bool int);
15908 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
15909 vector unsigned int vec_orc (vector bool unsigned int,
15910 vector unsigned int);
15911 vector unsigned int vec_orc (vector unsigned int,
15912 vector bool unsigned int);
15913 vector short vec_orc (vector short, vector short);
15914 vector short vec_orc (vector bool short, vector short);
15915 vector short vec_orc (vector short, vector bool short);
15916 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
15917 vector unsigned short vec_orc (vector bool unsigned short,
15918 vector unsigned short);
15919 vector unsigned short vec_orc (vector unsigned short,
15920 vector bool unsigned short);
15921 vector signed char vec_orc (vector signed char, vector signed char);
15922 vector signed char vec_orc (vector bool signed char, vector signed char);
15923 vector signed char vec_orc (vector signed char, vector bool signed char);
15924 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
15925 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
15926 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
15927
15928 vector int vec_pack (vector long long, vector long long);
15929 vector unsigned int vec_pack (vector unsigned long long,
15930 vector unsigned long long);
15931 vector bool int vec_pack (vector bool long long, vector bool long long);
15932
15933 vector int vec_packs (vector long long, vector long long);
15934 vector unsigned int vec_packs (vector unsigned long long,
15935 vector unsigned long long);
15936
15937 vector unsigned int vec_packsu (vector long long, vector long long);
15938 vector unsigned int vec_packsu (vector unsigned long long,
15939 vector unsigned long long);
15940
15941 vector long long vec_rl (vector long long,
15942 vector unsigned long long);
15943 vector long long vec_rl (vector unsigned long long,
15944 vector unsigned long long);
15945
15946 vector long long vec_sl (vector long long, vector unsigned long long);
15947 vector long long vec_sl (vector unsigned long long,
15948 vector unsigned long long);
15949
15950 vector long long vec_sr (vector long long, vector unsigned long long);
15951 vector unsigned long long char vec_sr (vector unsigned long long,
15952 vector unsigned long long);
15953
15954 vector long long vec_sra (vector long long, vector unsigned long long);
15955 vector unsigned long long vec_sra (vector unsigned long long,
15956 vector unsigned long long);
15957
15958 vector long long vec_sub (vector long long, vector long long);
15959 vector unsigned long long vec_sub (vector unsigned long long,
15960 vector unsigned long long);
15961
15962 vector long long vec_unpackh (vector int);
15963 vector unsigned long long vec_unpackh (vector unsigned int);
15964
15965 vector long long vec_unpackl (vector int);
15966 vector unsigned long long vec_unpackl (vector unsigned int);
15967
15968 vector long long vec_vaddudm (vector long long, vector long long);
15969 vector long long vec_vaddudm (vector bool long long, vector long long);
15970 vector long long vec_vaddudm (vector long long, vector bool long long);
15971 vector unsigned long long vec_vaddudm (vector unsigned long long,
15972 vector unsigned long long);
15973 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
15974 vector unsigned long long);
15975 vector unsigned long long vec_vaddudm (vector unsigned long long,
15976 vector bool unsigned long long);
15977
15978 vector long long vec_vbpermq (vector signed char, vector signed char);
15979 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
15980
15981 vector long long vec_cntlz (vector long long);
15982 vector unsigned long long vec_cntlz (vector unsigned long long);
15983 vector int vec_cntlz (vector int);
15984 vector unsigned int vec_cntlz (vector int);
15985 vector short vec_cntlz (vector short);
15986 vector unsigned short vec_cntlz (vector unsigned short);
15987 vector signed char vec_cntlz (vector signed char);
15988 vector unsigned char vec_cntlz (vector unsigned char);
15989
15990 vector long long vec_vclz (vector long long);
15991 vector unsigned long long vec_vclz (vector unsigned long long);
15992 vector int vec_vclz (vector int);
15993 vector unsigned int vec_vclz (vector int);
15994 vector short vec_vclz (vector short);
15995 vector unsigned short vec_vclz (vector unsigned short);
15996 vector signed char vec_vclz (vector signed char);
15997 vector unsigned char vec_vclz (vector unsigned char);
15998
15999 vector signed char vec_vclzb (vector signed char);
16000 vector unsigned char vec_vclzb (vector unsigned char);
16001
16002 vector long long vec_vclzd (vector long long);
16003 vector unsigned long long vec_vclzd (vector unsigned long long);
16004
16005 vector short vec_vclzh (vector short);
16006 vector unsigned short vec_vclzh (vector unsigned short);
16007
16008 vector int vec_vclzw (vector int);
16009 vector unsigned int vec_vclzw (vector int);
16010
16011 vector signed char vec_vgbbd (vector signed char);
16012 vector unsigned char vec_vgbbd (vector unsigned char);
16013
16014 vector long long vec_vmaxsd (vector long long, vector long long);
16015
16016 vector unsigned long long vec_vmaxud (vector unsigned long long,
16017 unsigned vector long long);
16018
16019 vector long long vec_vminsd (vector long long, vector long long);
16020
16021 vector unsigned long long vec_vminud (vector long long,
16022 vector long long);
16023
16024 vector int vec_vpksdss (vector long long, vector long long);
16025 vector unsigned int vec_vpksdss (vector long long, vector long long);
16026
16027 vector unsigned int vec_vpkudus (vector unsigned long long,
16028 vector unsigned long long);
16029
16030 vector int vec_vpkudum (vector long long, vector long long);
16031 vector unsigned int vec_vpkudum (vector unsigned long long,
16032 vector unsigned long long);
16033 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
16034
16035 vector long long vec_vpopcnt (vector long long);
16036 vector unsigned long long vec_vpopcnt (vector unsigned long long);
16037 vector int vec_vpopcnt (vector int);
16038 vector unsigned int vec_vpopcnt (vector int);
16039 vector short vec_vpopcnt (vector short);
16040 vector unsigned short vec_vpopcnt (vector unsigned short);
16041 vector signed char vec_vpopcnt (vector signed char);
16042 vector unsigned char vec_vpopcnt (vector unsigned char);
16043
16044 vector signed char vec_vpopcntb (vector signed char);
16045 vector unsigned char vec_vpopcntb (vector unsigned char);
16046
16047 vector long long vec_vpopcntd (vector long long);
16048 vector unsigned long long vec_vpopcntd (vector unsigned long long);
16049
16050 vector short vec_vpopcnth (vector short);
16051 vector unsigned short vec_vpopcnth (vector unsigned short);
16052
16053 vector int vec_vpopcntw (vector int);
16054 vector unsigned int vec_vpopcntw (vector int);
16055
16056 vector long long vec_vrld (vector long long, vector unsigned long long);
16057 vector unsigned long long vec_vrld (vector unsigned long long,
16058 vector unsigned long long);
16059
16060 vector long long vec_vsld (vector long long, vector unsigned long long);
16061 vector long long vec_vsld (vector unsigned long long,
16062 vector unsigned long long);
16063
16064 vector long long vec_vsrad (vector long long, vector unsigned long long);
16065 vector unsigned long long vec_vsrad (vector unsigned long long,
16066 vector unsigned long long);
16067
16068 vector long long vec_vsrd (vector long long, vector unsigned long long);
16069 vector unsigned long long char vec_vsrd (vector unsigned long long,
16070 vector unsigned long long);
16071
16072 vector long long vec_vsubudm (vector long long, vector long long);
16073 vector long long vec_vsubudm (vector bool long long, vector long long);
16074 vector long long vec_vsubudm (vector long long, vector bool long long);
16075 vector unsigned long long vec_vsubudm (vector unsigned long long,
16076 vector unsigned long long);
16077 vector unsigned long long vec_vsubudm (vector bool long long,
16078 vector unsigned long long);
16079 vector unsigned long long vec_vsubudm (vector unsigned long long,
16080 vector bool long long);
16081
16082 vector long long vec_vupkhsw (vector int);
16083 vector unsigned long long vec_vupkhsw (vector unsigned int);
16084
16085 vector long long vec_vupklsw (vector int);
16086 vector unsigned long long vec_vupklsw (vector int);
16087 @end smallexample
16088
16089 If the ISA 2.07 additions to the vector/scalar (power8-vector)
16090 instruction set is available, the following additional functions are
16091 available for 64-bit targets. New vector types
16092 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
16093 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
16094 builtins.
16095
16096 The normal vector extract, and set operations work on
16097 @var{vector __int128_t} and @var{vector __uint128_t} types,
16098 but the index value must be 0.
16099
16100 @smallexample
16101 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
16102 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
16103
16104 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
16105 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
16106
16107 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
16108 vector __int128_t);
16109 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
16110 vector __uint128_t);
16111
16112 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
16113 vector __int128_t);
16114 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
16115 vector __uint128_t);
16116
16117 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
16118 vector __int128_t);
16119 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
16120 vector __uint128_t);
16121
16122 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
16123 vector __int128_t);
16124 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
16125 vector __uint128_t);
16126
16127 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
16128 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
16129
16130 __int128_t vec_vsubuqm (__int128_t, __int128_t);
16131 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
16132
16133 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
16134 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
16135 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
16136 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
16137 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
16138 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
16139 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
16140 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
16141 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
16142 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
16143 @end smallexample
16144
16145 If the cryptographic instructions are enabled (@option{-mcrypto} or
16146 @option{-mcpu=power8}), the following builtins are enabled.
16147
16148 @smallexample
16149 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
16150
16151 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
16152 vector unsigned long long);
16153
16154 vector unsigned long long __builtin_crypto_vcipherlast
16155 (vector unsigned long long,
16156 vector unsigned long long);
16157
16158 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
16159 vector unsigned long long);
16160
16161 vector unsigned long long __builtin_crypto_vncipherlast
16162 (vector unsigned long long,
16163 vector unsigned long long);
16164
16165 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
16166 vector unsigned char,
16167 vector unsigned char);
16168
16169 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
16170 vector unsigned short,
16171 vector unsigned short);
16172
16173 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
16174 vector unsigned int,
16175 vector unsigned int);
16176
16177 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
16178 vector unsigned long long,
16179 vector unsigned long long);
16180
16181 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
16182 vector unsigned char);
16183
16184 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
16185 vector unsigned short);
16186
16187 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
16188 vector unsigned int);
16189
16190 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
16191 vector unsigned long long);
16192
16193 vector unsigned long long __builtin_crypto_vshasigmad
16194 (vector unsigned long long, int, int);
16195
16196 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
16197 int, int);
16198 @end smallexample
16199
16200 The second argument to the @var{__builtin_crypto_vshasigmad} and
16201 @var{__builtin_crypto_vshasigmaw} builtin functions must be a constant
16202 integer that is 0 or 1. The third argument to these builtin functions
16203 must be a constant integer in the range of 0 to 15.
16204
16205 @node PowerPC Hardware Transactional Memory Built-in Functions
16206 @subsection PowerPC Hardware Transactional Memory Built-in Functions
16207 GCC provides two interfaces for accessing the Hardware Transactional
16208 Memory (HTM) instructions available on some of the PowerPC family
16209 of processors (eg, POWER8). The two interfaces come in a low level
16210 interface, consisting of built-in functions specific to PowerPC and a
16211 higher level interface consisting of inline functions that are common
16212 between PowerPC and S/390.
16213
16214 @subsubsection PowerPC HTM Low Level Built-in Functions
16215
16216 The following low level built-in functions are available with
16217 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
16218 They all generate the machine instruction that is part of the name.
16219
16220 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
16221 the full 4-bit condition register value set by their associated hardware
16222 instruction. The header file @code{htmintrin.h} defines some macros that can
16223 be used to decipher the return value. The @code{__builtin_tbegin} builtin
16224 returns a simple true or false value depending on whether a transaction was
16225 successfully started or not. The arguments of the builtins match exactly the
16226 type and order of the associated hardware instruction's operands, except for
16227 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
16228 Refer to the ISA manual for a description of each instruction's operands.
16229
16230 @smallexample
16231 unsigned int __builtin_tbegin (unsigned int)
16232 unsigned int __builtin_tend (unsigned int)
16233
16234 unsigned int __builtin_tabort (unsigned int)
16235 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
16236 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
16237 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
16238 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
16239
16240 unsigned int __builtin_tcheck (void)
16241 unsigned int __builtin_treclaim (unsigned int)
16242 unsigned int __builtin_trechkpt (void)
16243 unsigned int __builtin_tsr (unsigned int)
16244 @end smallexample
16245
16246 In addition to the above HTM built-ins, we have added built-ins for
16247 some common extended mnemonics of the HTM instructions:
16248
16249 @smallexample
16250 unsigned int __builtin_tendall (void)
16251 unsigned int __builtin_tresume (void)
16252 unsigned int __builtin_tsuspend (void)
16253 @end smallexample
16254
16255 Note that the semantics of the above HTM builtins are required to mimic
16256 the locking semantics used for critical sections. Builtins that are used
16257 to create a new transaction or restart a suspended transaction must have
16258 lock acquisition like semantics while those builtins that end or suspend a
16259 transaction must have lock release like semantics. Specifically, this must
16260 mimic lock semantics as specified by C++11, for example: Lock acquisition is
16261 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
16262 that returns 0, and lock release is as-if an execution of
16263 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
16264 implicit implementation-defined lock used for all transactions. The HTM
16265 instructions associated with with the builtins inherently provide the
16266 correct acquisition and release hardware barriers required. However,
16267 the compiler must also be prohibited from moving loads and stores across
16268 the builtins in a way that would violate their semantics. This has been
16269 accomplished by adding memory barriers to the associated HTM instructions
16270 (which is a conservative approach to provide acquire and release semantics).
16271 Earlier versions of the compiler did not treat the HTM instructions as
16272 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
16273 be used to determine whether the current compiler treats HTM instructions
16274 as memory barriers or not. This allows the user to explicitly add memory
16275 barriers to their code when using an older version of the compiler.
16276
16277 The following set of built-in functions are available to gain access
16278 to the HTM specific special purpose registers.
16279
16280 @smallexample
16281 unsigned long __builtin_get_texasr (void)
16282 unsigned long __builtin_get_texasru (void)
16283 unsigned long __builtin_get_tfhar (void)
16284 unsigned long __builtin_get_tfiar (void)
16285
16286 void __builtin_set_texasr (unsigned long);
16287 void __builtin_set_texasru (unsigned long);
16288 void __builtin_set_tfhar (unsigned long);
16289 void __builtin_set_tfiar (unsigned long);
16290 @end smallexample
16291
16292 Example usage of these low level built-in functions may look like:
16293
16294 @smallexample
16295 #include <htmintrin.h>
16296
16297 int num_retries = 10;
16298
16299 while (1)
16300 @{
16301 if (__builtin_tbegin (0))
16302 @{
16303 /* Transaction State Initiated. */
16304 if (is_locked (lock))
16305 __builtin_tabort (0);
16306 ... transaction code...
16307 __builtin_tend (0);
16308 break;
16309 @}
16310 else
16311 @{
16312 /* Transaction State Failed. Use locks if the transaction
16313 failure is "persistent" or we've tried too many times. */
16314 if (num_retries-- <= 0
16315 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
16316 @{
16317 acquire_lock (lock);
16318 ... non transactional fallback path...
16319 release_lock (lock);
16320 break;
16321 @}
16322 @}
16323 @}
16324 @end smallexample
16325
16326 One final built-in function has been added that returns the value of
16327 the 2-bit Transaction State field of the Machine Status Register (MSR)
16328 as stored in @code{CR0}.
16329
16330 @smallexample
16331 unsigned long __builtin_ttest (void)
16332 @end smallexample
16333
16334 This built-in can be used to determine the current transaction state
16335 using the following code example:
16336
16337 @smallexample
16338 #include <htmintrin.h>
16339
16340 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
16341
16342 if (tx_state == _HTM_TRANSACTIONAL)
16343 @{
16344 /* Code to use in transactional state. */
16345 @}
16346 else if (tx_state == _HTM_NONTRANSACTIONAL)
16347 @{
16348 /* Code to use in non-transactional state. */
16349 @}
16350 else if (tx_state == _HTM_SUSPENDED)
16351 @{
16352 /* Code to use in transaction suspended state. */
16353 @}
16354 @end smallexample
16355
16356 @subsubsection PowerPC HTM High Level Inline Functions
16357
16358 The following high level HTM interface is made available by including
16359 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
16360 where CPU is `power8' or later. This interface is common between PowerPC
16361 and S/390, allowing users to write one HTM source implementation that
16362 can be compiled and executed on either system.
16363
16364 @smallexample
16365 long __TM_simple_begin (void)
16366 long __TM_begin (void* const TM_buff)
16367 long __TM_end (void)
16368 void __TM_abort (void)
16369 void __TM_named_abort (unsigned char const code)
16370 void __TM_resume (void)
16371 void __TM_suspend (void)
16372
16373 long __TM_is_user_abort (void* const TM_buff)
16374 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
16375 long __TM_is_illegal (void* const TM_buff)
16376 long __TM_is_footprint_exceeded (void* const TM_buff)
16377 long __TM_nesting_depth (void* const TM_buff)
16378 long __TM_is_nested_too_deep(void* const TM_buff)
16379 long __TM_is_conflict(void* const TM_buff)
16380 long __TM_is_failure_persistent(void* const TM_buff)
16381 long __TM_failure_address(void* const TM_buff)
16382 long long __TM_failure_code(void* const TM_buff)
16383 @end smallexample
16384
16385 Using these common set of HTM inline functions, we can create
16386 a more portable version of the HTM example in the previous
16387 section that will work on either PowerPC or S/390:
16388
16389 @smallexample
16390 #include <htmxlintrin.h>
16391
16392 int num_retries = 10;
16393 TM_buff_type TM_buff;
16394
16395 while (1)
16396 @{
16397 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
16398 @{
16399 /* Transaction State Initiated. */
16400 if (is_locked (lock))
16401 __TM_abort ();
16402 ... transaction code...
16403 __TM_end ();
16404 break;
16405 @}
16406 else
16407 @{
16408 /* Transaction State Failed. Use locks if the transaction
16409 failure is "persistent" or we've tried too many times. */
16410 if (num_retries-- <= 0
16411 || __TM_is_failure_persistent (TM_buff))
16412 @{
16413 acquire_lock (lock);
16414 ... non transactional fallback path...
16415 release_lock (lock);
16416 break;
16417 @}
16418 @}
16419 @}
16420 @end smallexample
16421
16422 @node RX Built-in Functions
16423 @subsection RX Built-in Functions
16424 GCC supports some of the RX instructions which cannot be expressed in
16425 the C programming language via the use of built-in functions. The
16426 following functions are supported:
16427
16428 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
16429 Generates the @code{brk} machine instruction.
16430 @end deftypefn
16431
16432 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
16433 Generates the @code{clrpsw} machine instruction to clear the specified
16434 bit in the processor status word.
16435 @end deftypefn
16436
16437 @deftypefn {Built-in Function} void __builtin_rx_int (int)
16438 Generates the @code{int} machine instruction to generate an interrupt
16439 with the specified value.
16440 @end deftypefn
16441
16442 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
16443 Generates the @code{machi} machine instruction to add the result of
16444 multiplying the top 16 bits of the two arguments into the
16445 accumulator.
16446 @end deftypefn
16447
16448 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
16449 Generates the @code{maclo} machine instruction to add the result of
16450 multiplying the bottom 16 bits of the two arguments into the
16451 accumulator.
16452 @end deftypefn
16453
16454 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
16455 Generates the @code{mulhi} machine instruction to place the result of
16456 multiplying the top 16 bits of the two arguments into the
16457 accumulator.
16458 @end deftypefn
16459
16460 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
16461 Generates the @code{mullo} machine instruction to place the result of
16462 multiplying the bottom 16 bits of the two arguments into the
16463 accumulator.
16464 @end deftypefn
16465
16466 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
16467 Generates the @code{mvfachi} machine instruction to read the top
16468 32 bits of the accumulator.
16469 @end deftypefn
16470
16471 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
16472 Generates the @code{mvfacmi} machine instruction to read the middle
16473 32 bits of the accumulator.
16474 @end deftypefn
16475
16476 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
16477 Generates the @code{mvfc} machine instruction which reads the control
16478 register specified in its argument and returns its value.
16479 @end deftypefn
16480
16481 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
16482 Generates the @code{mvtachi} machine instruction to set the top
16483 32 bits of the accumulator.
16484 @end deftypefn
16485
16486 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
16487 Generates the @code{mvtaclo} machine instruction to set the bottom
16488 32 bits of the accumulator.
16489 @end deftypefn
16490
16491 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
16492 Generates the @code{mvtc} machine instruction which sets control
16493 register number @code{reg} to @code{val}.
16494 @end deftypefn
16495
16496 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
16497 Generates the @code{mvtipl} machine instruction set the interrupt
16498 priority level.
16499 @end deftypefn
16500
16501 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
16502 Generates the @code{racw} machine instruction to round the accumulator
16503 according to the specified mode.
16504 @end deftypefn
16505
16506 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
16507 Generates the @code{revw} machine instruction which swaps the bytes in
16508 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
16509 and also bits 16--23 occupy bits 24--31 and vice versa.
16510 @end deftypefn
16511
16512 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
16513 Generates the @code{rmpa} machine instruction which initiates a
16514 repeated multiply and accumulate sequence.
16515 @end deftypefn
16516
16517 @deftypefn {Built-in Function} void __builtin_rx_round (float)
16518 Generates the @code{round} machine instruction which returns the
16519 floating-point argument rounded according to the current rounding mode
16520 set in the floating-point status word register.
16521 @end deftypefn
16522
16523 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
16524 Generates the @code{sat} machine instruction which returns the
16525 saturated value of the argument.
16526 @end deftypefn
16527
16528 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
16529 Generates the @code{setpsw} machine instruction to set the specified
16530 bit in the processor status word.
16531 @end deftypefn
16532
16533 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
16534 Generates the @code{wait} machine instruction.
16535 @end deftypefn
16536
16537 @node S/390 System z Built-in Functions
16538 @subsection S/390 System z Built-in Functions
16539 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
16540 Generates the @code{tbegin} machine instruction starting a
16541 non-constraint hardware transaction. If the parameter is non-NULL the
16542 memory area is used to store the transaction diagnostic buffer and
16543 will be passed as first operand to @code{tbegin}. This buffer can be
16544 defined using the @code{struct __htm_tdb} C struct defined in
16545 @code{htmintrin.h} and must reside on a double-word boundary. The
16546 second tbegin operand is set to @code{0xff0c}. This enables
16547 save/restore of all GPRs and disables aborts for FPR and AR
16548 manipulations inside the transaction body. The condition code set by
16549 the tbegin instruction is returned as integer value. The tbegin
16550 instruction by definition overwrites the content of all FPRs. The
16551 compiler will generate code which saves and restores the FPRs. For
16552 soft-float code it is recommended to used the @code{*_nofloat}
16553 variant. In order to prevent a TDB from being written it is required
16554 to pass an constant zero value as parameter. Passing the zero value
16555 through a variable is not sufficient. Although modifications of
16556 access registers inside the transaction will not trigger an
16557 transaction abort it is not supported to actually modify them. Access
16558 registers do not get saved when entering a transaction. They will have
16559 undefined state when reaching the abort code.
16560 @end deftypefn
16561
16562 Macros for the possible return codes of tbegin are defined in the
16563 @code{htmintrin.h} header file:
16564
16565 @table @code
16566 @item _HTM_TBEGIN_STARTED
16567 @code{tbegin} has been executed as part of normal processing. The
16568 transaction body is supposed to be executed.
16569 @item _HTM_TBEGIN_INDETERMINATE
16570 The transaction was aborted due to an indeterminate condition which
16571 might be persistent.
16572 @item _HTM_TBEGIN_TRANSIENT
16573 The transaction aborted due to a transient failure. The transaction
16574 should be re-executed in that case.
16575 @item _HTM_TBEGIN_PERSISTENT
16576 The transaction aborted due to a persistent failure. Re-execution
16577 under same circumstances will not be productive.
16578 @end table
16579
16580 @defmac _HTM_FIRST_USER_ABORT_CODE
16581 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
16582 specifies the first abort code which can be used for
16583 @code{__builtin_tabort}. Values below this threshold are reserved for
16584 machine use.
16585 @end defmac
16586
16587 @deftp {Data type} {struct __htm_tdb}
16588 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
16589 the structure of the transaction diagnostic block as specified in the
16590 Principles of Operation manual chapter 5-91.
16591 @end deftp
16592
16593 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
16594 Same as @code{__builtin_tbegin} but without FPR saves and restores.
16595 Using this variant in code making use of FPRs will leave the FPRs in
16596 undefined state when entering the transaction abort handler code.
16597 @end deftypefn
16598
16599 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
16600 In addition to @code{__builtin_tbegin} a loop for transient failures
16601 is generated. If tbegin returns a condition code of 2 the transaction
16602 will be retried as often as specified in the second argument. The
16603 perform processor assist instruction is used to tell the CPU about the
16604 number of fails so far.
16605 @end deftypefn
16606
16607 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
16608 Same as @code{__builtin_tbegin_retry} but without FPR saves and
16609 restores. Using this variant in code making use of FPRs will leave
16610 the FPRs in undefined state when entering the transaction abort
16611 handler code.
16612 @end deftypefn
16613
16614 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
16615 Generates the @code{tbeginc} machine instruction starting a constraint
16616 hardware transaction. The second operand is set to @code{0xff08}.
16617 @end deftypefn
16618
16619 @deftypefn {Built-in Function} int __builtin_tend (void)
16620 Generates the @code{tend} machine instruction finishing a transaction
16621 and making the changes visible to other threads. The condition code
16622 generated by tend is returned as integer value.
16623 @end deftypefn
16624
16625 @deftypefn {Built-in Function} void __builtin_tabort (int)
16626 Generates the @code{tabort} machine instruction with the specified
16627 abort code. Abort codes from 0 through 255 are reserved and will
16628 result in an error message.
16629 @end deftypefn
16630
16631 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
16632 Generates the @code{ppa rX,rY,1} machine instruction. Where the
16633 integer parameter is loaded into rX and a value of zero is loaded into
16634 rY. The integer parameter specifies the number of times the
16635 transaction repeatedly aborted.
16636 @end deftypefn
16637
16638 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
16639 Generates the @code{etnd} machine instruction. The current nesting
16640 depth is returned as integer value. For a nesting depth of 0 the code
16641 is not executed as part of an transaction.
16642 @end deftypefn
16643
16644 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
16645
16646 Generates the @code{ntstg} machine instruction. The second argument
16647 is written to the first arguments location. The store operation will
16648 not be rolled-back in case of an transaction abort.
16649 @end deftypefn
16650
16651 @node SH Built-in Functions
16652 @subsection SH Built-in Functions
16653 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
16654 families of processors:
16655
16656 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
16657 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
16658 used by system code that manages threads and execution contexts. The compiler
16659 normally does not generate code that modifies the contents of @samp{GBR} and
16660 thus the value is preserved across function calls. Changing the @samp{GBR}
16661 value in user code must be done with caution, since the compiler might use
16662 @samp{GBR} in order to access thread local variables.
16663
16664 @end deftypefn
16665
16666 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
16667 Returns the value that is currently set in the @samp{GBR} register.
16668 Memory loads and stores that use the thread pointer as a base address are
16669 turned into @samp{GBR} based displacement loads and stores, if possible.
16670 For example:
16671 @smallexample
16672 struct my_tcb
16673 @{
16674 int a, b, c, d, e;
16675 @};
16676
16677 int get_tcb_value (void)
16678 @{
16679 // Generate @samp{mov.l @@(8,gbr),r0} instruction
16680 return ((my_tcb*)__builtin_thread_pointer ())->c;
16681 @}
16682
16683 @end smallexample
16684 @end deftypefn
16685
16686 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
16687 Returns the value that is currently set in the @samp{FPSCR} register.
16688 @end deftypefn
16689
16690 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
16691 Sets the @samp{FPSCR} register to the specified value @var{val}, while
16692 preserving the current values of the FR, SZ and PR bits.
16693 @end deftypefn
16694
16695 @node SPARC VIS Built-in Functions
16696 @subsection SPARC VIS Built-in Functions
16697
16698 GCC supports SIMD operations on the SPARC using both the generic vector
16699 extensions (@pxref{Vector Extensions}) as well as built-in functions for
16700 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
16701 switch, the VIS extension is exposed as the following built-in functions:
16702
16703 @smallexample
16704 typedef int v1si __attribute__ ((vector_size (4)));
16705 typedef int v2si __attribute__ ((vector_size (8)));
16706 typedef short v4hi __attribute__ ((vector_size (8)));
16707 typedef short v2hi __attribute__ ((vector_size (4)));
16708 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
16709 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
16710
16711 void __builtin_vis_write_gsr (int64_t);
16712 int64_t __builtin_vis_read_gsr (void);
16713
16714 void * __builtin_vis_alignaddr (void *, long);
16715 void * __builtin_vis_alignaddrl (void *, long);
16716 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
16717 v2si __builtin_vis_faligndatav2si (v2si, v2si);
16718 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
16719 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
16720
16721 v4hi __builtin_vis_fexpand (v4qi);
16722
16723 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
16724 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
16725 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
16726 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
16727 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
16728 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
16729 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
16730
16731 v4qi __builtin_vis_fpack16 (v4hi);
16732 v8qi __builtin_vis_fpack32 (v2si, v8qi);
16733 v2hi __builtin_vis_fpackfix (v2si);
16734 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
16735
16736 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
16737
16738 long __builtin_vis_edge8 (void *, void *);
16739 long __builtin_vis_edge8l (void *, void *);
16740 long __builtin_vis_edge16 (void *, void *);
16741 long __builtin_vis_edge16l (void *, void *);
16742 long __builtin_vis_edge32 (void *, void *);
16743 long __builtin_vis_edge32l (void *, void *);
16744
16745 long __builtin_vis_fcmple16 (v4hi, v4hi);
16746 long __builtin_vis_fcmple32 (v2si, v2si);
16747 long __builtin_vis_fcmpne16 (v4hi, v4hi);
16748 long __builtin_vis_fcmpne32 (v2si, v2si);
16749 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
16750 long __builtin_vis_fcmpgt32 (v2si, v2si);
16751 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
16752 long __builtin_vis_fcmpeq32 (v2si, v2si);
16753
16754 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
16755 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
16756 v2si __builtin_vis_fpadd32 (v2si, v2si);
16757 v1si __builtin_vis_fpadd32s (v1si, v1si);
16758 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
16759 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
16760 v2si __builtin_vis_fpsub32 (v2si, v2si);
16761 v1si __builtin_vis_fpsub32s (v1si, v1si);
16762
16763 long __builtin_vis_array8 (long, long);
16764 long __builtin_vis_array16 (long, long);
16765 long __builtin_vis_array32 (long, long);
16766 @end smallexample
16767
16768 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
16769 functions also become available:
16770
16771 @smallexample
16772 long __builtin_vis_bmask (long, long);
16773 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
16774 v2si __builtin_vis_bshufflev2si (v2si, v2si);
16775 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
16776 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
16777
16778 long __builtin_vis_edge8n (void *, void *);
16779 long __builtin_vis_edge8ln (void *, void *);
16780 long __builtin_vis_edge16n (void *, void *);
16781 long __builtin_vis_edge16ln (void *, void *);
16782 long __builtin_vis_edge32n (void *, void *);
16783 long __builtin_vis_edge32ln (void *, void *);
16784 @end smallexample
16785
16786 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
16787 functions also become available:
16788
16789 @smallexample
16790 void __builtin_vis_cmask8 (long);
16791 void __builtin_vis_cmask16 (long);
16792 void __builtin_vis_cmask32 (long);
16793
16794 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
16795
16796 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
16797 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
16798 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
16799 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
16800 v2si __builtin_vis_fsll16 (v2si, v2si);
16801 v2si __builtin_vis_fslas16 (v2si, v2si);
16802 v2si __builtin_vis_fsrl16 (v2si, v2si);
16803 v2si __builtin_vis_fsra16 (v2si, v2si);
16804
16805 long __builtin_vis_pdistn (v8qi, v8qi);
16806
16807 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
16808
16809 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
16810 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
16811
16812 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
16813 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
16814 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
16815 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
16816 v2si __builtin_vis_fpadds32 (v2si, v2si);
16817 v1si __builtin_vis_fpadds32s (v1si, v1si);
16818 v2si __builtin_vis_fpsubs32 (v2si, v2si);
16819 v1si __builtin_vis_fpsubs32s (v1si, v1si);
16820
16821 long __builtin_vis_fucmple8 (v8qi, v8qi);
16822 long __builtin_vis_fucmpne8 (v8qi, v8qi);
16823 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
16824 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
16825
16826 float __builtin_vis_fhadds (float, float);
16827 double __builtin_vis_fhaddd (double, double);
16828 float __builtin_vis_fhsubs (float, float);
16829 double __builtin_vis_fhsubd (double, double);
16830 float __builtin_vis_fnhadds (float, float);
16831 double __builtin_vis_fnhaddd (double, double);
16832
16833 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
16834 int64_t __builtin_vis_xmulx (int64_t, int64_t);
16835 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
16836 @end smallexample
16837
16838 @node SPU Built-in Functions
16839 @subsection SPU Built-in Functions
16840
16841 GCC provides extensions for the SPU processor as described in the
16842 Sony/Toshiba/IBM SPU Language Extensions Specification, which can be
16843 found at @uref{http://cell.scei.co.jp/} or
16844 @uref{http://www.ibm.com/developerworks/power/cell/}. GCC's
16845 implementation differs in several ways.
16846
16847 @itemize @bullet
16848
16849 @item
16850 The optional extension of specifying vector constants in parentheses is
16851 not supported.
16852
16853 @item
16854 A vector initializer requires no cast if the vector constant is of the
16855 same type as the variable it is initializing.
16856
16857 @item
16858 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16859 vector type is the default signedness of the base type. The default
16860 varies depending on the operating system, so a portable program should
16861 always specify the signedness.
16862
16863 @item
16864 By default, the keyword @code{__vector} is added. The macro
16865 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
16866 undefined.
16867
16868 @item
16869 GCC allows using a @code{typedef} name as the type specifier for a
16870 vector type.
16871
16872 @item
16873 For C, overloaded functions are implemented with macros so the following
16874 does not work:
16875
16876 @smallexample
16877 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16878 @end smallexample
16879
16880 @noindent
16881 Since @code{spu_add} is a macro, the vector constant in the example
16882 is treated as four separate arguments. Wrap the entire argument in
16883 parentheses for this to work.
16884
16885 @item
16886 The extended version of @code{__builtin_expect} is not supported.
16887
16888 @end itemize
16889
16890 @emph{Note:} Only the interface described in the aforementioned
16891 specification is supported. Internally, GCC uses built-in functions to
16892 implement the required functionality, but these are not supported and
16893 are subject to change without notice.
16894
16895 @node TI C6X Built-in Functions
16896 @subsection TI C6X Built-in Functions
16897
16898 GCC provides intrinsics to access certain instructions of the TI C6X
16899 processors. These intrinsics, listed below, are available after
16900 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
16901 to C6X instructions.
16902
16903 @smallexample
16904
16905 int _sadd (int, int)
16906 int _ssub (int, int)
16907 int _sadd2 (int, int)
16908 int _ssub2 (int, int)
16909 long long _mpy2 (int, int)
16910 long long _smpy2 (int, int)
16911 int _add4 (int, int)
16912 int _sub4 (int, int)
16913 int _saddu4 (int, int)
16914
16915 int _smpy (int, int)
16916 int _smpyh (int, int)
16917 int _smpyhl (int, int)
16918 int _smpylh (int, int)
16919
16920 int _sshl (int, int)
16921 int _subc (int, int)
16922
16923 int _avg2 (int, int)
16924 int _avgu4 (int, int)
16925
16926 int _clrr (int, int)
16927 int _extr (int, int)
16928 int _extru (int, int)
16929 int _abs (int)
16930 int _abs2 (int)
16931
16932 @end smallexample
16933
16934 @node TILE-Gx Built-in Functions
16935 @subsection TILE-Gx Built-in Functions
16936
16937 GCC provides intrinsics to access every instruction of the TILE-Gx
16938 processor. The intrinsics are of the form:
16939
16940 @smallexample
16941
16942 unsigned long long __insn_@var{op} (...)
16943
16944 @end smallexample
16945
16946 Where @var{op} is the name of the instruction. Refer to the ISA manual
16947 for the complete list of instructions.
16948
16949 GCC also provides intrinsics to directly access the network registers.
16950 The intrinsics are:
16951
16952 @smallexample
16953
16954 unsigned long long __tile_idn0_receive (void)
16955 unsigned long long __tile_idn1_receive (void)
16956 unsigned long long __tile_udn0_receive (void)
16957 unsigned long long __tile_udn1_receive (void)
16958 unsigned long long __tile_udn2_receive (void)
16959 unsigned long long __tile_udn3_receive (void)
16960 void __tile_idn_send (unsigned long long)
16961 void __tile_udn_send (unsigned long long)
16962
16963 @end smallexample
16964
16965 The intrinsic @code{void __tile_network_barrier (void)} is used to
16966 guarantee that no network operations before it are reordered with
16967 those after it.
16968
16969 @node TILEPro Built-in Functions
16970 @subsection TILEPro Built-in Functions
16971
16972 GCC provides intrinsics to access every instruction of the TILEPro
16973 processor. The intrinsics are of the form:
16974
16975 @smallexample
16976
16977 unsigned __insn_@var{op} (...)
16978
16979 @end smallexample
16980
16981 @noindent
16982 where @var{op} is the name of the instruction. Refer to the ISA manual
16983 for the complete list of instructions.
16984
16985 GCC also provides intrinsics to directly access the network registers.
16986 The intrinsics are:
16987
16988 @smallexample
16989
16990 unsigned __tile_idn0_receive (void)
16991 unsigned __tile_idn1_receive (void)
16992 unsigned __tile_sn_receive (void)
16993 unsigned __tile_udn0_receive (void)
16994 unsigned __tile_udn1_receive (void)
16995 unsigned __tile_udn2_receive (void)
16996 unsigned __tile_udn3_receive (void)
16997 void __tile_idn_send (unsigned)
16998 void __tile_sn_send (unsigned)
16999 void __tile_udn_send (unsigned)
17000
17001 @end smallexample
17002
17003 The intrinsic @code{void __tile_network_barrier (void)} is used to
17004 guarantee that no network operations before it are reordered with
17005 those after it.
17006
17007 @node x86 Built-in Functions
17008 @subsection x86 Built-in Functions
17009
17010 These built-in functions are available for the x86-32 and x86-64 family
17011 of computers, depending on the command-line switches used.
17012
17013 If you specify command-line switches such as @option{-msse},
17014 the compiler could use the extended instruction sets even if the built-ins
17015 are not used explicitly in the program. For this reason, applications
17016 that perform run-time CPU detection must compile separate files for each
17017 supported architecture, using the appropriate flags. In particular,
17018 the file containing the CPU detection code should be compiled without
17019 these options.
17020
17021 The following machine modes are available for use with MMX built-in functions
17022 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
17023 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
17024 vector of eight 8-bit integers. Some of the built-in functions operate on
17025 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
17026
17027 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
17028 of two 32-bit floating-point values.
17029
17030 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
17031 floating-point values. Some instructions use a vector of four 32-bit
17032 integers, these use @code{V4SI}. Finally, some instructions operate on an
17033 entire vector register, interpreting it as a 128-bit integer, these use mode
17034 @code{TI}.
17035
17036 In 64-bit mode, the x86-64 family of processors uses additional built-in
17037 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
17038 floating point and @code{TC} 128-bit complex floating-point values.
17039
17040 The following floating-point built-in functions are available in 64-bit
17041 mode. All of them implement the function that is part of the name.
17042
17043 @smallexample
17044 __float128 __builtin_fabsq (__float128)
17045 __float128 __builtin_copysignq (__float128, __float128)
17046 @end smallexample
17047
17048 The following built-in function is always available.
17049
17050 @table @code
17051 @item void __builtin_ia32_pause (void)
17052 Generates the @code{pause} machine instruction with a compiler memory
17053 barrier.
17054 @end table
17055
17056 The following floating-point built-in functions are made available in the
17057 64-bit mode.
17058
17059 @table @code
17060 @item __float128 __builtin_infq (void)
17061 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
17062 @findex __builtin_infq
17063
17064 @item __float128 __builtin_huge_valq (void)
17065 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
17066 @findex __builtin_huge_valq
17067 @end table
17068
17069 The following built-in functions are always available and can be used to
17070 check the target platform type.
17071
17072 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
17073 This function runs the CPU detection code to check the type of CPU and the
17074 features supported. This built-in function needs to be invoked along with the built-in functions
17075 to check CPU type and features, @code{__builtin_cpu_is} and
17076 @code{__builtin_cpu_supports}, only when used in a function that is
17077 executed before any constructors are called. The CPU detection code is
17078 automatically executed in a very high priority constructor.
17079
17080 For example, this function has to be used in @code{ifunc} resolvers that
17081 check for CPU type using the built-in functions @code{__builtin_cpu_is}
17082 and @code{__builtin_cpu_supports}, or in constructors on targets that
17083 don't support constructor priority.
17084 @smallexample
17085
17086 static void (*resolve_memcpy (void)) (void)
17087 @{
17088 // ifunc resolvers fire before constructors, explicitly call the init
17089 // function.
17090 __builtin_cpu_init ();
17091 if (__builtin_cpu_supports ("ssse3"))
17092 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
17093 else
17094 return default_memcpy;
17095 @}
17096
17097 void *memcpy (void *, const void *, size_t)
17098 __attribute__ ((ifunc ("resolve_memcpy")));
17099 @end smallexample
17100
17101 @end deftypefn
17102
17103 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
17104 This function returns a positive integer if the run-time CPU
17105 is of type @var{cpuname}
17106 and returns @code{0} otherwise. The following CPU names can be detected:
17107
17108 @table @samp
17109 @item intel
17110 Intel CPU.
17111
17112 @item atom
17113 Intel Atom CPU.
17114
17115 @item core2
17116 Intel Core 2 CPU.
17117
17118 @item corei7
17119 Intel Core i7 CPU.
17120
17121 @item nehalem
17122 Intel Core i7 Nehalem CPU.
17123
17124 @item westmere
17125 Intel Core i7 Westmere CPU.
17126
17127 @item sandybridge
17128 Intel Core i7 Sandy Bridge CPU.
17129
17130 @item amd
17131 AMD CPU.
17132
17133 @item amdfam10h
17134 AMD Family 10h CPU.
17135
17136 @item barcelona
17137 AMD Family 10h Barcelona CPU.
17138
17139 @item shanghai
17140 AMD Family 10h Shanghai CPU.
17141
17142 @item istanbul
17143 AMD Family 10h Istanbul CPU.
17144
17145 @item btver1
17146 AMD Family 14h CPU.
17147
17148 @item amdfam15h
17149 AMD Family 15h CPU.
17150
17151 @item bdver1
17152 AMD Family 15h Bulldozer version 1.
17153
17154 @item bdver2
17155 AMD Family 15h Bulldozer version 2.
17156
17157 @item bdver3
17158 AMD Family 15h Bulldozer version 3.
17159
17160 @item bdver4
17161 AMD Family 15h Bulldozer version 4.
17162
17163 @item btver2
17164 AMD Family 16h CPU.
17165
17166 @item znver1
17167 AMD Family 17h CPU.
17168 @end table
17169
17170 Here is an example:
17171 @smallexample
17172 if (__builtin_cpu_is ("corei7"))
17173 @{
17174 do_corei7 (); // Core i7 specific implementation.
17175 @}
17176 else
17177 @{
17178 do_generic (); // Generic implementation.
17179 @}
17180 @end smallexample
17181 @end deftypefn
17182
17183 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
17184 This function returns a positive integer if the run-time CPU
17185 supports @var{feature}
17186 and returns @code{0} otherwise. The following features can be detected:
17187
17188 @table @samp
17189 @item cmov
17190 CMOV instruction.
17191 @item mmx
17192 MMX instructions.
17193 @item popcnt
17194 POPCNT instruction.
17195 @item sse
17196 SSE instructions.
17197 @item sse2
17198 SSE2 instructions.
17199 @item sse3
17200 SSE3 instructions.
17201 @item ssse3
17202 SSSE3 instructions.
17203 @item sse4.1
17204 SSE4.1 instructions.
17205 @item sse4.2
17206 SSE4.2 instructions.
17207 @item avx
17208 AVX instructions.
17209 @item avx2
17210 AVX2 instructions.
17211 @item avx512f
17212 AVX512F instructions.
17213 @end table
17214
17215 Here is an example:
17216 @smallexample
17217 if (__builtin_cpu_supports ("popcnt"))
17218 @{
17219 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
17220 @}
17221 else
17222 @{
17223 count = generic_countbits (n); //generic implementation.
17224 @}
17225 @end smallexample
17226 @end deftypefn
17227
17228
17229 The following built-in functions are made available by @option{-mmmx}.
17230 All of them generate the machine instruction that is part of the name.
17231
17232 @smallexample
17233 v8qi __builtin_ia32_paddb (v8qi, v8qi)
17234 v4hi __builtin_ia32_paddw (v4hi, v4hi)
17235 v2si __builtin_ia32_paddd (v2si, v2si)
17236 v8qi __builtin_ia32_psubb (v8qi, v8qi)
17237 v4hi __builtin_ia32_psubw (v4hi, v4hi)
17238 v2si __builtin_ia32_psubd (v2si, v2si)
17239 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
17240 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
17241 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
17242 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
17243 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
17244 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
17245 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
17246 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
17247 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
17248 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
17249 di __builtin_ia32_pand (di, di)
17250 di __builtin_ia32_pandn (di,di)
17251 di __builtin_ia32_por (di, di)
17252 di __builtin_ia32_pxor (di, di)
17253 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
17254 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
17255 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
17256 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
17257 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
17258 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
17259 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
17260 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
17261 v2si __builtin_ia32_punpckhdq (v2si, v2si)
17262 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
17263 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
17264 v2si __builtin_ia32_punpckldq (v2si, v2si)
17265 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
17266 v4hi __builtin_ia32_packssdw (v2si, v2si)
17267 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
17268
17269 v4hi __builtin_ia32_psllw (v4hi, v4hi)
17270 v2si __builtin_ia32_pslld (v2si, v2si)
17271 v1di __builtin_ia32_psllq (v1di, v1di)
17272 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
17273 v2si __builtin_ia32_psrld (v2si, v2si)
17274 v1di __builtin_ia32_psrlq (v1di, v1di)
17275 v4hi __builtin_ia32_psraw (v4hi, v4hi)
17276 v2si __builtin_ia32_psrad (v2si, v2si)
17277 v4hi __builtin_ia32_psllwi (v4hi, int)
17278 v2si __builtin_ia32_pslldi (v2si, int)
17279 v1di __builtin_ia32_psllqi (v1di, int)
17280 v4hi __builtin_ia32_psrlwi (v4hi, int)
17281 v2si __builtin_ia32_psrldi (v2si, int)
17282 v1di __builtin_ia32_psrlqi (v1di, int)
17283 v4hi __builtin_ia32_psrawi (v4hi, int)
17284 v2si __builtin_ia32_psradi (v2si, int)
17285
17286 @end smallexample
17287
17288 The following built-in functions are made available either with
17289 @option{-msse}, or with a combination of @option{-m3dnow} and
17290 @option{-march=athlon}. All of them generate the machine
17291 instruction that is part of the name.
17292
17293 @smallexample
17294 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
17295 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
17296 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
17297 v1di __builtin_ia32_psadbw (v8qi, v8qi)
17298 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
17299 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
17300 v8qi __builtin_ia32_pminub (v8qi, v8qi)
17301 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
17302 int __builtin_ia32_pmovmskb (v8qi)
17303 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
17304 void __builtin_ia32_movntq (di *, di)
17305 void __builtin_ia32_sfence (void)
17306 @end smallexample
17307
17308 The following built-in functions are available when @option{-msse} is used.
17309 All of them generate the machine instruction that is part of the name.
17310
17311 @smallexample
17312 int __builtin_ia32_comieq (v4sf, v4sf)
17313 int __builtin_ia32_comineq (v4sf, v4sf)
17314 int __builtin_ia32_comilt (v4sf, v4sf)
17315 int __builtin_ia32_comile (v4sf, v4sf)
17316 int __builtin_ia32_comigt (v4sf, v4sf)
17317 int __builtin_ia32_comige (v4sf, v4sf)
17318 int __builtin_ia32_ucomieq (v4sf, v4sf)
17319 int __builtin_ia32_ucomineq (v4sf, v4sf)
17320 int __builtin_ia32_ucomilt (v4sf, v4sf)
17321 int __builtin_ia32_ucomile (v4sf, v4sf)
17322 int __builtin_ia32_ucomigt (v4sf, v4sf)
17323 int __builtin_ia32_ucomige (v4sf, v4sf)
17324 v4sf __builtin_ia32_addps (v4sf, v4sf)
17325 v4sf __builtin_ia32_subps (v4sf, v4sf)
17326 v4sf __builtin_ia32_mulps (v4sf, v4sf)
17327 v4sf __builtin_ia32_divps (v4sf, v4sf)
17328 v4sf __builtin_ia32_addss (v4sf, v4sf)
17329 v4sf __builtin_ia32_subss (v4sf, v4sf)
17330 v4sf __builtin_ia32_mulss (v4sf, v4sf)
17331 v4sf __builtin_ia32_divss (v4sf, v4sf)
17332 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
17333 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
17334 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
17335 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
17336 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
17337 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
17338 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
17339 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
17340 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
17341 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
17342 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
17343 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
17344 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
17345 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
17346 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
17347 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
17348 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
17349 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
17350 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
17351 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
17352 v4sf __builtin_ia32_maxps (v4sf, v4sf)
17353 v4sf __builtin_ia32_maxss (v4sf, v4sf)
17354 v4sf __builtin_ia32_minps (v4sf, v4sf)
17355 v4sf __builtin_ia32_minss (v4sf, v4sf)
17356 v4sf __builtin_ia32_andps (v4sf, v4sf)
17357 v4sf __builtin_ia32_andnps (v4sf, v4sf)
17358 v4sf __builtin_ia32_orps (v4sf, v4sf)
17359 v4sf __builtin_ia32_xorps (v4sf, v4sf)
17360 v4sf __builtin_ia32_movss (v4sf, v4sf)
17361 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
17362 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
17363 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
17364 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
17365 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
17366 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
17367 v2si __builtin_ia32_cvtps2pi (v4sf)
17368 int __builtin_ia32_cvtss2si (v4sf)
17369 v2si __builtin_ia32_cvttps2pi (v4sf)
17370 int __builtin_ia32_cvttss2si (v4sf)
17371 v4sf __builtin_ia32_rcpps (v4sf)
17372 v4sf __builtin_ia32_rsqrtps (v4sf)
17373 v4sf __builtin_ia32_sqrtps (v4sf)
17374 v4sf __builtin_ia32_rcpss (v4sf)
17375 v4sf __builtin_ia32_rsqrtss (v4sf)
17376 v4sf __builtin_ia32_sqrtss (v4sf)
17377 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
17378 void __builtin_ia32_movntps (float *, v4sf)
17379 int __builtin_ia32_movmskps (v4sf)
17380 @end smallexample
17381
17382 The following built-in functions are available when @option{-msse} is used.
17383
17384 @table @code
17385 @item v4sf __builtin_ia32_loadups (float *)
17386 Generates the @code{movups} machine instruction as a load from memory.
17387 @item void __builtin_ia32_storeups (float *, v4sf)
17388 Generates the @code{movups} machine instruction as a store to memory.
17389 @item v4sf __builtin_ia32_loadss (float *)
17390 Generates the @code{movss} machine instruction as a load from memory.
17391 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
17392 Generates the @code{movhps} machine instruction as a load from memory.
17393 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
17394 Generates the @code{movlps} machine instruction as a load from memory
17395 @item void __builtin_ia32_storehps (v2sf *, v4sf)
17396 Generates the @code{movhps} machine instruction as a store to memory.
17397 @item void __builtin_ia32_storelps (v2sf *, v4sf)
17398 Generates the @code{movlps} machine instruction as a store to memory.
17399 @end table
17400
17401 The following built-in functions are available when @option{-msse2} is used.
17402 All of them generate the machine instruction that is part of the name.
17403
17404 @smallexample
17405 int __builtin_ia32_comisdeq (v2df, v2df)
17406 int __builtin_ia32_comisdlt (v2df, v2df)
17407 int __builtin_ia32_comisdle (v2df, v2df)
17408 int __builtin_ia32_comisdgt (v2df, v2df)
17409 int __builtin_ia32_comisdge (v2df, v2df)
17410 int __builtin_ia32_comisdneq (v2df, v2df)
17411 int __builtin_ia32_ucomisdeq (v2df, v2df)
17412 int __builtin_ia32_ucomisdlt (v2df, v2df)
17413 int __builtin_ia32_ucomisdle (v2df, v2df)
17414 int __builtin_ia32_ucomisdgt (v2df, v2df)
17415 int __builtin_ia32_ucomisdge (v2df, v2df)
17416 int __builtin_ia32_ucomisdneq (v2df, v2df)
17417 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
17418 v2df __builtin_ia32_cmpltpd (v2df, v2df)
17419 v2df __builtin_ia32_cmplepd (v2df, v2df)
17420 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
17421 v2df __builtin_ia32_cmpgepd (v2df, v2df)
17422 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
17423 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
17424 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
17425 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
17426 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
17427 v2df __builtin_ia32_cmpngepd (v2df, v2df)
17428 v2df __builtin_ia32_cmpordpd (v2df, v2df)
17429 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
17430 v2df __builtin_ia32_cmpltsd (v2df, v2df)
17431 v2df __builtin_ia32_cmplesd (v2df, v2df)
17432 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
17433 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
17434 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
17435 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
17436 v2df __builtin_ia32_cmpordsd (v2df, v2df)
17437 v2di __builtin_ia32_paddq (v2di, v2di)
17438 v2di __builtin_ia32_psubq (v2di, v2di)
17439 v2df __builtin_ia32_addpd (v2df, v2df)
17440 v2df __builtin_ia32_subpd (v2df, v2df)
17441 v2df __builtin_ia32_mulpd (v2df, v2df)
17442 v2df __builtin_ia32_divpd (v2df, v2df)
17443 v2df __builtin_ia32_addsd (v2df, v2df)
17444 v2df __builtin_ia32_subsd (v2df, v2df)
17445 v2df __builtin_ia32_mulsd (v2df, v2df)
17446 v2df __builtin_ia32_divsd (v2df, v2df)
17447 v2df __builtin_ia32_minpd (v2df, v2df)
17448 v2df __builtin_ia32_maxpd (v2df, v2df)
17449 v2df __builtin_ia32_minsd (v2df, v2df)
17450 v2df __builtin_ia32_maxsd (v2df, v2df)
17451 v2df __builtin_ia32_andpd (v2df, v2df)
17452 v2df __builtin_ia32_andnpd (v2df, v2df)
17453 v2df __builtin_ia32_orpd (v2df, v2df)
17454 v2df __builtin_ia32_xorpd (v2df, v2df)
17455 v2df __builtin_ia32_movsd (v2df, v2df)
17456 v2df __builtin_ia32_unpckhpd (v2df, v2df)
17457 v2df __builtin_ia32_unpcklpd (v2df, v2df)
17458 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
17459 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
17460 v4si __builtin_ia32_paddd128 (v4si, v4si)
17461 v2di __builtin_ia32_paddq128 (v2di, v2di)
17462 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
17463 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
17464 v4si __builtin_ia32_psubd128 (v4si, v4si)
17465 v2di __builtin_ia32_psubq128 (v2di, v2di)
17466 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
17467 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
17468 v2di __builtin_ia32_pand128 (v2di, v2di)
17469 v2di __builtin_ia32_pandn128 (v2di, v2di)
17470 v2di __builtin_ia32_por128 (v2di, v2di)
17471 v2di __builtin_ia32_pxor128 (v2di, v2di)
17472 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
17473 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
17474 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
17475 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
17476 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
17477 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
17478 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
17479 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
17480 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
17481 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
17482 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
17483 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
17484 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
17485 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
17486 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
17487 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
17488 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
17489 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
17490 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
17491 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
17492 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
17493 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
17494 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
17495 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
17496 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
17497 v2df __builtin_ia32_loadupd (double *)
17498 void __builtin_ia32_storeupd (double *, v2df)
17499 v2df __builtin_ia32_loadhpd (v2df, double const *)
17500 v2df __builtin_ia32_loadlpd (v2df, double const *)
17501 int __builtin_ia32_movmskpd (v2df)
17502 int __builtin_ia32_pmovmskb128 (v16qi)
17503 void __builtin_ia32_movnti (int *, int)
17504 void __builtin_ia32_movnti64 (long long int *, long long int)
17505 void __builtin_ia32_movntpd (double *, v2df)
17506 void __builtin_ia32_movntdq (v2df *, v2df)
17507 v4si __builtin_ia32_pshufd (v4si, int)
17508 v8hi __builtin_ia32_pshuflw (v8hi, int)
17509 v8hi __builtin_ia32_pshufhw (v8hi, int)
17510 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
17511 v2df __builtin_ia32_sqrtpd (v2df)
17512 v2df __builtin_ia32_sqrtsd (v2df)
17513 v2df __builtin_ia32_shufpd (v2df, v2df, int)
17514 v2df __builtin_ia32_cvtdq2pd (v4si)
17515 v4sf __builtin_ia32_cvtdq2ps (v4si)
17516 v4si __builtin_ia32_cvtpd2dq (v2df)
17517 v2si __builtin_ia32_cvtpd2pi (v2df)
17518 v4sf __builtin_ia32_cvtpd2ps (v2df)
17519 v4si __builtin_ia32_cvttpd2dq (v2df)
17520 v2si __builtin_ia32_cvttpd2pi (v2df)
17521 v2df __builtin_ia32_cvtpi2pd (v2si)
17522 int __builtin_ia32_cvtsd2si (v2df)
17523 int __builtin_ia32_cvttsd2si (v2df)
17524 long long __builtin_ia32_cvtsd2si64 (v2df)
17525 long long __builtin_ia32_cvttsd2si64 (v2df)
17526 v4si __builtin_ia32_cvtps2dq (v4sf)
17527 v2df __builtin_ia32_cvtps2pd (v4sf)
17528 v4si __builtin_ia32_cvttps2dq (v4sf)
17529 v2df __builtin_ia32_cvtsi2sd (v2df, int)
17530 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
17531 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
17532 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
17533 void __builtin_ia32_clflush (const void *)
17534 void __builtin_ia32_lfence (void)
17535 void __builtin_ia32_mfence (void)
17536 v16qi __builtin_ia32_loaddqu (const char *)
17537 void __builtin_ia32_storedqu (char *, v16qi)
17538 v1di __builtin_ia32_pmuludq (v2si, v2si)
17539 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
17540 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
17541 v4si __builtin_ia32_pslld128 (v4si, v4si)
17542 v2di __builtin_ia32_psllq128 (v2di, v2di)
17543 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
17544 v4si __builtin_ia32_psrld128 (v4si, v4si)
17545 v2di __builtin_ia32_psrlq128 (v2di, v2di)
17546 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
17547 v4si __builtin_ia32_psrad128 (v4si, v4si)
17548 v2di __builtin_ia32_pslldqi128 (v2di, int)
17549 v8hi __builtin_ia32_psllwi128 (v8hi, int)
17550 v4si __builtin_ia32_pslldi128 (v4si, int)
17551 v2di __builtin_ia32_psllqi128 (v2di, int)
17552 v2di __builtin_ia32_psrldqi128 (v2di, int)
17553 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
17554 v4si __builtin_ia32_psrldi128 (v4si, int)
17555 v2di __builtin_ia32_psrlqi128 (v2di, int)
17556 v8hi __builtin_ia32_psrawi128 (v8hi, int)
17557 v4si __builtin_ia32_psradi128 (v4si, int)
17558 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
17559 v2di __builtin_ia32_movq128 (v2di)
17560 @end smallexample
17561
17562 The following built-in functions are available when @option{-msse3} is used.
17563 All of them generate the machine instruction that is part of the name.
17564
17565 @smallexample
17566 v2df __builtin_ia32_addsubpd (v2df, v2df)
17567 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
17568 v2df __builtin_ia32_haddpd (v2df, v2df)
17569 v4sf __builtin_ia32_haddps (v4sf, v4sf)
17570 v2df __builtin_ia32_hsubpd (v2df, v2df)
17571 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
17572 v16qi __builtin_ia32_lddqu (char const *)
17573 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
17574 v4sf __builtin_ia32_movshdup (v4sf)
17575 v4sf __builtin_ia32_movsldup (v4sf)
17576 void __builtin_ia32_mwait (unsigned int, unsigned int)
17577 @end smallexample
17578
17579 The following built-in functions are available when @option{-mssse3} is used.
17580 All of them generate the machine instruction that is part of the name.
17581
17582 @smallexample
17583 v2si __builtin_ia32_phaddd (v2si, v2si)
17584 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
17585 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
17586 v2si __builtin_ia32_phsubd (v2si, v2si)
17587 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
17588 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
17589 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
17590 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
17591 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
17592 v8qi __builtin_ia32_psignb (v8qi, v8qi)
17593 v2si __builtin_ia32_psignd (v2si, v2si)
17594 v4hi __builtin_ia32_psignw (v4hi, v4hi)
17595 v1di __builtin_ia32_palignr (v1di, v1di, int)
17596 v8qi __builtin_ia32_pabsb (v8qi)
17597 v2si __builtin_ia32_pabsd (v2si)
17598 v4hi __builtin_ia32_pabsw (v4hi)
17599 @end smallexample
17600
17601 The following built-in functions are available when @option{-mssse3} is used.
17602 All of them generate the machine instruction that is part of the name.
17603
17604 @smallexample
17605 v4si __builtin_ia32_phaddd128 (v4si, v4si)
17606 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
17607 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
17608 v4si __builtin_ia32_phsubd128 (v4si, v4si)
17609 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
17610 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
17611 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
17612 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
17613 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
17614 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
17615 v4si __builtin_ia32_psignd128 (v4si, v4si)
17616 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
17617 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
17618 v16qi __builtin_ia32_pabsb128 (v16qi)
17619 v4si __builtin_ia32_pabsd128 (v4si)
17620 v8hi __builtin_ia32_pabsw128 (v8hi)
17621 @end smallexample
17622
17623 The following built-in functions are available when @option{-msse4.1} is
17624 used. All of them generate the machine instruction that is part of the
17625 name.
17626
17627 @smallexample
17628 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
17629 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
17630 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
17631 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
17632 v2df __builtin_ia32_dppd (v2df, v2df, const int)
17633 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
17634 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
17635 v2di __builtin_ia32_movntdqa (v2di *);
17636 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
17637 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
17638 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
17639 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
17640 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
17641 v8hi __builtin_ia32_phminposuw128 (v8hi)
17642 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
17643 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
17644 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
17645 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
17646 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
17647 v4si __builtin_ia32_pminsd128 (v4si, v4si)
17648 v4si __builtin_ia32_pminud128 (v4si, v4si)
17649 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
17650 v4si __builtin_ia32_pmovsxbd128 (v16qi)
17651 v2di __builtin_ia32_pmovsxbq128 (v16qi)
17652 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
17653 v2di __builtin_ia32_pmovsxdq128 (v4si)
17654 v4si __builtin_ia32_pmovsxwd128 (v8hi)
17655 v2di __builtin_ia32_pmovsxwq128 (v8hi)
17656 v4si __builtin_ia32_pmovzxbd128 (v16qi)
17657 v2di __builtin_ia32_pmovzxbq128 (v16qi)
17658 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
17659 v2di __builtin_ia32_pmovzxdq128 (v4si)
17660 v4si __builtin_ia32_pmovzxwd128 (v8hi)
17661 v2di __builtin_ia32_pmovzxwq128 (v8hi)
17662 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
17663 v4si __builtin_ia32_pmulld128 (v4si, v4si)
17664 int __builtin_ia32_ptestc128 (v2di, v2di)
17665 int __builtin_ia32_ptestnzc128 (v2di, v2di)
17666 int __builtin_ia32_ptestz128 (v2di, v2di)
17667 v2df __builtin_ia32_roundpd (v2df, const int)
17668 v4sf __builtin_ia32_roundps (v4sf, const int)
17669 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
17670 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
17671 @end smallexample
17672
17673 The following built-in functions are available when @option{-msse4.1} is
17674 used.
17675
17676 @table @code
17677 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
17678 Generates the @code{insertps} machine instruction.
17679 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
17680 Generates the @code{pextrb} machine instruction.
17681 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
17682 Generates the @code{pinsrb} machine instruction.
17683 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
17684 Generates the @code{pinsrd} machine instruction.
17685 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
17686 Generates the @code{pinsrq} machine instruction in 64bit mode.
17687 @end table
17688
17689 The following built-in functions are changed to generate new SSE4.1
17690 instructions when @option{-msse4.1} is used.
17691
17692 @table @code
17693 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
17694 Generates the @code{extractps} machine instruction.
17695 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
17696 Generates the @code{pextrd} machine instruction.
17697 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
17698 Generates the @code{pextrq} machine instruction in 64bit mode.
17699 @end table
17700
17701 The following built-in functions are available when @option{-msse4.2} is
17702 used. All of them generate the machine instruction that is part of the
17703 name.
17704
17705 @smallexample
17706 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
17707 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
17708 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
17709 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
17710 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
17711 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
17712 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
17713 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
17714 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
17715 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
17716 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
17717 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
17718 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
17719 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
17720 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
17721 @end smallexample
17722
17723 The following built-in functions are available when @option{-msse4.2} is
17724 used.
17725
17726 @table @code
17727 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
17728 Generates the @code{crc32b} machine instruction.
17729 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
17730 Generates the @code{crc32w} machine instruction.
17731 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
17732 Generates the @code{crc32l} machine instruction.
17733 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
17734 Generates the @code{crc32q} machine instruction.
17735 @end table
17736
17737 The following built-in functions are changed to generate new SSE4.2
17738 instructions when @option{-msse4.2} is used.
17739
17740 @table @code
17741 @item int __builtin_popcount (unsigned int)
17742 Generates the @code{popcntl} machine instruction.
17743 @item int __builtin_popcountl (unsigned long)
17744 Generates the @code{popcntl} or @code{popcntq} machine instruction,
17745 depending on the size of @code{unsigned long}.
17746 @item int __builtin_popcountll (unsigned long long)
17747 Generates the @code{popcntq} machine instruction.
17748 @end table
17749
17750 The following built-in functions are available when @option{-mavx} is
17751 used. All of them generate the machine instruction that is part of the
17752 name.
17753
17754 @smallexample
17755 v4df __builtin_ia32_addpd256 (v4df,v4df)
17756 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
17757 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
17758 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
17759 v4df __builtin_ia32_andnpd256 (v4df,v4df)
17760 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
17761 v4df __builtin_ia32_andpd256 (v4df,v4df)
17762 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
17763 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
17764 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
17765 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
17766 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
17767 v2df __builtin_ia32_cmppd (v2df,v2df,int)
17768 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
17769 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
17770 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
17771 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
17772 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
17773 v4df __builtin_ia32_cvtdq2pd256 (v4si)
17774 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
17775 v4si __builtin_ia32_cvtpd2dq256 (v4df)
17776 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
17777 v8si __builtin_ia32_cvtps2dq256 (v8sf)
17778 v4df __builtin_ia32_cvtps2pd256 (v4sf)
17779 v4si __builtin_ia32_cvttpd2dq256 (v4df)
17780 v8si __builtin_ia32_cvttps2dq256 (v8sf)
17781 v4df __builtin_ia32_divpd256 (v4df,v4df)
17782 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
17783 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
17784 v4df __builtin_ia32_haddpd256 (v4df,v4df)
17785 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
17786 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
17787 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
17788 v32qi __builtin_ia32_lddqu256 (pcchar)
17789 v32qi __builtin_ia32_loaddqu256 (pcchar)
17790 v4df __builtin_ia32_loadupd256 (pcdouble)
17791 v8sf __builtin_ia32_loadups256 (pcfloat)
17792 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
17793 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
17794 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
17795 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
17796 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
17797 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
17798 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
17799 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
17800 v4df __builtin_ia32_maxpd256 (v4df,v4df)
17801 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
17802 v4df __builtin_ia32_minpd256 (v4df,v4df)
17803 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
17804 v4df __builtin_ia32_movddup256 (v4df)
17805 int __builtin_ia32_movmskpd256 (v4df)
17806 int __builtin_ia32_movmskps256 (v8sf)
17807 v8sf __builtin_ia32_movshdup256 (v8sf)
17808 v8sf __builtin_ia32_movsldup256 (v8sf)
17809 v4df __builtin_ia32_mulpd256 (v4df,v4df)
17810 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
17811 v4df __builtin_ia32_orpd256 (v4df,v4df)
17812 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
17813 v2df __builtin_ia32_pd_pd256 (v4df)
17814 v4df __builtin_ia32_pd256_pd (v2df)
17815 v4sf __builtin_ia32_ps_ps256 (v8sf)
17816 v8sf __builtin_ia32_ps256_ps (v4sf)
17817 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
17818 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
17819 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
17820 v8sf __builtin_ia32_rcpps256 (v8sf)
17821 v4df __builtin_ia32_roundpd256 (v4df,int)
17822 v8sf __builtin_ia32_roundps256 (v8sf,int)
17823 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
17824 v8sf __builtin_ia32_rsqrtps256 (v8sf)
17825 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
17826 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
17827 v4si __builtin_ia32_si_si256 (v8si)
17828 v8si __builtin_ia32_si256_si (v4si)
17829 v4df __builtin_ia32_sqrtpd256 (v4df)
17830 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
17831 v8sf __builtin_ia32_sqrtps256 (v8sf)
17832 void __builtin_ia32_storedqu256 (pchar,v32qi)
17833 void __builtin_ia32_storeupd256 (pdouble,v4df)
17834 void __builtin_ia32_storeups256 (pfloat,v8sf)
17835 v4df __builtin_ia32_subpd256 (v4df,v4df)
17836 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
17837 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
17838 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
17839 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
17840 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
17841 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
17842 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
17843 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
17844 v4sf __builtin_ia32_vbroadcastss (pcfloat)
17845 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
17846 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
17847 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
17848 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
17849 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
17850 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
17851 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
17852 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
17853 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
17854 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
17855 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
17856 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
17857 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
17858 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
17859 v2df __builtin_ia32_vpermilpd (v2df,int)
17860 v4df __builtin_ia32_vpermilpd256 (v4df,int)
17861 v4sf __builtin_ia32_vpermilps (v4sf,int)
17862 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
17863 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
17864 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
17865 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
17866 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
17867 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
17868 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
17869 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
17870 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
17871 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
17872 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
17873 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
17874 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
17875 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
17876 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
17877 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
17878 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
17879 void __builtin_ia32_vzeroall (void)
17880 void __builtin_ia32_vzeroupper (void)
17881 v4df __builtin_ia32_xorpd256 (v4df,v4df)
17882 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
17883 @end smallexample
17884
17885 The following built-in functions are available when @option{-mavx2} is
17886 used. All of them generate the machine instruction that is part of the
17887 name.
17888
17889 @smallexample
17890 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
17891 v32qi __builtin_ia32_pabsb256 (v32qi)
17892 v16hi __builtin_ia32_pabsw256 (v16hi)
17893 v8si __builtin_ia32_pabsd256 (v8si)
17894 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
17895 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
17896 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
17897 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
17898 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
17899 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
17900 v8si __builtin_ia32_paddd256 (v8si,v8si)
17901 v4di __builtin_ia32_paddq256 (v4di,v4di)
17902 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
17903 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
17904 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
17905 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
17906 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
17907 v4di __builtin_ia32_andsi256 (v4di,v4di)
17908 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
17909 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
17910 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
17911 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
17912 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
17913 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
17914 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
17915 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
17916 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
17917 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
17918 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
17919 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
17920 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
17921 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
17922 v8si __builtin_ia32_phaddd256 (v8si,v8si)
17923 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
17924 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
17925 v8si __builtin_ia32_phsubd256 (v8si,v8si)
17926 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
17927 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
17928 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
17929 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
17930 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
17931 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
17932 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
17933 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
17934 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
17935 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
17936 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
17937 v8si __builtin_ia32_pminsd256 (v8si,v8si)
17938 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
17939 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
17940 v8si __builtin_ia32_pminud256 (v8si,v8si)
17941 int __builtin_ia32_pmovmskb256 (v32qi)
17942 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
17943 v8si __builtin_ia32_pmovsxbd256 (v16qi)
17944 v4di __builtin_ia32_pmovsxbq256 (v16qi)
17945 v8si __builtin_ia32_pmovsxwd256 (v8hi)
17946 v4di __builtin_ia32_pmovsxwq256 (v8hi)
17947 v4di __builtin_ia32_pmovsxdq256 (v4si)
17948 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
17949 v8si __builtin_ia32_pmovzxbd256 (v16qi)
17950 v4di __builtin_ia32_pmovzxbq256 (v16qi)
17951 v8si __builtin_ia32_pmovzxwd256 (v8hi)
17952 v4di __builtin_ia32_pmovzxwq256 (v8hi)
17953 v4di __builtin_ia32_pmovzxdq256 (v4si)
17954 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
17955 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
17956 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
17957 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
17958 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
17959 v8si __builtin_ia32_pmulld256 (v8si,v8si)
17960 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
17961 v4di __builtin_ia32_por256 (v4di,v4di)
17962 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
17963 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
17964 v8si __builtin_ia32_pshufd256 (v8si,int)
17965 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
17966 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
17967 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
17968 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
17969 v8si __builtin_ia32_psignd256 (v8si,v8si)
17970 v4di __builtin_ia32_pslldqi256 (v4di,int)
17971 v16hi __builtin_ia32_psllwi256 (16hi,int)
17972 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
17973 v8si __builtin_ia32_pslldi256 (v8si,int)
17974 v8si __builtin_ia32_pslld256(v8si,v4si)
17975 v4di __builtin_ia32_psllqi256 (v4di,int)
17976 v4di __builtin_ia32_psllq256(v4di,v2di)
17977 v16hi __builtin_ia32_psrawi256 (v16hi,int)
17978 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
17979 v8si __builtin_ia32_psradi256 (v8si,int)
17980 v8si __builtin_ia32_psrad256 (v8si,v4si)
17981 v4di __builtin_ia32_psrldqi256 (v4di, int)
17982 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
17983 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
17984 v8si __builtin_ia32_psrldi256 (v8si,int)
17985 v8si __builtin_ia32_psrld256 (v8si,v4si)
17986 v4di __builtin_ia32_psrlqi256 (v4di,int)
17987 v4di __builtin_ia32_psrlq256(v4di,v2di)
17988 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
17989 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
17990 v8si __builtin_ia32_psubd256 (v8si,v8si)
17991 v4di __builtin_ia32_psubq256 (v4di,v4di)
17992 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
17993 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
17994 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
17995 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
17996 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
17997 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
17998 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
17999 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
18000 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
18001 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
18002 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
18003 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
18004 v4di __builtin_ia32_pxor256 (v4di,v4di)
18005 v4di __builtin_ia32_movntdqa256 (pv4di)
18006 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
18007 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
18008 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
18009 v4di __builtin_ia32_vbroadcastsi256 (v2di)
18010 v4si __builtin_ia32_pblendd128 (v4si,v4si)
18011 v8si __builtin_ia32_pblendd256 (v8si,v8si)
18012 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
18013 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
18014 v8si __builtin_ia32_pbroadcastd256 (v4si)
18015 v4di __builtin_ia32_pbroadcastq256 (v2di)
18016 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
18017 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
18018 v4si __builtin_ia32_pbroadcastd128 (v4si)
18019 v2di __builtin_ia32_pbroadcastq128 (v2di)
18020 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
18021 v4df __builtin_ia32_permdf256 (v4df,int)
18022 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
18023 v4di __builtin_ia32_permdi256 (v4di,int)
18024 v4di __builtin_ia32_permti256 (v4di,v4di,int)
18025 v4di __builtin_ia32_extract128i256 (v4di,int)
18026 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
18027 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
18028 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
18029 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
18030 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
18031 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
18032 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
18033 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
18034 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
18035 v8si __builtin_ia32_psllv8si (v8si,v8si)
18036 v4si __builtin_ia32_psllv4si (v4si,v4si)
18037 v4di __builtin_ia32_psllv4di (v4di,v4di)
18038 v2di __builtin_ia32_psllv2di (v2di,v2di)
18039 v8si __builtin_ia32_psrav8si (v8si,v8si)
18040 v4si __builtin_ia32_psrav4si (v4si,v4si)
18041 v8si __builtin_ia32_psrlv8si (v8si,v8si)
18042 v4si __builtin_ia32_psrlv4si (v4si,v4si)
18043 v4di __builtin_ia32_psrlv4di (v4di,v4di)
18044 v2di __builtin_ia32_psrlv2di (v2di,v2di)
18045 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
18046 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
18047 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
18048 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
18049 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
18050 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
18051 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
18052 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
18053 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
18054 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
18055 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
18056 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
18057 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
18058 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
18059 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
18060 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
18061 @end smallexample
18062
18063 The following built-in functions are available when @option{-maes} is
18064 used. All of them generate the machine instruction that is part of the
18065 name.
18066
18067 @smallexample
18068 v2di __builtin_ia32_aesenc128 (v2di, v2di)
18069 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
18070 v2di __builtin_ia32_aesdec128 (v2di, v2di)
18071 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
18072 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
18073 v2di __builtin_ia32_aesimc128 (v2di)
18074 @end smallexample
18075
18076 The following built-in function is available when @option{-mpclmul} is
18077 used.
18078
18079 @table @code
18080 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
18081 Generates the @code{pclmulqdq} machine instruction.
18082 @end table
18083
18084 The following built-in function is available when @option{-mfsgsbase} is
18085 used. All of them generate the machine instruction that is part of the
18086 name.
18087
18088 @smallexample
18089 unsigned int __builtin_ia32_rdfsbase32 (void)
18090 unsigned long long __builtin_ia32_rdfsbase64 (void)
18091 unsigned int __builtin_ia32_rdgsbase32 (void)
18092 unsigned long long __builtin_ia32_rdgsbase64 (void)
18093 void _writefsbase_u32 (unsigned int)
18094 void _writefsbase_u64 (unsigned long long)
18095 void _writegsbase_u32 (unsigned int)
18096 void _writegsbase_u64 (unsigned long long)
18097 @end smallexample
18098
18099 The following built-in function is available when @option{-mrdrnd} is
18100 used. All of them generate the machine instruction that is part of the
18101 name.
18102
18103 @smallexample
18104 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
18105 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
18106 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
18107 @end smallexample
18108
18109 The following built-in functions are available when @option{-msse4a} is used.
18110 All of them generate the machine instruction that is part of the name.
18111
18112 @smallexample
18113 void __builtin_ia32_movntsd (double *, v2df)
18114 void __builtin_ia32_movntss (float *, v4sf)
18115 v2di __builtin_ia32_extrq (v2di, v16qi)
18116 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
18117 v2di __builtin_ia32_insertq (v2di, v2di)
18118 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
18119 @end smallexample
18120
18121 The following built-in functions are available when @option{-mxop} is used.
18122 @smallexample
18123 v2df __builtin_ia32_vfrczpd (v2df)
18124 v4sf __builtin_ia32_vfrczps (v4sf)
18125 v2df __builtin_ia32_vfrczsd (v2df)
18126 v4sf __builtin_ia32_vfrczss (v4sf)
18127 v4df __builtin_ia32_vfrczpd256 (v4df)
18128 v8sf __builtin_ia32_vfrczps256 (v8sf)
18129 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
18130 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
18131 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
18132 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
18133 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
18134 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
18135 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
18136 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
18137 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
18138 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
18139 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
18140 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
18141 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
18142 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
18143 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18144 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
18145 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
18146 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
18147 v4si __builtin_ia32_vpcomequd (v4si, v4si)
18148 v2di __builtin_ia32_vpcomequq (v2di, v2di)
18149 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
18150 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
18151 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
18152 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
18153 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
18154 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
18155 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
18156 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
18157 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
18158 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
18159 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
18160 v4si __builtin_ia32_vpcomged (v4si, v4si)
18161 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
18162 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
18163 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
18164 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
18165 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
18166 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
18167 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
18168 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
18169 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
18170 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
18171 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
18172 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
18173 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
18174 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
18175 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
18176 v4si __builtin_ia32_vpcomled (v4si, v4si)
18177 v2di __builtin_ia32_vpcomleq (v2di, v2di)
18178 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
18179 v4si __builtin_ia32_vpcomleud (v4si, v4si)
18180 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
18181 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
18182 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
18183 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
18184 v4si __builtin_ia32_vpcomltd (v4si, v4si)
18185 v2di __builtin_ia32_vpcomltq (v2di, v2di)
18186 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
18187 v4si __builtin_ia32_vpcomltud (v4si, v4si)
18188 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
18189 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
18190 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
18191 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
18192 v4si __builtin_ia32_vpcomned (v4si, v4si)
18193 v2di __builtin_ia32_vpcomneq (v2di, v2di)
18194 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
18195 v4si __builtin_ia32_vpcomneud (v4si, v4si)
18196 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
18197 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
18198 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
18199 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
18200 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
18201 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
18202 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
18203 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
18204 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
18205 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
18206 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
18207 v4si __builtin_ia32_vphaddbd (v16qi)
18208 v2di __builtin_ia32_vphaddbq (v16qi)
18209 v8hi __builtin_ia32_vphaddbw (v16qi)
18210 v2di __builtin_ia32_vphadddq (v4si)
18211 v4si __builtin_ia32_vphaddubd (v16qi)
18212 v2di __builtin_ia32_vphaddubq (v16qi)
18213 v8hi __builtin_ia32_vphaddubw (v16qi)
18214 v2di __builtin_ia32_vphaddudq (v4si)
18215 v4si __builtin_ia32_vphadduwd (v8hi)
18216 v2di __builtin_ia32_vphadduwq (v8hi)
18217 v4si __builtin_ia32_vphaddwd (v8hi)
18218 v2di __builtin_ia32_vphaddwq (v8hi)
18219 v8hi __builtin_ia32_vphsubbw (v16qi)
18220 v2di __builtin_ia32_vphsubdq (v4si)
18221 v4si __builtin_ia32_vphsubwd (v8hi)
18222 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
18223 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
18224 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
18225 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
18226 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
18227 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
18228 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
18229 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
18230 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
18231 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
18232 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
18233 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
18234 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
18235 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
18236 v4si __builtin_ia32_vprotd (v4si, v4si)
18237 v2di __builtin_ia32_vprotq (v2di, v2di)
18238 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
18239 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
18240 v4si __builtin_ia32_vpshad (v4si, v4si)
18241 v2di __builtin_ia32_vpshaq (v2di, v2di)
18242 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
18243 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
18244 v4si __builtin_ia32_vpshld (v4si, v4si)
18245 v2di __builtin_ia32_vpshlq (v2di, v2di)
18246 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
18247 @end smallexample
18248
18249 The following built-in functions are available when @option{-mfma4} is used.
18250 All of them generate the machine instruction that is part of the name.
18251
18252 @smallexample
18253 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
18254 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
18255 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
18256 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
18257 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
18258 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
18259 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
18260 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
18261 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
18262 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
18263 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
18264 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
18265 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
18266 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
18267 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
18268 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
18269 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
18270 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
18271 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
18272 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
18273 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
18274 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
18275 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
18276 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
18277 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
18278 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
18279 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
18280 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
18281 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
18282 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
18283 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
18284 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
18285
18286 @end smallexample
18287
18288 The following built-in functions are available when @option{-mlwp} is used.
18289
18290 @smallexample
18291 void __builtin_ia32_llwpcb16 (void *);
18292 void __builtin_ia32_llwpcb32 (void *);
18293 void __builtin_ia32_llwpcb64 (void *);
18294 void * __builtin_ia32_llwpcb16 (void);
18295 void * __builtin_ia32_llwpcb32 (void);
18296 void * __builtin_ia32_llwpcb64 (void);
18297 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
18298 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
18299 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
18300 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
18301 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
18302 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
18303 @end smallexample
18304
18305 The following built-in functions are available when @option{-mbmi} is used.
18306 All of them generate the machine instruction that is part of the name.
18307 @smallexample
18308 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
18309 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
18310 @end smallexample
18311
18312 The following built-in functions are available when @option{-mbmi2} is used.
18313 All of them generate the machine instruction that is part of the name.
18314 @smallexample
18315 unsigned int _bzhi_u32 (unsigned int, unsigned int)
18316 unsigned int _pdep_u32 (unsigned int, unsigned int)
18317 unsigned int _pext_u32 (unsigned int, unsigned int)
18318 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
18319 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
18320 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
18321 @end smallexample
18322
18323 The following built-in functions are available when @option{-mlzcnt} is used.
18324 All of them generate the machine instruction that is part of the name.
18325 @smallexample
18326 unsigned short __builtin_ia32_lzcnt_16(unsigned short);
18327 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
18328 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
18329 @end smallexample
18330
18331 The following built-in functions are available when @option{-mfxsr} is used.
18332 All of them generate the machine instruction that is part of the name.
18333 @smallexample
18334 void __builtin_ia32_fxsave (void *)
18335 void __builtin_ia32_fxrstor (void *)
18336 void __builtin_ia32_fxsave64 (void *)
18337 void __builtin_ia32_fxrstor64 (void *)
18338 @end smallexample
18339
18340 The following built-in functions are available when @option{-mxsave} is used.
18341 All of them generate the machine instruction that is part of the name.
18342 @smallexample
18343 void __builtin_ia32_xsave (void *, long long)
18344 void __builtin_ia32_xrstor (void *, long long)
18345 void __builtin_ia32_xsave64 (void *, long long)
18346 void __builtin_ia32_xrstor64 (void *, long long)
18347 @end smallexample
18348
18349 The following built-in functions are available when @option{-mxsaveopt} is used.
18350 All of them generate the machine instruction that is part of the name.
18351 @smallexample
18352 void __builtin_ia32_xsaveopt (void *, long long)
18353 void __builtin_ia32_xsaveopt64 (void *, long long)
18354 @end smallexample
18355
18356 The following built-in functions are available when @option{-mtbm} is used.
18357 Both of them generate the immediate form of the bextr machine instruction.
18358 @smallexample
18359 unsigned int __builtin_ia32_bextri_u32 (unsigned int, const unsigned int);
18360 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long, const unsigned long long);
18361 @end smallexample
18362
18363
18364 The following built-in functions are available when @option{-m3dnow} is used.
18365 All of them generate the machine instruction that is part of the name.
18366
18367 @smallexample
18368 void __builtin_ia32_femms (void)
18369 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
18370 v2si __builtin_ia32_pf2id (v2sf)
18371 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
18372 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
18373 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
18374 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
18375 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
18376 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
18377 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
18378 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
18379 v2sf __builtin_ia32_pfrcp (v2sf)
18380 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
18381 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
18382 v2sf __builtin_ia32_pfrsqrt (v2sf)
18383 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
18384 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
18385 v2sf __builtin_ia32_pi2fd (v2si)
18386 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
18387 @end smallexample
18388
18389 The following built-in functions are available when both @option{-m3dnow}
18390 and @option{-march=athlon} are used. All of them generate the machine
18391 instruction that is part of the name.
18392
18393 @smallexample
18394 v2si __builtin_ia32_pf2iw (v2sf)
18395 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
18396 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
18397 v2sf __builtin_ia32_pi2fw (v2si)
18398 v2sf __builtin_ia32_pswapdsf (v2sf)
18399 v2si __builtin_ia32_pswapdsi (v2si)
18400 @end smallexample
18401
18402 The following built-in functions are available when @option{-mrtm} is used
18403 They are used for restricted transactional memory. These are the internal
18404 low level functions. Normally the functions in
18405 @ref{x86 transactional memory intrinsics} should be used instead.
18406
18407 @smallexample
18408 int __builtin_ia32_xbegin ()
18409 void __builtin_ia32_xend ()
18410 void __builtin_ia32_xabort (status)
18411 int __builtin_ia32_xtest ()
18412 @end smallexample
18413
18414 The following built-in functions are available when @option{-mmwaitx} is used.
18415 All of them generate the machine instruction that is part of the name.
18416 @smallexample
18417 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
18418 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
18419 @end smallexample
18420
18421 The following built-in functions are available when @option{-mclzero} is used.
18422 All of them generate the machine instruction that is part of the name.
18423 @smallexample
18424 void __builtin_i32_clzero (void *)
18425 @end smallexample
18426
18427 The following built-in functions are available when @option{-mpku} is used.
18428 They generate reads and writes to PKRU.
18429 @smallexample
18430 void __builtin_ia32_wrpkru (unsigned int)
18431 unsigned int __builtin_ia32_rdpkru ()
18432 @end smallexample
18433
18434 @node x86 transactional memory intrinsics
18435 @subsection x86 Transactional Memory Intrinsics
18436
18437 These hardware transactional memory intrinsics for x86 allow you to use
18438 memory transactions with RTM (Restricted Transactional Memory).
18439 This support is enabled with the @option{-mrtm} option.
18440 For using HLE (Hardware Lock Elision) see
18441 @ref{x86 specific memory model extensions for transactional memory} instead.
18442
18443 A memory transaction commits all changes to memory in an atomic way,
18444 as visible to other threads. If the transaction fails it is rolled back
18445 and all side effects discarded.
18446
18447 Generally there is no guarantee that a memory transaction ever succeeds
18448 and suitable fallback code always needs to be supplied.
18449
18450 @deftypefn {RTM Function} {unsigned} _xbegin ()
18451 Start a RTM (Restricted Transactional Memory) transaction.
18452 Returns @code{_XBEGIN_STARTED} when the transaction
18453 started successfully (note this is not 0, so the constant has to be
18454 explicitly tested).
18455
18456 If the transaction aborts, all side-effects
18457 are undone and an abort code encoded as a bit mask is returned.
18458 The following macros are defined:
18459
18460 @table @code
18461 @item _XABORT_EXPLICIT
18462 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
18463 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
18464 @item _XABORT_RETRY
18465 Transaction retry is possible.
18466 @item _XABORT_CONFLICT
18467 Transaction abort due to a memory conflict with another thread.
18468 @item _XABORT_CAPACITY
18469 Transaction abort due to the transaction using too much memory.
18470 @item _XABORT_DEBUG
18471 Transaction abort due to a debug trap.
18472 @item _XABORT_NESTED
18473 Transaction abort in an inner nested transaction.
18474 @end table
18475
18476 There is no guarantee
18477 any transaction ever succeeds, so there always needs to be a valid
18478 fallback path.
18479 @end deftypefn
18480
18481 @deftypefn {RTM Function} {void} _xend ()
18482 Commit the current transaction. When no transaction is active this faults.
18483 All memory side-effects of the transaction become visible
18484 to other threads in an atomic manner.
18485 @end deftypefn
18486
18487 @deftypefn {RTM Function} {int} _xtest ()
18488 Return a nonzero value if a transaction is currently active, otherwise 0.
18489 @end deftypefn
18490
18491 @deftypefn {RTM Function} {void} _xabort (status)
18492 Abort the current transaction. When no transaction is active this is a no-op.
18493 The @var{status} is an 8-bit constant; its value is encoded in the return
18494 value from @code{_xbegin}.
18495 @end deftypefn
18496
18497 Here is an example showing handling for @code{_XABORT_RETRY}
18498 and a fallback path for other failures:
18499
18500 @smallexample
18501 #include <immintrin.h>
18502
18503 int n_tries, max_tries;
18504 unsigned status = _XABORT_EXPLICIT;
18505 ...
18506
18507 for (n_tries = 0; n_tries < max_tries; n_tries++)
18508 @{
18509 status = _xbegin ();
18510 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
18511 break;
18512 @}
18513 if (status == _XBEGIN_STARTED)
18514 @{
18515 ... transaction code...
18516 _xend ();
18517 @}
18518 else
18519 @{
18520 ... non-transactional fallback path...
18521 @}
18522 @end smallexample
18523
18524 @noindent
18525 Note that, in most cases, the transactional and non-transactional code
18526 must synchronize together to ensure consistency.
18527
18528 @node Target Format Checks
18529 @section Format Checks Specific to Particular Target Machines
18530
18531 For some target machines, GCC supports additional options to the
18532 format attribute
18533 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
18534
18535 @menu
18536 * Solaris Format Checks::
18537 * Darwin Format Checks::
18538 @end menu
18539
18540 @node Solaris Format Checks
18541 @subsection Solaris Format Checks
18542
18543 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
18544 check. @code{cmn_err} accepts a subset of the standard @code{printf}
18545 conversions, and the two-argument @code{%b} conversion for displaying
18546 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
18547
18548 @node Darwin Format Checks
18549 @subsection Darwin Format Checks
18550
18551 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
18552 attribute context. Declarations made with such attribution are parsed for correct syntax
18553 and format argument types. However, parsing of the format string itself is currently undefined
18554 and is not carried out by this version of the compiler.
18555
18556 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
18557 also be used as format arguments. Note that the relevant headers are only likely to be
18558 available on Darwin (OSX) installations. On such installations, the XCode and system
18559 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
18560 associated functions.
18561
18562 @node Pragmas
18563 @section Pragmas Accepted by GCC
18564 @cindex pragmas
18565 @cindex @code{#pragma}
18566
18567 GCC supports several types of pragmas, primarily in order to compile
18568 code originally written for other compilers. Note that in general
18569 we do not recommend the use of pragmas; @xref{Function Attributes},
18570 for further explanation.
18571
18572 @menu
18573 * AArch64 Pragmas::
18574 * ARM Pragmas::
18575 * M32C Pragmas::
18576 * MeP Pragmas::
18577 * RS/6000 and PowerPC Pragmas::
18578 * S/390 Pragmas::
18579 * Darwin Pragmas::
18580 * Solaris Pragmas::
18581 * Symbol-Renaming Pragmas::
18582 * Structure-Layout Pragmas::
18583 * Weak Pragmas::
18584 * Diagnostic Pragmas::
18585 * Visibility Pragmas::
18586 * Push/Pop Macro Pragmas::
18587 * Function Specific Option Pragmas::
18588 * Loop-Specific Pragmas::
18589 @end menu
18590
18591 @node AArch64 Pragmas
18592 @subsection AArch64 Pragmas
18593
18594 The pragmas defined by the AArch64 target correspond to the AArch64
18595 target function attributes. They can be specified as below:
18596 @smallexample
18597 #pragma GCC target("string")
18598 @end smallexample
18599
18600 where @code{@var{string}} can be any string accepted as an AArch64 target
18601 attribute. @xref{AArch64 Function Attributes}, for more details
18602 on the permissible values of @code{string}.
18603
18604 @node ARM Pragmas
18605 @subsection ARM Pragmas
18606
18607 The ARM target defines pragmas for controlling the default addition of
18608 @code{long_call} and @code{short_call} attributes to functions.
18609 @xref{Function Attributes}, for information about the effects of these
18610 attributes.
18611
18612 @table @code
18613 @item long_calls
18614 @cindex pragma, long_calls
18615 Set all subsequent functions to have the @code{long_call} attribute.
18616
18617 @item no_long_calls
18618 @cindex pragma, no_long_calls
18619 Set all subsequent functions to have the @code{short_call} attribute.
18620
18621 @item long_calls_off
18622 @cindex pragma, long_calls_off
18623 Do not affect the @code{long_call} or @code{short_call} attributes of
18624 subsequent functions.
18625 @end table
18626
18627 @node M32C Pragmas
18628 @subsection M32C Pragmas
18629
18630 @table @code
18631 @item GCC memregs @var{number}
18632 @cindex pragma, memregs
18633 Overrides the command-line option @code{-memregs=} for the current
18634 file. Use with care! This pragma must be before any function in the
18635 file, and mixing different memregs values in different objects may
18636 make them incompatible. This pragma is useful when a
18637 performance-critical function uses a memreg for temporary values,
18638 as it may allow you to reduce the number of memregs used.
18639
18640 @item ADDRESS @var{name} @var{address}
18641 @cindex pragma, address
18642 For any declared symbols matching @var{name}, this does three things
18643 to that symbol: it forces the symbol to be located at the given
18644 address (a number), it forces the symbol to be volatile, and it
18645 changes the symbol's scope to be static. This pragma exists for
18646 compatibility with other compilers, but note that the common
18647 @code{1234H} numeric syntax is not supported (use @code{0x1234}
18648 instead). Example:
18649
18650 @smallexample
18651 #pragma ADDRESS port3 0x103
18652 char port3;
18653 @end smallexample
18654
18655 @end table
18656
18657 @node MeP Pragmas
18658 @subsection MeP Pragmas
18659
18660 @table @code
18661
18662 @item custom io_volatile (on|off)
18663 @cindex pragma, custom io_volatile
18664 Overrides the command-line option @code{-mio-volatile} for the current
18665 file. Note that for compatibility with future GCC releases, this
18666 option should only be used once before any @code{io} variables in each
18667 file.
18668
18669 @item GCC coprocessor available @var{registers}
18670 @cindex pragma, coprocessor available
18671 Specifies which coprocessor registers are available to the register
18672 allocator. @var{registers} may be a single register, register range
18673 separated by ellipses, or comma-separated list of those. Example:
18674
18675 @smallexample
18676 #pragma GCC coprocessor available $c0...$c10, $c28
18677 @end smallexample
18678
18679 @item GCC coprocessor call_saved @var{registers}
18680 @cindex pragma, coprocessor call_saved
18681 Specifies which coprocessor registers are to be saved and restored by
18682 any function using them. @var{registers} may be a single register,
18683 register range separated by ellipses, or comma-separated list of
18684 those. Example:
18685
18686 @smallexample
18687 #pragma GCC coprocessor call_saved $c4...$c6, $c31
18688 @end smallexample
18689
18690 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
18691 @cindex pragma, coprocessor subclass
18692 Creates and defines a register class. These register classes can be
18693 used by inline @code{asm} constructs. @var{registers} may be a single
18694 register, register range separated by ellipses, or comma-separated
18695 list of those. Example:
18696
18697 @smallexample
18698 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
18699
18700 asm ("cpfoo %0" : "=B" (x));
18701 @end smallexample
18702
18703 @item GCC disinterrupt @var{name} , @var{name} @dots{}
18704 @cindex pragma, disinterrupt
18705 For the named functions, the compiler adds code to disable interrupts
18706 for the duration of those functions. If any functions so named
18707 are not encountered in the source, a warning is emitted that the pragma is
18708 not used. Examples:
18709
18710 @smallexample
18711 #pragma disinterrupt foo
18712 #pragma disinterrupt bar, grill
18713 int foo () @{ @dots{} @}
18714 @end smallexample
18715
18716 @item GCC call @var{name} , @var{name} @dots{}
18717 @cindex pragma, call
18718 For the named functions, the compiler always uses a register-indirect
18719 call model when calling the named functions. Examples:
18720
18721 @smallexample
18722 extern int foo ();
18723 #pragma call foo
18724 @end smallexample
18725
18726 @end table
18727
18728 @node RS/6000 and PowerPC Pragmas
18729 @subsection RS/6000 and PowerPC Pragmas
18730
18731 The RS/6000 and PowerPC targets define one pragma for controlling
18732 whether or not the @code{longcall} attribute is added to function
18733 declarations by default. This pragma overrides the @option{-mlongcall}
18734 option, but not the @code{longcall} and @code{shortcall} attributes.
18735 @xref{RS/6000 and PowerPC Options}, for more information about when long
18736 calls are and are not necessary.
18737
18738 @table @code
18739 @item longcall (1)
18740 @cindex pragma, longcall
18741 Apply the @code{longcall} attribute to all subsequent function
18742 declarations.
18743
18744 @item longcall (0)
18745 Do not apply the @code{longcall} attribute to subsequent function
18746 declarations.
18747 @end table
18748
18749 @c Describe h8300 pragmas here.
18750 @c Describe sh pragmas here.
18751 @c Describe v850 pragmas here.
18752
18753 @node S/390 Pragmas
18754 @subsection S/390 Pragmas
18755
18756 The pragmas defined by the S/390 target correspond to the S/390
18757 target function attributes and some the additional options:
18758
18759 @table @samp
18760 @item zvector
18761 @itemx no-zvector
18762 @end table
18763
18764 Note that options of the pragma, unlike options of the target
18765 attribute, do change the value of preprocessor macros like
18766 @code{__VEC__}. They can be specified as below:
18767
18768 @smallexample
18769 #pragma GCC target("string[,string]...")
18770 #pragma GCC target("string"[,"string"]...)
18771 @end smallexample
18772
18773 @node Darwin Pragmas
18774 @subsection Darwin Pragmas
18775
18776 The following pragmas are available for all architectures running the
18777 Darwin operating system. These are useful for compatibility with other
18778 Mac OS compilers.
18779
18780 @table @code
18781 @item mark @var{tokens}@dots{}
18782 @cindex pragma, mark
18783 This pragma is accepted, but has no effect.
18784
18785 @item options align=@var{alignment}
18786 @cindex pragma, options align
18787 This pragma sets the alignment of fields in structures. The values of
18788 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
18789 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
18790 properly; to restore the previous setting, use @code{reset} for the
18791 @var{alignment}.
18792
18793 @item segment @var{tokens}@dots{}
18794 @cindex pragma, segment
18795 This pragma is accepted, but has no effect.
18796
18797 @item unused (@var{var} [, @var{var}]@dots{})
18798 @cindex pragma, unused
18799 This pragma declares variables to be possibly unused. GCC does not
18800 produce warnings for the listed variables. The effect is similar to
18801 that of the @code{unused} attribute, except that this pragma may appear
18802 anywhere within the variables' scopes.
18803 @end table
18804
18805 @node Solaris Pragmas
18806 @subsection Solaris Pragmas
18807
18808 The Solaris target supports @code{#pragma redefine_extname}
18809 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
18810 @code{#pragma} directives for compatibility with the system compiler.
18811
18812 @table @code
18813 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
18814 @cindex pragma, align
18815
18816 Increase the minimum alignment of each @var{variable} to @var{alignment}.
18817 This is the same as GCC's @code{aligned} attribute @pxref{Variable
18818 Attributes}). Macro expansion occurs on the arguments to this pragma
18819 when compiling C and Objective-C@. It does not currently occur when
18820 compiling C++, but this is a bug which may be fixed in a future
18821 release.
18822
18823 @item fini (@var{function} [, @var{function}]...)
18824 @cindex pragma, fini
18825
18826 This pragma causes each listed @var{function} to be called after
18827 main, or during shared module unloading, by adding a call to the
18828 @code{.fini} section.
18829
18830 @item init (@var{function} [, @var{function}]...)
18831 @cindex pragma, init
18832
18833 This pragma causes each listed @var{function} to be called during
18834 initialization (before @code{main}) or during shared module loading, by
18835 adding a call to the @code{.init} section.
18836
18837 @end table
18838
18839 @node Symbol-Renaming Pragmas
18840 @subsection Symbol-Renaming Pragmas
18841
18842 GCC supports a @code{#pragma} directive that changes the name used in
18843 assembly for a given declaration. While this pragma is supported on all
18844 platforms, it is intended primarily to provide compatibility with the
18845 Solaris system headers. This effect can also be achieved using the asm
18846 labels extension (@pxref{Asm Labels}).
18847
18848 @table @code
18849 @item redefine_extname @var{oldname} @var{newname}
18850 @cindex pragma, redefine_extname
18851
18852 This pragma gives the C function @var{oldname} the assembly symbol
18853 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
18854 is defined if this pragma is available (currently on all platforms).
18855 @end table
18856
18857 This pragma and the asm labels extension interact in a complicated
18858 manner. Here are some corner cases you may want to be aware of:
18859
18860 @enumerate
18861 @item This pragma silently applies only to declarations with external
18862 linkage. Asm labels do not have this restriction.
18863
18864 @item In C++, this pragma silently applies only to declarations with
18865 ``C'' linkage. Again, asm labels do not have this restriction.
18866
18867 @item If either of the ways of changing the assembly name of a
18868 declaration are applied to a declaration whose assembly name has
18869 already been determined (either by a previous use of one of these
18870 features, or because the compiler needed the assembly name in order to
18871 generate code), and the new name is different, a warning issues and
18872 the name does not change.
18873
18874 @item The @var{oldname} used by @code{#pragma redefine_extname} is
18875 always the C-language name.
18876 @end enumerate
18877
18878 @node Structure-Layout Pragmas
18879 @subsection Structure-Layout Pragmas
18880
18881 For compatibility with Microsoft Windows compilers, GCC supports a
18882 set of @code{#pragma} directives that change the maximum alignment of
18883 members of structures (other than zero-width bit-fields), unions, and
18884 classes subsequently defined. The @var{n} value below always is required
18885 to be a small power of two and specifies the new alignment in bytes.
18886
18887 @enumerate
18888 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
18889 @item @code{#pragma pack()} sets the alignment to the one that was in
18890 effect when compilation started (see also command-line option
18891 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
18892 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
18893 setting on an internal stack and then optionally sets the new alignment.
18894 @item @code{#pragma pack(pop)} restores the alignment setting to the one
18895 saved at the top of the internal stack (and removes that stack entry).
18896 Note that @code{#pragma pack([@var{n}])} does not influence this internal
18897 stack; thus it is possible to have @code{#pragma pack(push)} followed by
18898 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
18899 @code{#pragma pack(pop)}.
18900 @end enumerate
18901
18902 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
18903 directive which lays out structures and unions subsequently defined as the
18904 documented @code{__attribute__ ((ms_struct))}.
18905
18906 @enumerate
18907 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
18908 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
18909 @item @code{#pragma ms_struct reset} goes back to the default layout.
18910 @end enumerate
18911
18912 Most targets also support the @code{#pragma scalar_storage_order} directive
18913 which lays out structures and unions subsequently defined as the documented
18914 @code{__attribute__ ((scalar_storage_order))}.
18915
18916 @enumerate
18917 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
18918 of the scalar fields to big-endian.
18919 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
18920 of the scalar fields to little-endian.
18921 @item @code{#pragma scalar_storage_order default} goes back to the endianness
18922 that was in effect when compilation started (see also command-line option
18923 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
18924 @end enumerate
18925
18926 @node Weak Pragmas
18927 @subsection Weak Pragmas
18928
18929 For compatibility with SVR4, GCC supports a set of @code{#pragma}
18930 directives for declaring symbols to be weak, and defining weak
18931 aliases.
18932
18933 @table @code
18934 @item #pragma weak @var{symbol}
18935 @cindex pragma, weak
18936 This pragma declares @var{symbol} to be weak, as if the declaration
18937 had the attribute of the same name. The pragma may appear before
18938 or after the declaration of @var{symbol}. It is not an error for
18939 @var{symbol} to never be defined at all.
18940
18941 @item #pragma weak @var{symbol1} = @var{symbol2}
18942 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
18943 It is an error if @var{symbol2} is not defined in the current
18944 translation unit.
18945 @end table
18946
18947 @node Diagnostic Pragmas
18948 @subsection Diagnostic Pragmas
18949
18950 GCC allows the user to selectively enable or disable certain types of
18951 diagnostics, and change the kind of the diagnostic. For example, a
18952 project's policy might require that all sources compile with
18953 @option{-Werror} but certain files might have exceptions allowing
18954 specific types of warnings. Or, a project might selectively enable
18955 diagnostics and treat them as errors depending on which preprocessor
18956 macros are defined.
18957
18958 @table @code
18959 @item #pragma GCC diagnostic @var{kind} @var{option}
18960 @cindex pragma, diagnostic
18961
18962 Modifies the disposition of a diagnostic. Note that not all
18963 diagnostics are modifiable; at the moment only warnings (normally
18964 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
18965 Use @option{-fdiagnostics-show-option} to determine which diagnostics
18966 are controllable and which option controls them.
18967
18968 @var{kind} is @samp{error} to treat this diagnostic as an error,
18969 @samp{warning} to treat it like a warning (even if @option{-Werror} is
18970 in effect), or @samp{ignored} if the diagnostic is to be ignored.
18971 @var{option} is a double quoted string that matches the command-line
18972 option.
18973
18974 @smallexample
18975 #pragma GCC diagnostic warning "-Wformat"
18976 #pragma GCC diagnostic error "-Wformat"
18977 #pragma GCC diagnostic ignored "-Wformat"
18978 @end smallexample
18979
18980 Note that these pragmas override any command-line options. GCC keeps
18981 track of the location of each pragma, and issues diagnostics according
18982 to the state as of that point in the source file. Thus, pragmas occurring
18983 after a line do not affect diagnostics caused by that line.
18984
18985 @item #pragma GCC diagnostic push
18986 @itemx #pragma GCC diagnostic pop
18987
18988 Causes GCC to remember the state of the diagnostics as of each
18989 @code{push}, and restore to that point at each @code{pop}. If a
18990 @code{pop} has no matching @code{push}, the command-line options are
18991 restored.
18992
18993 @smallexample
18994 #pragma GCC diagnostic error "-Wuninitialized"
18995 foo(a); /* error is given for this one */
18996 #pragma GCC diagnostic push
18997 #pragma GCC diagnostic ignored "-Wuninitialized"
18998 foo(b); /* no diagnostic for this one */
18999 #pragma GCC diagnostic pop
19000 foo(c); /* error is given for this one */
19001 #pragma GCC diagnostic pop
19002 foo(d); /* depends on command-line options */
19003 @end smallexample
19004
19005 @end table
19006
19007 GCC also offers a simple mechanism for printing messages during
19008 compilation.
19009
19010 @table @code
19011 @item #pragma message @var{string}
19012 @cindex pragma, diagnostic
19013
19014 Prints @var{string} as a compiler message on compilation. The message
19015 is informational only, and is neither a compilation warning nor an error.
19016
19017 @smallexample
19018 #pragma message "Compiling " __FILE__ "..."
19019 @end smallexample
19020
19021 @var{string} may be parenthesized, and is printed with location
19022 information. For example,
19023
19024 @smallexample
19025 #define DO_PRAGMA(x) _Pragma (#x)
19026 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
19027
19028 TODO(Remember to fix this)
19029 @end smallexample
19030
19031 @noindent
19032 prints @samp{/tmp/file.c:4: note: #pragma message:
19033 TODO - Remember to fix this}.
19034
19035 @end table
19036
19037 @node Visibility Pragmas
19038 @subsection Visibility Pragmas
19039
19040 @table @code
19041 @item #pragma GCC visibility push(@var{visibility})
19042 @itemx #pragma GCC visibility pop
19043 @cindex pragma, visibility
19044
19045 This pragma allows the user to set the visibility for multiple
19046 declarations without having to give each a visibility attribute
19047 (@pxref{Function Attributes}).
19048
19049 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
19050 declarations. Class members and template specializations are not
19051 affected; if you want to override the visibility for a particular
19052 member or instantiation, you must use an attribute.
19053
19054 @end table
19055
19056
19057 @node Push/Pop Macro Pragmas
19058 @subsection Push/Pop Macro Pragmas
19059
19060 For compatibility with Microsoft Windows compilers, GCC supports
19061 @samp{#pragma push_macro(@var{"macro_name"})}
19062 and @samp{#pragma pop_macro(@var{"macro_name"})}.
19063
19064 @table @code
19065 @item #pragma push_macro(@var{"macro_name"})
19066 @cindex pragma, push_macro
19067 This pragma saves the value of the macro named as @var{macro_name} to
19068 the top of the stack for this macro.
19069
19070 @item #pragma pop_macro(@var{"macro_name"})
19071 @cindex pragma, pop_macro
19072 This pragma sets the value of the macro named as @var{macro_name} to
19073 the value on top of the stack for this macro. If the stack for
19074 @var{macro_name} is empty, the value of the macro remains unchanged.
19075 @end table
19076
19077 For example:
19078
19079 @smallexample
19080 #define X 1
19081 #pragma push_macro("X")
19082 #undef X
19083 #define X -1
19084 #pragma pop_macro("X")
19085 int x [X];
19086 @end smallexample
19087
19088 @noindent
19089 In this example, the definition of X as 1 is saved by @code{#pragma
19090 push_macro} and restored by @code{#pragma pop_macro}.
19091
19092 @node Function Specific Option Pragmas
19093 @subsection Function Specific Option Pragmas
19094
19095 @table @code
19096 @item #pragma GCC target (@var{"string"}...)
19097 @cindex pragma GCC target
19098
19099 This pragma allows you to set target specific options for functions
19100 defined later in the source file. One or more strings can be
19101 specified. Each function that is defined after this point is as
19102 if @code{attribute((target("STRING")))} was specified for that
19103 function. The parenthesis around the options is optional.
19104 @xref{Function Attributes}, for more information about the
19105 @code{target} attribute and the attribute syntax.
19106
19107 The @code{#pragma GCC target} pragma is presently implemented for
19108 x86, PowerPC, and Nios II targets only.
19109 @end table
19110
19111 @table @code
19112 @item #pragma GCC optimize (@var{"string"}...)
19113 @cindex pragma GCC optimize
19114
19115 This pragma allows you to set global optimization options for functions
19116 defined later in the source file. One or more strings can be
19117 specified. Each function that is defined after this point is as
19118 if @code{attribute((optimize("STRING")))} was specified for that
19119 function. The parenthesis around the options is optional.
19120 @xref{Function Attributes}, for more information about the
19121 @code{optimize} attribute and the attribute syntax.
19122 @end table
19123
19124 @table @code
19125 @item #pragma GCC push_options
19126 @itemx #pragma GCC pop_options
19127 @cindex pragma GCC push_options
19128 @cindex pragma GCC pop_options
19129
19130 These pragmas maintain a stack of the current target and optimization
19131 options. It is intended for include files where you temporarily want
19132 to switch to using a different @samp{#pragma GCC target} or
19133 @samp{#pragma GCC optimize} and then to pop back to the previous
19134 options.
19135 @end table
19136
19137 @table @code
19138 @item #pragma GCC reset_options
19139 @cindex pragma GCC reset_options
19140
19141 This pragma clears the current @code{#pragma GCC target} and
19142 @code{#pragma GCC optimize} to use the default switches as specified
19143 on the command line.
19144 @end table
19145
19146 @node Loop-Specific Pragmas
19147 @subsection Loop-Specific Pragmas
19148
19149 @table @code
19150 @item #pragma GCC ivdep
19151 @cindex pragma GCC ivdep
19152 @end table
19153
19154 With this pragma, the programmer asserts that there are no loop-carried
19155 dependencies which would prevent consecutive iterations of
19156 the following loop from executing concurrently with SIMD
19157 (single instruction multiple data) instructions.
19158
19159 For example, the compiler can only unconditionally vectorize the following
19160 loop with the pragma:
19161
19162 @smallexample
19163 void foo (int n, int *a, int *b, int *c)
19164 @{
19165 int i, j;
19166 #pragma GCC ivdep
19167 for (i = 0; i < n; ++i)
19168 a[i] = b[i] + c[i];
19169 @}
19170 @end smallexample
19171
19172 @noindent
19173 In this example, using the @code{restrict} qualifier had the same
19174 effect. In the following example, that would not be possible. Assume
19175 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
19176 that it can unconditionally vectorize the following loop:
19177
19178 @smallexample
19179 void ignore_vec_dep (int *a, int k, int c, int m)
19180 @{
19181 #pragma GCC ivdep
19182 for (int i = 0; i < m; i++)
19183 a[i] = a[i + k] * c;
19184 @}
19185 @end smallexample
19186
19187
19188 @node Unnamed Fields
19189 @section Unnamed Structure and Union Fields
19190 @cindex @code{struct}
19191 @cindex @code{union}
19192
19193 As permitted by ISO C11 and for compatibility with other compilers,
19194 GCC allows you to define
19195 a structure or union that contains, as fields, structures and unions
19196 without names. For example:
19197
19198 @smallexample
19199 struct @{
19200 int a;
19201 union @{
19202 int b;
19203 float c;
19204 @};
19205 int d;
19206 @} foo;
19207 @end smallexample
19208
19209 @noindent
19210 In this example, you are able to access members of the unnamed
19211 union with code like @samp{foo.b}. Note that only unnamed structs and
19212 unions are allowed, you may not have, for example, an unnamed
19213 @code{int}.
19214
19215 You must never create such structures that cause ambiguous field definitions.
19216 For example, in this structure:
19217
19218 @smallexample
19219 struct @{
19220 int a;
19221 struct @{
19222 int a;
19223 @};
19224 @} foo;
19225 @end smallexample
19226
19227 @noindent
19228 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
19229 The compiler gives errors for such constructs.
19230
19231 @opindex fms-extensions
19232 Unless @option{-fms-extensions} is used, the unnamed field must be a
19233 structure or union definition without a tag (for example, @samp{struct
19234 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
19235 also be a definition with a tag such as @samp{struct foo @{ int a;
19236 @};}, a reference to a previously defined structure or union such as
19237 @samp{struct foo;}, or a reference to a @code{typedef} name for a
19238 previously defined structure or union type.
19239
19240 @opindex fplan9-extensions
19241 The option @option{-fplan9-extensions} enables
19242 @option{-fms-extensions} as well as two other extensions. First, a
19243 pointer to a structure is automatically converted to a pointer to an
19244 anonymous field for assignments and function calls. For example:
19245
19246 @smallexample
19247 struct s1 @{ int a; @};
19248 struct s2 @{ struct s1; @};
19249 extern void f1 (struct s1 *);
19250 void f2 (struct s2 *p) @{ f1 (p); @}
19251 @end smallexample
19252
19253 @noindent
19254 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
19255 converted into a pointer to the anonymous field.
19256
19257 Second, when the type of an anonymous field is a @code{typedef} for a
19258 @code{struct} or @code{union}, code may refer to the field using the
19259 name of the @code{typedef}.
19260
19261 @smallexample
19262 typedef struct @{ int a; @} s1;
19263 struct s2 @{ s1; @};
19264 s1 f1 (struct s2 *p) @{ return p->s1; @}
19265 @end smallexample
19266
19267 These usages are only permitted when they are not ambiguous.
19268
19269 @node Thread-Local
19270 @section Thread-Local Storage
19271 @cindex Thread-Local Storage
19272 @cindex @acronym{TLS}
19273 @cindex @code{__thread}
19274
19275 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
19276 are allocated such that there is one instance of the variable per extant
19277 thread. The runtime model GCC uses to implement this originates
19278 in the IA-64 processor-specific ABI, but has since been migrated
19279 to other processors as well. It requires significant support from
19280 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
19281 system libraries (@file{libc.so} and @file{libpthread.so}), so it
19282 is not available everywhere.
19283
19284 At the user level, the extension is visible with a new storage
19285 class keyword: @code{__thread}. For example:
19286
19287 @smallexample
19288 __thread int i;
19289 extern __thread struct state s;
19290 static __thread char *p;
19291 @end smallexample
19292
19293 The @code{__thread} specifier may be used alone, with the @code{extern}
19294 or @code{static} specifiers, but with no other storage class specifier.
19295 When used with @code{extern} or @code{static}, @code{__thread} must appear
19296 immediately after the other storage class specifier.
19297
19298 The @code{__thread} specifier may be applied to any global, file-scoped
19299 static, function-scoped static, or static data member of a class. It may
19300 not be applied to block-scoped automatic or non-static data member.
19301
19302 When the address-of operator is applied to a thread-local variable, it is
19303 evaluated at run time and returns the address of the current thread's
19304 instance of that variable. An address so obtained may be used by any
19305 thread. When a thread terminates, any pointers to thread-local variables
19306 in that thread become invalid.
19307
19308 No static initialization may refer to the address of a thread-local variable.
19309
19310 In C++, if an initializer is present for a thread-local variable, it must
19311 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
19312 standard.
19313
19314 See @uref{http://www.akkadia.org/drepper/tls.pdf,
19315 ELF Handling For Thread-Local Storage} for a detailed explanation of
19316 the four thread-local storage addressing models, and how the runtime
19317 is expected to function.
19318
19319 @menu
19320 * C99 Thread-Local Edits::
19321 * C++98 Thread-Local Edits::
19322 @end menu
19323
19324 @node C99 Thread-Local Edits
19325 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
19326
19327 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
19328 that document the exact semantics of the language extension.
19329
19330 @itemize @bullet
19331 @item
19332 @cite{5.1.2 Execution environments}
19333
19334 Add new text after paragraph 1
19335
19336 @quotation
19337 Within either execution environment, a @dfn{thread} is a flow of
19338 control within a program. It is implementation defined whether
19339 or not there may be more than one thread associated with a program.
19340 It is implementation defined how threads beyond the first are
19341 created, the name and type of the function called at thread
19342 startup, and how threads may be terminated. However, objects
19343 with thread storage duration shall be initialized before thread
19344 startup.
19345 @end quotation
19346
19347 @item
19348 @cite{6.2.4 Storage durations of objects}
19349
19350 Add new text before paragraph 3
19351
19352 @quotation
19353 An object whose identifier is declared with the storage-class
19354 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
19355 Its lifetime is the entire execution of the thread, and its
19356 stored value is initialized only once, prior to thread startup.
19357 @end quotation
19358
19359 @item
19360 @cite{6.4.1 Keywords}
19361
19362 Add @code{__thread}.
19363
19364 @item
19365 @cite{6.7.1 Storage-class specifiers}
19366
19367 Add @code{__thread} to the list of storage class specifiers in
19368 paragraph 1.
19369
19370 Change paragraph 2 to
19371
19372 @quotation
19373 With the exception of @code{__thread}, at most one storage-class
19374 specifier may be given [@dots{}]. The @code{__thread} specifier may
19375 be used alone, or immediately following @code{extern} or
19376 @code{static}.
19377 @end quotation
19378
19379 Add new text after paragraph 6
19380
19381 @quotation
19382 The declaration of an identifier for a variable that has
19383 block scope that specifies @code{__thread} shall also
19384 specify either @code{extern} or @code{static}.
19385
19386 The @code{__thread} specifier shall be used only with
19387 variables.
19388 @end quotation
19389 @end itemize
19390
19391 @node C++98 Thread-Local Edits
19392 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
19393
19394 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
19395 that document the exact semantics of the language extension.
19396
19397 @itemize @bullet
19398 @item
19399 @b{[intro.execution]}
19400
19401 New text after paragraph 4
19402
19403 @quotation
19404 A @dfn{thread} is a flow of control within the abstract machine.
19405 It is implementation defined whether or not there may be more than
19406 one thread.
19407 @end quotation
19408
19409 New text after paragraph 7
19410
19411 @quotation
19412 It is unspecified whether additional action must be taken to
19413 ensure when and whether side effects are visible to other threads.
19414 @end quotation
19415
19416 @item
19417 @b{[lex.key]}
19418
19419 Add @code{__thread}.
19420
19421 @item
19422 @b{[basic.start.main]}
19423
19424 Add after paragraph 5
19425
19426 @quotation
19427 The thread that begins execution at the @code{main} function is called
19428 the @dfn{main thread}. It is implementation defined how functions
19429 beginning threads other than the main thread are designated or typed.
19430 A function so designated, as well as the @code{main} function, is called
19431 a @dfn{thread startup function}. It is implementation defined what
19432 happens if a thread startup function returns. It is implementation
19433 defined what happens to other threads when any thread calls @code{exit}.
19434 @end quotation
19435
19436 @item
19437 @b{[basic.start.init]}
19438
19439 Add after paragraph 4
19440
19441 @quotation
19442 The storage for an object of thread storage duration shall be
19443 statically initialized before the first statement of the thread startup
19444 function. An object of thread storage duration shall not require
19445 dynamic initialization.
19446 @end quotation
19447
19448 @item
19449 @b{[basic.start.term]}
19450
19451 Add after paragraph 3
19452
19453 @quotation
19454 The type of an object with thread storage duration shall not have a
19455 non-trivial destructor, nor shall it be an array type whose elements
19456 (directly or indirectly) have non-trivial destructors.
19457 @end quotation
19458
19459 @item
19460 @b{[basic.stc]}
19461
19462 Add ``thread storage duration'' to the list in paragraph 1.
19463
19464 Change paragraph 2
19465
19466 @quotation
19467 Thread, static, and automatic storage durations are associated with
19468 objects introduced by declarations [@dots{}].
19469 @end quotation
19470
19471 Add @code{__thread} to the list of specifiers in paragraph 3.
19472
19473 @item
19474 @b{[basic.stc.thread]}
19475
19476 New section before @b{[basic.stc.static]}
19477
19478 @quotation
19479 The keyword @code{__thread} applied to a non-local object gives the
19480 object thread storage duration.
19481
19482 A local variable or class data member declared both @code{static}
19483 and @code{__thread} gives the variable or member thread storage
19484 duration.
19485 @end quotation
19486
19487 @item
19488 @b{[basic.stc.static]}
19489
19490 Change paragraph 1
19491
19492 @quotation
19493 All objects that have neither thread storage duration, dynamic
19494 storage duration nor are local [@dots{}].
19495 @end quotation
19496
19497 @item
19498 @b{[dcl.stc]}
19499
19500 Add @code{__thread} to the list in paragraph 1.
19501
19502 Change paragraph 1
19503
19504 @quotation
19505 With the exception of @code{__thread}, at most one
19506 @var{storage-class-specifier} shall appear in a given
19507 @var{decl-specifier-seq}. The @code{__thread} specifier may
19508 be used alone, or immediately following the @code{extern} or
19509 @code{static} specifiers. [@dots{}]
19510 @end quotation
19511
19512 Add after paragraph 5
19513
19514 @quotation
19515 The @code{__thread} specifier can be applied only to the names of objects
19516 and to anonymous unions.
19517 @end quotation
19518
19519 @item
19520 @b{[class.mem]}
19521
19522 Add after paragraph 6
19523
19524 @quotation
19525 Non-@code{static} members shall not be @code{__thread}.
19526 @end quotation
19527 @end itemize
19528
19529 @node Binary constants
19530 @section Binary Constants using the @samp{0b} Prefix
19531 @cindex Binary constants using the @samp{0b} prefix
19532
19533 Integer constants can be written as binary constants, consisting of a
19534 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
19535 @samp{0B}. This is particularly useful in environments that operate a
19536 lot on the bit level (like microcontrollers).
19537
19538 The following statements are identical:
19539
19540 @smallexample
19541 i = 42;
19542 i = 0x2a;
19543 i = 052;
19544 i = 0b101010;
19545 @end smallexample
19546
19547 The type of these constants follows the same rules as for octal or
19548 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
19549 can be applied.
19550
19551 @node C++ Extensions
19552 @chapter Extensions to the C++ Language
19553 @cindex extensions, C++ language
19554 @cindex C++ language extensions
19555
19556 The GNU compiler provides these extensions to the C++ language (and you
19557 can also use most of the C language extensions in your C++ programs). If you
19558 want to write code that checks whether these features are available, you can
19559 test for the GNU compiler the same way as for C programs: check for a
19560 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
19561 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
19562 Predefined Macros,cpp,The GNU C Preprocessor}).
19563
19564 @menu
19565 * C++ Volatiles:: What constitutes an access to a volatile object.
19566 * Restricted Pointers:: C99 restricted pointers and references.
19567 * Vague Linkage:: Where G++ puts inlines, vtables and such.
19568 * C++ Interface:: You can use a single C++ header file for both
19569 declarations and definitions.
19570 * Template Instantiation:: Methods for ensuring that exactly one copy of
19571 each needed template instantiation is emitted.
19572 * Bound member functions:: You can extract a function pointer to the
19573 method denoted by a @samp{->*} or @samp{.*} expression.
19574 * C++ Attributes:: Variable, function, and type attributes for C++ only.
19575 * Function Multiversioning:: Declaring multiple function versions.
19576 * Namespace Association:: Strong using-directives for namespace association.
19577 * Type Traits:: Compiler support for type traits.
19578 * C++ Concepts:: Improved support for generic programming.
19579 * Java Exceptions:: Tweaking exception handling to work with Java.
19580 * Deprecated Features:: Things will disappear from G++.
19581 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
19582 @end menu
19583
19584 @node C++ Volatiles
19585 @section When is a Volatile C++ Object Accessed?
19586 @cindex accessing volatiles
19587 @cindex volatile read
19588 @cindex volatile write
19589 @cindex volatile access
19590
19591 The C++ standard differs from the C standard in its treatment of
19592 volatile objects. It fails to specify what constitutes a volatile
19593 access, except to say that C++ should behave in a similar manner to C
19594 with respect to volatiles, where possible. However, the different
19595 lvalueness of expressions between C and C++ complicate the behavior.
19596 G++ behaves the same as GCC for volatile access, @xref{C
19597 Extensions,,Volatiles}, for a description of GCC's behavior.
19598
19599 The C and C++ language specifications differ when an object is
19600 accessed in a void context:
19601
19602 @smallexample
19603 volatile int *src = @var{somevalue};
19604 *src;
19605 @end smallexample
19606
19607 The C++ standard specifies that such expressions do not undergo lvalue
19608 to rvalue conversion, and that the type of the dereferenced object may
19609 be incomplete. The C++ standard does not specify explicitly that it
19610 is lvalue to rvalue conversion that is responsible for causing an
19611 access. There is reason to believe that it is, because otherwise
19612 certain simple expressions become undefined. However, because it
19613 would surprise most programmers, G++ treats dereferencing a pointer to
19614 volatile object of complete type as GCC would do for an equivalent
19615 type in C@. When the object has incomplete type, G++ issues a
19616 warning; if you wish to force an error, you must force a conversion to
19617 rvalue with, for instance, a static cast.
19618
19619 When using a reference to volatile, G++ does not treat equivalent
19620 expressions as accesses to volatiles, but instead issues a warning that
19621 no volatile is accessed. The rationale for this is that otherwise it
19622 becomes difficult to determine where volatile access occur, and not
19623 possible to ignore the return value from functions returning volatile
19624 references. Again, if you wish to force a read, cast the reference to
19625 an rvalue.
19626
19627 G++ implements the same behavior as GCC does when assigning to a
19628 volatile object---there is no reread of the assigned-to object, the
19629 assigned rvalue is reused. Note that in C++ assignment expressions
19630 are lvalues, and if used as an lvalue, the volatile object is
19631 referred to. For instance, @var{vref} refers to @var{vobj}, as
19632 expected, in the following example:
19633
19634 @smallexample
19635 volatile int vobj;
19636 volatile int &vref = vobj = @var{something};
19637 @end smallexample
19638
19639 @node Restricted Pointers
19640 @section Restricting Pointer Aliasing
19641 @cindex restricted pointers
19642 @cindex restricted references
19643 @cindex restricted this pointer
19644
19645 As with the C front end, G++ understands the C99 feature of restricted pointers,
19646 specified with the @code{__restrict__}, or @code{__restrict} type
19647 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
19648 language flag, @code{restrict} is not a keyword in C++.
19649
19650 In addition to allowing restricted pointers, you can specify restricted
19651 references, which indicate that the reference is not aliased in the local
19652 context.
19653
19654 @smallexample
19655 void fn (int *__restrict__ rptr, int &__restrict__ rref)
19656 @{
19657 /* @r{@dots{}} */
19658 @}
19659 @end smallexample
19660
19661 @noindent
19662 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
19663 @var{rref} refers to a (different) unaliased integer.
19664
19665 You may also specify whether a member function's @var{this} pointer is
19666 unaliased by using @code{__restrict__} as a member function qualifier.
19667
19668 @smallexample
19669 void T::fn () __restrict__
19670 @{
19671 /* @r{@dots{}} */
19672 @}
19673 @end smallexample
19674
19675 @noindent
19676 Within the body of @code{T::fn}, @var{this} has the effective
19677 definition @code{T *__restrict__ const this}. Notice that the
19678 interpretation of a @code{__restrict__} member function qualifier is
19679 different to that of @code{const} or @code{volatile} qualifier, in that it
19680 is applied to the pointer rather than the object. This is consistent with
19681 other compilers that implement restricted pointers.
19682
19683 As with all outermost parameter qualifiers, @code{__restrict__} is
19684 ignored in function definition matching. This means you only need to
19685 specify @code{__restrict__} in a function definition, rather than
19686 in a function prototype as well.
19687
19688 @node Vague Linkage
19689 @section Vague Linkage
19690 @cindex vague linkage
19691
19692 There are several constructs in C++ that require space in the object
19693 file but are not clearly tied to a single translation unit. We say that
19694 these constructs have ``vague linkage''. Typically such constructs are
19695 emitted wherever they are needed, though sometimes we can be more
19696 clever.
19697
19698 @table @asis
19699 @item Inline Functions
19700 Inline functions are typically defined in a header file which can be
19701 included in many different compilations. Hopefully they can usually be
19702 inlined, but sometimes an out-of-line copy is necessary, if the address
19703 of the function is taken or if inlining fails. In general, we emit an
19704 out-of-line copy in all translation units where one is needed. As an
19705 exception, we only emit inline virtual functions with the vtable, since
19706 it always requires a copy.
19707
19708 Local static variables and string constants used in an inline function
19709 are also considered to have vague linkage, since they must be shared
19710 between all inlined and out-of-line instances of the function.
19711
19712 @item VTables
19713 @cindex vtable
19714 C++ virtual functions are implemented in most compilers using a lookup
19715 table, known as a vtable. The vtable contains pointers to the virtual
19716 functions provided by a class, and each object of the class contains a
19717 pointer to its vtable (or vtables, in some multiple-inheritance
19718 situations). If the class declares any non-inline, non-pure virtual
19719 functions, the first one is chosen as the ``key method'' for the class,
19720 and the vtable is only emitted in the translation unit where the key
19721 method is defined.
19722
19723 @emph{Note:} If the chosen key method is later defined as inline, the
19724 vtable is still emitted in every translation unit that defines it.
19725 Make sure that any inline virtuals are declared inline in the class
19726 body, even if they are not defined there.
19727
19728 @item @code{type_info} objects
19729 @cindex @code{type_info}
19730 @cindex RTTI
19731 C++ requires information about types to be written out in order to
19732 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
19733 For polymorphic classes (classes with virtual functions), the @samp{type_info}
19734 object is written out along with the vtable so that @samp{dynamic_cast}
19735 can determine the dynamic type of a class object at run time. For all
19736 other types, we write out the @samp{type_info} object when it is used: when
19737 applying @samp{typeid} to an expression, throwing an object, or
19738 referring to a type in a catch clause or exception specification.
19739
19740 @item Template Instantiations
19741 Most everything in this section also applies to template instantiations,
19742 but there are other options as well.
19743 @xref{Template Instantiation,,Where's the Template?}.
19744
19745 @end table
19746
19747 When used with GNU ld version 2.8 or later on an ELF system such as
19748 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
19749 these constructs will be discarded at link time. This is known as
19750 COMDAT support.
19751
19752 On targets that don't support COMDAT, but do support weak symbols, GCC
19753 uses them. This way one copy overrides all the others, but
19754 the unused copies still take up space in the executable.
19755
19756 For targets that do not support either COMDAT or weak symbols,
19757 most entities with vague linkage are emitted as local symbols to
19758 avoid duplicate definition errors from the linker. This does not happen
19759 for local statics in inlines, however, as having multiple copies
19760 almost certainly breaks things.
19761
19762 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
19763 another way to control placement of these constructs.
19764
19765 @node C++ Interface
19766 @section C++ Interface and Implementation Pragmas
19767
19768 @cindex interface and implementation headers, C++
19769 @cindex C++ interface and implementation headers
19770 @cindex pragmas, interface and implementation
19771
19772 @code{#pragma interface} and @code{#pragma implementation} provide the
19773 user with a way of explicitly directing the compiler to emit entities
19774 with vague linkage (and debugging information) in a particular
19775 translation unit.
19776
19777 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
19778 by COMDAT support and the ``key method'' heuristic
19779 mentioned in @ref{Vague Linkage}. Using them can actually cause your
19780 program to grow due to unnecessary out-of-line copies of inline
19781 functions.
19782
19783 @table @code
19784 @item #pragma interface
19785 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
19786 @kindex #pragma interface
19787 Use this directive in @emph{header files} that define object classes, to save
19788 space in most of the object files that use those classes. Normally,
19789 local copies of certain information (backup copies of inline member
19790 functions, debugging information, and the internal tables that implement
19791 virtual functions) must be kept in each object file that includes class
19792 definitions. You can use this pragma to avoid such duplication. When a
19793 header file containing @samp{#pragma interface} is included in a
19794 compilation, this auxiliary information is not generated (unless
19795 the main input source file itself uses @samp{#pragma implementation}).
19796 Instead, the object files contain references to be resolved at link
19797 time.
19798
19799 The second form of this directive is useful for the case where you have
19800 multiple headers with the same name in different directories. If you
19801 use this form, you must specify the same string to @samp{#pragma
19802 implementation}.
19803
19804 @item #pragma implementation
19805 @itemx #pragma implementation "@var{objects}.h"
19806 @kindex #pragma implementation
19807 Use this pragma in a @emph{main input file}, when you want full output from
19808 included header files to be generated (and made globally visible). The
19809 included header file, in turn, should use @samp{#pragma interface}.
19810 Backup copies of inline member functions, debugging information, and the
19811 internal tables used to implement virtual functions are all generated in
19812 implementation files.
19813
19814 @cindex implied @code{#pragma implementation}
19815 @cindex @code{#pragma implementation}, implied
19816 @cindex naming convention, implementation headers
19817 If you use @samp{#pragma implementation} with no argument, it applies to
19818 an include file with the same basename@footnote{A file's @dfn{basename}
19819 is the name stripped of all leading path information and of trailing
19820 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
19821 file. For example, in @file{allclass.cc}, giving just
19822 @samp{#pragma implementation}
19823 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
19824
19825 Use the string argument if you want a single implementation file to
19826 include code from multiple header files. (You must also use
19827 @samp{#include} to include the header file; @samp{#pragma
19828 implementation} only specifies how to use the file---it doesn't actually
19829 include it.)
19830
19831 There is no way to split up the contents of a single header file into
19832 multiple implementation files.
19833 @end table
19834
19835 @cindex inlining and C++ pragmas
19836 @cindex C++ pragmas, effect on inlining
19837 @cindex pragmas in C++, effect on inlining
19838 @samp{#pragma implementation} and @samp{#pragma interface} also have an
19839 effect on function inlining.
19840
19841 If you define a class in a header file marked with @samp{#pragma
19842 interface}, the effect on an inline function defined in that class is
19843 similar to an explicit @code{extern} declaration---the compiler emits
19844 no code at all to define an independent version of the function. Its
19845 definition is used only for inlining with its callers.
19846
19847 @opindex fno-implement-inlines
19848 Conversely, when you include the same header file in a main source file
19849 that declares it as @samp{#pragma implementation}, the compiler emits
19850 code for the function itself; this defines a version of the function
19851 that can be found via pointers (or by callers compiled without
19852 inlining). If all calls to the function can be inlined, you can avoid
19853 emitting the function by compiling with @option{-fno-implement-inlines}.
19854 If any calls are not inlined, you will get linker errors.
19855
19856 @node Template Instantiation
19857 @section Where's the Template?
19858 @cindex template instantiation
19859
19860 C++ templates were the first language feature to require more
19861 intelligence from the environment than was traditionally found on a UNIX
19862 system. Somehow the compiler and linker have to make sure that each
19863 template instance occurs exactly once in the executable if it is needed,
19864 and not at all otherwise. There are two basic approaches to this
19865 problem, which are referred to as the Borland model and the Cfront model.
19866
19867 @table @asis
19868 @item Borland model
19869 Borland C++ solved the template instantiation problem by adding the code
19870 equivalent of common blocks to their linker; the compiler emits template
19871 instances in each translation unit that uses them, and the linker
19872 collapses them together. The advantage of this model is that the linker
19873 only has to consider the object files themselves; there is no external
19874 complexity to worry about. The disadvantage is that compilation time
19875 is increased because the template code is being compiled repeatedly.
19876 Code written for this model tends to include definitions of all
19877 templates in the header file, since they must be seen to be
19878 instantiated.
19879
19880 @item Cfront model
19881 The AT&T C++ translator, Cfront, solved the template instantiation
19882 problem by creating the notion of a template repository, an
19883 automatically maintained place where template instances are stored. A
19884 more modern version of the repository works as follows: As individual
19885 object files are built, the compiler places any template definitions and
19886 instantiations encountered in the repository. At link time, the link
19887 wrapper adds in the objects in the repository and compiles any needed
19888 instances that were not previously emitted. The advantages of this
19889 model are more optimal compilation speed and the ability to use the
19890 system linker; to implement the Borland model a compiler vendor also
19891 needs to replace the linker. The disadvantages are vastly increased
19892 complexity, and thus potential for error; for some code this can be
19893 just as transparent, but in practice it can been very difficult to build
19894 multiple programs in one directory and one program in multiple
19895 directories. Code written for this model tends to separate definitions
19896 of non-inline member templates into a separate file, which should be
19897 compiled separately.
19898 @end table
19899
19900 G++ implements the Borland model on targets where the linker supports it,
19901 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
19902 Otherwise G++ implements neither automatic model.
19903
19904 You have the following options for dealing with template instantiations:
19905
19906 @enumerate
19907 @item
19908 Do nothing. Code written for the Borland model works fine, but
19909 each translation unit contains instances of each of the templates it
19910 uses. The duplicate instances will be discarded by the linker, but in
19911 a large program, this can lead to an unacceptable amount of code
19912 duplication in object files or shared libraries.
19913
19914 Duplicate instances of a template can be avoided by defining an explicit
19915 instantiation in one object file, and preventing the compiler from doing
19916 implicit instantiations in any other object files by using an explicit
19917 instantiation declaration, using the @code{extern template} syntax:
19918
19919 @smallexample
19920 extern template int max (int, int);
19921 @end smallexample
19922
19923 This syntax is defined in the C++ 2011 standard, but has been supported by
19924 G++ and other compilers since well before 2011.
19925
19926 Explicit instantiations can be used for the largest or most frequently
19927 duplicated instances, without having to know exactly which other instances
19928 are used in the rest of the program. You can scatter the explicit
19929 instantiations throughout your program, perhaps putting them in the
19930 translation units where the instances are used or the translation units
19931 that define the templates themselves; you can put all of the explicit
19932 instantiations you need into one big file; or you can create small files
19933 like
19934
19935 @smallexample
19936 #include "Foo.h"
19937 #include "Foo.cc"
19938
19939 template class Foo<int>;
19940 template ostream& operator <<
19941 (ostream&, const Foo<int>&);
19942 @end smallexample
19943
19944 @noindent
19945 for each of the instances you need, and create a template instantiation
19946 library from those.
19947
19948 This is the simplest option, but also offers flexibility and
19949 fine-grained control when necessary. It is also the most portable
19950 alternative and programs using this approach will work with most modern
19951 compilers.
19952
19953 @item
19954 @opindex frepo
19955 Compile your template-using code with @option{-frepo}. The compiler
19956 generates files with the extension @samp{.rpo} listing all of the
19957 template instantiations used in the corresponding object files that
19958 could be instantiated there; the link wrapper, @samp{collect2},
19959 then updates the @samp{.rpo} files to tell the compiler where to place
19960 those instantiations and rebuild any affected object files. The
19961 link-time overhead is negligible after the first pass, as the compiler
19962 continues to place the instantiations in the same files.
19963
19964 This can be a suitable option for application code written for the Borland
19965 model, as it usually just works. Code written for the Cfront model
19966 needs to be modified so that the template definitions are available at
19967 one or more points of instantiation; usually this is as simple as adding
19968 @code{#include <tmethods.cc>} to the end of each template header.
19969
19970 For library code, if you want the library to provide all of the template
19971 instantiations it needs, just try to link all of its object files
19972 together; the link will fail, but cause the instantiations to be
19973 generated as a side effect. Be warned, however, that this may cause
19974 conflicts if multiple libraries try to provide the same instantiations.
19975 For greater control, use explicit instantiation as described in the next
19976 option.
19977
19978 @item
19979 @opindex fno-implicit-templates
19980 Compile your code with @option{-fno-implicit-templates} to disable the
19981 implicit generation of template instances, and explicitly instantiate
19982 all the ones you use. This approach requires more knowledge of exactly
19983 which instances you need than do the others, but it's less
19984 mysterious and allows greater control if you want to ensure that only
19985 the intended instances are used.
19986
19987 If you are using Cfront-model code, you can probably get away with not
19988 using @option{-fno-implicit-templates} when compiling files that don't
19989 @samp{#include} the member template definitions.
19990
19991 If you use one big file to do the instantiations, you may want to
19992 compile it without @option{-fno-implicit-templates} so you get all of the
19993 instances required by your explicit instantiations (but not by any
19994 other files) without having to specify them as well.
19995
19996 In addition to forward declaration of explicit instantiations
19997 (with @code{extern}), G++ has extended the template instantiation
19998 syntax to support instantiation of the compiler support data for a
19999 template class (i.e.@: the vtable) without instantiating any of its
20000 members (with @code{inline}), and instantiation of only the static data
20001 members of a template class, without the support data or member
20002 functions (with @code{static}):
20003
20004 @smallexample
20005 inline template class Foo<int>;
20006 static template class Foo<int>;
20007 @end smallexample
20008 @end enumerate
20009
20010 @node Bound member functions
20011 @section Extracting the Function Pointer from a Bound Pointer to Member Function
20012 @cindex pmf
20013 @cindex pointer to member function
20014 @cindex bound pointer to member function
20015
20016 In C++, pointer to member functions (PMFs) are implemented using a wide
20017 pointer of sorts to handle all the possible call mechanisms; the PMF
20018 needs to store information about how to adjust the @samp{this} pointer,
20019 and if the function pointed to is virtual, where to find the vtable, and
20020 where in the vtable to look for the member function. If you are using
20021 PMFs in an inner loop, you should really reconsider that decision. If
20022 that is not an option, you can extract the pointer to the function that
20023 would be called for a given object/PMF pair and call it directly inside
20024 the inner loop, to save a bit of time.
20025
20026 Note that you still pay the penalty for the call through a
20027 function pointer; on most modern architectures, such a call defeats the
20028 branch prediction features of the CPU@. This is also true of normal
20029 virtual function calls.
20030
20031 The syntax for this extension is
20032
20033 @smallexample
20034 extern A a;
20035 extern int (A::*fp)();
20036 typedef int (*fptr)(A *);
20037
20038 fptr p = (fptr)(a.*fp);
20039 @end smallexample
20040
20041 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
20042 no object is needed to obtain the address of the function. They can be
20043 converted to function pointers directly:
20044
20045 @smallexample
20046 fptr p1 = (fptr)(&A::foo);
20047 @end smallexample
20048
20049 @opindex Wno-pmf-conversions
20050 You must specify @option{-Wno-pmf-conversions} to use this extension.
20051
20052 @node C++ Attributes
20053 @section C++-Specific Variable, Function, and Type Attributes
20054
20055 Some attributes only make sense for C++ programs.
20056
20057 @table @code
20058 @item abi_tag ("@var{tag}", ...)
20059 @cindex @code{abi_tag} function attribute
20060 @cindex @code{abi_tag} variable attribute
20061 @cindex @code{abi_tag} type attribute
20062 The @code{abi_tag} attribute can be applied to a function, variable, or class
20063 declaration. It modifies the mangled name of the entity to
20064 incorporate the tag name, in order to distinguish the function or
20065 class from an earlier version with a different ABI; perhaps the class
20066 has changed size, or the function has a different return type that is
20067 not encoded in the mangled name.
20068
20069 The attribute can also be applied to an inline namespace, but does not
20070 affect the mangled name of the namespace; in this case it is only used
20071 for @option{-Wabi-tag} warnings and automatic tagging of functions and
20072 variables. Tagging inline namespaces is generally preferable to
20073 tagging individual declarations, but the latter is sometimes
20074 necessary, such as when only certain members of a class need to be
20075 tagged.
20076
20077 The argument can be a list of strings of arbitrary length. The
20078 strings are sorted on output, so the order of the list is
20079 unimportant.
20080
20081 A redeclaration of an entity must not add new ABI tags,
20082 since doing so would change the mangled name.
20083
20084 The ABI tags apply to a name, so all instantiations and
20085 specializations of a template have the same tags. The attribute will
20086 be ignored if applied to an explicit specialization or instantiation.
20087
20088 The @option{-Wabi-tag} flag enables a warning about a class which does
20089 not have all the ABI tags used by its subobjects and virtual functions; for users with code
20090 that needs to coexist with an earlier ABI, using this option can help
20091 to find all affected types that need to be tagged.
20092
20093 When a type involving an ABI tag is used as the type of a variable or
20094 return type of a function where that tag is not already present in the
20095 signature of the function, the tag is automatically applied to the
20096 variable or function. @option{-Wabi-tag} also warns about this
20097 situation; this warning can be avoided by explicitly tagging the
20098 variable or function or moving it into a tagged inline namespace.
20099
20100 @item init_priority (@var{priority})
20101 @cindex @code{init_priority} variable attribute
20102
20103 In Standard C++, objects defined at namespace scope are guaranteed to be
20104 initialized in an order in strict accordance with that of their definitions
20105 @emph{in a given translation unit}. No guarantee is made for initializations
20106 across translation units. However, GNU C++ allows users to control the
20107 order of initialization of objects defined at namespace scope with the
20108 @code{init_priority} attribute by specifying a relative @var{priority},
20109 a constant integral expression currently bounded between 101 and 65535
20110 inclusive. Lower numbers indicate a higher priority.
20111
20112 In the following example, @code{A} would normally be created before
20113 @code{B}, but the @code{init_priority} attribute reverses that order:
20114
20115 @smallexample
20116 Some_Class A __attribute__ ((init_priority (2000)));
20117 Some_Class B __attribute__ ((init_priority (543)));
20118 @end smallexample
20119
20120 @noindent
20121 Note that the particular values of @var{priority} do not matter; only their
20122 relative ordering.
20123
20124 @item java_interface
20125 @cindex @code{java_interface} type attribute
20126
20127 This type attribute informs C++ that the class is a Java interface. It may
20128 only be applied to classes declared within an @code{extern "Java"} block.
20129 Calls to methods declared in this interface are dispatched using GCJ's
20130 interface table mechanism, instead of regular virtual table dispatch.
20131
20132 @item warn_unused
20133 @cindex @code{warn_unused} type attribute
20134
20135 For C++ types with non-trivial constructors and/or destructors it is
20136 impossible for the compiler to determine whether a variable of this
20137 type is truly unused if it is not referenced. This type attribute
20138 informs the compiler that variables of this type should be warned
20139 about if they appear to be unused, just like variables of fundamental
20140 types.
20141
20142 This attribute is appropriate for types which just represent a value,
20143 such as @code{std::string}; it is not appropriate for types which
20144 control a resource, such as @code{std::mutex}.
20145
20146 This attribute is also accepted in C, but it is unnecessary because C
20147 does not have constructors or destructors.
20148
20149 @end table
20150
20151 See also @ref{Namespace Association}.
20152
20153 @node Function Multiversioning
20154 @section Function Multiversioning
20155 @cindex function versions
20156
20157 With the GNU C++ front end, for x86 targets, you may specify multiple
20158 versions of a function, where each function is specialized for a
20159 specific target feature. At runtime, the appropriate version of the
20160 function is automatically executed depending on the characteristics of
20161 the execution platform. Here is an example.
20162
20163 @smallexample
20164 __attribute__ ((target ("default")))
20165 int foo ()
20166 @{
20167 // The default version of foo.
20168 return 0;
20169 @}
20170
20171 __attribute__ ((target ("sse4.2")))
20172 int foo ()
20173 @{
20174 // foo version for SSE4.2
20175 return 1;
20176 @}
20177
20178 __attribute__ ((target ("arch=atom")))
20179 int foo ()
20180 @{
20181 // foo version for the Intel ATOM processor
20182 return 2;
20183 @}
20184
20185 __attribute__ ((target ("arch=amdfam10")))
20186 int foo ()
20187 @{
20188 // foo version for the AMD Family 0x10 processors.
20189 return 3;
20190 @}
20191
20192 int main ()
20193 @{
20194 int (*p)() = &foo;
20195 assert ((*p) () == foo ());
20196 return 0;
20197 @}
20198 @end smallexample
20199
20200 In the above example, four versions of function foo are created. The
20201 first version of foo with the target attribute "default" is the default
20202 version. This version gets executed when no other target specific
20203 version qualifies for execution on a particular platform. A new version
20204 of foo is created by using the same function signature but with a
20205 different target string. Function foo is called or a pointer to it is
20206 taken just like a regular function. GCC takes care of doing the
20207 dispatching to call the right version at runtime. Refer to the
20208 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
20209 Function Multiversioning} for more details.
20210
20211 @node Namespace Association
20212 @section Namespace Association
20213
20214 @strong{Caution:} The semantics of this extension are equivalent
20215 to C++ 2011 inline namespaces. Users should use inline namespaces
20216 instead as this extension will be removed in future versions of G++.
20217
20218 A using-directive with @code{__attribute ((strong))} is stronger
20219 than a normal using-directive in two ways:
20220
20221 @itemize @bullet
20222 @item
20223 Templates from the used namespace can be specialized and explicitly
20224 instantiated as though they were members of the using namespace.
20225
20226 @item
20227 The using namespace is considered an associated namespace of all
20228 templates in the used namespace for purposes of argument-dependent
20229 name lookup.
20230 @end itemize
20231
20232 The used namespace must be nested within the using namespace so that
20233 normal unqualified lookup works properly.
20234
20235 This is useful for composing a namespace transparently from
20236 implementation namespaces. For example:
20237
20238 @smallexample
20239 namespace std @{
20240 namespace debug @{
20241 template <class T> struct A @{ @};
20242 @}
20243 using namespace debug __attribute ((__strong__));
20244 template <> struct A<int> @{ @}; // @r{OK to specialize}
20245
20246 template <class T> void f (A<T>);
20247 @}
20248
20249 int main()
20250 @{
20251 f (std::A<float>()); // @r{lookup finds} std::f
20252 f (std::A<int>());
20253 @}
20254 @end smallexample
20255
20256 @node Type Traits
20257 @section Type Traits
20258
20259 The C++ front end implements syntactic extensions that allow
20260 compile-time determination of
20261 various characteristics of a type (or of a
20262 pair of types).
20263
20264 @table @code
20265 @item __has_nothrow_assign (type)
20266 If @code{type} is const qualified or is a reference type then the trait is
20267 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
20268 is true, else if @code{type} is a cv class or union type with copy assignment
20269 operators that are known not to throw an exception then the trait is true,
20270 else it is false. Requires: @code{type} shall be a complete type,
20271 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20272
20273 @item __has_nothrow_copy (type)
20274 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
20275 @code{type} is a cv class or union type with copy constructors that
20276 are known not to throw an exception then the trait is true, else it is false.
20277 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
20278 @code{void}, or an array of unknown bound.
20279
20280 @item __has_nothrow_constructor (type)
20281 If @code{__has_trivial_constructor (type)} is true then the trait is
20282 true, else if @code{type} is a cv class or union type (or array
20283 thereof) with a default constructor that is known not to throw an
20284 exception then the trait is true, else it is false. Requires:
20285 @code{type} shall be a complete type, (possibly cv-qualified)
20286 @code{void}, or an array of unknown bound.
20287
20288 @item __has_trivial_assign (type)
20289 If @code{type} is const qualified or is a reference type then the trait is
20290 false. Otherwise if @code{__is_pod (type)} is true then the trait is
20291 true, else if @code{type} is a cv class or union type with a trivial
20292 copy assignment ([class.copy]) then the trait is true, else it is
20293 false. Requires: @code{type} shall be a complete type, (possibly
20294 cv-qualified) @code{void}, or an array of unknown bound.
20295
20296 @item __has_trivial_copy (type)
20297 If @code{__is_pod (type)} is true or @code{type} is a reference type
20298 then the trait is true, else if @code{type} is a cv class or union type
20299 with a trivial copy constructor ([class.copy]) then the trait
20300 is true, else it is false. Requires: @code{type} shall be a complete
20301 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20302
20303 @item __has_trivial_constructor (type)
20304 If @code{__is_pod (type)} is true then the trait is true, else if
20305 @code{type} is a cv class or union type (or array thereof) with a
20306 trivial default constructor ([class.ctor]) then the trait is true,
20307 else it is false. Requires: @code{type} shall be a complete
20308 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20309
20310 @item __has_trivial_destructor (type)
20311 If @code{__is_pod (type)} is true or @code{type} is a reference type then
20312 the trait is true, else if @code{type} is a cv class or union type (or
20313 array thereof) with a trivial destructor ([class.dtor]) then the trait
20314 is true, else it is false. Requires: @code{type} shall be a complete
20315 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20316
20317 @item __has_virtual_destructor (type)
20318 If @code{type} is a class type with a virtual destructor
20319 ([class.dtor]) then the trait is true, else it is false. Requires:
20320 @code{type} shall be a complete type, (possibly cv-qualified)
20321 @code{void}, or an array of unknown bound.
20322
20323 @item __is_abstract (type)
20324 If @code{type} is an abstract class ([class.abstract]) then the trait
20325 is true, else it is false. Requires: @code{type} shall be a complete
20326 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20327
20328 @item __is_base_of (base_type, derived_type)
20329 If @code{base_type} is a base class of @code{derived_type}
20330 ([class.derived]) then the trait is true, otherwise it is false.
20331 Top-level cv qualifications of @code{base_type} and
20332 @code{derived_type} are ignored. For the purposes of this trait, a
20333 class type is considered is own base. Requires: if @code{__is_class
20334 (base_type)} and @code{__is_class (derived_type)} are true and
20335 @code{base_type} and @code{derived_type} are not the same type
20336 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
20337 type. Diagnostic is produced if this requirement is not met.
20338
20339 @item __is_class (type)
20340 If @code{type} is a cv class type, and not a union type
20341 ([basic.compound]) the trait is true, else it is false.
20342
20343 @item __is_empty (type)
20344 If @code{__is_class (type)} is false then the trait is false.
20345 Otherwise @code{type} is considered empty if and only if: @code{type}
20346 has no non-static data members, or all non-static data members, if
20347 any, are bit-fields of length 0, and @code{type} has no virtual
20348 members, and @code{type} has no virtual base classes, and @code{type}
20349 has no base classes @code{base_type} for which
20350 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
20351 be a complete type, (possibly cv-qualified) @code{void}, or an array
20352 of unknown bound.
20353
20354 @item __is_enum (type)
20355 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
20356 true, else it is false.
20357
20358 @item __is_literal_type (type)
20359 If @code{type} is a literal type ([basic.types]) the trait is
20360 true, else it is false. Requires: @code{type} shall be a complete type,
20361 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20362
20363 @item __is_pod (type)
20364 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
20365 else it is false. Requires: @code{type} shall be a complete type,
20366 (possibly cv-qualified) @code{void}, or an array of unknown bound.
20367
20368 @item __is_polymorphic (type)
20369 If @code{type} is a polymorphic class ([class.virtual]) then the trait
20370 is true, else it is false. Requires: @code{type} shall be a complete
20371 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20372
20373 @item __is_standard_layout (type)
20374 If @code{type} is a standard-layout type ([basic.types]) the trait is
20375 true, else it is false. Requires: @code{type} shall be a complete
20376 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20377
20378 @item __is_trivial (type)
20379 If @code{type} is a trivial type ([basic.types]) the trait is
20380 true, else it is false. Requires: @code{type} shall be a complete
20381 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
20382
20383 @item __is_union (type)
20384 If @code{type} is a cv union type ([basic.compound]) the trait is
20385 true, else it is false.
20386
20387 @item __underlying_type (type)
20388 The underlying type of @code{type}. Requires: @code{type} shall be
20389 an enumeration type ([dcl.enum]).
20390
20391 @end table
20392
20393
20394 @node C++ Concepts
20395 @section C++ Concepts
20396
20397 C++ concepts provide much-improved support for generic programming. In
20398 particular, they allow the specification of constraints on template arguments.
20399 The constraints are used to extend the usual overloading and partial
20400 specialization capabilities of the language, allowing generic data structures
20401 and algorithms to be ``refined'' based on their properties rather than their
20402 type names.
20403
20404 The following keywords are reserved for concepts.
20405
20406 @table @code
20407 @item assumes
20408 States an expression as an assumption, and if possible, verifies that the
20409 assumption is valid. For example, @code{assume(n > 0)}.
20410
20411 @item axiom
20412 Introduces an axiom definition. Axioms introduce requirements on values.
20413
20414 @item forall
20415 Introduces a universally quantified object in an axiom. For example,
20416 @code{forall (int n) n + 0 == n}).
20417
20418 @item concept
20419 Introduces a concept definition. Concepts are sets of syntactic and semantic
20420 requirements on types and their values.
20421
20422 @item requires
20423 Introduces constraints on template arguments or requirements for a member
20424 function of a class template.
20425
20426 @end table
20427
20428 The front end also exposes a number of internal mechanism that can be used
20429 to simplify the writing of type traits. Note that some of these traits are
20430 likely to be removed in the future.
20431
20432 @table @code
20433 @item __is_same (type1, type2)
20434 A binary type trait: true whenever the type arguments are the same.
20435
20436 @end table
20437
20438
20439 @node Java Exceptions
20440 @section Java Exceptions
20441
20442 The Java language uses a slightly different exception handling model
20443 from C++. Normally, GNU C++ automatically detects when you are
20444 writing C++ code that uses Java exceptions, and handle them
20445 appropriately. However, if C++ code only needs to execute destructors
20446 when Java exceptions are thrown through it, GCC guesses incorrectly.
20447 Sample problematic code is:
20448
20449 @smallexample
20450 struct S @{ ~S(); @};
20451 extern void bar(); // @r{is written in Java, and may throw exceptions}
20452 void foo()
20453 @{
20454 S s;
20455 bar();
20456 @}
20457 @end smallexample
20458
20459 @noindent
20460 The usual effect of an incorrect guess is a link failure, complaining of
20461 a missing routine called @samp{__gxx_personality_v0}.
20462
20463 You can inform the compiler that Java exceptions are to be used in a
20464 translation unit, irrespective of what it might think, by writing
20465 @samp{@w{#pragma GCC java_exceptions}} at the head of the file. This
20466 @samp{#pragma} must appear before any functions that throw or catch
20467 exceptions, or run destructors when exceptions are thrown through them.
20468
20469 You cannot mix Java and C++ exceptions in the same translation unit. It
20470 is believed to be safe to throw a C++ exception from one file through
20471 another file compiled for the Java exception model, or vice versa, but
20472 there may be bugs in this area.
20473
20474 @node Deprecated Features
20475 @section Deprecated Features
20476
20477 In the past, the GNU C++ compiler was extended to experiment with new
20478 features, at a time when the C++ language was still evolving. Now that
20479 the C++ standard is complete, some of those features are superseded by
20480 superior alternatives. Using the old features might cause a warning in
20481 some cases that the feature will be dropped in the future. In other
20482 cases, the feature might be gone already.
20483
20484 While the list below is not exhaustive, it documents some of the options
20485 that are now deprecated:
20486
20487 @table @code
20488 @item -fexternal-templates
20489 @itemx -falt-external-templates
20490 These are two of the many ways for G++ to implement template
20491 instantiation. @xref{Template Instantiation}. The C++ standard clearly
20492 defines how template definitions have to be organized across
20493 implementation units. G++ has an implicit instantiation mechanism that
20494 should work just fine for standard-conforming code.
20495
20496 @item -fstrict-prototype
20497 @itemx -fno-strict-prototype
20498 Previously it was possible to use an empty prototype parameter list to
20499 indicate an unspecified number of parameters (like C), rather than no
20500 parameters, as C++ demands. This feature has been removed, except where
20501 it is required for backwards compatibility. @xref{Backwards Compatibility}.
20502 @end table
20503
20504 G++ allows a virtual function returning @samp{void *} to be overridden
20505 by one returning a different pointer type. This extension to the
20506 covariant return type rules is now deprecated and will be removed from a
20507 future version.
20508
20509 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
20510 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
20511 and are now removed from G++. Code using these operators should be
20512 modified to use @code{std::min} and @code{std::max} instead.
20513
20514 The named return value extension has been deprecated, and is now
20515 removed from G++.
20516
20517 The use of initializer lists with new expressions has been deprecated,
20518 and is now removed from G++.
20519
20520 Floating and complex non-type template parameters have been deprecated,
20521 and are now removed from G++.
20522
20523 The implicit typename extension has been deprecated and is now
20524 removed from G++.
20525
20526 The use of default arguments in function pointers, function typedefs
20527 and other places where they are not permitted by the standard is
20528 deprecated and will be removed from a future version of G++.
20529
20530 G++ allows floating-point literals to appear in integral constant expressions,
20531 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
20532 This extension is deprecated and will be removed from a future version.
20533
20534 G++ allows static data members of const floating-point type to be declared
20535 with an initializer in a class definition. The standard only allows
20536 initializers for static members of const integral types and const
20537 enumeration types so this extension has been deprecated and will be removed
20538 from a future version.
20539
20540 @node Backwards Compatibility
20541 @section Backwards Compatibility
20542 @cindex Backwards Compatibility
20543 @cindex ARM [Annotated C++ Reference Manual]
20544
20545 Now that there is a definitive ISO standard C++, G++ has a specification
20546 to adhere to. The C++ language evolved over time, and features that
20547 used to be acceptable in previous drafts of the standard, such as the ARM
20548 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
20549 compilation of C++ written to such drafts, G++ contains some backwards
20550 compatibilities. @emph{All such backwards compatibility features are
20551 liable to disappear in future versions of G++.} They should be considered
20552 deprecated. @xref{Deprecated Features}.
20553
20554 @table @code
20555 @item For scope
20556 If a variable is declared at for scope, it used to remain in scope until
20557 the end of the scope that contained the for statement (rather than just
20558 within the for scope). G++ retains this, but issues a warning, if such a
20559 variable is accessed outside the for scope.
20560
20561 @item Implicit C language
20562 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
20563 scope to set the language. On such systems, all header files are
20564 implicitly scoped inside a C language scope. Also, an empty prototype
20565 @code{()} is treated as an unspecified number of arguments, rather
20566 than no arguments, as C++ demands.
20567 @end table
20568
20569 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
20570 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr