]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/extend.texi
RISC-V: Add interrupt attribute modes.
[thirdparty/gcc.git] / gcc / doc / extend.texi
1 c Copyright (C) 1988-2018 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 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax:: Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments:: C++ comments are recognized.
67 * Dollar Signs:: Dollar sign is allowed in identifiers.
68 * Character Escapes:: @samp{\e} stands for the character @key{ESC}.
69 * Alignment:: Inquiring about the alignment of a type or variable.
70 * Inline:: Defining inline functions (as fast as macros).
71 * Volatiles:: What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums:: @code{enum foo;}, with details to follow.
75 * Function Names:: Printable strings which are the name of the current
76 function.
77 * Return Address:: Getting the return or frame address of a function.
78 * Vector Extensions:: Using vector instructions through built-in functions.
79 * Offsetof:: Special syntax for implementing @code{offsetof}.
80 * __sync Builtins:: Legacy built-in functions for atomic memory access.
81 * __atomic Builtins:: Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83 arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86 checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
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 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
901 that includes the @samp{<complex>} header cannot use @samp{i} for the
902 GNU extension. The @samp{j} suffix still has the GNU meaning.
903
904 @cindex @code{__real__} keyword
905 @cindex @code{__imag__} keyword
906 To extract the real part of a complex-valued expression @var{exp}, write
907 @code{__real__ @var{exp}}. Likewise, use @code{__imag__} to
908 extract the imaginary part. This is a GNU extension; for values of
909 floating type, you should use the ISO C99 functions @code{crealf},
910 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
911 @code{cimagl}, declared in @code{<complex.h>} and also provided as
912 built-in functions by GCC@.
913
914 @cindex complex conjugation
915 The operator @samp{~} performs complex conjugation when used on a value
916 with a complex type. This is a GNU extension; for values of
917 floating type, you should use the ISO C99 functions @code{conjf},
918 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
919 provided as built-in functions by GCC@.
920
921 GCC can allocate complex automatic variables in a noncontiguous
922 fashion; it's even possible for the real part to be in a register while
923 the imaginary part is on the stack (or vice versa). Only the DWARF
924 debug info format can represent this, so use of DWARF is recommended.
925 If you are using the stabs debug info format, GCC describes a noncontiguous
926 complex variable as if it were two separate variables of noncomplex type.
927 If the variable's actual name is @code{foo}, the two fictitious
928 variables are named @code{foo$real} and @code{foo$imag}. You can
929 examine and set these two fictitious variables with your debugger.
930
931 @node Floating Types
932 @section Additional Floating Types
933 @cindex additional floating types
934 @cindex @code{_Float@var{n}} data types
935 @cindex @code{_Float@var{n}x} data types
936 @cindex @code{__float80} data type
937 @cindex @code{__float128} data type
938 @cindex @code{__ibm128} data type
939 @cindex @code{w} floating point suffix
940 @cindex @code{q} floating point suffix
941 @cindex @code{W} floating point suffix
942 @cindex @code{Q} floating point suffix
943
944 ISO/IEC TS 18661-3:2015 defines C support for additional floating
945 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
946 these type names; the set of types supported depends on the target
947 architecture. These types are not supported when compiling C++.
948 Constants with these types use suffixes @code{f@var{n}} or
949 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}. These type
950 names can be used together with @code{_Complex} to declare complex
951 types.
952
953 As an extension, GNU C and GNU C++ support additional floating
954 types, which are not supported by all targets.
955 @itemize @bullet
956 @item @code{__float128} is available on i386, x86_64, IA-64, and
957 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
958 the vector scalar (VSX) instruction set. @code{__float128} supports
959 the 128-bit floating type. On i386, x86_64, PowerPC, and IA-64
960 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
961 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
962 double}.
963
964 @item @code{__float80} is available on the i386, x86_64, and IA-64
965 targets, and supports the 80-bit (@code{XFmode}) floating type. It is
966 an alias for the type name @code{_Float64x} on these targets.
967
968 @item @code{__ibm128} is available on PowerPC targets, and provides
969 access to the IBM extended double format which is the current format
970 used for @code{long double}. When @code{long double} transitions to
971 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
972 for use in conversions between the two types.
973 @end itemize
974
975 Support for these additional types includes the arithmetic operators:
976 add, subtract, multiply, divide; unary arithmetic operators;
977 relational operators; equality operators; and conversions to and from
978 integer and other floating types. Use a suffix @samp{w} or @samp{W}
979 in a literal constant of type @code{__float80} or type
980 @code{__ibm128}. Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
981
982 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
983 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
984 expected in future versions of GCC that @code{_Float128} and @code{__float128}
985 will be enabled automatically.
986
987 The @code{_Float128} type is supported on all systems where
988 @code{__float128} is supported or where @code{long double} has the
989 IEEE binary128 format. The @code{_Float64x} type is supported on all
990 systems where @code{__float128} is supported. The @code{_Float32}
991 type is supported on all systems supporting IEEE binary32; the
992 @code{_Float64} and @code{_Float32x} types are supported on all systems
993 supporting IEEE binary64. The @code{_Float16} type is supported on AArch64
994 systems by default, and on ARM systems when the IEEE format for 16-bit
995 floating-point types is selected with @option{-mfp16-format=ieee}.
996 GCC does not currently support @code{_Float128x} on any systems.
997
998 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
999 types using the corresponding internal complex type, @code{XCmode} for
1000 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1001
1002 @smallexample
1003 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1004 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1005 @end smallexample
1006
1007 On the PowerPC Linux VSX targets, you can declare complex types using
1008 the corresponding internal complex type, @code{KCmode} for
1009 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1010
1011 @smallexample
1012 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1013 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1014 @end smallexample
1015
1016 @node Half-Precision
1017 @section Half-Precision Floating Point
1018 @cindex half-precision floating point
1019 @cindex @code{__fp16} data type
1020
1021 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1022 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1023 On ARM systems, you must enable this type explicitly with the
1024 @option{-mfp16-format} command-line option in order to use it.
1025
1026 ARM targets support two incompatible representations for half-precision
1027 floating-point values. You must choose one of the representations and
1028 use it consistently in your program.
1029
1030 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1031 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1032 There are 11 bits of significand precision, approximately 3
1033 decimal digits.
1034
1035 Specifying @option{-mfp16-format=alternative} selects the ARM
1036 alternative format. This representation is similar to the IEEE
1037 format, but does not support infinities or NaNs. Instead, the range
1038 of exponents is extended, so that this format can represent normalized
1039 values in the range of @math{2^{-14}} to 131008.
1040
1041 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1042 not require use of the @option{-mfp16-format} command-line option.
1043
1044 The @code{__fp16} type may only be used as an argument to intrinsics defined
1045 in @code{<arm_fp16.h>}, or as a storage format. For purposes of
1046 arithmetic and other operations, @code{__fp16} values in C or C++
1047 expressions are automatically promoted to @code{float}.
1048
1049 The ARM target provides hardware support for conversions between
1050 @code{__fp16} and @code{float} values
1051 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1052 hardware support for conversions between @code{__fp16} and @code{double}
1053 values. GCC generates code using these hardware instructions if you
1054 compile with options to select an FPU that provides them;
1055 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1056 in addition to the @option{-mfp16-format} option to select
1057 a half-precision format.
1058
1059 Language-level support for the @code{__fp16} data type is
1060 independent of whether GCC generates code using hardware floating-point
1061 instructions. In cases where hardware support is not specified, GCC
1062 implements conversions between @code{__fp16} and other types as library
1063 calls.
1064
1065 It is recommended that portable code use the @code{_Float16} type defined
1066 by ISO/IEC TS 18661-3:2015. @xref{Floating Types}.
1067
1068 @node Decimal Float
1069 @section Decimal Floating Types
1070 @cindex decimal floating types
1071 @cindex @code{_Decimal32} data type
1072 @cindex @code{_Decimal64} data type
1073 @cindex @code{_Decimal128} data type
1074 @cindex @code{df} integer suffix
1075 @cindex @code{dd} integer suffix
1076 @cindex @code{dl} integer suffix
1077 @cindex @code{DF} integer suffix
1078 @cindex @code{DD} integer suffix
1079 @cindex @code{DL} integer suffix
1080
1081 As an extension, GNU C supports decimal floating types as
1082 defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
1083 floating types in GCC will evolve as the draft technical report changes.
1084 Calling conventions for any target might also change. Not all targets
1085 support decimal floating types.
1086
1087 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1088 @code{_Decimal128}. They use a radix of ten, unlike the floating types
1089 @code{float}, @code{double}, and @code{long double} whose radix is not
1090 specified by the C standard but is usually two.
1091
1092 Support for decimal floating types includes the arithmetic operators
1093 add, subtract, multiply, divide; unary arithmetic operators;
1094 relational operators; equality operators; and conversions to and from
1095 integer and other floating types. Use a suffix @samp{df} or
1096 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1097 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1098 @code{_Decimal128}.
1099
1100 GCC support of decimal float as specified by the draft technical report
1101 is incomplete:
1102
1103 @itemize @bullet
1104 @item
1105 When the value of a decimal floating type cannot be represented in the
1106 integer type to which it is being converted, the result is undefined
1107 rather than the result value specified by the draft technical report.
1108
1109 @item
1110 GCC does not provide the C library functionality associated with
1111 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1112 @file{wchar.h}, which must come from a separate C library implementation.
1113 Because of this the GNU C compiler does not define macro
1114 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1115 the technical report.
1116 @end itemize
1117
1118 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1119 are supported by the DWARF debug information format.
1120
1121 @node Hex Floats
1122 @section Hex Floats
1123 @cindex hex floats
1124
1125 ISO C99 supports floating-point numbers written not only in the usual
1126 decimal notation, such as @code{1.55e1}, but also numbers such as
1127 @code{0x1.fp3} written in hexadecimal format. As a GNU extension, GCC
1128 supports this in C90 mode (except in some cases when strictly
1129 conforming) and in C++. In that format the
1130 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1131 mandatory. The exponent is a decimal number that indicates the power of
1132 2 by which the significant part is multiplied. Thus @samp{0x1.f} is
1133 @tex
1134 $1 {15\over16}$,
1135 @end tex
1136 @ifnottex
1137 1 15/16,
1138 @end ifnottex
1139 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1140 is the same as @code{1.55e1}.
1141
1142 Unlike for floating-point numbers in the decimal notation the exponent
1143 is always required in the hexadecimal notation. Otherwise the compiler
1144 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}. This
1145 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1146 extension for floating-point constants of type @code{float}.
1147
1148 @node Fixed-Point
1149 @section Fixed-Point Types
1150 @cindex fixed-point types
1151 @cindex @code{_Fract} data type
1152 @cindex @code{_Accum} data type
1153 @cindex @code{_Sat} data type
1154 @cindex @code{hr} fixed-suffix
1155 @cindex @code{r} fixed-suffix
1156 @cindex @code{lr} fixed-suffix
1157 @cindex @code{llr} fixed-suffix
1158 @cindex @code{uhr} fixed-suffix
1159 @cindex @code{ur} fixed-suffix
1160 @cindex @code{ulr} fixed-suffix
1161 @cindex @code{ullr} fixed-suffix
1162 @cindex @code{hk} fixed-suffix
1163 @cindex @code{k} fixed-suffix
1164 @cindex @code{lk} fixed-suffix
1165 @cindex @code{llk} fixed-suffix
1166 @cindex @code{uhk} fixed-suffix
1167 @cindex @code{uk} fixed-suffix
1168 @cindex @code{ulk} fixed-suffix
1169 @cindex @code{ullk} fixed-suffix
1170 @cindex @code{HR} fixed-suffix
1171 @cindex @code{R} fixed-suffix
1172 @cindex @code{LR} fixed-suffix
1173 @cindex @code{LLR} fixed-suffix
1174 @cindex @code{UHR} fixed-suffix
1175 @cindex @code{UR} fixed-suffix
1176 @cindex @code{ULR} fixed-suffix
1177 @cindex @code{ULLR} fixed-suffix
1178 @cindex @code{HK} fixed-suffix
1179 @cindex @code{K} fixed-suffix
1180 @cindex @code{LK} fixed-suffix
1181 @cindex @code{LLK} fixed-suffix
1182 @cindex @code{UHK} fixed-suffix
1183 @cindex @code{UK} fixed-suffix
1184 @cindex @code{ULK} fixed-suffix
1185 @cindex @code{ULLK} fixed-suffix
1186
1187 As an extension, GNU C supports fixed-point types as
1188 defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
1189 types in GCC will evolve as the draft technical report changes.
1190 Calling conventions for any target might also change. Not all targets
1191 support fixed-point types.
1192
1193 The fixed-point types are
1194 @code{short _Fract},
1195 @code{_Fract},
1196 @code{long _Fract},
1197 @code{long long _Fract},
1198 @code{unsigned short _Fract},
1199 @code{unsigned _Fract},
1200 @code{unsigned long _Fract},
1201 @code{unsigned long long _Fract},
1202 @code{_Sat short _Fract},
1203 @code{_Sat _Fract},
1204 @code{_Sat long _Fract},
1205 @code{_Sat long long _Fract},
1206 @code{_Sat unsigned short _Fract},
1207 @code{_Sat unsigned _Fract},
1208 @code{_Sat unsigned long _Fract},
1209 @code{_Sat unsigned long long _Fract},
1210 @code{short _Accum},
1211 @code{_Accum},
1212 @code{long _Accum},
1213 @code{long long _Accum},
1214 @code{unsigned short _Accum},
1215 @code{unsigned _Accum},
1216 @code{unsigned long _Accum},
1217 @code{unsigned long long _Accum},
1218 @code{_Sat short _Accum},
1219 @code{_Sat _Accum},
1220 @code{_Sat long _Accum},
1221 @code{_Sat long long _Accum},
1222 @code{_Sat unsigned short _Accum},
1223 @code{_Sat unsigned _Accum},
1224 @code{_Sat unsigned long _Accum},
1225 @code{_Sat unsigned long long _Accum}.
1226
1227 Fixed-point data values contain fractional and optional integral parts.
1228 The format of fixed-point data varies and depends on the target machine.
1229
1230 Support for fixed-point types includes:
1231 @itemize @bullet
1232 @item
1233 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1234 @item
1235 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1236 @item
1237 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1238 @item
1239 binary shift operators (@code{<<}, @code{>>})
1240 @item
1241 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1242 @item
1243 equality operators (@code{==}, @code{!=})
1244 @item
1245 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1246 @code{<<=}, @code{>>=})
1247 @item
1248 conversions to and from integer, floating-point, or fixed-point types
1249 @end itemize
1250
1251 Use a suffix in a fixed-point literal constant:
1252 @itemize
1253 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1254 @code{_Sat short _Fract}
1255 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1256 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1257 @code{_Sat long _Fract}
1258 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1259 @code{_Sat long long _Fract}
1260 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1261 @code{_Sat unsigned short _Fract}
1262 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1263 @code{_Sat unsigned _Fract}
1264 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1265 @code{_Sat unsigned long _Fract}
1266 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1267 and @code{_Sat unsigned long long _Fract}
1268 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1269 @code{_Sat short _Accum}
1270 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1271 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1272 @code{_Sat long _Accum}
1273 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1274 @code{_Sat long long _Accum}
1275 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1276 @code{_Sat unsigned short _Accum}
1277 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1278 @code{_Sat unsigned _Accum}
1279 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1280 @code{_Sat unsigned long _Accum}
1281 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1282 and @code{_Sat unsigned long long _Accum}
1283 @end itemize
1284
1285 GCC support of fixed-point types as specified by the draft technical report
1286 is incomplete:
1287
1288 @itemize @bullet
1289 @item
1290 Pragmas to control overflow and rounding behaviors are not implemented.
1291 @end itemize
1292
1293 Fixed-point types are supported by the DWARF debug information format.
1294
1295 @node Named Address Spaces
1296 @section Named Address Spaces
1297 @cindex Named Address Spaces
1298
1299 As an extension, GNU C supports named address spaces as
1300 defined in the N1275 draft of ISO/IEC DTR 18037. Support for named
1301 address spaces in GCC will evolve as the draft technical report
1302 changes. Calling conventions for any target might also change. At
1303 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1304 address spaces other than the generic address space.
1305
1306 Address space identifiers may be used exactly like any other C type
1307 qualifier (e.g., @code{const} or @code{volatile}). See the N1275
1308 document for more details.
1309
1310 @anchor{AVR Named Address Spaces}
1311 @subsection AVR Named Address Spaces
1312
1313 On the AVR target, there are several address spaces that can be used
1314 in order to put read-only data into the flash memory and access that
1315 data by means of the special instructions @code{LPM} or @code{ELPM}
1316 needed to read from flash.
1317
1318 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1319 flash memory by means of @code{LD*} instructions because the flash
1320 memory is mapped into the RAM address space. There is @emph{no need}
1321 for language extensions like @code{__flash} or attribute
1322 @ref{AVR Variable Attributes,,@code{progmem}}.
1323 The default linker description files for these devices cater for that
1324 feature and @code{.rodata} stays in flash: The compiler just generates
1325 @code{LD*} instructions, and the linker script adds core specific
1326 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1327 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1328 See @ref{AVR Options} for a list of respective devices.
1329
1330 For devices not in @code{avrtiny} or @code{avrxmega3},
1331 any data including read-only data is located in RAM (the generic
1332 address space) because flash memory is not visible in the RAM address
1333 space. In order to locate read-only data in flash memory @emph{and}
1334 to generate the right instructions to access this data without
1335 using (inline) assembler code, special address spaces are needed.
1336
1337 @table @code
1338 @item __flash
1339 @cindex @code{__flash} AVR Named Address Spaces
1340 The @code{__flash} qualifier locates data in the
1341 @code{.progmem.data} section. Data is read using the @code{LPM}
1342 instruction. Pointers to this address space are 16 bits wide.
1343
1344 @item __flash1
1345 @itemx __flash2
1346 @itemx __flash3
1347 @itemx __flash4
1348 @itemx __flash5
1349 @cindex @code{__flash1} AVR Named Address Spaces
1350 @cindex @code{__flash2} AVR Named Address Spaces
1351 @cindex @code{__flash3} AVR Named Address Spaces
1352 @cindex @code{__flash4} AVR Named Address Spaces
1353 @cindex @code{__flash5} AVR Named Address Spaces
1354 These are 16-bit address spaces locating data in section
1355 @code{.progmem@var{N}.data} where @var{N} refers to
1356 address space @code{__flash@var{N}}.
1357 The compiler sets the @code{RAMPZ} segment register appropriately
1358 before reading data by means of the @code{ELPM} instruction.
1359
1360 @item __memx
1361 @cindex @code{__memx} AVR Named Address Spaces
1362 This is a 24-bit address space that linearizes flash and RAM:
1363 If the high bit of the address is set, data is read from
1364 RAM using the lower two bytes as RAM address.
1365 If the high bit of the address is clear, data is read from flash
1366 with @code{RAMPZ} set according to the high byte of the address.
1367 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1368
1369 Objects in this address space are located in @code{.progmemx.data}.
1370 @end table
1371
1372 @b{Example}
1373
1374 @smallexample
1375 char my_read (const __flash char ** p)
1376 @{
1377 /* p is a pointer to RAM that points to a pointer to flash.
1378 The first indirection of p reads that flash pointer
1379 from RAM and the second indirection reads a char from this
1380 flash address. */
1381
1382 return **p;
1383 @}
1384
1385 /* Locate array[] in flash memory */
1386 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1387
1388 int i = 1;
1389
1390 int main (void)
1391 @{
1392 /* Return 17 by reading from flash memory */
1393 return array[array[i]];
1394 @}
1395 @end smallexample
1396
1397 @noindent
1398 For each named address space supported by avr-gcc there is an equally
1399 named but uppercase built-in macro defined.
1400 The purpose is to facilitate testing if respective address space
1401 support is available or not:
1402
1403 @smallexample
1404 #ifdef __FLASH
1405 const __flash int var = 1;
1406
1407 int read_var (void)
1408 @{
1409 return var;
1410 @}
1411 #else
1412 #include <avr/pgmspace.h> /* From AVR-LibC */
1413
1414 const int var PROGMEM = 1;
1415
1416 int read_var (void)
1417 @{
1418 return (int) pgm_read_word (&var);
1419 @}
1420 #endif /* __FLASH */
1421 @end smallexample
1422
1423 @noindent
1424 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1425 locates data in flash but
1426 accesses to these data read from generic address space, i.e.@:
1427 from RAM,
1428 so that you need special accessors like @code{pgm_read_byte}
1429 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1430 together with attribute @code{progmem}.
1431
1432 @noindent
1433 @b{Limitations and caveats}
1434
1435 @itemize
1436 @item
1437 Reading across the 64@tie{}KiB section boundary of
1438 the @code{__flash} or @code{__flash@var{N}} address spaces
1439 shows undefined behavior. The only address space that
1440 supports reading across the 64@tie{}KiB flash segment boundaries is
1441 @code{__memx}.
1442
1443 @item
1444 If you use one of the @code{__flash@var{N}} address spaces
1445 you must arrange your linker script to locate the
1446 @code{.progmem@var{N}.data} sections according to your needs.
1447
1448 @item
1449 Any data or pointers to the non-generic address spaces must
1450 be qualified as @code{const}, i.e.@: as read-only data.
1451 This still applies if the data in one of these address
1452 spaces like software version number or calibration lookup table are intended to
1453 be changed after load time by, say, a boot loader. In this case
1454 the right qualification is @code{const} @code{volatile} so that the compiler
1455 must not optimize away known values or insert them
1456 as immediates into operands of instructions.
1457
1458 @item
1459 The following code initializes a variable @code{pfoo}
1460 located in static storage with a 24-bit address:
1461 @smallexample
1462 extern const __memx char foo;
1463 const __memx void *pfoo = &foo;
1464 @end smallexample
1465
1466 @item
1467 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1468 Just use vanilla C / C++ code without overhead as outlined above.
1469 Attribute @code{progmem} is supported but works differently,
1470 see @ref{AVR Variable Attributes}.
1471
1472 @end itemize
1473
1474 @subsection M32C Named Address Spaces
1475 @cindex @code{__far} M32C Named Address Spaces
1476
1477 On the M32C target, with the R8C and M16C CPU variants, variables
1478 qualified with @code{__far} are accessed using 32-bit addresses in
1479 order to access memory beyond the first 64@tie{}Ki bytes. If
1480 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1481 effect.
1482
1483 @subsection RL78 Named Address Spaces
1484 @cindex @code{__far} RL78 Named Address Spaces
1485
1486 On the RL78 target, variables qualified with @code{__far} are accessed
1487 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1488 addresses. Non-far variables are assumed to appear in the topmost
1489 64@tie{}KiB of the address space.
1490
1491 @subsection SPU Named Address Spaces
1492 @cindex @code{__ea} SPU Named Address Spaces
1493
1494 On the SPU target variables may be declared as
1495 belonging to another address space by qualifying the type with the
1496 @code{__ea} address space identifier:
1497
1498 @smallexample
1499 extern int __ea i;
1500 @end smallexample
1501
1502 @noindent
1503 The compiler generates special code to access the variable @code{i}.
1504 It may use runtime library
1505 support, or generate special machine instructions to access that address
1506 space.
1507
1508 @subsection x86 Named Address Spaces
1509 @cindex x86 named address spaces
1510
1511 On the x86 target, variables may be declared as being relative
1512 to the @code{%fs} or @code{%gs} segments.
1513
1514 @table @code
1515 @item __seg_fs
1516 @itemx __seg_gs
1517 @cindex @code{__seg_fs} x86 named address space
1518 @cindex @code{__seg_gs} x86 named address space
1519 The object is accessed with the respective segment override prefix.
1520
1521 The respective segment base must be set via some method specific to
1522 the operating system. Rather than require an expensive system call
1523 to retrieve the segment base, these address spaces are not considered
1524 to be subspaces of the generic (flat) address space. This means that
1525 explicit casts are required to convert pointers between these address
1526 spaces and the generic address space. In practice the application
1527 should cast to @code{uintptr_t} and apply the segment base offset
1528 that it installed previously.
1529
1530 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1531 defined when these address spaces are supported.
1532 @end table
1533
1534 @node Zero Length
1535 @section Arrays of Length Zero
1536 @cindex arrays of length zero
1537 @cindex zero-length arrays
1538 @cindex length-zero arrays
1539 @cindex flexible array members
1540
1541 Zero-length arrays are allowed in GNU C@. They are very useful as the
1542 last element of a structure that is really a header for a variable-length
1543 object:
1544
1545 @smallexample
1546 struct line @{
1547 int length;
1548 char contents[0];
1549 @};
1550
1551 struct line *thisline = (struct line *)
1552 malloc (sizeof (struct line) + this_length);
1553 thisline->length = this_length;
1554 @end smallexample
1555
1556 In ISO C90, you would have to give @code{contents} a length of 1, which
1557 means either you waste space or complicate the argument to @code{malloc}.
1558
1559 In ISO C99, you would use a @dfn{flexible array member}, which is
1560 slightly different in syntax and semantics:
1561
1562 @itemize @bullet
1563 @item
1564 Flexible array members are written as @code{contents[]} without
1565 the @code{0}.
1566
1567 @item
1568 Flexible array members have incomplete type, and so the @code{sizeof}
1569 operator may not be applied. As a quirk of the original implementation
1570 of zero-length arrays, @code{sizeof} evaluates to zero.
1571
1572 @item
1573 Flexible array members may only appear as the last member of a
1574 @code{struct} that is otherwise non-empty.
1575
1576 @item
1577 A structure containing a flexible array member, or a union containing
1578 such a structure (possibly recursively), may not be a member of a
1579 structure or an element of an array. (However, these uses are
1580 permitted by GCC as extensions.)
1581 @end itemize
1582
1583 Non-empty initialization of zero-length
1584 arrays is treated like any case where there are more initializer
1585 elements than the array holds, in that a suitable warning about ``excess
1586 elements in array'' is given, and the excess elements (all of them, in
1587 this case) are ignored.
1588
1589 GCC allows static initialization of flexible array members.
1590 This is equivalent to defining a new structure containing the original
1591 structure followed by an array of sufficient size to contain the data.
1592 E.g.@: in the following, @code{f1} is constructed as if it were declared
1593 like @code{f2}.
1594
1595 @smallexample
1596 struct f1 @{
1597 int x; int y[];
1598 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1599
1600 struct f2 @{
1601 struct f1 f1; int data[3];
1602 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1603 @end smallexample
1604
1605 @noindent
1606 The convenience of this extension is that @code{f1} has the desired
1607 type, eliminating the need to consistently refer to @code{f2.f1}.
1608
1609 This has symmetry with normal static arrays, in that an array of
1610 unknown size is also written with @code{[]}.
1611
1612 Of course, this extension only makes sense if the extra data comes at
1613 the end of a top-level object, as otherwise we would be overwriting
1614 data at subsequent offsets. To avoid undue complication and confusion
1615 with initialization of deeply nested arrays, we simply disallow any
1616 non-empty initialization except when the structure is the top-level
1617 object. For example:
1618
1619 @smallexample
1620 struct foo @{ int x; int y[]; @};
1621 struct bar @{ struct foo z; @};
1622
1623 struct foo a = @{ 1, @{ 2, 3, 4 @} @}; // @r{Valid.}
1624 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1625 struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
1626 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
1627 @end smallexample
1628
1629 @node Empty Structures
1630 @section Structures with No Members
1631 @cindex empty structures
1632 @cindex zero-size structures
1633
1634 GCC permits a C structure to have no members:
1635
1636 @smallexample
1637 struct empty @{
1638 @};
1639 @end smallexample
1640
1641 The structure has size zero. In C++, empty structures are part
1642 of the language. G++ treats empty structures as if they had a single
1643 member of type @code{char}.
1644
1645 @node Variable Length
1646 @section Arrays of Variable Length
1647 @cindex variable-length arrays
1648 @cindex arrays of variable length
1649 @cindex VLAs
1650
1651 Variable-length automatic arrays are allowed in ISO C99, and as an
1652 extension GCC accepts them in C90 mode and in C++. These arrays are
1653 declared like any other automatic arrays, but with a length that is not
1654 a constant expression. The storage is allocated at the point of
1655 declaration and deallocated when the block scope containing the declaration
1656 exits. For
1657 example:
1658
1659 @smallexample
1660 FILE *
1661 concat_fopen (char *s1, char *s2, char *mode)
1662 @{
1663 char str[strlen (s1) + strlen (s2) + 1];
1664 strcpy (str, s1);
1665 strcat (str, s2);
1666 return fopen (str, mode);
1667 @}
1668 @end smallexample
1669
1670 @cindex scope of a variable length array
1671 @cindex variable-length array scope
1672 @cindex deallocating variable length arrays
1673 Jumping or breaking out of the scope of the array name deallocates the
1674 storage. Jumping into the scope is not allowed; you get an error
1675 message for it.
1676
1677 @cindex variable-length array in a structure
1678 As an extension, GCC accepts variable-length arrays as a member of
1679 a structure or a union. For example:
1680
1681 @smallexample
1682 void
1683 foo (int n)
1684 @{
1685 struct S @{ int x[n]; @};
1686 @}
1687 @end smallexample
1688
1689 @cindex @code{alloca} vs variable-length arrays
1690 You can use the function @code{alloca} to get an effect much like
1691 variable-length arrays. The function @code{alloca} is available in
1692 many other C implementations (but not in all). On the other hand,
1693 variable-length arrays are more elegant.
1694
1695 There are other differences between these two methods. Space allocated
1696 with @code{alloca} exists until the containing @emph{function} returns.
1697 The space for a variable-length array is deallocated as soon as the array
1698 name's scope ends, unless you also use @code{alloca} in this scope.
1699
1700 You can also use variable-length arrays as arguments to functions:
1701
1702 @smallexample
1703 struct entry
1704 tester (int len, char data[len][len])
1705 @{
1706 /* @r{@dots{}} */
1707 @}
1708 @end smallexample
1709
1710 The length of an array is computed once when the storage is allocated
1711 and is remembered for the scope of the array in case you access it with
1712 @code{sizeof}.
1713
1714 If you want to pass the array first and the length afterward, you can
1715 use a forward declaration in the parameter list---another GNU extension.
1716
1717 @smallexample
1718 struct entry
1719 tester (int len; char data[len][len], int len)
1720 @{
1721 /* @r{@dots{}} */
1722 @}
1723 @end smallexample
1724
1725 @cindex parameter forward declaration
1726 The @samp{int len} before the semicolon is a @dfn{parameter forward
1727 declaration}, and it serves the purpose of making the name @code{len}
1728 known when the declaration of @code{data} is parsed.
1729
1730 You can write any number of such parameter forward declarations in the
1731 parameter list. They can be separated by commas or semicolons, but the
1732 last one must end with a semicolon, which is followed by the ``real''
1733 parameter declarations. Each forward declaration must match a ``real''
1734 declaration in parameter name and data type. ISO C99 does not support
1735 parameter forward declarations.
1736
1737 @node Variadic Macros
1738 @section Macros with a Variable Number of Arguments.
1739 @cindex variable number of arguments
1740 @cindex macro with variable arguments
1741 @cindex rest argument (in macro)
1742 @cindex variadic macros
1743
1744 In the ISO C standard of 1999, a macro can be declared to accept a
1745 variable number of arguments much as a function can. The syntax for
1746 defining the macro is similar to that of a function. Here is an
1747 example:
1748
1749 @smallexample
1750 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1751 @end smallexample
1752
1753 @noindent
1754 Here @samp{@dots{}} is a @dfn{variable argument}. In the invocation of
1755 such a macro, it represents the zero or more tokens until the closing
1756 parenthesis that ends the invocation, including any commas. This set of
1757 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1758 wherever it appears. See the CPP manual for more information.
1759
1760 GCC has long supported variadic macros, and used a different syntax that
1761 allowed you to give a name to the variable arguments just like any other
1762 argument. Here is an example:
1763
1764 @smallexample
1765 #define debug(format, args...) fprintf (stderr, format, args)
1766 @end smallexample
1767
1768 @noindent
1769 This is in all ways equivalent to the ISO C example above, but arguably
1770 more readable and descriptive.
1771
1772 GNU CPP has two further variadic macro extensions, and permits them to
1773 be used with either of the above forms of macro definition.
1774
1775 In standard C, you are not allowed to leave the variable argument out
1776 entirely; but you are allowed to pass an empty argument. For example,
1777 this invocation is invalid in ISO C, because there is no comma after
1778 the string:
1779
1780 @smallexample
1781 debug ("A message")
1782 @end smallexample
1783
1784 GNU CPP permits you to completely omit the variable arguments in this
1785 way. In the above examples, the compiler would complain, though since
1786 the expansion of the macro still has the extra comma after the format
1787 string.
1788
1789 To help solve this problem, CPP behaves specially for variable arguments
1790 used with the token paste operator, @samp{##}. If instead you write
1791
1792 @smallexample
1793 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1794 @end smallexample
1795
1796 @noindent
1797 and if the variable arguments are omitted or empty, the @samp{##}
1798 operator causes the preprocessor to remove the comma before it. If you
1799 do provide some variable arguments in your macro invocation, GNU CPP
1800 does not complain about the paste operation and instead places the
1801 variable arguments after the comma. Just like any other pasted macro
1802 argument, these arguments are not macro expanded.
1803
1804 @node Escaped Newlines
1805 @section Slightly Looser Rules for Escaped Newlines
1806 @cindex escaped newlines
1807 @cindex newlines (escaped)
1808
1809 The preprocessor treatment of escaped newlines is more relaxed
1810 than that specified by the C90 standard, which requires the newline
1811 to immediately follow a backslash.
1812 GCC's implementation allows whitespace in the form
1813 of spaces, horizontal and vertical tabs, and form feeds between the
1814 backslash and the subsequent newline. The preprocessor issues a
1815 warning, but treats it as a valid escaped newline and combines the two
1816 lines to form a single logical line. This works within comments and
1817 tokens, as well as between tokens. Comments are @emph{not} treated as
1818 whitespace for the purposes of this relaxation, since they have not
1819 yet been replaced with spaces.
1820
1821 @node Subscripting
1822 @section Non-Lvalue Arrays May Have Subscripts
1823 @cindex subscripting
1824 @cindex arrays, non-lvalue
1825
1826 @cindex subscripting and function values
1827 In ISO C99, arrays that are not lvalues still decay to pointers, and
1828 may be subscripted, although they may not be modified or used after
1829 the next sequence point and the unary @samp{&} operator may not be
1830 applied to them. As an extension, GNU C allows such arrays to be
1831 subscripted in C90 mode, though otherwise they do not decay to
1832 pointers outside C99 mode. For example,
1833 this is valid in GNU C though not valid in C90:
1834
1835 @smallexample
1836 @group
1837 struct foo @{int a[4];@};
1838
1839 struct foo f();
1840
1841 bar (int index)
1842 @{
1843 return f().a[index];
1844 @}
1845 @end group
1846 @end smallexample
1847
1848 @node Pointer Arith
1849 @section Arithmetic on @code{void}- and Function-Pointers
1850 @cindex void pointers, arithmetic
1851 @cindex void, size of pointer to
1852 @cindex function pointers, arithmetic
1853 @cindex function, size of pointer to
1854
1855 In GNU C, addition and subtraction operations are supported on pointers to
1856 @code{void} and on pointers to functions. This is done by treating the
1857 size of a @code{void} or of a function as 1.
1858
1859 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1860 and on function types, and returns 1.
1861
1862 @opindex Wpointer-arith
1863 The option @option{-Wpointer-arith} requests a warning if these extensions
1864 are used.
1865
1866 @node Pointers to Arrays
1867 @section Pointers to Arrays with Qualifiers Work as Expected
1868 @cindex pointers to arrays
1869 @cindex const qualifier
1870
1871 In GNU C, pointers to arrays with qualifiers work similar to pointers
1872 to other qualified types. For example, a value of type @code{int (*)[5]}
1873 can be used to initialize a variable of type @code{const int (*)[5]}.
1874 These types are incompatible in ISO C because the @code{const} qualifier
1875 is formally attached to the element type of the array and not the
1876 array itself.
1877
1878 @smallexample
1879 extern void
1880 transpose (int N, int M, double out[M][N], const double in[N][M]);
1881 double x[3][2];
1882 double y[2][3];
1883 @r{@dots{}}
1884 transpose(3, 2, y, x);
1885 @end smallexample
1886
1887 @node Initializers
1888 @section Non-Constant Initializers
1889 @cindex initializers, non-constant
1890 @cindex non-constant initializers
1891
1892 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1893 automatic variable are not required to be constant expressions in GNU C@.
1894 Here is an example of an initializer with run-time varying elements:
1895
1896 @smallexample
1897 foo (float f, float g)
1898 @{
1899 float beat_freqs[2] = @{ f-g, f+g @};
1900 /* @r{@dots{}} */
1901 @}
1902 @end smallexample
1903
1904 @node Compound Literals
1905 @section Compound Literals
1906 @cindex constructor expressions
1907 @cindex initializations in expressions
1908 @cindex structures, constructor expression
1909 @cindex expressions, constructor
1910 @cindex compound literals
1911 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1912
1913 A compound literal looks like a cast of a brace-enclosed aggregate
1914 initializer list. Its value is an object of the type specified in
1915 the cast, containing the elements specified in the initializer.
1916 Unlike the result of a cast, a compound literal is an lvalue. ISO
1917 C99 and later support compound literals. As an extension, GCC
1918 supports compound literals also in C90 mode and in C++, although
1919 as explained below, the C++ semantics are somewhat different.
1920
1921 Usually, the specified type of a compound literal is a structure. Assume
1922 that @code{struct foo} and @code{structure} are declared as shown:
1923
1924 @smallexample
1925 struct foo @{int a; char b[2];@} structure;
1926 @end smallexample
1927
1928 @noindent
1929 Here is an example of constructing a @code{struct foo} with a compound literal:
1930
1931 @smallexample
1932 structure = ((struct foo) @{x + y, 'a', 0@});
1933 @end smallexample
1934
1935 @noindent
1936 This is equivalent to writing the following:
1937
1938 @smallexample
1939 @{
1940 struct foo temp = @{x + y, 'a', 0@};
1941 structure = temp;
1942 @}
1943 @end smallexample
1944
1945 You can also construct an array, though this is dangerous in C++, as
1946 explained below. If all the elements of the compound literal are
1947 (made up of) simple constant expressions suitable for use in
1948 initializers of objects of static storage duration, then the compound
1949 literal can be coerced to a pointer to its first element and used in
1950 such an initializer, as shown here:
1951
1952 @smallexample
1953 char **foo = (char *[]) @{ "x", "y", "z" @};
1954 @end smallexample
1955
1956 Compound literals for scalar types and union types are also allowed. In
1957 the following example the variable @code{i} is initialized to the value
1958 @code{2}, the result of incrementing the unnamed object created by
1959 the compound literal.
1960
1961 @smallexample
1962 int i = ++(int) @{ 1 @};
1963 @end smallexample
1964
1965 As a GNU extension, GCC allows initialization of objects with static storage
1966 duration by compound literals (which is not possible in ISO C99 because
1967 the initializer is not a constant).
1968 It is handled as if the object were initialized only with the brace-enclosed
1969 list if the types of the compound literal and the object match.
1970 The elements of the compound literal must be constant.
1971 If the object being initialized has array type of unknown size, the size is
1972 determined by the size of the compound literal.
1973
1974 @smallexample
1975 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1976 static int y[] = (int []) @{1, 2, 3@};
1977 static int z[] = (int [3]) @{1@};
1978 @end smallexample
1979
1980 @noindent
1981 The above lines are equivalent to the following:
1982 @smallexample
1983 static struct foo x = @{1, 'a', 'b'@};
1984 static int y[] = @{1, 2, 3@};
1985 static int z[] = @{1, 0, 0@};
1986 @end smallexample
1987
1988 In C, a compound literal designates an unnamed object with static or
1989 automatic storage duration. In C++, a compound literal designates a
1990 temporary object that only lives until the end of its full-expression.
1991 As a result, well-defined C code that takes the address of a subobject
1992 of a compound literal can be undefined in C++, so G++ rejects
1993 the conversion of a temporary array to a pointer. For instance, if
1994 the array compound literal example above appeared inside a function,
1995 any subsequent use of @code{foo} in C++ would have undefined behavior
1996 because the lifetime of the array ends after the declaration of @code{foo}.
1997
1998 As an optimization, G++ sometimes gives array compound literals longer
1999 lifetimes: when the array either appears outside a function or has
2000 a @code{const}-qualified type. If @code{foo} and its initializer had
2001 elements of type @code{char *const} rather than @code{char *}, or if
2002 @code{foo} were a global variable, the array would have static storage
2003 duration. But it is probably safest just to avoid the use of array
2004 compound literals in C++ code.
2005
2006 @node Designated Inits
2007 @section Designated Initializers
2008 @cindex initializers with labeled elements
2009 @cindex labeled elements in initializers
2010 @cindex case labels in initializers
2011 @cindex designated initializers
2012
2013 Standard C90 requires the elements of an initializer to appear in a fixed
2014 order, the same as the order of the elements in the array or structure
2015 being initialized.
2016
2017 In ISO C99 you can give the elements in any order, specifying the array
2018 indices or structure field names they apply to, and GNU C allows this as
2019 an extension in C90 mode as well. This extension is not
2020 implemented in GNU C++.
2021
2022 To specify an array index, write
2023 @samp{[@var{index}] =} before the element value. For example,
2024
2025 @smallexample
2026 int a[6] = @{ [4] = 29, [2] = 15 @};
2027 @end smallexample
2028
2029 @noindent
2030 is equivalent to
2031
2032 @smallexample
2033 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2034 @end smallexample
2035
2036 @noindent
2037 The index values must be constant expressions, even if the array being
2038 initialized is automatic.
2039
2040 An alternative syntax for this that has been obsolete since GCC 2.5 but
2041 GCC still accepts is to write @samp{[@var{index}]} before the element
2042 value, with no @samp{=}.
2043
2044 To initialize a range of elements to the same value, write
2045 @samp{[@var{first} ... @var{last}] = @var{value}}. This is a GNU
2046 extension. For example,
2047
2048 @smallexample
2049 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2050 @end smallexample
2051
2052 @noindent
2053 If the value in it has side effects, the side effects happen only once,
2054 not for each initialized field by the range initializer.
2055
2056 @noindent
2057 Note that the length of the array is the highest value specified
2058 plus one.
2059
2060 In a structure initializer, specify the name of a field to initialize
2061 with @samp{.@var{fieldname} =} before the element value. For example,
2062 given the following structure,
2063
2064 @smallexample
2065 struct point @{ int x, y; @};
2066 @end smallexample
2067
2068 @noindent
2069 the following initialization
2070
2071 @smallexample
2072 struct point p = @{ .y = yvalue, .x = xvalue @};
2073 @end smallexample
2074
2075 @noindent
2076 is equivalent to
2077
2078 @smallexample
2079 struct point p = @{ xvalue, yvalue @};
2080 @end smallexample
2081
2082 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2083 @samp{@var{fieldname}:}, as shown here:
2084
2085 @smallexample
2086 struct point p = @{ y: yvalue, x: xvalue @};
2087 @end smallexample
2088
2089 Omitted field members are implicitly initialized the same as objects
2090 that have static storage duration.
2091
2092 @cindex designators
2093 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2094 @dfn{designator}. You can also use a designator (or the obsolete colon
2095 syntax) when initializing a union, to specify which element of the union
2096 should be used. For example,
2097
2098 @smallexample
2099 union foo @{ int i; double d; @};
2100
2101 union foo f = @{ .d = 4 @};
2102 @end smallexample
2103
2104 @noindent
2105 converts 4 to a @code{double} to store it in the union using
2106 the second element. By contrast, casting 4 to type @code{union foo}
2107 stores it into the union as the integer @code{i}, since it is
2108 an integer. @xref{Cast to Union}.
2109
2110 You can combine this technique of naming elements with ordinary C
2111 initialization of successive elements. Each initializer element that
2112 does not have a designator applies to the next consecutive element of the
2113 array or structure. For example,
2114
2115 @smallexample
2116 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2117 @end smallexample
2118
2119 @noindent
2120 is equivalent to
2121
2122 @smallexample
2123 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2124 @end smallexample
2125
2126 Labeling the elements of an array initializer is especially useful
2127 when the indices are characters or belong to an @code{enum} type.
2128 For example:
2129
2130 @smallexample
2131 int whitespace[256]
2132 = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2133 ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2134 @end smallexample
2135
2136 @cindex designator lists
2137 You can also write a series of @samp{.@var{fieldname}} and
2138 @samp{[@var{index}]} designators before an @samp{=} to specify a
2139 nested subobject to initialize; the list is taken relative to the
2140 subobject corresponding to the closest surrounding brace pair. For
2141 example, with the @samp{struct point} declaration above:
2142
2143 @smallexample
2144 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2145 @end smallexample
2146
2147 @noindent
2148 If the same field is initialized multiple times, it has the value from
2149 the last initialization. If any such overridden initialization has
2150 side effect, it is unspecified whether the side effect happens or not.
2151 Currently, GCC discards them and issues a warning.
2152
2153 @node Case Ranges
2154 @section Case Ranges
2155 @cindex case ranges
2156 @cindex ranges in case statements
2157
2158 You can specify a range of consecutive values in a single @code{case} label,
2159 like this:
2160
2161 @smallexample
2162 case @var{low} ... @var{high}:
2163 @end smallexample
2164
2165 @noindent
2166 This has the same effect as the proper number of individual @code{case}
2167 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2168
2169 This feature is especially useful for ranges of ASCII character codes:
2170
2171 @smallexample
2172 case 'A' ... 'Z':
2173 @end smallexample
2174
2175 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2176 it may be parsed wrong when you use it with integer values. For example,
2177 write this:
2178
2179 @smallexample
2180 case 1 ... 5:
2181 @end smallexample
2182
2183 @noindent
2184 rather than this:
2185
2186 @smallexample
2187 case 1...5:
2188 @end smallexample
2189
2190 @node Cast to Union
2191 @section Cast to a Union Type
2192 @cindex cast to a union
2193 @cindex union, casting to a
2194
2195 A cast to union type looks similar to other casts, except that the type
2196 specified is a union type. You can specify the type either with the
2197 @code{union} keyword or with a @code{typedef} name that refers to
2198 a union. A cast to a union actually creates a compound literal and
2199 yields an lvalue, not an rvalue like true casts do.
2200 @xref{Compound Literals}.
2201
2202 The types that may be cast to the union type are those of the members
2203 of the union. Thus, given the following union and variables:
2204
2205 @smallexample
2206 union foo @{ int i; double d; @};
2207 int x;
2208 double y;
2209 @end smallexample
2210
2211 @noindent
2212 both @code{x} and @code{y} can be cast to type @code{union foo}.
2213
2214 Using the cast as the right-hand side of an assignment to a variable of
2215 union type is equivalent to storing in a member of the union:
2216
2217 @smallexample
2218 union foo u;
2219 /* @r{@dots{}} */
2220 u = (union foo) x @equiv{} u.i = x
2221 u = (union foo) y @equiv{} u.d = y
2222 @end smallexample
2223
2224 You can also use the union cast as a function argument:
2225
2226 @smallexample
2227 void hack (union foo);
2228 /* @r{@dots{}} */
2229 hack ((union foo) x);
2230 @end smallexample
2231
2232 @node Mixed Declarations
2233 @section Mixed Declarations and Code
2234 @cindex mixed declarations and code
2235 @cindex declarations, mixed with code
2236 @cindex code, mixed with declarations
2237
2238 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2239 within compound statements. As an extension, GNU C also allows this in
2240 C90 mode. For example, you could do:
2241
2242 @smallexample
2243 int i;
2244 /* @r{@dots{}} */
2245 i++;
2246 int j = i + 2;
2247 @end smallexample
2248
2249 Each identifier is visible from where it is declared until the end of
2250 the enclosing block.
2251
2252 @node Function Attributes
2253 @section Declaring Attributes of Functions
2254 @cindex function attributes
2255 @cindex declaring attributes of functions
2256 @cindex @code{volatile} applied to function
2257 @cindex @code{const} applied to function
2258
2259 In GNU C, you can use function attributes to declare certain things
2260 about functions called in your program which help the compiler
2261 optimize calls and check your code more carefully. For example, you
2262 can use attributes to declare that a function never returns
2263 (@code{noreturn}), returns a value depending only on its arguments
2264 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2265
2266 You can also use attributes to control memory placement, code
2267 generation options or call/return conventions within the function
2268 being annotated. Many of these attributes are target-specific. For
2269 example, many targets support attributes for defining interrupt
2270 handler functions, which typically must follow special register usage
2271 and return conventions.
2272
2273 Function attributes are introduced by the @code{__attribute__} keyword
2274 on a declaration, followed by an attribute specification inside double
2275 parentheses. You can specify multiple attributes in a declaration by
2276 separating them by commas within the double parentheses or by
2277 immediately following an attribute declaration with another attribute
2278 declaration. @xref{Attribute Syntax}, for the exact rules on attribute
2279 syntax and placement. Compatible attribute specifications on distinct
2280 declarations of the same function are merged. An attribute specification
2281 that is not compatible with attributes already applied to a declaration
2282 of the same function is ignored with a warning.
2283
2284 GCC also supports attributes on
2285 variable declarations (@pxref{Variable Attributes}),
2286 labels (@pxref{Label Attributes}),
2287 enumerators (@pxref{Enumerator Attributes}),
2288 statements (@pxref{Statement Attributes}),
2289 and types (@pxref{Type Attributes}).
2290
2291 There is some overlap between the purposes of attributes and pragmas
2292 (@pxref{Pragmas,,Pragmas Accepted by GCC}). It has been
2293 found convenient to use @code{__attribute__} to achieve a natural
2294 attachment of attributes to their corresponding declarations, whereas
2295 @code{#pragma} is of use for compatibility with other compilers
2296 or constructs that do not naturally form part of the grammar.
2297
2298 In addition to the attributes documented here,
2299 GCC plugins may provide their own attributes.
2300
2301 @menu
2302 * Common Function Attributes::
2303 * AArch64 Function Attributes::
2304 * ARC Function Attributes::
2305 * ARM Function Attributes::
2306 * AVR Function Attributes::
2307 * Blackfin Function Attributes::
2308 * CR16 Function Attributes::
2309 * Epiphany Function Attributes::
2310 * H8/300 Function Attributes::
2311 * IA-64 Function Attributes::
2312 * M32C Function Attributes::
2313 * M32R/D Function Attributes::
2314 * m68k Function Attributes::
2315 * MCORE Function Attributes::
2316 * MeP Function Attributes::
2317 * MicroBlaze Function Attributes::
2318 * Microsoft Windows Function Attributes::
2319 * MIPS Function Attributes::
2320 * MSP430 Function Attributes::
2321 * NDS32 Function Attributes::
2322 * Nios II Function Attributes::
2323 * Nvidia PTX Function Attributes::
2324 * PowerPC Function Attributes::
2325 * RISC-V Function Attributes::
2326 * RL78 Function Attributes::
2327 * RX Function Attributes::
2328 * S/390 Function Attributes::
2329 * SH Function Attributes::
2330 * SPU Function Attributes::
2331 * Symbian OS Function Attributes::
2332 * V850 Function Attributes::
2333 * Visium Function Attributes::
2334 * x86 Function Attributes::
2335 * Xstormy16 Function Attributes::
2336 @end menu
2337
2338 @node Common Function Attributes
2339 @subsection Common Function Attributes
2340
2341 The following attributes are supported on most targets.
2342
2343 @table @code
2344 @c Keep this table alphabetized by attribute name. Treat _ as space.
2345
2346 @item alias ("@var{target}")
2347 @cindex @code{alias} function attribute
2348 The @code{alias} attribute causes the declaration to be emitted as an
2349 alias for another symbol, which must be specified. For instance,
2350
2351 @smallexample
2352 void __f () @{ /* @r{Do something.} */; @}
2353 void f () __attribute__ ((weak, alias ("__f")));
2354 @end smallexample
2355
2356 @noindent
2357 defines @samp{f} to be a weak alias for @samp{__f}. In C++, the
2358 mangled name for the target must be used. It is an error if @samp{__f}
2359 is not defined in the same translation unit.
2360
2361 This attribute requires assembler and object file support,
2362 and may not be available on all targets.
2363
2364 @item aligned (@var{alignment})
2365 @cindex @code{aligned} function attribute
2366 This attribute specifies a minimum alignment for the function,
2367 measured in bytes.
2368
2369 You cannot use this attribute to decrease the alignment of a function,
2370 only to increase it. However, when you explicitly specify a function
2371 alignment this overrides the effect of the
2372 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2373 function.
2374
2375 Note that the effectiveness of @code{aligned} attributes may be
2376 limited by inherent limitations in your linker. On many systems, the
2377 linker is only able to arrange for functions to be aligned up to a
2378 certain maximum alignment. (For some linkers, the maximum supported
2379 alignment may be very very small.) See your linker documentation for
2380 further information.
2381
2382 The @code{aligned} attribute can also be used for variables and fields
2383 (@pxref{Variable Attributes}.)
2384
2385 @item alloc_align
2386 @cindex @code{alloc_align} function attribute
2387 The @code{alloc_align} attribute is used to tell the compiler that the
2388 function return value points to memory, where the returned pointer minimum
2389 alignment is given by one of the functions parameters. GCC uses this
2390 information to improve pointer alignment analysis.
2391
2392 The function parameter denoting the allocated alignment is specified by
2393 one integer argument, whose number is the argument of the attribute.
2394 Argument numbering starts at one.
2395
2396 For instance,
2397
2398 @smallexample
2399 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2400 @end smallexample
2401
2402 @noindent
2403 declares that @code{my_memalign} returns memory with minimum alignment
2404 given by parameter 1.
2405
2406 @item alloc_size
2407 @cindex @code{alloc_size} function attribute
2408 The @code{alloc_size} attribute is used to tell the compiler that the
2409 function return value points to memory, where the size is given by
2410 one or two of the functions parameters. GCC uses this
2411 information to improve the correctness of @code{__builtin_object_size}.
2412
2413 The function parameter(s) denoting the allocated size are specified by
2414 one or two integer arguments supplied to the attribute. The allocated size
2415 is either the value of the single function argument specified or the product
2416 of the two function arguments specified. Argument numbering starts at
2417 one.
2418
2419 For instance,
2420
2421 @smallexample
2422 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2423 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2424 @end smallexample
2425
2426 @noindent
2427 declares that @code{my_calloc} returns memory of the size given by
2428 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2429 of the size given by parameter 2.
2430
2431 @item always_inline
2432 @cindex @code{always_inline} function attribute
2433 Generally, functions are not inlined unless optimization is specified.
2434 For functions declared inline, this attribute inlines the function
2435 independent of any restrictions that otherwise apply to inlining.
2436 Failure to inline such a function is diagnosed as an error.
2437 Note that if such a function is called indirectly the compiler may
2438 or may not inline it depending on optimization level and a failure
2439 to inline an indirect call may or may not be diagnosed.
2440
2441 @item artificial
2442 @cindex @code{artificial} function attribute
2443 This attribute is useful for small inline wrappers that if possible
2444 should appear during debugging as a unit. Depending on the debug
2445 info format it either means marking the function as artificial
2446 or using the caller location for all instructions within the inlined
2447 body.
2448
2449 @item assume_aligned
2450 @cindex @code{assume_aligned} function attribute
2451 The @code{assume_aligned} attribute is used to tell the compiler that the
2452 function return value points to memory, where the returned pointer minimum
2453 alignment is given by the first argument.
2454 If the attribute has two arguments, the second argument is misalignment offset.
2455
2456 For instance
2457
2458 @smallexample
2459 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2460 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2461 @end smallexample
2462
2463 @noindent
2464 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2465 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2466 to 8.
2467
2468 @item bnd_instrument
2469 @cindex @code{bnd_instrument} function attribute
2470 The @code{bnd_instrument} attribute on functions is used to inform the
2471 compiler that the function should be instrumented when compiled
2472 with the @option{-fchkp-instrument-marked-only} option.
2473
2474 @item bnd_legacy
2475 @cindex @code{bnd_legacy} function attribute
2476 @cindex Pointer Bounds Checker attributes
2477 The @code{bnd_legacy} attribute on functions is used to inform the
2478 compiler that the function should not be instrumented when compiled
2479 with the @option{-fcheck-pointer-bounds} option.
2480
2481 @item cold
2482 @cindex @code{cold} function attribute
2483 The @code{cold} attribute on functions is used to inform the compiler that
2484 the function is unlikely to be executed. The function is optimized for
2485 size rather than speed and on many targets it is placed into a special
2486 subsection of the text section so all cold functions appear close together,
2487 improving code locality of non-cold parts of program. The paths leading
2488 to calls of cold functions within code are marked as unlikely by the branch
2489 prediction mechanism. It is thus useful to mark functions used to handle
2490 unlikely conditions, such as @code{perror}, as cold to improve optimization
2491 of hot functions that do call marked functions in rare occasions.
2492
2493 When profile feedback is available, via @option{-fprofile-use}, cold functions
2494 are automatically detected and this attribute is ignored.
2495
2496 @item const
2497 @cindex @code{const} function attribute
2498 @cindex functions that have no side effects
2499 Many functions do not examine any values except their arguments, and
2500 have no effects except to return a value. Calls to such functions lend
2501 themselves to optimization such as common subexpression elimination.
2502 The @code{const} attribute imposes greater restrictions on a function's
2503 definition than the similar @code{pure} attribute below because it prohibits
2504 the function from reading global variables. Consequently, the presence of
2505 the attribute on a function declaration allows GCC to emit more efficient
2506 code for some calls to the function. Decorating the same function with
2507 both the @code{const} and the @code{pure} attribute is diagnosed.
2508
2509 @cindex pointer arguments
2510 Note that a function that has pointer arguments and examines the data
2511 pointed to must @emph{not} be declared @code{const}. Likewise, a
2512 function that calls a non-@code{const} function usually must not be
2513 @code{const}. Because a @code{const} function cannot have any side
2514 effects it does not make sense for such a function to return @code{void}.
2515 Declaring such a function is diagnosed.
2516
2517 @item constructor
2518 @itemx destructor
2519 @itemx constructor (@var{priority})
2520 @itemx destructor (@var{priority})
2521 @cindex @code{constructor} function attribute
2522 @cindex @code{destructor} function attribute
2523 The @code{constructor} attribute causes the function to be called
2524 automatically before execution enters @code{main ()}. Similarly, the
2525 @code{destructor} attribute causes the function to be called
2526 automatically after @code{main ()} completes or @code{exit ()} is
2527 called. Functions with these attributes are useful for
2528 initializing data that is used implicitly during the execution of
2529 the program.
2530
2531 You may provide an optional integer priority to control the order in
2532 which constructor and destructor functions are run. A constructor
2533 with a smaller priority number runs before a constructor with a larger
2534 priority number; the opposite relationship holds for destructors. So,
2535 if you have a constructor that allocates a resource and a destructor
2536 that deallocates the same resource, both functions typically have the
2537 same priority. The priorities for constructor and destructor
2538 functions are the same as those specified for namespace-scope C++
2539 objects (@pxref{C++ Attributes}). However, at present, the order in which
2540 constructors for C++ objects with static storage duration and functions
2541 decorated with attribute @code{constructor} are invoked is unspecified.
2542 In mixed declarations, attribute @code{init_priority} can be used to
2543 impose a specific ordering.
2544
2545 @item deprecated
2546 @itemx deprecated (@var{msg})
2547 @cindex @code{deprecated} function attribute
2548 The @code{deprecated} attribute results in a warning if the function
2549 is used anywhere in the source file. This is useful when identifying
2550 functions that are expected to be removed in a future version of a
2551 program. The warning also includes the location of the declaration
2552 of the deprecated function, to enable users to easily find further
2553 information about why the function is deprecated, or what they should
2554 do instead. Note that the warnings only occurs for uses:
2555
2556 @smallexample
2557 int old_fn () __attribute__ ((deprecated));
2558 int old_fn ();
2559 int (*fn_ptr)() = old_fn;
2560 @end smallexample
2561
2562 @noindent
2563 results in a warning on line 3 but not line 2. The optional @var{msg}
2564 argument, which must be a string, is printed in the warning if
2565 present.
2566
2567 The @code{deprecated} attribute can also be used for variables and
2568 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2569
2570 @item error ("@var{message}")
2571 @itemx warning ("@var{message}")
2572 @cindex @code{error} function attribute
2573 @cindex @code{warning} function attribute
2574 If the @code{error} or @code{warning} attribute
2575 is used on a function declaration and a call to such a function
2576 is not eliminated through dead code elimination or other optimizations,
2577 an error or warning (respectively) that includes @var{message} is diagnosed.
2578 This is useful
2579 for compile-time checking, especially together with @code{__builtin_constant_p}
2580 and inline functions where checking the inline function arguments is not
2581 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2582
2583 While it is possible to leave the function undefined and thus invoke
2584 a link failure (to define the function with
2585 a message in @code{.gnu.warning*} section),
2586 when using these attributes the problem is diagnosed
2587 earlier and with exact location of the call even in presence of inline
2588 functions or when not emitting debugging information.
2589
2590 @item externally_visible
2591 @cindex @code{externally_visible} function attribute
2592 This attribute, attached to a global variable or function, nullifies
2593 the effect of the @option{-fwhole-program} command-line option, so the
2594 object remains visible outside the current compilation unit.
2595
2596 If @option{-fwhole-program} is used together with @option{-flto} and
2597 @command{gold} is used as the linker plugin,
2598 @code{externally_visible} attributes are automatically added to functions
2599 (not variable yet due to a current @command{gold} issue)
2600 that are accessed outside of LTO objects according to resolution file
2601 produced by @command{gold}.
2602 For other linkers that cannot generate resolution file,
2603 explicit @code{externally_visible} attributes are still necessary.
2604
2605 @item flatten
2606 @cindex @code{flatten} function attribute
2607 Generally, inlining into a function is limited. For a function marked with
2608 this attribute, every call inside this function is inlined, if possible.
2609 Whether the function itself is considered for inlining depends on its size and
2610 the current inlining parameters.
2611
2612 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2613 @cindex @code{format} function attribute
2614 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2615 @opindex Wformat
2616 The @code{format} attribute specifies that a function takes @code{printf},
2617 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2618 should be type-checked against a format string. For example, the
2619 declaration:
2620
2621 @smallexample
2622 extern int
2623 my_printf (void *my_object, const char *my_format, ...)
2624 __attribute__ ((format (printf, 2, 3)));
2625 @end smallexample
2626
2627 @noindent
2628 causes the compiler to check the arguments in calls to @code{my_printf}
2629 for consistency with the @code{printf} style format string argument
2630 @code{my_format}.
2631
2632 The parameter @var{archetype} determines how the format string is
2633 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2634 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2635 @code{strfmon}. (You can also use @code{__printf__},
2636 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.) On
2637 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2638 @code{ms_strftime} are also present.
2639 @var{archetype} values such as @code{printf} refer to the formats accepted
2640 by the system's C runtime library,
2641 while values prefixed with @samp{gnu_} always refer
2642 to the formats accepted by the GNU C Library. On Microsoft Windows
2643 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2644 @file{msvcrt.dll} library.
2645 The parameter @var{string-index}
2646 specifies which argument is the format string argument (starting
2647 from 1), while @var{first-to-check} is the number of the first
2648 argument to check against the format string. For functions
2649 where the arguments are not available to be checked (such as
2650 @code{vprintf}), specify the third parameter as zero. In this case the
2651 compiler only checks the format string for consistency. For
2652 @code{strftime} formats, the third parameter is required to be zero.
2653 Since non-static C++ methods have an implicit @code{this} argument, the
2654 arguments of such methods should be counted from two, not one, when
2655 giving values for @var{string-index} and @var{first-to-check}.
2656
2657 In the example above, the format string (@code{my_format}) is the second
2658 argument of the function @code{my_print}, and the arguments to check
2659 start with the third argument, so the correct parameters for the format
2660 attribute are 2 and 3.
2661
2662 @opindex ffreestanding
2663 @opindex fno-builtin
2664 The @code{format} attribute allows you to identify your own functions
2665 that take format strings as arguments, so that GCC can check the
2666 calls to these functions for errors. The compiler always (unless
2667 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2668 for the standard library functions @code{printf}, @code{fprintf},
2669 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2670 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2671 warnings are requested (using @option{-Wformat}), so there is no need to
2672 modify the header file @file{stdio.h}. In C99 mode, the functions
2673 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2674 @code{vsscanf} are also checked. Except in strictly conforming C
2675 standard modes, the X/Open function @code{strfmon} is also checked as
2676 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2677 @xref{C Dialect Options,,Options Controlling C Dialect}.
2678
2679 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2680 recognized in the same context. Declarations including these format attributes
2681 are parsed for correct syntax, however the result of checking of such format
2682 strings is not yet defined, and is not carried out by this version of the
2683 compiler.
2684
2685 The target may also provide additional types of format checks.
2686 @xref{Target Format Checks,,Format Checks Specific to Particular
2687 Target Machines}.
2688
2689 @item format_arg (@var{string-index})
2690 @cindex @code{format_arg} function attribute
2691 @opindex Wformat-nonliteral
2692 The @code{format_arg} attribute specifies that a function takes a format
2693 string for a @code{printf}, @code{scanf}, @code{strftime} or
2694 @code{strfmon} style function and modifies it (for example, to translate
2695 it into another language), so the result can be passed to a
2696 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2697 function (with the remaining arguments to the format function the same
2698 as they would have been for the unmodified string). For example, the
2699 declaration:
2700
2701 @smallexample
2702 extern char *
2703 my_dgettext (char *my_domain, const char *my_format)
2704 __attribute__ ((format_arg (2)));
2705 @end smallexample
2706
2707 @noindent
2708 causes the compiler to check the arguments in calls to a @code{printf},
2709 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2710 format string argument is a call to the @code{my_dgettext} function, for
2711 consistency with the format string argument @code{my_format}. If the
2712 @code{format_arg} attribute had not been specified, all the compiler
2713 could tell in such calls to format functions would be that the format
2714 string argument is not constant; this would generate a warning when
2715 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2716 without the attribute.
2717
2718 The parameter @var{string-index} specifies which argument is the format
2719 string argument (starting from one). Since non-static C++ methods have
2720 an implicit @code{this} argument, the arguments of such methods should
2721 be counted from two.
2722
2723 The @code{format_arg} attribute allows you to identify your own
2724 functions that modify format strings, so that GCC can check the
2725 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2726 type function whose operands are a call to one of your own function.
2727 The compiler always treats @code{gettext}, @code{dgettext}, and
2728 @code{dcgettext} in this manner except when strict ISO C support is
2729 requested by @option{-ansi} or an appropriate @option{-std} option, or
2730 @option{-ffreestanding} or @option{-fno-builtin}
2731 is used. @xref{C Dialect Options,,Options
2732 Controlling C Dialect}.
2733
2734 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2735 @code{NSString} reference for compatibility with the @code{format} attribute
2736 above.
2737
2738 The target may also allow additional types in @code{format-arg} attributes.
2739 @xref{Target Format Checks,,Format Checks Specific to Particular
2740 Target Machines}.
2741
2742 @item gnu_inline
2743 @cindex @code{gnu_inline} function attribute
2744 This attribute should be used with a function that is also declared
2745 with the @code{inline} keyword. It directs GCC to treat the function
2746 as if it were defined in gnu90 mode even when compiling in C99 or
2747 gnu99 mode.
2748
2749 If the function is declared @code{extern}, then this definition of the
2750 function is used only for inlining. In no case is the function
2751 compiled as a standalone function, not even if you take its address
2752 explicitly. Such an address becomes an external reference, as if you
2753 had only declared the function, and had not defined it. This has
2754 almost the effect of a macro. The way to use this is to put a
2755 function definition in a header file with this attribute, and put
2756 another copy of the function, without @code{extern}, in a library
2757 file. The definition in the header file causes most calls to the
2758 function to be inlined. If any uses of the function remain, they
2759 refer to the single copy in the library. Note that the two
2760 definitions of the functions need not be precisely the same, although
2761 if they do not have the same effect your program may behave oddly.
2762
2763 In C, if the function is neither @code{extern} nor @code{static}, then
2764 the function is compiled as a standalone function, as well as being
2765 inlined where possible.
2766
2767 This is how GCC traditionally handled functions declared
2768 @code{inline}. Since ISO C99 specifies a different semantics for
2769 @code{inline}, this function attribute is provided as a transition
2770 measure and as a useful feature in its own right. This attribute is
2771 available in GCC 4.1.3 and later. It is available if either of the
2772 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2773 @code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
2774 Function is As Fast As a Macro}.
2775
2776 In C++, this attribute does not depend on @code{extern} in any way,
2777 but it still requires the @code{inline} keyword to enable its special
2778 behavior.
2779
2780 @item hot
2781 @cindex @code{hot} function attribute
2782 The @code{hot} attribute on a function is used to inform the compiler that
2783 the function is a hot spot of the compiled program. The function is
2784 optimized more aggressively and on many targets it is placed into a special
2785 subsection of the text section so all hot functions appear close together,
2786 improving locality.
2787
2788 When profile feedback is available, via @option{-fprofile-use}, hot functions
2789 are automatically detected and this attribute is ignored.
2790
2791 @item ifunc ("@var{resolver}")
2792 @cindex @code{ifunc} function attribute
2793 @cindex indirect functions
2794 @cindex functions that are dynamically resolved
2795 The @code{ifunc} attribute is used to mark a function as an indirect
2796 function using the STT_GNU_IFUNC symbol type extension to the ELF
2797 standard. This allows the resolution of the symbol value to be
2798 determined dynamically at load time, and an optimized version of the
2799 routine to be selected for the particular processor or other system
2800 characteristics determined then. To use this attribute, first define
2801 the implementation functions available, and a resolver function that
2802 returns a pointer to the selected implementation function. The
2803 implementation functions' declarations must match the API of the
2804 function being implemented. The resolver should be declared to
2805 be a function taking no arguments and returning a pointer to
2806 a function of the same type as the implementation. For example:
2807
2808 @smallexample
2809 void *my_memcpy (void *dst, const void *src, size_t len)
2810 @{
2811 @dots{}
2812 return dst;
2813 @}
2814
2815 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2816 @{
2817 return my_memcpy; // we will just always select this routine
2818 @}
2819 @end smallexample
2820
2821 @noindent
2822 The exported header file declaring the function the user calls would
2823 contain:
2824
2825 @smallexample
2826 extern void *memcpy (void *, const void *, size_t);
2827 @end smallexample
2828
2829 @noindent
2830 allowing the user to call @code{memcpy} as a regular function, unaware of
2831 the actual implementation. Finally, the indirect function needs to be
2832 defined in the same translation unit as the resolver function:
2833
2834 @smallexample
2835 void *memcpy (void *, const void *, size_t)
2836 __attribute__ ((ifunc ("resolve_memcpy")));
2837 @end smallexample
2838
2839 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2840 of the resolver function. A C++ resolver for a non-static member function
2841 of class @code{C} should be declared to return a pointer to a non-member
2842 function taking pointer to @code{C} as the first argument, followed by
2843 the same arguments as of the implementation function. G++ checks
2844 the signatures of the two functions and issues
2845 a @option{-Wattribute-alias} warning for mismatches. To suppress a warning
2846 for the necessary cast from a pointer to the implementation member function
2847 to the type of the corresponding non-member function use
2848 the @option{-Wno-pmf-conversions} option. For example:
2849
2850 @smallexample
2851 class S
2852 @{
2853 private:
2854 int debug_impl (int);
2855 int optimized_impl (int);
2856
2857 typedef int Func (S*, int);
2858
2859 static Func* resolver ();
2860 public:
2861
2862 int interface (int);
2863 @};
2864
2865 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2866 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2867
2868 S::Func* S::resolver ()
2869 @{
2870 int (S::*pimpl) (int)
2871 = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2872
2873 // Cast triggers -Wno-pmf-conversions.
2874 return reinterpret_cast<Func*>(pimpl);
2875 @}
2876
2877 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2878 @end smallexample
2879
2880 Indirect functions cannot be weak. Binutils version 2.20.1 or higher
2881 and GNU C Library version 2.11.1 are required to use this feature.
2882
2883 @item interrupt
2884 @itemx interrupt_handler
2885 Many GCC back ends support attributes to indicate that a function is
2886 an interrupt handler, which tells the compiler to generate function
2887 entry and exit sequences that differ from those from regular
2888 functions. The exact syntax and behavior are target-specific;
2889 refer to the following subsections for details.
2890
2891 @item leaf
2892 @cindex @code{leaf} function attribute
2893 Calls to external functions with this attribute must return to the
2894 current compilation unit only by return or by exception handling. In
2895 particular, a leaf function is not allowed to invoke callback functions
2896 passed to it from the current compilation unit, directly call functions
2897 exported by the unit, or @code{longjmp} into the unit. Leaf functions
2898 might still call functions from other compilation units and thus they
2899 are not necessarily leaf in the sense that they contain no function
2900 calls at all.
2901
2902 The attribute is intended for library functions to improve dataflow
2903 analysis. The compiler takes the hint that any data not escaping the
2904 current compilation unit cannot be used or modified by the leaf
2905 function. For example, the @code{sin} function is a leaf function, but
2906 @code{qsort} is not.
2907
2908 Note that leaf functions might indirectly run a signal handler defined
2909 in the current compilation unit that uses static variables. Similarly,
2910 when lazy symbol resolution is in effect, leaf functions might invoke
2911 indirect functions whose resolver function or implementation function is
2912 defined in the current compilation unit and uses static variables. There
2913 is no standard-compliant way to write such a signal handler, resolver
2914 function, or implementation function, and the best that you can do is to
2915 remove the @code{leaf} attribute or mark all such static variables
2916 @code{volatile}. Lastly, for ELF-based systems that support symbol
2917 interposition, care should be taken that functions defined in the
2918 current compilation unit do not unexpectedly interpose other symbols
2919 based on the defined standards mode and defined feature test macros;
2920 otherwise an inadvertent callback would be added.
2921
2922 The attribute has no effect on functions defined within the current
2923 compilation unit. This is to allow easy merging of multiple compilation
2924 units into one, for example, by using the link-time optimization. For
2925 this reason the attribute is not allowed on types to annotate indirect
2926 calls.
2927
2928 @item malloc
2929 @cindex @code{malloc} function attribute
2930 @cindex functions that behave like malloc
2931 This tells the compiler that a function is @code{malloc}-like, i.e.,
2932 that the pointer @var{P} returned by the function cannot alias any
2933 other pointer valid when the function returns, and moreover no
2934 pointers to valid objects occur in any storage addressed by @var{P}.
2935
2936 Using this attribute can improve optimization. Functions like
2937 @code{malloc} and @code{calloc} have this property because they return
2938 a pointer to uninitialized or zeroed-out storage. However, functions
2939 like @code{realloc} do not have this property, as they can return a
2940 pointer to storage containing pointers.
2941
2942 @item no_icf
2943 @cindex @code{no_icf} function attribute
2944 This function attribute prevents a functions from being merged with another
2945 semantically equivalent function.
2946
2947 @item no_instrument_function
2948 @cindex @code{no_instrument_function} function attribute
2949 @opindex finstrument-functions
2950 If @option{-finstrument-functions} is given, profiling function calls are
2951 generated at entry and exit of most user-compiled functions.
2952 Functions with this attribute are not so instrumented.
2953
2954 @item no_profile_instrument_function
2955 @cindex @code{no_profile_instrument_function} function attribute
2956 The @code{no_profile_instrument_function} attribute on functions is used
2957 to inform the compiler that it should not process any profile feedback based
2958 optimization code instrumentation.
2959
2960 @item no_reorder
2961 @cindex @code{no_reorder} function attribute
2962 Do not reorder functions or variables marked @code{no_reorder}
2963 against each other or top level assembler statements the executable.
2964 The actual order in the program will depend on the linker command
2965 line. Static variables marked like this are also not removed.
2966 This has a similar effect
2967 as the @option{-fno-toplevel-reorder} option, but only applies to the
2968 marked symbols.
2969
2970 @item no_sanitize ("@var{sanitize_option}")
2971 @cindex @code{no_sanitize} function attribute
2972 The @code{no_sanitize} attribute on functions is used
2973 to inform the compiler that it should not do sanitization of all options
2974 mentioned in @var{sanitize_option}. A list of values acceptable by
2975 @option{-fsanitize} option can be provided.
2976
2977 @smallexample
2978 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2979 f () @{ /* @r{Do something.} */; @}
2980 void __attribute__ ((no_sanitize ("alignment,object-size")))
2981 g () @{ /* @r{Do something.} */; @}
2982 @end smallexample
2983
2984 @item no_sanitize_address
2985 @itemx no_address_safety_analysis
2986 @cindex @code{no_sanitize_address} function attribute
2987 The @code{no_sanitize_address} attribute on functions is used
2988 to inform the compiler that it should not instrument memory accesses
2989 in the function when compiling with the @option{-fsanitize=address} option.
2990 The @code{no_address_safety_analysis} is a deprecated alias of the
2991 @code{no_sanitize_address} attribute, new code should use
2992 @code{no_sanitize_address}.
2993
2994 @item no_sanitize_thread
2995 @cindex @code{no_sanitize_thread} function attribute
2996 The @code{no_sanitize_thread} attribute on functions is used
2997 to inform the compiler that it should not instrument memory accesses
2998 in the function when compiling with the @option{-fsanitize=thread} option.
2999
3000 @item no_sanitize_undefined
3001 @cindex @code{no_sanitize_undefined} function attribute
3002 The @code{no_sanitize_undefined} attribute on functions is used
3003 to inform the compiler that it should not check for undefined behavior
3004 in the function when compiling with the @option{-fsanitize=undefined} option.
3005
3006 @item no_split_stack
3007 @cindex @code{no_split_stack} function attribute
3008 @opindex fsplit-stack
3009 If @option{-fsplit-stack} is given, functions have a small
3010 prologue which decides whether to split the stack. Functions with the
3011 @code{no_split_stack} attribute do not have that prologue, and thus
3012 may run with only a small amount of stack space available.
3013
3014 @item no_stack_limit
3015 @cindex @code{no_stack_limit} function attribute
3016 This attribute locally overrides the @option{-fstack-limit-register}
3017 and @option{-fstack-limit-symbol} command-line options; it has the effect
3018 of disabling stack limit checking in the function it applies to.
3019
3020 @item noclone
3021 @cindex @code{noclone} function attribute
3022 This function attribute prevents a function from being considered for
3023 cloning---a mechanism that produces specialized copies of functions
3024 and which is (currently) performed by interprocedural constant
3025 propagation.
3026
3027 @item noinline
3028 @cindex @code{noinline} function attribute
3029 This function attribute prevents a function from being considered for
3030 inlining.
3031 @c Don't enumerate the optimizations by name here; we try to be
3032 @c future-compatible with this mechanism.
3033 If the function does not have side effects, there are optimizations
3034 other than inlining that cause function calls to be optimized away,
3035 although the function call is live. To keep such calls from being
3036 optimized away, put
3037 @smallexample
3038 asm ("");
3039 @end smallexample
3040
3041 @noindent
3042 (@pxref{Extended Asm}) in the called function, to serve as a special
3043 side effect.
3044
3045 @item noipa
3046 @cindex @code{noipa} function attribute
3047 Disable interprocedural optimizations between the function with this
3048 attribute and its callers, as if the body of the function is not available
3049 when optimizing callers and the callers are unavailable when optimizing
3050 the body. This attribute implies @code{noinline}, @code{noclone} and
3051 @code{no_icf} attributes. However, this attribute is not equivalent
3052 to a combination of other attributes, because its purpose is to suppress
3053 existing and future optimizations employing interprocedural analysis,
3054 including those that do not have an attribute suitable for disabling
3055 them individually. This attribute is supported mainly for the purpose
3056 of testing the compiler.
3057
3058 @item nonnull (@var{arg-index}, @dots{})
3059 @cindex @code{nonnull} function attribute
3060 @cindex functions with non-null pointer arguments
3061 The @code{nonnull} attribute specifies that some function parameters should
3062 be non-null pointers. For instance, the declaration:
3063
3064 @smallexample
3065 extern void *
3066 my_memcpy (void *dest, const void *src, size_t len)
3067 __attribute__((nonnull (1, 2)));
3068 @end smallexample
3069
3070 @noindent
3071 causes the compiler to check that, in calls to @code{my_memcpy},
3072 arguments @var{dest} and @var{src} are non-null. If the compiler
3073 determines that a null pointer is passed in an argument slot marked
3074 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3075 is issued. The compiler may also choose to make optimizations based
3076 on the knowledge that certain function arguments will never be null.
3077
3078 If no argument index list is given to the @code{nonnull} attribute,
3079 all pointer arguments are marked as non-null. To illustrate, the
3080 following declaration is equivalent to the previous example:
3081
3082 @smallexample
3083 extern void *
3084 my_memcpy (void *dest, const void *src, size_t len)
3085 __attribute__((nonnull));
3086 @end smallexample
3087
3088 @item noplt
3089 @cindex @code{noplt} function attribute
3090 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3091 Calls to functions marked with this attribute in position-independent code
3092 do not use the PLT.
3093
3094 @smallexample
3095 @group
3096 /* Externally defined function foo. */
3097 int foo () __attribute__ ((noplt));
3098
3099 int
3100 main (/* @r{@dots{}} */)
3101 @{
3102 /* @r{@dots{}} */
3103 foo ();
3104 /* @r{@dots{}} */
3105 @}
3106 @end group
3107 @end smallexample
3108
3109 The @code{noplt} attribute on function @code{foo}
3110 tells the compiler to assume that
3111 the function @code{foo} is externally defined and that the call to
3112 @code{foo} must avoid the PLT
3113 in position-independent code.
3114
3115 In position-dependent code, a few targets also convert calls to
3116 functions that are marked to not use the PLT to use the GOT instead.
3117
3118 @item noreturn
3119 @cindex @code{noreturn} function attribute
3120 @cindex functions that never return
3121 A few standard library functions, such as @code{abort} and @code{exit},
3122 cannot return. GCC knows this automatically. Some programs define
3123 their own functions that never return. You can declare them
3124 @code{noreturn} to tell the compiler this fact. For example,
3125
3126 @smallexample
3127 @group
3128 void fatal () __attribute__ ((noreturn));
3129
3130 void
3131 fatal (/* @r{@dots{}} */)
3132 @{
3133 /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3134 exit (1);
3135 @}
3136 @end group
3137 @end smallexample
3138
3139 The @code{noreturn} keyword tells the compiler to assume that
3140 @code{fatal} cannot return. It can then optimize without regard to what
3141 would happen if @code{fatal} ever did return. This makes slightly
3142 better code. More importantly, it helps avoid spurious warnings of
3143 uninitialized variables.
3144
3145 The @code{noreturn} keyword does not affect the exceptional path when that
3146 applies: a @code{noreturn}-marked function may still return to the caller
3147 by throwing an exception or calling @code{longjmp}.
3148
3149 Do not assume that registers saved by the calling function are
3150 restored before calling the @code{noreturn} function.
3151
3152 It does not make sense for a @code{noreturn} function to have a return
3153 type other than @code{void}.
3154
3155 @item nothrow
3156 @cindex @code{nothrow} function attribute
3157 The @code{nothrow} attribute is used to inform the compiler that a
3158 function cannot throw an exception. For example, most functions in
3159 the standard C library can be guaranteed not to throw an exception
3160 with the notable exceptions of @code{qsort} and @code{bsearch} that
3161 take function pointer arguments.
3162
3163 @item optimize
3164 @cindex @code{optimize} function attribute
3165 The @code{optimize} attribute is used to specify that a function is to
3166 be compiled with different optimization options than specified on the
3167 command line. Arguments can either be numbers or strings. Numbers
3168 are assumed to be an optimization level. Strings that begin with
3169 @code{O} are assumed to be an optimization option, while other options
3170 are assumed to be used with a @code{-f} prefix. You can also use the
3171 @samp{#pragma GCC optimize} pragma to set the optimization options
3172 that affect more than one function.
3173 @xref{Function Specific Option Pragmas}, for details about the
3174 @samp{#pragma GCC optimize} pragma.
3175
3176 This attribute should be used for debugging purposes only. It is not
3177 suitable in production code.
3178
3179 @item patchable_function_entry
3180 @cindex @code{patchable_function_entry} function attribute
3181 @cindex extra NOP instructions at the function entry point
3182 In case the target's text segment can be made writable at run time by
3183 any means, padding the function entry with a number of NOPs can be
3184 used to provide a universal tool for instrumentation.
3185
3186 The @code{patchable_function_entry} function attribute can be used to
3187 change the number of NOPs to any desired value. The two-value syntax
3188 is the same as for the command-line switch
3189 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3190 the function entry point before the @var{M}th NOP instruction.
3191 @var{M} defaults to 0 if omitted e.g. function entry point is before
3192 the first NOP.
3193
3194 If patchable function entries are enabled globally using the command-line
3195 option @option{-fpatchable-function-entry=N,M}, then you must disable
3196 instrumentation on all functions that are part of the instrumentation
3197 framework with the attribute @code{patchable_function_entry (0)}
3198 to prevent recursion.
3199
3200 @item pure
3201 @cindex @code{pure} function attribute
3202 @cindex functions that have no side effects
3203 Many functions have no effects except the return value and their
3204 return value depends only on the parameters and/or global variables.
3205 Calls to such functions can be subject
3206 to common subexpression elimination and loop optimization just as an
3207 arithmetic operator would be. These functions should be declared
3208 with the attribute @code{pure}. For example,
3209
3210 @smallexample
3211 int square (int) __attribute__ ((pure));
3212 @end smallexample
3213
3214 @noindent
3215 says that the hypothetical function @code{square} is safe to call
3216 fewer times than the program says.
3217
3218 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3219 Interesting non-pure functions are functions with infinite loops or those
3220 depending on volatile memory or other system resource, that may change between
3221 two consecutive calls (such as @code{feof} in a multithreading environment).
3222
3223 The @code{pure} attribute imposes similar but looser restrictions on
3224 a function's defintion than the @code{const} attribute: it allows the
3225 function to read global variables. Decorating the same function with
3226 both the @code{pure} and the @code{const} attribute is diagnosed.
3227 Because a @code{pure} function cannot have any side effects it does not
3228 make sense for such a function to return @code{void}. Declaring such
3229 a function is diagnosed.
3230
3231 @item returns_nonnull
3232 @cindex @code{returns_nonnull} function attribute
3233 The @code{returns_nonnull} attribute specifies that the function
3234 return value should be a non-null pointer. For instance, the declaration:
3235
3236 @smallexample
3237 extern void *
3238 mymalloc (size_t len) __attribute__((returns_nonnull));
3239 @end smallexample
3240
3241 @noindent
3242 lets the compiler optimize callers based on the knowledge
3243 that the return value will never be null.
3244
3245 @item returns_twice
3246 @cindex @code{returns_twice} function attribute
3247 @cindex functions that return more than once
3248 The @code{returns_twice} attribute tells the compiler that a function may
3249 return more than one time. The compiler ensures that all registers
3250 are dead before calling such a function and emits a warning about
3251 the variables that may be clobbered after the second return from the
3252 function. Examples of such functions are @code{setjmp} and @code{vfork}.
3253 The @code{longjmp}-like counterpart of such function, if any, might need
3254 to be marked with the @code{noreturn} attribute.
3255
3256 @item section ("@var{section-name}")
3257 @cindex @code{section} function attribute
3258 @cindex functions in arbitrary sections
3259 Normally, the compiler places the code it generates in the @code{text} section.
3260 Sometimes, however, you need additional sections, or you need certain
3261 particular functions to appear in special sections. The @code{section}
3262 attribute specifies that a function lives in a particular section.
3263 For example, the declaration:
3264
3265 @smallexample
3266 extern void foobar (void) __attribute__ ((section ("bar")));
3267 @end smallexample
3268
3269 @noindent
3270 puts the function @code{foobar} in the @code{bar} section.
3271
3272 Some file formats do not support arbitrary sections so the @code{section}
3273 attribute is not available on all platforms.
3274 If you need to map the entire contents of a module to a particular
3275 section, consider using the facilities of the linker instead.
3276
3277 @item sentinel
3278 @cindex @code{sentinel} function attribute
3279 This function attribute ensures that a parameter in a function call is
3280 an explicit @code{NULL}. The attribute is only valid on variadic
3281 functions. By default, the sentinel is located at position zero, the
3282 last parameter of the function call. If an optional integer position
3283 argument P is supplied to the attribute, the sentinel must be located at
3284 position P counting backwards from the end of the argument list.
3285
3286 @smallexample
3287 __attribute__ ((sentinel))
3288 is equivalent to
3289 __attribute__ ((sentinel(0)))
3290 @end smallexample
3291
3292 The attribute is automatically set with a position of 0 for the built-in
3293 functions @code{execl} and @code{execlp}. The built-in function
3294 @code{execle} has the attribute set with a position of 1.
3295
3296 A valid @code{NULL} in this context is defined as zero with any pointer
3297 type. If your system defines the @code{NULL} macro with an integer type
3298 then you need to add an explicit cast. GCC replaces @code{stddef.h}
3299 with a copy that redefines NULL appropriately.
3300
3301 The warnings for missing or incorrect sentinels are enabled with
3302 @option{-Wformat}.
3303
3304 @item simd
3305 @itemx simd("@var{mask}")
3306 @cindex @code{simd} function attribute
3307 This attribute enables creation of one or more function versions that
3308 can process multiple arguments using SIMD instructions from a
3309 single invocation. Specifying this attribute allows compiler to
3310 assume that such versions are available at link time (provided
3311 in the same or another translation unit). Generated versions are
3312 target-dependent and described in the corresponding Vector ABI document. For
3313 x86_64 target this document can be found
3314 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3315
3316 The optional argument @var{mask} may have the value
3317 @code{notinbranch} or @code{inbranch},
3318 and instructs the compiler to generate non-masked or masked
3319 clones correspondingly. By default, all clones are generated.
3320
3321 If the attribute is specified and @code{#pragma omp declare simd} is
3322 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3323 switch is specified, then the attribute is ignored.
3324
3325 @item stack_protect
3326 @cindex @code{stack_protect} function attribute
3327 This attribute adds stack protection code to the function if
3328 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3329 or @option{-fstack-protector-explicit} are set.
3330
3331 @item target (@var{options})
3332 @cindex @code{target} function attribute
3333 Multiple target back ends implement the @code{target} attribute
3334 to specify that a function is to
3335 be compiled with different target options than specified on the
3336 command line. This can be used for instance to have functions
3337 compiled with a different ISA (instruction set architecture) than the
3338 default. You can also use the @samp{#pragma GCC target} pragma to set
3339 more than one function to be compiled with specific target options.
3340 @xref{Function Specific Option Pragmas}, for details about the
3341 @samp{#pragma GCC target} pragma.
3342
3343 For instance, on an x86, you could declare one function with the
3344 @code{target("sse4.1,arch=core2")} attribute and another with
3345 @code{target("sse4a,arch=amdfam10")}. This is equivalent to
3346 compiling the first function with @option{-msse4.1} and
3347 @option{-march=core2} options, and the second function with
3348 @option{-msse4a} and @option{-march=amdfam10} options. It is up to you
3349 to make sure that a function is only invoked on a machine that
3350 supports the particular ISA it is compiled for (for example by using
3351 @code{cpuid} on x86 to determine what feature bits and architecture
3352 family are used).
3353
3354 @smallexample
3355 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3356 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3357 @end smallexample
3358
3359 You can either use multiple
3360 strings separated by commas to specify multiple options,
3361 or separate the options with a comma (@samp{,}) within a single string.
3362
3363 The options supported are specific to each target; refer to @ref{x86
3364 Function Attributes}, @ref{PowerPC Function Attributes},
3365 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3366 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3367 for details.
3368
3369 @item target_clones (@var{options})
3370 @cindex @code{target_clones} function attribute
3371 The @code{target_clones} attribute is used to specify that a function
3372 be cloned into multiple versions compiled with different target options
3373 than specified on the command line. The supported options and restrictions
3374 are the same as for @code{target} attribute.
3375
3376 For instance, on an x86, you could compile a function with
3377 @code{target_clones("sse4.1,avx")}. GCC creates two function clones,
3378 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3379
3380 On a PowerPC, you can compile a function with
3381 @code{target_clones("cpu=power9,default")}. GCC will create two
3382 function clones, one compiled with @option{-mcpu=power9} and another
3383 with the default options. GCC must be configured to use GLIBC 2.23 or
3384 newer in order to use the @code{target_clones} attribute.
3385
3386 It also creates a resolver function (see
3387 the @code{ifunc} attribute above) that dynamically selects a clone
3388 suitable for current architecture. The resolver is created only if there
3389 is a usage of a function with @code{target_clones} attribute.
3390
3391 @item unused
3392 @cindex @code{unused} function attribute
3393 This attribute, attached to a function, means that the function is meant
3394 to be possibly unused. GCC does not produce a warning for this
3395 function.
3396
3397 @item used
3398 @cindex @code{used} function attribute
3399 This attribute, attached to a function, means that code must be emitted
3400 for the function even if it appears that the function is not referenced.
3401 This is useful, for example, when the function is referenced only in
3402 inline assembly.
3403
3404 When applied to a member function of a C++ class template, the
3405 attribute also means that the function is instantiated if the
3406 class itself is instantiated.
3407
3408 @item visibility ("@var{visibility_type}")
3409 @cindex @code{visibility} function attribute
3410 This attribute affects the linkage of the declaration to which it is attached.
3411 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3412 (@pxref{Common Type Attributes}) as well as functions.
3413
3414 There are four supported @var{visibility_type} values: default,
3415 hidden, protected or internal visibility.
3416
3417 @smallexample
3418 void __attribute__ ((visibility ("protected")))
3419 f () @{ /* @r{Do something.} */; @}
3420 int i __attribute__ ((visibility ("hidden")));
3421 @end smallexample
3422
3423 The possible values of @var{visibility_type} correspond to the
3424 visibility settings in the ELF gABI.
3425
3426 @table @code
3427 @c keep this list of visibilities in alphabetical order.
3428
3429 @item default
3430 Default visibility is the normal case for the object file format.
3431 This value is available for the visibility attribute to override other
3432 options that may change the assumed visibility of entities.
3433
3434 On ELF, default visibility means that the declaration is visible to other
3435 modules and, in shared libraries, means that the declared entity may be
3436 overridden.
3437
3438 On Darwin, default visibility means that the declaration is visible to
3439 other modules.
3440
3441 Default visibility corresponds to ``external linkage'' in the language.
3442
3443 @item hidden
3444 Hidden visibility indicates that the entity declared has a new
3445 form of linkage, which we call ``hidden linkage''. Two
3446 declarations of an object with hidden linkage refer to the same object
3447 if they are in the same shared object.
3448
3449 @item internal
3450 Internal visibility is like hidden visibility, but with additional
3451 processor specific semantics. Unless otherwise specified by the
3452 psABI, GCC defines internal visibility to mean that a function is
3453 @emph{never} called from another module. Compare this with hidden
3454 functions which, while they cannot be referenced directly by other
3455 modules, can be referenced indirectly via function pointers. By
3456 indicating that a function cannot be called from outside the module,
3457 GCC may for instance omit the load of a PIC register since it is known
3458 that the calling function loaded the correct value.
3459
3460 @item protected
3461 Protected visibility is like default visibility except that it
3462 indicates that references within the defining module bind to the
3463 definition in that module. That is, the declared entity cannot be
3464 overridden by another module.
3465
3466 @end table
3467
3468 All visibilities are supported on many, but not all, ELF targets
3469 (supported when the assembler supports the @samp{.visibility}
3470 pseudo-op). Default visibility is supported everywhere. Hidden
3471 visibility is supported on Darwin targets.
3472
3473 The visibility attribute should be applied only to declarations that
3474 would otherwise have external linkage. The attribute should be applied
3475 consistently, so that the same entity should not be declared with
3476 different settings of the attribute.
3477
3478 In C++, the visibility attribute applies to types as well as functions
3479 and objects, because in C++ types have linkage. A class must not have
3480 greater visibility than its non-static data member types and bases,
3481 and class members default to the visibility of their class. Also, a
3482 declaration without explicit visibility is limited to the visibility
3483 of its type.
3484
3485 In C++, you can mark member functions and static member variables of a
3486 class with the visibility attribute. This is useful if you know a
3487 particular method or static member variable should only be used from
3488 one shared object; then you can mark it hidden while the rest of the
3489 class has default visibility. Care must be taken to avoid breaking
3490 the One Definition Rule; for example, it is usually not useful to mark
3491 an inline method as hidden without marking the whole class as hidden.
3492
3493 A C++ namespace declaration can also have the visibility attribute.
3494
3495 @smallexample
3496 namespace nspace1 __attribute__ ((visibility ("protected")))
3497 @{ /* @r{Do something.} */; @}
3498 @end smallexample
3499
3500 This attribute applies only to the particular namespace body, not to
3501 other definitions of the same namespace; it is equivalent to using
3502 @samp{#pragma GCC visibility} before and after the namespace
3503 definition (@pxref{Visibility Pragmas}).
3504
3505 In C++, if a template argument has limited visibility, this
3506 restriction is implicitly propagated to the template instantiation.
3507 Otherwise, template instantiations and specializations default to the
3508 visibility of their template.
3509
3510 If both the template and enclosing class have explicit visibility, the
3511 visibility from the template is used.
3512
3513 @item warn_unused_result
3514 @cindex @code{warn_unused_result} function attribute
3515 The @code{warn_unused_result} attribute causes a warning to be emitted
3516 if a caller of the function with this attribute does not use its
3517 return value. This is useful for functions where not checking
3518 the result is either a security problem or always a bug, such as
3519 @code{realloc}.
3520
3521 @smallexample
3522 int fn () __attribute__ ((warn_unused_result));
3523 int foo ()
3524 @{
3525 if (fn () < 0) return -1;
3526 fn ();
3527 return 0;
3528 @}
3529 @end smallexample
3530
3531 @noindent
3532 results in warning on line 5.
3533
3534 @item weak
3535 @cindex @code{weak} function attribute
3536 The @code{weak} attribute causes the declaration to be emitted as a weak
3537 symbol rather than a global. This is primarily useful in defining
3538 library functions that can be overridden in user code, though it can
3539 also be used with non-function declarations. Weak symbols are supported
3540 for ELF targets, and also for a.out targets when using the GNU assembler
3541 and linker.
3542
3543 @item weakref
3544 @itemx weakref ("@var{target}")
3545 @cindex @code{weakref} function attribute
3546 The @code{weakref} attribute marks a declaration as a weak reference.
3547 Without arguments, it should be accompanied by an @code{alias} attribute
3548 naming the target symbol. Optionally, the @var{target} may be given as
3549 an argument to @code{weakref} itself. In either case, @code{weakref}
3550 implicitly marks the declaration as @code{weak}. Without a
3551 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3552 @code{weakref} is equivalent to @code{weak}.
3553
3554 @smallexample
3555 static int x() __attribute__ ((weakref ("y")));
3556 /* is equivalent to... */
3557 static int x() __attribute__ ((weak, weakref, alias ("y")));
3558 /* and to... */
3559 static int x() __attribute__ ((weakref));
3560 static int x() __attribute__ ((alias ("y")));
3561 @end smallexample
3562
3563 A weak reference is an alias that does not by itself require a
3564 definition to be given for the target symbol. If the target symbol is
3565 only referenced through weak references, then it becomes a @code{weak}
3566 undefined symbol. If it is directly referenced, however, then such
3567 strong references prevail, and a definition is required for the
3568 symbol, not necessarily in the same translation unit.
3569
3570 The effect is equivalent to moving all references to the alias to a
3571 separate translation unit, renaming the alias to the aliased symbol,
3572 declaring it as weak, compiling the two separate translation units and
3573 performing a reloadable link on them.
3574
3575 At present, a declaration to which @code{weakref} is attached can
3576 only be @code{static}.
3577
3578
3579 @end table
3580
3581 @c This is the end of the target-independent attribute table
3582
3583 @node AArch64 Function Attributes
3584 @subsection AArch64 Function Attributes
3585
3586 The following target-specific function attributes are available for the
3587 AArch64 target. For the most part, these options mirror the behavior of
3588 similar command-line options (@pxref{AArch64 Options}), but on a
3589 per-function basis.
3590
3591 @table @code
3592 @item general-regs-only
3593 @cindex @code{general-regs-only} function attribute, AArch64
3594 Indicates that no floating-point or Advanced SIMD registers should be
3595 used when generating code for this function. If the function explicitly
3596 uses floating-point code, then the compiler gives an error. This is
3597 the same behavior as that of the command-line option
3598 @option{-mgeneral-regs-only}.
3599
3600 @item fix-cortex-a53-835769
3601 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3602 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3603 applied to this function. To explicitly disable the workaround for this
3604 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3605 This corresponds to the behavior of the command line options
3606 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3607
3608 @item cmodel=
3609 @cindex @code{cmodel=} function attribute, AArch64
3610 Indicates that code should be generated for a particular code model for
3611 this function. The behavior and permissible arguments are the same as
3612 for the command line option @option{-mcmodel=}.
3613
3614 @item strict-align
3615 @itemx no-strict-align
3616 @cindex @code{strict-align} function attribute, AArch64
3617 @code{strict-align} indicates that the compiler should not assume that unaligned
3618 memory references are handled by the system. To allow the compiler to assume
3619 that aligned memory references are handled by the system, the inverse attribute
3620 @code{no-strict-align} can be specified. The behavior is same as for the
3621 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3622
3623 @item omit-leaf-frame-pointer
3624 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3625 Indicates that the frame pointer should be omitted for a leaf function call.
3626 To keep the frame pointer, the inverse attribute
3627 @code{no-omit-leaf-frame-pointer} can be specified. These attributes have
3628 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3629 and @option{-mno-omit-leaf-frame-pointer}.
3630
3631 @item tls-dialect=
3632 @cindex @code{tls-dialect=} function attribute, AArch64
3633 Specifies the TLS dialect to use for this function. The behavior and
3634 permissible arguments are the same as for the command-line option
3635 @option{-mtls-dialect=}.
3636
3637 @item arch=
3638 @cindex @code{arch=} function attribute, AArch64
3639 Specifies the architecture version and architectural extensions to use
3640 for this function. The behavior and permissible arguments are the same as
3641 for the @option{-march=} command-line option.
3642
3643 @item tune=
3644 @cindex @code{tune=} function attribute, AArch64
3645 Specifies the core for which to tune the performance of this function.
3646 The behavior and permissible arguments are the same as for the @option{-mtune=}
3647 command-line option.
3648
3649 @item cpu=
3650 @cindex @code{cpu=} function attribute, AArch64
3651 Specifies the core for which to tune the performance of this function and also
3652 whose architectural features to use. The behavior and valid arguments are the
3653 same as for the @option{-mcpu=} command-line option.
3654
3655 @item sign-return-address
3656 @cindex @code{sign-return-address} function attribute, AArch64
3657 Select the function scope on which return address signing will be applied. The
3658 behavior and permissible arguments are the same as for the command-line option
3659 @option{-msign-return-address=}. The default value is @code{none}.
3660
3661 @end table
3662
3663 The above target attributes can be specified as follows:
3664
3665 @smallexample
3666 __attribute__((target("@var{attr-string}")))
3667 int
3668 f (int a)
3669 @{
3670 return a + 5;
3671 @}
3672 @end smallexample
3673
3674 where @code{@var{attr-string}} is one of the attribute strings specified above.
3675
3676 Additionally, the architectural extension string may be specified on its
3677 own. This can be used to turn on and off particular architectural extensions
3678 without having to specify a particular architecture version or core. Example:
3679
3680 @smallexample
3681 __attribute__((target("+crc+nocrypto")))
3682 int
3683 foo (int a)
3684 @{
3685 return a + 5;
3686 @}
3687 @end smallexample
3688
3689 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3690 extension and disables the @code{crypto} extension for the function @code{foo}
3691 without modifying an existing @option{-march=} or @option{-mcpu} option.
3692
3693 Multiple target function attributes can be specified by separating them with
3694 a comma. For example:
3695 @smallexample
3696 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3697 int
3698 foo (int a)
3699 @{
3700 return a + 5;
3701 @}
3702 @end smallexample
3703
3704 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3705 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3706
3707 @subsubsection Inlining rules
3708 Specifying target attributes on individual functions or performing link-time
3709 optimization across translation units compiled with different target options
3710 can affect function inlining rules:
3711
3712 In particular, a caller function can inline a callee function only if the
3713 architectural features available to the callee are a subset of the features
3714 available to the caller.
3715 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3716 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3717 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3718 because the all the architectural features that function @code{bar} requires
3719 are available to function @code{foo}. Conversely, function @code{bar} cannot
3720 inline function @code{foo}.
3721
3722 Additionally inlining a function compiled with @option{-mstrict-align} into a
3723 function compiled without @code{-mstrict-align} is not allowed.
3724 However, inlining a function compiled without @option{-mstrict-align} into a
3725 function compiled with @option{-mstrict-align} is allowed.
3726
3727 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3728 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3729 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3730 architectural feature rules specified above.
3731
3732 @node ARC Function Attributes
3733 @subsection ARC Function Attributes
3734
3735 These function attributes are supported by the ARC back end:
3736
3737 @table @code
3738 @item interrupt
3739 @cindex @code{interrupt} function attribute, ARC
3740 Use this attribute to indicate
3741 that the specified function is an interrupt handler. The compiler generates
3742 function entry and exit sequences suitable for use in an interrupt handler
3743 when this attribute is present.
3744
3745 On the ARC, you must specify the kind of interrupt to be handled
3746 in a parameter to the interrupt attribute like this:
3747
3748 @smallexample
3749 void f () __attribute__ ((interrupt ("ilink1")));
3750 @end smallexample
3751
3752 Permissible values for this parameter are: @w{@code{ilink1}} and
3753 @w{@code{ilink2}}.
3754
3755 @item long_call
3756 @itemx medium_call
3757 @itemx short_call
3758 @cindex @code{long_call} function attribute, ARC
3759 @cindex @code{medium_call} function attribute, ARC
3760 @cindex @code{short_call} function attribute, ARC
3761 @cindex indirect calls, ARC
3762 These attributes specify how a particular function is called.
3763 These attributes override the
3764 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3765 command-line switches and @code{#pragma long_calls} settings.
3766
3767 For ARC, a function marked with the @code{long_call} attribute is
3768 always called using register-indirect jump-and-link instructions,
3769 thereby enabling the called function to be placed anywhere within the
3770 32-bit address space. A function marked with the @code{medium_call}
3771 attribute will always be close enough to be called with an unconditional
3772 branch-and-link instruction, which has a 25-bit offset from
3773 the call site. A function marked with the @code{short_call}
3774 attribute will always be close enough to be called with a conditional
3775 branch-and-link instruction, which has a 21-bit offset from
3776 the call site.
3777
3778 @item jli_always
3779 @cindex @code{jli_always} function attribute, ARC
3780 Forces a particular function to be called using @code{jli}
3781 instruction. The @code{jli} instruction makes use of a table stored
3782 into @code{.jlitab} section, which holds the location of the functions
3783 which are addressed using this instruction.
3784
3785 @item jli_fixed
3786 @cindex @code{jli_fixed} function attribute, ARC
3787 Identical like the above one, but the location of the function in the
3788 @code{jli} table is known and given as an attribute parameter.
3789
3790 @item secure_call
3791 @cindex @code{secure_call} function attribute, ARC
3792 This attribute allows one to mark secure-code functions that are
3793 callable from normal mode. The location of the secure call function
3794 into the @code{sjli} table needs to be passed as argument.
3795
3796 @end table
3797
3798 @node ARM Function Attributes
3799 @subsection ARM Function Attributes
3800
3801 These function attributes are supported for ARM targets:
3802
3803 @table @code
3804 @item interrupt
3805 @cindex @code{interrupt} function attribute, ARM
3806 Use this attribute to indicate
3807 that the specified function is an interrupt handler. The compiler generates
3808 function entry and exit sequences suitable for use in an interrupt handler
3809 when this attribute is present.
3810
3811 You can specify the kind of interrupt to be handled by
3812 adding an optional parameter to the interrupt attribute like this:
3813
3814 @smallexample
3815 void f () __attribute__ ((interrupt ("IRQ")));
3816 @end smallexample
3817
3818 @noindent
3819 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3820 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3821
3822 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3823 may be called with a word-aligned stack pointer.
3824
3825 @item isr
3826 @cindex @code{isr} function attribute, ARM
3827 Use this attribute on ARM to write Interrupt Service Routines. This is an
3828 alias to the @code{interrupt} attribute above.
3829
3830 @item long_call
3831 @itemx short_call
3832 @cindex @code{long_call} function attribute, ARM
3833 @cindex @code{short_call} function attribute, ARM
3834 @cindex indirect calls, ARM
3835 These attributes specify how a particular function is called.
3836 These attributes override the
3837 @option{-mlong-calls} (@pxref{ARM Options})
3838 command-line switch and @code{#pragma long_calls} settings. For ARM, the
3839 @code{long_call} attribute indicates that the function might be far
3840 away from the call site and require a different (more expensive)
3841 calling sequence. The @code{short_call} attribute always places
3842 the offset to the function from the call site into the @samp{BL}
3843 instruction directly.
3844
3845 @item naked
3846 @cindex @code{naked} function attribute, ARM
3847 This attribute allows the compiler to construct the
3848 requisite function declaration, while allowing the body of the
3849 function to be assembly code. The specified function will not have
3850 prologue/epilogue sequences generated by the compiler. Only basic
3851 @code{asm} statements can safely be included in naked functions
3852 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3853 basic @code{asm} and C code may appear to work, they cannot be
3854 depended upon to work reliably and are not supported.
3855
3856 @item pcs
3857 @cindex @code{pcs} function attribute, ARM
3858
3859 The @code{pcs} attribute can be used to control the calling convention
3860 used for a function on ARM. The attribute takes an argument that specifies
3861 the calling convention to use.
3862
3863 When compiling using the AAPCS ABI (or a variant of it) then valid
3864 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}. In
3865 order to use a variant other than @code{"aapcs"} then the compiler must
3866 be permitted to use the appropriate co-processor registers (i.e., the
3867 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3868 For example,
3869
3870 @smallexample
3871 /* Argument passed in r0, and result returned in r0+r1. */
3872 double f2d (float) __attribute__((pcs("aapcs")));
3873 @end smallexample
3874
3875 Variadic functions always use the @code{"aapcs"} calling convention and
3876 the compiler rejects attempts to specify an alternative.
3877
3878 @item target (@var{options})
3879 @cindex @code{target} function attribute
3880 As discussed in @ref{Common Function Attributes}, this attribute
3881 allows specification of target-specific compilation options.
3882
3883 On ARM, the following options are allowed:
3884
3885 @table @samp
3886 @item thumb
3887 @cindex @code{target("thumb")} function attribute, ARM
3888 Force code generation in the Thumb (T16/T32) ISA, depending on the
3889 architecture level.
3890
3891 @item arm
3892 @cindex @code{target("arm")} function attribute, ARM
3893 Force code generation in the ARM (A32) ISA.
3894
3895 Functions from different modes can be inlined in the caller's mode.
3896
3897 @item fpu=
3898 @cindex @code{target("fpu=")} function attribute, ARM
3899 Specifies the fpu for which to tune the performance of this function.
3900 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3901 command-line option.
3902
3903 @item arch=
3904 @cindex @code{arch=} function attribute, ARM
3905 Specifies the architecture version and architectural extensions to use
3906 for this function. The behavior and permissible arguments are the same as
3907 for the @option{-march=} command-line option.
3908
3909 The above target attributes can be specified as follows:
3910
3911 @smallexample
3912 __attribute__((target("arch=armv8-a+crc")))
3913 int
3914 f (int a)
3915 @{
3916 return a + 5;
3917 @}
3918 @end smallexample
3919
3920 Additionally, the architectural extension string may be specified on its
3921 own. This can be used to turn on and off particular architectural extensions
3922 without having to specify a particular architecture version or core. Example:
3923
3924 @smallexample
3925 __attribute__((target("+crc+nocrypto")))
3926 int
3927 foo (int a)
3928 @{
3929 return a + 5;
3930 @}
3931 @end smallexample
3932
3933 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3934 extension and disables the @code{crypto} extension for the function @code{foo}
3935 without modifying an existing @option{-march=} or @option{-mcpu} option.
3936
3937 @end table
3938
3939 @end table
3940
3941 @node AVR Function Attributes
3942 @subsection AVR Function Attributes
3943
3944 These function attributes are supported by the AVR back end:
3945
3946 @table @code
3947 @item interrupt
3948 @cindex @code{interrupt} function attribute, AVR
3949 Use this attribute to indicate
3950 that the specified function is an interrupt handler. The compiler generates
3951 function entry and exit sequences suitable for use in an interrupt handler
3952 when this attribute is present.
3953
3954 On the AVR, the hardware globally disables interrupts when an
3955 interrupt is executed. The first instruction of an interrupt handler
3956 declared with this attribute is a @code{SEI} instruction to
3957 re-enable interrupts. See also the @code{signal} function attribute
3958 that does not insert a @code{SEI} instruction. If both @code{signal} and
3959 @code{interrupt} are specified for the same function, @code{signal}
3960 is silently ignored.
3961
3962 @item naked
3963 @cindex @code{naked} function attribute, AVR
3964 This attribute allows the compiler to construct the
3965 requisite function declaration, while allowing the body of the
3966 function to be assembly code. The specified function will not have
3967 prologue/epilogue sequences generated by the compiler. Only basic
3968 @code{asm} statements can safely be included in naked functions
3969 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3970 basic @code{asm} and C code may appear to work, they cannot be
3971 depended upon to work reliably and are not supported.
3972
3973 @item no_gccisr
3974 @cindex @code{no_gccisr} function attribute, AVR
3975 Do not use @code{__gcc_isr} pseudo instructions in a function with
3976 the @code{interrupt} or @code{signal} attribute aka. interrupt
3977 service routine (ISR).
3978 Use this attribute if the preamble of the ISR prologue should always read
3979 @example
3980 push __zero_reg__
3981 push __tmp_reg__
3982 in __tmp_reg__, __SREG__
3983 push __tmp_reg__
3984 clr __zero_reg__
3985 @end example
3986 and accordingly for the postamble of the epilogue --- no matter whether
3987 the mentioned registers are actually used in the ISR or not.
3988 Situations where you might want to use this attribute include:
3989 @itemize @bullet
3990 @item
3991 Code that (effectively) clobbers bits of @code{SREG} other than the
3992 @code{I}-flag by writing to the memory location of @code{SREG}.
3993 @item
3994 Code that uses inline assembler to jump to a different function which
3995 expects (parts of) the prologue code as outlined above to be present.
3996 @end itemize
3997 To disable @code{__gcc_isr} generation for the whole compilation unit,
3998 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
3999
4000 @item OS_main
4001 @itemx OS_task
4002 @cindex @code{OS_main} function attribute, AVR
4003 @cindex @code{OS_task} function attribute, AVR
4004 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4005 do not save/restore any call-saved register in their prologue/epilogue.
4006
4007 The @code{OS_main} attribute can be used when there @emph{is
4008 guarantee} that interrupts are disabled at the time when the function
4009 is entered. This saves resources when the stack pointer has to be
4010 changed to set up a frame for local variables.
4011
4012 The @code{OS_task} attribute can be used when there is @emph{no
4013 guarantee} that interrupts are disabled at that time when the function
4014 is entered like for, e@.g@. task functions in a multi-threading operating
4015 system. In that case, changing the stack pointer register is
4016 guarded by save/clear/restore of the global interrupt enable flag.
4017
4018 The differences to the @code{naked} function attribute are:
4019 @itemize @bullet
4020 @item @code{naked} functions do not have a return instruction whereas
4021 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4022 @code{RETI} return instruction.
4023 @item @code{naked} functions do not set up a frame for local variables
4024 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4025 as needed.
4026 @end itemize
4027
4028 @item signal
4029 @cindex @code{signal} function attribute, AVR
4030 Use this attribute on the AVR to indicate that the specified
4031 function is an interrupt handler. The compiler generates function
4032 entry and exit sequences suitable for use in an interrupt handler when this
4033 attribute is present.
4034
4035 See also the @code{interrupt} function attribute.
4036
4037 The AVR hardware globally disables interrupts when an interrupt is executed.
4038 Interrupt handler functions defined with the @code{signal} attribute
4039 do not re-enable interrupts. It is save to enable interrupts in a
4040 @code{signal} handler. This ``save'' only applies to the code
4041 generated by the compiler and not to the IRQ layout of the
4042 application which is responsibility of the application.
4043
4044 If both @code{signal} and @code{interrupt} are specified for the same
4045 function, @code{signal} is silently ignored.
4046 @end table
4047
4048 @node Blackfin Function Attributes
4049 @subsection Blackfin Function Attributes
4050
4051 These function attributes are supported by the Blackfin back end:
4052
4053 @table @code
4054
4055 @item exception_handler
4056 @cindex @code{exception_handler} function attribute
4057 @cindex exception handler functions, Blackfin
4058 Use this attribute on the Blackfin to indicate that the specified function
4059 is an exception handler. The compiler generates function entry and
4060 exit sequences suitable for use in an exception handler when this
4061 attribute is present.
4062
4063 @item interrupt_handler
4064 @cindex @code{interrupt_handler} function attribute, Blackfin
4065 Use this attribute to
4066 indicate that the specified function is an interrupt handler. The compiler
4067 generates function entry and exit sequences suitable for use in an
4068 interrupt handler when this attribute is present.
4069
4070 @item kspisusp
4071 @cindex @code{kspisusp} function attribute, Blackfin
4072 @cindex User stack pointer in interrupts on the Blackfin
4073 When used together with @code{interrupt_handler}, @code{exception_handler}
4074 or @code{nmi_handler}, code is generated to load the stack pointer
4075 from the USP register in the function prologue.
4076
4077 @item l1_text
4078 @cindex @code{l1_text} function attribute, Blackfin
4079 This attribute specifies a function to be placed into L1 Instruction
4080 SRAM@. The function is put into a specific section named @code{.l1.text}.
4081 With @option{-mfdpic}, function calls with a such function as the callee
4082 or caller uses inlined PLT.
4083
4084 @item l2
4085 @cindex @code{l2} function attribute, Blackfin
4086 This attribute specifies a function to be placed into L2
4087 SRAM. The function is put into a specific section named
4088 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4089 an inlined PLT.
4090
4091 @item longcall
4092 @itemx shortcall
4093 @cindex indirect calls, Blackfin
4094 @cindex @code{longcall} function attribute, Blackfin
4095 @cindex @code{shortcall} function attribute, Blackfin
4096 The @code{longcall} attribute
4097 indicates that the function might be far away from the call site and
4098 require a different (more expensive) calling sequence. The
4099 @code{shortcall} attribute indicates that the function is always close
4100 enough for the shorter calling sequence to be used. These attributes
4101 override the @option{-mlongcall} switch.
4102
4103 @item nesting
4104 @cindex @code{nesting} function attribute, Blackfin
4105 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4106 Use this attribute together with @code{interrupt_handler},
4107 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4108 entry code should enable nested interrupts or exceptions.
4109
4110 @item nmi_handler
4111 @cindex @code{nmi_handler} function attribute, Blackfin
4112 @cindex NMI handler functions on the Blackfin processor
4113 Use this attribute on the Blackfin to indicate that the specified function
4114 is an NMI handler. The compiler generates function entry and
4115 exit sequences suitable for use in an NMI handler when this
4116 attribute is present.
4117
4118 @item saveall
4119 @cindex @code{saveall} function attribute, Blackfin
4120 @cindex save all registers on the Blackfin
4121 Use this attribute to indicate that
4122 all registers except the stack pointer should be saved in the prologue
4123 regardless of whether they are used or not.
4124 @end table
4125
4126 @node CR16 Function Attributes
4127 @subsection CR16 Function Attributes
4128
4129 These function attributes are supported by the CR16 back end:
4130
4131 @table @code
4132 @item interrupt
4133 @cindex @code{interrupt} function attribute, CR16
4134 Use this attribute to indicate
4135 that the specified function is an interrupt handler. The compiler generates
4136 function entry and exit sequences suitable for use in an interrupt handler
4137 when this attribute is present.
4138 @end table
4139
4140 @node Epiphany Function Attributes
4141 @subsection Epiphany Function Attributes
4142
4143 These function attributes are supported by the Epiphany back end:
4144
4145 @table @code
4146 @item disinterrupt
4147 @cindex @code{disinterrupt} function attribute, Epiphany
4148 This attribute causes the compiler to emit
4149 instructions to disable interrupts for the duration of the given
4150 function.
4151
4152 @item forwarder_section
4153 @cindex @code{forwarder_section} function attribute, Epiphany
4154 This attribute modifies the behavior of an interrupt handler.
4155 The interrupt handler may be in external memory which cannot be
4156 reached by a branch instruction, so generate a local memory trampoline
4157 to transfer control. The single parameter identifies the section where
4158 the trampoline is placed.
4159
4160 @item interrupt
4161 @cindex @code{interrupt} function attribute, Epiphany
4162 Use this attribute to indicate
4163 that the specified function is an interrupt handler. The compiler generates
4164 function entry and exit sequences suitable for use in an interrupt handler
4165 when this attribute is present. It may also generate
4166 a special section with code to initialize the interrupt vector table.
4167
4168 On Epiphany targets one or more optional parameters can be added like this:
4169
4170 @smallexample
4171 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4172 @end smallexample
4173
4174 Permissible values for these parameters are: @w{@code{reset}},
4175 @w{@code{software_exception}}, @w{@code{page_miss}},
4176 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4177 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4178 Multiple parameters indicate that multiple entries in the interrupt
4179 vector table should be initialized for this function, i.e.@: for each
4180 parameter @w{@var{name}}, a jump to the function is emitted in
4181 the section @w{ivt_entry_@var{name}}. The parameter(s) may be omitted
4182 entirely, in which case no interrupt vector table entry is provided.
4183
4184 Note that interrupts are enabled inside the function
4185 unless the @code{disinterrupt} attribute is also specified.
4186
4187 The following examples are all valid uses of these attributes on
4188 Epiphany targets:
4189 @smallexample
4190 void __attribute__ ((interrupt)) universal_handler ();
4191 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4192 void __attribute__ ((interrupt ("dma0, dma1")))
4193 universal_dma_handler ();
4194 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4195 fast_timer_handler ();
4196 void __attribute__ ((interrupt ("dma0, dma1"),
4197 forwarder_section ("tramp")))
4198 external_dma_handler ();
4199 @end smallexample
4200
4201 @item long_call
4202 @itemx short_call
4203 @cindex @code{long_call} function attribute, Epiphany
4204 @cindex @code{short_call} function attribute, Epiphany
4205 @cindex indirect calls, Epiphany
4206 These attributes specify how a particular function is called.
4207 These attributes override the
4208 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4209 command-line switch and @code{#pragma long_calls} settings.
4210 @end table
4211
4212
4213 @node H8/300 Function Attributes
4214 @subsection H8/300 Function Attributes
4215
4216 These function attributes are available for H8/300 targets:
4217
4218 @table @code
4219 @item function_vector
4220 @cindex @code{function_vector} function attribute, H8/300
4221 Use this attribute on the H8/300, H8/300H, and H8S to indicate
4222 that the specified function should be called through the function vector.
4223 Calling a function through the function vector reduces code size; however,
4224 the function vector has a limited size (maximum 128 entries on the H8/300
4225 and 64 entries on the H8/300H and H8S)
4226 and shares space with the interrupt vector.
4227
4228 @item interrupt_handler
4229 @cindex @code{interrupt_handler} function attribute, H8/300
4230 Use this attribute on the H8/300, H8/300H, and H8S to
4231 indicate that the specified function is an interrupt handler. The compiler
4232 generates function entry and exit sequences suitable for use in an
4233 interrupt handler when this attribute is present.
4234
4235 @item saveall
4236 @cindex @code{saveall} function attribute, H8/300
4237 @cindex save all registers on the H8/300, H8/300H, and H8S
4238 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4239 all registers except the stack pointer should be saved in the prologue
4240 regardless of whether they are used or not.
4241 @end table
4242
4243 @node IA-64 Function Attributes
4244 @subsection IA-64 Function Attributes
4245
4246 These function attributes are supported on IA-64 targets:
4247
4248 @table @code
4249 @item syscall_linkage
4250 @cindex @code{syscall_linkage} function attribute, IA-64
4251 This attribute is used to modify the IA-64 calling convention by marking
4252 all input registers as live at all function exits. This makes it possible
4253 to restart a system call after an interrupt without having to save/restore
4254 the input registers. This also prevents kernel data from leaking into
4255 application code.
4256
4257 @item version_id
4258 @cindex @code{version_id} function attribute, IA-64
4259 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4260 symbol to contain a version string, thus allowing for function level
4261 versioning. HP-UX system header files may use function level versioning
4262 for some system calls.
4263
4264 @smallexample
4265 extern int foo () __attribute__((version_id ("20040821")));
4266 @end smallexample
4267
4268 @noindent
4269 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4270 @end table
4271
4272 @node M32C Function Attributes
4273 @subsection M32C Function Attributes
4274
4275 These function attributes are supported by the M32C back end:
4276
4277 @table @code
4278 @item bank_switch
4279 @cindex @code{bank_switch} function attribute, M32C
4280 When added to an interrupt handler with the M32C port, causes the
4281 prologue and epilogue to use bank switching to preserve the registers
4282 rather than saving them on the stack.
4283
4284 @item fast_interrupt
4285 @cindex @code{fast_interrupt} function attribute, M32C
4286 Use this attribute on the M32C port to indicate that the specified
4287 function is a fast interrupt handler. This is just like the
4288 @code{interrupt} attribute, except that @code{freit} is used to return
4289 instead of @code{reit}.
4290
4291 @item function_vector
4292 @cindex @code{function_vector} function attribute, M16C/M32C
4293 On M16C/M32C targets, the @code{function_vector} attribute declares a
4294 special page subroutine call function. Use of this attribute reduces
4295 the code size by 2 bytes for each call generated to the
4296 subroutine. The argument to the attribute is the vector number entry
4297 from the special page vector table which contains the 16 low-order
4298 bits of the subroutine's entry address. Each vector table has special
4299 page number (18 to 255) that is used in @code{jsrs} instructions.
4300 Jump addresses of the routines are generated by adding 0x0F0000 (in
4301 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4302 2-byte addresses set in the vector table. Therefore you need to ensure
4303 that all the special page vector routines should get mapped within the
4304 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4305 (for M32C).
4306
4307 In the following example 2 bytes are saved for each call to
4308 function @code{foo}.
4309
4310 @smallexample
4311 void foo (void) __attribute__((function_vector(0x18)));
4312 void foo (void)
4313 @{
4314 @}
4315
4316 void bar (void)
4317 @{
4318 foo();
4319 @}
4320 @end smallexample
4321
4322 If functions are defined in one file and are called in another file,
4323 then be sure to write this declaration in both files.
4324
4325 This attribute is ignored for R8C target.
4326
4327 @item interrupt
4328 @cindex @code{interrupt} function attribute, M32C
4329 Use this attribute to indicate
4330 that the specified function is an interrupt handler. The compiler generates
4331 function entry and exit sequences suitable for use in an interrupt handler
4332 when this attribute is present.
4333 @end table
4334
4335 @node M32R/D Function Attributes
4336 @subsection M32R/D Function Attributes
4337
4338 These function attributes are supported by the M32R/D back end:
4339
4340 @table @code
4341 @item interrupt
4342 @cindex @code{interrupt} function attribute, M32R/D
4343 Use this attribute to indicate
4344 that the specified function is an interrupt handler. The compiler generates
4345 function entry and exit sequences suitable for use in an interrupt handler
4346 when this attribute is present.
4347
4348 @item model (@var{model-name})
4349 @cindex @code{model} function attribute, M32R/D
4350 @cindex function addressability on the M32R/D
4351
4352 On the M32R/D, use this attribute to set the addressability of an
4353 object, and of the code generated for a function. The identifier
4354 @var{model-name} is one of @code{small}, @code{medium}, or
4355 @code{large}, representing each of the code models.
4356
4357 Small model objects live in the lower 16MB of memory (so that their
4358 addresses can be loaded with the @code{ld24} instruction), and are
4359 callable with the @code{bl} instruction.
4360
4361 Medium model objects may live anywhere in the 32-bit address space (the
4362 compiler generates @code{seth/add3} instructions to load their addresses),
4363 and are callable with the @code{bl} instruction.
4364
4365 Large model objects may live anywhere in the 32-bit address space (the
4366 compiler generates @code{seth/add3} instructions to load their addresses),
4367 and may not be reachable with the @code{bl} instruction (the compiler
4368 generates the much slower @code{seth/add3/jl} instruction sequence).
4369 @end table
4370
4371 @node m68k Function Attributes
4372 @subsection m68k Function Attributes
4373
4374 These function attributes are supported by the m68k back end:
4375
4376 @table @code
4377 @item interrupt
4378 @itemx interrupt_handler
4379 @cindex @code{interrupt} function attribute, m68k
4380 @cindex @code{interrupt_handler} function attribute, m68k
4381 Use this attribute to
4382 indicate that the specified function is an interrupt handler. The compiler
4383 generates function entry and exit sequences suitable for use in an
4384 interrupt handler when this attribute is present. Either name may be used.
4385
4386 @item interrupt_thread
4387 @cindex @code{interrupt_thread} function attribute, fido
4388 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4389 that the specified function is an interrupt handler that is designed
4390 to run as a thread. The compiler omits generate prologue/epilogue
4391 sequences and replaces the return instruction with a @code{sleep}
4392 instruction. This attribute is available only on fido.
4393 @end table
4394
4395 @node MCORE Function Attributes
4396 @subsection MCORE Function Attributes
4397
4398 These function attributes are supported by the MCORE back end:
4399
4400 @table @code
4401 @item naked
4402 @cindex @code{naked} function attribute, MCORE
4403 This attribute allows the compiler to construct the
4404 requisite function declaration, while allowing the body of the
4405 function to be assembly code. The specified function will not have
4406 prologue/epilogue sequences generated by the compiler. Only basic
4407 @code{asm} statements can safely be included in naked functions
4408 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4409 basic @code{asm} and C code may appear to work, they cannot be
4410 depended upon to work reliably and are not supported.
4411 @end table
4412
4413 @node MeP Function Attributes
4414 @subsection MeP Function Attributes
4415
4416 These function attributes are supported by the MeP back end:
4417
4418 @table @code
4419 @item disinterrupt
4420 @cindex @code{disinterrupt} function attribute, MeP
4421 On MeP targets, this attribute causes the compiler to emit
4422 instructions to disable interrupts for the duration of the given
4423 function.
4424
4425 @item interrupt
4426 @cindex @code{interrupt} function attribute, MeP
4427 Use this attribute to indicate
4428 that the specified function is an interrupt handler. The compiler generates
4429 function entry and exit sequences suitable for use in an interrupt handler
4430 when this attribute is present.
4431
4432 @item near
4433 @cindex @code{near} function attribute, MeP
4434 This attribute causes the compiler to assume the called
4435 function is close enough to use the normal calling convention,
4436 overriding the @option{-mtf} command-line option.
4437
4438 @item far
4439 @cindex @code{far} function attribute, MeP
4440 On MeP targets this causes the compiler to use a calling convention
4441 that assumes the called function is too far away for the built-in
4442 addressing modes.
4443
4444 @item vliw
4445 @cindex @code{vliw} function attribute, MeP
4446 The @code{vliw} attribute tells the compiler to emit
4447 instructions in VLIW mode instead of core mode. Note that this
4448 attribute is not allowed unless a VLIW coprocessor has been configured
4449 and enabled through command-line options.
4450 @end table
4451
4452 @node MicroBlaze Function Attributes
4453 @subsection MicroBlaze Function Attributes
4454
4455 These function attributes are supported on MicroBlaze targets:
4456
4457 @table @code
4458 @item save_volatiles
4459 @cindex @code{save_volatiles} function attribute, MicroBlaze
4460 Use this attribute to indicate that the function is
4461 an interrupt handler. All volatile registers (in addition to non-volatile
4462 registers) are saved in the function prologue. If the function is a leaf
4463 function, only volatiles used by the function are saved. A normal function
4464 return is generated instead of a return from interrupt.
4465
4466 @item break_handler
4467 @cindex @code{break_handler} function attribute, MicroBlaze
4468 @cindex break handler functions
4469 Use this attribute to indicate that
4470 the specified function is a break handler. The compiler generates function
4471 entry and exit sequences suitable for use in an break handler when this
4472 attribute is present. The return from @code{break_handler} is done through
4473 the @code{rtbd} instead of @code{rtsd}.
4474
4475 @smallexample
4476 void f () __attribute__ ((break_handler));
4477 @end smallexample
4478
4479 @item interrupt_handler
4480 @itemx fast_interrupt
4481 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4482 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4483 These attributes indicate that the specified function is an interrupt
4484 handler. Use the @code{fast_interrupt} attribute to indicate handlers
4485 used in low-latency interrupt mode, and @code{interrupt_handler} for
4486 interrupts that do not use low-latency handlers. In both cases, GCC
4487 emits appropriate prologue code and generates a return from the handler
4488 using @code{rtid} instead of @code{rtsd}.
4489 @end table
4490
4491 @node Microsoft Windows Function Attributes
4492 @subsection Microsoft Windows Function Attributes
4493
4494 The following attributes are available on Microsoft Windows and Symbian OS
4495 targets.
4496
4497 @table @code
4498 @item dllexport
4499 @cindex @code{dllexport} function attribute
4500 @cindex @code{__declspec(dllexport)}
4501 On Microsoft Windows targets and Symbian OS targets the
4502 @code{dllexport} attribute causes the compiler to provide a global
4503 pointer to a pointer in a DLL, so that it can be referenced with the
4504 @code{dllimport} attribute. On Microsoft Windows targets, the pointer
4505 name is formed by combining @code{_imp__} and the function or variable
4506 name.
4507
4508 You can use @code{__declspec(dllexport)} as a synonym for
4509 @code{__attribute__ ((dllexport))} for compatibility with other
4510 compilers.
4511
4512 On systems that support the @code{visibility} attribute, this
4513 attribute also implies ``default'' visibility. It is an error to
4514 explicitly specify any other visibility.
4515
4516 GCC's default behavior is to emit all inline functions with the
4517 @code{dllexport} attribute. Since this can cause object file-size bloat,
4518 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4519 ignore the attribute for inlined functions unless the
4520 @option{-fkeep-inline-functions} flag is used instead.
4521
4522 The attribute is ignored for undefined symbols.
4523
4524 When applied to C++ classes, the attribute marks defined non-inlined
4525 member functions and static data members as exports. Static consts
4526 initialized in-class are not marked unless they are also defined
4527 out-of-class.
4528
4529 For Microsoft Windows targets there are alternative methods for
4530 including the symbol in the DLL's export table such as using a
4531 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4532 the @option{--export-all} linker flag.
4533
4534 @item dllimport
4535 @cindex @code{dllimport} function attribute
4536 @cindex @code{__declspec(dllimport)}
4537 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4538 attribute causes the compiler to reference a function or variable via
4539 a global pointer to a pointer that is set up by the DLL exporting the
4540 symbol. The attribute implies @code{extern}. On Microsoft Windows
4541 targets, the pointer name is formed by combining @code{_imp__} and the
4542 function or variable name.
4543
4544 You can use @code{__declspec(dllimport)} as a synonym for
4545 @code{__attribute__ ((dllimport))} for compatibility with other
4546 compilers.
4547
4548 On systems that support the @code{visibility} attribute, this
4549 attribute also implies ``default'' visibility. It is an error to
4550 explicitly specify any other visibility.
4551
4552 Currently, the attribute is ignored for inlined functions. If the
4553 attribute is applied to a symbol @emph{definition}, an error is reported.
4554 If a symbol previously declared @code{dllimport} is later defined, the
4555 attribute is ignored in subsequent references, and a warning is emitted.
4556 The attribute is also overridden by a subsequent declaration as
4557 @code{dllexport}.
4558
4559 When applied to C++ classes, the attribute marks non-inlined
4560 member functions and static data members as imports. However, the
4561 attribute is ignored for virtual methods to allow creation of vtables
4562 using thunks.
4563
4564 On the SH Symbian OS target the @code{dllimport} attribute also has
4565 another affect---it can cause the vtable and run-time type information
4566 for a class to be exported. This happens when the class has a
4567 dllimported constructor or a non-inline, non-pure virtual function
4568 and, for either of those two conditions, the class also has an inline
4569 constructor or destructor and has a key function that is defined in
4570 the current translation unit.
4571
4572 For Microsoft Windows targets the use of the @code{dllimport}
4573 attribute on functions is not necessary, but provides a small
4574 performance benefit by eliminating a thunk in the DLL@. The use of the
4575 @code{dllimport} attribute on imported variables can be avoided by passing the
4576 @option{--enable-auto-import} switch to the GNU linker. As with
4577 functions, using the attribute for a variable eliminates a thunk in
4578 the DLL@.
4579
4580 One drawback to using this attribute is that a pointer to a
4581 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4582 address. However, a pointer to a @emph{function} with the
4583 @code{dllimport} attribute can be used as a constant initializer; in
4584 this case, the address of a stub function in the import lib is
4585 referenced. On Microsoft Windows targets, the attribute can be disabled
4586 for functions by setting the @option{-mnop-fun-dllimport} flag.
4587 @end table
4588
4589 @node MIPS Function Attributes
4590 @subsection MIPS Function Attributes
4591
4592 These function attributes are supported by the MIPS back end:
4593
4594 @table @code
4595 @item interrupt
4596 @cindex @code{interrupt} function attribute, MIPS
4597 Use this attribute to indicate that the specified function is an interrupt
4598 handler. The compiler generates function entry and exit sequences suitable
4599 for use in an interrupt handler when this attribute is present.
4600 An optional argument is supported for the interrupt attribute which allows
4601 the interrupt mode to be described. By default GCC assumes the external
4602 interrupt controller (EIC) mode is in use, this can be explicitly set using
4603 @code{eic}. When interrupts are non-masked then the requested Interrupt
4604 Priority Level (IPL) is copied to the current IPL which has the effect of only
4605 enabling higher priority interrupts. To use vectored interrupt mode use
4606 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4607 the behavior of the non-masked interrupt support and GCC will arrange to mask
4608 all interrupts from sw0 up to and including the specified interrupt vector.
4609
4610 You can use the following attributes to modify the behavior
4611 of an interrupt handler:
4612 @table @code
4613 @item use_shadow_register_set
4614 @cindex @code{use_shadow_register_set} function attribute, MIPS
4615 Assume that the handler uses a shadow register set, instead of
4616 the main general-purpose registers. An optional argument @code{intstack} is
4617 supported to indicate that the shadow register set contains a valid stack
4618 pointer.
4619
4620 @item keep_interrupts_masked
4621 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4622 Keep interrupts masked for the whole function. Without this attribute,
4623 GCC tries to reenable interrupts for as much of the function as it can.
4624
4625 @item use_debug_exception_return
4626 @cindex @code{use_debug_exception_return} function attribute, MIPS
4627 Return using the @code{deret} instruction. Interrupt handlers that don't
4628 have this attribute return using @code{eret} instead.
4629 @end table
4630
4631 You can use any combination of these attributes, as shown below:
4632 @smallexample
4633 void __attribute__ ((interrupt)) v0 ();
4634 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4635 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4636 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4637 void __attribute__ ((interrupt, use_shadow_register_set,
4638 keep_interrupts_masked)) v4 ();
4639 void __attribute__ ((interrupt, use_shadow_register_set,
4640 use_debug_exception_return)) v5 ();
4641 void __attribute__ ((interrupt, keep_interrupts_masked,
4642 use_debug_exception_return)) v6 ();
4643 void __attribute__ ((interrupt, use_shadow_register_set,
4644 keep_interrupts_masked,
4645 use_debug_exception_return)) v7 ();
4646 void __attribute__ ((interrupt("eic"))) v8 ();
4647 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4648 @end smallexample
4649
4650 @item long_call
4651 @itemx short_call
4652 @itemx near
4653 @itemx far
4654 @cindex indirect calls, MIPS
4655 @cindex @code{long_call} function attribute, MIPS
4656 @cindex @code{short_call} function attribute, MIPS
4657 @cindex @code{near} function attribute, MIPS
4658 @cindex @code{far} function attribute, MIPS
4659 These attributes specify how a particular function is called on MIPS@.
4660 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4661 command-line switch. The @code{long_call} and @code{far} attributes are
4662 synonyms, and cause the compiler to always call
4663 the function by first loading its address into a register, and then using
4664 the contents of that register. The @code{short_call} and @code{near}
4665 attributes are synonyms, and have the opposite
4666 effect; they specify that non-PIC calls should be made using the more
4667 efficient @code{jal} instruction.
4668
4669 @item mips16
4670 @itemx nomips16
4671 @cindex @code{mips16} function attribute, MIPS
4672 @cindex @code{nomips16} function attribute, MIPS
4673
4674 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4675 function attributes to locally select or turn off MIPS16 code generation.
4676 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4677 while MIPS16 code generation is disabled for functions with the
4678 @code{nomips16} attribute. These attributes override the
4679 @option{-mips16} and @option{-mno-mips16} options on the command line
4680 (@pxref{MIPS Options}).
4681
4682 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4683 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4684 not that within individual functions. Mixed MIPS16 and non-MIPS16 code
4685 may interact badly with some GCC extensions such as @code{__builtin_apply}
4686 (@pxref{Constructing Calls}).
4687
4688 @item micromips, MIPS
4689 @itemx nomicromips, MIPS
4690 @cindex @code{micromips} function attribute
4691 @cindex @code{nomicromips} function attribute
4692
4693 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4694 function attributes to locally select or turn off microMIPS code generation.
4695 A function with the @code{micromips} attribute is emitted as microMIPS code,
4696 while microMIPS code generation is disabled for functions with the
4697 @code{nomicromips} attribute. These attributes override the
4698 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4699 (@pxref{MIPS Options}).
4700
4701 When compiling files containing mixed microMIPS and non-microMIPS code, the
4702 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4703 command line,
4704 not that within individual functions. Mixed microMIPS and non-microMIPS code
4705 may interact badly with some GCC extensions such as @code{__builtin_apply}
4706 (@pxref{Constructing Calls}).
4707
4708 @item nocompression
4709 @cindex @code{nocompression} function attribute, MIPS
4710 On MIPS targets, you can use the @code{nocompression} function attribute
4711 to locally turn off MIPS16 and microMIPS code generation. This attribute
4712 overrides the @option{-mips16} and @option{-mmicromips} options on the
4713 command line (@pxref{MIPS Options}).
4714 @end table
4715
4716 @node MSP430 Function Attributes
4717 @subsection MSP430 Function Attributes
4718
4719 These function attributes are supported by the MSP430 back end:
4720
4721 @table @code
4722 @item critical
4723 @cindex @code{critical} function attribute, MSP430
4724 Critical functions disable interrupts upon entry and restore the
4725 previous interrupt state upon exit. Critical functions cannot also
4726 have the @code{naked} or @code{reentrant} attributes. They can have
4727 the @code{interrupt} attribute.
4728
4729 @item interrupt
4730 @cindex @code{interrupt} function attribute, MSP430
4731 Use this attribute to indicate
4732 that the specified function is an interrupt handler. The compiler generates
4733 function entry and exit sequences suitable for use in an interrupt handler
4734 when this attribute is present.
4735
4736 You can provide an argument to the interrupt
4737 attribute which specifies a name or number. If the argument is a
4738 number it indicates the slot in the interrupt vector table (0 - 31) to
4739 which this handler should be assigned. If the argument is a name it
4740 is treated as a symbolic name for the vector slot. These names should
4741 match up with appropriate entries in the linker script. By default
4742 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4743 @code{reset} for vector 31 are recognized.
4744
4745 @item naked
4746 @cindex @code{naked} function attribute, MSP430
4747 This attribute allows the compiler to construct the
4748 requisite function declaration, while allowing the body of the
4749 function to be assembly code. The specified function will not have
4750 prologue/epilogue sequences generated by the compiler. Only basic
4751 @code{asm} statements can safely be included in naked functions
4752 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4753 basic @code{asm} and C code may appear to work, they cannot be
4754 depended upon to work reliably and are not supported.
4755
4756 @item reentrant
4757 @cindex @code{reentrant} function attribute, MSP430
4758 Reentrant functions disable interrupts upon entry and enable them
4759 upon exit. Reentrant functions cannot also have the @code{naked}
4760 or @code{critical} attributes. They can have the @code{interrupt}
4761 attribute.
4762
4763 @item wakeup
4764 @cindex @code{wakeup} function attribute, MSP430
4765 This attribute only applies to interrupt functions. It is silently
4766 ignored if applied to a non-interrupt function. A wakeup interrupt
4767 function will rouse the processor from any low-power state that it
4768 might be in when the function exits.
4769
4770 @item lower
4771 @itemx upper
4772 @itemx either
4773 @cindex @code{lower} function attribute, MSP430
4774 @cindex @code{upper} function attribute, MSP430
4775 @cindex @code{either} function attribute, MSP430
4776 On the MSP430 target these attributes can be used to specify whether
4777 the function or variable should be placed into low memory, high
4778 memory, or the placement should be left to the linker to decide. The
4779 attributes are only significant if compiling for the MSP430X
4780 architecture.
4781
4782 The attributes work in conjunction with a linker script that has been
4783 augmented to specify where to place sections with a @code{.lower} and
4784 a @code{.upper} prefix. So, for example, as well as placing the
4785 @code{.data} section, the script also specifies the placement of a
4786 @code{.lower.data} and a @code{.upper.data} section. The intention
4787 is that @code{lower} sections are placed into a small but easier to
4788 access memory region and the upper sections are placed into a larger, but
4789 slower to access, region.
4790
4791 The @code{either} attribute is special. It tells the linker to place
4792 the object into the corresponding @code{lower} section if there is
4793 room for it. If there is insufficient room then the object is placed
4794 into the corresponding @code{upper} section instead. Note that the
4795 placement algorithm is not very sophisticated. It does not attempt to
4796 find an optimal packing of the @code{lower} sections. It just makes
4797 one pass over the objects and does the best that it can. Using the
4798 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4799 options can help the packing, however, since they produce smaller,
4800 easier to pack regions.
4801 @end table
4802
4803 @node NDS32 Function Attributes
4804 @subsection NDS32 Function Attributes
4805
4806 These function attributes are supported by the NDS32 back end:
4807
4808 @table @code
4809 @item exception
4810 @cindex @code{exception} function attribute
4811 @cindex exception handler functions, NDS32
4812 Use this attribute on the NDS32 target to indicate that the specified function
4813 is an exception handler. The compiler will generate corresponding sections
4814 for use in an exception handler.
4815
4816 @item interrupt
4817 @cindex @code{interrupt} function attribute, NDS32
4818 On NDS32 target, this attribute indicates that the specified function
4819 is an interrupt handler. The compiler generates corresponding sections
4820 for use in an interrupt handler. You can use the following attributes
4821 to modify the behavior:
4822 @table @code
4823 @item nested
4824 @cindex @code{nested} function attribute, NDS32
4825 This interrupt service routine is interruptible.
4826 @item not_nested
4827 @cindex @code{not_nested} function attribute, NDS32
4828 This interrupt service routine is not interruptible.
4829 @item nested_ready
4830 @cindex @code{nested_ready} function attribute, NDS32
4831 This interrupt service routine is interruptible after @code{PSW.GIE}
4832 (global interrupt enable) is set. This allows interrupt service routine to
4833 finish some short critical code before enabling interrupts.
4834 @item save_all
4835 @cindex @code{save_all} function attribute, NDS32
4836 The system will help save all registers into stack before entering
4837 interrupt handler.
4838 @item partial_save
4839 @cindex @code{partial_save} function attribute, NDS32
4840 The system will help save caller registers into stack before entering
4841 interrupt handler.
4842 @end table
4843
4844 @item naked
4845 @cindex @code{naked} function attribute, NDS32
4846 This attribute allows the compiler to construct the
4847 requisite function declaration, while allowing the body of the
4848 function to be assembly code. The specified function will not have
4849 prologue/epilogue sequences generated by the compiler. Only basic
4850 @code{asm} statements can safely be included in naked functions
4851 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4852 basic @code{asm} and C code may appear to work, they cannot be
4853 depended upon to work reliably and are not supported.
4854
4855 @item reset
4856 @cindex @code{reset} function attribute, NDS32
4857 @cindex reset handler functions
4858 Use this attribute on the NDS32 target to indicate that the specified function
4859 is a reset handler. The compiler will generate corresponding sections
4860 for use in a reset handler. You can use the following attributes
4861 to provide extra exception handling:
4862 @table @code
4863 @item nmi
4864 @cindex @code{nmi} function attribute, NDS32
4865 Provide a user-defined function to handle NMI exception.
4866 @item warm
4867 @cindex @code{warm} function attribute, NDS32
4868 Provide a user-defined function to handle warm reset exception.
4869 @end table
4870 @end table
4871
4872 @node Nios II Function Attributes
4873 @subsection Nios II Function Attributes
4874
4875 These function attributes are supported by the Nios II back end:
4876
4877 @table @code
4878 @item target (@var{options})
4879 @cindex @code{target} function attribute
4880 As discussed in @ref{Common Function Attributes}, this attribute
4881 allows specification of target-specific compilation options.
4882
4883 When compiling for Nios II, the following options are allowed:
4884
4885 @table @samp
4886 @item custom-@var{insn}=@var{N}
4887 @itemx no-custom-@var{insn}
4888 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4889 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4890 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4891 custom instruction with encoding @var{N} when generating code that uses
4892 @var{insn}. Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4893 the custom instruction @var{insn}.
4894 These target attributes correspond to the
4895 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4896 command-line options, and support the same set of @var{insn} keywords.
4897 @xref{Nios II Options}, for more information.
4898
4899 @item custom-fpu-cfg=@var{name}
4900 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4901 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4902 command-line option, to select a predefined set of custom instructions
4903 named @var{name}.
4904 @xref{Nios II Options}, for more information.
4905 @end table
4906 @end table
4907
4908 @node Nvidia PTX Function Attributes
4909 @subsection Nvidia PTX Function Attributes
4910
4911 These function attributes are supported by the Nvidia PTX back end:
4912
4913 @table @code
4914 @item kernel
4915 @cindex @code{kernel} attribute, Nvidia PTX
4916 This attribute indicates that the corresponding function should be compiled
4917 as a kernel function, which can be invoked from the host via the CUDA RT
4918 library.
4919 By default functions are only callable only from other PTX functions.
4920
4921 Kernel functions must have @code{void} return type.
4922 @end table
4923
4924 @node PowerPC Function Attributes
4925 @subsection PowerPC Function Attributes
4926
4927 These function attributes are supported by the PowerPC back end:
4928
4929 @table @code
4930 @item longcall
4931 @itemx shortcall
4932 @cindex indirect calls, PowerPC
4933 @cindex @code{longcall} function attribute, PowerPC
4934 @cindex @code{shortcall} function attribute, PowerPC
4935 The @code{longcall} attribute
4936 indicates that the function might be far away from the call site and
4937 require a different (more expensive) calling sequence. The
4938 @code{shortcall} attribute indicates that the function is always close
4939 enough for the shorter calling sequence to be used. These attributes
4940 override both the @option{-mlongcall} switch and
4941 the @code{#pragma longcall} setting.
4942
4943 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4944 calls are necessary.
4945
4946 @item target (@var{options})
4947 @cindex @code{target} function attribute
4948 As discussed in @ref{Common Function Attributes}, this attribute
4949 allows specification of target-specific compilation options.
4950
4951 On the PowerPC, the following options are allowed:
4952
4953 @table @samp
4954 @item altivec
4955 @itemx no-altivec
4956 @cindex @code{target("altivec")} function attribute, PowerPC
4957 Generate code that uses (does not use) AltiVec instructions. In
4958 32-bit code, you cannot enable AltiVec instructions unless
4959 @option{-mabi=altivec} is used on the command line.
4960
4961 @item cmpb
4962 @itemx no-cmpb
4963 @cindex @code{target("cmpb")} function attribute, PowerPC
4964 Generate code that uses (does not use) the compare bytes instruction
4965 implemented on the POWER6 processor and other processors that support
4966 the PowerPC V2.05 architecture.
4967
4968 @item dlmzb
4969 @itemx no-dlmzb
4970 @cindex @code{target("dlmzb")} function attribute, PowerPC
4971 Generate code that uses (does not use) the string-search @samp{dlmzb}
4972 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
4973 generated by default when targeting those processors.
4974
4975 @item fprnd
4976 @itemx no-fprnd
4977 @cindex @code{target("fprnd")} function attribute, PowerPC
4978 Generate code that uses (does not use) the FP round to integer
4979 instructions implemented on the POWER5+ processor and other processors
4980 that support the PowerPC V2.03 architecture.
4981
4982 @item hard-dfp
4983 @itemx no-hard-dfp
4984 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4985 Generate code that uses (does not use) the decimal floating-point
4986 instructions implemented on some POWER processors.
4987
4988 @item isel
4989 @itemx no-isel
4990 @cindex @code{target("isel")} function attribute, PowerPC
4991 Generate code that uses (does not use) ISEL instruction.
4992
4993 @item mfcrf
4994 @itemx no-mfcrf
4995 @cindex @code{target("mfcrf")} function attribute, PowerPC
4996 Generate code that uses (does not use) the move from condition
4997 register field instruction implemented on the POWER4 processor and
4998 other processors that support the PowerPC V2.01 architecture.
4999
5000 @item mfpgpr
5001 @itemx no-mfpgpr
5002 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5003 Generate code that uses (does not use) the FP move to/from general
5004 purpose register instructions implemented on the POWER6X processor and
5005 other processors that support the extended PowerPC V2.05 architecture.
5006
5007 @item mulhw
5008 @itemx no-mulhw
5009 @cindex @code{target("mulhw")} function attribute, PowerPC
5010 Generate code that uses (does not use) the half-word multiply and
5011 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5012 These instructions are generated by default when targeting those
5013 processors.
5014
5015 @item multiple
5016 @itemx no-multiple
5017 @cindex @code{target("multiple")} function attribute, PowerPC
5018 Generate code that uses (does not use) the load multiple word
5019 instructions and the store multiple word instructions.
5020
5021 @item update
5022 @itemx no-update
5023 @cindex @code{target("update")} function attribute, PowerPC
5024 Generate code that uses (does not use) the load or store instructions
5025 that update the base register to the address of the calculated memory
5026 location.
5027
5028 @item popcntb
5029 @itemx no-popcntb
5030 @cindex @code{target("popcntb")} function attribute, PowerPC
5031 Generate code that uses (does not use) the popcount and double-precision
5032 FP reciprocal estimate instruction implemented on the POWER5
5033 processor and other processors that support the PowerPC V2.02
5034 architecture.
5035
5036 @item popcntd
5037 @itemx no-popcntd
5038 @cindex @code{target("popcntd")} function attribute, PowerPC
5039 Generate code that uses (does not use) the popcount instruction
5040 implemented on the POWER7 processor and other processors that support
5041 the PowerPC V2.06 architecture.
5042
5043 @item powerpc-gfxopt
5044 @itemx no-powerpc-gfxopt
5045 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5046 Generate code that uses (does not use) the optional PowerPC
5047 architecture instructions in the Graphics group, including
5048 floating-point select.
5049
5050 @item powerpc-gpopt
5051 @itemx no-powerpc-gpopt
5052 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5053 Generate code that uses (does not use) the optional PowerPC
5054 architecture instructions in the General Purpose group, including
5055 floating-point square root.
5056
5057 @item recip-precision
5058 @itemx no-recip-precision
5059 @cindex @code{target("recip-precision")} function attribute, PowerPC
5060 Assume (do not assume) that the reciprocal estimate instructions
5061 provide higher-precision estimates than is mandated by the PowerPC
5062 ABI.
5063
5064 @item string
5065 @itemx no-string
5066 @cindex @code{target("string")} function attribute, PowerPC
5067 Generate code that uses (does not use) the load string instructions
5068 and the store string word instructions to save multiple registers and
5069 do small block moves.
5070
5071 @item vsx
5072 @itemx no-vsx
5073 @cindex @code{target("vsx")} function attribute, PowerPC
5074 Generate code that uses (does not use) vector/scalar (VSX)
5075 instructions, and also enable the use of built-in functions that allow
5076 more direct access to the VSX instruction set. In 32-bit code, you
5077 cannot enable VSX or AltiVec instructions unless
5078 @option{-mabi=altivec} is used on the command line.
5079
5080 @item friz
5081 @itemx no-friz
5082 @cindex @code{target("friz")} function attribute, PowerPC
5083 Generate (do not generate) the @code{friz} instruction when the
5084 @option{-funsafe-math-optimizations} option is used to optimize
5085 rounding a floating-point value to 64-bit integer and back to floating
5086 point. The @code{friz} instruction does not return the same value if
5087 the floating-point number is too large to fit in an integer.
5088
5089 @item avoid-indexed-addresses
5090 @itemx no-avoid-indexed-addresses
5091 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5092 Generate code that tries to avoid (not avoid) the use of indexed load
5093 or store instructions.
5094
5095 @item paired
5096 @itemx no-paired
5097 @cindex @code{target("paired")} function attribute, PowerPC
5098 Generate code that uses (does not use) the generation of PAIRED simd
5099 instructions.
5100
5101 @item longcall
5102 @itemx no-longcall
5103 @cindex @code{target("longcall")} function attribute, PowerPC
5104 Generate code that assumes (does not assume) that all calls are far
5105 away so that a longer more expensive calling sequence is required.
5106
5107 @item cpu=@var{CPU}
5108 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5109 Specify the architecture to generate code for when compiling the
5110 function. If you select the @code{target("cpu=power7")} attribute when
5111 generating 32-bit code, VSX and AltiVec instructions are not generated
5112 unless you use the @option{-mabi=altivec} option on the command line.
5113
5114 @item tune=@var{TUNE}
5115 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5116 Specify the architecture to tune for when compiling the function. If
5117 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5118 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5119 compilation tunes for the @var{CPU} architecture, and not the
5120 default tuning specified on the command line.
5121 @end table
5122
5123 On the PowerPC, the inliner does not inline a
5124 function that has different target options than the caller, unless the
5125 callee has a subset of the target options of the caller.
5126 @end table
5127
5128 @node RISC-V Function Attributes
5129 @subsection RISC-V Function Attributes
5130
5131 These function attributes are supported by the RISC-V back end:
5132
5133 @table @code
5134 @item naked
5135 @cindex @code{naked} function attribute, RISC-V
5136 This attribute allows the compiler to construct the
5137 requisite function declaration, while allowing the body of the
5138 function to be assembly code. The specified function will not have
5139 prologue/epilogue sequences generated by the compiler. Only basic
5140 @code{asm} statements can safely be included in naked functions
5141 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5142 basic @code{asm} and C code may appear to work, they cannot be
5143 depended upon to work reliably and are not supported.
5144
5145 @item interrupt
5146 @cindex @code{interrupt} function attribute, RISC-V
5147 Use this attribute to indicate that the specified function is an interrupt
5148 handler. The compiler generates function entry and exit sequences suitable
5149 for use in an interrupt handler when this attribute is present.
5150
5151 You can specify the kind of interrupt to be handled by adding an optional
5152 parameter to the interrupt attribute like this:
5153
5154 @smallexample
5155 void f (void) __attribute__ ((interrupt ("user")));
5156 @end smallexample
5157
5158 Permissible values for this parameter are @code{user}, @code{supervisor},
5159 and @code{machine}. If there is no parameter, then it defaults to
5160 @code{machine}.
5161 @end table
5162
5163 @node RL78 Function Attributes
5164 @subsection RL78 Function Attributes
5165
5166 These function attributes are supported by the RL78 back end:
5167
5168 @table @code
5169 @item interrupt
5170 @itemx brk_interrupt
5171 @cindex @code{interrupt} function attribute, RL78
5172 @cindex @code{brk_interrupt} function attribute, RL78
5173 These attributes indicate
5174 that the specified function is an interrupt handler. The compiler generates
5175 function entry and exit sequences suitable for use in an interrupt handler
5176 when this attribute is present.
5177
5178 Use @code{brk_interrupt} instead of @code{interrupt} for
5179 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5180 that must end with @code{RETB} instead of @code{RETI}).
5181
5182 @item naked
5183 @cindex @code{naked} function attribute, RL78
5184 This attribute allows the compiler to construct the
5185 requisite function declaration, while allowing the body of the
5186 function to be assembly code. The specified function will not have
5187 prologue/epilogue sequences generated by the compiler. Only basic
5188 @code{asm} statements can safely be included in naked functions
5189 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5190 basic @code{asm} and C code may appear to work, they cannot be
5191 depended upon to work reliably and are not supported.
5192 @end table
5193
5194 @node RX Function Attributes
5195 @subsection RX Function Attributes
5196
5197 These function attributes are supported by the RX back end:
5198
5199 @table @code
5200 @item fast_interrupt
5201 @cindex @code{fast_interrupt} function attribute, RX
5202 Use this attribute on the RX port to indicate that the specified
5203 function is a fast interrupt handler. This is just like the
5204 @code{interrupt} attribute, except that @code{freit} is used to return
5205 instead of @code{reit}.
5206
5207 @item interrupt
5208 @cindex @code{interrupt} function attribute, RX
5209 Use this attribute to indicate
5210 that the specified function is an interrupt handler. The compiler generates
5211 function entry and exit sequences suitable for use in an interrupt handler
5212 when this attribute is present.
5213
5214 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5215 to the attribute, as well as naming an alternate table name.
5216 Parameters are handled sequentially, so one handler can be assigned to
5217 multiple entries in multiple tables. One may also pass the magic
5218 string @code{"$default"} which causes the function to be used for any
5219 unfilled slots in the current table.
5220
5221 This example shows a simple assignment of a function to one vector in
5222 the default table (note that preprocessor macros may be used for
5223 chip-specific symbolic vector names):
5224 @smallexample
5225 void __attribute__ ((interrupt (5))) txd1_handler ();
5226 @end smallexample
5227
5228 This example assigns a function to two slots in the default table
5229 (using preprocessor macros defined elsewhere) and makes it the default
5230 for the @code{dct} table:
5231 @smallexample
5232 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5233 txd1_handler ();
5234 @end smallexample
5235
5236 @item naked
5237 @cindex @code{naked} function attribute, RX
5238 This attribute allows the compiler to construct the
5239 requisite function declaration, while allowing the body of the
5240 function to be assembly code. The specified function will not have
5241 prologue/epilogue sequences generated by the compiler. Only basic
5242 @code{asm} statements can safely be included in naked functions
5243 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5244 basic @code{asm} and C code may appear to work, they cannot be
5245 depended upon to work reliably and are not supported.
5246
5247 @item vector
5248 @cindex @code{vector} function attribute, RX
5249 This RX attribute is similar to the @code{interrupt} attribute, including its
5250 parameters, but does not make the function an interrupt-handler type
5251 function (i.e. it retains the normal C function calling ABI). See the
5252 @code{interrupt} attribute for a description of its arguments.
5253 @end table
5254
5255 @node S/390 Function Attributes
5256 @subsection S/390 Function Attributes
5257
5258 These function attributes are supported on the S/390:
5259
5260 @table @code
5261 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5262 @cindex @code{hotpatch} function attribute, S/390
5263
5264 On S/390 System z targets, you can use this function attribute to
5265 make GCC generate a ``hot-patching'' function prologue. If the
5266 @option{-mhotpatch=} command-line option is used at the same time,
5267 the @code{hotpatch} attribute takes precedence. The first of the
5268 two arguments specifies the number of halfwords to be added before
5269 the function label. A second argument can be used to specify the
5270 number of halfwords to be added after the function label. For
5271 both arguments the maximum allowed value is 1000000.
5272
5273 If both arguments are zero, hotpatching is disabled.
5274
5275 @item target (@var{options})
5276 @cindex @code{target} function attribute
5277 As discussed in @ref{Common Function Attributes}, this attribute
5278 allows specification of target-specific compilation options.
5279
5280 On S/390, the following options are supported:
5281
5282 @table @samp
5283 @item arch=
5284 @item tune=
5285 @item stack-guard=
5286 @item stack-size=
5287 @item branch-cost=
5288 @item warn-framesize=
5289 @item backchain
5290 @itemx no-backchain
5291 @item hard-dfp
5292 @itemx no-hard-dfp
5293 @item hard-float
5294 @itemx soft-float
5295 @item htm
5296 @itemx no-htm
5297 @item vx
5298 @itemx no-vx
5299 @item packed-stack
5300 @itemx no-packed-stack
5301 @item small-exec
5302 @itemx no-small-exec
5303 @item mvcle
5304 @itemx no-mvcle
5305 @item warn-dynamicstack
5306 @itemx no-warn-dynamicstack
5307 @end table
5308
5309 The options work exactly like the S/390 specific command line
5310 options (without the prefix @option{-m}) except that they do not
5311 change any feature macros. For example,
5312
5313 @smallexample
5314 @code{target("no-vx")}
5315 @end smallexample
5316
5317 does not undefine the @code{__VEC__} macro.
5318 @end table
5319
5320 @node SH Function Attributes
5321 @subsection SH Function Attributes
5322
5323 These function attributes are supported on the SH family of processors:
5324
5325 @table @code
5326 @item function_vector
5327 @cindex @code{function_vector} function attribute, SH
5328 @cindex calling functions through the function vector on SH2A
5329 On SH2A targets, this attribute declares a function to be called using the
5330 TBR relative addressing mode. The argument to this attribute is the entry
5331 number of the same function in a vector table containing all the TBR
5332 relative addressable functions. For correct operation the TBR must be setup
5333 accordingly to point to the start of the vector table before any functions with
5334 this attribute are invoked. Usually a good place to do the initialization is
5335 the startup routine. The TBR relative vector table can have at max 256 function
5336 entries. The jumps to these functions are generated using a SH2A specific,
5337 non delayed branch instruction JSR/N @@(disp8,TBR). You must use GAS and GLD
5338 from GNU binutils version 2.7 or later for this attribute to work correctly.
5339
5340 In an application, for a function being called once, this attribute
5341 saves at least 8 bytes of code; and if other successive calls are being
5342 made to the same function, it saves 2 bytes of code per each of these
5343 calls.
5344
5345 @item interrupt_handler
5346 @cindex @code{interrupt_handler} function attribute, SH
5347 Use this attribute to
5348 indicate that the specified function is an interrupt handler. The compiler
5349 generates function entry and exit sequences suitable for use in an
5350 interrupt handler when this attribute is present.
5351
5352 @item nosave_low_regs
5353 @cindex @code{nosave_low_regs} function attribute, SH
5354 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5355 function should not save and restore registers R0..R7. This can be used on SH3*
5356 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5357 interrupt handlers.
5358
5359 @item renesas
5360 @cindex @code{renesas} function attribute, SH
5361 On SH targets this attribute specifies that the function or struct follows the
5362 Renesas ABI.
5363
5364 @item resbank
5365 @cindex @code{resbank} function attribute, SH
5366 On the SH2A target, this attribute enables the high-speed register
5367 saving and restoration using a register bank for @code{interrupt_handler}
5368 routines. Saving to the bank is performed automatically after the CPU
5369 accepts an interrupt that uses a register bank.
5370
5371 The nineteen 32-bit registers comprising general register R0 to R14,
5372 control register GBR, and system registers MACH, MACL, and PR and the
5373 vector table address offset are saved into a register bank. Register
5374 banks are stacked in first-in last-out (FILO) sequence. Restoration
5375 from the bank is executed by issuing a RESBANK instruction.
5376
5377 @item sp_switch
5378 @cindex @code{sp_switch} function attribute, SH
5379 Use this attribute on the SH to indicate an @code{interrupt_handler}
5380 function should switch to an alternate stack. It expects a string
5381 argument that names a global variable holding the address of the
5382 alternate stack.
5383
5384 @smallexample
5385 void *alt_stack;
5386 void f () __attribute__ ((interrupt_handler,
5387 sp_switch ("alt_stack")));
5388 @end smallexample
5389
5390 @item trap_exit
5391 @cindex @code{trap_exit} function attribute, SH
5392 Use this attribute on the SH for an @code{interrupt_handler} to return using
5393 @code{trapa} instead of @code{rte}. This attribute expects an integer
5394 argument specifying the trap number to be used.
5395
5396 @item trapa_handler
5397 @cindex @code{trapa_handler} function attribute, SH
5398 On SH targets this function attribute is similar to @code{interrupt_handler}
5399 but it does not save and restore all registers.
5400 @end table
5401
5402 @node SPU Function Attributes
5403 @subsection SPU Function Attributes
5404
5405 These function attributes are supported by the SPU back end:
5406
5407 @table @code
5408 @item naked
5409 @cindex @code{naked} function attribute, SPU
5410 This attribute allows the compiler to construct the
5411 requisite function declaration, while allowing the body of the
5412 function to be assembly code. The specified function will not have
5413 prologue/epilogue sequences generated by the compiler. Only basic
5414 @code{asm} statements can safely be included in naked functions
5415 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5416 basic @code{asm} and C code may appear to work, they cannot be
5417 depended upon to work reliably and are not supported.
5418 @end table
5419
5420 @node Symbian OS Function Attributes
5421 @subsection Symbian OS Function Attributes
5422
5423 @xref{Microsoft Windows Function Attributes}, for discussion of the
5424 @code{dllexport} and @code{dllimport} attributes.
5425
5426 @node V850 Function Attributes
5427 @subsection V850 Function Attributes
5428
5429 The V850 back end supports these function attributes:
5430
5431 @table @code
5432 @item interrupt
5433 @itemx interrupt_handler
5434 @cindex @code{interrupt} function attribute, V850
5435 @cindex @code{interrupt_handler} function attribute, V850
5436 Use these attributes 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 either attribute is present.
5440 @end table
5441
5442 @node Visium Function Attributes
5443 @subsection Visium Function Attributes
5444
5445 These function attributes are supported by the Visium back end:
5446
5447 @table @code
5448 @item interrupt
5449 @cindex @code{interrupt} function attribute, Visium
5450 Use this attribute to indicate
5451 that the specified function is an interrupt handler. The compiler generates
5452 function entry and exit sequences suitable for use in an interrupt handler
5453 when this attribute is present.
5454 @end table
5455
5456 @node x86 Function Attributes
5457 @subsection x86 Function Attributes
5458
5459 These function attributes are supported by the x86 back end:
5460
5461 @table @code
5462 @item cdecl
5463 @cindex @code{cdecl} function attribute, x86-32
5464 @cindex functions that pop the argument stack on x86-32
5465 @opindex mrtd
5466 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5467 assume that the calling function pops off the stack space used to
5468 pass arguments. This is
5469 useful to override the effects of the @option{-mrtd} switch.
5470
5471 @item fastcall
5472 @cindex @code{fastcall} function attribute, x86-32
5473 @cindex functions that pop the argument stack on x86-32
5474 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5475 pass the first argument (if of integral type) in the register ECX and
5476 the second argument (if of integral type) in the register EDX@. Subsequent
5477 and other typed arguments are passed on the stack. The called function
5478 pops the arguments off the stack. If the number of arguments is variable all
5479 arguments are pushed on the stack.
5480
5481 @item thiscall
5482 @cindex @code{thiscall} function attribute, x86-32
5483 @cindex functions that pop the argument stack on x86-32
5484 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5485 pass the first argument (if of integral type) in the register ECX.
5486 Subsequent and other typed arguments are passed on the stack. The called
5487 function pops the arguments off the stack.
5488 If the number of arguments is variable all arguments are pushed on the
5489 stack.
5490 The @code{thiscall} attribute is intended for C++ non-static member functions.
5491 As a GCC extension, this calling convention can be used for C functions
5492 and for static member methods.
5493
5494 @item ms_abi
5495 @itemx sysv_abi
5496 @cindex @code{ms_abi} function attribute, x86
5497 @cindex @code{sysv_abi} function attribute, x86
5498
5499 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5500 to indicate which calling convention should be used for a function. The
5501 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5502 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5503 used on GNU/Linux and other systems. The default is to use the Microsoft ABI
5504 when targeting Windows. On all other systems, the default is the x86/AMD ABI.
5505
5506 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5507 requires the @option{-maccumulate-outgoing-args} option.
5508
5509 @item callee_pop_aggregate_return (@var{number})
5510 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5511
5512 On x86-32 targets, you can use this attribute to control how
5513 aggregates are returned in memory. If the caller is responsible for
5514 popping the hidden pointer together with the rest of the arguments, specify
5515 @var{number} equal to zero. If callee is responsible for popping the
5516 hidden pointer, specify @var{number} equal to one.
5517
5518 The default x86-32 ABI assumes that the callee pops the
5519 stack for hidden pointer. However, on x86-32 Microsoft Windows targets,
5520 the compiler assumes that the
5521 caller pops the stack for hidden pointer.
5522
5523 @item ms_hook_prologue
5524 @cindex @code{ms_hook_prologue} function attribute, x86
5525
5526 On 32-bit and 64-bit x86 targets, you can use
5527 this function attribute to make GCC generate the ``hot-patching'' function
5528 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5529 and newer.
5530
5531 @item naked
5532 @cindex @code{naked} function attribute, x86
5533 This attribute allows the compiler to construct the
5534 requisite function declaration, while allowing the body of the
5535 function to be assembly code. The specified function will not have
5536 prologue/epilogue sequences generated by the compiler. Only basic
5537 @code{asm} statements can safely be included in naked functions
5538 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5539 basic @code{asm} and C code may appear to work, they cannot be
5540 depended upon to work reliably and are not supported.
5541
5542 @item regparm (@var{number})
5543 @cindex @code{regparm} function attribute, x86
5544 @cindex functions that are passed arguments in registers on x86-32
5545 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5546 pass arguments number one to @var{number} if they are of integral type
5547 in registers EAX, EDX, and ECX instead of on the stack. Functions that
5548 take a variable number of arguments continue to be passed all of their
5549 arguments on the stack.
5550
5551 Beware that on some ELF systems this attribute is unsuitable for
5552 global functions in shared libraries with lazy binding (which is the
5553 default). Lazy binding sends the first call via resolving code in
5554 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5555 per the standard calling conventions. Solaris 8 is affected by this.
5556 Systems with the GNU C Library version 2.1 or higher
5557 and FreeBSD are believed to be
5558 safe since the loaders there save EAX, EDX and ECX. (Lazy binding can be
5559 disabled with the linker or the loader if desired, to avoid the
5560 problem.)
5561
5562 @item sseregparm
5563 @cindex @code{sseregparm} function attribute, x86
5564 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5565 causes the compiler to pass up to 3 floating-point arguments in
5566 SSE registers instead of on the stack. Functions that take a
5567 variable number of arguments continue to pass all of their
5568 floating-point arguments on the stack.
5569
5570 @item force_align_arg_pointer
5571 @cindex @code{force_align_arg_pointer} function attribute, x86
5572 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5573 applied to individual function definitions, generating an alternate
5574 prologue and epilogue that realigns the run-time stack if necessary.
5575 This supports mixing legacy codes that run with a 4-byte aligned stack
5576 with modern codes that keep a 16-byte stack for SSE compatibility.
5577
5578 @item stdcall
5579 @cindex @code{stdcall} function attribute, x86-32
5580 @cindex functions that pop the argument stack on x86-32
5581 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5582 assume that the called function pops off the stack space used to
5583 pass arguments, unless it takes a variable number of arguments.
5584
5585 @item no_caller_saved_registers
5586 @cindex @code{no_caller_saved_registers} function attribute, x86
5587 Use this attribute to indicate that the specified function has no
5588 caller-saved registers. That is, all registers are callee-saved. For
5589 example, this attribute can be used for a function called from an
5590 interrupt handler. The compiler generates proper function entry and
5591 exit sequences to save and restore any modified registers, except for
5592 the EFLAGS register. Since GCC doesn't preserve MPX, SSE, MMX nor x87
5593 states, the GCC option @option{-mgeneral-regs-only} should be used to
5594 compile functions with @code{no_caller_saved_registers} attribute.
5595
5596 @item interrupt
5597 @cindex @code{interrupt} function attribute, x86
5598 Use this attribute to indicate that the specified function is an
5599 interrupt handler or an exception handler (depending on parameters passed
5600 to the function, explained further). The compiler generates function
5601 entry and exit sequences suitable for use in an interrupt handler when
5602 this attribute is present. The @code{IRET} instruction, instead of the
5603 @code{RET} instruction, is used to return from interrupt handlers. All
5604 registers, except for the EFLAGS register which is restored by the
5605 @code{IRET} instruction, are preserved by the compiler. Since GCC
5606 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5607 @option{-mgeneral-regs-only} should be used to compile interrupt and
5608 exception handlers.
5609
5610 Any interruptible-without-stack-switch code must be compiled with
5611 @option{-mno-red-zone} since interrupt handlers can and will, because
5612 of the hardware design, touch the red zone.
5613
5614 An interrupt handler must be declared with a mandatory pointer
5615 argument:
5616
5617 @smallexample
5618 struct interrupt_frame;
5619
5620 __attribute__ ((interrupt))
5621 void
5622 f (struct interrupt_frame *frame)
5623 @{
5624 @}
5625 @end smallexample
5626
5627 @noindent
5628 and you must define @code{struct interrupt_frame} as described in the
5629 processor's manual.
5630
5631 Exception handlers differ from interrupt handlers because the system
5632 pushes an error code on the stack. An exception handler declaration is
5633 similar to that for an interrupt handler, but with a different mandatory
5634 function signature. The compiler arranges to pop the error code off the
5635 stack before the @code{IRET} instruction.
5636
5637 @smallexample
5638 #ifdef __x86_64__
5639 typedef unsigned long long int uword_t;
5640 #else
5641 typedef unsigned int uword_t;
5642 #endif
5643
5644 struct interrupt_frame;
5645
5646 __attribute__ ((interrupt))
5647 void
5648 f (struct interrupt_frame *frame, uword_t error_code)
5649 @{
5650 ...
5651 @}
5652 @end smallexample
5653
5654 Exception handlers should only be used for exceptions that push an error
5655 code; you should use an interrupt handler in other cases. The system
5656 will crash if the wrong kind of handler is used.
5657
5658 @item target (@var{options})
5659 @cindex @code{target} function attribute
5660 As discussed in @ref{Common Function Attributes}, this attribute
5661 allows specification of target-specific compilation options.
5662
5663 On the x86, the following options are allowed:
5664 @table @samp
5665 @item abm
5666 @itemx no-abm
5667 @cindex @code{target("abm")} function attribute, x86
5668 Enable/disable the generation of the advanced bit instructions.
5669
5670 @item aes
5671 @itemx no-aes
5672 @cindex @code{target("aes")} function attribute, x86
5673 Enable/disable the generation of the AES instructions.
5674
5675 @item default
5676 @cindex @code{target("default")} function attribute, x86
5677 @xref{Function Multiversioning}, where it is used to specify the
5678 default function version.
5679
5680 @item mmx
5681 @itemx no-mmx
5682 @cindex @code{target("mmx")} function attribute, x86
5683 Enable/disable the generation of the MMX instructions.
5684
5685 @item pclmul
5686 @itemx no-pclmul
5687 @cindex @code{target("pclmul")} function attribute, x86
5688 Enable/disable the generation of the PCLMUL instructions.
5689
5690 @item popcnt
5691 @itemx no-popcnt
5692 @cindex @code{target("popcnt")} function attribute, x86
5693 Enable/disable the generation of the POPCNT instruction.
5694
5695 @item sse
5696 @itemx no-sse
5697 @cindex @code{target("sse")} function attribute, x86
5698 Enable/disable the generation of the SSE instructions.
5699
5700 @item sse2
5701 @itemx no-sse2
5702 @cindex @code{target("sse2")} function attribute, x86
5703 Enable/disable the generation of the SSE2 instructions.
5704
5705 @item sse3
5706 @itemx no-sse3
5707 @cindex @code{target("sse3")} function attribute, x86
5708 Enable/disable the generation of the SSE3 instructions.
5709
5710 @item sse4
5711 @itemx no-sse4
5712 @cindex @code{target("sse4")} function attribute, x86
5713 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5714 and SSE4.2).
5715
5716 @item sse4.1
5717 @itemx no-sse4.1
5718 @cindex @code{target("sse4.1")} function attribute, x86
5719 Enable/disable the generation of the sse4.1 instructions.
5720
5721 @item sse4.2
5722 @itemx no-sse4.2
5723 @cindex @code{target("sse4.2")} function attribute, x86
5724 Enable/disable the generation of the sse4.2 instructions.
5725
5726 @item sse4a
5727 @itemx no-sse4a
5728 @cindex @code{target("sse4a")} function attribute, x86
5729 Enable/disable the generation of the SSE4A instructions.
5730
5731 @item fma4
5732 @itemx no-fma4
5733 @cindex @code{target("fma4")} function attribute, x86
5734 Enable/disable the generation of the FMA4 instructions.
5735
5736 @item xop
5737 @itemx no-xop
5738 @cindex @code{target("xop")} function attribute, x86
5739 Enable/disable the generation of the XOP instructions.
5740
5741 @item lwp
5742 @itemx no-lwp
5743 @cindex @code{target("lwp")} function attribute, x86
5744 Enable/disable the generation of the LWP instructions.
5745
5746 @item ssse3
5747 @itemx no-ssse3
5748 @cindex @code{target("ssse3")} function attribute, x86
5749 Enable/disable the generation of the SSSE3 instructions.
5750
5751 @item cld
5752 @itemx no-cld
5753 @cindex @code{target("cld")} function attribute, x86
5754 Enable/disable the generation of the CLD before string moves.
5755
5756 @item fancy-math-387
5757 @itemx no-fancy-math-387
5758 @cindex @code{target("fancy-math-387")} function attribute, x86
5759 Enable/disable the generation of the @code{sin}, @code{cos}, and
5760 @code{sqrt} instructions on the 387 floating-point unit.
5761
5762 @item ieee-fp
5763 @itemx no-ieee-fp
5764 @cindex @code{target("ieee-fp")} function attribute, x86
5765 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5766
5767 @item inline-all-stringops
5768 @itemx no-inline-all-stringops
5769 @cindex @code{target("inline-all-stringops")} function attribute, x86
5770 Enable/disable inlining of string operations.
5771
5772 @item inline-stringops-dynamically
5773 @itemx no-inline-stringops-dynamically
5774 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5775 Enable/disable the generation of the inline code to do small string
5776 operations and calling the library routines for large operations.
5777
5778 @item align-stringops
5779 @itemx no-align-stringops
5780 @cindex @code{target("align-stringops")} function attribute, x86
5781 Do/do not align destination of inlined string operations.
5782
5783 @item recip
5784 @itemx no-recip
5785 @cindex @code{target("recip")} function attribute, x86
5786 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5787 instructions followed an additional Newton-Raphson step instead of
5788 doing a floating-point division.
5789
5790 @item arch=@var{ARCH}
5791 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5792 Specify the architecture to generate code for in compiling the function.
5793
5794 @item tune=@var{TUNE}
5795 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5796 Specify the architecture to tune for in compiling the function.
5797
5798 @item fpmath=@var{FPMATH}
5799 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5800 Specify which floating-point unit to use. You must specify the
5801 @code{target("fpmath=sse,387")} option as
5802 @code{target("fpmath=sse+387")} because the comma would separate
5803 different options.
5804
5805 @item indirect_branch("@var{choice}")
5806 @cindex @code{indirect_branch} function attribute, x86
5807 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5808 to convert indirect call and jump with @var{choice}. @samp{keep}
5809 keeps indirect call and jump unmodified. @samp{thunk} converts indirect
5810 call and jump to call and return thunk. @samp{thunk-inline} converts
5811 indirect call and jump to inlined call and return thunk.
5812 @samp{thunk-extern} converts indirect call and jump to external call
5813 and return thunk provided in a separate object file.
5814
5815 @item function_return("@var{choice}")
5816 @cindex @code{function_return} function attribute, x86
5817 On x86 targets, the @code{function_return} attribute causes the compiler
5818 to convert function return with @var{choice}. @samp{keep} keeps function
5819 return unmodified. @samp{thunk} converts function return to call and
5820 return thunk. @samp{thunk-inline} converts function return to inlined
5821 call and return thunk. @samp{thunk-extern} converts function return to
5822 external call and return thunk provided in a separate object file.
5823
5824 @item nocf_check
5825 @cindex @code{nocf_check} function attribute
5826 The @code{nocf_check} attribute on a function is used to inform the
5827 compiler that the function's prologue should not be instrumented when
5828 compiled with the @option{-fcf-protection=branch} option. The
5829 compiler assumes that the function's address is a valid target for a
5830 control-flow transfer.
5831
5832 The @code{nocf_check} attribute on a type of pointer to function is
5833 used to inform the compiler that a call through the pointer should
5834 not be instrumented when compiled with the
5835 @option{-fcf-protection=branch} option. The compiler assumes
5836 that the function's address from the pointer is a valid target for
5837 a control-flow transfer. A direct function call through a function
5838 name is assumed to be a safe call thus direct calls are not
5839 instrumented by the compiler.
5840
5841 The @code{nocf_check} attribute is applied to an object's type.
5842 In case of assignment of a function address or a function pointer to
5843 another pointer, the attribute is not carried over from the right-hand
5844 object's type; the type of left-hand object stays unchanged. The
5845 compiler checks for @code{nocf_check} attribute mismatch and reports
5846 a warning in case of mismatch.
5847
5848 @smallexample
5849 @{
5850 int foo (void) __attribute__(nocf_check);
5851 void (*foo1)(void) __attribute__(nocf_check);
5852 void (*foo2)(void);
5853
5854 /* foo's address is assumed to be valid. */
5855 int
5856 foo (void)
5857
5858 /* This call site is not checked for control-flow
5859 validity. */
5860 (*foo1)();
5861
5862 /* A warning is issued about attribute mismatch. */
5863 foo1 = foo2;
5864
5865 /* This call site is still not checked. */
5866 (*foo1)();
5867
5868 /* This call site is checked. */
5869 (*foo2)();
5870
5871 /* A warning is issued about attribute mismatch. */
5872 foo2 = foo1;
5873
5874 /* This call site is still checked. */
5875 (*foo2)();
5876
5877 return 0;
5878 @}
5879 @end smallexample
5880
5881 @end table
5882
5883 On the x86, the inliner does not inline a
5884 function that has different target options than the caller, unless the
5885 callee has a subset of the target options of the caller. For example
5886 a function declared with @code{target("sse3")} can inline a function
5887 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5888 @end table
5889
5890 @node Xstormy16 Function Attributes
5891 @subsection Xstormy16 Function Attributes
5892
5893 These function attributes are supported by the Xstormy16 back end:
5894
5895 @table @code
5896 @item interrupt
5897 @cindex @code{interrupt} function attribute, Xstormy16
5898 Use this attribute to indicate
5899 that the specified function is an interrupt handler. The compiler generates
5900 function entry and exit sequences suitable for use in an interrupt handler
5901 when this attribute is present.
5902 @end table
5903
5904 @node Variable Attributes
5905 @section Specifying Attributes of Variables
5906 @cindex attribute of variables
5907 @cindex variable attributes
5908
5909 The keyword @code{__attribute__} allows you to specify special
5910 attributes of variables or structure fields. This keyword is followed
5911 by an attribute specification inside double parentheses. Some
5912 attributes are currently defined generically for variables.
5913 Other attributes are defined for variables on particular target
5914 systems. Other attributes are available for functions
5915 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5916 enumerators (@pxref{Enumerator Attributes}), statements
5917 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5918 Other front ends might define more attributes
5919 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5920
5921 @xref{Attribute Syntax}, for details of the exact syntax for using
5922 attributes.
5923
5924 @menu
5925 * Common Variable Attributes::
5926 * ARC Variable Attributes::
5927 * AVR Variable Attributes::
5928 * Blackfin Variable Attributes::
5929 * H8/300 Variable Attributes::
5930 * IA-64 Variable Attributes::
5931 * M32R/D Variable Attributes::
5932 * MeP Variable Attributes::
5933 * Microsoft Windows Variable Attributes::
5934 * MSP430 Variable Attributes::
5935 * Nvidia PTX Variable Attributes::
5936 * PowerPC Variable Attributes::
5937 * RL78 Variable Attributes::
5938 * SPU Variable Attributes::
5939 * V850 Variable Attributes::
5940 * x86 Variable Attributes::
5941 * Xstormy16 Variable Attributes::
5942 @end menu
5943
5944 @node Common Variable Attributes
5945 @subsection Common Variable Attributes
5946
5947 The following attributes are supported on most targets.
5948
5949 @table @code
5950 @cindex @code{aligned} variable attribute
5951 @item aligned (@var{alignment})
5952 This attribute specifies a minimum alignment for the variable or
5953 structure field, measured in bytes. For example, the declaration:
5954
5955 @smallexample
5956 int x __attribute__ ((aligned (16))) = 0;
5957 @end smallexample
5958
5959 @noindent
5960 causes the compiler to allocate the global variable @code{x} on a
5961 16-byte boundary. On a 68040, this could be used in conjunction with
5962 an @code{asm} expression to access the @code{move16} instruction which
5963 requires 16-byte aligned operands.
5964
5965 You can also specify the alignment of structure fields. For example, to
5966 create a double-word aligned @code{int} pair, you could write:
5967
5968 @smallexample
5969 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5970 @end smallexample
5971
5972 @noindent
5973 This is an alternative to creating a union with a @code{double} member,
5974 which forces the union to be double-word aligned.
5975
5976 As in the preceding examples, you can explicitly specify the alignment
5977 (in bytes) that you wish the compiler to use for a given variable or
5978 structure field. Alternatively, you can leave out the alignment factor
5979 and just ask the compiler to align a variable or field to the
5980 default alignment for the target architecture you are compiling for.
5981 The default alignment is sufficient for all scalar types, but may not be
5982 enough for all vector types on a target that supports vector operations.
5983 The default alignment is fixed for a particular target ABI.
5984
5985 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5986 which is the largest alignment ever used for any data type on the
5987 target machine you are compiling for. For example, you could write:
5988
5989 @smallexample
5990 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5991 @end smallexample
5992
5993 The compiler automatically sets the alignment for the declared
5994 variable or field to @code{__BIGGEST_ALIGNMENT__}. Doing this can
5995 often make copy operations more efficient, because the compiler can
5996 use whatever instructions copy the biggest chunks of memory when
5997 performing copies to or from the variables or fields that you have
5998 aligned this way. Note that the value of @code{__BIGGEST_ALIGNMENT__}
5999 may change depending on command-line options.
6000
6001 When used on a struct, or struct member, the @code{aligned} attribute can
6002 only increase the alignment; in order to decrease it, the @code{packed}
6003 attribute must be specified as well. When used as part of a typedef, the
6004 @code{aligned} attribute can both increase and decrease alignment, and
6005 specifying the @code{packed} attribute generates a warning.
6006
6007 Note that the effectiveness of @code{aligned} attributes may be limited
6008 by inherent limitations in your linker. On many systems, the linker is
6009 only able to arrange for variables to be aligned up to a certain maximum
6010 alignment. (For some linkers, the maximum supported alignment may
6011 be very very small.) If your linker is only able to align variables
6012 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6013 in an @code{__attribute__} still only provides you with 8-byte
6014 alignment. See your linker documentation for further information.
6015
6016 The @code{aligned} attribute can also be used for functions
6017 (@pxref{Common Function Attributes}.)
6018
6019 @cindex @code{warn_if_not_aligned} variable attribute
6020 @item warn_if_not_aligned (@var{alignment})
6021 This attribute specifies a threshold for the structure field, measured
6022 in bytes. If the structure field is aligned below the threshold, a
6023 warning will be issued. For example, the declaration:
6024
6025 @smallexample
6026 struct foo
6027 @{
6028 int i1;
6029 int i2;
6030 unsigned long long x __attribute__((warn_if_not_aligned(16)));
6031 @};
6032 @end smallexample
6033
6034 @noindent
6035 causes the compiler to issue an warning on @code{struct foo}, like
6036 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6037 The compiler also issues a warning, like @samp{warning: 'x' offset
6038 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6039 the misaligned offset:
6040
6041 @smallexample
6042 struct foo
6043 @{
6044 int i1;
6045 int i2;
6046 unsigned long long x __attribute__((warn_if_not_aligned(16)));
6047 @} __attribute__((aligned(16)));
6048 @end smallexample
6049
6050 This warning can be disabled by @option{-Wno-if-not-aligned}.
6051 The @code{warn_if_not_aligned} attribute can also be used for types
6052 (@pxref{Common Type Attributes}.)
6053
6054 @item cleanup (@var{cleanup_function})
6055 @cindex @code{cleanup} variable attribute
6056 The @code{cleanup} attribute runs a function when the variable goes
6057 out of scope. This attribute can only be applied to auto function
6058 scope variables; it may not be applied to parameters or variables
6059 with static storage duration. The function must take one parameter,
6060 a pointer to a type compatible with the variable. The return value
6061 of the function (if any) is ignored.
6062
6063 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6064 is run during the stack unwinding that happens during the
6065 processing of the exception. Note that the @code{cleanup} attribute
6066 does not allow the exception to be caught, only to perform an action.
6067 It is undefined what happens if @var{cleanup_function} does not
6068 return normally.
6069
6070 @item common
6071 @itemx nocommon
6072 @cindex @code{common} variable attribute
6073 @cindex @code{nocommon} variable attribute
6074 @opindex fcommon
6075 @opindex fno-common
6076 The @code{common} attribute requests GCC to place a variable in
6077 ``common'' storage. The @code{nocommon} attribute requests the
6078 opposite---to allocate space for it directly.
6079
6080 These attributes override the default chosen by the
6081 @option{-fno-common} and @option{-fcommon} flags respectively.
6082
6083 @item deprecated
6084 @itemx deprecated (@var{msg})
6085 @cindex @code{deprecated} variable attribute
6086 The @code{deprecated} attribute results in a warning if the variable
6087 is used anywhere in the source file. This is useful when identifying
6088 variables that are expected to be removed in a future version of a
6089 program. The warning also includes the location of the declaration
6090 of the deprecated variable, to enable users to easily find further
6091 information about why the variable is deprecated, or what they should
6092 do instead. Note that the warning only occurs for uses:
6093
6094 @smallexample
6095 extern int old_var __attribute__ ((deprecated));
6096 extern int old_var;
6097 int new_fn () @{ return old_var; @}
6098 @end smallexample
6099
6100 @noindent
6101 results in a warning on line 3 but not line 2. The optional @var{msg}
6102 argument, which must be a string, is printed in the warning if
6103 present.
6104
6105 The @code{deprecated} attribute can also be used for functions and
6106 types (@pxref{Common Function Attributes},
6107 @pxref{Common Type Attributes}).
6108
6109 @item nonstring
6110 @cindex @code{nonstring} variable attribute
6111 The @code{nonstring} variable attribute specifies that an object or member
6112 declaration with type array of @code{char}, @code{signed char}, or
6113 @code{unsigned char}, or pointer to such a type is intended to store
6114 character arrays that do not necessarily contain a terminating @code{NUL}.
6115 This is useful in detecting uses of such arrays or pointers with functions
6116 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6117 an array or pointer is used as an argument to a bounded string manipulation
6118 function such as @code{strncpy}. For example, without the attribute, GCC
6119 will issue a warning for the @code{strncpy} call below because it may
6120 truncate the copy without appending the terminating @code{NUL} character.
6121 Using the attribute makes it possible to suppress the warning. However,
6122 when the array is declared with the attribute the call to @code{strlen} is
6123 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6124 string the call is undefined. To copy, compare, of search non-string
6125 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6126 and other functions that operate on arrays of bytes. In addition,
6127 calling @code{strnlen} and @code{strndup} with such arrays is safe
6128 provided a suitable bound is specified, and not diagnosed.
6129
6130 @smallexample
6131 struct Data
6132 @{
6133 char name [32] __attribute__ ((nonstring));
6134 @};
6135
6136 int f (struct Data *pd, const char *s)
6137 @{
6138 strncpy (pd->name, s, sizeof pd->name);
6139 @dots{}
6140 return strlen (pd->name); // unsafe, gets a warning
6141 @}
6142 @end smallexample
6143
6144 @item mode (@var{mode})
6145 @cindex @code{mode} variable attribute
6146 This attribute specifies the data type for the declaration---whichever
6147 type corresponds to the mode @var{mode}. This in effect lets you
6148 request an integer or floating-point type according to its width.
6149
6150 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6151 for a list of the possible keywords for @var{mode}.
6152 You may also specify a mode of @code{byte} or @code{__byte__} to
6153 indicate the mode corresponding to a one-byte integer, @code{word} or
6154 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6155 or @code{__pointer__} for the mode used to represent pointers.
6156
6157 @item packed
6158 @cindex @code{packed} variable attribute
6159 The @code{packed} attribute specifies that a variable or structure field
6160 should have the smallest possible alignment---one byte for a variable,
6161 and one bit for a field, unless you specify a larger value with the
6162 @code{aligned} attribute.
6163
6164 Here is a structure in which the field @code{x} is packed, so that it
6165 immediately follows @code{a}:
6166
6167 @smallexample
6168 struct foo
6169 @{
6170 char a;
6171 int x[2] __attribute__ ((packed));
6172 @};
6173 @end smallexample
6174
6175 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6176 @code{packed} attribute on bit-fields of type @code{char}. This has
6177 been fixed in GCC 4.4 but the change can lead to differences in the
6178 structure layout. See the documentation of
6179 @option{-Wpacked-bitfield-compat} for more information.
6180
6181 @item section ("@var{section-name}")
6182 @cindex @code{section} variable attribute
6183 Normally, the compiler places the objects it generates in sections like
6184 @code{data} and @code{bss}. Sometimes, however, you need additional sections,
6185 or you need certain particular variables to appear in special sections,
6186 for example to map to special hardware. The @code{section}
6187 attribute specifies that a variable (or function) lives in a particular
6188 section. For example, this small program uses several specific section names:
6189
6190 @smallexample
6191 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6192 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6193 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6194 int init_data __attribute__ ((section ("INITDATA")));
6195
6196 main()
6197 @{
6198 /* @r{Initialize stack pointer} */
6199 init_sp (stack + sizeof (stack));
6200
6201 /* @r{Initialize initialized data} */
6202 memcpy (&init_data, &data, &edata - &data);
6203
6204 /* @r{Turn on the serial ports} */
6205 init_duart (&a);
6206 init_duart (&b);
6207 @}
6208 @end smallexample
6209
6210 @noindent
6211 Use the @code{section} attribute with
6212 @emph{global} variables and not @emph{local} variables,
6213 as shown in the example.
6214
6215 You may use the @code{section} attribute with initialized or
6216 uninitialized global variables but the linker requires
6217 each object be defined once, with the exception that uninitialized
6218 variables tentatively go in the @code{common} (or @code{bss}) section
6219 and can be multiply ``defined''. Using the @code{section} attribute
6220 changes what section the variable goes into and may cause the
6221 linker to issue an error if an uninitialized variable has multiple
6222 definitions. You can force a variable to be initialized with the
6223 @option{-fno-common} flag or the @code{nocommon} attribute.
6224
6225 Some file formats do not support arbitrary sections so the @code{section}
6226 attribute is not available on all platforms.
6227 If you need to map the entire contents of a module to a particular
6228 section, consider using the facilities of the linker instead.
6229
6230 @item tls_model ("@var{tls_model}")
6231 @cindex @code{tls_model} variable attribute
6232 The @code{tls_model} attribute sets thread-local storage model
6233 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6234 overriding @option{-ftls-model=} command-line switch on a per-variable
6235 basis.
6236 The @var{tls_model} argument should be one of @code{global-dynamic},
6237 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6238
6239 Not all targets support this attribute.
6240
6241 @item unused
6242 @cindex @code{unused} variable attribute
6243 This attribute, attached to a variable, means that the variable is meant
6244 to be possibly unused. GCC does not produce a warning for this
6245 variable.
6246
6247 @item used
6248 @cindex @code{used} variable attribute
6249 This attribute, attached to a variable with static storage, means that
6250 the variable must be emitted even if it appears that the variable is not
6251 referenced.
6252
6253 When applied to a static data member of a C++ class template, the
6254 attribute also means that the member is instantiated if the
6255 class itself is instantiated.
6256
6257 @item vector_size (@var{bytes})
6258 @cindex @code{vector_size} variable attribute
6259 This attribute specifies the vector size for the variable, measured in
6260 bytes. For example, the declaration:
6261
6262 @smallexample
6263 int foo __attribute__ ((vector_size (16)));
6264 @end smallexample
6265
6266 @noindent
6267 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6268 divided into @code{int} sized units. Assuming a 32-bit int (a vector of
6269 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6270
6271 This attribute is only applicable to integral and float scalars,
6272 although arrays, pointers, and function return values are allowed in
6273 conjunction with this construct.
6274
6275 Aggregates with this attribute are invalid, even if they are of the same
6276 size as a corresponding scalar. For example, the declaration:
6277
6278 @smallexample
6279 struct S @{ int a; @};
6280 struct S __attribute__ ((vector_size (16))) foo;
6281 @end smallexample
6282
6283 @noindent
6284 is invalid even if the size of the structure is the same as the size of
6285 the @code{int}.
6286
6287 @item visibility ("@var{visibility_type}")
6288 @cindex @code{visibility} variable attribute
6289 This attribute affects the linkage of the declaration to which it is attached.
6290 The @code{visibility} attribute is described in
6291 @ref{Common Function Attributes}.
6292
6293 @item weak
6294 @cindex @code{weak} variable attribute
6295 The @code{weak} attribute is described in
6296 @ref{Common Function Attributes}.
6297
6298 @end table
6299
6300 @node ARC Variable Attributes
6301 @subsection ARC Variable Attributes
6302
6303 @table @code
6304 @item aux
6305 @cindex @code{aux} variable attribute, ARC
6306 The @code{aux} attribute is used to directly access the ARC's
6307 auxiliary register space from C. The auxilirary register number is
6308 given via attribute argument.
6309
6310 @end table
6311
6312 @node AVR Variable Attributes
6313 @subsection AVR Variable Attributes
6314
6315 @table @code
6316 @item progmem
6317 @cindex @code{progmem} variable attribute, AVR
6318 The @code{progmem} attribute is used on the AVR to place read-only
6319 data in the non-volatile program memory (flash). The @code{progmem}
6320 attribute accomplishes this by putting respective variables into a
6321 section whose name starts with @code{.progmem}.
6322
6323 This attribute works similar to the @code{section} attribute
6324 but adds additional checking.
6325
6326 @table @asis
6327 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6328 @code{progmem} affects the location
6329 of the data but not how this data is accessed.
6330 In order to read data located with the @code{progmem} attribute
6331 (inline) assembler must be used.
6332 @smallexample
6333 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6334 #include <avr/pgmspace.h>
6335
6336 /* Locate var in flash memory */
6337 const int var[2] PROGMEM = @{ 1, 2 @};
6338
6339 int read_var (int i)
6340 @{
6341 /* Access var[] by accessor macro from avr/pgmspace.h */
6342 return (int) pgm_read_word (& var[i]);
6343 @}
6344 @end smallexample
6345
6346 AVR is a Harvard architecture processor and data and read-only data
6347 normally resides in the data memory (RAM).
6348
6349 See also the @ref{AVR Named Address Spaces} section for
6350 an alternate way to locate and access data in flash memory.
6351
6352 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6353 On such devices, there is no need for attribute @code{progmem} or
6354 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6355 Just use standard C / C++. The compiler will generate @code{LD*}
6356 instructions. As flash memory is visible in the RAM address range,
6357 and the default linker script does @emph{not} locate @code{.rodata} in
6358 RAM, no special features are needed in order not to waste RAM for
6359 read-only data or to read from flash. You might even get slightly better
6360 performance by
6361 avoiding @code{progmem} and @code{__flash}. This applies to devices from
6362 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6363 an overview.
6364
6365 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6366 The compiler adds @code{0x4000}
6367 to the addresses of objects and declarations in @code{progmem} and locates
6368 the objects in flash memory, namely in section @code{.progmem.data}.
6369 The offset is needed because the flash memory is visible in the RAM
6370 address space starting at address @code{0x4000}.
6371
6372 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6373 no special functions or macros are needed.
6374
6375 @smallexample
6376 /* var is located in flash memory */
6377 extern const int var[2] __attribute__((progmem));
6378
6379 int read_var (int i)
6380 @{
6381 return var[i];
6382 @}
6383 @end smallexample
6384
6385 Please notice that on these devices, there is no need for @code{progmem}
6386 at all.
6387
6388 @end table
6389
6390 @item io
6391 @itemx io (@var{addr})
6392 @cindex @code{io} variable attribute, AVR
6393 Variables with the @code{io} attribute are used to address
6394 memory-mapped peripherals in the io address range.
6395 If an address is specified, the variable
6396 is assigned that address, and the value is interpreted as an
6397 address in the data address space.
6398 Example:
6399
6400 @smallexample
6401 volatile int porta __attribute__((io (0x22)));
6402 @end smallexample
6403
6404 The address specified in the address in the data address range.
6405
6406 Otherwise, the variable it is not assigned an address, but the
6407 compiler will still use in/out instructions where applicable,
6408 assuming some other module assigns an address in the io address range.
6409 Example:
6410
6411 @smallexample
6412 extern volatile int porta __attribute__((io));
6413 @end smallexample
6414
6415 @item io_low
6416 @itemx io_low (@var{addr})
6417 @cindex @code{io_low} variable attribute, AVR
6418 This is like the @code{io} attribute, but additionally it informs the
6419 compiler that the object lies in the lower half of the I/O area,
6420 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6421 instructions.
6422
6423 @item address
6424 @itemx address (@var{addr})
6425 @cindex @code{address} variable attribute, AVR
6426 Variables with the @code{address} attribute are used to address
6427 memory-mapped peripherals that may lie outside the io address range.
6428
6429 @smallexample
6430 volatile int porta __attribute__((address (0x600)));
6431 @end smallexample
6432
6433 @item absdata
6434 @cindex @code{absdata} variable attribute, AVR
6435 Variables in static storage and with the @code{absdata} attribute can
6436 be accessed by the @code{LDS} and @code{STS} instructions which take
6437 absolute addresses.
6438
6439 @itemize @bullet
6440 @item
6441 This attribute is only supported for the reduced AVR Tiny core
6442 like ATtiny40.
6443
6444 @item
6445 You must make sure that respective data is located in the
6446 address range @code{0x40}@dots{}@code{0xbf} accessible by
6447 @code{LDS} and @code{STS}. One way to achieve this as an
6448 appropriate linker description file.
6449
6450 @item
6451 If the location does not fit the address range of @code{LDS}
6452 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6453 warning like
6454 @quotation
6455 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6456 @end quotation
6457
6458 @end itemize
6459
6460 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6461
6462 @end table
6463
6464 @node Blackfin Variable Attributes
6465 @subsection Blackfin Variable Attributes
6466
6467 Three attributes are currently defined for the Blackfin.
6468
6469 @table @code
6470 @item l1_data
6471 @itemx l1_data_A
6472 @itemx l1_data_B
6473 @cindex @code{l1_data} variable attribute, Blackfin
6474 @cindex @code{l1_data_A} variable attribute, Blackfin
6475 @cindex @code{l1_data_B} variable attribute, Blackfin
6476 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6477 Variables with @code{l1_data} attribute are put into the specific section
6478 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6479 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6480 attribute are put into the specific section named @code{.l1.data.B}.
6481
6482 @item l2
6483 @cindex @code{l2} variable attribute, Blackfin
6484 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6485 Variables with @code{l2} attribute are put into the specific section
6486 named @code{.l2.data}.
6487 @end table
6488
6489 @node H8/300 Variable Attributes
6490 @subsection H8/300 Variable Attributes
6491
6492 These variable attributes are available for H8/300 targets:
6493
6494 @table @code
6495 @item eightbit_data
6496 @cindex @code{eightbit_data} variable attribute, H8/300
6497 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6498 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6499 variable should be placed into the eight-bit data section.
6500 The compiler generates more efficient code for certain operations
6501 on data in the eight-bit data area. Note the eight-bit data area is limited to
6502 256 bytes of data.
6503
6504 You must use GAS and GLD from GNU binutils version 2.7 or later for
6505 this attribute to work correctly.
6506
6507 @item tiny_data
6508 @cindex @code{tiny_data} variable attribute, H8/300
6509 @cindex tiny data section on the H8/300H and H8S
6510 Use this attribute on the H8/300H and H8S to indicate that the specified
6511 variable should be placed into the tiny data section.
6512 The compiler generates more efficient code for loads and stores
6513 on data in the tiny data section. Note the tiny data area is limited to
6514 slightly under 32KB of data.
6515
6516 @end table
6517
6518 @node IA-64 Variable Attributes
6519 @subsection IA-64 Variable Attributes
6520
6521 The IA-64 back end supports the following variable attribute:
6522
6523 @table @code
6524 @item model (@var{model-name})
6525 @cindex @code{model} variable attribute, IA-64
6526
6527 On IA-64, use this attribute to set the addressability of an object.
6528 At present, the only supported identifier for @var{model-name} is
6529 @code{small}, indicating addressability via ``small'' (22-bit)
6530 addresses (so that their addresses can be loaded with the @code{addl}
6531 instruction). Caveat: such addressing is by definition not position
6532 independent and hence this attribute must not be used for objects
6533 defined by shared libraries.
6534
6535 @end table
6536
6537 @node M32R/D Variable Attributes
6538 @subsection M32R/D Variable Attributes
6539
6540 One attribute is currently defined for the M32R/D@.
6541
6542 @table @code
6543 @item model (@var{model-name})
6544 @cindex @code{model-name} variable attribute, M32R/D
6545 @cindex variable addressability on the M32R/D
6546 Use this attribute on the M32R/D to set the addressability of an object.
6547 The identifier @var{model-name} is one of @code{small}, @code{medium},
6548 or @code{large}, representing each of the code models.
6549
6550 Small model objects live in the lower 16MB of memory (so that their
6551 addresses can be loaded with the @code{ld24} instruction).
6552
6553 Medium and large model objects may live anywhere in the 32-bit address space
6554 (the compiler generates @code{seth/add3} instructions to load their
6555 addresses).
6556 @end table
6557
6558 @node MeP Variable Attributes
6559 @subsection MeP Variable Attributes
6560
6561 The MeP target has a number of addressing modes and busses. The
6562 @code{near} space spans the standard memory space's first 16 megabytes
6563 (24 bits). The @code{far} space spans the entire 32-bit memory space.
6564 The @code{based} space is a 128-byte region in the memory space that
6565 is addressed relative to the @code{$tp} register. The @code{tiny}
6566 space is a 65536-byte region relative to the @code{$gp} register. In
6567 addition to these memory regions, the MeP target has a separate 16-bit
6568 control bus which is specified with @code{cb} attributes.
6569
6570 @table @code
6571
6572 @item based
6573 @cindex @code{based} variable attribute, MeP
6574 Any variable with the @code{based} attribute is assigned to the
6575 @code{.based} section, and is accessed with relative to the
6576 @code{$tp} register.
6577
6578 @item tiny
6579 @cindex @code{tiny} variable attribute, MeP
6580 Likewise, the @code{tiny} attribute assigned variables to the
6581 @code{.tiny} section, relative to the @code{$gp} register.
6582
6583 @item near
6584 @cindex @code{near} variable attribute, MeP
6585 Variables with the @code{near} attribute are assumed to have addresses
6586 that fit in a 24-bit addressing mode. This is the default for large
6587 variables (@code{-mtiny=4} is the default) but this attribute can
6588 override @code{-mtiny=} for small variables, or override @code{-ml}.
6589
6590 @item far
6591 @cindex @code{far} variable attribute, MeP
6592 Variables with the @code{far} attribute are addressed using a full
6593 32-bit address. Since this covers the entire memory space, this
6594 allows modules to make no assumptions about where variables might be
6595 stored.
6596
6597 @item io
6598 @cindex @code{io} variable attribute, MeP
6599 @itemx io (@var{addr})
6600 Variables with the @code{io} attribute are used to address
6601 memory-mapped peripherals. If an address is specified, the variable
6602 is assigned that address, else it is not assigned an address (it is
6603 assumed some other module assigns an address). Example:
6604
6605 @smallexample
6606 int timer_count __attribute__((io(0x123)));
6607 @end smallexample
6608
6609 @item cb
6610 @itemx cb (@var{addr})
6611 @cindex @code{cb} variable attribute, MeP
6612 Variables with the @code{cb} attribute are used to access the control
6613 bus, using special instructions. @code{addr} indicates the control bus
6614 address. Example:
6615
6616 @smallexample
6617 int cpu_clock __attribute__((cb(0x123)));
6618 @end smallexample
6619
6620 @end table
6621
6622 @node Microsoft Windows Variable Attributes
6623 @subsection Microsoft Windows Variable Attributes
6624
6625 You can use these attributes on Microsoft Windows targets.
6626 @ref{x86 Variable Attributes} for additional Windows compatibility
6627 attributes available on all x86 targets.
6628
6629 @table @code
6630 @item dllimport
6631 @itemx dllexport
6632 @cindex @code{dllimport} variable attribute
6633 @cindex @code{dllexport} variable attribute
6634 The @code{dllimport} and @code{dllexport} attributes are described in
6635 @ref{Microsoft Windows Function Attributes}.
6636
6637 @item selectany
6638 @cindex @code{selectany} variable attribute
6639 The @code{selectany} attribute causes an initialized global variable to
6640 have link-once semantics. When multiple definitions of the variable are
6641 encountered by the linker, the first is selected and the remainder are
6642 discarded. Following usage by the Microsoft compiler, the linker is told
6643 @emph{not} to warn about size or content differences of the multiple
6644 definitions.
6645
6646 Although the primary usage of this attribute is for POD types, the
6647 attribute can also be applied to global C++ objects that are initialized
6648 by a constructor. In this case, the static initialization and destruction
6649 code for the object is emitted in each translation defining the object,
6650 but the calls to the constructor and destructor are protected by a
6651 link-once guard variable.
6652
6653 The @code{selectany} attribute is only available on Microsoft Windows
6654 targets. You can use @code{__declspec (selectany)} as a synonym for
6655 @code{__attribute__ ((selectany))} for compatibility with other
6656 compilers.
6657
6658 @item shared
6659 @cindex @code{shared} variable attribute
6660 On Microsoft Windows, in addition to putting variable definitions in a named
6661 section, the section can also be shared among all running copies of an
6662 executable or DLL@. For example, this small program defines shared data
6663 by putting it in a named section @code{shared} and marking the section
6664 shareable:
6665
6666 @smallexample
6667 int foo __attribute__((section ("shared"), shared)) = 0;
6668
6669 int
6670 main()
6671 @{
6672 /* @r{Read and write foo. All running
6673 copies see the same value.} */
6674 return 0;
6675 @}
6676 @end smallexample
6677
6678 @noindent
6679 You may only use the @code{shared} attribute along with @code{section}
6680 attribute with a fully-initialized global definition because of the way
6681 linkers work. See @code{section} attribute for more information.
6682
6683 The @code{shared} attribute is only available on Microsoft Windows@.
6684
6685 @end table
6686
6687 @node MSP430 Variable Attributes
6688 @subsection MSP430 Variable Attributes
6689
6690 @table @code
6691 @item noinit
6692 @cindex @code{noinit} variable attribute, MSP430
6693 Any data with the @code{noinit} attribute will not be initialised by
6694 the C runtime startup code, or the program loader. Not initialising
6695 data in this way can reduce program startup times.
6696
6697 @item persistent
6698 @cindex @code{persistent} variable attribute, MSP430
6699 Any variable with the @code{persistent} attribute will not be
6700 initialised by the C runtime startup code. Instead its value will be
6701 set once, when the application is loaded, and then never initialised
6702 again, even if the processor is reset or the program restarts.
6703 Persistent data is intended to be placed into FLASH RAM, where its
6704 value will be retained across resets. The linker script being used to
6705 create the application should ensure that persistent data is correctly
6706 placed.
6707
6708 @item lower
6709 @itemx upper
6710 @itemx either
6711 @cindex @code{lower} variable attribute, MSP430
6712 @cindex @code{upper} variable attribute, MSP430
6713 @cindex @code{either} variable attribute, MSP430
6714 These attributes are the same as the MSP430 function attributes of the
6715 same name (@pxref{MSP430 Function Attributes}).
6716 These attributes can be applied to both functions and variables.
6717 @end table
6718
6719 @node Nvidia PTX Variable Attributes
6720 @subsection Nvidia PTX Variable Attributes
6721
6722 These variable attributes are supported by the Nvidia PTX back end:
6723
6724 @table @code
6725 @item shared
6726 @cindex @code{shared} attribute, Nvidia PTX
6727 Use this attribute to place a variable in the @code{.shared} memory space.
6728 This memory space is private to each cooperative thread array; only threads
6729 within one thread block refer to the same instance of the variable.
6730 The runtime does not initialize variables in this memory space.
6731 @end table
6732
6733 @node PowerPC Variable Attributes
6734 @subsection PowerPC Variable Attributes
6735
6736 Three attributes currently are defined for PowerPC configurations:
6737 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6738
6739 @cindex @code{ms_struct} variable attribute, PowerPC
6740 @cindex @code{gcc_struct} variable attribute, PowerPC
6741 For full documentation of the struct attributes please see the
6742 documentation in @ref{x86 Variable Attributes}.
6743
6744 @cindex @code{altivec} variable attribute, PowerPC
6745 For documentation of @code{altivec} attribute please see the
6746 documentation in @ref{PowerPC Type Attributes}.
6747
6748 @node RL78 Variable Attributes
6749 @subsection RL78 Variable Attributes
6750
6751 @cindex @code{saddr} variable attribute, RL78
6752 The RL78 back end supports the @code{saddr} variable attribute. This
6753 specifies placement of the corresponding variable in the SADDR area,
6754 which can be accessed more efficiently than the default memory region.
6755
6756 @node SPU Variable Attributes
6757 @subsection SPU Variable Attributes
6758
6759 @cindex @code{spu_vector} variable attribute, SPU
6760 The SPU supports the @code{spu_vector} attribute for variables. For
6761 documentation of this attribute please see the documentation in
6762 @ref{SPU Type Attributes}.
6763
6764 @node V850 Variable Attributes
6765 @subsection V850 Variable Attributes
6766
6767 These variable attributes are supported by the V850 back end:
6768
6769 @table @code
6770
6771 @item sda
6772 @cindex @code{sda} variable attribute, V850
6773 Use this attribute to explicitly place a variable in the small data area,
6774 which can hold up to 64 kilobytes.
6775
6776 @item tda
6777 @cindex @code{tda} variable attribute, V850
6778 Use this attribute to explicitly place a variable in the tiny data area,
6779 which can hold up to 256 bytes in total.
6780
6781 @item zda
6782 @cindex @code{zda} variable attribute, V850
6783 Use this attribute to explicitly place a variable in the first 32 kilobytes
6784 of memory.
6785 @end table
6786
6787 @node x86 Variable Attributes
6788 @subsection x86 Variable Attributes
6789
6790 Two attributes are currently defined for x86 configurations:
6791 @code{ms_struct} and @code{gcc_struct}.
6792
6793 @table @code
6794 @item ms_struct
6795 @itemx gcc_struct
6796 @cindex @code{ms_struct} variable attribute, x86
6797 @cindex @code{gcc_struct} variable attribute, x86
6798
6799 If @code{packed} is used on a structure, or if bit-fields are used,
6800 it may be that the Microsoft ABI lays out the structure differently
6801 than the way GCC normally does. Particularly when moving packed
6802 data between functions compiled with GCC and the native Microsoft compiler
6803 (either via function call or as data in a file), it may be necessary to access
6804 either format.
6805
6806 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6807 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6808 command-line options, respectively;
6809 see @ref{x86 Options}, for details of how structure layout is affected.
6810 @xref{x86 Type Attributes}, for information about the corresponding
6811 attributes on types.
6812
6813 @end table
6814
6815 @node Xstormy16 Variable Attributes
6816 @subsection Xstormy16 Variable Attributes
6817
6818 One attribute is currently defined for xstormy16 configurations:
6819 @code{below100}.
6820
6821 @table @code
6822 @item below100
6823 @cindex @code{below100} variable attribute, Xstormy16
6824
6825 If a variable has the @code{below100} attribute (@code{BELOW100} is
6826 allowed also), GCC places the variable in the first 0x100 bytes of
6827 memory and use special opcodes to access it. Such variables are
6828 placed in either the @code{.bss_below100} section or the
6829 @code{.data_below100} section.
6830
6831 @end table
6832
6833 @node Type Attributes
6834 @section Specifying Attributes of Types
6835 @cindex attribute of types
6836 @cindex type attributes
6837
6838 The keyword @code{__attribute__} allows you to specify special
6839 attributes of types. Some type attributes apply only to @code{struct}
6840 and @code{union} types, while others can apply to any type defined
6841 via a @code{typedef} declaration. Other attributes are defined for
6842 functions (@pxref{Function Attributes}), labels (@pxref{Label
6843 Attributes}), enumerators (@pxref{Enumerator Attributes}),
6844 statements (@pxref{Statement Attributes}), and for
6845 variables (@pxref{Variable Attributes}).
6846
6847 The @code{__attribute__} keyword is followed by an attribute specification
6848 inside double parentheses.
6849
6850 You may specify type attributes in an enum, struct or union type
6851 declaration or definition by placing them immediately after the
6852 @code{struct}, @code{union} or @code{enum} keyword. A less preferred
6853 syntax is to place them just past the closing curly brace of the
6854 definition.
6855
6856 You can also include type attributes in a @code{typedef} declaration.
6857 @xref{Attribute Syntax}, for details of the exact syntax for using
6858 attributes.
6859
6860 @menu
6861 * Common Type Attributes::
6862 * ARC Type Attributes::
6863 * ARM Type Attributes::
6864 * MeP Type Attributes::
6865 * PowerPC Type Attributes::
6866 * SPU Type Attributes::
6867 * x86 Type Attributes::
6868 @end menu
6869
6870 @node Common Type Attributes
6871 @subsection Common Type Attributes
6872
6873 The following type attributes are supported on most targets.
6874
6875 @table @code
6876 @cindex @code{aligned} type attribute
6877 @item aligned (@var{alignment})
6878 This attribute specifies a minimum alignment (in bytes) for variables
6879 of the specified type. For example, the declarations:
6880
6881 @smallexample
6882 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6883 typedef int more_aligned_int __attribute__ ((aligned (8)));
6884 @end smallexample
6885
6886 @noindent
6887 force the compiler to ensure (as far as it can) that each variable whose
6888 type is @code{struct S} or @code{more_aligned_int} is allocated and
6889 aligned @emph{at least} on a 8-byte boundary. On a SPARC, having all
6890 variables of type @code{struct S} aligned to 8-byte boundaries allows
6891 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6892 store) instructions when copying one variable of type @code{struct S} to
6893 another, thus improving run-time efficiency.
6894
6895 Note that the alignment of any given @code{struct} or @code{union} type
6896 is required by the ISO C standard to be at least a perfect multiple of
6897 the lowest common multiple of the alignments of all of the members of
6898 the @code{struct} or @code{union} in question. This means that you @emph{can}
6899 effectively adjust the alignment of a @code{struct} or @code{union}
6900 type by attaching an @code{aligned} attribute to any one of the members
6901 of such a type, but the notation illustrated in the example above is a
6902 more obvious, intuitive, and readable way to request the compiler to
6903 adjust the alignment of an entire @code{struct} or @code{union} type.
6904
6905 As in the preceding example, you can explicitly specify the alignment
6906 (in bytes) that you wish the compiler to use for a given @code{struct}
6907 or @code{union} type. Alternatively, you can leave out the alignment factor
6908 and just ask the compiler to align a type to the maximum
6909 useful alignment for the target machine you are compiling for. For
6910 example, you could write:
6911
6912 @smallexample
6913 struct S @{ short f[3]; @} __attribute__ ((aligned));
6914 @end smallexample
6915
6916 Whenever you leave out the alignment factor in an @code{aligned}
6917 attribute specification, the compiler automatically sets the alignment
6918 for the type to the largest alignment that is ever used for any data
6919 type on the target machine you are compiling for. Doing this can often
6920 make copy operations more efficient, because the compiler can use
6921 whatever instructions copy the biggest chunks of memory when performing
6922 copies to or from the variables that have types that you have aligned
6923 this way.
6924
6925 In the example above, if the size of each @code{short} is 2 bytes, then
6926 the size of the entire @code{struct S} type is 6 bytes. The smallest
6927 power of two that is greater than or equal to that is 8, so the
6928 compiler sets the alignment for the entire @code{struct S} type to 8
6929 bytes.
6930
6931 Note that although you can ask the compiler to select a time-efficient
6932 alignment for a given type and then declare only individual stand-alone
6933 objects of that type, the compiler's ability to select a time-efficient
6934 alignment is primarily useful only when you plan to create arrays of
6935 variables having the relevant (efficiently aligned) type. If you
6936 declare or use arrays of variables of an efficiently-aligned type, then
6937 it is likely that your program also does pointer arithmetic (or
6938 subscripting, which amounts to the same thing) on pointers to the
6939 relevant type, and the code that the compiler generates for these
6940 pointer arithmetic operations is often more efficient for
6941 efficiently-aligned types than for other types.
6942
6943 Note that the effectiveness of @code{aligned} attributes may be limited
6944 by inherent limitations in your linker. On many systems, the linker is
6945 only able to arrange for variables to be aligned up to a certain maximum
6946 alignment. (For some linkers, the maximum supported alignment may
6947 be very very small.) If your linker is only able to align variables
6948 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6949 in an @code{__attribute__} still only provides you with 8-byte
6950 alignment. See your linker documentation for further information.
6951
6952 The @code{aligned} attribute can only increase alignment. Alignment
6953 can be decreased by specifying the @code{packed} attribute. See below.
6954
6955 @cindex @code{warn_if_not_aligned} type attribute
6956 @item warn_if_not_aligned (@var{alignment})
6957 This attribute specifies a threshold for the structure field, measured
6958 in bytes. If the structure field is aligned below the threshold, a
6959 warning will be issued. For example, the declaration:
6960
6961 @smallexample
6962 typedef unsigned long long __u64
6963 __attribute__((aligned(4),warn_if_not_aligned(8)));
6964
6965 struct foo
6966 @{
6967 int i1;
6968 int i2;
6969 __u64 x;
6970 @};
6971 @end smallexample
6972
6973 @noindent
6974 causes the compiler to issue an warning on @code{struct foo}, like
6975 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
6976 It is used to define @code{struct foo} in such a way that
6977 @code{struct foo} has the same layout and the structure field @code{x}
6978 has the same alignment when @code{__u64} is aligned at either 4 or
6979 8 bytes. Align @code{struct foo} to 8 bytes:
6980
6981 @smallexample
6982 struct foo
6983 @{
6984 int i1;
6985 int i2;
6986 __u64 x;
6987 @} __attribute__((aligned(8)));
6988 @end smallexample
6989
6990 @noindent
6991 silences the warning. The compiler also issues a warning, like
6992 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
6993 when the structure field has the misaligned offset:
6994
6995 @smallexample
6996 struct foo
6997 @{
6998 int i1;
6999 int i2;
7000 int i3;
7001 __u64 x;
7002 @} __attribute__((aligned(8)));
7003 @end smallexample
7004
7005 This warning can be disabled by @option{-Wno-if-not-aligned}.
7006
7007 @item bnd_variable_size
7008 @cindex @code{bnd_variable_size} type attribute
7009 @cindex Pointer Bounds Checker attributes
7010 When applied to a structure field, this attribute tells Pointer
7011 Bounds Checker that the size of this field should not be computed
7012 using static type information. It may be used to mark variably-sized
7013 static array fields placed at the end of a structure.
7014
7015 @smallexample
7016 struct S
7017 @{
7018 int size;
7019 char data[1];
7020 @}
7021 S *p = (S *)malloc (sizeof(S) + 100);
7022 p->data[10] = 0; //Bounds violation
7023 @end smallexample
7024
7025 @noindent
7026 By using an attribute for the field we may avoid unwanted bound
7027 violation checks:
7028
7029 @smallexample
7030 struct S
7031 @{
7032 int size;
7033 char data[1] __attribute__((bnd_variable_size));
7034 @}
7035 S *p = (S *)malloc (sizeof(S) + 100);
7036 p->data[10] = 0; //OK
7037 @end smallexample
7038
7039 @item deprecated
7040 @itemx deprecated (@var{msg})
7041 @cindex @code{deprecated} type attribute
7042 The @code{deprecated} attribute results in a warning if the type
7043 is used anywhere in the source file. This is useful when identifying
7044 types that are expected to be removed in a future version of a program.
7045 If possible, the warning also includes the location of the declaration
7046 of the deprecated type, to enable users to easily find further
7047 information about why the type is deprecated, or what they should do
7048 instead. Note that the warnings only occur for uses and then only
7049 if the type is being applied to an identifier that itself is not being
7050 declared as deprecated.
7051
7052 @smallexample
7053 typedef int T1 __attribute__ ((deprecated));
7054 T1 x;
7055 typedef T1 T2;
7056 T2 y;
7057 typedef T1 T3 __attribute__ ((deprecated));
7058 T3 z __attribute__ ((deprecated));
7059 @end smallexample
7060
7061 @noindent
7062 results in a warning on line 2 and 3 but not lines 4, 5, or 6. No
7063 warning is issued for line 4 because T2 is not explicitly
7064 deprecated. Line 5 has no warning because T3 is explicitly
7065 deprecated. Similarly for line 6. The optional @var{msg}
7066 argument, which must be a string, is printed in the warning if
7067 present.
7068
7069 The @code{deprecated} attribute can also be used for functions and
7070 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7071
7072 @item designated_init
7073 @cindex @code{designated_init} type attribute
7074 This attribute may only be applied to structure types. It indicates
7075 that any initialization of an object of this type must use designated
7076 initializers rather than positional initializers. The intent of this
7077 attribute is to allow the programmer to indicate that a structure's
7078 layout may change, and that therefore relying on positional
7079 initialization will result in future breakage.
7080
7081 GCC emits warnings based on this attribute by default; use
7082 @option{-Wno-designated-init} to suppress them.
7083
7084 @item may_alias
7085 @cindex @code{may_alias} type attribute
7086 Accesses through pointers to types with this attribute are not subject
7087 to type-based alias analysis, but are instead assumed to be able to alias
7088 any other type of objects.
7089 In the context of section 6.5 paragraph 7 of the C99 standard,
7090 an lvalue expression
7091 dereferencing such a pointer is treated like having a character type.
7092 See @option{-fstrict-aliasing} for more information on aliasing issues.
7093 This extension exists to support some vector APIs, in which pointers to
7094 one vector type are permitted to alias pointers to a different vector type.
7095
7096 Note that an object of a type with this attribute does not have any
7097 special semantics.
7098
7099 Example of use:
7100
7101 @smallexample
7102 typedef short __attribute__((__may_alias__)) short_a;
7103
7104 int
7105 main (void)
7106 @{
7107 int a = 0x12345678;
7108 short_a *b = (short_a *) &a;
7109
7110 b[1] = 0;
7111
7112 if (a == 0x12345678)
7113 abort();
7114
7115 exit(0);
7116 @}
7117 @end smallexample
7118
7119 @noindent
7120 If you replaced @code{short_a} with @code{short} in the variable
7121 declaration, the above program would abort when compiled with
7122 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7123 above.
7124
7125 @item packed
7126 @cindex @code{packed} type attribute
7127 This attribute, attached to @code{struct} or @code{union} type
7128 definition, specifies that each member (other than zero-width bit-fields)
7129 of the structure or union is placed to minimize the memory required. When
7130 attached to an @code{enum} definition, it indicates that the smallest
7131 integral type should be used.
7132
7133 @opindex fshort-enums
7134 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7135 types is equivalent to specifying the @code{packed} attribute on each
7136 of the structure or union members. Specifying the @option{-fshort-enums}
7137 flag on the command line is equivalent to specifying the @code{packed}
7138 attribute on all @code{enum} definitions.
7139
7140 In the following example @code{struct my_packed_struct}'s members are
7141 packed closely together, but the internal layout of its @code{s} member
7142 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7143 be packed too.
7144
7145 @smallexample
7146 struct my_unpacked_struct
7147 @{
7148 char c;
7149 int i;
7150 @};
7151
7152 struct __attribute__ ((__packed__)) my_packed_struct
7153 @{
7154 char c;
7155 int i;
7156 struct my_unpacked_struct s;
7157 @};
7158 @end smallexample
7159
7160 You may only specify the @code{packed} attribute attribute on the definition
7161 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7162 that does not also define the enumerated type, structure or union.
7163
7164 @item scalar_storage_order ("@var{endianness}")
7165 @cindex @code{scalar_storage_order} type attribute
7166 When attached to a @code{union} or a @code{struct}, this attribute sets
7167 the storage order, aka endianness, of the scalar fields of the type, as
7168 well as the array fields whose component is scalar. The supported
7169 endiannesses are @code{big-endian} and @code{little-endian}. The attribute
7170 has no effects on fields which are themselves a @code{union}, a @code{struct}
7171 or an array whose component is a @code{union} or a @code{struct}, and it is
7172 possible for these fields to have a different scalar storage order than the
7173 enclosing type.
7174
7175 This attribute is supported only for targets that use a uniform default
7176 scalar storage order (fortunately, most of them), i.e. targets that store
7177 the scalars either all in big-endian or all in little-endian.
7178
7179 Additional restrictions are enforced for types with the reverse scalar
7180 storage order with regard to the scalar storage order of the target:
7181
7182 @itemize
7183 @item Taking the address of a scalar field of a @code{union} or a
7184 @code{struct} with reverse scalar storage order is not permitted and yields
7185 an error.
7186 @item Taking the address of an array field, whose component is scalar, of
7187 a @code{union} or a @code{struct} with reverse scalar storage order is
7188 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7189 is specified.
7190 @item Taking the address of a @code{union} or a @code{struct} with reverse
7191 scalar storage order is permitted.
7192 @end itemize
7193
7194 These restrictions exist because the storage order attribute is lost when
7195 the address of a scalar or the address of an array with scalar component is
7196 taken, so storing indirectly through this address generally does not work.
7197 The second case is nevertheless allowed to be able to perform a block copy
7198 from or to the array.
7199
7200 Moreover, the use of type punning or aliasing to toggle the storage order
7201 is not supported; that is to say, a given scalar object cannot be accessed
7202 through distinct types that assign a different storage order to it.
7203
7204 @item transparent_union
7205 @cindex @code{transparent_union} type attribute
7206
7207 This attribute, attached to a @code{union} type definition, indicates
7208 that any function parameter having that union type causes calls to that
7209 function to be treated in a special way.
7210
7211 First, the argument corresponding to a transparent union type can be of
7212 any type in the union; no cast is required. Also, if the union contains
7213 a pointer type, the corresponding argument can be a null pointer
7214 constant or a void pointer expression; and if the union contains a void
7215 pointer type, the corresponding argument can be any pointer expression.
7216 If the union member type is a pointer, qualifiers like @code{const} on
7217 the referenced type must be respected, just as with normal pointer
7218 conversions.
7219
7220 Second, the argument is passed to the function using the calling
7221 conventions of the first member of the transparent union, not the calling
7222 conventions of the union itself. All members of the union must have the
7223 same machine representation; this is necessary for this argument passing
7224 to work properly.
7225
7226 Transparent unions are designed for library functions that have multiple
7227 interfaces for compatibility reasons. For example, suppose the
7228 @code{wait} function must accept either a value of type @code{int *} to
7229 comply with POSIX, or a value of type @code{union wait *} to comply with
7230 the 4.1BSD interface. If @code{wait}'s parameter were @code{void *},
7231 @code{wait} would accept both kinds of arguments, but it would also
7232 accept any other pointer type and this would make argument type checking
7233 less useful. Instead, @code{<sys/wait.h>} might define the interface
7234 as follows:
7235
7236 @smallexample
7237 typedef union __attribute__ ((__transparent_union__))
7238 @{
7239 int *__ip;
7240 union wait *__up;
7241 @} wait_status_ptr_t;
7242
7243 pid_t wait (wait_status_ptr_t);
7244 @end smallexample
7245
7246 @noindent
7247 This interface allows either @code{int *} or @code{union wait *}
7248 arguments to be passed, using the @code{int *} calling convention.
7249 The program can call @code{wait} with arguments of either type:
7250
7251 @smallexample
7252 int w1 () @{ int w; return wait (&w); @}
7253 int w2 () @{ union wait w; return wait (&w); @}
7254 @end smallexample
7255
7256 @noindent
7257 With this interface, @code{wait}'s implementation might look like this:
7258
7259 @smallexample
7260 pid_t wait (wait_status_ptr_t p)
7261 @{
7262 return waitpid (-1, p.__ip, 0);
7263 @}
7264 @end smallexample
7265
7266 @item unused
7267 @cindex @code{unused} type attribute
7268 When attached to a type (including a @code{union} or a @code{struct}),
7269 this attribute means that variables of that type are meant to appear
7270 possibly unused. GCC does not produce a warning for any variables of
7271 that type, even if the variable appears to do nothing. This is often
7272 the case with lock or thread classes, which are usually defined and then
7273 not referenced, but contain constructors and destructors that have
7274 nontrivial bookkeeping functions.
7275
7276 @item visibility
7277 @cindex @code{visibility} type attribute
7278 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7279 applied to class, struct, union and enum types. Unlike other type
7280 attributes, the attribute must appear between the initial keyword and
7281 the name of the type; it cannot appear after the body of the type.
7282
7283 Note that the type visibility is applied to vague linkage entities
7284 associated with the class (vtable, typeinfo node, etc.). In
7285 particular, if a class is thrown as an exception in one shared object
7286 and caught in another, the class must have default visibility.
7287 Otherwise the two shared objects are unable to use the same
7288 typeinfo node and exception handling will break.
7289
7290 @end table
7291
7292 To specify multiple attributes, separate them by commas within the
7293 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7294 packed))}.
7295
7296 @node ARC Type Attributes
7297 @subsection ARC Type Attributes
7298
7299 @cindex @code{uncached} type attribute, ARC
7300 Declaring objects with @code{uncached} allows you to exclude
7301 data-cache participation in load and store operations on those objects
7302 without involving the additional semantic implications of
7303 @code{volatile}. The @code{.di} instruction suffix is used for all
7304 loads and stores of data declared @code{uncached}.
7305
7306 @node ARM Type Attributes
7307 @subsection ARM Type Attributes
7308
7309 @cindex @code{notshared} type attribute, ARM
7310 On those ARM targets that support @code{dllimport} (such as Symbian
7311 OS), you can use the @code{notshared} attribute to indicate that the
7312 virtual table and other similar data for a class should not be
7313 exported from a DLL@. For example:
7314
7315 @smallexample
7316 class __declspec(notshared) C @{
7317 public:
7318 __declspec(dllimport) C();
7319 virtual void f();
7320 @}
7321
7322 __declspec(dllexport)
7323 C::C() @{@}
7324 @end smallexample
7325
7326 @noindent
7327 In this code, @code{C::C} is exported from the current DLL, but the
7328 virtual table for @code{C} is not exported. (You can use
7329 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7330 most Symbian OS code uses @code{__declspec}.)
7331
7332 @node MeP Type Attributes
7333 @subsection MeP Type Attributes
7334
7335 @cindex @code{based} type attribute, MeP
7336 @cindex @code{tiny} type attribute, MeP
7337 @cindex @code{near} type attribute, MeP
7338 @cindex @code{far} type attribute, MeP
7339 Many of the MeP variable attributes may be applied to types as well.
7340 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7341 @code{far} attributes may be applied to either. The @code{io} and
7342 @code{cb} attributes may not be applied to types.
7343
7344 @node PowerPC Type Attributes
7345 @subsection PowerPC Type Attributes
7346
7347 Three attributes currently are defined for PowerPC configurations:
7348 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7349
7350 @cindex @code{ms_struct} type attribute, PowerPC
7351 @cindex @code{gcc_struct} type attribute, PowerPC
7352 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7353 attributes please see the documentation in @ref{x86 Type Attributes}.
7354
7355 @cindex @code{altivec} type attribute, PowerPC
7356 The @code{altivec} attribute allows one to declare AltiVec vector data
7357 types supported by the AltiVec Programming Interface Manual. The
7358 attribute requires an argument to specify one of three vector types:
7359 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7360 and @code{bool__} (always followed by unsigned).
7361
7362 @smallexample
7363 __attribute__((altivec(vector__)))
7364 __attribute__((altivec(pixel__))) unsigned short
7365 __attribute__((altivec(bool__))) unsigned
7366 @end smallexample
7367
7368 These attributes mainly are intended to support the @code{__vector},
7369 @code{__pixel}, and @code{__bool} AltiVec keywords.
7370
7371 @node SPU Type Attributes
7372 @subsection SPU Type Attributes
7373
7374 @cindex @code{spu_vector} type attribute, SPU
7375 The SPU supports the @code{spu_vector} attribute for types. This attribute
7376 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7377 Language Extensions Specification. It is intended to support the
7378 @code{__vector} keyword.
7379
7380 @node x86 Type Attributes
7381 @subsection x86 Type Attributes
7382
7383 Two attributes are currently defined for x86 configurations:
7384 @code{ms_struct} and @code{gcc_struct}.
7385
7386 @table @code
7387
7388 @item ms_struct
7389 @itemx gcc_struct
7390 @cindex @code{ms_struct} type attribute, x86
7391 @cindex @code{gcc_struct} type attribute, x86
7392
7393 If @code{packed} is used on a structure, or if bit-fields are used
7394 it may be that the Microsoft ABI packs them differently
7395 than GCC normally packs them. Particularly when moving packed
7396 data between functions compiled with GCC and the native Microsoft compiler
7397 (either via function call or as data in a file), it may be necessary to access
7398 either format.
7399
7400 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7401 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7402 command-line options, respectively;
7403 see @ref{x86 Options}, for details of how structure layout is affected.
7404 @xref{x86 Variable Attributes}, for information about the corresponding
7405 attributes on variables.
7406
7407 @end table
7408
7409 @node Label Attributes
7410 @section Label Attributes
7411 @cindex Label Attributes
7412
7413 GCC allows attributes to be set on C labels. @xref{Attribute Syntax}, for
7414 details of the exact syntax for using attributes. Other attributes are
7415 available for functions (@pxref{Function Attributes}), variables
7416 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7417 statements (@pxref{Statement Attributes}), and for types
7418 (@pxref{Type Attributes}).
7419
7420 This example uses the @code{cold} label attribute to indicate the
7421 @code{ErrorHandling} branch is unlikely to be taken and that the
7422 @code{ErrorHandling} label is unused:
7423
7424 @smallexample
7425
7426 asm goto ("some asm" : : : : NoError);
7427
7428 /* This branch (the fall-through from the asm) is less commonly used */
7429 ErrorHandling:
7430 __attribute__((cold, unused)); /* Semi-colon is required here */
7431 printf("error\n");
7432 return 0;
7433
7434 NoError:
7435 printf("no error\n");
7436 return 1;
7437 @end smallexample
7438
7439 @table @code
7440 @item unused
7441 @cindex @code{unused} label attribute
7442 This feature is intended for program-generated code that may contain
7443 unused labels, but which is compiled with @option{-Wall}. It is
7444 not normally appropriate to use in it human-written code, though it
7445 could be useful in cases where the code that jumps to the label is
7446 contained within an @code{#ifdef} conditional.
7447
7448 @item hot
7449 @cindex @code{hot} label attribute
7450 The @code{hot} attribute on a label is used to inform the compiler that
7451 the path following the label is more likely than paths that are not so
7452 annotated. This attribute is used in cases where @code{__builtin_expect}
7453 cannot be used, for instance with computed goto or @code{asm goto}.
7454
7455 @item cold
7456 @cindex @code{cold} label attribute
7457 The @code{cold} attribute on labels is used to inform the compiler that
7458 the path following the label is unlikely to be executed. This attribute
7459 is used in cases where @code{__builtin_expect} cannot be used, for instance
7460 with computed goto or @code{asm goto}.
7461
7462 @end table
7463
7464 @node Enumerator Attributes
7465 @section Enumerator Attributes
7466 @cindex Enumerator Attributes
7467
7468 GCC allows attributes to be set on enumerators. @xref{Attribute Syntax}, for
7469 details of the exact syntax for using attributes. Other attributes are
7470 available for functions (@pxref{Function Attributes}), variables
7471 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7472 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7473
7474 This example uses the @code{deprecated} enumerator attribute to indicate the
7475 @code{oldval} enumerator is deprecated:
7476
7477 @smallexample
7478 enum E @{
7479 oldval __attribute__((deprecated)),
7480 newval
7481 @};
7482
7483 int
7484 fn (void)
7485 @{
7486 return oldval;
7487 @}
7488 @end smallexample
7489
7490 @table @code
7491 @item deprecated
7492 @cindex @code{deprecated} enumerator attribute
7493 The @code{deprecated} attribute results in a warning if the enumerator
7494 is used anywhere in the source file. This is useful when identifying
7495 enumerators that are expected to be removed in a future version of a
7496 program. The warning also includes the location of the declaration
7497 of the deprecated enumerator, to enable users to easily find further
7498 information about why the enumerator is deprecated, or what they should
7499 do instead. Note that the warnings only occurs for uses.
7500
7501 @end table
7502
7503 @node Statement Attributes
7504 @section Statement Attributes
7505 @cindex Statement Attributes
7506
7507 GCC allows attributes to be set on null statements. @xref{Attribute Syntax},
7508 for details of the exact syntax for using attributes. Other attributes are
7509 available for functions (@pxref{Function Attributes}), variables
7510 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7511 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7512
7513 This example uses the @code{fallthrough} statement attribute to indicate that
7514 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7515
7516 @smallexample
7517 switch (cond)
7518 @{
7519 case 1:
7520 bar (1);
7521 __attribute__((fallthrough));
7522 case 2:
7523 @dots{}
7524 @}
7525 @end smallexample
7526
7527 @table @code
7528 @item fallthrough
7529 @cindex @code{fallthrough} statement attribute
7530 The @code{fallthrough} attribute with a null statement serves as a
7531 fallthrough statement. It hints to the compiler that a statement
7532 that falls through to another case label, or user-defined label
7533 in a switch statement is intentional and thus the
7534 @option{-Wimplicit-fallthrough} warning must not trigger. The
7535 fallthrough attribute may appear at most once in each attribute
7536 list, and may not be mixed with other attributes. It can only
7537 be used in a switch statement (the compiler will issue an error
7538 otherwise), after a preceding statement and before a logically
7539 succeeding case label, or user-defined label.
7540
7541 @end table
7542
7543 @node Attribute Syntax
7544 @section Attribute Syntax
7545 @cindex attribute syntax
7546
7547 This section describes the syntax with which @code{__attribute__} may be
7548 used, and the constructs to which attribute specifiers bind, for the C
7549 language. Some details may vary for C++ and Objective-C@. Because of
7550 infelicities in the grammar for attributes, some forms described here
7551 may not be successfully parsed in all cases.
7552
7553 There are some problems with the semantics of attributes in C++. For
7554 example, there are no manglings for attributes, although they may affect
7555 code generation, so problems may arise when attributed types are used in
7556 conjunction with templates or overloading. Similarly, @code{typeid}
7557 does not distinguish between types with different attributes. Support
7558 for attributes in C++ may be restricted in future to attributes on
7559 declarations only, but not on nested declarators.
7560
7561 @xref{Function Attributes}, for details of the semantics of attributes
7562 applying to functions. @xref{Variable Attributes}, for details of the
7563 semantics of attributes applying to variables. @xref{Type Attributes},
7564 for details of the semantics of attributes applying to structure, union
7565 and enumerated types.
7566 @xref{Label Attributes}, for details of the semantics of attributes
7567 applying to labels.
7568 @xref{Enumerator Attributes}, for details of the semantics of attributes
7569 applying to enumerators.
7570 @xref{Statement Attributes}, for details of the semantics of attributes
7571 applying to statements.
7572
7573 An @dfn{attribute specifier} is of the form
7574 @code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list}
7575 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7576 each attribute is one of the following:
7577
7578 @itemize @bullet
7579 @item
7580 Empty. Empty attributes are ignored.
7581
7582 @item
7583 An attribute name
7584 (which may be an identifier such as @code{unused}, or a reserved
7585 word such as @code{const}).
7586
7587 @item
7588 An attribute name followed by a parenthesized list of
7589 parameters for the attribute.
7590 These parameters take one of the following forms:
7591
7592 @itemize @bullet
7593 @item
7594 An identifier. For example, @code{mode} attributes use this form.
7595
7596 @item
7597 An identifier followed by a comma and a non-empty comma-separated list
7598 of expressions. For example, @code{format} attributes use this form.
7599
7600 @item
7601 A possibly empty comma-separated list of expressions. For example,
7602 @code{format_arg} attributes use this form with the list being a single
7603 integer constant expression, and @code{alias} attributes use this form
7604 with the list being a single string constant.
7605 @end itemize
7606 @end itemize
7607
7608 An @dfn{attribute specifier list} is a sequence of one or more attribute
7609 specifiers, not separated by any other tokens.
7610
7611 You may optionally specify attribute names with @samp{__}
7612 preceding and following the name.
7613 This allows you to use them in header files without
7614 being concerned about a possible macro of the same name. For example,
7615 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7616
7617
7618 @subsubheading Label Attributes
7619
7620 In GNU C, an attribute specifier list may appear after the colon following a
7621 label, other than a @code{case} or @code{default} label. GNU C++ only permits
7622 attributes on labels if the attribute specifier is immediately
7623 followed by a semicolon (i.e., the label applies to an empty
7624 statement). If the semicolon is missing, C++ label attributes are
7625 ambiguous, as it is permissible for a declaration, which could begin
7626 with an attribute list, to be labelled in C++. Declarations cannot be
7627 labelled in C90 or C99, so the ambiguity does not arise there.
7628
7629 @subsubheading Enumerator Attributes
7630
7631 In GNU C, an attribute specifier list may appear as part of an enumerator.
7632 The attribute goes after the enumeration constant, before @code{=}, if
7633 present. The optional attribute in the enumerator appertains to the
7634 enumeration constant. It is not possible to place the attribute after
7635 the constant expression, if present.
7636
7637 @subsubheading Statement Attributes
7638 In GNU C, an attribute specifier list may appear as part of a null
7639 statement. The attribute goes before the semicolon.
7640
7641 @subsubheading Type Attributes
7642
7643 An attribute specifier list may appear as part of a @code{struct},
7644 @code{union} or @code{enum} specifier. It may go either immediately
7645 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7646 the closing brace. The former syntax is preferred.
7647 Where attribute specifiers follow the closing brace, they are considered
7648 to relate to the structure, union or enumerated type defined, not to any
7649 enclosing declaration the type specifier appears in, and the type
7650 defined is not complete until after the attribute specifiers.
7651 @c Otherwise, there would be the following problems: a shift/reduce
7652 @c conflict between attributes binding the struct/union/enum and
7653 @c binding to the list of specifiers/qualifiers; and "aligned"
7654 @c attributes could use sizeof for the structure, but the size could be
7655 @c changed later by "packed" attributes.
7656
7657
7658 @subsubheading All other attributes
7659
7660 Otherwise, an attribute specifier appears as part of a declaration,
7661 counting declarations of unnamed parameters and type names, and relates
7662 to that declaration (which may be nested in another declaration, for
7663 example in the case of a parameter declaration), or to a particular declarator
7664 within a declaration. Where an
7665 attribute specifier is applied to a parameter declared as a function or
7666 an array, it should apply to the function or array rather than the
7667 pointer to which the parameter is implicitly converted, but this is not
7668 yet correctly implemented.
7669
7670 Any list of specifiers and qualifiers at the start of a declaration may
7671 contain attribute specifiers, whether or not such a list may in that
7672 context contain storage class specifiers. (Some attributes, however,
7673 are essentially in the nature of storage class specifiers, and only make
7674 sense where storage class specifiers may be used; for example,
7675 @code{section}.) There is one necessary limitation to this syntax: the
7676 first old-style parameter declaration in a function definition cannot
7677 begin with an attribute specifier, because such an attribute applies to
7678 the function instead by syntax described below (which, however, is not
7679 yet implemented in this case). In some other cases, attribute
7680 specifiers are permitted by this grammar but not yet supported by the
7681 compiler. All attribute specifiers in this place relate to the
7682 declaration as a whole. In the obsolescent usage where a type of
7683 @code{int} is implied by the absence of type specifiers, such a list of
7684 specifiers and qualifiers may be an attribute specifier list with no
7685 other specifiers or qualifiers.
7686
7687 At present, the first parameter in a function prototype must have some
7688 type specifier that is not an attribute specifier; this resolves an
7689 ambiguity in the interpretation of @code{void f(int
7690 (__attribute__((foo)) x))}, but is subject to change. At present, if
7691 the parentheses of a function declarator contain only attributes then
7692 those attributes are ignored, rather than yielding an error or warning
7693 or implying a single parameter of type int, but this is subject to
7694 change.
7695
7696 An attribute specifier list may appear immediately before a declarator
7697 (other than the first) in a comma-separated list of declarators in a
7698 declaration of more than one identifier using a single list of
7699 specifiers and qualifiers. Such attribute specifiers apply
7700 only to the identifier before whose declarator they appear. For
7701 example, in
7702
7703 @smallexample
7704 __attribute__((noreturn)) void d0 (void),
7705 __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7706 d2 (void);
7707 @end smallexample
7708
7709 @noindent
7710 the @code{noreturn} attribute applies to all the functions
7711 declared; the @code{format} attribute only applies to @code{d1}.
7712
7713 An attribute specifier list may appear immediately before the comma,
7714 @code{=} or semicolon terminating the declaration of an identifier other
7715 than a function definition. Such attribute specifiers apply
7716 to the declared object or function. Where an
7717 assembler name for an object or function is specified (@pxref{Asm
7718 Labels}), the attribute must follow the @code{asm}
7719 specification.
7720
7721 An attribute specifier list may, in future, be permitted to appear after
7722 the declarator in a function definition (before any old-style parameter
7723 declarations or the function body).
7724
7725 Attribute specifiers may be mixed with type qualifiers appearing inside
7726 the @code{[]} of a parameter array declarator, in the C99 construct by
7727 which such qualifiers are applied to the pointer to which the array is
7728 implicitly converted. Such attribute specifiers apply to the pointer,
7729 not to the array, but at present this is not implemented and they are
7730 ignored.
7731
7732 An attribute specifier list may appear at the start of a nested
7733 declarator. At present, there are some limitations in this usage: the
7734 attributes correctly apply to the declarator, but for most individual
7735 attributes the semantics this implies are not implemented.
7736 When attribute specifiers follow the @code{*} of a pointer
7737 declarator, they may be mixed with any type qualifiers present.
7738 The following describes the formal semantics of this syntax. It makes the
7739 most sense if you are familiar with the formal specification of
7740 declarators in the ISO C standard.
7741
7742 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7743 D1}, where @code{T} contains declaration specifiers that specify a type
7744 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7745 contains an identifier @var{ident}. The type specified for @var{ident}
7746 for derived declarators whose type does not include an attribute
7747 specifier is as in the ISO C standard.
7748
7749 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7750 and the declaration @code{T D} specifies the type
7751 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7752 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7753 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7754
7755 If @code{D1} has the form @code{*
7756 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7757 declaration @code{T D} specifies the type
7758 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7759 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7760 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7761 @var{ident}.
7762
7763 For example,
7764
7765 @smallexample
7766 void (__attribute__((noreturn)) ****f) (void);
7767 @end smallexample
7768
7769 @noindent
7770 specifies the type ``pointer to pointer to pointer to pointer to
7771 non-returning function returning @code{void}''. As another example,
7772
7773 @smallexample
7774 char *__attribute__((aligned(8))) *f;
7775 @end smallexample
7776
7777 @noindent
7778 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7779 Note again that this does not work with most attributes; for example,
7780 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7781 is not yet supported.
7782
7783 For compatibility with existing code written for compiler versions that
7784 did not implement attributes on nested declarators, some laxity is
7785 allowed in the placing of attributes. If an attribute that only applies
7786 to types is applied to a declaration, it is treated as applying to
7787 the type of that declaration. If an attribute that only applies to
7788 declarations is applied to the type of a declaration, it is treated
7789 as applying to that declaration; and, for compatibility with code
7790 placing the attributes immediately before the identifier declared, such
7791 an attribute applied to a function return type is treated as
7792 applying to the function type, and such an attribute applied to an array
7793 element type is treated as applying to the array type. If an
7794 attribute that only applies to function types is applied to a
7795 pointer-to-function type, it is treated as applying to the pointer
7796 target type; if such an attribute is applied to a function return type
7797 that is not a pointer-to-function type, it is treated as applying
7798 to the function type.
7799
7800 @node Function Prototypes
7801 @section Prototypes and Old-Style Function Definitions
7802 @cindex function prototype declarations
7803 @cindex old-style function definitions
7804 @cindex promotion of formal parameters
7805
7806 GNU C extends ISO C to allow a function prototype to override a later
7807 old-style non-prototype definition. Consider the following example:
7808
7809 @smallexample
7810 /* @r{Use prototypes unless the compiler is old-fashioned.} */
7811 #ifdef __STDC__
7812 #define P(x) x
7813 #else
7814 #define P(x) ()
7815 #endif
7816
7817 /* @r{Prototype function declaration.} */
7818 int isroot P((uid_t));
7819
7820 /* @r{Old-style function definition.} */
7821 int
7822 isroot (x) /* @r{??? lossage here ???} */
7823 uid_t x;
7824 @{
7825 return x == 0;
7826 @}
7827 @end smallexample
7828
7829 Suppose the type @code{uid_t} happens to be @code{short}. ISO C does
7830 not allow this example, because subword arguments in old-style
7831 non-prototype definitions are promoted. Therefore in this example the
7832 function definition's argument is really an @code{int}, which does not
7833 match the prototype argument type of @code{short}.
7834
7835 This restriction of ISO C makes it hard to write code that is portable
7836 to traditional C compilers, because the programmer does not know
7837 whether the @code{uid_t} type is @code{short}, @code{int}, or
7838 @code{long}. Therefore, in cases like these GNU C allows a prototype
7839 to override a later old-style definition. More precisely, in GNU C, a
7840 function prototype argument type overrides the argument type specified
7841 by a later old-style definition if the former type is the same as the
7842 latter type before promotion. Thus in GNU C the above example is
7843 equivalent to the following:
7844
7845 @smallexample
7846 int isroot (uid_t);
7847
7848 int
7849 isroot (uid_t x)
7850 @{
7851 return x == 0;
7852 @}
7853 @end smallexample
7854
7855 @noindent
7856 GNU C++ does not support old-style function definitions, so this
7857 extension is irrelevant.
7858
7859 @node C++ Comments
7860 @section C++ Style Comments
7861 @cindex @code{//}
7862 @cindex C++ comments
7863 @cindex comments, C++ style
7864
7865 In GNU C, you may use C++ style comments, which start with @samp{//} and
7866 continue until the end of the line. Many other C implementations allow
7867 such comments, and they are included in the 1999 C standard. However,
7868 C++ style comments are not recognized if you specify an @option{-std}
7869 option specifying a version of ISO C before C99, or @option{-ansi}
7870 (equivalent to @option{-std=c90}).
7871
7872 @node Dollar Signs
7873 @section Dollar Signs in Identifier Names
7874 @cindex $
7875 @cindex dollar signs in identifier names
7876 @cindex identifier names, dollar signs in
7877
7878 In GNU C, you may normally use dollar signs in identifier names.
7879 This is because many traditional C implementations allow such identifiers.
7880 However, dollar signs in identifiers are not supported on a few target
7881 machines, typically because the target assembler does not allow them.
7882
7883 @node Character Escapes
7884 @section The Character @key{ESC} in Constants
7885
7886 You can use the sequence @samp{\e} in a string or character constant to
7887 stand for the ASCII character @key{ESC}.
7888
7889 @node Alignment
7890 @section Inquiring on Alignment of Types or Variables
7891 @cindex alignment
7892 @cindex type alignment
7893 @cindex variable alignment
7894
7895 The keyword @code{__alignof__} allows you to inquire about how an object
7896 is aligned, or the minimum alignment usually required by a type. Its
7897 syntax is just like @code{sizeof}.
7898
7899 For example, if the target machine requires a @code{double} value to be
7900 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7901 This is true on many RISC machines. On more traditional machine
7902 designs, @code{__alignof__ (double)} is 4 or even 2.
7903
7904 Some machines never actually require alignment; they allow reference to any
7905 data type even at an odd address. For these machines, @code{__alignof__}
7906 reports the smallest alignment that GCC gives the data type, usually as
7907 mandated by the target ABI.
7908
7909 If the operand of @code{__alignof__} is an lvalue rather than a type,
7910 its value is the required alignment for its type, taking into account
7911 any minimum alignment specified with GCC's @code{__attribute__}
7912 extension (@pxref{Variable Attributes}). For example, after this
7913 declaration:
7914
7915 @smallexample
7916 struct foo @{ int x; char y; @} foo1;
7917 @end smallexample
7918
7919 @noindent
7920 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7921 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7922
7923 It is an error to ask for the alignment of an incomplete type.
7924
7925
7926 @node Inline
7927 @section An Inline Function is As Fast As a Macro
7928 @cindex inline functions
7929 @cindex integrating function code
7930 @cindex open coding
7931 @cindex macros, inline alternative
7932
7933 By declaring a function inline, you can direct GCC to make
7934 calls to that function faster. One way GCC can achieve this is to
7935 integrate that function's code into the code for its callers. This
7936 makes execution faster by eliminating the function-call overhead; in
7937 addition, if any of the actual argument values are constant, their
7938 known values may permit simplifications at compile time so that not
7939 all of the inline function's code needs to be included. The effect on
7940 code size is less predictable; object code may be larger or smaller
7941 with function inlining, depending on the particular case. You can
7942 also direct GCC to try to integrate all ``simple enough'' functions
7943 into their callers with the option @option{-finline-functions}.
7944
7945 GCC implements three different semantics of declaring a function
7946 inline. One is available with @option{-std=gnu89} or
7947 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7948 on all inline declarations, another when
7949 @option{-std=c99},
7950 @option{-std=gnu99} or an option for a later C version is used
7951 (without @option{-fgnu89-inline}), and the third
7952 is used when compiling C++.
7953
7954 To declare a function inline, use the @code{inline} keyword in its
7955 declaration, like this:
7956
7957 @smallexample
7958 static inline int
7959 inc (int *a)
7960 @{
7961 return (*a)++;
7962 @}
7963 @end smallexample
7964
7965 If you are writing a header file to be included in ISO C90 programs, write
7966 @code{__inline__} instead of @code{inline}. @xref{Alternate Keywords}.
7967
7968 The three types of inlining behave similarly in two important cases:
7969 when the @code{inline} keyword is used on a @code{static} function,
7970 like the example above, and when a function is first declared without
7971 using the @code{inline} keyword and then is defined with
7972 @code{inline}, like this:
7973
7974 @smallexample
7975 extern int inc (int *a);
7976 inline int
7977 inc (int *a)
7978 @{
7979 return (*a)++;
7980 @}
7981 @end smallexample
7982
7983 In both of these common cases, the program behaves the same as if you
7984 had not used the @code{inline} keyword, except for its speed.
7985
7986 @cindex inline functions, omission of
7987 @opindex fkeep-inline-functions
7988 When a function is both inline and @code{static}, if all calls to the
7989 function are integrated into the caller, and the function's address is
7990 never used, then the function's own assembler code is never referenced.
7991 In this case, GCC does not actually output assembler code for the
7992 function, unless you specify the option @option{-fkeep-inline-functions}.
7993 If there is a nonintegrated call, then the function is compiled to
7994 assembler code as usual. The function must also be compiled as usual if
7995 the program refers to its address, because that cannot be inlined.
7996
7997 @opindex Winline
7998 Note that certain usages in a function definition can make it unsuitable
7999 for inline substitution. Among these usages are: variadic functions,
8000 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8001 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8002 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8003 @code{__builtin_apply_args}. Using @option{-Winline} warns when a
8004 function marked @code{inline} could not be substituted, and gives the
8005 reason for the failure.
8006
8007 @cindex automatic @code{inline} for C++ member fns
8008 @cindex @code{inline} automatic for C++ member fns
8009 @cindex member fns, automatically @code{inline}
8010 @cindex C++ member fns, automatically @code{inline}
8011 @opindex fno-default-inline
8012 As required by ISO C++, GCC considers member functions defined within
8013 the body of a class to be marked inline even if they are
8014 not explicitly declared with the @code{inline} keyword. You can
8015 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8016 Options,,Options Controlling C++ Dialect}.
8017
8018 GCC does not inline any functions when not optimizing unless you specify
8019 the @samp{always_inline} attribute for the function, like this:
8020
8021 @smallexample
8022 /* @r{Prototype.} */
8023 inline void foo (const char) __attribute__((always_inline));
8024 @end smallexample
8025
8026 The remainder of this section is specific to GNU C90 inlining.
8027
8028 @cindex non-static inline function
8029 When an inline function is not @code{static}, then the compiler must assume
8030 that there may be calls from other source files; since a global symbol can
8031 be defined only once in any program, the function must not be defined in
8032 the other source files, so the calls therein cannot be integrated.
8033 Therefore, a non-@code{static} inline function is always compiled on its
8034 own in the usual fashion.
8035
8036 If you specify both @code{inline} and @code{extern} in the function
8037 definition, then the definition is used only for inlining. In no case
8038 is the function compiled on its own, not even if you refer to its
8039 address explicitly. Such an address becomes an external reference, as
8040 if you had only declared the function, and had not defined it.
8041
8042 This combination of @code{inline} and @code{extern} has almost the
8043 effect of a macro. The way to use it is to put a function definition in
8044 a header file with these keywords, and put another copy of the
8045 definition (lacking @code{inline} and @code{extern}) in a library file.
8046 The definition in the header file causes most calls to the function
8047 to be inlined. If any uses of the function remain, they refer to
8048 the single copy in the library.
8049
8050 @node Volatiles
8051 @section When is a Volatile Object Accessed?
8052 @cindex accessing volatiles
8053 @cindex volatile read
8054 @cindex volatile write
8055 @cindex volatile access
8056
8057 C has the concept of volatile objects. These are normally accessed by
8058 pointers and used for accessing hardware or inter-thread
8059 communication. The standard encourages compilers to refrain from
8060 optimizations concerning accesses to volatile objects, but leaves it
8061 implementation defined as to what constitutes a volatile access. The
8062 minimum requirement is that at a sequence point all previous accesses
8063 to volatile objects have stabilized and no subsequent accesses have
8064 occurred. Thus an implementation is free to reorder and combine
8065 volatile accesses that occur between sequence points, but cannot do
8066 so for accesses across a sequence point. The use of volatile does
8067 not allow you to violate the restriction on updating objects multiple
8068 times between two sequence points.
8069
8070 Accesses to non-volatile objects are not ordered with respect to
8071 volatile accesses. You cannot use a volatile object as a memory
8072 barrier to order a sequence of writes to non-volatile memory. For
8073 instance:
8074
8075 @smallexample
8076 int *ptr = @var{something};
8077 volatile int vobj;
8078 *ptr = @var{something};
8079 vobj = 1;
8080 @end smallexample
8081
8082 @noindent
8083 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8084 that the write to @var{*ptr} occurs by the time the update
8085 of @var{vobj} happens. If you need this guarantee, you must use
8086 a stronger memory barrier such as:
8087
8088 @smallexample
8089 int *ptr = @var{something};
8090 volatile int vobj;
8091 *ptr = @var{something};
8092 asm volatile ("" : : : "memory");
8093 vobj = 1;
8094 @end smallexample
8095
8096 A scalar volatile object is read when it is accessed in a void context:
8097
8098 @smallexample
8099 volatile int *src = @var{somevalue};
8100 *src;
8101 @end smallexample
8102
8103 Such expressions are rvalues, and GCC implements this as a
8104 read of the volatile object being pointed to.
8105
8106 Assignments are also expressions and have an rvalue. However when
8107 assigning to a scalar volatile, the volatile object is not reread,
8108 regardless of whether the assignment expression's rvalue is used or
8109 not. If the assignment's rvalue is used, the value is that assigned
8110 to the volatile object. For instance, there is no read of @var{vobj}
8111 in all the following cases:
8112
8113 @smallexample
8114 int obj;
8115 volatile int vobj;
8116 vobj = @var{something};
8117 obj = vobj = @var{something};
8118 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8119 obj = (@var{something}, vobj = @var{anotherthing});
8120 @end smallexample
8121
8122 If you need to read the volatile object after an assignment has
8123 occurred, you must use a separate expression with an intervening
8124 sequence point.
8125
8126 As bit-fields are not individually addressable, volatile bit-fields may
8127 be implicitly read when written to, or when adjacent bit-fields are
8128 accessed. Bit-field operations may be optimized such that adjacent
8129 bit-fields are only partially accessed, if they straddle a storage unit
8130 boundary. For these reasons it is unwise to use volatile bit-fields to
8131 access hardware.
8132
8133 @node Using Assembly Language with C
8134 @section How to Use Inline Assembly Language in C Code
8135 @cindex @code{asm} keyword
8136 @cindex assembly language in C
8137 @cindex inline assembly language
8138 @cindex mixing assembly language and C
8139
8140 The @code{asm} keyword allows you to embed assembler instructions
8141 within C code. GCC provides two forms of inline @code{asm}
8142 statements. A @dfn{basic @code{asm}} statement is one with no
8143 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8144 statement (@pxref{Extended Asm}) includes one or more operands.
8145 The extended form is preferred for mixing C and assembly language
8146 within a function, but to include assembly language at
8147 top level you must use basic @code{asm}.
8148
8149 You can also use the @code{asm} keyword to override the assembler name
8150 for a C symbol, or to place a C variable in a specific register.
8151
8152 @menu
8153 * Basic Asm:: Inline assembler without operands.
8154 * Extended Asm:: Inline assembler with operands.
8155 * Constraints:: Constraints for @code{asm} operands
8156 * Asm Labels:: Specifying the assembler name to use for a C symbol.
8157 * Explicit Register Variables:: Defining variables residing in specified
8158 registers.
8159 * Size of an asm:: How GCC calculates the size of an @code{asm} block.
8160 @end menu
8161
8162 @node Basic Asm
8163 @subsection Basic Asm --- Assembler Instructions Without Operands
8164 @cindex basic @code{asm}
8165 @cindex assembly language in C, basic
8166
8167 A basic @code{asm} statement has the following syntax:
8168
8169 @example
8170 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8171 @end example
8172
8173 The @code{asm} keyword is a GNU extension.
8174 When writing code that can be compiled with @option{-ansi} and the
8175 various @option{-std} options, use @code{__asm__} instead of
8176 @code{asm} (@pxref{Alternate Keywords}).
8177
8178 @subsubheading Qualifiers
8179 @table @code
8180 @item volatile
8181 The optional @code{volatile} qualifier has no effect.
8182 All basic @code{asm} blocks are implicitly volatile.
8183 @end table
8184
8185 @subsubheading Parameters
8186 @table @var
8187
8188 @item AssemblerInstructions
8189 This is a literal string that specifies the assembler code. The string can
8190 contain any instructions recognized by the assembler, including directives.
8191 GCC does not parse the assembler instructions themselves and
8192 does not know what they mean or even whether they are valid assembler input.
8193
8194 You may place multiple assembler instructions together in a single @code{asm}
8195 string, separated by the characters normally used in assembly code for the
8196 system. A combination that works in most places is a newline to break the
8197 line, plus a tab character (written as @samp{\n\t}).
8198 Some assemblers allow semicolons as a line separator. However,
8199 note that some assembler dialects use semicolons to start a comment.
8200 @end table
8201
8202 @subsubheading Remarks
8203 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8204 smaller, safer, and more efficient code, and in most cases it is a
8205 better solution than basic @code{asm}. However, there are two
8206 situations where only basic @code{asm} can be used:
8207
8208 @itemize @bullet
8209 @item
8210 Extended @code{asm} statements have to be inside a C
8211 function, so to write inline assembly language at file scope (``top-level''),
8212 outside of C functions, you must use basic @code{asm}.
8213 You can use this technique to emit assembler directives,
8214 define assembly language macros that can be invoked elsewhere in the file,
8215 or write entire functions in assembly language.
8216
8217 @item
8218 Functions declared
8219 with the @code{naked} attribute also require basic @code{asm}
8220 (@pxref{Function Attributes}).
8221 @end itemize
8222
8223 Safely accessing C data and calling functions from basic @code{asm} is more
8224 complex than it may appear. To access C data, it is better to use extended
8225 @code{asm}.
8226
8227 Do not expect a sequence of @code{asm} statements to remain perfectly
8228 consecutive after compilation. If certain instructions need to remain
8229 consecutive in the output, put them in a single multi-instruction @code{asm}
8230 statement. Note that GCC's optimizers can move @code{asm} statements
8231 relative to other code, including across jumps.
8232
8233 @code{asm} statements may not perform jumps into other @code{asm} statements.
8234 GCC does not know about these jumps, and therefore cannot take
8235 account of them when deciding how to optimize. Jumps from @code{asm} to C
8236 labels are only supported in extended @code{asm}.
8237
8238 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8239 assembly code when optimizing. This can lead to unexpected duplicate
8240 symbol errors during compilation if your assembly code defines symbols or
8241 labels.
8242
8243 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8244 making it a potential source of incompatibilities between compilers. These
8245 incompatibilities may not produce compiler warnings/errors.
8246
8247 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8248 means there is no way to communicate to the compiler what is happening
8249 inside them. GCC has no visibility of symbols in the @code{asm} and may
8250 discard them as unreferenced. It also does not know about side effects of
8251 the assembler code, such as modifications to memory or registers. Unlike
8252 some compilers, GCC assumes that no changes to general purpose registers
8253 occur. This assumption may change in a future release.
8254
8255 To avoid complications from future changes to the semantics and the
8256 compatibility issues between compilers, consider replacing basic @code{asm}
8257 with extended @code{asm}. See
8258 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8259 from basic asm to extended asm} for information about how to perform this
8260 conversion.
8261
8262 The compiler copies the assembler instructions in a basic @code{asm}
8263 verbatim to the assembly language output file, without
8264 processing dialects or any of the @samp{%} operators that are available with
8265 extended @code{asm}. This results in minor differences between basic
8266 @code{asm} strings and extended @code{asm} templates. For example, to refer to
8267 registers you might use @samp{%eax} in basic @code{asm} and
8268 @samp{%%eax} in extended @code{asm}.
8269
8270 On targets such as x86 that support multiple assembler dialects,
8271 all basic @code{asm} blocks use the assembler dialect specified by the
8272 @option{-masm} command-line option (@pxref{x86 Options}).
8273 Basic @code{asm} provides no
8274 mechanism to provide different assembler strings for different dialects.
8275
8276 For basic @code{asm} with non-empty assembler string GCC assumes
8277 the assembler block does not change any general purpose registers,
8278 but it may read or write any globally accessible variable.
8279
8280 Here is an example of basic @code{asm} for i386:
8281
8282 @example
8283 /* Note that this code will not compile with -masm=intel */
8284 #define DebugBreak() asm("int $3")
8285 @end example
8286
8287 @node Extended Asm
8288 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8289 @cindex extended @code{asm}
8290 @cindex assembly language in C, extended
8291
8292 With extended @code{asm} you can read and write C variables from
8293 assembler and perform jumps from assembler code to C labels.
8294 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8295 the operand parameters after the assembler template:
8296
8297 @example
8298 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate}
8299 : @var{OutputOperands}
8300 @r{[} : @var{InputOperands}
8301 @r{[} : @var{Clobbers} @r{]} @r{]})
8302
8303 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate}
8304 :
8305 : @var{InputOperands}
8306 : @var{Clobbers}
8307 : @var{GotoLabels})
8308 @end example
8309
8310 The @code{asm} keyword is a GNU extension.
8311 When writing code that can be compiled with @option{-ansi} and the
8312 various @option{-std} options, use @code{__asm__} instead of
8313 @code{asm} (@pxref{Alternate Keywords}).
8314
8315 @subsubheading Qualifiers
8316 @table @code
8317
8318 @item volatile
8319 The typical use of extended @code{asm} statements is to manipulate input
8320 values to produce output values. However, your @code{asm} statements may
8321 also produce side effects. If so, you may need to use the @code{volatile}
8322 qualifier to disable certain optimizations. @xref{Volatile}.
8323
8324 @item goto
8325 This qualifier informs the compiler that the @code{asm} statement may
8326 perform a jump to one of the labels listed in the @var{GotoLabels}.
8327 @xref{GotoLabels}.
8328 @end table
8329
8330 @subsubheading Parameters
8331 @table @var
8332 @item AssemblerTemplate
8333 This is a literal string that is the template for the assembler code. It is a
8334 combination of fixed text and tokens that refer to the input, output,
8335 and goto parameters. @xref{AssemblerTemplate}.
8336
8337 @item OutputOperands
8338 A comma-separated list of the C variables modified by the instructions in the
8339 @var{AssemblerTemplate}. An empty list is permitted. @xref{OutputOperands}.
8340
8341 @item InputOperands
8342 A comma-separated list of C expressions read by the instructions in the
8343 @var{AssemblerTemplate}. An empty list is permitted. @xref{InputOperands}.
8344
8345 @item Clobbers
8346 A comma-separated list of registers or other values changed by the
8347 @var{AssemblerTemplate}, beyond those listed as outputs.
8348 An empty list is permitted. @xref{Clobbers and Scratch Registers}.
8349
8350 @item GotoLabels
8351 When you are using the @code{goto} form of @code{asm}, this section contains
8352 the list of all C labels to which the code in the
8353 @var{AssemblerTemplate} may jump.
8354 @xref{GotoLabels}.
8355
8356 @code{asm} statements may not perform jumps into other @code{asm} statements,
8357 only to the listed @var{GotoLabels}.
8358 GCC's optimizers do not know about other jumps; therefore they cannot take
8359 account of them when deciding how to optimize.
8360 @end table
8361
8362 The total number of input + output + goto operands is limited to 30.
8363
8364 @subsubheading Remarks
8365 The @code{asm} statement allows you to include assembly instructions directly
8366 within C code. This may help you to maximize performance in time-sensitive
8367 code or to access assembly instructions that are not readily available to C
8368 programs.
8369
8370 Note that extended @code{asm} statements must be inside a function. Only
8371 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8372 Functions declared with the @code{naked} attribute also require basic
8373 @code{asm} (@pxref{Function Attributes}).
8374
8375 While the uses of @code{asm} are many and varied, it may help to think of an
8376 @code{asm} statement as a series of low-level instructions that convert input
8377 parameters to output parameters. So a simple (if not particularly useful)
8378 example for i386 using @code{asm} might look like this:
8379
8380 @example
8381 int src = 1;
8382 int dst;
8383
8384 asm ("mov %1, %0\n\t"
8385 "add $1, %0"
8386 : "=r" (dst)
8387 : "r" (src));
8388
8389 printf("%d\n", dst);
8390 @end example
8391
8392 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8393
8394 @anchor{Volatile}
8395 @subsubsection Volatile
8396 @cindex volatile @code{asm}
8397 @cindex @code{asm} volatile
8398
8399 GCC's optimizers sometimes discard @code{asm} statements if they determine
8400 there is no need for the output variables. Also, the optimizers may move
8401 code out of loops if they believe that the code will always return the same
8402 result (i.e. none of its input values change between calls). Using the
8403 @code{volatile} qualifier disables these optimizations. @code{asm} statements
8404 that have no output operands, including @code{asm goto} statements,
8405 are implicitly volatile.
8406
8407 This i386 code demonstrates a case that does not use (or require) the
8408 @code{volatile} qualifier. If it is performing assertion checking, this code
8409 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is
8410 unreferenced by any code. As a result, the optimizers can discard the
8411 @code{asm} statement, which in turn removes the need for the entire
8412 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it
8413 isn't needed you allow the optimizers to produce the most efficient code
8414 possible.
8415
8416 @example
8417 void DoCheck(uint32_t dwSomeValue)
8418 @{
8419 uint32_t dwRes;
8420
8421 // Assumes dwSomeValue is not zero.
8422 asm ("bsfl %1,%0"
8423 : "=r" (dwRes)
8424 : "r" (dwSomeValue)
8425 : "cc");
8426
8427 assert(dwRes > 3);
8428 @}
8429 @end example
8430
8431 The next example shows a case where the optimizers can recognize that the input
8432 (@code{dwSomeValue}) never changes during the execution of the function and can
8433 therefore move the @code{asm} outside the loop to produce more efficient code.
8434 Again, using @code{volatile} disables this type of optimization.
8435
8436 @example
8437 void do_print(uint32_t dwSomeValue)
8438 @{
8439 uint32_t dwRes;
8440
8441 for (uint32_t x=0; x < 5; x++)
8442 @{
8443 // Assumes dwSomeValue is not zero.
8444 asm ("bsfl %1,%0"
8445 : "=r" (dwRes)
8446 : "r" (dwSomeValue)
8447 : "cc");
8448
8449 printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8450 @}
8451 @}
8452 @end example
8453
8454 The following example demonstrates a case where you need to use the
8455 @code{volatile} qualifier.
8456 It uses the x86 @code{rdtsc} instruction, which reads
8457 the computer's time-stamp counter. Without the @code{volatile} qualifier,
8458 the optimizers might assume that the @code{asm} block will always return the
8459 same value and therefore optimize away the second call.
8460
8461 @example
8462 uint64_t msr;
8463
8464 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8465 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8466 "or %%rdx, %0" // 'Or' in the lower bits.
8467 : "=a" (msr)
8468 :
8469 : "rdx");
8470
8471 printf("msr: %llx\n", msr);
8472
8473 // Do other work...
8474
8475 // Reprint the timestamp
8476 asm volatile ( "rdtsc\n\t" // Returns the time in EDX:EAX.
8477 "shl $32, %%rdx\n\t" // Shift the upper bits left.
8478 "or %%rdx, %0" // 'Or' in the lower bits.
8479 : "=a" (msr)
8480 :
8481 : "rdx");
8482
8483 printf("msr: %llx\n", msr);
8484 @end example
8485
8486 GCC's optimizers do not treat this code like the non-volatile code in the
8487 earlier examples. They do not move it out of loops or omit it on the
8488 assumption that the result from a previous call is still valid.
8489
8490 Note that the compiler can move even volatile @code{asm} instructions relative
8491 to other code, including across jump instructions. For example, on many
8492 targets there is a system register that controls the rounding mode of
8493 floating-point operations. Setting it with a volatile @code{asm}, as in the
8494 following PowerPC example, does not work reliably.
8495
8496 @example
8497 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8498 sum = x + y;
8499 @end example
8500
8501 The compiler may move the addition back before the volatile @code{asm}. To
8502 make it work as expected, add an artificial dependency to the @code{asm} by
8503 referencing a variable in the subsequent code, for example:
8504
8505 @example
8506 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8507 sum = x + y;
8508 @end example
8509
8510 Under certain circumstances, GCC may duplicate (or remove duplicates of) your
8511 assembly code when optimizing. This can lead to unexpected duplicate symbol
8512 errors during compilation if your asm code defines symbols or labels.
8513 Using @samp{%=}
8514 (@pxref{AssemblerTemplate}) may help resolve this problem.
8515
8516 @anchor{AssemblerTemplate}
8517 @subsubsection Assembler Template
8518 @cindex @code{asm} assembler template
8519
8520 An assembler template is a literal string containing assembler instructions.
8521 The compiler replaces tokens in the template that refer
8522 to inputs, outputs, and goto labels,
8523 and then outputs the resulting string to the assembler. The
8524 string can contain any instructions recognized by the assembler, including
8525 directives. GCC does not parse the assembler instructions
8526 themselves and does not know what they mean or even whether they are valid
8527 assembler input. However, it does count the statements
8528 (@pxref{Size of an asm}).
8529
8530 You may place multiple assembler instructions together in a single @code{asm}
8531 string, separated by the characters normally used in assembly code for the
8532 system. A combination that works in most places is a newline to break the
8533 line, plus a tab character to move to the instruction field (written as
8534 @samp{\n\t}).
8535 Some assemblers allow semicolons as a line separator. However, note
8536 that some assembler dialects use semicolons to start a comment.
8537
8538 Do not expect a sequence of @code{asm} statements to remain perfectly
8539 consecutive after compilation, even when you are using the @code{volatile}
8540 qualifier. If certain instructions need to remain consecutive in the output,
8541 put them in a single multi-instruction asm statement.
8542
8543 Accessing data from C programs without using input/output operands (such as
8544 by using global symbols directly from the assembler template) may not work as
8545 expected. Similarly, calling functions directly from an assembler template
8546 requires a detailed understanding of the target assembler and ABI.
8547
8548 Since GCC does not parse the assembler template,
8549 it has no visibility of any
8550 symbols it references. This may result in GCC discarding those symbols as
8551 unreferenced unless they are also listed as input, output, or goto operands.
8552
8553 @subsubheading Special format strings
8554
8555 In addition to the tokens described by the input, output, and goto operands,
8556 these tokens have special meanings in the assembler template:
8557
8558 @table @samp
8559 @item %%
8560 Outputs a single @samp{%} into the assembler code.
8561
8562 @item %=
8563 Outputs a number that is unique to each instance of the @code{asm}
8564 statement in the entire compilation. This option is useful when creating local
8565 labels and referring to them multiple times in a single template that
8566 generates multiple assembler instructions.
8567
8568 @item %@{
8569 @itemx %|
8570 @itemx %@}
8571 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8572 into the assembler code. When unescaped, these characters have special
8573 meaning to indicate multiple assembler dialects, as described below.
8574 @end table
8575
8576 @subsubheading Multiple assembler dialects in @code{asm} templates
8577
8578 On targets such as x86, GCC supports multiple assembler dialects.
8579 The @option{-masm} option controls which dialect GCC uses as its
8580 default for inline assembler. The target-specific documentation for the
8581 @option{-masm} option contains the list of supported dialects, as well as the
8582 default dialect if the option is not specified. This information may be
8583 important to understand, since assembler code that works correctly when
8584 compiled using one dialect will likely fail if compiled using another.
8585 @xref{x86 Options}.
8586
8587 If your code needs to support multiple assembler dialects (for example, if
8588 you are writing public headers that need to support a variety of compilation
8589 options), use constructs of this form:
8590
8591 @example
8592 @{ dialect0 | dialect1 | dialect2... @}
8593 @end example
8594
8595 This construct outputs @code{dialect0}
8596 when using dialect #0 to compile the code,
8597 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the
8598 braces than the number of dialects the compiler supports, the construct
8599 outputs nothing.
8600
8601 For example, if an x86 compiler supports two dialects
8602 (@samp{att}, @samp{intel}), an
8603 assembler template such as this:
8604
8605 @example
8606 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8607 @end example
8608
8609 @noindent
8610 is equivalent to one of
8611
8612 @example
8613 "btl %[Offset],%[Base] ; jc %l2" @r{/* att dialect */}
8614 "bt %[Base],%[Offset]; jc %l2" @r{/* intel dialect */}
8615 @end example
8616
8617 Using that same compiler, this code:
8618
8619 @example
8620 "xchg@{l@}\t@{%%@}ebx, %1"
8621 @end example
8622
8623 @noindent
8624 corresponds to either
8625
8626 @example
8627 "xchgl\t%%ebx, %1" @r{/* att dialect */}
8628 "xchg\tebx, %1" @r{/* intel dialect */}
8629 @end example
8630
8631 There is no support for nesting dialect alternatives.
8632
8633 @anchor{OutputOperands}
8634 @subsubsection Output Operands
8635 @cindex @code{asm} output operands
8636
8637 An @code{asm} statement has zero or more output operands indicating the names
8638 of C variables modified by the assembler code.
8639
8640 In this i386 example, @code{old} (referred to in the template string as
8641 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset}
8642 (@code{%2}) is an input:
8643
8644 @example
8645 bool old;
8646
8647 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8648 "sbb %0,%0" // Use the CF to calculate old.
8649 : "=r" (old), "+rm" (*Base)
8650 : "Ir" (Offset)
8651 : "cc");
8652
8653 return old;
8654 @end example
8655
8656 Operands are separated by commas. Each operand has this format:
8657
8658 @example
8659 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8660 @end example
8661
8662 @table @var
8663 @item asmSymbolicName
8664 Specifies a symbolic name for the operand.
8665 Reference the name in the assembler template
8666 by enclosing it in square brackets
8667 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8668 that contains the definition. Any valid C variable name is acceptable,
8669 including names already defined in the surrounding code. No two operands
8670 within the same @code{asm} statement can use the same symbolic name.
8671
8672 When not using an @var{asmSymbolicName}, use the (zero-based) position
8673 of the operand
8674 in the list of operands in the assembler template. For example if there are
8675 three output operands, use @samp{%0} in the template to refer to the first,
8676 @samp{%1} for the second, and @samp{%2} for the third.
8677
8678 @item constraint
8679 A string constant specifying constraints on the placement of the operand;
8680 @xref{Constraints}, for details.
8681
8682 Output constraints must begin with either @samp{=} (a variable overwriting an
8683 existing value) or @samp{+} (when reading and writing). When using
8684 @samp{=}, do not assume the location contains the existing value
8685 on entry to the @code{asm}, except
8686 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8687
8688 After the prefix, there must be one or more additional constraints
8689 (@pxref{Constraints}) that describe where the value resides. Common
8690 constraints include @samp{r} for register and @samp{m} for memory.
8691 When you list more than one possible location (for example, @code{"=rm"}),
8692 the compiler chooses the most efficient one based on the current context.
8693 If you list as many alternates as the @code{asm} statement allows, you permit
8694 the optimizers to produce the best possible code.
8695 If you must use a specific register, but your Machine Constraints do not
8696 provide sufficient control to select the specific register you want,
8697 local register variables may provide a solution (@pxref{Local Register
8698 Variables}).
8699
8700 @item cvariablename
8701 Specifies a C lvalue expression to hold the output, typically a variable name.
8702 The enclosing parentheses are a required part of the syntax.
8703
8704 @end table
8705
8706 When the compiler selects the registers to use to
8707 represent the output operands, it does not use any of the clobbered registers
8708 (@pxref{Clobbers and Scratch Registers}).
8709
8710 Output operand expressions must be lvalues. The compiler cannot check whether
8711 the operands have data types that are reasonable for the instruction being
8712 executed. For output expressions that are not directly addressable (for
8713 example a bit-field), the constraint must allow a register. In that case, GCC
8714 uses the register as the output of the @code{asm}, and then stores that
8715 register into the output.
8716
8717 Operands using the @samp{+} constraint modifier count as two operands
8718 (that is, both as input and output) towards the total maximum of 30 operands
8719 per @code{asm} statement.
8720
8721 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8722 operands that must not overlap an input. Otherwise,
8723 GCC may allocate the output operand in the same register as an unrelated
8724 input operand, on the assumption that the assembler code consumes its
8725 inputs before producing outputs. This assumption may be false if the assembler
8726 code actually consists of more than one instruction.
8727
8728 The same problem can occur if one output parameter (@var{a}) allows a register
8729 constraint and another output parameter (@var{b}) allows a memory constraint.
8730 The code generated by GCC to access the memory address in @var{b} can contain
8731 registers which @emph{might} be shared by @var{a}, and GCC considers those
8732 registers to be inputs to the asm. As above, GCC assumes that such input
8733 registers are consumed before any outputs are written. This assumption may
8734 result in incorrect behavior if the asm writes to @var{a} before using
8735 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8736 ensures that modifying @var{a} does not affect the address referenced by
8737 @var{b}. Otherwise, the location of @var{b}
8738 is undefined if @var{a} is modified before using @var{b}.
8739
8740 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8741 instead of simply @samp{%2}). Typically these qualifiers are hardware
8742 dependent. The list of supported modifiers for x86 is found at
8743 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8744
8745 If the C code that follows the @code{asm} makes no use of any of the output
8746 operands, use @code{volatile} for the @code{asm} statement to prevent the
8747 optimizers from discarding the @code{asm} statement as unneeded
8748 (see @ref{Volatile}).
8749
8750 This code makes no use of the optional @var{asmSymbolicName}. Therefore it
8751 references the first output operand as @code{%0} (were there a second, it
8752 would be @code{%1}, etc). The number of the first input operand is one greater
8753 than that of the last output operand. In this i386 example, that makes
8754 @code{Mask} referenced as @code{%1}:
8755
8756 @example
8757 uint32_t Mask = 1234;
8758 uint32_t Index;
8759
8760 asm ("bsfl %1, %0"
8761 : "=r" (Index)
8762 : "r" (Mask)
8763 : "cc");
8764 @end example
8765
8766 That code overwrites the variable @code{Index} (@samp{=}),
8767 placing the value in a register (@samp{r}).
8768 Using the generic @samp{r} constraint instead of a constraint for a specific
8769 register allows the compiler to pick the register to use, which can result
8770 in more efficient code. This may not be possible if an assembler instruction
8771 requires a specific register.
8772
8773 The following i386 example uses the @var{asmSymbolicName} syntax.
8774 It produces the
8775 same result as the code above, but some may consider it more readable or more
8776 maintainable since reordering index numbers is not necessary when adding or
8777 removing operands. The names @code{aIndex} and @code{aMask}
8778 are only used in this example to emphasize which
8779 names get used where.
8780 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8781
8782 @example
8783 uint32_t Mask = 1234;
8784 uint32_t Index;
8785
8786 asm ("bsfl %[aMask], %[aIndex]"
8787 : [aIndex] "=r" (Index)
8788 : [aMask] "r" (Mask)
8789 : "cc");
8790 @end example
8791
8792 Here are some more examples of output operands.
8793
8794 @example
8795 uint32_t c = 1;
8796 uint32_t d;
8797 uint32_t *e = &c;
8798
8799 asm ("mov %[e], %[d]"
8800 : [d] "=rm" (d)
8801 : [e] "rm" (*e));
8802 @end example
8803
8804 Here, @code{d} may either be in a register or in memory. Since the compiler
8805 might already have the current value of the @code{uint32_t} location
8806 pointed to by @code{e}
8807 in a register, you can enable it to choose the best location
8808 for @code{d} by specifying both constraints.
8809
8810 @anchor{FlagOutputOperands}
8811 @subsubsection Flag Output Operands
8812 @cindex @code{asm} flag output operands
8813
8814 Some targets have a special register that holds the ``flags'' for the
8815 result of an operation or comparison. Normally, the contents of that
8816 register are either unmodifed by the asm, or the asm is considered to
8817 clobber the contents.
8818
8819 On some targets, a special form of output operand exists by which
8820 conditions in the flags register may be outputs of the asm. The set of
8821 conditions supported are target specific, but the general rule is that
8822 the output variable must be a scalar integer, and the value is boolean.
8823 When supported, the target defines the preprocessor symbol
8824 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8825
8826 Because of the special nature of the flag output operands, the constraint
8827 may not include alternatives.
8828
8829 Most often, the target has only one flags register, and thus is an implied
8830 operand of many instructions. In this case, the operand should not be
8831 referenced within the assembler template via @code{%0} etc, as there's
8832 no corresponding text in the assembly language.
8833
8834 @table @asis
8835 @item x86 family
8836 The flag output constraints for the x86 family are of the form
8837 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8838 conditions defined in the ISA manual for @code{j@var{cc}} or
8839 @code{set@var{cc}}.
8840
8841 @table @code
8842 @item a
8843 ``above'' or unsigned greater than
8844 @item ae
8845 ``above or equal'' or unsigned greater than or equal
8846 @item b
8847 ``below'' or unsigned less than
8848 @item be
8849 ``below or equal'' or unsigned less than or equal
8850 @item c
8851 carry flag set
8852 @item e
8853 @itemx z
8854 ``equal'' or zero flag set
8855 @item g
8856 signed greater than
8857 @item ge
8858 signed greater than or equal
8859 @item l
8860 signed less than
8861 @item le
8862 signed less than or equal
8863 @item o
8864 overflow flag set
8865 @item p
8866 parity flag set
8867 @item s
8868 sign flag set
8869 @item na
8870 @itemx nae
8871 @itemx nb
8872 @itemx nbe
8873 @itemx nc
8874 @itemx ne
8875 @itemx ng
8876 @itemx nge
8877 @itemx nl
8878 @itemx nle
8879 @itemx no
8880 @itemx np
8881 @itemx ns
8882 @itemx nz
8883 ``not'' @var{flag}, or inverted versions of those above
8884 @end table
8885
8886 @end table
8887
8888 @anchor{InputOperands}
8889 @subsubsection Input Operands
8890 @cindex @code{asm} input operands
8891 @cindex @code{asm} expressions
8892
8893 Input operands make values from C variables and expressions available to the
8894 assembly code.
8895
8896 Operands are separated by commas. Each operand has this format:
8897
8898 @example
8899 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8900 @end example
8901
8902 @table @var
8903 @item asmSymbolicName
8904 Specifies a symbolic name for the operand.
8905 Reference the name in the assembler template
8906 by enclosing it in square brackets
8907 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement
8908 that contains the definition. Any valid C variable name is acceptable,
8909 including names already defined in the surrounding code. No two operands
8910 within the same @code{asm} statement can use the same symbolic name.
8911
8912 When not using an @var{asmSymbolicName}, use the (zero-based) position
8913 of the operand
8914 in the list of operands in the assembler template. For example if there are
8915 two output operands and three inputs,
8916 use @samp{%2} in the template to refer to the first input operand,
8917 @samp{%3} for the second, and @samp{%4} for the third.
8918
8919 @item constraint
8920 A string constant specifying constraints on the placement of the operand;
8921 @xref{Constraints}, for details.
8922
8923 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8924 When you list more than one possible location (for example, @samp{"irm"}),
8925 the compiler chooses the most efficient one based on the current context.
8926 If you must use a specific register, but your Machine Constraints do not
8927 provide sufficient control to select the specific register you want,
8928 local register variables may provide a solution (@pxref{Local Register
8929 Variables}).
8930
8931 Input constraints can also be digits (for example, @code{"0"}). This indicates
8932 that the specified input must be in the same place as the output constraint
8933 at the (zero-based) index in the output constraint list.
8934 When using @var{asmSymbolicName} syntax for the output operands,
8935 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8936
8937 @item cexpression
8938 This is the C variable or expression being passed to the @code{asm} statement
8939 as input. The enclosing parentheses are a required part of the syntax.
8940
8941 @end table
8942
8943 When the compiler selects the registers to use to represent the input
8944 operands, it does not use any of the clobbered registers
8945 (@pxref{Clobbers and Scratch Registers}).
8946
8947 If there are no output operands but there are input operands, place two
8948 consecutive colons where the output operands would go:
8949
8950 @example
8951 __asm__ ("some instructions"
8952 : /* No outputs. */
8953 : "r" (Offset / 8));
8954 @end example
8955
8956 @strong{Warning:} Do @emph{not} modify the contents of input-only operands
8957 (except for inputs tied to outputs). The compiler assumes that on exit from
8958 the @code{asm} statement these operands contain the same values as they
8959 had before executing the statement.
8960 It is @emph{not} possible to use clobbers
8961 to inform the compiler that the values in these inputs are changing. One
8962 common work-around is to tie the changing input variable to an output variable
8963 that never gets used. Note, however, that if the code that follows the
8964 @code{asm} statement makes no use of any of the output operands, the GCC
8965 optimizers may discard the @code{asm} statement as unneeded
8966 (see @ref{Volatile}).
8967
8968 @code{asm} supports operand modifiers on operands (for example @samp{%k2}
8969 instead of simply @samp{%2}). Typically these qualifiers are hardware
8970 dependent. The list of supported modifiers for x86 is found at
8971 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8972
8973 In this example using the fictitious @code{combine} instruction, the
8974 constraint @code{"0"} for input operand 1 says that it must occupy the same
8975 location as output operand 0. Only input operands may use numbers in
8976 constraints, and they must each refer to an output operand. Only a number (or
8977 the symbolic assembler name) in the constraint can guarantee that one operand
8978 is in the same place as another. The mere fact that @code{foo} is the value of
8979 both operands is not enough to guarantee that they are in the same place in
8980 the generated assembler code.
8981
8982 @example
8983 asm ("combine %2, %0"
8984 : "=r" (foo)
8985 : "0" (foo), "g" (bar));
8986 @end example
8987
8988 Here is an example using symbolic names.
8989
8990 @example
8991 asm ("cmoveq %1, %2, %[result]"
8992 : [result] "=r"(result)
8993 : "r" (test), "r" (new), "[result]" (old));
8994 @end example
8995
8996 @anchor{Clobbers and Scratch Registers}
8997 @subsubsection Clobbers and Scratch Registers
8998 @cindex @code{asm} clobbers
8999 @cindex @code{asm} scratch registers
9000
9001 While the compiler is aware of changes to entries listed in the output
9002 operands, the inline @code{asm} code may modify more than just the outputs. For
9003 example, calculations may require additional registers, or the processor may
9004 overwrite a register as a side effect of a particular assembler instruction.
9005 In order to inform the compiler of these changes, list them in the clobber
9006 list. Clobber list items are either register names or the special clobbers
9007 (listed below). Each clobber list item is a string constant
9008 enclosed in double quotes and separated by commas.
9009
9010 Clobber descriptions may not in any way overlap with an input or output
9011 operand. For example, you may not have an operand describing a register class
9012 with one member when listing that register in the clobber list. Variables
9013 declared to live in specific registers (@pxref{Explicit Register
9014 Variables}) and used
9015 as @code{asm} input or output operands must have no part mentioned in the
9016 clobber description. In particular, there is no way to specify that input
9017 operands get modified without also specifying them as output operands.
9018
9019 When the compiler selects which registers to use to represent input and output
9020 operands, it does not use any of the clobbered registers. As a result,
9021 clobbered registers are available for any use in the assembler code.
9022
9023 Here is a realistic example for the VAX showing the use of clobbered
9024 registers:
9025
9026 @example
9027 asm volatile ("movc3 %0, %1, %2"
9028 : /* No outputs. */
9029 : "g" (from), "g" (to), "g" (count)
9030 : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9031 @end example
9032
9033 Also, there are two special clobber arguments:
9034
9035 @table @code
9036 @item "cc"
9037 The @code{"cc"} clobber indicates that the assembler code modifies the flags
9038 register. On some machines, GCC represents the condition codes as a specific
9039 hardware register; @code{"cc"} serves to name this register.
9040 On other machines, condition code handling is different,
9041 and specifying @code{"cc"} has no effect. But
9042 it is valid no matter what the target.
9043
9044 @item "memory"
9045 The @code{"memory"} clobber tells the compiler that the assembly code
9046 performs memory
9047 reads or writes to items other than those listed in the input and output
9048 operands (for example, accessing the memory pointed to by one of the input
9049 parameters). To ensure memory contains correct values, GCC may need to flush
9050 specific register values to memory before executing the @code{asm}. Further,
9051 the compiler does not assume that any values read from memory before an
9052 @code{asm} remain unchanged after that @code{asm}; it reloads them as
9053 needed.
9054 Using the @code{"memory"} clobber effectively forms a read/write
9055 memory barrier for the compiler.
9056
9057 Note that this clobber does not prevent the @emph{processor} from doing
9058 speculative reads past the @code{asm} statement. To prevent that, you need
9059 processor-specific fence instructions.
9060
9061 @end table
9062
9063 Flushing registers to memory has performance implications and may be
9064 an issue for time-sensitive code. You can provide better information
9065 to GCC to avoid this, as shown in the following examples. At a
9066 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9067 need to be flushed.
9068
9069 Here is a fictitious sum of squares instruction, that takes two
9070 pointers to floating point values in memory and produces a floating
9071 point register output.
9072 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9073 parameters, once to specify memory accessed, and once to specify a
9074 base register used by the @code{asm}. You won't normally be wasting a
9075 register by doing this as GCC can use the same register for both
9076 purposes. However, it would be foolish to use both @code{%1} and
9077 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9078 same. In fact, @code{%3} may well not be a register. It might be a
9079 symbolic memory reference to the object pointed to by @code{x}.
9080
9081 @smallexample
9082 asm ("sumsq %0, %1, %2"
9083 : "+f" (result)
9084 : "r" (x), "r" (y), "m" (*x), "m" (*y));
9085 @end smallexample
9086
9087 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9088 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9089 must be specified as input/output because the @code{asm} modifies
9090 them.
9091
9092 @smallexample
9093 asm ("vecmul %0, %1, %2"
9094 : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9095 : "m" (*x), "m" (*y));
9096 @end smallexample
9097
9098 An x86 example where the string memory argument is of unknown length.
9099
9100 @smallexample
9101 asm("repne scasb"
9102 : "=c" (count), "+D" (p)
9103 : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9104 @end smallexample
9105
9106 If you know the above will only be reading a ten byte array then you
9107 could instead use a memory input like:
9108 @code{"m" (*(const char (*)[10]) p)}.
9109
9110 Here is an example of a PowerPC vector scale implemented in assembly,
9111 complete with vector and condition code clobbers, and some initialized
9112 offset registers that are unchanged by the @code{asm}.
9113
9114 @smallexample
9115 void
9116 dscal (size_t n, double *x, double alpha)
9117 @{
9118 asm ("/* lots of asm here */"
9119 : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9120 : "d" (alpha), "b" (32), "b" (48), "b" (64),
9121 "b" (80), "b" (96), "b" (112)
9122 : "cr0",
9123 "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9124 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9125 @}
9126 @end smallexample
9127
9128 Rather than allocating fixed registers via clobbers to provide scratch
9129 registers for an @code{asm} statement, an alternative is to define a
9130 variable and make it an early-clobber output as with @code{a2} and
9131 @code{a3} in the example below. This gives the compiler register
9132 allocator more freedom. You can also define a variable and make it an
9133 output tied to an input as with @code{a0} and @code{a1}, tied
9134 respectively to @code{ap} and @code{lda}. Of course, with tied
9135 outputs your @code{asm} can't use the input value after modifying the
9136 output register since they are one and the same register. What's
9137 more, if you omit the early-clobber on the output, it is possible that
9138 GCC might allocate the same register to another of the inputs if GCC
9139 could prove they had the same value on entry to the @code{asm}. This
9140 is why @code{a1} has an early-clobber. Its tied input, @code{lda}
9141 might conceivably be known to have the value 16 and without an
9142 early-clobber share the same register as @code{%11}. On the other
9143 hand, @code{ap} can't be the same as any of the other inputs, so an
9144 early-clobber on @code{a0} is not needed. It is also not desirable in
9145 this case. An early-clobber on @code{a0} would cause GCC to allocate
9146 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9147 input. Note that tying an input to an output is the way to set up an
9148 initialized temporary register modified by an @code{asm} statement.
9149 An input not tied to an output is assumed by GCC to be unchanged, for
9150 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9151 use that register in following code if the value 16 happened to be
9152 needed. You can even use a normal @code{asm} output for a scratch if
9153 all inputs that might share the same register are consumed before the
9154 scratch is used. The VSX registers clobbered by the @code{asm}
9155 statement could have used this technique except for GCC's limit on the
9156 number of @code{asm} parameters.
9157
9158 @smallexample
9159 static void
9160 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9161 const double *x, double *y, double alpha)
9162 @{
9163 double *a0;
9164 double *a1;
9165 double *a2;
9166 double *a3;
9167
9168 __asm__
9169 (
9170 /* lots of asm here */
9171 "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9172 "#a0=%3 a1=%4 a2=%5 a3=%6"
9173 :
9174 "+m" (*(double (*)[n]) y),
9175 "+&r" (n), // 1
9176 "+b" (y), // 2
9177 "=b" (a0), // 3
9178 "=&b" (a1), // 4
9179 "=&b" (a2), // 5
9180 "=&b" (a3) // 6
9181 :
9182 "m" (*(const double (*)[n]) x),
9183 "m" (*(const double (*)[]) ap),
9184 "d" (alpha), // 9
9185 "r" (x), // 10
9186 "b" (16), // 11
9187 "3" (ap), // 12
9188 "4" (lda) // 13
9189 :
9190 "cr0",
9191 "vs32","vs33","vs34","vs35","vs36","vs37",
9192 "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9193 );
9194 @}
9195 @end smallexample
9196
9197 @anchor{GotoLabels}
9198 @subsubsection Goto Labels
9199 @cindex @code{asm} goto labels
9200
9201 @code{asm goto} allows assembly code to jump to one or more C labels. The
9202 @var{GotoLabels} section in an @code{asm goto} statement contains
9203 a comma-separated
9204 list of all C labels to which the assembler code may jump. GCC assumes that
9205 @code{asm} execution falls through to the next statement (if this is not the
9206 case, consider using the @code{__builtin_unreachable} intrinsic after the
9207 @code{asm} statement). Optimization of @code{asm goto} may be improved by
9208 using the @code{hot} and @code{cold} label attributes (@pxref{Label
9209 Attributes}).
9210
9211 An @code{asm goto} statement cannot have outputs.
9212 This is due to an internal restriction of
9213 the compiler: control transfer instructions cannot have outputs.
9214 If the assembler code does modify anything, use the @code{"memory"} clobber
9215 to force the
9216 optimizers to flush all register values to memory and reload them if
9217 necessary after the @code{asm} statement.
9218
9219 Also note that an @code{asm goto} statement is always implicitly
9220 considered volatile.
9221
9222 To reference a label in the assembler template,
9223 prefix it with @samp{%l} (lowercase @samp{L}) followed
9224 by its (zero-based) position in @var{GotoLabels} plus the number of input
9225 operands. For example, if the @code{asm} has three inputs and references two
9226 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9227
9228 Alternately, you can reference labels using the actual C label name enclosed
9229 in brackets. For example, to reference a label named @code{carry}, you can
9230 use @samp{%l[carry]}. The label must still be listed in the @var{GotoLabels}
9231 section when using this approach.
9232
9233 Here is an example of @code{asm goto} for i386:
9234
9235 @example
9236 asm goto (
9237 "btl %1, %0\n\t"
9238 "jc %l2"
9239 : /* No outputs. */
9240 : "r" (p1), "r" (p2)
9241 : "cc"
9242 : carry);
9243
9244 return 0;
9245
9246 carry:
9247 return 1;
9248 @end example
9249
9250 The following example shows an @code{asm goto} that uses a memory clobber.
9251
9252 @example
9253 int frob(int x)
9254 @{
9255 int y;
9256 asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9257 : /* No outputs. */
9258 : "r"(x), "r"(&y)
9259 : "r5", "memory"
9260 : error);
9261 return y;
9262 error:
9263 return -1;
9264 @}
9265 @end example
9266
9267 @anchor{x86Operandmodifiers}
9268 @subsubsection x86 Operand Modifiers
9269
9270 References to input, output, and goto operands in the assembler template
9271 of extended @code{asm} statements can use
9272 modifiers to affect the way the operands are formatted in
9273 the code output to the assembler. For example, the
9274 following code uses the @samp{h} and @samp{b} modifiers for x86:
9275
9276 @example
9277 uint16_t num;
9278 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9279 @end example
9280
9281 @noindent
9282 These modifiers generate this assembler code:
9283
9284 @example
9285 xchg %ah, %al
9286 @end example
9287
9288 The rest of this discussion uses the following code for illustrative purposes.
9289
9290 @example
9291 int main()
9292 @{
9293 int iInt = 1;
9294
9295 top:
9296
9297 asm volatile goto ("some assembler instructions here"
9298 : /* No outputs. */
9299 : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9300 : /* No clobbers. */
9301 : top);
9302 @}
9303 @end example
9304
9305 With no modifiers, this is what the output from the operands would be
9306 for the @samp{att} and @samp{intel} dialects of assembler:
9307
9308 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9309 @headitem Operand @tab @samp{att} @tab @samp{intel}
9310 @item @code{%0}
9311 @tab @code{%eax}
9312 @tab @code{eax}
9313 @item @code{%1}
9314 @tab @code{$2}
9315 @tab @code{2}
9316 @item @code{%3}
9317 @tab @code{$.L3}
9318 @tab @code{OFFSET FLAT:.L3}
9319 @end multitable
9320
9321 The table below shows the list of supported modifiers and their effects.
9322
9323 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9324 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9325 @item @code{a}
9326 @tab Print an absolute memory reference.
9327 @tab @code{%A0}
9328 @tab @code{*%rax}
9329 @tab @code{rax}
9330 @item @code{b}
9331 @tab Print the QImode name of the register.
9332 @tab @code{%b0}
9333 @tab @code{%al}
9334 @tab @code{al}
9335 @item @code{c}
9336 @tab Require a constant operand and print the constant expression with no punctuation.
9337 @tab @code{%c1}
9338 @tab @code{2}
9339 @tab @code{2}
9340 @item @code{E}
9341 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9342 Otherwise mode is unspecified (VOIDmode).
9343 @tab @code{%E1}
9344 @tab @code{%(rax)}
9345 @tab @code{[rax]}
9346 @item @code{h}
9347 @tab Print the QImode name for a ``high'' register.
9348 @tab @code{%h0}
9349 @tab @code{%ah}
9350 @tab @code{ah}
9351 @item @code{H}
9352 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9353 high 8 bytes of SSE values. For a memref in (%rax), it generates
9354 @tab @code{%H0}
9355 @tab @code{8(%rax)}
9356 @tab @code{8[rax]}
9357 @item @code{k}
9358 @tab Print the SImode name of the register.
9359 @tab @code{%k0}
9360 @tab @code{%eax}
9361 @tab @code{eax}
9362 @item @code{l}
9363 @tab Print the label name with no punctuation.
9364 @tab @code{%l3}
9365 @tab @code{.L3}
9366 @tab @code{.L3}
9367 @item @code{p}
9368 @tab Print raw symbol name (without syntax-specific prefixes).
9369 @tab @code{%p2}
9370 @tab @code{42}
9371 @tab @code{42}
9372 @item @code{P}
9373 @tab If used for a function, print the PLT suffix and generate PIC code.
9374 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9375 foo(). If used for a constant, drop all syntax-specific prefixes and
9376 issue the bare constant. See @code{p} above.
9377 @item @code{q}
9378 @tab Print the DImode name of the register.
9379 @tab @code{%q0}
9380 @tab @code{%rax}
9381 @tab @code{rax}
9382 @item @code{w}
9383 @tab Print the HImode name of the register.
9384 @tab @code{%w0}
9385 @tab @code{%ax}
9386 @tab @code{ax}
9387 @item @code{z}
9388 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9389 @tab @code{%z0}
9390 @tab @code{l}
9391 @tab
9392 @end multitable
9393
9394 @code{V} is a special modifier which prints the name of the full integer
9395 register without @code{%}.
9396
9397 @anchor{x86floatingpointasmoperands}
9398 @subsubsection x86 Floating-Point @code{asm} Operands
9399
9400 On x86 targets, there are several rules on the usage of stack-like registers
9401 in the operands of an @code{asm}. These rules apply only to the operands
9402 that are stack-like registers:
9403
9404 @enumerate
9405 @item
9406 Given a set of input registers that die in an @code{asm}, it is
9407 necessary to know which are implicitly popped by the @code{asm}, and
9408 which must be explicitly popped by GCC@.
9409
9410 An input register that is implicitly popped by the @code{asm} must be
9411 explicitly clobbered, unless it is constrained to match an
9412 output operand.
9413
9414 @item
9415 For any input register that is implicitly popped by an @code{asm}, it is
9416 necessary to know how to adjust the stack to compensate for the pop.
9417 If any non-popped input is closer to the top of the reg-stack than
9418 the implicitly popped register, it would not be possible to know what the
9419 stack looked like---it's not clear how the rest of the stack ``slides
9420 up''.
9421
9422 All implicitly popped input registers must be closer to the top of
9423 the reg-stack than any input that is not implicitly popped.
9424
9425 It is possible that if an input dies in an @code{asm}, the compiler might
9426 use the input register for an output reload. Consider this example:
9427
9428 @smallexample
9429 asm ("foo" : "=t" (a) : "f" (b));
9430 @end smallexample
9431
9432 @noindent
9433 This code says that input @code{b} is not popped by the @code{asm}, and that
9434 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9435 deeper after the @code{asm} than it was before. But, it is possible that
9436 reload may think that it can use the same register for both the input and
9437 the output.
9438
9439 To prevent this from happening,
9440 if any input operand uses the @samp{f} constraint, all output register
9441 constraints must use the @samp{&} early-clobber modifier.
9442
9443 The example above is correctly written as:
9444
9445 @smallexample
9446 asm ("foo" : "=&t" (a) : "f" (b));
9447 @end smallexample
9448
9449 @item
9450 Some operands need to be in particular places on the stack. All
9451 output operands fall in this category---GCC has no other way to
9452 know which registers the outputs appear in unless you indicate
9453 this in the constraints.
9454
9455 Output operands must specifically indicate which register an output
9456 appears in after an @code{asm}. @samp{=f} is not allowed: the operand
9457 constraints must select a class with a single register.
9458
9459 @item
9460 Output operands may not be ``inserted'' between existing stack registers.
9461 Since no 387 opcode uses a read/write operand, all output operands
9462 are dead before the @code{asm}, and are pushed by the @code{asm}.
9463 It makes no sense to push anywhere but the top of the reg-stack.
9464
9465 Output operands must start at the top of the reg-stack: output
9466 operands may not ``skip'' a register.
9467
9468 @item
9469 Some @code{asm} statements may need extra stack space for internal
9470 calculations. This can be guaranteed by clobbering stack registers
9471 unrelated to the inputs and outputs.
9472
9473 @end enumerate
9474
9475 This @code{asm}
9476 takes one input, which is internally popped, and produces two outputs.
9477
9478 @smallexample
9479 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9480 @end smallexample
9481
9482 @noindent
9483 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9484 and replaces them with one output. The @code{st(1)} clobber is necessary
9485 for the compiler to know that @code{fyl2xp1} pops both inputs.
9486
9487 @smallexample
9488 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9489 @end smallexample
9490
9491 @lowersections
9492 @include md.texi
9493 @raisesections
9494
9495 @node Asm Labels
9496 @subsection Controlling Names Used in Assembler Code
9497 @cindex assembler names for identifiers
9498 @cindex names used in assembler code
9499 @cindex identifiers, names in assembler code
9500
9501 You can specify the name to be used in the assembler code for a C
9502 function or variable by writing the @code{asm} (or @code{__asm__})
9503 keyword after the declarator.
9504 It is up to you to make sure that the assembler names you choose do not
9505 conflict with any other assembler symbols, or reference registers.
9506
9507 @subsubheading Assembler names for data:
9508
9509 This sample shows how to specify the assembler name for data:
9510
9511 @smallexample
9512 int foo asm ("myfoo") = 2;
9513 @end smallexample
9514
9515 @noindent
9516 This specifies that the name to be used for the variable @code{foo} in
9517 the assembler code should be @samp{myfoo} rather than the usual
9518 @samp{_foo}.
9519
9520 On systems where an underscore is normally prepended to the name of a C
9521 variable, this feature allows you to define names for the
9522 linker that do not start with an underscore.
9523
9524 GCC does not support using this feature with a non-static local variable
9525 since such variables do not have assembler names. If you are
9526 trying to put the variable in a particular register, see
9527 @ref{Explicit Register Variables}.
9528
9529 @subsubheading Assembler names for functions:
9530
9531 To specify the assembler name for functions, write a declaration for the
9532 function before its definition and put @code{asm} there, like this:
9533
9534 @smallexample
9535 int func (int x, int y) asm ("MYFUNC");
9536
9537 int func (int x, int y)
9538 @{
9539 /* @r{@dots{}} */
9540 @end smallexample
9541
9542 @noindent
9543 This specifies that the name to be used for the function @code{func} in
9544 the assembler code should be @code{MYFUNC}.
9545
9546 @node Explicit Register Variables
9547 @subsection Variables in Specified Registers
9548 @anchor{Explicit Reg Vars}
9549 @cindex explicit register variables
9550 @cindex variables in specified registers
9551 @cindex specified registers
9552
9553 GNU C allows you to associate specific hardware registers with C
9554 variables. In almost all cases, allowing the compiler to assign
9555 registers produces the best code. However under certain unusual
9556 circumstances, more precise control over the variable storage is
9557 required.
9558
9559 Both global and local variables can be associated with a register. The
9560 consequences of performing this association are very different between
9561 the two, as explained in the sections below.
9562
9563 @menu
9564 * Global Register Variables:: Variables declared at global scope.
9565 * Local Register Variables:: Variables declared within a function.
9566 @end menu
9567
9568 @node Global Register Variables
9569 @subsubsection Defining Global Register Variables
9570 @anchor{Global Reg Vars}
9571 @cindex global register variables
9572 @cindex registers, global variables in
9573 @cindex registers, global allocation
9574
9575 You can define a global register variable and associate it with a specified
9576 register like this:
9577
9578 @smallexample
9579 register int *foo asm ("r12");
9580 @end smallexample
9581
9582 @noindent
9583 Here @code{r12} is the name of the register that should be used. Note that
9584 this is the same syntax used for defining local register variables, but for
9585 a global variable the declaration appears outside a function. The
9586 @code{register} keyword is required, and cannot be combined with
9587 @code{static}. The register name must be a valid register name for the
9588 target platform.
9589
9590 Registers are a scarce resource on most systems and allowing the
9591 compiler to manage their usage usually results in the best code. However,
9592 under special circumstances it can make sense to reserve some globally.
9593 For example this may be useful in programs such as programming language
9594 interpreters that have a couple of global variables that are accessed
9595 very often.
9596
9597 After defining a global register variable, for the current compilation
9598 unit:
9599
9600 @itemize @bullet
9601 @item If the register is a call-saved register, call ABI is affected:
9602 the register will not be restored in function epilogue sequences after
9603 the variable has been assigned. Therefore, functions cannot safely
9604 return to callers that assume standard ABI.
9605 @item Conversely, if the register is a call-clobbered register, making
9606 calls to functions that use standard ABI may lose contents of the variable.
9607 Such calls may be created by the compiler even if none are evident in
9608 the original program, for example when libgcc functions are used to
9609 make up for unavailable instructions.
9610 @item Accesses to the variable may be optimized as usual and the register
9611 remains available for allocation and use in any computations, provided that
9612 observable values of the variable are not affected.
9613 @item If the variable is referenced in inline assembly, the type of access
9614 must be provided to the compiler via constraints (@pxref{Constraints}).
9615 Accesses from basic asms are not supported.
9616 @end itemize
9617
9618 Note that these points @emph{only} apply to code that is compiled with the
9619 definition. The behavior of code that is merely linked in (for example
9620 code from libraries) is not affected.
9621
9622 If you want to recompile source files that do not actually use your global
9623 register variable so they do not use the specified register for any other
9624 purpose, you need not actually add the global register declaration to
9625 their source code. It suffices to specify the compiler option
9626 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the
9627 register.
9628
9629 @subsubheading Declaring the variable
9630
9631 Global register variables can not have initial values, because an
9632 executable file has no means to supply initial contents for a register.
9633
9634 When selecting a register, choose one that is normally saved and
9635 restored by function calls on your machine. This ensures that code
9636 which is unaware of this reservation (such as library routines) will
9637 restore it before returning.
9638
9639 On machines with register windows, be sure to choose a global
9640 register that is not affected magically by the function call mechanism.
9641
9642 @subsubheading Using the variable
9643
9644 @cindex @code{qsort}, and global register variables
9645 When calling routines that are not aware of the reservation, be
9646 cautious if those routines call back into code which uses them. As an
9647 example, if you call the system library version of @code{qsort}, it may
9648 clobber your registers during execution, but (if you have selected
9649 appropriate registers) it will restore them before returning. However
9650 it will @emph{not} restore them before calling @code{qsort}'s comparison
9651 function. As a result, global values will not reliably be available to
9652 the comparison function unless the @code{qsort} function itself is rebuilt.
9653
9654 Similarly, it is not safe to access the global register variables from signal
9655 handlers or from more than one thread of control. Unless you recompile
9656 them specially for the task at hand, the system library routines may
9657 temporarily use the register for other things. Furthermore, since the register
9658 is not reserved exclusively for the variable, accessing it from handlers of
9659 asynchronous signals may observe unrelated temporary values residing in the
9660 register.
9661
9662 @cindex register variable after @code{longjmp}
9663 @cindex global register after @code{longjmp}
9664 @cindex value after @code{longjmp}
9665 @findex longjmp
9666 @findex setjmp
9667 On most machines, @code{longjmp} restores to each global register
9668 variable the value it had at the time of the @code{setjmp}. On some
9669 machines, however, @code{longjmp} does not change the value of global
9670 register variables. To be portable, the function that called @code{setjmp}
9671 should make other arrangements to save the values of the global register
9672 variables, and to restore them in a @code{longjmp}. This way, the same
9673 thing happens regardless of what @code{longjmp} does.
9674
9675 @node Local Register Variables
9676 @subsubsection Specifying Registers for Local Variables
9677 @anchor{Local Reg Vars}
9678 @cindex local variables, specifying registers
9679 @cindex specifying registers for local variables
9680 @cindex registers for local variables
9681
9682 You can define a local register variable and associate it with a specified
9683 register like this:
9684
9685 @smallexample
9686 register int *foo asm ("r12");
9687 @end smallexample
9688
9689 @noindent
9690 Here @code{r12} is the name of the register that should be used. Note
9691 that this is the same syntax used for defining global register variables,
9692 but for a local variable the declaration appears within a function. The
9693 @code{register} keyword is required, and cannot be combined with
9694 @code{static}. The register name must be a valid register name for the
9695 target platform.
9696
9697 As with global register variables, it is recommended that you choose
9698 a register that is normally saved and restored by function calls on your
9699 machine, so that calls to library routines will not clobber it.
9700
9701 The only supported use for this feature is to specify registers
9702 for input and output operands when calling Extended @code{asm}
9703 (@pxref{Extended Asm}). This may be necessary if the constraints for a
9704 particular machine don't provide sufficient control to select the desired
9705 register. To force an operand into a register, create a local variable
9706 and specify the register name after the variable's declaration. Then use
9707 the local variable for the @code{asm} operand and specify any constraint
9708 letter that matches the register:
9709
9710 @smallexample
9711 register int *p1 asm ("r0") = @dots{};
9712 register int *p2 asm ("r1") = @dots{};
9713 register int *result asm ("r0");
9714 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9715 @end smallexample
9716
9717 @emph{Warning:} In the above example, be aware that a register (for example
9718 @code{r0}) can be call-clobbered by subsequent code, including function
9719 calls and library calls for arithmetic operators on other variables (for
9720 example the initialization of @code{p2}). In this case, use temporary
9721 variables for expressions between the register assignments:
9722
9723 @smallexample
9724 int t1 = @dots{};
9725 register int *p1 asm ("r0") = @dots{};
9726 register int *p2 asm ("r1") = t1;
9727 register int *result asm ("r0");
9728 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9729 @end smallexample
9730
9731 Defining a register variable does not reserve the register. Other than
9732 when invoking the Extended @code{asm}, the contents of the specified
9733 register are not guaranteed. For this reason, the following uses
9734 are explicitly @emph{not} supported. If they appear to work, it is only
9735 happenstance, and may stop working as intended due to (seemingly)
9736 unrelated changes in surrounding code, or even minor changes in the
9737 optimization of a future version of gcc:
9738
9739 @itemize @bullet
9740 @item Passing parameters to or from Basic @code{asm}
9741 @item Passing parameters to or from Extended @code{asm} without using input
9742 or output operands.
9743 @item Passing parameters to or from routines written in assembler (or
9744 other languages) using non-standard calling conventions.
9745 @end itemize
9746
9747 Some developers use Local Register Variables in an attempt to improve
9748 gcc's allocation of registers, especially in large functions. In this
9749 case the register name is essentially a hint to the register allocator.
9750 While in some instances this can generate better code, improvements are
9751 subject to the whims of the allocator/optimizers. Since there are no
9752 guarantees that your improvements won't be lost, this usage of Local
9753 Register Variables is discouraged.
9754
9755 On the MIPS platform, there is related use for local register variables
9756 with slightly different characteristics (@pxref{MIPS Coprocessors,,
9757 Defining coprocessor specifics for MIPS targets, gccint,
9758 GNU Compiler Collection (GCC) Internals}).
9759
9760 @node Size of an asm
9761 @subsection Size of an @code{asm}
9762
9763 Some targets require that GCC track the size of each instruction used
9764 in order to generate correct code. Because the final length of the
9765 code produced by an @code{asm} statement is only known by the
9766 assembler, GCC must make an estimate as to how big it will be. It
9767 does this by counting the number of instructions in the pattern of the
9768 @code{asm} and multiplying that by the length of the longest
9769 instruction supported by that processor. (When working out the number
9770 of instructions, it assumes that any occurrence of a newline or of
9771 whatever statement separator character is supported by the assembler --
9772 typically @samp{;} --- indicates the end of an instruction.)
9773
9774 Normally, GCC's estimate is adequate to ensure that correct
9775 code is generated, but it is possible to confuse the compiler if you use
9776 pseudo instructions or assembler macros that expand into multiple real
9777 instructions, or if you use assembler directives that expand to more
9778 space in the object file than is needed for a single instruction.
9779 If this happens then the assembler may produce a diagnostic saying that
9780 a label is unreachable.
9781
9782 @node Alternate Keywords
9783 @section Alternate Keywords
9784 @cindex alternate keywords
9785 @cindex keywords, alternate
9786
9787 @option{-ansi} and the various @option{-std} options disable certain
9788 keywords. This causes trouble when you want to use GNU C extensions, or
9789 a general-purpose header file that should be usable by all programs,
9790 including ISO C programs. The keywords @code{asm}, @code{typeof} and
9791 @code{inline} are not available in programs compiled with
9792 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9793 program compiled with @option{-std=c99} or @option{-std=c11}). The
9794 ISO C99 keyword
9795 @code{restrict} is only available when @option{-std=gnu99} (which will
9796 eventually be the default) or @option{-std=c99} (or the equivalent
9797 @option{-std=iso9899:1999}), or an option for a later standard
9798 version, is used.
9799
9800 The way to solve these problems is to put @samp{__} at the beginning and
9801 end of each problematical keyword. For example, use @code{__asm__}
9802 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9803
9804 Other C compilers won't accept these alternative keywords; if you want to
9805 compile with another compiler, you can define the alternate keywords as
9806 macros to replace them with the customary keywords. It looks like this:
9807
9808 @smallexample
9809 #ifndef __GNUC__
9810 #define __asm__ asm
9811 #endif
9812 @end smallexample
9813
9814 @findex __extension__
9815 @opindex pedantic
9816 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9817 You can
9818 prevent such warnings within one expression by writing
9819 @code{__extension__} before the expression. @code{__extension__} has no
9820 effect aside from this.
9821
9822 @node Incomplete Enums
9823 @section Incomplete @code{enum} Types
9824
9825 You can define an @code{enum} tag without specifying its possible values.
9826 This results in an incomplete type, much like what you get if you write
9827 @code{struct foo} without describing the elements. A later declaration
9828 that does specify the possible values completes the type.
9829
9830 You cannot allocate variables or storage using the type while it is
9831 incomplete. However, you can work with pointers to that type.
9832
9833 This extension may not be very useful, but it makes the handling of
9834 @code{enum} more consistent with the way @code{struct} and @code{union}
9835 are handled.
9836
9837 This extension is not supported by GNU C++.
9838
9839 @node Function Names
9840 @section Function Names as Strings
9841 @cindex @code{__func__} identifier
9842 @cindex @code{__FUNCTION__} identifier
9843 @cindex @code{__PRETTY_FUNCTION__} identifier
9844
9845 GCC provides three magic constants that hold the name of the current
9846 function as a string. In C++11 and later modes, all three are treated
9847 as constant expressions and can be used in @code{constexpr} constexts.
9848 The first of these constants is @code{__func__}, which is part of
9849 the C99 standard:
9850
9851 The identifier @code{__func__} is implicitly declared by the translator
9852 as if, immediately following the opening brace of each function
9853 definition, the declaration
9854
9855 @smallexample
9856 static const char __func__[] = "function-name";
9857 @end smallexample
9858
9859 @noindent
9860 appeared, where function-name is the name of the lexically-enclosing
9861 function. This name is the unadorned name of the function. As an
9862 extension, at file (or, in C++, namespace scope), @code{__func__}
9863 evaluates to the empty string.
9864
9865 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9866 backward compatibility with old versions of GCC.
9867
9868 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9869 @code{__func__}, except that at file (or, in C++, namespace scope),
9870 it evaluates to the string @code{"top level"}. In addition, in C++,
9871 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9872 well as its bare name. For example, this program:
9873
9874 @smallexample
9875 extern "C" int printf (const char *, ...);
9876
9877 class a @{
9878 public:
9879 void sub (int i)
9880 @{
9881 printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9882 printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9883 @}
9884 @};
9885
9886 int
9887 main (void)
9888 @{
9889 a ax;
9890 ax.sub (0);
9891 return 0;
9892 @}
9893 @end smallexample
9894
9895 @noindent
9896 gives this output:
9897
9898 @smallexample
9899 __FUNCTION__ = sub
9900 __PRETTY_FUNCTION__ = void a::sub(int)
9901 @end smallexample
9902
9903 These identifiers are variables, not preprocessor macros, and may not
9904 be used to initialize @code{char} arrays or be concatenated with string
9905 literals.
9906
9907 @node Return Address
9908 @section Getting the Return or Frame Address of a Function
9909
9910 These functions may be used to get information about the callers of a
9911 function.
9912
9913 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9914 This function returns the return address of the current function, or of
9915 one of its callers. The @var{level} argument is number of frames to
9916 scan up the call stack. A value of @code{0} yields the return address
9917 of the current function, a value of @code{1} yields the return address
9918 of the caller of the current function, and so forth. When inlining
9919 the expected behavior is that the function returns the address of
9920 the function that is returned to. To work around this behavior use
9921 the @code{noinline} function attribute.
9922
9923 The @var{level} argument must be a constant integer.
9924
9925 On some machines it may be impossible to determine the return address of
9926 any function other than the current one; in such cases, or when the top
9927 of the stack has been reached, this function returns @code{0} or a
9928 random value. In addition, @code{__builtin_frame_address} may be used
9929 to determine if the top of the stack has been reached.
9930
9931 Additional post-processing of the returned value may be needed, see
9932 @code{__builtin_extract_return_addr}.
9933
9934 Calling this function with a nonzero argument can have unpredictable
9935 effects, including crashing the calling program. As a result, calls
9936 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9937 option is in effect. Such calls should only be made in debugging
9938 situations.
9939 @end deftypefn
9940
9941 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9942 The address as returned by @code{__builtin_return_address} may have to be fed
9943 through this function to get the actual encoded address. For example, on the
9944 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9945 platforms an offset has to be added for the true next instruction to be
9946 executed.
9947
9948 If no fixup is needed, this function simply passes through @var{addr}.
9949 @end deftypefn
9950
9951 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9952 This function does the reverse of @code{__builtin_extract_return_addr}.
9953 @end deftypefn
9954
9955 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9956 This function is similar to @code{__builtin_return_address}, but it
9957 returns the address of the function frame rather than the return address
9958 of the function. Calling @code{__builtin_frame_address} with a value of
9959 @code{0} yields the frame address of the current function, a value of
9960 @code{1} yields the frame address of the caller of the current function,
9961 and so forth.
9962
9963 The frame is the area on the stack that holds local variables and saved
9964 registers. The frame address is normally the address of the first word
9965 pushed on to the stack by the function. However, the exact definition
9966 depends upon the processor and the calling convention. If the processor
9967 has a dedicated frame pointer register, and the function has a frame,
9968 then @code{__builtin_frame_address} returns the value of the frame
9969 pointer register.
9970
9971 On some machines it may be impossible to determine the frame address of
9972 any function other than the current one; in such cases, or when the top
9973 of the stack has been reached, this function returns @code{0} if
9974 the first frame pointer is properly initialized by the startup code.
9975
9976 Calling this function with a nonzero argument can have unpredictable
9977 effects, including crashing the calling program. As a result, calls
9978 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9979 option is in effect. Such calls should only be made in debugging
9980 situations.
9981 @end deftypefn
9982
9983 @node Vector Extensions
9984 @section Using Vector Instructions through Built-in Functions
9985
9986 On some targets, the instruction set contains SIMD vector instructions which
9987 operate on multiple values contained in one large register at the same time.
9988 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9989 this way.
9990
9991 The first step in using these extensions is to provide the necessary data
9992 types. This should be done using an appropriate @code{typedef}:
9993
9994 @smallexample
9995 typedef int v4si __attribute__ ((vector_size (16)));
9996 @end smallexample
9997
9998 @noindent
9999 The @code{int} type specifies the base type, while the attribute specifies
10000 the vector size for the variable, measured in bytes. For example, the
10001 declaration above causes the compiler to set the mode for the @code{v4si}
10002 type to be 16 bytes wide and divided into @code{int} sized units. For
10003 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10004 corresponding mode of @code{foo} is @acronym{V4SI}.
10005
10006 The @code{vector_size} attribute is only applicable to integral and
10007 float scalars, although arrays, pointers, and function return values
10008 are allowed in conjunction with this construct. Only sizes that are
10009 a power of two are currently allowed.
10010
10011 All the basic integer types can be used as base types, both as signed
10012 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10013 @code{long long}. In addition, @code{float} and @code{double} can be
10014 used to build floating-point vector types.
10015
10016 Specifying a combination that is not valid for the current architecture
10017 causes GCC to synthesize the instructions using a narrower mode.
10018 For example, if you specify a variable of type @code{V4SI} and your
10019 architecture does not allow for this specific SIMD type, GCC
10020 produces code that uses 4 @code{SIs}.
10021
10022 The types defined in this manner can be used with a subset of normal C
10023 operations. Currently, GCC allows using the following operators
10024 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10025
10026 The operations behave like C++ @code{valarrays}. Addition is defined as
10027 the addition of the corresponding elements of the operands. For
10028 example, in the code below, each of the 4 elements in @var{a} is
10029 added to the corresponding 4 elements in @var{b} and the resulting
10030 vector is stored in @var{c}.
10031
10032 @smallexample
10033 typedef int v4si __attribute__ ((vector_size (16)));
10034
10035 v4si a, b, c;
10036
10037 c = a + b;
10038 @end smallexample
10039
10040 Subtraction, multiplication, division, and the logical operations
10041 operate in a similar manner. Likewise, the result of using the unary
10042 minus or complement operators on a vector type is a vector whose
10043 elements are the negative or complemented values of the corresponding
10044 elements in the operand.
10045
10046 It is possible to use shifting operators @code{<<}, @code{>>} on
10047 integer-type vectors. The operation is defined as following: @code{@{a0,
10048 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10049 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10050 elements.
10051
10052 For convenience, it is allowed to use a binary vector operation
10053 where one operand is a scalar. In that case the compiler transforms
10054 the scalar operand into a vector where each element is the scalar from
10055 the operation. The transformation happens only if the scalar could be
10056 safely converted to the vector-element type.
10057 Consider the following code.
10058
10059 @smallexample
10060 typedef int v4si __attribute__ ((vector_size (16)));
10061
10062 v4si a, b, c;
10063 long l;
10064
10065 a = b + 1; /* a = b + @{1,1,1,1@}; */
10066 a = 2 * b; /* a = @{2,2,2,2@} * b; */
10067
10068 a = l + a; /* Error, cannot convert long to int. */
10069 @end smallexample
10070
10071 Vectors can be subscripted as if the vector were an array with
10072 the same number of elements and base type. Out of bound accesses
10073 invoke undefined behavior at run time. Warnings for out of bound
10074 accesses for vector subscription can be enabled with
10075 @option{-Warray-bounds}.
10076
10077 Vector comparison is supported with standard comparison
10078 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10079 vector expressions of integer-type or real-type. Comparison between
10080 integer-type vectors and real-type vectors are not supported. The
10081 result of the comparison is a vector of the same width and number of
10082 elements as the comparison operands with a signed integral element
10083 type.
10084
10085 Vectors are compared element-wise producing 0 when comparison is false
10086 and -1 (constant of the appropriate type where all bits are set)
10087 otherwise. Consider the following example.
10088
10089 @smallexample
10090 typedef int v4si __attribute__ ((vector_size (16)));
10091
10092 v4si a = @{1,2,3,4@};
10093 v4si b = @{3,2,1,4@};
10094 v4si c;
10095
10096 c = a > b; /* The result would be @{0, 0,-1, 0@} */
10097 c = a == b; /* The result would be @{0,-1, 0,-1@} */
10098 @end smallexample
10099
10100 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10101 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10102 integer vector with the same number of elements of the same size as @code{b}
10103 and @code{c}, computes all three arguments and creates a vector
10104 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}. Note that unlike in
10105 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10106 As in the case of binary operations, this syntax is also accepted when
10107 one of @code{b} or @code{c} is a scalar that is then transformed into a
10108 vector. If both @code{b} and @code{c} are scalars and the type of
10109 @code{true?b:c} has the same size as the element type of @code{a}, then
10110 @code{b} and @code{c} are converted to a vector type whose elements have
10111 this type and with the same number of elements as @code{a}.
10112
10113 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10114 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10115 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10116 For mixed operations between a scalar @code{s} and a vector @code{v},
10117 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10118 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10119
10120 @findex __builtin_shuffle
10121 Vector shuffling is available using functions
10122 @code{__builtin_shuffle (vec, mask)} and
10123 @code{__builtin_shuffle (vec0, vec1, mask)}.
10124 Both functions construct a permutation of elements from one or two
10125 vectors and return a vector of the same type as the input vector(s).
10126 The @var{mask} is an integral vector with the same width (@var{W})
10127 and element count (@var{N}) as the output vector.
10128
10129 The elements of the input vectors are numbered in memory ordering of
10130 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}. The
10131 elements of @var{mask} are considered modulo @var{N} in the single-operand
10132 case and modulo @math{2*@var{N}} in the two-operand case.
10133
10134 Consider the following example,
10135
10136 @smallexample
10137 typedef int v4si __attribute__ ((vector_size (16)));
10138
10139 v4si a = @{1,2,3,4@};
10140 v4si b = @{5,6,7,8@};
10141 v4si mask1 = @{0,1,1,3@};
10142 v4si mask2 = @{0,4,2,5@};
10143 v4si res;
10144
10145 res = __builtin_shuffle (a, mask1); /* res is @{1,2,2,4@} */
10146 res = __builtin_shuffle (a, b, mask2); /* res is @{1,5,3,6@} */
10147 @end smallexample
10148
10149 Note that @code{__builtin_shuffle} is intentionally semantically
10150 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10151
10152 You can declare variables and use them in function calls and returns, as
10153 well as in assignments and some casts. You can specify a vector type as
10154 a return type for a function. Vector types can also be used as function
10155 arguments. It is possible to cast from one vector type to another,
10156 provided they are of the same size (in fact, you can also cast vectors
10157 to and from other datatypes of the same size).
10158
10159 You cannot operate between vectors of different lengths or different
10160 signedness without a cast.
10161
10162 @node Offsetof
10163 @section Support for @code{offsetof}
10164 @findex __builtin_offsetof
10165
10166 GCC implements for both C and C++ a syntactic extension to implement
10167 the @code{offsetof} macro.
10168
10169 @smallexample
10170 primary:
10171 "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10172
10173 offsetof_member_designator:
10174 @code{identifier}
10175 | offsetof_member_designator "." @code{identifier}
10176 | offsetof_member_designator "[" @code{expr} "]"
10177 @end smallexample
10178
10179 This extension is sufficient such that
10180
10181 @smallexample
10182 #define offsetof(@var{type}, @var{member}) __builtin_offsetof (@var{type}, @var{member})
10183 @end smallexample
10184
10185 @noindent
10186 is a suitable definition of the @code{offsetof} macro. In C++, @var{type}
10187 may be dependent. In either case, @var{member} may consist of a single
10188 identifier, or a sequence of member accesses and array references.
10189
10190 @node __sync Builtins
10191 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10192
10193 The following built-in functions
10194 are intended to be compatible with those described
10195 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10196 section 7.4. As such, they depart from normal GCC practice by not using
10197 the @samp{__builtin_} prefix and also by being overloaded so that they
10198 work on multiple types.
10199
10200 The definition given in the Intel documentation allows only for the use of
10201 the types @code{int}, @code{long}, @code{long long} or their unsigned
10202 counterparts. GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10203 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10204 Operations on pointer arguments are performed as if the operands were
10205 of the @code{uintptr_t} type. That is, they are not scaled by the size
10206 of the type to which the pointer points.
10207
10208 These functions are implemented in terms of the @samp{__atomic}
10209 builtins (@pxref{__atomic Builtins}). They should not be used for new
10210 code which should use the @samp{__atomic} builtins instead.
10211
10212 Not all operations are supported by all target processors. If a particular
10213 operation cannot be implemented on the target processor, a warning is
10214 generated and a call to an external function is generated. The external
10215 function carries the same name as the built-in version,
10216 with an additional suffix
10217 @samp{_@var{n}} where @var{n} is the size of the data type.
10218
10219 @c ??? Should we have a mechanism to suppress this warning? This is almost
10220 @c useful for implementing the operation under the control of an external
10221 @c mutex.
10222
10223 In most cases, these built-in functions are considered a @dfn{full barrier}.
10224 That is,
10225 no memory operand is moved across the operation, either forward or
10226 backward. Further, instructions are issued as necessary to prevent the
10227 processor from speculating loads across the operation and from queuing stores
10228 after the operation.
10229
10230 All of the routines are described in the Intel documentation to take
10231 ``an optional list of variables protected by the memory barrier''. It's
10232 not clear what is meant by that; it could mean that @emph{only} the
10233 listed variables are protected, or it could mean a list of additional
10234 variables to be protected. The list is ignored by GCC which treats it as
10235 empty. GCC interprets an empty list as meaning that all globally
10236 accessible variables should be protected.
10237
10238 @table @code
10239 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10240 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10241 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10242 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10243 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10244 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10245 @findex __sync_fetch_and_add
10246 @findex __sync_fetch_and_sub
10247 @findex __sync_fetch_and_or
10248 @findex __sync_fetch_and_and
10249 @findex __sync_fetch_and_xor
10250 @findex __sync_fetch_and_nand
10251 These built-in functions perform the operation suggested by the name, and
10252 returns the value that had previously been in memory. That is, operations
10253 on integer operands have the following semantics. Operations on pointer
10254 arguments are performed as if the operands were of the @code{uintptr_t}
10255 type. That is, they are not scaled by the size of the type to which
10256 the pointer points.
10257
10258 @smallexample
10259 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10260 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @} // nand
10261 @end smallexample
10262
10263 The object pointed to by the first argument must be of integer or pointer
10264 type. It must not be a boolean type.
10265
10266 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10267 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10268
10269 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10270 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10271 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10272 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10273 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10274 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10275 @findex __sync_add_and_fetch
10276 @findex __sync_sub_and_fetch
10277 @findex __sync_or_and_fetch
10278 @findex __sync_and_and_fetch
10279 @findex __sync_xor_and_fetch
10280 @findex __sync_nand_and_fetch
10281 These built-in functions perform the operation suggested by the name, and
10282 return the new value. That is, operations on integer operands have
10283 the following semantics. Operations on pointer operands are performed as
10284 if the operand's type were @code{uintptr_t}.
10285
10286 @smallexample
10287 @{ *ptr @var{op}= value; return *ptr; @}
10288 @{ *ptr = ~(*ptr & value); return *ptr; @} // nand
10289 @end smallexample
10290
10291 The same constraints on arguments apply as for the corresponding
10292 @code{__sync_op_and_fetch} built-in functions.
10293
10294 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10295 as @code{*ptr = ~(*ptr & value)} instead of
10296 @code{*ptr = ~*ptr & value}.
10297
10298 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10299 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10300 @findex __sync_bool_compare_and_swap
10301 @findex __sync_val_compare_and_swap
10302 These built-in functions perform an atomic compare and swap.
10303 That is, if the current
10304 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10305 @code{*@var{ptr}}.
10306
10307 The ``bool'' version returns true if the comparison is successful and
10308 @var{newval} is written. The ``val'' version returns the contents
10309 of @code{*@var{ptr}} before the operation.
10310
10311 @item __sync_synchronize (...)
10312 @findex __sync_synchronize
10313 This built-in function issues a full memory barrier.
10314
10315 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10316 @findex __sync_lock_test_and_set
10317 This built-in function, as described by Intel, is not a traditional test-and-set
10318 operation, but rather an atomic exchange operation. It writes @var{value}
10319 into @code{*@var{ptr}}, and returns the previous contents of
10320 @code{*@var{ptr}}.
10321
10322 Many targets have only minimal support for such locks, and do not support
10323 a full exchange operation. In this case, a target may support reduced
10324 functionality here by which the @emph{only} valid value to store is the
10325 immediate constant 1. The exact value actually stored in @code{*@var{ptr}}
10326 is implementation defined.
10327
10328 This built-in function is not a full barrier,
10329 but rather an @dfn{acquire barrier}.
10330 This means that references after the operation cannot move to (or be
10331 speculated to) before the operation, but previous memory stores may not
10332 be globally visible yet, and previous memory loads may not yet be
10333 satisfied.
10334
10335 @item void __sync_lock_release (@var{type} *ptr, ...)
10336 @findex __sync_lock_release
10337 This built-in function releases the lock acquired by
10338 @code{__sync_lock_test_and_set}.
10339 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10340
10341 This built-in function is not a full barrier,
10342 but rather a @dfn{release barrier}.
10343 This means that all previous memory stores are globally visible, and all
10344 previous memory loads have been satisfied, but following memory reads
10345 are not prevented from being speculated to before the barrier.
10346 @end table
10347
10348 @node __atomic Builtins
10349 @section Built-in Functions for Memory Model Aware Atomic Operations
10350
10351 The following built-in functions approximately match the requirements
10352 for the C++11 memory model. They are all
10353 identified by being prefixed with @samp{__atomic} and most are
10354 overloaded so that they work with multiple types.
10355
10356 These functions are intended to replace the legacy @samp{__sync}
10357 builtins. The main difference is that the memory order that is requested
10358 is a parameter to the functions. New code should always use the
10359 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10360
10361 Note that the @samp{__atomic} builtins assume that programs will
10362 conform to the C++11 memory model. In particular, they assume
10363 that programs are free of data races. See the C++11 standard for
10364 detailed requirements.
10365
10366 The @samp{__atomic} builtins can be used with any integral scalar or
10367 pointer type that is 1, 2, 4, or 8 bytes in length. 16-byte integral
10368 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10369 supported by the architecture.
10370
10371 The four non-arithmetic functions (load, store, exchange, and
10372 compare_exchange) all have a generic version as well. This generic
10373 version works on any data type. It uses the lock-free built-in function
10374 if the specific data type size makes that possible; otherwise, an
10375 external call is left to be resolved at run time. This external call is
10376 the same format with the addition of a @samp{size_t} parameter inserted
10377 as the first parameter indicating the size of the object being pointed to.
10378 All objects must be the same size.
10379
10380 There are 6 different memory orders that can be specified. These map
10381 to the C++11 memory orders with the same names, see the C++11 standard
10382 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10383 on atomic synchronization} for detailed definitions. Individual
10384 targets may also support additional memory orders for use on specific
10385 architectures. Refer to the target documentation for details of
10386 these.
10387
10388 An atomic operation can both constrain code motion and
10389 be mapped to hardware instructions for synchronization between threads
10390 (e.g., a fence). To which extent this happens is controlled by the
10391 memory orders, which are listed here in approximately ascending order of
10392 strength. The description of each memory order is only meant to roughly
10393 illustrate the effects and is not a specification; see the C++11
10394 memory model for precise semantics.
10395
10396 @table @code
10397 @item __ATOMIC_RELAXED
10398 Implies no inter-thread ordering constraints.
10399 @item __ATOMIC_CONSUME
10400 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10401 memory order because of a deficiency in C++11's semantics for
10402 @code{memory_order_consume}.
10403 @item __ATOMIC_ACQUIRE
10404 Creates an inter-thread happens-before constraint from the release (or
10405 stronger) semantic store to this acquire load. Can prevent hoisting
10406 of code to before the operation.
10407 @item __ATOMIC_RELEASE
10408 Creates an inter-thread happens-before constraint to acquire (or stronger)
10409 semantic loads that read from this release store. Can prevent sinking
10410 of code to after the operation.
10411 @item __ATOMIC_ACQ_REL
10412 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10413 @code{__ATOMIC_RELEASE}.
10414 @item __ATOMIC_SEQ_CST
10415 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10416 @end table
10417
10418 Note that in the C++11 memory model, @emph{fences} (e.g.,
10419 @samp{__atomic_thread_fence}) take effect in combination with other
10420 atomic operations on specific memory locations (e.g., atomic loads);
10421 operations on specific memory locations do not necessarily affect other
10422 operations in the same way.
10423
10424 Target architectures are encouraged to provide their own patterns for
10425 each of the atomic built-in functions. If no target is provided, the original
10426 non-memory model set of @samp{__sync} atomic built-in functions are
10427 used, along with any required synchronization fences surrounding it in
10428 order to achieve the proper behavior. Execution in this case is subject
10429 to the same restrictions as those built-in functions.
10430
10431 If there is no pattern or mechanism to provide a lock-free instruction
10432 sequence, a call is made to an external routine with the same parameters
10433 to be resolved at run time.
10434
10435 When implementing patterns for these built-in functions, the memory order
10436 parameter can be ignored as long as the pattern implements the most
10437 restrictive @code{__ATOMIC_SEQ_CST} memory order. Any of the other memory
10438 orders execute correctly with this memory order but they may not execute as
10439 efficiently as they could with a more appropriate implementation of the
10440 relaxed requirements.
10441
10442 Note that the C++11 standard allows for the memory order parameter to be
10443 determined at run time rather than at compile time. These built-in
10444 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10445 than invoke a runtime library call or inline a switch statement. This is
10446 standard compliant, safe, and the simplest approach for now.
10447
10448 The memory order parameter is a signed int, but only the lower 16 bits are
10449 reserved for the memory order. The remainder of the signed int is reserved
10450 for target use and should be 0. Use of the predefined atomic values
10451 ensures proper usage.
10452
10453 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10454 This built-in function implements an atomic load operation. It returns the
10455 contents of @code{*@var{ptr}}.
10456
10457 The valid memory order variants are
10458 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10459 and @code{__ATOMIC_CONSUME}.
10460
10461 @end deftypefn
10462
10463 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10464 This is the generic version of an atomic load. It returns the
10465 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10466
10467 @end deftypefn
10468
10469 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10470 This built-in function implements an atomic store operation. It writes
10471 @code{@var{val}} into @code{*@var{ptr}}.
10472
10473 The valid memory order variants are
10474 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10475
10476 @end deftypefn
10477
10478 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10479 This is the generic version of an atomic store. It stores the value
10480 of @code{*@var{val}} into @code{*@var{ptr}}.
10481
10482 @end deftypefn
10483
10484 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10485 This built-in function implements an atomic exchange operation. It writes
10486 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10487 @code{*@var{ptr}}.
10488
10489 The valid memory order variants are
10490 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10491 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10492
10493 @end deftypefn
10494
10495 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10496 This is the generic version of an atomic exchange. It stores the
10497 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10498 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10499
10500 @end deftypefn
10501
10502 @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)
10503 This built-in function implements an atomic compare and exchange operation.
10504 This compares the contents of @code{*@var{ptr}} with the contents of
10505 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10506 operation that writes @var{desired} into @code{*@var{ptr}}. If they are not
10507 equal, the operation is a @emph{read} and the current contents of
10508 @code{*@var{ptr}} are written into @code{*@var{expected}}. @var{weak} is true
10509 for weak compare_exchange, which may fail spuriously, and false for
10510 the strong variation, which never fails spuriously. Many targets
10511 only offer the strong variation and ignore the parameter. When in doubt, use
10512 the strong variation.
10513
10514 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10515 and memory is affected according to the
10516 memory order specified by @var{success_memorder}. There are no
10517 restrictions on what memory order can be used here.
10518
10519 Otherwise, false is returned and memory is affected according
10520 to @var{failure_memorder}. This memory order cannot be
10521 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}. It also cannot be a
10522 stronger order than that specified by @var{success_memorder}.
10523
10524 @end deftypefn
10525
10526 @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)
10527 This built-in function implements the generic version of
10528 @code{__atomic_compare_exchange}. The function is virtually identical to
10529 @code{__atomic_compare_exchange_n}, except the desired value is also a
10530 pointer.
10531
10532 @end deftypefn
10533
10534 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10535 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10536 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10537 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10538 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10539 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10540 These built-in functions perform the operation suggested by the name, and
10541 return the result of the operation. Operations on pointer arguments are
10542 performed as if the operands were of the @code{uintptr_t} type. That is,
10543 they are not scaled by the size of the type to which the pointer points.
10544
10545 @smallexample
10546 @{ *ptr @var{op}= val; return *ptr; @}
10547 @end smallexample
10548
10549 The object pointed to by the first argument must be of integer or pointer
10550 type. It must not be a boolean type. All memory orders are valid.
10551
10552 @end deftypefn
10553
10554 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10555 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10556 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10557 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10558 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10559 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10560 These built-in functions perform the operation suggested by the name, and
10561 return the value that had previously been in @code{*@var{ptr}}. Operations
10562 on pointer arguments are performed as if the operands were of
10563 the @code{uintptr_t} type. That is, they are not scaled by the size of
10564 the type to which the pointer points.
10565
10566 @smallexample
10567 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10568 @end smallexample
10569
10570 The same constraints on arguments apply as for the corresponding
10571 @code{__atomic_op_fetch} built-in functions. All memory orders are valid.
10572
10573 @end deftypefn
10574
10575 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10576
10577 This built-in function performs an atomic test-and-set operation on
10578 the byte at @code{*@var{ptr}}. The byte is set to some implementation
10579 defined nonzero ``set'' value and the return value is @code{true} if and only
10580 if the previous contents were ``set''.
10581 It should be only used for operands of type @code{bool} or @code{char}. For
10582 other types only part of the value may be set.
10583
10584 All memory orders are valid.
10585
10586 @end deftypefn
10587
10588 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10589
10590 This built-in function performs an atomic clear operation on
10591 @code{*@var{ptr}}. After the operation, @code{*@var{ptr}} contains 0.
10592 It should be only used for operands of type @code{bool} or @code{char} and
10593 in conjunction with @code{__atomic_test_and_set}.
10594 For other types it may only clear partially. If the type is not @code{bool}
10595 prefer using @code{__atomic_store}.
10596
10597 The valid memory order variants are
10598 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10599 @code{__ATOMIC_RELEASE}.
10600
10601 @end deftypefn
10602
10603 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10604
10605 This built-in function acts as a synchronization fence between threads
10606 based on the specified memory order.
10607
10608 All memory orders are valid.
10609
10610 @end deftypefn
10611
10612 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10613
10614 This built-in function acts as a synchronization fence between a thread
10615 and signal handlers based in the same thread.
10616
10617 All memory orders are valid.
10618
10619 @end deftypefn
10620
10621 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size, void *ptr)
10622
10623 This built-in function returns true if objects of @var{size} bytes always
10624 generate lock-free atomic instructions for the target architecture.
10625 @var{size} must resolve to a compile-time constant and the result also
10626 resolves to a compile-time constant.
10627
10628 @var{ptr} is an optional pointer to the object that may be used to determine
10629 alignment. A value of 0 indicates typical alignment should be used. The
10630 compiler may also ignore this parameter.
10631
10632 @smallexample
10633 if (__atomic_always_lock_free (sizeof (long long), 0))
10634 @end smallexample
10635
10636 @end deftypefn
10637
10638 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10639
10640 This built-in function returns true if objects of @var{size} bytes always
10641 generate lock-free atomic instructions for the target architecture. If
10642 the built-in function is not known to be lock-free, a call is made to a
10643 runtime routine named @code{__atomic_is_lock_free}.
10644
10645 @var{ptr} is an optional pointer to the object that may be used to determine
10646 alignment. A value of 0 indicates typical alignment should be used. The
10647 compiler may also ignore this parameter.
10648 @end deftypefn
10649
10650 @node Integer Overflow Builtins
10651 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10652
10653 The following built-in functions allow performing simple arithmetic operations
10654 together with checking whether the operations overflowed.
10655
10656 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10657 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10658 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10659 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10660 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10661 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10662 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10663
10664 These built-in functions promote the first two operands into infinite precision signed
10665 type and perform addition on those promoted operands. The result is then
10666 cast to the type the third pointer argument points to and stored there.
10667 If the stored result is equal to the infinite precision result, the built-in
10668 functions return false, otherwise they return true. As the addition is
10669 performed in infinite signed precision, these built-in functions have fully defined
10670 behavior for all argument values.
10671
10672 The first built-in function allows arbitrary integral types for operands and
10673 the result type must be pointer to some integral type other than enumerated or
10674 boolean type, the rest of the built-in functions have explicit integer types.
10675
10676 The compiler will attempt to use hardware instructions to implement
10677 these built-in functions where possible, like conditional jump on overflow
10678 after addition, conditional jump on carry etc.
10679
10680 @end deftypefn
10681
10682 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10683 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10684 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10685 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10686 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10687 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10688 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10689
10690 These built-in functions are similar to the add overflow checking built-in
10691 functions above, except they perform subtraction, subtract the second argument
10692 from the first one, instead of addition.
10693
10694 @end deftypefn
10695
10696 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10697 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10698 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10699 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10700 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10701 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10702 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10703
10704 These built-in functions are similar to the add overflow checking built-in
10705 functions above, except they perform multiplication, instead of addition.
10706
10707 @end deftypefn
10708
10709 The following built-in functions allow checking if simple arithmetic operation
10710 would overflow.
10711
10712 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10713 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10714 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10715
10716 These built-in functions are similar to @code{__builtin_add_overflow},
10717 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10718 they don't store the result of the arithmetic operation anywhere and the
10719 last argument is not a pointer, but some expression with integral type other
10720 than enumerated or boolean type.
10721
10722 The built-in functions promote the first two operands into infinite precision signed type
10723 and perform addition on those promoted operands. The result is then
10724 cast to the type of the third argument. If the cast result is equal to the infinite
10725 precision result, the built-in functions return false, otherwise they return true.
10726 The value of the third argument is ignored, just the side effects in the third argument
10727 are evaluated, and no integral argument promotions are performed on the last argument.
10728 If the third argument is a bit-field, the type used for the result cast has the
10729 precision and signedness of the given bit-field, rather than precision and signedness
10730 of the underlying type.
10731
10732 For example, the following macro can be used to portably check, at
10733 compile-time, whether or not adding two constant integers will overflow,
10734 and perform the addition only when it is known to be safe and not to trigger
10735 a @option{-Woverflow} warning.
10736
10737 @smallexample
10738 #define INT_ADD_OVERFLOW_P(a, b) \
10739 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10740
10741 enum @{
10742 A = INT_MAX, B = 3,
10743 C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10744 D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10745 @};
10746 @end smallexample
10747
10748 The compiler will attempt to use hardware instructions to implement
10749 these built-in functions where possible, like conditional jump on overflow
10750 after addition, conditional jump on carry etc.
10751
10752 @end deftypefn
10753
10754 @node x86 specific memory model extensions for transactional memory
10755 @section x86-Specific Memory Model Extensions for Transactional Memory
10756
10757 The x86 architecture supports additional memory ordering flags
10758 to mark critical sections for hardware lock elision.
10759 These must be specified in addition to an existing memory order to
10760 atomic intrinsics.
10761
10762 @table @code
10763 @item __ATOMIC_HLE_ACQUIRE
10764 Start lock elision on a lock variable.
10765 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10766 @item __ATOMIC_HLE_RELEASE
10767 End lock elision on a lock variable.
10768 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10769 @end table
10770
10771 When a lock acquire fails, it is required for good performance to abort
10772 the transaction quickly. This can be done with a @code{_mm_pause}.
10773
10774 @smallexample
10775 #include <immintrin.h> // For _mm_pause
10776
10777 int lockvar;
10778
10779 /* Acquire lock with lock elision */
10780 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10781 _mm_pause(); /* Abort failed transaction */
10782 ...
10783 /* Free lock with lock elision */
10784 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10785 @end smallexample
10786
10787 @node Object Size Checking
10788 @section Object Size Checking Built-in Functions
10789 @findex __builtin_object_size
10790 @findex __builtin___memcpy_chk
10791 @findex __builtin___mempcpy_chk
10792 @findex __builtin___memmove_chk
10793 @findex __builtin___memset_chk
10794 @findex __builtin___strcpy_chk
10795 @findex __builtin___stpcpy_chk
10796 @findex __builtin___strncpy_chk
10797 @findex __builtin___strcat_chk
10798 @findex __builtin___strncat_chk
10799 @findex __builtin___sprintf_chk
10800 @findex __builtin___snprintf_chk
10801 @findex __builtin___vsprintf_chk
10802 @findex __builtin___vsnprintf_chk
10803 @findex __builtin___printf_chk
10804 @findex __builtin___vprintf_chk
10805 @findex __builtin___fprintf_chk
10806 @findex __builtin___vfprintf_chk
10807
10808 GCC implements a limited buffer overflow protection mechanism that can
10809 prevent some buffer overflow attacks by determining the sizes of objects
10810 into which data is about to be written and preventing the writes when
10811 the size isn't sufficient. The built-in functions described below yield
10812 the best results when used together and when optimization is enabled.
10813 For example, to detect object sizes across function boundaries or to
10814 follow pointer assignments through non-trivial control flow they rely
10815 on various optimization passes enabled with @option{-O2}. However, to
10816 a limited extent, they can be used without optimization as well.
10817
10818 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10819 is a built-in construct that returns a constant number of bytes from
10820 @var{ptr} to the end of the object @var{ptr} pointer points to
10821 (if known at compile time). @code{__builtin_object_size} never evaluates
10822 its arguments for side effects. If there are any side effects in them, it
10823 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10824 for @var{type} 2 or 3. If there are multiple objects @var{ptr} can
10825 point to and all of them are known at compile time, the returned number
10826 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10827 0 and minimum if nonzero. If it is not possible to determine which objects
10828 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10829 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10830 for @var{type} 2 or 3.
10831
10832 @var{type} is an integer constant from 0 to 3. If the least significant
10833 bit is clear, objects are whole variables, if it is set, a closest
10834 surrounding subobject is considered the object a pointer points to.
10835 The second bit determines if maximum or minimum of remaining bytes
10836 is computed.
10837
10838 @smallexample
10839 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10840 char *p = &var.buf1[1], *q = &var.b;
10841
10842 /* Here the object p points to is var. */
10843 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10844 /* The subobject p points to is var.buf1. */
10845 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10846 /* The object q points to is var. */
10847 assert (__builtin_object_size (q, 0)
10848 == (char *) (&var + 1) - (char *) &var.b);
10849 /* The subobject q points to is var.b. */
10850 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10851 @end smallexample
10852 @end deftypefn
10853
10854 There are built-in functions added for many common string operation
10855 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10856 built-in is provided. This built-in has an additional last argument,
10857 which is the number of bytes remaining in the object the @var{dest}
10858 argument points to or @code{(size_t) -1} if the size is not known.
10859
10860 The built-in functions are optimized into the normal string functions
10861 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10862 it is known at compile time that the destination object will not
10863 be overflowed. If the compiler can determine at compile time that the
10864 object will always be overflowed, it issues a warning.
10865
10866 The intended use can be e.g.@:
10867
10868 @smallexample
10869 #undef memcpy
10870 #define bos0(dest) __builtin_object_size (dest, 0)
10871 #define memcpy(dest, src, n) \
10872 __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10873
10874 char *volatile p;
10875 char buf[10];
10876 /* It is unknown what object p points to, so this is optimized
10877 into plain memcpy - no checking is possible. */
10878 memcpy (p, "abcde", n);
10879 /* Destination is known and length too. It is known at compile
10880 time there will be no overflow. */
10881 memcpy (&buf[5], "abcde", 5);
10882 /* Destination is known, but the length is not known at compile time.
10883 This will result in __memcpy_chk call that can check for overflow
10884 at run time. */
10885 memcpy (&buf[5], "abcde", n);
10886 /* Destination is known and it is known at compile time there will
10887 be overflow. There will be a warning and __memcpy_chk call that
10888 will abort the program at run time. */
10889 memcpy (&buf[6], "abcde", 5);
10890 @end smallexample
10891
10892 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10893 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10894 @code{strcat} and @code{strncat}.
10895
10896 There are also checking built-in functions for formatted output functions.
10897 @smallexample
10898 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10899 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10900 const char *fmt, ...);
10901 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10902 va_list ap);
10903 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10904 const char *fmt, va_list ap);
10905 @end smallexample
10906
10907 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10908 etc.@: functions and can contain implementation specific flags on what
10909 additional security measures the checking function might take, such as
10910 handling @code{%n} differently.
10911
10912 The @var{os} argument is the object size @var{s} points to, like in the
10913 other built-in functions. There is a small difference in the behavior
10914 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10915 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10916 the checking function is called with @var{os} argument set to
10917 @code{(size_t) -1}.
10918
10919 In addition to this, there are checking built-in functions
10920 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10921 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10922 These have just one additional argument, @var{flag}, right before
10923 format string @var{fmt}. If the compiler is able to optimize them to
10924 @code{fputc} etc.@: functions, it does, otherwise the checking function
10925 is called and the @var{flag} argument passed to it.
10926
10927 @node Pointer Bounds Checker builtins
10928 @section Pointer Bounds Checker Built-in Functions
10929 @cindex Pointer Bounds Checker builtins
10930 @findex __builtin___bnd_set_ptr_bounds
10931 @findex __builtin___bnd_narrow_ptr_bounds
10932 @findex __builtin___bnd_copy_ptr_bounds
10933 @findex __builtin___bnd_init_ptr_bounds
10934 @findex __builtin___bnd_null_ptr_bounds
10935 @findex __builtin___bnd_store_ptr_bounds
10936 @findex __builtin___bnd_chk_ptr_lbounds
10937 @findex __builtin___bnd_chk_ptr_ubounds
10938 @findex __builtin___bnd_chk_ptr_bounds
10939 @findex __builtin___bnd_get_ptr_lbound
10940 @findex __builtin___bnd_get_ptr_ubound
10941
10942 GCC provides a set of built-in functions to control Pointer Bounds Checker
10943 instrumentation. Note that all Pointer Bounds Checker builtins can be used
10944 even if you compile with Pointer Bounds Checker off
10945 (@option{-fno-check-pointer-bounds}).
10946 The behavior may differ in such case as documented below.
10947
10948 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10949
10950 This built-in function returns a new pointer with the value of @var{q}, and
10951 associate it with the bounds [@var{q}, @var{q}+@var{size}-1]. With Pointer
10952 Bounds Checker off, the built-in function just returns the first argument.
10953
10954 @smallexample
10955 extern void *__wrap_malloc (size_t n)
10956 @{
10957 void *p = (void *)__real_malloc (n);
10958 if (!p) return __builtin___bnd_null_ptr_bounds (p);
10959 return __builtin___bnd_set_ptr_bounds (p, n);
10960 @}
10961 @end smallexample
10962
10963 @end deftypefn
10964
10965 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t @var{size})
10966
10967 This built-in function returns a new pointer with the value of @var{p}
10968 and associates it with the narrowed bounds formed by the intersection
10969 of bounds associated with @var{q} and the bounds
10970 [@var{p}, @var{p} + @var{size} - 1].
10971 With Pointer Bounds Checker off, the built-in function just returns the first
10972 argument.
10973
10974 @smallexample
10975 void init_objects (object *objs, size_t size)
10976 @{
10977 size_t i;
10978 /* Initialize objects one-by-one passing pointers with bounds of
10979 an object, not the full array of objects. */
10980 for (i = 0; i < size; i++)
10981 init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10982 sizeof(object)));
10983 @}
10984 @end smallexample
10985
10986 @end deftypefn
10987
10988 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10989
10990 This built-in function returns a new pointer with the value of @var{q},
10991 and associates it with the bounds already associated with pointer @var{r}.
10992 With Pointer Bounds Checker off, the built-in function just returns the first
10993 argument.
10994
10995 @smallexample
10996 /* Here is a way to get pointer to object's field but
10997 still with the full object's bounds. */
10998 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field,
10999 objptr);
11000 @end smallexample
11001
11002 @end deftypefn
11003
11004 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
11005
11006 This built-in function returns a new pointer with the value of @var{q}, and
11007 associates it with INIT (allowing full memory access) bounds. With Pointer
11008 Bounds Checker off, the built-in function just returns the first argument.
11009
11010 @end deftypefn
11011
11012 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
11013
11014 This built-in function returns a new pointer with the value of @var{q}, and
11015 associates it with NULL (allowing no memory access) bounds. With Pointer
11016 Bounds Checker off, the built-in function just returns the first argument.
11017
11018 @end deftypefn
11019
11020 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
11021
11022 This built-in function stores the bounds associated with pointer @var{ptr_val}
11023 and location @var{ptr_addr} into Bounds Table. This can be useful to propagate
11024 bounds from legacy code without touching the associated pointer's memory when
11025 pointers are copied as integers. With Pointer Bounds Checker off, the built-in
11026 function call is ignored.
11027
11028 @end deftypefn
11029
11030 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
11031
11032 This built-in function checks if the pointer @var{q} is within the lower
11033 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
11034 function call is ignored.
11035
11036 @smallexample
11037 extern void *__wrap_memset (void *dst, int c, size_t len)
11038 @{
11039 if (len > 0)
11040 @{
11041 __builtin___bnd_chk_ptr_lbounds (dst);
11042 __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
11043 __real_memset (dst, c, len);
11044 @}
11045 return dst;
11046 @}
11047 @end smallexample
11048
11049 @end deftypefn
11050
11051 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
11052
11053 This built-in function checks if the pointer @var{q} is within the upper
11054 bound of its associated bounds. With Pointer Bounds Checker off, the built-in
11055 function call is ignored.
11056
11057 @end deftypefn
11058
11059 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
11060
11061 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
11062 the lower and upper bounds associated with @var{q}. With Pointer Bounds Checker
11063 off, the built-in function call is ignored.
11064
11065 @smallexample
11066 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
11067 @{
11068 if (n > 0)
11069 @{
11070 __bnd_chk_ptr_bounds (dst, n);
11071 __bnd_chk_ptr_bounds (src, n);
11072 __real_memcpy (dst, src, n);
11073 @}
11074 return dst;
11075 @}
11076 @end smallexample
11077
11078 @end deftypefn
11079
11080 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
11081
11082 This built-in function returns the lower bound associated
11083 with the pointer @var{q}, as a pointer value.
11084 This is useful for debugging using @code{printf}.
11085 With Pointer Bounds Checker off, the built-in function returns 0.
11086
11087 @smallexample
11088 void *lb = __builtin___bnd_get_ptr_lbound (q);
11089 void *ub = __builtin___bnd_get_ptr_ubound (q);
11090 printf ("q = %p lb(q) = %p ub(q) = %p", q, lb, ub);
11091 @end smallexample
11092
11093 @end deftypefn
11094
11095 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
11096
11097 This built-in function returns the upper bound (which is a pointer) associated
11098 with the pointer @var{q}. With Pointer Bounds Checker off,
11099 the built-in function returns -1.
11100
11101 @end deftypefn
11102
11103 @node Other Builtins
11104 @section Other Built-in Functions Provided by GCC
11105 @cindex built-in functions
11106 @findex __builtin_alloca
11107 @findex __builtin_alloca_with_align
11108 @findex __builtin_alloca_with_align_and_max
11109 @findex __builtin_call_with_static_chain
11110 @findex __builtin_extend_pointer
11111 @findex __builtin_fpclassify
11112 @findex __builtin_isfinite
11113 @findex __builtin_isnormal
11114 @findex __builtin_isgreater
11115 @findex __builtin_isgreaterequal
11116 @findex __builtin_isinf_sign
11117 @findex __builtin_isless
11118 @findex __builtin_islessequal
11119 @findex __builtin_islessgreater
11120 @findex __builtin_isunordered
11121 @findex __builtin_powi
11122 @findex __builtin_powif
11123 @findex __builtin_powil
11124 @findex _Exit
11125 @findex _exit
11126 @findex abort
11127 @findex abs
11128 @findex acos
11129 @findex acosf
11130 @findex acosh
11131 @findex acoshf
11132 @findex acoshl
11133 @findex acosl
11134 @findex alloca
11135 @findex asin
11136 @findex asinf
11137 @findex asinh
11138 @findex asinhf
11139 @findex asinhl
11140 @findex asinl
11141 @findex atan
11142 @findex atan2
11143 @findex atan2f
11144 @findex atan2l
11145 @findex atanf
11146 @findex atanh
11147 @findex atanhf
11148 @findex atanhl
11149 @findex atanl
11150 @findex bcmp
11151 @findex bzero
11152 @findex cabs
11153 @findex cabsf
11154 @findex cabsl
11155 @findex cacos
11156 @findex cacosf
11157 @findex cacosh
11158 @findex cacoshf
11159 @findex cacoshl
11160 @findex cacosl
11161 @findex calloc
11162 @findex carg
11163 @findex cargf
11164 @findex cargl
11165 @findex casin
11166 @findex casinf
11167 @findex casinh
11168 @findex casinhf
11169 @findex casinhl
11170 @findex casinl
11171 @findex catan
11172 @findex catanf
11173 @findex catanh
11174 @findex catanhf
11175 @findex catanhl
11176 @findex catanl
11177 @findex cbrt
11178 @findex cbrtf
11179 @findex cbrtl
11180 @findex ccos
11181 @findex ccosf
11182 @findex ccosh
11183 @findex ccoshf
11184 @findex ccoshl
11185 @findex ccosl
11186 @findex ceil
11187 @findex ceilf
11188 @findex ceill
11189 @findex cexp
11190 @findex cexpf
11191 @findex cexpl
11192 @findex cimag
11193 @findex cimagf
11194 @findex cimagl
11195 @findex clog
11196 @findex clogf
11197 @findex clogl
11198 @findex clog10
11199 @findex clog10f
11200 @findex clog10l
11201 @findex conj
11202 @findex conjf
11203 @findex conjl
11204 @findex copysign
11205 @findex copysignf
11206 @findex copysignl
11207 @findex cos
11208 @findex cosf
11209 @findex cosh
11210 @findex coshf
11211 @findex coshl
11212 @findex cosl
11213 @findex cpow
11214 @findex cpowf
11215 @findex cpowl
11216 @findex cproj
11217 @findex cprojf
11218 @findex cprojl
11219 @findex creal
11220 @findex crealf
11221 @findex creall
11222 @findex csin
11223 @findex csinf
11224 @findex csinh
11225 @findex csinhf
11226 @findex csinhl
11227 @findex csinl
11228 @findex csqrt
11229 @findex csqrtf
11230 @findex csqrtl
11231 @findex ctan
11232 @findex ctanf
11233 @findex ctanh
11234 @findex ctanhf
11235 @findex ctanhl
11236 @findex ctanl
11237 @findex dcgettext
11238 @findex dgettext
11239 @findex drem
11240 @findex dremf
11241 @findex dreml
11242 @findex erf
11243 @findex erfc
11244 @findex erfcf
11245 @findex erfcl
11246 @findex erff
11247 @findex erfl
11248 @findex exit
11249 @findex exp
11250 @findex exp10
11251 @findex exp10f
11252 @findex exp10l
11253 @findex exp2
11254 @findex exp2f
11255 @findex exp2l
11256 @findex expf
11257 @findex expl
11258 @findex expm1
11259 @findex expm1f
11260 @findex expm1l
11261 @findex fabs
11262 @findex fabsf
11263 @findex fabsl
11264 @findex fdim
11265 @findex fdimf
11266 @findex fdiml
11267 @findex ffs
11268 @findex floor
11269 @findex floorf
11270 @findex floorl
11271 @findex fma
11272 @findex fmaf
11273 @findex fmal
11274 @findex fmax
11275 @findex fmaxf
11276 @findex fmaxl
11277 @findex fmin
11278 @findex fminf
11279 @findex fminl
11280 @findex fmod
11281 @findex fmodf
11282 @findex fmodl
11283 @findex fprintf
11284 @findex fprintf_unlocked
11285 @findex fputs
11286 @findex fputs_unlocked
11287 @findex frexp
11288 @findex frexpf
11289 @findex frexpl
11290 @findex fscanf
11291 @findex gamma
11292 @findex gammaf
11293 @findex gammal
11294 @findex gamma_r
11295 @findex gammaf_r
11296 @findex gammal_r
11297 @findex gettext
11298 @findex hypot
11299 @findex hypotf
11300 @findex hypotl
11301 @findex ilogb
11302 @findex ilogbf
11303 @findex ilogbl
11304 @findex imaxabs
11305 @findex index
11306 @findex isalnum
11307 @findex isalpha
11308 @findex isascii
11309 @findex isblank
11310 @findex iscntrl
11311 @findex isdigit
11312 @findex isgraph
11313 @findex islower
11314 @findex isprint
11315 @findex ispunct
11316 @findex isspace
11317 @findex isupper
11318 @findex iswalnum
11319 @findex iswalpha
11320 @findex iswblank
11321 @findex iswcntrl
11322 @findex iswdigit
11323 @findex iswgraph
11324 @findex iswlower
11325 @findex iswprint
11326 @findex iswpunct
11327 @findex iswspace
11328 @findex iswupper
11329 @findex iswxdigit
11330 @findex isxdigit
11331 @findex j0
11332 @findex j0f
11333 @findex j0l
11334 @findex j1
11335 @findex j1f
11336 @findex j1l
11337 @findex jn
11338 @findex jnf
11339 @findex jnl
11340 @findex labs
11341 @findex ldexp
11342 @findex ldexpf
11343 @findex ldexpl
11344 @findex lgamma
11345 @findex lgammaf
11346 @findex lgammal
11347 @findex lgamma_r
11348 @findex lgammaf_r
11349 @findex lgammal_r
11350 @findex llabs
11351 @findex llrint
11352 @findex llrintf
11353 @findex llrintl
11354 @findex llround
11355 @findex llroundf
11356 @findex llroundl
11357 @findex log
11358 @findex log10
11359 @findex log10f
11360 @findex log10l
11361 @findex log1p
11362 @findex log1pf
11363 @findex log1pl
11364 @findex log2
11365 @findex log2f
11366 @findex log2l
11367 @findex logb
11368 @findex logbf
11369 @findex logbl
11370 @findex logf
11371 @findex logl
11372 @findex lrint
11373 @findex lrintf
11374 @findex lrintl
11375 @findex lround
11376 @findex lroundf
11377 @findex lroundl
11378 @findex malloc
11379 @findex memchr
11380 @findex memcmp
11381 @findex memcpy
11382 @findex mempcpy
11383 @findex memset
11384 @findex modf
11385 @findex modff
11386 @findex modfl
11387 @findex nearbyint
11388 @findex nearbyintf
11389 @findex nearbyintl
11390 @findex nextafter
11391 @findex nextafterf
11392 @findex nextafterl
11393 @findex nexttoward
11394 @findex nexttowardf
11395 @findex nexttowardl
11396 @findex pow
11397 @findex pow10
11398 @findex pow10f
11399 @findex pow10l
11400 @findex powf
11401 @findex powl
11402 @findex printf
11403 @findex printf_unlocked
11404 @findex putchar
11405 @findex puts
11406 @findex remainder
11407 @findex remainderf
11408 @findex remainderl
11409 @findex remquo
11410 @findex remquof
11411 @findex remquol
11412 @findex rindex
11413 @findex rint
11414 @findex rintf
11415 @findex rintl
11416 @findex round
11417 @findex roundf
11418 @findex roundl
11419 @findex scalb
11420 @findex scalbf
11421 @findex scalbl
11422 @findex scalbln
11423 @findex scalblnf
11424 @findex scalblnf
11425 @findex scalbn
11426 @findex scalbnf
11427 @findex scanfnl
11428 @findex signbit
11429 @findex signbitf
11430 @findex signbitl
11431 @findex signbitd32
11432 @findex signbitd64
11433 @findex signbitd128
11434 @findex significand
11435 @findex significandf
11436 @findex significandl
11437 @findex sin
11438 @findex sincos
11439 @findex sincosf
11440 @findex sincosl
11441 @findex sinf
11442 @findex sinh
11443 @findex sinhf
11444 @findex sinhl
11445 @findex sinl
11446 @findex snprintf
11447 @findex sprintf
11448 @findex sqrt
11449 @findex sqrtf
11450 @findex sqrtl
11451 @findex sscanf
11452 @findex stpcpy
11453 @findex stpncpy
11454 @findex strcasecmp
11455 @findex strcat
11456 @findex strchr
11457 @findex strcmp
11458 @findex strcpy
11459 @findex strcspn
11460 @findex strdup
11461 @findex strfmon
11462 @findex strftime
11463 @findex strlen
11464 @findex strncasecmp
11465 @findex strncat
11466 @findex strncmp
11467 @findex strncpy
11468 @findex strndup
11469 @findex strpbrk
11470 @findex strrchr
11471 @findex strspn
11472 @findex strstr
11473 @findex tan
11474 @findex tanf
11475 @findex tanh
11476 @findex tanhf
11477 @findex tanhl
11478 @findex tanl
11479 @findex tgamma
11480 @findex tgammaf
11481 @findex tgammal
11482 @findex toascii
11483 @findex tolower
11484 @findex toupper
11485 @findex towlower
11486 @findex towupper
11487 @findex trunc
11488 @findex truncf
11489 @findex truncl
11490 @findex vfprintf
11491 @findex vfscanf
11492 @findex vprintf
11493 @findex vscanf
11494 @findex vsnprintf
11495 @findex vsprintf
11496 @findex vsscanf
11497 @findex y0
11498 @findex y0f
11499 @findex y0l
11500 @findex y1
11501 @findex y1f
11502 @findex y1l
11503 @findex yn
11504 @findex ynf
11505 @findex ynl
11506
11507 GCC provides a large number of built-in functions other than the ones
11508 mentioned above. Some of these are for internal use in the processing
11509 of exceptions or variable-length argument lists and are not
11510 documented here because they may change from time to time; we do not
11511 recommend general use of these functions.
11512
11513 The remaining functions are provided for optimization purposes.
11514
11515 With the exception of built-ins that have library equivalents such as
11516 the standard C library functions discussed below, or that expand to
11517 library calls, GCC built-in functions are always expanded inline and
11518 thus do not have corresponding entry points and their address cannot
11519 be obtained. Attempting to use them in an expression other than
11520 a function call results in a compile-time error.
11521
11522 @opindex fno-builtin
11523 GCC includes built-in versions of many of the functions in the standard
11524 C library. These functions come in two forms: one whose names start with
11525 the @code{__builtin_} prefix, and the other without. Both forms have the
11526 same type (including prototype), the same address (when their address is
11527 taken), and the same meaning as the C library functions even if you specify
11528 the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these
11529 functions are only optimized in certain cases; if they are not optimized in
11530 a particular case, a call to the library function is emitted.
11531
11532 @opindex ansi
11533 @opindex std
11534 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11535 @option{-std=c99} or @option{-std=c11}), the functions
11536 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11537 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11538 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11539 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11540 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11541 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11542 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11543 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11544 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11545 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11546 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11547 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11548 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11549 @code{significandl}, @code{significand}, @code{sincosf},
11550 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11551 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11552 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
11553 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11554 @code{yn}
11555 may be handled as built-in functions.
11556 All these functions have corresponding versions
11557 prefixed with @code{__builtin_}, which may be used even in strict C90
11558 mode.
11559
11560 The ISO C99 functions
11561 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11562 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11563 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11564 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11565 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11566 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11567 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11568 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11569 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11570 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11571 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11572 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11573 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11574 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11575 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11576 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11577 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11578 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11579 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11580 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11581 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11582 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11583 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11584 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11585 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11586 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11587 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11588 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11589 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11590 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11591 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11592 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11593 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11594 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11595 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11596 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11597 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11598 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11599 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11600 are handled as built-in functions
11601 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11602
11603 There are also built-in versions of the ISO C99 functions
11604 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11605 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11606 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11607 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11608 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11609 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11610 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11611 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11612 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11613 that are recognized in any mode since ISO C90 reserves these names for
11614 the purpose to which ISO C99 puts them. All these functions have
11615 corresponding versions prefixed with @code{__builtin_}.
11616
11617 There are also built-in functions @code{__builtin_fabsf@var{n}},
11618 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11619 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11620 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11621 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11622 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11623
11624 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11625 @code{clog10l} which names are reserved by ISO C99 for future use.
11626 All these functions have versions prefixed with @code{__builtin_}.
11627
11628 The ISO C94 functions
11629 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11630 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11631 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11632 @code{towupper}
11633 are handled as built-in functions
11634 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11635
11636 The ISO C90 functions
11637 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11638 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11639 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11640 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11641 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11642 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11643 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11644 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11645 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11646 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11647 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11648 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11649 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11650 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11651 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11652 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11653 are all recognized as built-in functions unless
11654 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11655 is specified for an individual function). All of these functions have
11656 corresponding versions prefixed with @code{__builtin_}.
11657
11658 GCC provides built-in versions of the ISO C99 floating-point comparison
11659 macros that avoid raising exceptions for unordered operands. They have
11660 the same names as the standard macros ( @code{isgreater},
11661 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11662 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11663 prefixed. We intend for a library implementor to be able to simply
11664 @code{#define} each standard macro to its built-in equivalent.
11665 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11666 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11667 @code{__builtin_} prefixed. The @code{isinf} and @code{isnan}
11668 built-in functions appear both with and without the @code{__builtin_} prefix.
11669
11670 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11671 The @code{__builtin_alloca} function must be called at block scope.
11672 The function allocates an object @var{size} bytes large on the stack
11673 of the calling function. The object is aligned on the default stack
11674 alignment boundary for the target determined by the
11675 @code{__BIGGEST_ALIGNMENT__} macro. The @code{__builtin_alloca}
11676 function returns a pointer to the first byte of the allocated object.
11677 The lifetime of the allocated object ends just before the calling
11678 function returns to its caller. This is so even when
11679 @code{__builtin_alloca} is called within a nested block.
11680
11681 For example, the following function allocates eight objects of @code{n}
11682 bytes each on the stack, storing a pointer to each in consecutive elements
11683 of the array @code{a}. It then passes the array to function @code{g}
11684 which can safely use the storage pointed to by each of the array elements.
11685
11686 @smallexample
11687 void f (unsigned n)
11688 @{
11689 void *a [8];
11690 for (int i = 0; i != 8; ++i)
11691 a [i] = __builtin_alloca (n);
11692
11693 g (a, n); // @r{safe}
11694 @}
11695 @end smallexample
11696
11697 Since the @code{__builtin_alloca} function doesn't validate its argument
11698 it is the responsibility of its caller to make sure the argument doesn't
11699 cause it to exceed the stack size limit.
11700 The @code{__builtin_alloca} function is provided to make it possible to
11701 allocate on the stack arrays of bytes with an upper bound that may be
11702 computed at run time. Since C99 Variable Length Arrays offer
11703 similar functionality under a portable, more convenient, and safer
11704 interface they are recommended instead, in both C99 and C++ programs
11705 where GCC provides them as an extension.
11706 @xref{Variable Length}, for details.
11707
11708 @end deftypefn
11709
11710 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11711 The @code{__builtin_alloca_with_align} function must be called at block
11712 scope. The function allocates an object @var{size} bytes large on
11713 the stack of the calling function. The allocated object is aligned on
11714 the boundary specified by the argument @var{alignment} whose unit is given
11715 in bits (not bytes). The @var{size} argument must be positive and not
11716 exceed the stack size limit. The @var{alignment} argument must be a constant
11717 integer expression that evaluates to a power of 2 greater than or equal to
11718 @code{CHAR_BIT} and less than some unspecified maximum. Invocations
11719 with other values are rejected with an error indicating the valid bounds.
11720 The function returns a pointer to the first byte of the allocated object.
11721 The lifetime of the allocated object ends at the end of the block in which
11722 the function was called. The allocated storage is released no later than
11723 just before the calling function returns to its caller, but may be released
11724 at the end of the block in which the function was called.
11725
11726 For example, in the following function the call to @code{g} is unsafe
11727 because when @code{overalign} is non-zero, the space allocated by
11728 @code{__builtin_alloca_with_align} may have been released at the end
11729 of the @code{if} statement in which it was called.
11730
11731 @smallexample
11732 void f (unsigned n, bool overalign)
11733 @{
11734 void *p;
11735 if (overalign)
11736 p = __builtin_alloca_with_align (n, 64 /* bits */);
11737 else
11738 p = __builtin_alloc (n);
11739
11740 g (p, n); // @r{unsafe}
11741 @}
11742 @end smallexample
11743
11744 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11745 @var{size} argument it is the responsibility of its caller to make sure
11746 the argument doesn't cause it to exceed the stack size limit.
11747 The @code{__builtin_alloca_with_align} function is provided to make
11748 it possible to allocate on the stack overaligned arrays of bytes with
11749 an upper bound that may be computed at run time. Since C99
11750 Variable Length Arrays offer the same functionality under
11751 a portable, more convenient, and safer interface they are recommended
11752 instead, in both C99 and C++ programs where GCC provides them as
11753 an extension. @xref{Variable Length}, for details.
11754
11755 @end deftypefn
11756
11757 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11758 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11759 specifying an upper bound for @var{size} in case its value cannot be computed
11760 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11761 and @option{-Walloca-larger-than}. @var{max_size} must be a constant integer
11762 expression, it has no effect on code generation and no attempt is made to
11763 check its compatibility with @var{size}.
11764
11765 @end deftypefn
11766
11767 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11768
11769 You can use the built-in function @code{__builtin_types_compatible_p} to
11770 determine whether two types are the same.
11771
11772 This built-in function returns 1 if the unqualified versions of the
11773 types @var{type1} and @var{type2} (which are types, not expressions) are
11774 compatible, 0 otherwise. The result of this built-in function can be
11775 used in integer constant expressions.
11776
11777 This built-in function ignores top level qualifiers (e.g., @code{const},
11778 @code{volatile}). For example, @code{int} is equivalent to @code{const
11779 int}.
11780
11781 The type @code{int[]} and @code{int[5]} are compatible. On the other
11782 hand, @code{int} and @code{char *} are not compatible, even if the size
11783 of their types, on the particular architecture are the same. Also, the
11784 amount of pointer indirection is taken into account when determining
11785 similarity. Consequently, @code{short *} is not similar to
11786 @code{short **}. Furthermore, two types that are typedefed are
11787 considered compatible if their underlying types are compatible.
11788
11789 An @code{enum} type is not considered to be compatible with another
11790 @code{enum} type even if both are compatible with the same integer
11791 type; this is what the C standard specifies.
11792 For example, @code{enum @{foo, bar@}} is not similar to
11793 @code{enum @{hot, dog@}}.
11794
11795 You typically use this function in code whose execution varies
11796 depending on the arguments' types. For example:
11797
11798 @smallexample
11799 #define foo(x) \
11800 (@{ \
11801 typeof (x) tmp = (x); \
11802 if (__builtin_types_compatible_p (typeof (x), long double)) \
11803 tmp = foo_long_double (tmp); \
11804 else if (__builtin_types_compatible_p (typeof (x), double)) \
11805 tmp = foo_double (tmp); \
11806 else if (__builtin_types_compatible_p (typeof (x), float)) \
11807 tmp = foo_float (tmp); \
11808 else \
11809 abort (); \
11810 tmp; \
11811 @})
11812 @end smallexample
11813
11814 @emph{Note:} This construct is only available for C@.
11815
11816 @end deftypefn
11817
11818 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11819
11820 The @var{call_exp} expression must be a function call, and the
11821 @var{pointer_exp} expression must be a pointer. The @var{pointer_exp}
11822 is passed to the function call in the target's static chain location.
11823 The result of builtin is the result of the function call.
11824
11825 @emph{Note:} This builtin is only available for C@.
11826 This builtin can be used to call Go closures from C.
11827
11828 @end deftypefn
11829
11830 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11831
11832 You can use the built-in function @code{__builtin_choose_expr} to
11833 evaluate code depending on the value of a constant expression. This
11834 built-in function returns @var{exp1} if @var{const_exp}, which is an
11835 integer constant expression, is nonzero. Otherwise it returns @var{exp2}.
11836
11837 This built-in function is analogous to the @samp{? :} operator in C,
11838 except that the expression returned has its type unaltered by promotion
11839 rules. Also, the built-in function does not evaluate the expression
11840 that is not chosen. For example, if @var{const_exp} evaluates to true,
11841 @var{exp2} is not evaluated even if it has side effects.
11842
11843 This built-in function can return an lvalue if the chosen argument is an
11844 lvalue.
11845
11846 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11847 type. Similarly, if @var{exp2} is returned, its return type is the same
11848 as @var{exp2}.
11849
11850 Example:
11851
11852 @smallexample
11853 #define foo(x) \
11854 __builtin_choose_expr ( \
11855 __builtin_types_compatible_p (typeof (x), double), \
11856 foo_double (x), \
11857 __builtin_choose_expr ( \
11858 __builtin_types_compatible_p (typeof (x), float), \
11859 foo_float (x), \
11860 /* @r{The void expression results in a compile-time error} \
11861 @r{when assigning the result to something.} */ \
11862 (void)0))
11863 @end smallexample
11864
11865 @emph{Note:} This construct is only available for C@. Furthermore, the
11866 unused expression (@var{exp1} or @var{exp2} depending on the value of
11867 @var{const_exp}) may still generate syntax errors. This may change in
11868 future revisions.
11869
11870 @end deftypefn
11871
11872 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11873
11874 The built-in function @code{__builtin_tgmath}, available only for C
11875 and Objective-C, calls a function determined according to the rules of
11876 @code{<tgmath.h>} macros. It is intended to be used in
11877 implementations of that header, so that expansions of macros from that
11878 header only expand each of their arguments once, to avoid problems
11879 when calls to such macros are nested inside the arguments of other
11880 calls to such macros; in addition, it results in better diagnostics
11881 for invalid calls to @code{<tgmath.h>} macros than implementations
11882 using other GNU C language features. For example, the @code{pow}
11883 type-generic macro might be defined as:
11884
11885 @smallexample
11886 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11887 cpowf, cpow, cpowl, a, b)
11888 @end smallexample
11889
11890 The arguments to @code{__builtin_tgmath} are at least two pointers to
11891 functions, followed by the arguments to the type-generic macro (which
11892 will be passed as arguments to the selected function). All the
11893 pointers to functions must be pointers to prototyped functions, none
11894 of which may have variable arguments, and all of which must have the
11895 same number of parameters; the number of parameters of the first
11896 function determines how many arguments to @code{__builtin_tgmath} are
11897 interpreted as function pointers, and how many as the arguments to the
11898 called function.
11899
11900 The types of the specified functions must all be different, but
11901 related to each other in the same way as a set of functions that may
11902 be selected between by a macro in @code{<tgmath.h>}. This means that
11903 the functions are parameterized by a floating-point type @var{t},
11904 different for each such function. The function return types may all
11905 be the same type, or they may be @var{t} for each function, or they
11906 may be the real type corresponding to @var{t} for each function (if
11907 some of the types @var{t} are complex). Likewise, for each parameter
11908 position, the type of the parameter in that position may always be the
11909 same type, or may be @var{t} for each function (this case must apply
11910 for at least one parameter position), or may be the real type
11911 corresponding to @var{t} for each function.
11912
11913 The standard rules for @code{<tgmath.h>} macros are used to find a
11914 common type @var{u} from the types of the arguments for parameters
11915 whose types vary between the functions; complex integer types (a GNU
11916 extension) are treated like @code{_Complex double} for this purpose
11917 (or @code{_Complex _Float64} if all the function return types are the
11918 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
11919 If the function return types vary, or are all the same integer type,
11920 the function called is the one for which @var{t} is @var{u}, and it is
11921 an error if there is no such function. If the function return types
11922 are all the same floating-point type, the type-generic macro is taken
11923 to be one of those from TS 18661 that rounds the result to a narrower
11924 type; if there is a function for which @var{t} is @var{u}, it is
11925 called, and otherwise the first function, if any, for which @var{t}
11926 has at least the range and precision of @var{u} is called, and it is
11927 an error if there is no such function.
11928
11929 @end deftypefn
11930
11931 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11932
11933 The built-in function @code{__builtin_complex} is provided for use in
11934 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11935 @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a
11936 real binary floating-point type, and the result has the corresponding
11937 complex type with real and imaginary parts @var{real} and @var{imag}.
11938 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11939 infinities, NaNs and negative zeros are involved.
11940
11941 @end deftypefn
11942
11943 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11944 You can use the built-in function @code{__builtin_constant_p} to
11945 determine if a value is known to be constant at compile time and hence
11946 that GCC can perform constant-folding on expressions involving that
11947 value. The argument of the function is the value to test. The function
11948 returns the integer 1 if the argument is known to be a compile-time
11949 constant and 0 if it is not known to be a compile-time constant. A
11950 return of 0 does not indicate that the value is @emph{not} a constant,
11951 but merely that GCC cannot prove it is a constant with the specified
11952 value of the @option{-O} option.
11953
11954 You typically use this function in an embedded application where
11955 memory is a critical resource. If you have some complex calculation,
11956 you may want it to be folded if it involves constants, but need to call
11957 a function if it does not. For example:
11958
11959 @smallexample
11960 #define Scale_Value(X) \
11961 (__builtin_constant_p (X) \
11962 ? ((X) * SCALE + OFFSET) : Scale (X))
11963 @end smallexample
11964
11965 You may use this built-in function in either a macro or an inline
11966 function. However, if you use it in an inlined function and pass an
11967 argument of the function as the argument to the built-in, GCC
11968 never returns 1 when you call the inline function with a string constant
11969 or compound literal (@pxref{Compound Literals}) and does not return 1
11970 when you pass a constant numeric value to the inline function unless you
11971 specify the @option{-O} option.
11972
11973 You may also use @code{__builtin_constant_p} in initializers for static
11974 data. For instance, you can write
11975
11976 @smallexample
11977 static const int table[] = @{
11978 __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11979 /* @r{@dots{}} */
11980 @};
11981 @end smallexample
11982
11983 @noindent
11984 This is an acceptable initializer even if @var{EXPRESSION} is not a
11985 constant expression, including the case where
11986 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11987 folded to a constant but @var{EXPRESSION} contains operands that are
11988 not otherwise permitted in a static initializer (for example,
11989 @code{0 && foo ()}). GCC must be more conservative about evaluating the
11990 built-in in this case, because it has no opportunity to perform
11991 optimization.
11992 @end deftypefn
11993
11994 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11995 @opindex fprofile-arcs
11996 You may use @code{__builtin_expect} to provide the compiler with
11997 branch prediction information. In general, you should prefer to
11998 use actual profile feedback for this (@option{-fprofile-arcs}), as
11999 programmers are notoriously bad at predicting how their programs
12000 actually perform. However, there are applications in which this
12001 data is hard to collect.
12002
12003 The return value is the value of @var{exp}, which should be an integral
12004 expression. The semantics of the built-in are that it is expected that
12005 @var{exp} == @var{c}. For example:
12006
12007 @smallexample
12008 if (__builtin_expect (x, 0))
12009 foo ();
12010 @end smallexample
12011
12012 @noindent
12013 indicates that we do not expect to call @code{foo}, since
12014 we expect @code{x} to be zero. Since you are limited to integral
12015 expressions for @var{exp}, you should use constructions such as
12016
12017 @smallexample
12018 if (__builtin_expect (ptr != NULL, 1))
12019 foo (*ptr);
12020 @end smallexample
12021
12022 @noindent
12023 when testing pointer or floating-point values.
12024 @end deftypefn
12025
12026 @deftypefn {Built-in Function} void __builtin_trap (void)
12027 This function causes the program to exit abnormally. GCC implements
12028 this function by using a target-dependent mechanism (such as
12029 intentionally executing an illegal instruction) or by calling
12030 @code{abort}. The mechanism used may vary from release to release so
12031 you should not rely on any particular implementation.
12032 @end deftypefn
12033
12034 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12035 If control flow reaches the point of the @code{__builtin_unreachable},
12036 the program is undefined. It is useful in situations where the
12037 compiler cannot deduce the unreachability of the code.
12038
12039 One such case is immediately following an @code{asm} statement that
12040 either never terminates, or one that transfers control elsewhere
12041 and never returns. In this example, without the
12042 @code{__builtin_unreachable}, GCC issues a warning that control
12043 reaches the end of a non-void function. It also generates code
12044 to return after the @code{asm}.
12045
12046 @smallexample
12047 int f (int c, int v)
12048 @{
12049 if (c)
12050 @{
12051 return v;
12052 @}
12053 else
12054 @{
12055 asm("jmp error_handler");
12056 __builtin_unreachable ();
12057 @}
12058 @}
12059 @end smallexample
12060
12061 @noindent
12062 Because the @code{asm} statement unconditionally transfers control out
12063 of the function, control never reaches the end of the function
12064 body. The @code{__builtin_unreachable} is in fact unreachable and
12065 communicates this fact to the compiler.
12066
12067 Another use for @code{__builtin_unreachable} is following a call a
12068 function that never returns but that is not declared
12069 @code{__attribute__((noreturn))}, as in this example:
12070
12071 @smallexample
12072 void function_that_never_returns (void);
12073
12074 int g (int c)
12075 @{
12076 if (c)
12077 @{
12078 return 1;
12079 @}
12080 else
12081 @{
12082 function_that_never_returns ();
12083 __builtin_unreachable ();
12084 @}
12085 @}
12086 @end smallexample
12087
12088 @end deftypefn
12089
12090 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12091 This function returns its first argument, and allows the compiler
12092 to assume that the returned pointer is at least @var{align} bytes
12093 aligned. This built-in can have either two or three arguments,
12094 if it has three, the third argument should have integer type, and
12095 if it is nonzero means misalignment offset. For example:
12096
12097 @smallexample
12098 void *x = __builtin_assume_aligned (arg, 16);
12099 @end smallexample
12100
12101 @noindent
12102 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12103 16-byte aligned, while:
12104
12105 @smallexample
12106 void *x = __builtin_assume_aligned (arg, 32, 8);
12107 @end smallexample
12108
12109 @noindent
12110 means that the compiler can assume for @code{x}, set to @code{arg}, that
12111 @code{(char *) x - 8} is 32-byte aligned.
12112 @end deftypefn
12113
12114 @deftypefn {Built-in Function} int __builtin_LINE ()
12115 This function is the equivalent of the preprocessor @code{__LINE__}
12116 macro and returns a constant integer expression that evaluates to
12117 the line number of the invocation of the built-in. When used as a C++
12118 default argument for a function @var{F}, it returns the line number
12119 of the call to @var{F}.
12120 @end deftypefn
12121
12122 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12123 This function is the equivalent of the @code{__FUNCTION__} symbol
12124 and returns an address constant pointing to the name of the function
12125 from which the built-in was invoked, or the empty string if
12126 the invocation is not at function scope. When used as a C++ default
12127 argument for a function @var{F}, it returns the name of @var{F}'s
12128 caller or the empty string if the call was not made at function
12129 scope.
12130 @end deftypefn
12131
12132 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12133 This function is the equivalent of the preprocessor @code{__FILE__}
12134 macro and returns an address constant pointing to the file name
12135 containing the invocation of the built-in, or the empty string if
12136 the invocation is not at function scope. When used as a C++ default
12137 argument for a function @var{F}, it returns the file name of the call
12138 to @var{F} or the empty string if the call was not made at function
12139 scope.
12140
12141 For example, in the following, each call to function @code{foo} will
12142 print a line similar to @code{"file.c:123: foo: message"} with the name
12143 of the file and the line number of the @code{printf} call, the name of
12144 the function @code{foo}, followed by the word @code{message}.
12145
12146 @smallexample
12147 const char*
12148 function (const char *func = __builtin_FUNCTION ())
12149 @{
12150 return func;
12151 @}
12152
12153 void foo (void)
12154 @{
12155 printf ("%s:%i: %s: message\n", file (), line (), function ());
12156 @}
12157 @end smallexample
12158
12159 @end deftypefn
12160
12161 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12162 This function is used to flush the processor's instruction cache for
12163 the region of memory between @var{begin} inclusive and @var{end}
12164 exclusive. Some targets require that the instruction cache be
12165 flushed, after modifying memory containing code, in order to obtain
12166 deterministic behavior.
12167
12168 If the target does not require instruction cache flushes,
12169 @code{__builtin___clear_cache} has no effect. Otherwise either
12170 instructions are emitted in-line to clear the instruction cache or a
12171 call to the @code{__clear_cache} function in libgcc is made.
12172 @end deftypefn
12173
12174 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12175 This function is used to minimize cache-miss latency by moving data into
12176 a cache before it is accessed.
12177 You can insert calls to @code{__builtin_prefetch} into code for which
12178 you know addresses of data in memory that is likely to be accessed soon.
12179 If the target supports them, data prefetch instructions are generated.
12180 If the prefetch is done early enough before the access then the data will
12181 be in the cache by the time it is accessed.
12182
12183 The value of @var{addr} is the address of the memory to prefetch.
12184 There are two optional arguments, @var{rw} and @var{locality}.
12185 The value of @var{rw} is a compile-time constant one or zero; one
12186 means that the prefetch is preparing for a write to the memory address
12187 and zero, the default, means that the prefetch is preparing for a read.
12188 The value @var{locality} must be a compile-time constant integer between
12189 zero and three. A value of zero means that the data has no temporal
12190 locality, so it need not be left in the cache after the access. A value
12191 of three means that the data has a high degree of temporal locality and
12192 should be left in all levels of cache possible. Values of one and two
12193 mean, respectively, a low or moderate degree of temporal locality. The
12194 default is three.
12195
12196 @smallexample
12197 for (i = 0; i < n; i++)
12198 @{
12199 a[i] = a[i] + b[i];
12200 __builtin_prefetch (&a[i+j], 1, 1);
12201 __builtin_prefetch (&b[i+j], 0, 1);
12202 /* @r{@dots{}} */
12203 @}
12204 @end smallexample
12205
12206 Data prefetch does not generate faults if @var{addr} is invalid, but
12207 the address expression itself must be valid. For example, a prefetch
12208 of @code{p->next} does not fault if @code{p->next} is not a valid
12209 address, but evaluation faults if @code{p} is not a valid address.
12210
12211 If the target does not support data prefetch, the address expression
12212 is evaluated if it includes side effects but no other code is generated
12213 and GCC does not issue a warning.
12214 @end deftypefn
12215
12216 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12217 Returns a positive infinity, if supported by the floating-point format,
12218 else @code{DBL_MAX}. This function is suitable for implementing the
12219 ISO C macro @code{HUGE_VAL}.
12220 @end deftypefn
12221
12222 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12223 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12224 @end deftypefn
12225
12226 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12227 Similar to @code{__builtin_huge_val}, except the return
12228 type is @code{long double}.
12229 @end deftypefn
12230
12231 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12232 Similar to @code{__builtin_huge_val}, except the return type is
12233 @code{_Float@var{n}}.
12234 @end deftypefn
12235
12236 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12237 Similar to @code{__builtin_huge_val}, except the return type is
12238 @code{_Float@var{n}x}.
12239 @end deftypefn
12240
12241 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12242 This built-in implements the C99 fpclassify functionality. The first
12243 five int arguments should be the target library's notion of the
12244 possible FP classes and are used for return values. They must be
12245 constant values and they must appear in this order: @code{FP_NAN},
12246 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12247 @code{FP_ZERO}. The ellipsis is for exactly one floating-point value
12248 to classify. GCC treats the last argument as type-generic, which
12249 means it does not do default promotion from float to double.
12250 @end deftypefn
12251
12252 @deftypefn {Built-in Function} double __builtin_inf (void)
12253 Similar to @code{__builtin_huge_val}, except a warning is generated
12254 if the target floating-point format does not support infinities.
12255 @end deftypefn
12256
12257 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12258 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12259 @end deftypefn
12260
12261 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12262 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12263 @end deftypefn
12264
12265 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12266 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12267 @end deftypefn
12268
12269 @deftypefn {Built-in Function} float __builtin_inff (void)
12270 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12271 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12272 @end deftypefn
12273
12274 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12275 Similar to @code{__builtin_inf}, except the return
12276 type is @code{long double}.
12277 @end deftypefn
12278
12279 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12280 Similar to @code{__builtin_inf}, except the return
12281 type is @code{_Float@var{n}}.
12282 @end deftypefn
12283
12284 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12285 Similar to @code{__builtin_inf}, except the return
12286 type is @code{_Float@var{n}x}.
12287 @end deftypefn
12288
12289 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12290 Similar to @code{isinf}, except the return value is -1 for
12291 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12292 Note while the parameter list is an
12293 ellipsis, this function only accepts exactly one floating-point
12294 argument. GCC treats this parameter as type-generic, which means it
12295 does not do default promotion from float to double.
12296 @end deftypefn
12297
12298 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12299 This is an implementation of the ISO C99 function @code{nan}.
12300
12301 Since ISO C99 defines this function in terms of @code{strtod}, which we
12302 do not implement, a description of the parsing is in order. The string
12303 is parsed as by @code{strtol}; that is, the base is recognized by
12304 leading @samp{0} or @samp{0x} prefixes. The number parsed is placed
12305 in the significand such that the least significant bit of the number
12306 is at the least significant bit of the significand. The number is
12307 truncated to fit the significand field provided. The significand is
12308 forced to be a quiet NaN@.
12309
12310 This function, if given a string literal all of which would have been
12311 consumed by @code{strtol}, is evaluated early enough that it is considered a
12312 compile-time constant.
12313 @end deftypefn
12314
12315 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12316 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12317 @end deftypefn
12318
12319 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12320 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12321 @end deftypefn
12322
12323 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12324 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12325 @end deftypefn
12326
12327 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12328 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12329 @end deftypefn
12330
12331 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12332 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12333 @end deftypefn
12334
12335 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12336 Similar to @code{__builtin_nan}, except the return type is
12337 @code{_Float@var{n}}.
12338 @end deftypefn
12339
12340 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12341 Similar to @code{__builtin_nan}, except the return type is
12342 @code{_Float@var{n}x}.
12343 @end deftypefn
12344
12345 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12346 Similar to @code{__builtin_nan}, except the significand is forced
12347 to be a signaling NaN@. The @code{nans} function is proposed by
12348 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12349 @end deftypefn
12350
12351 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12352 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12353 @end deftypefn
12354
12355 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12356 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12357 @end deftypefn
12358
12359 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12360 Similar to @code{__builtin_nans}, except the return type is
12361 @code{_Float@var{n}}.
12362 @end deftypefn
12363
12364 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12365 Similar to @code{__builtin_nans}, except the return type is
12366 @code{_Float@var{n}x}.
12367 @end deftypefn
12368
12369 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12370 Returns one plus the index of the least significant 1-bit of @var{x}, or
12371 if @var{x} is zero, returns zero.
12372 @end deftypefn
12373
12374 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12375 Returns the number of leading 0-bits in @var{x}, starting at the most
12376 significant bit position. If @var{x} is 0, the result is undefined.
12377 @end deftypefn
12378
12379 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12380 Returns the number of trailing 0-bits in @var{x}, starting at the least
12381 significant bit position. If @var{x} is 0, the result is undefined.
12382 @end deftypefn
12383
12384 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12385 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12386 number of bits following the most significant bit that are identical
12387 to it. There are no special cases for 0 or other values.
12388 @end deftypefn
12389
12390 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12391 Returns the number of 1-bits in @var{x}.
12392 @end deftypefn
12393
12394 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12395 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12396 modulo 2.
12397 @end deftypefn
12398
12399 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12400 Similar to @code{__builtin_ffs}, except the argument type is
12401 @code{long}.
12402 @end deftypefn
12403
12404 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12405 Similar to @code{__builtin_clz}, except the argument type is
12406 @code{unsigned long}.
12407 @end deftypefn
12408
12409 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12410 Similar to @code{__builtin_ctz}, except the argument type is
12411 @code{unsigned long}.
12412 @end deftypefn
12413
12414 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12415 Similar to @code{__builtin_clrsb}, except the argument type is
12416 @code{long}.
12417 @end deftypefn
12418
12419 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12420 Similar to @code{__builtin_popcount}, except the argument type is
12421 @code{unsigned long}.
12422 @end deftypefn
12423
12424 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12425 Similar to @code{__builtin_parity}, except the argument type is
12426 @code{unsigned long}.
12427 @end deftypefn
12428
12429 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12430 Similar to @code{__builtin_ffs}, except the argument type is
12431 @code{long long}.
12432 @end deftypefn
12433
12434 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12435 Similar to @code{__builtin_clz}, except the argument type is
12436 @code{unsigned long long}.
12437 @end deftypefn
12438
12439 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12440 Similar to @code{__builtin_ctz}, except the argument type is
12441 @code{unsigned long long}.
12442 @end deftypefn
12443
12444 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12445 Similar to @code{__builtin_clrsb}, except the argument type is
12446 @code{long long}.
12447 @end deftypefn
12448
12449 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12450 Similar to @code{__builtin_popcount}, except the argument type is
12451 @code{unsigned long long}.
12452 @end deftypefn
12453
12454 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12455 Similar to @code{__builtin_parity}, except the argument type is
12456 @code{unsigned long long}.
12457 @end deftypefn
12458
12459 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12460 Returns the first argument raised to the power of the second. Unlike the
12461 @code{pow} function no guarantees about precision and rounding are made.
12462 @end deftypefn
12463
12464 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12465 Similar to @code{__builtin_powi}, except the argument and return types
12466 are @code{float}.
12467 @end deftypefn
12468
12469 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12470 Similar to @code{__builtin_powi}, except the argument and return types
12471 are @code{long double}.
12472 @end deftypefn
12473
12474 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12475 Returns @var{x} with the order of the bytes reversed; for example,
12476 @code{0xaabb} becomes @code{0xbbaa}. Byte here always means
12477 exactly 8 bits.
12478 @end deftypefn
12479
12480 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12481 Similar to @code{__builtin_bswap16}, except the argument and return types
12482 are 32 bit.
12483 @end deftypefn
12484
12485 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12486 Similar to @code{__builtin_bswap32}, except the argument and return types
12487 are 64 bit.
12488 @end deftypefn
12489
12490 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12491 On targets where the user visible pointer size is smaller than the size
12492 of an actual hardware address this function returns the extended user
12493 pointer. Targets where this is true included ILP32 mode on x86_64 or
12494 Aarch64. This function is mainly useful when writing inline assembly
12495 code.
12496 @end deftypefn
12497
12498 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12499 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12500 0, 1 or 2.
12501 @end deftypefn
12502
12503 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12504 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12505 0, 1 or 2.
12506 @end deftypefn
12507
12508 @node Target Builtins
12509 @section Built-in Functions Specific to Particular Target Machines
12510
12511 On some target machines, GCC supports many built-in functions specific
12512 to those machines. Generally these generate calls to specific machine
12513 instructions, but allow the compiler to schedule those calls.
12514
12515 @menu
12516 * AArch64 Built-in Functions::
12517 * Alpha Built-in Functions::
12518 * Altera Nios II Built-in Functions::
12519 * ARC Built-in Functions::
12520 * ARC SIMD Built-in Functions::
12521 * ARM iWMMXt Built-in Functions::
12522 * ARM C Language Extensions (ACLE)::
12523 * ARM Floating Point Status and Control Intrinsics::
12524 * ARM ARMv8-M Security Extensions::
12525 * AVR Built-in Functions::
12526 * Blackfin Built-in Functions::
12527 * FR-V Built-in Functions::
12528 * MIPS DSP Built-in Functions::
12529 * MIPS Paired-Single Support::
12530 * MIPS Loongson Built-in Functions::
12531 * MIPS SIMD Architecture (MSA) Support::
12532 * Other MIPS Built-in Functions::
12533 * MSP430 Built-in Functions::
12534 * NDS32 Built-in Functions::
12535 * picoChip Built-in Functions::
12536 * Basic PowerPC Built-in Functions::
12537 * PowerPC AltiVec/VSX Built-in Functions::
12538 * PowerPC Hardware Transactional Memory Built-in Functions::
12539 * PowerPC Atomic Memory Operation Functions::
12540 * RX Built-in Functions::
12541 * S/390 System z Built-in Functions::
12542 * SH Built-in Functions::
12543 * SPARC VIS Built-in Functions::
12544 * SPU Built-in Functions::
12545 * TI C6X Built-in Functions::
12546 * TILE-Gx Built-in Functions::
12547 * TILEPro Built-in Functions::
12548 * x86 Built-in Functions::
12549 * x86 transactional memory intrinsics::
12550 * x86 control-flow protection intrinsics::
12551 @end menu
12552
12553 @node AArch64 Built-in Functions
12554 @subsection AArch64 Built-in Functions
12555
12556 These built-in functions are available for the AArch64 family of
12557 processors.
12558 @smallexample
12559 unsigned int __builtin_aarch64_get_fpcr ()
12560 void __builtin_aarch64_set_fpcr (unsigned int)
12561 unsigned int __builtin_aarch64_get_fpsr ()
12562 void __builtin_aarch64_set_fpsr (unsigned int)
12563 @end smallexample
12564
12565 @node Alpha Built-in Functions
12566 @subsection Alpha Built-in Functions
12567
12568 These built-in functions are available for the Alpha family of
12569 processors, depending on the command-line switches used.
12570
12571 The following built-in functions are always available. They
12572 all generate the machine instruction that is part of the name.
12573
12574 @smallexample
12575 long __builtin_alpha_implver (void)
12576 long __builtin_alpha_rpcc (void)
12577 long __builtin_alpha_amask (long)
12578 long __builtin_alpha_cmpbge (long, long)
12579 long __builtin_alpha_extbl (long, long)
12580 long __builtin_alpha_extwl (long, long)
12581 long __builtin_alpha_extll (long, long)
12582 long __builtin_alpha_extql (long, long)
12583 long __builtin_alpha_extwh (long, long)
12584 long __builtin_alpha_extlh (long, long)
12585 long __builtin_alpha_extqh (long, long)
12586 long __builtin_alpha_insbl (long, long)
12587 long __builtin_alpha_inswl (long, long)
12588 long __builtin_alpha_insll (long, long)
12589 long __builtin_alpha_insql (long, long)
12590 long __builtin_alpha_inswh (long, long)
12591 long __builtin_alpha_inslh (long, long)
12592 long __builtin_alpha_insqh (long, long)
12593 long __builtin_alpha_mskbl (long, long)
12594 long __builtin_alpha_mskwl (long, long)
12595 long __builtin_alpha_mskll (long, long)
12596 long __builtin_alpha_mskql (long, long)
12597 long __builtin_alpha_mskwh (long, long)
12598 long __builtin_alpha_msklh (long, long)
12599 long __builtin_alpha_mskqh (long, long)
12600 long __builtin_alpha_umulh (long, long)
12601 long __builtin_alpha_zap (long, long)
12602 long __builtin_alpha_zapnot (long, long)
12603 @end smallexample
12604
12605 The following built-in functions are always with @option{-mmax}
12606 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12607 later. They all generate the machine instruction that is part
12608 of the name.
12609
12610 @smallexample
12611 long __builtin_alpha_pklb (long)
12612 long __builtin_alpha_pkwb (long)
12613 long __builtin_alpha_unpkbl (long)
12614 long __builtin_alpha_unpkbw (long)
12615 long __builtin_alpha_minub8 (long, long)
12616 long __builtin_alpha_minsb8 (long, long)
12617 long __builtin_alpha_minuw4 (long, long)
12618 long __builtin_alpha_minsw4 (long, long)
12619 long __builtin_alpha_maxub8 (long, long)
12620 long __builtin_alpha_maxsb8 (long, long)
12621 long __builtin_alpha_maxuw4 (long, long)
12622 long __builtin_alpha_maxsw4 (long, long)
12623 long __builtin_alpha_perr (long, long)
12624 @end smallexample
12625
12626 The following built-in functions are always with @option{-mcix}
12627 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12628 later. They all generate the machine instruction that is part
12629 of the name.
12630
12631 @smallexample
12632 long __builtin_alpha_cttz (long)
12633 long __builtin_alpha_ctlz (long)
12634 long __builtin_alpha_ctpop (long)
12635 @end smallexample
12636
12637 The following built-in functions are available on systems that use the OSF/1
12638 PALcode. Normally they invoke the @code{rduniq} and @code{wruniq}
12639 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12640 @code{rdval} and @code{wrval}.
12641
12642 @smallexample
12643 void *__builtin_thread_pointer (void)
12644 void __builtin_set_thread_pointer (void *)
12645 @end smallexample
12646
12647 @node Altera Nios II Built-in Functions
12648 @subsection Altera Nios II Built-in Functions
12649
12650 These built-in functions are available for the Altera Nios II
12651 family of processors.
12652
12653 The following built-in functions are always available. They
12654 all generate the machine instruction that is part of the name.
12655
12656 @example
12657 int __builtin_ldbio (volatile const void *)
12658 int __builtin_ldbuio (volatile const void *)
12659 int __builtin_ldhio (volatile const void *)
12660 int __builtin_ldhuio (volatile const void *)
12661 int __builtin_ldwio (volatile const void *)
12662 void __builtin_stbio (volatile void *, int)
12663 void __builtin_sthio (volatile void *, int)
12664 void __builtin_stwio (volatile void *, int)
12665 void __builtin_sync (void)
12666 int __builtin_rdctl (int)
12667 int __builtin_rdprs (int, int)
12668 void __builtin_wrctl (int, int)
12669 void __builtin_flushd (volatile void *)
12670 void __builtin_flushda (volatile void *)
12671 int __builtin_wrpie (int);
12672 void __builtin_eni (int);
12673 int __builtin_ldex (volatile const void *)
12674 int __builtin_stex (volatile void *, int)
12675 int __builtin_ldsex (volatile const void *)
12676 int __builtin_stsex (volatile void *, int)
12677 @end example
12678
12679 The following built-in functions are always available. They
12680 all generate a Nios II Custom Instruction. The name of the
12681 function represents the types that the function takes and
12682 returns. The letter before the @code{n} is the return type
12683 or void if absent. The @code{n} represents the first parameter
12684 to all the custom instructions, the custom instruction number.
12685 The two letters after the @code{n} represent the up to two
12686 parameters to the function.
12687
12688 The letters represent the following data types:
12689 @table @code
12690 @item <no letter>
12691 @code{void} for return type and no parameter for parameter types.
12692
12693 @item i
12694 @code{int} for return type and parameter type
12695
12696 @item f
12697 @code{float} for return type and parameter type
12698
12699 @item p
12700 @code{void *} for return type and parameter type
12701
12702 @end table
12703
12704 And the function names are:
12705 @example
12706 void __builtin_custom_n (void)
12707 void __builtin_custom_ni (int)
12708 void __builtin_custom_nf (float)
12709 void __builtin_custom_np (void *)
12710 void __builtin_custom_nii (int, int)
12711 void __builtin_custom_nif (int, float)
12712 void __builtin_custom_nip (int, void *)
12713 void __builtin_custom_nfi (float, int)
12714 void __builtin_custom_nff (float, float)
12715 void __builtin_custom_nfp (float, void *)
12716 void __builtin_custom_npi (void *, int)
12717 void __builtin_custom_npf (void *, float)
12718 void __builtin_custom_npp (void *, void *)
12719 int __builtin_custom_in (void)
12720 int __builtin_custom_ini (int)
12721 int __builtin_custom_inf (float)
12722 int __builtin_custom_inp (void *)
12723 int __builtin_custom_inii (int, int)
12724 int __builtin_custom_inif (int, float)
12725 int __builtin_custom_inip (int, void *)
12726 int __builtin_custom_infi (float, int)
12727 int __builtin_custom_inff (float, float)
12728 int __builtin_custom_infp (float, void *)
12729 int __builtin_custom_inpi (void *, int)
12730 int __builtin_custom_inpf (void *, float)
12731 int __builtin_custom_inpp (void *, void *)
12732 float __builtin_custom_fn (void)
12733 float __builtin_custom_fni (int)
12734 float __builtin_custom_fnf (float)
12735 float __builtin_custom_fnp (void *)
12736 float __builtin_custom_fnii (int, int)
12737 float __builtin_custom_fnif (int, float)
12738 float __builtin_custom_fnip (int, void *)
12739 float __builtin_custom_fnfi (float, int)
12740 float __builtin_custom_fnff (float, float)
12741 float __builtin_custom_fnfp (float, void *)
12742 float __builtin_custom_fnpi (void *, int)
12743 float __builtin_custom_fnpf (void *, float)
12744 float __builtin_custom_fnpp (void *, void *)
12745 void * __builtin_custom_pn (void)
12746 void * __builtin_custom_pni (int)
12747 void * __builtin_custom_pnf (float)
12748 void * __builtin_custom_pnp (void *)
12749 void * __builtin_custom_pnii (int, int)
12750 void * __builtin_custom_pnif (int, float)
12751 void * __builtin_custom_pnip (int, void *)
12752 void * __builtin_custom_pnfi (float, int)
12753 void * __builtin_custom_pnff (float, float)
12754 void * __builtin_custom_pnfp (float, void *)
12755 void * __builtin_custom_pnpi (void *, int)
12756 void * __builtin_custom_pnpf (void *, float)
12757 void * __builtin_custom_pnpp (void *, void *)
12758 @end example
12759
12760 @node ARC Built-in Functions
12761 @subsection ARC Built-in Functions
12762
12763 The following built-in functions are provided for ARC targets. The
12764 built-ins generate the corresponding assembly instructions. In the
12765 examples given below, the generated code often requires an operand or
12766 result to be in a register. Where necessary further code will be
12767 generated to ensure this is true, but for brevity this is not
12768 described in each case.
12769
12770 @emph{Note:} Using a built-in to generate an instruction not supported
12771 by a target may cause problems. At present the compiler is not
12772 guaranteed to detect such misuse, and as a result an internal compiler
12773 error may be generated.
12774
12775 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12776 Return 1 if @var{val} is known to have the byte alignment given
12777 by @var{alignval}, otherwise return 0.
12778 Note that this is different from
12779 @smallexample
12780 __alignof__(*(char *)@var{val}) >= alignval
12781 @end smallexample
12782 because __alignof__ sees only the type of the dereference, whereas
12783 __builtin_arc_align uses alignment information from the pointer
12784 as well as from the pointed-to type.
12785 The information available will depend on optimization level.
12786 @end deftypefn
12787
12788 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12789 Generates
12790 @example
12791 brk
12792 @end example
12793 @end deftypefn
12794
12795 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12796 The operand is the number of a register to be read. Generates:
12797 @example
12798 mov @var{dest}, r@var{regno}
12799 @end example
12800 where the value in @var{dest} will be the result returned from the
12801 built-in.
12802 @end deftypefn
12803
12804 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12805 The first operand is the number of a register to be written, the
12806 second operand is a compile time constant to write into that
12807 register. Generates:
12808 @example
12809 mov r@var{regno}, @var{val}
12810 @end example
12811 @end deftypefn
12812
12813 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12814 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12815 Generates:
12816 @example
12817 divaw @var{dest}, @var{a}, @var{b}
12818 @end example
12819 where the value in @var{dest} will be the result returned from the
12820 built-in.
12821 @end deftypefn
12822
12823 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12824 Generates
12825 @example
12826 flag @var{a}
12827 @end example
12828 @end deftypefn
12829
12830 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12831 The operand, @var{auxv}, is the address of an auxiliary register and
12832 must be a compile time constant. Generates:
12833 @example
12834 lr @var{dest}, [@var{auxr}]
12835 @end example
12836 Where the value in @var{dest} will be the result returned from the
12837 built-in.
12838 @end deftypefn
12839
12840 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12841 Only available with @option{-mmul64}. Generates:
12842 @example
12843 mul64 @var{a}, @var{b}
12844 @end example
12845 @end deftypefn
12846
12847 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12848 Only available with @option{-mmul64}. Generates:
12849 @example
12850 mulu64 @var{a}, @var{b}
12851 @end example
12852 @end deftypefn
12853
12854 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12855 Generates:
12856 @example
12857 nop
12858 @end example
12859 @end deftypefn
12860
12861 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12862 Only valid if the @samp{norm} instruction is available through the
12863 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12864 Generates:
12865 @example
12866 norm @var{dest}, @var{src}
12867 @end example
12868 Where the value in @var{dest} will be the result returned from the
12869 built-in.
12870 @end deftypefn
12871
12872 @deftypefn {Built-in Function} {short int} __builtin_arc_normw (short int @var{src})
12873 Only valid if the @samp{normw} instruction is available through the
12874 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12875 Generates:
12876 @example
12877 normw @var{dest}, @var{src}
12878 @end example
12879 Where the value in @var{dest} will be the result returned from the
12880 built-in.
12881 @end deftypefn
12882
12883 @deftypefn {Built-in Function} void __builtin_arc_rtie (void)
12884 Generates:
12885 @example
12886 rtie
12887 @end example
12888 @end deftypefn
12889
12890 @deftypefn {Built-in Function} void __builtin_arc_sleep (int @var{a}
12891 Generates:
12892 @example
12893 sleep @var{a}
12894 @end example
12895 @end deftypefn
12896
12897 @deftypefn {Built-in Function} void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12898 The first argument, @var{auxv}, is the address of an auxiliary
12899 register, the second argument, @var{val}, is a compile time constant
12900 to be written to the register. Generates:
12901 @example
12902 sr @var{auxr}, [@var{val}]
12903 @end example
12904 @end deftypefn
12905
12906 @deftypefn {Built-in Function} int __builtin_arc_swap (int @var{src})
12907 Only valid with @option{-mswap}. Generates:
12908 @example
12909 swap @var{dest}, @var{src}
12910 @end example
12911 Where the value in @var{dest} will be the result returned from the
12912 built-in.
12913 @end deftypefn
12914
12915 @deftypefn {Built-in Function} void __builtin_arc_swi (void)
12916 Generates:
12917 @example
12918 swi
12919 @end example
12920 @end deftypefn
12921
12922 @deftypefn {Built-in Function} void __builtin_arc_sync (void)
12923 Only available with @option{-mcpu=ARC700}. Generates:
12924 @example
12925 sync
12926 @end example
12927 @end deftypefn
12928
12929 @deftypefn {Built-in Function} void __builtin_arc_trap_s (unsigned int @var{c})
12930 Only available with @option{-mcpu=ARC700}. Generates:
12931 @example
12932 trap_s @var{c}
12933 @end example
12934 @end deftypefn
12935
12936 @deftypefn {Built-in Function} void __builtin_arc_unimp_s (void)
12937 Only available with @option{-mcpu=ARC700}. Generates:
12938 @example
12939 unimp_s
12940 @end example
12941 @end deftypefn
12942
12943 The instructions generated by the following builtins are not
12944 considered as candidates for scheduling. They are not moved around by
12945 the compiler during scheduling, and thus can be expected to appear
12946 where they are put in the C code:
12947 @example
12948 __builtin_arc_brk()
12949 __builtin_arc_core_read()
12950 __builtin_arc_core_write()
12951 __builtin_arc_flag()
12952 __builtin_arc_lr()
12953 __builtin_arc_sleep()
12954 __builtin_arc_sr()
12955 __builtin_arc_swi()
12956 @end example
12957
12958 @node ARC SIMD Built-in Functions
12959 @subsection ARC SIMD Built-in Functions
12960
12961 SIMD builtins provided by the compiler can be used to generate the
12962 vector instructions. This section describes the available builtins
12963 and their usage in programs. With the @option{-msimd} option, the
12964 compiler provides 128-bit vector types, which can be specified using
12965 the @code{vector_size} attribute. The header file @file{arc-simd.h}
12966 can be included to use the following predefined types:
12967 @example
12968 typedef int __v4si __attribute__((vector_size(16)));
12969 typedef short __v8hi __attribute__((vector_size(16)));
12970 @end example
12971
12972 These types can be used to define 128-bit variables. The built-in
12973 functions listed in the following section can be used on these
12974 variables to generate the vector operations.
12975
12976 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12977 @file{arc-simd.h} also provides equivalent macros called
12978 @code{_@var{someinsn}} that can be used for programming ease and
12979 improved readability. The following macros for DMA control are also
12980 provided:
12981 @example
12982 #define _setup_dma_in_channel_reg _vdiwr
12983 #define _setup_dma_out_channel_reg _vdowr
12984 @end example
12985
12986 The following is a complete list of all the SIMD built-ins provided
12987 for ARC, grouped by calling signature.
12988
12989 The following take two @code{__v8hi} arguments and return a
12990 @code{__v8hi} result:
12991 @example
12992 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12993 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12994 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12995 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12996 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12997 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12998 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12999 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
13000 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
13001 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
13002 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
13003 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
13004 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
13005 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
13006 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
13007 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
13008 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
13009 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
13010 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
13011 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
13012 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
13013 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13014 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13015 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13016 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13017 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13018 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13019 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13020 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13021 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13022 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13023 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13024 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13025 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13026 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13027 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13028 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13029 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13030 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13031 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13032 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13033 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13034 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13035 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13036 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13037 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13038 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13039 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13040 @end example
13041
13042 The following take one @code{__v8hi} and one @code{int} argument and return a
13043 @code{__v8hi} result:
13044
13045 @example
13046 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13047 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13048 __v8hi __builtin_arc_vbminw (__v8hi, int)
13049 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13050 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13051 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13052 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13053 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13054 @end example
13055
13056 The following take one @code{__v8hi} argument and one @code{int} argument which
13057 must be a 3-bit compile time constant indicating a register number
13058 I0-I7. They return a @code{__v8hi} result.
13059 @example
13060 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13061 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13062 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13063 @end example
13064
13065 The following take one @code{__v8hi} argument and one @code{int}
13066 argument which must be a 6-bit compile time constant. They return a
13067 @code{__v8hi} result.
13068 @example
13069 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13070 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13071 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13072 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13073 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13074 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13075 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13076 @end example
13077
13078 The following take one @code{__v8hi} argument and one @code{int} argument which
13079 must be a 8-bit compile time constant. They return a @code{__v8hi}
13080 result.
13081 @example
13082 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13083 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13084 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13085 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13086 @end example
13087
13088 The following take two @code{int} arguments, the second of which which
13089 must be a 8-bit compile time constant. They return a @code{__v8hi}
13090 result:
13091 @example
13092 __v8hi __builtin_arc_vmovaw (int, const int)
13093 __v8hi __builtin_arc_vmovw (int, const int)
13094 __v8hi __builtin_arc_vmovzw (int, const int)
13095 @end example
13096
13097 The following take a single @code{__v8hi} argument and return a
13098 @code{__v8hi} result:
13099 @example
13100 __v8hi __builtin_arc_vabsaw (__v8hi)
13101 __v8hi __builtin_arc_vabsw (__v8hi)
13102 __v8hi __builtin_arc_vaddsuw (__v8hi)
13103 __v8hi __builtin_arc_vexch1 (__v8hi)
13104 __v8hi __builtin_arc_vexch2 (__v8hi)
13105 __v8hi __builtin_arc_vexch4 (__v8hi)
13106 __v8hi __builtin_arc_vsignw (__v8hi)
13107 __v8hi __builtin_arc_vupbaw (__v8hi)
13108 __v8hi __builtin_arc_vupbw (__v8hi)
13109 __v8hi __builtin_arc_vupsbaw (__v8hi)
13110 __v8hi __builtin_arc_vupsbw (__v8hi)
13111 @end example
13112
13113 The following take two @code{int} arguments and return no result:
13114 @example
13115 void __builtin_arc_vdirun (int, int)
13116 void __builtin_arc_vdorun (int, int)
13117 @end example
13118
13119 The following take two @code{int} arguments and return no result. The
13120 first argument must a 3-bit compile time constant indicating one of
13121 the DR0-DR7 DMA setup channels:
13122 @example
13123 void __builtin_arc_vdiwr (const int, int)
13124 void __builtin_arc_vdowr (const int, int)
13125 @end example
13126
13127 The following take an @code{int} argument and return no result:
13128 @example
13129 void __builtin_arc_vendrec (int)
13130 void __builtin_arc_vrec (int)
13131 void __builtin_arc_vrecrun (int)
13132 void __builtin_arc_vrun (int)
13133 @end example
13134
13135 The following take a @code{__v8hi} argument and two @code{int}
13136 arguments and return a @code{__v8hi} result. The second argument must
13137 be a 3-bit compile time constants, indicating one the registers I0-I7,
13138 and the third argument must be an 8-bit compile time constant.
13139
13140 @emph{Note:} Although the equivalent hardware instructions do not take
13141 an SIMD register as an operand, these builtins overwrite the relevant
13142 bits of the @code{__v8hi} register provided as the first argument with
13143 the value loaded from the @code{[Ib, u8]} location in the SDM.
13144
13145 @example
13146 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13147 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13148 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13149 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13150 @end example
13151
13152 The following take two @code{int} arguments and return a @code{__v8hi}
13153 result. The first argument must be a 3-bit compile time constants,
13154 indicating one the registers I0-I7, and the second argument must be an
13155 8-bit compile time constant.
13156
13157 @example
13158 __v8hi __builtin_arc_vld128 (const int, const int)
13159 __v8hi __builtin_arc_vld64w (const int, const int)
13160 @end example
13161
13162 The following take a @code{__v8hi} argument and two @code{int}
13163 arguments and return no result. The second argument must be a 3-bit
13164 compile time constants, indicating one the registers I0-I7, and the
13165 third argument must be an 8-bit compile time constant.
13166
13167 @example
13168 void __builtin_arc_vst128 (__v8hi, const int, const int)
13169 void __builtin_arc_vst64 (__v8hi, const int, const int)
13170 @end example
13171
13172 The following take a @code{__v8hi} argument and three @code{int}
13173 arguments and return no result. The second argument must be a 3-bit
13174 compile-time constant, identifying the 16-bit sub-register to be
13175 stored, the third argument must be a 3-bit compile time constants,
13176 indicating one the registers I0-I7, and the fourth argument must be an
13177 8-bit compile time constant.
13178
13179 @example
13180 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13181 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13182 @end example
13183
13184 @node ARM iWMMXt Built-in Functions
13185 @subsection ARM iWMMXt Built-in Functions
13186
13187 These built-in functions are available for the ARM family of
13188 processors when the @option{-mcpu=iwmmxt} switch is used:
13189
13190 @smallexample
13191 typedef int v2si __attribute__ ((vector_size (8)));
13192 typedef short v4hi __attribute__ ((vector_size (8)));
13193 typedef char v8qi __attribute__ ((vector_size (8)));
13194
13195 int __builtin_arm_getwcgr0 (void)
13196 void __builtin_arm_setwcgr0 (int)
13197 int __builtin_arm_getwcgr1 (void)
13198 void __builtin_arm_setwcgr1 (int)
13199 int __builtin_arm_getwcgr2 (void)
13200 void __builtin_arm_setwcgr2 (int)
13201 int __builtin_arm_getwcgr3 (void)
13202 void __builtin_arm_setwcgr3 (int)
13203 int __builtin_arm_textrmsb (v8qi, int)
13204 int __builtin_arm_textrmsh (v4hi, int)
13205 int __builtin_arm_textrmsw (v2si, int)
13206 int __builtin_arm_textrmub (v8qi, int)
13207 int __builtin_arm_textrmuh (v4hi, int)
13208 int __builtin_arm_textrmuw (v2si, int)
13209 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13210 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13211 v2si __builtin_arm_tinsrw (v2si, int, int)
13212 long long __builtin_arm_tmia (long long, int, int)
13213 long long __builtin_arm_tmiabb (long long, int, int)
13214 long long __builtin_arm_tmiabt (long long, int, int)
13215 long long __builtin_arm_tmiaph (long long, int, int)
13216 long long __builtin_arm_tmiatb (long long, int, int)
13217 long long __builtin_arm_tmiatt (long long, int, int)
13218 int __builtin_arm_tmovmskb (v8qi)
13219 int __builtin_arm_tmovmskh (v4hi)
13220 int __builtin_arm_tmovmskw (v2si)
13221 long long __builtin_arm_waccb (v8qi)
13222 long long __builtin_arm_wacch (v4hi)
13223 long long __builtin_arm_waccw (v2si)
13224 v8qi __builtin_arm_waddb (v8qi, v8qi)
13225 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13226 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13227 v4hi __builtin_arm_waddh (v4hi, v4hi)
13228 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13229 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13230 v2si __builtin_arm_waddw (v2si, v2si)
13231 v2si __builtin_arm_waddwss (v2si, v2si)
13232 v2si __builtin_arm_waddwus (v2si, v2si)
13233 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13234 long long __builtin_arm_wand(long long, long long)
13235 long long __builtin_arm_wandn (long long, long long)
13236 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13237 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13238 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13239 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13240 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13241 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13242 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13243 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13244 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13245 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13246 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13247 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13248 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13249 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13250 long long __builtin_arm_wmacsz (v4hi, v4hi)
13251 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13252 long long __builtin_arm_wmacuz (v4hi, v4hi)
13253 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13254 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13255 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13256 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13257 v2si __builtin_arm_wmaxsw (v2si, v2si)
13258 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13259 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13260 v2si __builtin_arm_wmaxuw (v2si, v2si)
13261 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13262 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13263 v2si __builtin_arm_wminsw (v2si, v2si)
13264 v8qi __builtin_arm_wminub (v8qi, v8qi)
13265 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13266 v2si __builtin_arm_wminuw (v2si, v2si)
13267 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13268 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13269 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13270 long long __builtin_arm_wor (long long, long long)
13271 v2si __builtin_arm_wpackdss (long long, long long)
13272 v2si __builtin_arm_wpackdus (long long, long long)
13273 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13274 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13275 v4hi __builtin_arm_wpackwss (v2si, v2si)
13276 v4hi __builtin_arm_wpackwus (v2si, v2si)
13277 long long __builtin_arm_wrord (long long, long long)
13278 long long __builtin_arm_wrordi (long long, int)
13279 v4hi __builtin_arm_wrorh (v4hi, long long)
13280 v4hi __builtin_arm_wrorhi (v4hi, int)
13281 v2si __builtin_arm_wrorw (v2si, long long)
13282 v2si __builtin_arm_wrorwi (v2si, int)
13283 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13284 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13285 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13286 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13287 v4hi __builtin_arm_wshufh (v4hi, int)
13288 long long __builtin_arm_wslld (long long, long long)
13289 long long __builtin_arm_wslldi (long long, int)
13290 v4hi __builtin_arm_wsllh (v4hi, long long)
13291 v4hi __builtin_arm_wsllhi (v4hi, int)
13292 v2si __builtin_arm_wsllw (v2si, long long)
13293 v2si __builtin_arm_wsllwi (v2si, int)
13294 long long __builtin_arm_wsrad (long long, long long)
13295 long long __builtin_arm_wsradi (long long, int)
13296 v4hi __builtin_arm_wsrah (v4hi, long long)
13297 v4hi __builtin_arm_wsrahi (v4hi, int)
13298 v2si __builtin_arm_wsraw (v2si, long long)
13299 v2si __builtin_arm_wsrawi (v2si, int)
13300 long long __builtin_arm_wsrld (long long, long long)
13301 long long __builtin_arm_wsrldi (long long, int)
13302 v4hi __builtin_arm_wsrlh (v4hi, long long)
13303 v4hi __builtin_arm_wsrlhi (v4hi, int)
13304 v2si __builtin_arm_wsrlw (v2si, long long)
13305 v2si __builtin_arm_wsrlwi (v2si, int)
13306 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13307 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13308 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13309 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13310 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13311 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13312 v2si __builtin_arm_wsubw (v2si, v2si)
13313 v2si __builtin_arm_wsubwss (v2si, v2si)
13314 v2si __builtin_arm_wsubwus (v2si, v2si)
13315 v4hi __builtin_arm_wunpckehsb (v8qi)
13316 v2si __builtin_arm_wunpckehsh (v4hi)
13317 long long __builtin_arm_wunpckehsw (v2si)
13318 v4hi __builtin_arm_wunpckehub (v8qi)
13319 v2si __builtin_arm_wunpckehuh (v4hi)
13320 long long __builtin_arm_wunpckehuw (v2si)
13321 v4hi __builtin_arm_wunpckelsb (v8qi)
13322 v2si __builtin_arm_wunpckelsh (v4hi)
13323 long long __builtin_arm_wunpckelsw (v2si)
13324 v4hi __builtin_arm_wunpckelub (v8qi)
13325 v2si __builtin_arm_wunpckeluh (v4hi)
13326 long long __builtin_arm_wunpckeluw (v2si)
13327 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13328 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13329 v2si __builtin_arm_wunpckihw (v2si, v2si)
13330 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13331 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13332 v2si __builtin_arm_wunpckilw (v2si, v2si)
13333 long long __builtin_arm_wxor (long long, long long)
13334 long long __builtin_arm_wzero ()
13335 @end smallexample
13336
13337
13338 @node ARM C Language Extensions (ACLE)
13339 @subsection ARM C Language Extensions (ACLE)
13340
13341 GCC implements extensions for C as described in the ARM C Language
13342 Extensions (ACLE) specification, which can be found at
13343 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13344
13345 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13346 the ARM C Language Extensions Specification. The complete list of Advanced SIMD
13347 intrinsics can be found at
13348 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13349 The built-in intrinsics for the Advanced SIMD extension are available when
13350 NEON is enabled.
13351
13352 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully. Both
13353 back ends support CRC32 intrinsics and the ARM back end supports the
13354 Coprocessor intrinsics, all from @file{arm_acle.h}. The ARM back end's 16-bit
13355 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13356 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13357 intrinsics yet.
13358
13359 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13360 availability of extensions.
13361
13362 @node ARM Floating Point Status and Control Intrinsics
13363 @subsection ARM Floating Point Status and Control Intrinsics
13364
13365 These built-in functions are available for the ARM family of
13366 processors with floating-point unit.
13367
13368 @smallexample
13369 unsigned int __builtin_arm_get_fpscr ()
13370 void __builtin_arm_set_fpscr (unsigned int)
13371 @end smallexample
13372
13373 @node ARM ARMv8-M Security Extensions
13374 @subsection ARM ARMv8-M Security Extensions
13375
13376 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13377 Security Extensions: Requirements on Development Tools Engineering
13378 Specification, which can be found at
13379 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13380
13381 As part of the Security Extensions GCC implements two new function attributes:
13382 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13383
13384 As part of the Security Extensions GCC implements the intrinsics below. FPTR
13385 is used here to mean any function pointer type.
13386
13387 @smallexample
13388 cmse_address_info_t cmse_TT (void *)
13389 cmse_address_info_t cmse_TT_fptr (FPTR)
13390 cmse_address_info_t cmse_TTT (void *)
13391 cmse_address_info_t cmse_TTT_fptr (FPTR)
13392 cmse_address_info_t cmse_TTA (void *)
13393 cmse_address_info_t cmse_TTA_fptr (FPTR)
13394 cmse_address_info_t cmse_TTAT (void *)
13395 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13396 void * cmse_check_address_range (void *, size_t, int)
13397 typeof(p) cmse_nsfptr_create (FPTR p)
13398 intptr_t cmse_is_nsfptr (FPTR)
13399 int cmse_nonsecure_caller (void)
13400 @end smallexample
13401
13402 @node AVR Built-in Functions
13403 @subsection AVR Built-in Functions
13404
13405 For each built-in function for AVR, there is an equally named,
13406 uppercase built-in macro defined. That way users can easily query if
13407 or if not a specific built-in is implemented or not. For example, if
13408 @code{__builtin_avr_nop} is available the macro
13409 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13410
13411 @table @code
13412
13413 @item void __builtin_avr_nop (void)
13414 @itemx void __builtin_avr_sei (void)
13415 @itemx void __builtin_avr_cli (void)
13416 @itemx void __builtin_avr_sleep (void)
13417 @itemx void __builtin_avr_wdr (void)
13418 @itemx unsigned char __builtin_avr_swap (unsigned char)
13419 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13420 @itemx int __builtin_avr_fmuls (char, char)
13421 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13422 These built-in functions map to the respective machine
13423 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13424 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13425 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13426 as library call if no hardware multiplier is available.
13427
13428 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13429 Delay execution for @var{ticks} cycles. Note that this
13430 built-in does not take into account the effect of interrupts that
13431 might increase delay time. @var{ticks} must be a compile-time
13432 integer constant; delays with a variable number of cycles are not supported.
13433
13434 @item char __builtin_avr_flash_segment (const __memx void*)
13435 This built-in takes a byte address to the 24-bit
13436 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13437 the number of the flash segment (the 64 KiB chunk) where the address
13438 points to. Counting starts at @code{0}.
13439 If the address does not point to flash memory, return @code{-1}.
13440
13441 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13442 Insert bits from @var{bits} into @var{val} and return the resulting
13443 value. The nibbles of @var{map} determine how the insertion is
13444 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13445 @enumerate
13446 @item If @var{X} is @code{0xf},
13447 then the @var{n}-th bit of @var{val} is returned unaltered.
13448
13449 @item If X is in the range 0@dots{}7,
13450 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13451
13452 @item If X is in the range 8@dots{}@code{0xe},
13453 then the @var{n}-th result bit is undefined.
13454 @end enumerate
13455
13456 @noindent
13457 One typical use case for this built-in is adjusting input and
13458 output values to non-contiguous port layouts. Some examples:
13459
13460 @smallexample
13461 // same as val, bits is unused
13462 __builtin_avr_insert_bits (0xffffffff, bits, val)
13463 @end smallexample
13464
13465 @smallexample
13466 // same as bits, val is unused
13467 __builtin_avr_insert_bits (0x76543210, bits, val)
13468 @end smallexample
13469
13470 @smallexample
13471 // same as rotating bits by 4
13472 __builtin_avr_insert_bits (0x32107654, bits, 0)
13473 @end smallexample
13474
13475 @smallexample
13476 // high nibble of result is the high nibble of val
13477 // low nibble of result is the low nibble of bits
13478 __builtin_avr_insert_bits (0xffff3210, bits, val)
13479 @end smallexample
13480
13481 @smallexample
13482 // reverse the bit order of bits
13483 __builtin_avr_insert_bits (0x01234567, bits, 0)
13484 @end smallexample
13485
13486 @item void __builtin_avr_nops (unsigned count)
13487 Insert @var{count} @code{NOP} instructions.
13488 The number of instructions must be a compile-time integer constant.
13489
13490 @end table
13491
13492 @noindent
13493 There are many more AVR-specific built-in functions that are used to
13494 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13495 section 7.18a.6. You don't need to use these built-ins directly.
13496 Instead, use the declarations as supplied by the @code{stdfix.h} header
13497 with GNU-C99:
13498
13499 @smallexample
13500 #include <stdfix.h>
13501
13502 // Re-interpret the bit representation of unsigned 16-bit
13503 // integer @var{uval} as Q-format 0.16 value.
13504 unsigned fract get_bits (uint_ur_t uval)
13505 @{
13506 return urbits (uval);
13507 @}
13508 @end smallexample
13509
13510 @node Blackfin Built-in Functions
13511 @subsection Blackfin Built-in Functions
13512
13513 Currently, there are two Blackfin-specific built-in functions. These are
13514 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13515 using inline assembly; by using these built-in functions the compiler can
13516 automatically add workarounds for hardware errata involving these
13517 instructions. These functions are named as follows:
13518
13519 @smallexample
13520 void __builtin_bfin_csync (void)
13521 void __builtin_bfin_ssync (void)
13522 @end smallexample
13523
13524 @node FR-V Built-in Functions
13525 @subsection FR-V Built-in Functions
13526
13527 GCC provides many FR-V-specific built-in functions. In general,
13528 these functions are intended to be compatible with those described
13529 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13530 Semiconductor}. The two exceptions are @code{__MDUNPACKH} and
13531 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13532 pointer rather than by value.
13533
13534 Most of the functions are named after specific FR-V instructions.
13535 Such functions are said to be ``directly mapped'' and are summarized
13536 here in tabular form.
13537
13538 @menu
13539 * Argument Types::
13540 * Directly-mapped Integer Functions::
13541 * Directly-mapped Media Functions::
13542 * Raw read/write Functions::
13543 * Other Built-in Functions::
13544 @end menu
13545
13546 @node Argument Types
13547 @subsubsection Argument Types
13548
13549 The arguments to the built-in functions can be divided into three groups:
13550 register numbers, compile-time constants and run-time values. In order
13551 to make this classification clear at a glance, the arguments and return
13552 values are given the following pseudo types:
13553
13554 @multitable @columnfractions .20 .30 .15 .35
13555 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13556 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13557 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13558 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13559 @item @code{uw2} @tab @code{unsigned long long} @tab No
13560 @tab an unsigned doubleword
13561 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13562 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13563 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13564 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13565 @end multitable
13566
13567 These pseudo types are not defined by GCC, they are simply a notational
13568 convenience used in this manual.
13569
13570 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13571 and @code{sw2} are evaluated at run time. They correspond to
13572 register operands in the underlying FR-V instructions.
13573
13574 @code{const} arguments represent immediate operands in the underlying
13575 FR-V instructions. They must be compile-time constants.
13576
13577 @code{acc} arguments are evaluated at compile time and specify the number
13578 of an accumulator register. For example, an @code{acc} argument of 2
13579 selects the ACC2 register.
13580
13581 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13582 number of an IACC register. See @pxref{Other Built-in Functions}
13583 for more details.
13584
13585 @node Directly-mapped Integer Functions
13586 @subsubsection Directly-Mapped Integer Functions
13587
13588 The functions listed below map directly to FR-V I-type instructions.
13589
13590 @multitable @columnfractions .45 .32 .23
13591 @item Function prototype @tab Example usage @tab Assembly output
13592 @item @code{sw1 __ADDSS (sw1, sw1)}
13593 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13594 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13595 @item @code{sw1 __SCAN (sw1, sw1)}
13596 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13597 @tab @code{SCAN @var{a},@var{b},@var{c}}
13598 @item @code{sw1 __SCUTSS (sw1)}
13599 @tab @code{@var{b} = __SCUTSS (@var{a})}
13600 @tab @code{SCUTSS @var{a},@var{b}}
13601 @item @code{sw1 __SLASS (sw1, sw1)}
13602 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13603 @tab @code{SLASS @var{a},@var{b},@var{c}}
13604 @item @code{void __SMASS (sw1, sw1)}
13605 @tab @code{__SMASS (@var{a}, @var{b})}
13606 @tab @code{SMASS @var{a},@var{b}}
13607 @item @code{void __SMSSS (sw1, sw1)}
13608 @tab @code{__SMSSS (@var{a}, @var{b})}
13609 @tab @code{SMSSS @var{a},@var{b}}
13610 @item @code{void __SMU (sw1, sw1)}
13611 @tab @code{__SMU (@var{a}, @var{b})}
13612 @tab @code{SMU @var{a},@var{b}}
13613 @item @code{sw2 __SMUL (sw1, sw1)}
13614 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13615 @tab @code{SMUL @var{a},@var{b},@var{c}}
13616 @item @code{sw1 __SUBSS (sw1, sw1)}
13617 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13618 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13619 @item @code{uw2 __UMUL (uw1, uw1)}
13620 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13621 @tab @code{UMUL @var{a},@var{b},@var{c}}
13622 @end multitable
13623
13624 @node Directly-mapped Media Functions
13625 @subsubsection Directly-Mapped Media Functions
13626
13627 The functions listed below map directly to FR-V M-type instructions.
13628
13629 @multitable @columnfractions .45 .32 .23
13630 @item Function prototype @tab Example usage @tab Assembly output
13631 @item @code{uw1 __MABSHS (sw1)}
13632 @tab @code{@var{b} = __MABSHS (@var{a})}
13633 @tab @code{MABSHS @var{a},@var{b}}
13634 @item @code{void __MADDACCS (acc, acc)}
13635 @tab @code{__MADDACCS (@var{b}, @var{a})}
13636 @tab @code{MADDACCS @var{a},@var{b}}
13637 @item @code{sw1 __MADDHSS (sw1, sw1)}
13638 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13639 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13640 @item @code{uw1 __MADDHUS (uw1, uw1)}
13641 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13642 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13643 @item @code{uw1 __MAND (uw1, uw1)}
13644 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13645 @tab @code{MAND @var{a},@var{b},@var{c}}
13646 @item @code{void __MASACCS (acc, acc)}
13647 @tab @code{__MASACCS (@var{b}, @var{a})}
13648 @tab @code{MASACCS @var{a},@var{b}}
13649 @item @code{uw1 __MAVEH (uw1, uw1)}
13650 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13651 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13652 @item @code{uw2 __MBTOH (uw1)}
13653 @tab @code{@var{b} = __MBTOH (@var{a})}
13654 @tab @code{MBTOH @var{a},@var{b}}
13655 @item @code{void __MBTOHE (uw1 *, uw1)}
13656 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13657 @tab @code{MBTOHE @var{a},@var{b}}
13658 @item @code{void __MCLRACC (acc)}
13659 @tab @code{__MCLRACC (@var{a})}
13660 @tab @code{MCLRACC @var{a}}
13661 @item @code{void __MCLRACCA (void)}
13662 @tab @code{__MCLRACCA ()}
13663 @tab @code{MCLRACCA}
13664 @item @code{uw1 __Mcop1 (uw1, uw1)}
13665 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13666 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13667 @item @code{uw1 __Mcop2 (uw1, uw1)}
13668 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13669 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13670 @item @code{uw1 __MCPLHI (uw2, const)}
13671 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13672 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13673 @item @code{uw1 __MCPLI (uw2, const)}
13674 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13675 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13676 @item @code{void __MCPXIS (acc, sw1, sw1)}
13677 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13678 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13679 @item @code{void __MCPXIU (acc, uw1, uw1)}
13680 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13681 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13682 @item @code{void __MCPXRS (acc, sw1, sw1)}
13683 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13684 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13685 @item @code{void __MCPXRU (acc, uw1, uw1)}
13686 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13687 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13688 @item @code{uw1 __MCUT (acc, uw1)}
13689 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13690 @tab @code{MCUT @var{a},@var{b},@var{c}}
13691 @item @code{uw1 __MCUTSS (acc, sw1)}
13692 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13693 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13694 @item @code{void __MDADDACCS (acc, acc)}
13695 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13696 @tab @code{MDADDACCS @var{a},@var{b}}
13697 @item @code{void __MDASACCS (acc, acc)}
13698 @tab @code{__MDASACCS (@var{b}, @var{a})}
13699 @tab @code{MDASACCS @var{a},@var{b}}
13700 @item @code{uw2 __MDCUTSSI (acc, const)}
13701 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13702 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13703 @item @code{uw2 __MDPACKH (uw2, uw2)}
13704 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13705 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13706 @item @code{uw2 __MDROTLI (uw2, const)}
13707 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13708 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13709 @item @code{void __MDSUBACCS (acc, acc)}
13710 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13711 @tab @code{MDSUBACCS @var{a},@var{b}}
13712 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13713 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13714 @tab @code{MDUNPACKH @var{a},@var{b}}
13715 @item @code{uw2 __MEXPDHD (uw1, const)}
13716 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13717 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13718 @item @code{uw1 __MEXPDHW (uw1, const)}
13719 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13720 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13721 @item @code{uw1 __MHDSETH (uw1, const)}
13722 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13723 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13724 @item @code{sw1 __MHDSETS (const)}
13725 @tab @code{@var{b} = __MHDSETS (@var{a})}
13726 @tab @code{MHDSETS #@var{a},@var{b}}
13727 @item @code{uw1 __MHSETHIH (uw1, const)}
13728 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13729 @tab @code{MHSETHIH #@var{a},@var{b}}
13730 @item @code{sw1 __MHSETHIS (sw1, const)}
13731 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13732 @tab @code{MHSETHIS #@var{a},@var{b}}
13733 @item @code{uw1 __MHSETLOH (uw1, const)}
13734 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13735 @tab @code{MHSETLOH #@var{a},@var{b}}
13736 @item @code{sw1 __MHSETLOS (sw1, const)}
13737 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13738 @tab @code{MHSETLOS #@var{a},@var{b}}
13739 @item @code{uw1 __MHTOB (uw2)}
13740 @tab @code{@var{b} = __MHTOB (@var{a})}
13741 @tab @code{MHTOB @var{a},@var{b}}
13742 @item @code{void __MMACHS (acc, sw1, sw1)}
13743 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13744 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13745 @item @code{void __MMACHU (acc, uw1, uw1)}
13746 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13747 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13748 @item @code{void __MMRDHS (acc, sw1, sw1)}
13749 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13750 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13751 @item @code{void __MMRDHU (acc, uw1, uw1)}
13752 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13753 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13754 @item @code{void __MMULHS (acc, sw1, sw1)}
13755 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13756 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13757 @item @code{void __MMULHU (acc, uw1, uw1)}
13758 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13759 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13760 @item @code{void __MMULXHS (acc, sw1, sw1)}
13761 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13762 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13763 @item @code{void __MMULXHU (acc, uw1, uw1)}
13764 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13765 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13766 @item @code{uw1 __MNOT (uw1)}
13767 @tab @code{@var{b} = __MNOT (@var{a})}
13768 @tab @code{MNOT @var{a},@var{b}}
13769 @item @code{uw1 __MOR (uw1, uw1)}
13770 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13771 @tab @code{MOR @var{a},@var{b},@var{c}}
13772 @item @code{uw1 __MPACKH (uh, uh)}
13773 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13774 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13775 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13776 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13777 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13778 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13779 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13780 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13781 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13782 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13783 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13784 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13785 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13786 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13787 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13788 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13789 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13790 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13791 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13792 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13793 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13794 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13795 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13796 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13797 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13798 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13799 @item @code{void __MQMACHS (acc, sw2, sw2)}
13800 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13801 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13802 @item @code{void __MQMACHU (acc, uw2, uw2)}
13803 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13804 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13805 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13806 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13807 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13808 @item @code{void __MQMULHS (acc, sw2, sw2)}
13809 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13810 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13811 @item @code{void __MQMULHU (acc, uw2, uw2)}
13812 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13813 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13814 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13815 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13816 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13817 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13818 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13819 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13820 @item @code{sw2 __MQSATHS (sw2, sw2)}
13821 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13822 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13823 @item @code{uw2 __MQSLLHI (uw2, int)}
13824 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13825 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13826 @item @code{sw2 __MQSRAHI (sw2, int)}
13827 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13828 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13829 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13830 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13831 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13832 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13833 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13834 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13835 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13836 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13837 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13838 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13839 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13840 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13841 @item @code{uw1 __MRDACC (acc)}
13842 @tab @code{@var{b} = __MRDACC (@var{a})}
13843 @tab @code{MRDACC @var{a},@var{b}}
13844 @item @code{uw1 __MRDACCG (acc)}
13845 @tab @code{@var{b} = __MRDACCG (@var{a})}
13846 @tab @code{MRDACCG @var{a},@var{b}}
13847 @item @code{uw1 __MROTLI (uw1, const)}
13848 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13849 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13850 @item @code{uw1 __MROTRI (uw1, const)}
13851 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13852 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13853 @item @code{sw1 __MSATHS (sw1, sw1)}
13854 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13855 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13856 @item @code{uw1 __MSATHU (uw1, uw1)}
13857 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13858 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13859 @item @code{uw1 __MSLLHI (uw1, const)}
13860 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13861 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13862 @item @code{sw1 __MSRAHI (sw1, const)}
13863 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13864 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13865 @item @code{uw1 __MSRLHI (uw1, const)}
13866 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13867 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13868 @item @code{void __MSUBACCS (acc, acc)}
13869 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13870 @tab @code{MSUBACCS @var{a},@var{b}}
13871 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13872 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13873 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13874 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13875 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13876 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13877 @item @code{void __MTRAP (void)}
13878 @tab @code{__MTRAP ()}
13879 @tab @code{MTRAP}
13880 @item @code{uw2 __MUNPACKH (uw1)}
13881 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13882 @tab @code{MUNPACKH @var{a},@var{b}}
13883 @item @code{uw1 __MWCUT (uw2, uw1)}
13884 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13885 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13886 @item @code{void __MWTACC (acc, uw1)}
13887 @tab @code{__MWTACC (@var{b}, @var{a})}
13888 @tab @code{MWTACC @var{a},@var{b}}
13889 @item @code{void __MWTACCG (acc, uw1)}
13890 @tab @code{__MWTACCG (@var{b}, @var{a})}
13891 @tab @code{MWTACCG @var{a},@var{b}}
13892 @item @code{uw1 __MXOR (uw1, uw1)}
13893 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13894 @tab @code{MXOR @var{a},@var{b},@var{c}}
13895 @end multitable
13896
13897 @node Raw read/write Functions
13898 @subsubsection Raw Read/Write Functions
13899
13900 This sections describes built-in functions related to read and write
13901 instructions to access memory. These functions generate
13902 @code{membar} instructions to flush the I/O load and stores where
13903 appropriate, as described in Fujitsu's manual described above.
13904
13905 @table @code
13906
13907 @item unsigned char __builtin_read8 (void *@var{data})
13908 @item unsigned short __builtin_read16 (void *@var{data})
13909 @item unsigned long __builtin_read32 (void *@var{data})
13910 @item unsigned long long __builtin_read64 (void *@var{data})
13911
13912 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13913 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13914 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13915 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13916 @end table
13917
13918 @node Other Built-in Functions
13919 @subsubsection Other Built-in Functions
13920
13921 This section describes built-in functions that are not named after
13922 a specific FR-V instruction.
13923
13924 @table @code
13925 @item sw2 __IACCreadll (iacc @var{reg})
13926 Return the full 64-bit value of IACC0@. The @var{reg} argument is reserved
13927 for future expansion and must be 0.
13928
13929 @item sw1 __IACCreadl (iacc @var{reg})
13930 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13931 Other values of @var{reg} are rejected as invalid.
13932
13933 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13934 Set the full 64-bit value of IACC0 to @var{x}. The @var{reg} argument
13935 is reserved for future expansion and must be 0.
13936
13937 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13938 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13939 is 1. Other values of @var{reg} are rejected as invalid.
13940
13941 @item void __data_prefetch0 (const void *@var{x})
13942 Use the @code{dcpl} instruction to load the contents of address @var{x}
13943 into the data cache.
13944
13945 @item void __data_prefetch (const void *@var{x})
13946 Use the @code{nldub} instruction to load the contents of address @var{x}
13947 into the data cache. The instruction is issued in slot I1@.
13948 @end table
13949
13950 @node MIPS DSP Built-in Functions
13951 @subsection MIPS DSP Built-in Functions
13952
13953 The MIPS DSP Application-Specific Extension (ASE) includes new
13954 instructions that are designed to improve the performance of DSP and
13955 media applications. It provides instructions that operate on packed
13956 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13957
13958 GCC supports MIPS DSP operations using both the generic
13959 vector extensions (@pxref{Vector Extensions}) and a collection of
13960 MIPS-specific built-in functions. Both kinds of support are
13961 enabled by the @option{-mdsp} command-line option.
13962
13963 Revision 2 of the ASE was introduced in the second half of 2006.
13964 This revision adds extra instructions to the original ASE, but is
13965 otherwise backwards-compatible with it. You can select revision 2
13966 using the command-line option @option{-mdspr2}; this option implies
13967 @option{-mdsp}.
13968
13969 The SCOUNT and POS bits of the DSP control register are global. The
13970 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13971 POS bits. During optimization, the compiler does not delete these
13972 instructions and it does not delete calls to functions containing
13973 these instructions.
13974
13975 At present, GCC only provides support for operations on 32-bit
13976 vectors. The vector type associated with 8-bit integer data is
13977 usually called @code{v4i8}, the vector type associated with Q7
13978 is usually called @code{v4q7}, the vector type associated with 16-bit
13979 integer data is usually called @code{v2i16}, and the vector type
13980 associated with Q15 is usually called @code{v2q15}. They can be
13981 defined in C as follows:
13982
13983 @smallexample
13984 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13985 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13986 typedef short v2i16 __attribute__ ((vector_size(4)));
13987 typedef short v2q15 __attribute__ ((vector_size(4)));
13988 @end smallexample
13989
13990 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13991 initialized in the same way as aggregates. For example:
13992
13993 @smallexample
13994 v4i8 a = @{1, 2, 3, 4@};
13995 v4i8 b;
13996 b = (v4i8) @{5, 6, 7, 8@};
13997
13998 v2q15 c = @{0x0fcb, 0x3a75@};
13999 v2q15 d;
14000 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
14001 @end smallexample
14002
14003 @emph{Note:} The CPU's endianness determines the order in which values
14004 are packed. On little-endian targets, the first value is the least
14005 significant and the last value is the most significant. The opposite
14006 order applies to big-endian targets. For example, the code above
14007 sets the lowest byte of @code{a} to @code{1} on little-endian targets
14008 and @code{4} on big-endian targets.
14009
14010 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
14011 representation. As shown in this example, the integer representation
14012 of a Q7 value can be obtained by multiplying the fractional value by
14013 @code{0x1.0p7}. The equivalent for Q15 values is to multiply by
14014 @code{0x1.0p15}. The equivalent for Q31 values is to multiply by
14015 @code{0x1.0p31}.
14016
14017 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14018 hardware support exists. @code{a} and @code{b} are @code{v4i8} values,
14019 and @code{c} and @code{d} are @code{v2q15} values.
14020
14021 @multitable @columnfractions .50 .50
14022 @item C code @tab MIPS instruction
14023 @item @code{a + b} @tab @code{addu.qb}
14024 @item @code{c + d} @tab @code{addq.ph}
14025 @item @code{a - b} @tab @code{subu.qb}
14026 @item @code{c - d} @tab @code{subq.ph}
14027 @end multitable
14028
14029 The table below lists the @code{v2i16} operation for which
14030 hardware support exists for the DSP ASE REV 2. @code{e} and @code{f} are
14031 @code{v2i16} values.
14032
14033 @multitable @columnfractions .50 .50
14034 @item C code @tab MIPS instruction
14035 @item @code{e * f} @tab @code{mul.ph}
14036 @end multitable
14037
14038 It is easier to describe the DSP built-in functions if we first define
14039 the following types:
14040
14041 @smallexample
14042 typedef int q31;
14043 typedef int i32;
14044 typedef unsigned int ui32;
14045 typedef long long a64;
14046 @end smallexample
14047
14048 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14049 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14050 indicate a 32-bit integer value. Similarly, @code{a64} is the same as
14051 @code{long long}, but we use @code{a64} to indicate values that are
14052 placed in one of the four DSP accumulators (@code{$ac0},
14053 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14054
14055 Also, some built-in functions prefer or require immediate numbers as
14056 parameters, because the corresponding DSP instructions accept both immediate
14057 numbers and register operands, or accept immediate numbers only. The
14058 immediate parameters are listed as follows.
14059
14060 @smallexample
14061 imm0_3: 0 to 3.
14062 imm0_7: 0 to 7.
14063 imm0_15: 0 to 15.
14064 imm0_31: 0 to 31.
14065 imm0_63: 0 to 63.
14066 imm0_255: 0 to 255.
14067 imm_n32_31: -32 to 31.
14068 imm_n512_511: -512 to 511.
14069 @end smallexample
14070
14071 The following built-in functions map directly to a particular MIPS DSP
14072 instruction. Please refer to the architecture specification
14073 for details on what each instruction does.
14074
14075 @smallexample
14076 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14077 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14078 q31 __builtin_mips_addq_s_w (q31, q31)
14079 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14080 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14081 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14082 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14083 q31 __builtin_mips_subq_s_w (q31, q31)
14084 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14085 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14086 i32 __builtin_mips_addsc (i32, i32)
14087 i32 __builtin_mips_addwc (i32, i32)
14088 i32 __builtin_mips_modsub (i32, i32)
14089 i32 __builtin_mips_raddu_w_qb (v4i8)
14090 v2q15 __builtin_mips_absq_s_ph (v2q15)
14091 q31 __builtin_mips_absq_s_w (q31)
14092 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14093 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14094 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14095 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14096 q31 __builtin_mips_preceq_w_phl (v2q15)
14097 q31 __builtin_mips_preceq_w_phr (v2q15)
14098 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14099 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14100 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14101 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14102 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14103 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14104 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14105 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14106 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14107 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14108 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14109 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14110 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14111 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14112 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14113 q31 __builtin_mips_shll_s_w (q31, i32)
14114 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14115 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14116 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14117 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14118 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14119 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14120 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14121 q31 __builtin_mips_shra_r_w (q31, i32)
14122 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14123 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14124 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14125 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14126 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14127 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14128 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14129 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14130 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14131 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14132 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14133 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14134 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14135 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14136 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14137 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14138 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14139 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14140 i32 __builtin_mips_bitrev (i32)
14141 i32 __builtin_mips_insv (i32, i32)
14142 v4i8 __builtin_mips_repl_qb (imm0_255)
14143 v4i8 __builtin_mips_repl_qb (i32)
14144 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14145 v2q15 __builtin_mips_repl_ph (i32)
14146 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14147 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14148 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14149 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14150 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14151 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14152 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14153 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14154 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14155 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14156 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14157 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14158 i32 __builtin_mips_extr_w (a64, imm0_31)
14159 i32 __builtin_mips_extr_w (a64, i32)
14160 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14161 i32 __builtin_mips_extr_s_h (a64, i32)
14162 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14163 i32 __builtin_mips_extr_rs_w (a64, i32)
14164 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14165 i32 __builtin_mips_extr_r_w (a64, i32)
14166 i32 __builtin_mips_extp (a64, imm0_31)
14167 i32 __builtin_mips_extp (a64, i32)
14168 i32 __builtin_mips_extpdp (a64, imm0_31)
14169 i32 __builtin_mips_extpdp (a64, i32)
14170 a64 __builtin_mips_shilo (a64, imm_n32_31)
14171 a64 __builtin_mips_shilo (a64, i32)
14172 a64 __builtin_mips_mthlip (a64, i32)
14173 void __builtin_mips_wrdsp (i32, imm0_63)
14174 i32 __builtin_mips_rddsp (imm0_63)
14175 i32 __builtin_mips_lbux (void *, i32)
14176 i32 __builtin_mips_lhx (void *, i32)
14177 i32 __builtin_mips_lwx (void *, i32)
14178 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14179 i32 __builtin_mips_bposge32 (void)
14180 a64 __builtin_mips_madd (a64, i32, i32);
14181 a64 __builtin_mips_maddu (a64, ui32, ui32);
14182 a64 __builtin_mips_msub (a64, i32, i32);
14183 a64 __builtin_mips_msubu (a64, ui32, ui32);
14184 a64 __builtin_mips_mult (i32, i32);
14185 a64 __builtin_mips_multu (ui32, ui32);
14186 @end smallexample
14187
14188 The following built-in functions map directly to a particular MIPS DSP REV 2
14189 instruction. Please refer to the architecture specification
14190 for details on what each instruction does.
14191
14192 @smallexample
14193 v4q7 __builtin_mips_absq_s_qb (v4q7);
14194 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14195 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14196 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14197 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14198 i32 __builtin_mips_append (i32, i32, imm0_31);
14199 i32 __builtin_mips_balign (i32, i32, imm0_3);
14200 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14201 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14202 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14203 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14204 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14205 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14206 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14207 q31 __builtin_mips_mulq_rs_w (q31, q31);
14208 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14209 q31 __builtin_mips_mulq_s_w (q31, q31);
14210 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14211 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14212 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14213 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14214 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14215 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14216 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14217 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14218 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14219 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14220 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14221 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14222 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14223 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14224 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14225 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14226 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14227 q31 __builtin_mips_addqh_w (q31, q31);
14228 q31 __builtin_mips_addqh_r_w (q31, q31);
14229 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14230 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14231 q31 __builtin_mips_subqh_w (q31, q31);
14232 q31 __builtin_mips_subqh_r_w (q31, q31);
14233 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14234 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14235 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14236 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14237 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14238 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14239 @end smallexample
14240
14241
14242 @node MIPS Paired-Single Support
14243 @subsection MIPS Paired-Single Support
14244
14245 The MIPS64 architecture includes a number of instructions that
14246 operate on pairs of single-precision floating-point values.
14247 Each pair is packed into a 64-bit floating-point register,
14248 with one element being designated the ``upper half'' and
14249 the other being designated the ``lower half''.
14250
14251 GCC supports paired-single operations using both the generic
14252 vector extensions (@pxref{Vector Extensions}) and a collection of
14253 MIPS-specific built-in functions. Both kinds of support are
14254 enabled by the @option{-mpaired-single} command-line option.
14255
14256 The vector type associated with paired-single values is usually
14257 called @code{v2sf}. It can be defined in C as follows:
14258
14259 @smallexample
14260 typedef float v2sf __attribute__ ((vector_size (8)));
14261 @end smallexample
14262
14263 @code{v2sf} values are initialized in the same way as aggregates.
14264 For example:
14265
14266 @smallexample
14267 v2sf a = @{1.5, 9.1@};
14268 v2sf b;
14269 float e, f;
14270 b = (v2sf) @{e, f@};
14271 @end smallexample
14272
14273 @emph{Note:} The CPU's endianness determines which value is stored in
14274 the upper half of a register and which value is stored in the lower half.
14275 On little-endian targets, the first value is the lower one and the second
14276 value is the upper one. The opposite order applies to big-endian targets.
14277 For example, the code above sets the lower half of @code{a} to
14278 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14279
14280 @node MIPS Loongson Built-in Functions
14281 @subsection MIPS Loongson Built-in Functions
14282
14283 GCC provides intrinsics to access the SIMD instructions provided by the
14284 ST Microelectronics Loongson-2E and -2F processors. These intrinsics,
14285 available after inclusion of the @code{loongson.h} header file,
14286 operate on the following 64-bit vector types:
14287
14288 @itemize
14289 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14290 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14291 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14292 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14293 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14294 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14295 @end itemize
14296
14297 The intrinsics provided are listed below; each is named after the
14298 machine instruction to which it corresponds, with suffixes added as
14299 appropriate to distinguish intrinsics that expand to the same machine
14300 instruction yet have different argument types. Refer to the architecture
14301 documentation for a description of the functionality of each
14302 instruction.
14303
14304 @smallexample
14305 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14306 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14307 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14308 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14309 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14310 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14311 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14312 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14313 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14314 uint64_t paddd_u (uint64_t s, uint64_t t);
14315 int64_t paddd_s (int64_t s, int64_t t);
14316 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14317 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14318 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14319 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14320 uint64_t pandn_ud (uint64_t s, uint64_t t);
14321 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14322 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14323 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14324 int64_t pandn_sd (int64_t s, int64_t t);
14325 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14326 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14327 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14328 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14329 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14330 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14331 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14332 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14333 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14334 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14335 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14336 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14337 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14338 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14339 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14340 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14341 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14342 uint16x4_t pextrh_u (uint16x4_t s, int field);
14343 int16x4_t pextrh_s (int16x4_t s, int field);
14344 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14345 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14346 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14347 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14348 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14349 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14350 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14351 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14352 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14353 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14354 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14355 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14356 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14357 uint8x8_t pmovmskb_u (uint8x8_t s);
14358 int8x8_t pmovmskb_s (int8x8_t s);
14359 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14360 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14361 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14362 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14363 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14364 uint16x4_t biadd (uint8x8_t s);
14365 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14366 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14367 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14368 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14369 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14370 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14371 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14372 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14373 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14374 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14375 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14376 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14377 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14378 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14379 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14380 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14381 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14382 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14383 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14384 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14385 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14386 uint64_t psubd_u (uint64_t s, uint64_t t);
14387 int64_t psubd_s (int64_t s, int64_t t);
14388 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14389 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14390 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14391 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14392 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14393 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14394 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14395 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14396 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14397 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14398 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14399 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14400 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14401 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14402 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14403 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14404 @end smallexample
14405
14406 @menu
14407 * Paired-Single Arithmetic::
14408 * Paired-Single Built-in Functions::
14409 * MIPS-3D Built-in Functions::
14410 @end menu
14411
14412 @node Paired-Single Arithmetic
14413 @subsubsection Paired-Single Arithmetic
14414
14415 The table below lists the @code{v2sf} operations for which hardware
14416 support exists. @code{a}, @code{b} and @code{c} are @code{v2sf}
14417 values and @code{x} is an integral value.
14418
14419 @multitable @columnfractions .50 .50
14420 @item C code @tab MIPS instruction
14421 @item @code{a + b} @tab @code{add.ps}
14422 @item @code{a - b} @tab @code{sub.ps}
14423 @item @code{-a} @tab @code{neg.ps}
14424 @item @code{a * b} @tab @code{mul.ps}
14425 @item @code{a * b + c} @tab @code{madd.ps}
14426 @item @code{a * b - c} @tab @code{msub.ps}
14427 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14428 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14429 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14430 @end multitable
14431
14432 Note that the multiply-accumulate instructions can be disabled
14433 using the command-line option @code{-mno-fused-madd}.
14434
14435 @node Paired-Single Built-in Functions
14436 @subsubsection Paired-Single Built-in Functions
14437
14438 The following paired-single functions map directly to a particular
14439 MIPS instruction. Please refer to the architecture specification
14440 for details on what each instruction does.
14441
14442 @table @code
14443 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14444 Pair lower lower (@code{pll.ps}).
14445
14446 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14447 Pair upper lower (@code{pul.ps}).
14448
14449 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14450 Pair lower upper (@code{plu.ps}).
14451
14452 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14453 Pair upper upper (@code{puu.ps}).
14454
14455 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14456 Convert pair to paired single (@code{cvt.ps.s}).
14457
14458 @item float __builtin_mips_cvt_s_pl (v2sf)
14459 Convert pair lower to single (@code{cvt.s.pl}).
14460
14461 @item float __builtin_mips_cvt_s_pu (v2sf)
14462 Convert pair upper to single (@code{cvt.s.pu}).
14463
14464 @item v2sf __builtin_mips_abs_ps (v2sf)
14465 Absolute value (@code{abs.ps}).
14466
14467 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14468 Align variable (@code{alnv.ps}).
14469
14470 @emph{Note:} The value of the third parameter must be 0 or 4
14471 modulo 8, otherwise the result is unpredictable. Please read the
14472 instruction description for details.
14473 @end table
14474
14475 The following multi-instruction functions are also available.
14476 In each case, @var{cond} can be any of the 16 floating-point conditions:
14477 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14478 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14479 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14480
14481 @table @code
14482 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14483 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14484 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14485 @code{movt.ps}/@code{movf.ps}).
14486
14487 The @code{movt} functions return the value @var{x} computed by:
14488
14489 @smallexample
14490 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14491 mov.ps @var{x},@var{c}
14492 movt.ps @var{x},@var{d},@var{cc}
14493 @end smallexample
14494
14495 The @code{movf} functions are similar but use @code{movf.ps} instead
14496 of @code{movt.ps}.
14497
14498 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14499 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14500 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14501 @code{bc1t}/@code{bc1f}).
14502
14503 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14504 and return either the upper or lower half of the result. For example:
14505
14506 @smallexample
14507 v2sf a, b;
14508 if (__builtin_mips_upper_c_eq_ps (a, b))
14509 upper_halves_are_equal ();
14510 else
14511 upper_halves_are_unequal ();
14512
14513 if (__builtin_mips_lower_c_eq_ps (a, b))
14514 lower_halves_are_equal ();
14515 else
14516 lower_halves_are_unequal ();
14517 @end smallexample
14518 @end table
14519
14520 @node MIPS-3D Built-in Functions
14521 @subsubsection MIPS-3D Built-in Functions
14522
14523 The MIPS-3D Application-Specific Extension (ASE) includes additional
14524 paired-single instructions that are designed to improve the performance
14525 of 3D graphics operations. Support for these instructions is controlled
14526 by the @option{-mips3d} command-line option.
14527
14528 The functions listed below map directly to a particular MIPS-3D
14529 instruction. Please refer to the architecture specification for
14530 more details on what each instruction does.
14531
14532 @table @code
14533 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14534 Reduction add (@code{addr.ps}).
14535
14536 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14537 Reduction multiply (@code{mulr.ps}).
14538
14539 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14540 Convert paired single to paired word (@code{cvt.pw.ps}).
14541
14542 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14543 Convert paired word to paired single (@code{cvt.ps.pw}).
14544
14545 @item float __builtin_mips_recip1_s (float)
14546 @itemx double __builtin_mips_recip1_d (double)
14547 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14548 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14549
14550 @item float __builtin_mips_recip2_s (float, float)
14551 @itemx double __builtin_mips_recip2_d (double, double)
14552 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14553 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14554
14555 @item float __builtin_mips_rsqrt1_s (float)
14556 @itemx double __builtin_mips_rsqrt1_d (double)
14557 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14558 Reduced-precision reciprocal square root (sequence step 1)
14559 (@code{rsqrt1.@var{fmt}}).
14560
14561 @item float __builtin_mips_rsqrt2_s (float, float)
14562 @itemx double __builtin_mips_rsqrt2_d (double, double)
14563 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14564 Reduced-precision reciprocal square root (sequence step 2)
14565 (@code{rsqrt2.@var{fmt}}).
14566 @end table
14567
14568 The following multi-instruction functions are also available.
14569 In each case, @var{cond} can be any of the 16 floating-point conditions:
14570 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14571 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14572 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14573
14574 @table @code
14575 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14576 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14577 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14578 @code{bc1t}/@code{bc1f}).
14579
14580 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14581 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14582 For example:
14583
14584 @smallexample
14585 float a, b;
14586 if (__builtin_mips_cabs_eq_s (a, b))
14587 true ();
14588 else
14589 false ();
14590 @end smallexample
14591
14592 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14593 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14594 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14595 @code{bc1t}/@code{bc1f}).
14596
14597 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14598 and return either the upper or lower half of the result. For example:
14599
14600 @smallexample
14601 v2sf a, b;
14602 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14603 upper_halves_are_equal ();
14604 else
14605 upper_halves_are_unequal ();
14606
14607 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14608 lower_halves_are_equal ();
14609 else
14610 lower_halves_are_unequal ();
14611 @end smallexample
14612
14613 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14614 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14615 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14616 @code{movt.ps}/@code{movf.ps}).
14617
14618 The @code{movt} functions return the value @var{x} computed by:
14619
14620 @smallexample
14621 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14622 mov.ps @var{x},@var{c}
14623 movt.ps @var{x},@var{d},@var{cc}
14624 @end smallexample
14625
14626 The @code{movf} functions are similar but use @code{movf.ps} instead
14627 of @code{movt.ps}.
14628
14629 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14630 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14631 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14632 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14633 Comparison of two paired-single values
14634 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14635 @code{bc1any2t}/@code{bc1any2f}).
14636
14637 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14638 or @code{cabs.@var{cond}.ps}. The @code{any} forms return true if either
14639 result is true and the @code{all} forms return true if both results are true.
14640 For example:
14641
14642 @smallexample
14643 v2sf a, b;
14644 if (__builtin_mips_any_c_eq_ps (a, b))
14645 one_is_true ();
14646 else
14647 both_are_false ();
14648
14649 if (__builtin_mips_all_c_eq_ps (a, b))
14650 both_are_true ();
14651 else
14652 one_is_false ();
14653 @end smallexample
14654
14655 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14656 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14657 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14658 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14659 Comparison of four paired-single values
14660 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14661 @code{bc1any4t}/@code{bc1any4f}).
14662
14663 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14664 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14665 The @code{any} forms return true if any of the four results are true
14666 and the @code{all} forms return true if all four results are true.
14667 For example:
14668
14669 @smallexample
14670 v2sf a, b, c, d;
14671 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14672 some_are_true ();
14673 else
14674 all_are_false ();
14675
14676 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14677 all_are_true ();
14678 else
14679 some_are_false ();
14680 @end smallexample
14681 @end table
14682
14683 @node MIPS SIMD Architecture (MSA) Support
14684 @subsection MIPS SIMD Architecture (MSA) Support
14685
14686 @menu
14687 * MIPS SIMD Architecture Built-in Functions::
14688 @end menu
14689
14690 GCC provides intrinsics to access the SIMD instructions provided by the
14691 MSA MIPS SIMD Architecture. The interface is made available by including
14692 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14693 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14694 @code{__msa_*}.
14695
14696 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14697 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14698 data elements. The following vectors typedefs are included in @code{msa.h}:
14699 @itemize
14700 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14701 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14702 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14703 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14704 @item @code{v4i32}, a vector of four signed 32-bit integers;
14705 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14706 @item @code{v2i64}, a vector of two signed 64-bit integers;
14707 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14708 @item @code{v4f32}, a vector of four 32-bit floats;
14709 @item @code{v2f64}, a vector of two 64-bit doubles.
14710 @end itemize
14711
14712 Instructions and corresponding built-ins may have additional restrictions and/or
14713 input/output values manipulated:
14714 @itemize
14715 @item @code{imm0_1}, an integer literal in range 0 to 1;
14716 @item @code{imm0_3}, an integer literal in range 0 to 3;
14717 @item @code{imm0_7}, an integer literal in range 0 to 7;
14718 @item @code{imm0_15}, an integer literal in range 0 to 15;
14719 @item @code{imm0_31}, an integer literal in range 0 to 31;
14720 @item @code{imm0_63}, an integer literal in range 0 to 63;
14721 @item @code{imm0_255}, an integer literal in range 0 to 255;
14722 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14723 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14724 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14725 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14726 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14727 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14728 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14729 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14730 @item @code{imm1_4}, an integer literal in range 1 to 4;
14731 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14732 @end itemize
14733
14734 @smallexample
14735 @{
14736 typedef int i32;
14737 #if __LONG_MAX__ == __LONG_LONG_MAX__
14738 typedef long i64;
14739 #else
14740 typedef long long i64;
14741 #endif
14742
14743 typedef unsigned int u32;
14744 #if __LONG_MAX__ == __LONG_LONG_MAX__
14745 typedef unsigned long u64;
14746 #else
14747 typedef unsigned long long u64;
14748 #endif
14749
14750 typedef double f64;
14751 typedef float f32;
14752 @}
14753 @end smallexample
14754
14755 @node MIPS SIMD Architecture Built-in Functions
14756 @subsubsection MIPS SIMD Architecture Built-in Functions
14757
14758 The intrinsics provided are listed below; each is named after the
14759 machine instruction.
14760
14761 @smallexample
14762 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14763 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14764 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14765 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14766
14767 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14768 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14769 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14770 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14771
14772 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14773 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14774 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14775 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14776
14777 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14778 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14779 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14780 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14781
14782 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14783 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14784 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14785 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14786
14787 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14788 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14789 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14790 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14791
14792 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14793
14794 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14795
14796 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14797 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14798 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14799 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14800
14801 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14802 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14803 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14804 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14805
14806 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14807 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14808 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14809 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14810
14811 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14812 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14813 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14814 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14815
14816 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14817 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14818 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14819 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14820
14821 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14822 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14823 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14824 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14825
14826 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14827 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14828 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14829 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14830
14831 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14832 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14833 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14834 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14835
14836 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14837 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14838 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14839 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14840
14841 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14842 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14843 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14844 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14845
14846 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14847 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14848 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14849 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14850
14851 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14852 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14853 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14854 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14855
14856 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14857
14858 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14859
14860 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14861
14862 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14863
14864 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14865 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14866 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14867 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14868
14869 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14870 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14871 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14872 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14873
14874 i32 __builtin_msa_bnz_b (v16u8);
14875 i32 __builtin_msa_bnz_h (v8u16);
14876 i32 __builtin_msa_bnz_w (v4u32);
14877 i32 __builtin_msa_bnz_d (v2u64);
14878
14879 i32 __builtin_msa_bnz_v (v16u8);
14880
14881 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14882
14883 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14884
14885 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14886 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14887 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14888 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14889
14890 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14891 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14892 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14893 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14894
14895 i32 __builtin_msa_bz_b (v16u8);
14896 i32 __builtin_msa_bz_h (v8u16);
14897 i32 __builtin_msa_bz_w (v4u32);
14898 i32 __builtin_msa_bz_d (v2u64);
14899
14900 i32 __builtin_msa_bz_v (v16u8);
14901
14902 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14903 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14904 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14905 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14906
14907 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14908 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14909 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14910 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14911
14912 i32 __builtin_msa_cfcmsa (imm0_31);
14913
14914 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14915 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14916 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14917 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14918
14919 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14920 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14921 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14922 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14923
14924 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14925 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14926 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14927 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14928
14929 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14930 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14931 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14932 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14933
14934 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14935 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14936 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14937 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14938
14939 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14940 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14941 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14942 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14943
14944 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14945 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14946 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14947 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14948
14949 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14950 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14951 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14952 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14953
14954 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14955 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14956 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14957 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14958
14959 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14960 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14961 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14962 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14963
14964 void __builtin_msa_ctcmsa (imm0_31, i32);
14965
14966 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14967 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14968 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14969 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14970
14971 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14972 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14973 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14974 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14975
14976 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14977 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14978 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14979
14980 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14981 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14982 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14983
14984 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14985 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14986 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14987
14988 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14989 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14990 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14991
14992 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14993 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14994 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14995
14996 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14997 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14998 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14999
15000 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
15001 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
15002
15003 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
15004 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
15005
15006 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
15007 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
15008
15009 v4i32 __builtin_msa_fclass_w (v4f32);
15010 v2i64 __builtin_msa_fclass_d (v2f64);
15011
15012 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
15013 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15014
15015 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15016 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15017
15018 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15019 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15020
15021 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15022 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15023
15024 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15025 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15026
15027 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15028 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15029
15030 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15031 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15032
15033 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15034 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15035
15036 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15037 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15038
15039 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15040 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15041
15042 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15043 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15044
15045 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15046 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15047
15048 v4f32 __builtin_msa_fexupl_w (v8i16);
15049 v2f64 __builtin_msa_fexupl_d (v4f32);
15050
15051 v4f32 __builtin_msa_fexupr_w (v8i16);
15052 v2f64 __builtin_msa_fexupr_d (v4f32);
15053
15054 v4f32 __builtin_msa_ffint_s_w (v4i32);
15055 v2f64 __builtin_msa_ffint_s_d (v2i64);
15056
15057 v4f32 __builtin_msa_ffint_u_w (v4u32);
15058 v2f64 __builtin_msa_ffint_u_d (v2u64);
15059
15060 v4f32 __builtin_msa_ffql_w (v8i16);
15061 v2f64 __builtin_msa_ffql_d (v4i32);
15062
15063 v4f32 __builtin_msa_ffqr_w (v8i16);
15064 v2f64 __builtin_msa_ffqr_d (v4i32);
15065
15066 v16i8 __builtin_msa_fill_b (i32);
15067 v8i16 __builtin_msa_fill_h (i32);
15068 v4i32 __builtin_msa_fill_w (i32);
15069 v2i64 __builtin_msa_fill_d (i64);
15070
15071 v4f32 __builtin_msa_flog2_w (v4f32);
15072 v2f64 __builtin_msa_flog2_d (v2f64);
15073
15074 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15075 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15076
15077 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15078 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15079
15080 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15081 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15082
15083 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15084 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15085
15086 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15087 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15088
15089 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15090 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15091
15092 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15093 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15094
15095 v4f32 __builtin_msa_frint_w (v4f32);
15096 v2f64 __builtin_msa_frint_d (v2f64);
15097
15098 v4f32 __builtin_msa_frcp_w (v4f32);
15099 v2f64 __builtin_msa_frcp_d (v2f64);
15100
15101 v4f32 __builtin_msa_frsqrt_w (v4f32);
15102 v2f64 __builtin_msa_frsqrt_d (v2f64);
15103
15104 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15105 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15106
15107 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15108 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15109
15110 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15111 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15112
15113 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15114 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15115
15116 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15117 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15118
15119 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15120 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15121
15122 v4f32 __builtin_msa_fsqrt_w (v4f32);
15123 v2f64 __builtin_msa_fsqrt_d (v2f64);
15124
15125 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15126 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15127
15128 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15129 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15130
15131 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15132 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15133
15134 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15135 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15136
15137 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15138 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15139
15140 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15141 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15142
15143 v4i32 __builtin_msa_ftint_s_w (v4f32);
15144 v2i64 __builtin_msa_ftint_s_d (v2f64);
15145
15146 v4u32 __builtin_msa_ftint_u_w (v4f32);
15147 v2u64 __builtin_msa_ftint_u_d (v2f64);
15148
15149 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15150 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15151
15152 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15153 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15154
15155 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15156 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15157
15158 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15159 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15160 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15161
15162 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15163 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15164 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15165
15166 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15167 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15168 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15169
15170 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15171 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15172 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15173
15174 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15175 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15176 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15177 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15178
15179 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15180 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15181 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15182 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15183
15184 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15185 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15186 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15187 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15188
15189 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15190 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15191 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15192 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15193
15194 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15195 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15196 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15197 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15198
15199 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15200 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15201 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15202 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15203
15204 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15205 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15206 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15207 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15208
15209 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15210 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15211 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15212 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15213
15214 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15215 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15216
15217 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15218 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15219
15220 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15221 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15222 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15223 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15224
15225 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15226 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15227 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15228 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15229
15230 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15231 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15232 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15233 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15234
15235 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15236 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15237 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15238 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15239
15240 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15241 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15242 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15243 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15244
15245 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15246 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15247 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15248 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15249
15250 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15251 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15252 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15253 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15254
15255 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15256 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15257 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15258 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15259
15260 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15261 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15262 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15263 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15264
15265 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15266 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15267 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15268 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15269
15270 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15271 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15272 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15273 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15274
15275 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15276 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15277 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15278 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15279
15280 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15281 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15282 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15283 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15284
15285 v16i8 __builtin_msa_move_v (v16i8);
15286
15287 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15288 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15289
15290 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15291 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15292
15293 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15294 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15295 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15296 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15297
15298 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15299 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15300
15301 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15302 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15303
15304 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15305 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15306 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15307 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15308
15309 v16i8 __builtin_msa_nloc_b (v16i8);
15310 v8i16 __builtin_msa_nloc_h (v8i16);
15311 v4i32 __builtin_msa_nloc_w (v4i32);
15312 v2i64 __builtin_msa_nloc_d (v2i64);
15313
15314 v16i8 __builtin_msa_nlzc_b (v16i8);
15315 v8i16 __builtin_msa_nlzc_h (v8i16);
15316 v4i32 __builtin_msa_nlzc_w (v4i32);
15317 v2i64 __builtin_msa_nlzc_d (v2i64);
15318
15319 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15320
15321 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15322
15323 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15324
15325 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15326
15327 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15328 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15329 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15330 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15331
15332 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15333 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15334 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15335 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15336
15337 v16i8 __builtin_msa_pcnt_b (v16i8);
15338 v8i16 __builtin_msa_pcnt_h (v8i16);
15339 v4i32 __builtin_msa_pcnt_w (v4i32);
15340 v2i64 __builtin_msa_pcnt_d (v2i64);
15341
15342 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15343 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15344 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15345 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15346
15347 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15348 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15349 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15350 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15351
15352 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15353 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15354 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15355
15356 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15357 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15358 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15359 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15360
15361 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15362 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15363 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15364 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15365
15366 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15367 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15368 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15369 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15370
15371 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15372 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15373 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15374 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15375
15376 v16i8 __builtin_msa_splat_b (v16i8, i32);
15377 v8i16 __builtin_msa_splat_h (v8i16, i32);
15378 v4i32 __builtin_msa_splat_w (v4i32, i32);
15379 v2i64 __builtin_msa_splat_d (v2i64, i32);
15380
15381 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15382 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15383 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15384 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15385
15386 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15387 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15388 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15389 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15390
15391 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15392 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15393 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15394 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15395
15396 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15397 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15398 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15399 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15400
15401 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15402 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15403 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15404 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15405
15406 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15407 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15408 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15409 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15410
15411 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15412 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15413 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15414 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15415
15416 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15417 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15418 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15419 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15420
15421 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15422 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15423 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15424 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15425
15426 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15427 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15428 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15429 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15430
15431 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15432 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15433 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15434 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15435
15436 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15437 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15438 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15439 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15440
15441 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15442 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15443 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15444 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15445
15446 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15447 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15448 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15449 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15450
15451 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15452 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15453 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15454 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15455
15456 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15457 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15458 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15459 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15460
15461 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15462 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15463 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15464 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15465
15466 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15467
15468 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15469 @end smallexample
15470
15471 @node Other MIPS Built-in Functions
15472 @subsection Other MIPS Built-in Functions
15473
15474 GCC provides other MIPS-specific built-in functions:
15475
15476 @table @code
15477 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15478 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15479 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15480 when this function is available.
15481
15482 @item unsigned int __builtin_mips_get_fcsr (void)
15483 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15484 Get and set the contents of the floating-point control and status register
15485 (FPU control register 31). These functions are only available in hard-float
15486 code but can be called in both MIPS16 and non-MIPS16 contexts.
15487
15488 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15489 register except the condition codes, which GCC assumes are preserved.
15490 @end table
15491
15492 @node MSP430 Built-in Functions
15493 @subsection MSP430 Built-in Functions
15494
15495 GCC provides a couple of special builtin functions to aid in the
15496 writing of interrupt handlers in C.
15497
15498 @table @code
15499 @item __bic_SR_register_on_exit (int @var{mask})
15500 This clears the indicated bits in the saved copy of the status register
15501 currently residing on the stack. This only works inside interrupt
15502 handlers and the changes to the status register will only take affect
15503 once the handler returns.
15504
15505 @item __bis_SR_register_on_exit (int @var{mask})
15506 This sets the indicated bits in the saved copy of the status register
15507 currently residing on the stack. This only works inside interrupt
15508 handlers and the changes to the status register will only take affect
15509 once the handler returns.
15510
15511 @item __delay_cycles (long long @var{cycles})
15512 This inserts an instruction sequence that takes exactly @var{cycles}
15513 cycles (between 0 and about 17E9) to complete. The inserted sequence
15514 may use jumps, loops, or no-ops, and does not interfere with any other
15515 instructions. Note that @var{cycles} must be a compile-time constant
15516 integer - that is, you must pass a number, not a variable that may be
15517 optimized to a constant later. The number of cycles delayed by this
15518 builtin is exact.
15519 @end table
15520
15521 @node NDS32 Built-in Functions
15522 @subsection NDS32 Built-in Functions
15523
15524 These built-in functions are available for the NDS32 target:
15525
15526 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15527 Insert an ISYNC instruction into the instruction stream where
15528 @var{addr} is an instruction address for serialization.
15529 @end deftypefn
15530
15531 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15532 Insert an ISB instruction into the instruction stream.
15533 @end deftypefn
15534
15535 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15536 Return the content of a system register which is mapped by @var{sr}.
15537 @end deftypefn
15538
15539 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15540 Return the content of a user space register which is mapped by @var{usr}.
15541 @end deftypefn
15542
15543 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15544 Move the @var{value} to a system register which is mapped by @var{sr}.
15545 @end deftypefn
15546
15547 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15548 Move the @var{value} to a user space register which is mapped by @var{usr}.
15549 @end deftypefn
15550
15551 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15552 Enable global interrupt.
15553 @end deftypefn
15554
15555 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15556 Disable global interrupt.
15557 @end deftypefn
15558
15559 @node picoChip Built-in Functions
15560 @subsection picoChip Built-in Functions
15561
15562 GCC provides an interface to selected machine instructions from the
15563 picoChip instruction set.
15564
15565 @table @code
15566 @item int __builtin_sbc (int @var{value})
15567 Sign bit count. Return the number of consecutive bits in @var{value}
15568 that have the same value as the sign bit. The result is the number of
15569 leading sign bits minus one, giving the number of redundant sign bits in
15570 @var{value}.
15571
15572 @item int __builtin_byteswap (int @var{value})
15573 Byte swap. Return the result of swapping the upper and lower bytes of
15574 @var{value}.
15575
15576 @item int __builtin_brev (int @var{value})
15577 Bit reversal. Return the result of reversing the bits in
15578 @var{value}. Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15579 and so on.
15580
15581 @item int __builtin_adds (int @var{x}, int @var{y})
15582 Saturating addition. Return the result of adding @var{x} and @var{y},
15583 storing the value 32767 if the result overflows.
15584
15585 @item int __builtin_subs (int @var{x}, int @var{y})
15586 Saturating subtraction. Return the result of subtracting @var{y} from
15587 @var{x}, storing the value @minus{}32768 if the result overflows.
15588
15589 @item void __builtin_halt (void)
15590 Halt. The processor stops execution. This built-in is useful for
15591 implementing assertions.
15592
15593 @end table
15594
15595 @node Basic PowerPC Built-in Functions
15596 @subsection Basic PowerPC Built-in Functions
15597
15598 @menu
15599 * Basic PowerPC Built-in Functions Available on all Configurations::
15600 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15601 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15602 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15603 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15604 @end menu
15605
15606 This section describes PowerPC built-in functions that do not require
15607 the inclusion of any special header files to declare prototypes or
15608 provide macro definitions. The sections that follow describe
15609 additional PowerPC built-in functions.
15610
15611 @node Basic PowerPC Built-in Functions Available on all Configurations
15612 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15613
15614 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15615 This function is a @code{nop} on the PowerPC platform and is included solely
15616 to maintain API compatibility with the x86 builtins.
15617 @end deftypefn
15618
15619 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15620 This function returns a value of @code{1} if the run-time CPU is of type
15621 @var{cpuname} and returns @code{0} otherwise
15622
15623 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15624 which exports the hardware capability bits. GCC defines the macro
15625 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15626 built-in function is fully supported.
15627
15628 If GCC was configured to use a GLIBC before 2.23, the built-in
15629 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15630 issues a warning.
15631
15632 The following CPU names can be detected:
15633
15634 @table @samp
15635 @item power9
15636 IBM POWER9 Server CPU.
15637 @item power8
15638 IBM POWER8 Server CPU.
15639 @item power7
15640 IBM POWER7 Server CPU.
15641 @item power6x
15642 IBM POWER6 Server CPU (RAW mode).
15643 @item power6
15644 IBM POWER6 Server CPU (Architected mode).
15645 @item power5+
15646 IBM POWER5+ Server CPU.
15647 @item power5
15648 IBM POWER5 Server CPU.
15649 @item ppc970
15650 IBM 970 Server CPU (ie, Apple G5).
15651 @item power4
15652 IBM POWER4 Server CPU.
15653 @item ppca2
15654 IBM A2 64-bit Embedded CPU
15655 @item ppc476
15656 IBM PowerPC 476FP 32-bit Embedded CPU.
15657 @item ppc464
15658 IBM PowerPC 464 32-bit Embedded CPU.
15659 @item ppc440
15660 PowerPC 440 32-bit Embedded CPU.
15661 @item ppc405
15662 PowerPC 405 32-bit Embedded CPU.
15663 @item ppc-cell-be
15664 IBM PowerPC Cell Broadband Engine Architecture CPU.
15665 @end table
15666
15667 Here is an example:
15668 @smallexample
15669 #ifdef __BUILTIN_CPU_SUPPORTS__
15670 if (__builtin_cpu_is ("power8"))
15671 @{
15672 do_power8 (); // POWER8 specific implementation.
15673 @}
15674 else
15675 #endif
15676 @{
15677 do_generic (); // Generic implementation.
15678 @}
15679 @end smallexample
15680 @end deftypefn
15681
15682 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15683 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15684 feature @var{feature} and returns @code{0} otherwise.
15685
15686 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15687 newer which exports the hardware capability bits. GCC defines the
15688 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15689 @code{__builtin_cpu_supports} built-in function is fully supported.
15690
15691 If GCC was configured to use a GLIBC before 2.23, the built-in
15692 function @code{__builtin_cpu_suports} always returns a 0 and the
15693 compiler issues a warning.
15694
15695 The following features can be
15696 detected:
15697
15698 @table @samp
15699 @item 4xxmac
15700 4xx CPU has a Multiply Accumulator.
15701 @item altivec
15702 CPU has a SIMD/Vector Unit.
15703 @item arch_2_05
15704 CPU supports ISA 2.05 (eg, POWER6)
15705 @item arch_2_06
15706 CPU supports ISA 2.06 (eg, POWER7)
15707 @item arch_2_07
15708 CPU supports ISA 2.07 (eg, POWER8)
15709 @item arch_3_00
15710 CPU supports ISA 3.0 (eg, POWER9)
15711 @item archpmu
15712 CPU supports the set of compatible performance monitoring events.
15713 @item booke
15714 CPU supports the Embedded ISA category.
15715 @item cellbe
15716 CPU has a CELL broadband engine.
15717 @item darn
15718 CPU supports the @code{darn} (deliver a random number) instruction.
15719 @item dfp
15720 CPU has a decimal floating point unit.
15721 @item dscr
15722 CPU supports the data stream control register.
15723 @item ebb
15724 CPU supports event base branching.
15725 @item efpdouble
15726 CPU has a SPE double precision floating point unit.
15727 @item efpsingle
15728 CPU has a SPE single precision floating point unit.
15729 @item fpu
15730 CPU has a floating point unit.
15731 @item htm
15732 CPU has hardware transaction memory instructions.
15733 @item htm-nosc
15734 Kernel aborts hardware transactions when a syscall is made.
15735 @item htm-no-suspend
15736 CPU supports hardware transaction memory but does not support the
15737 @code{tsuspend.} instruction.
15738 @item ic_snoop
15739 CPU supports icache snooping capabilities.
15740 @item ieee128
15741 CPU supports 128-bit IEEE binary floating point instructions.
15742 @item isel
15743 CPU supports the integer select instruction.
15744 @item mmu
15745 CPU has a memory management unit.
15746 @item notb
15747 CPU does not have a timebase (eg, 601 and 403gx).
15748 @item pa6t
15749 CPU supports the PA Semi 6T CORE ISA.
15750 @item power4
15751 CPU supports ISA 2.00 (eg, POWER4)
15752 @item power5
15753 CPU supports ISA 2.02 (eg, POWER5)
15754 @item power5+
15755 CPU supports ISA 2.03 (eg, POWER5+)
15756 @item power6x
15757 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15758 @item ppc32
15759 CPU supports 32-bit mode execution.
15760 @item ppc601
15761 CPU supports the old POWER ISA (eg, 601)
15762 @item ppc64
15763 CPU supports 64-bit mode execution.
15764 @item ppcle
15765 CPU supports a little-endian mode that uses address swizzling.
15766 @item scv
15767 Kernel supports system call vectored.
15768 @item smt
15769 CPU support simultaneous multi-threading.
15770 @item spe
15771 CPU has a signal processing extension unit.
15772 @item tar
15773 CPU supports the target address register.
15774 @item true_le
15775 CPU supports true little-endian mode.
15776 @item ucache
15777 CPU has unified I/D cache.
15778 @item vcrypto
15779 CPU supports the vector cryptography instructions.
15780 @item vsx
15781 CPU supports the vector-scalar extension.
15782 @end table
15783
15784 Here is an example:
15785 @smallexample
15786 #ifdef __BUILTIN_CPU_SUPPORTS__
15787 if (__builtin_cpu_supports ("fpu"))
15788 @{
15789 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15790 @}
15791 else
15792 #endif
15793 @{
15794 dst = __fadd (src1, src2); // Software FP addition function.
15795 @}
15796 @end smallexample
15797 @end deftypefn
15798
15799 The following built-in functions are also available on all PowerPC
15800 processors:
15801 @smallexample
15802 uint64_t __builtin_ppc_get_timebase ();
15803 unsigned long __builtin_ppc_mftb ();
15804 @end smallexample
15805
15806 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15807 functions generate instructions to read the Time Base Register. The
15808 @code{__builtin_ppc_get_timebase} function may generate multiple
15809 instructions and always returns the 64 bits of the Time Base Register.
15810 The @code{__builtin_ppc_mftb} function always generates one instruction and
15811 returns the Time Base Register value as an unsigned long, throwing away
15812 the most significant word on 32-bit environments.
15813
15814 @node Basic PowerPC Built-in Functions Available on ISA 2.05
15815 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
15816
15817 The basic built-in functions described in this section are
15818 available on the PowerPC family of processors starting with ISA 2.05
15819 or later. Unless specific options are explicitly disabled on the
15820 command line, specifying option @option{-mcpu=power6} has the effect of
15821 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
15822 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
15823 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
15824 @option{-mrecip-precision} options. Specify the
15825 @option{-maltivec} and @option{-mfpgpr} options explicitly in
15826 combination with the above options if they are desired.
15827
15828 The following functions require option @option{-mcmpb}.
15829 @smallexample
15830 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15831 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15832 @end smallexample
15833
15834 The @code{__builtin_cmpb} function
15835 performs a byte-wise compare on the contents of its two arguments,
15836 returning the result of the byte-wise comparison as the returned
15837 value. For each byte comparison, the corresponding byte of the return
15838 value holds 0xff if the input bytes are equal and 0 if the input bytes
15839 are not equal. If either of the arguments to this built-in function
15840 is wider than 32 bits, the function call expands into the form that
15841 expects @code{unsigned long long int} arguments
15842 which is only available on 64-bit targets.
15843
15844 The following built-in functions are available
15845 when hardware decimal floating point
15846 (@option{-mhard-dfp}) is available:
15847 @smallexample
15848 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15849 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15850 _Decimal64 __builtin_denbcd (int, _Decimal64);
15851 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15852 _Decimal64 __builtin_diex (long long, _Decimal64);
15853 _Decimal128 _builtin_diexq (long long, _Decimal128);
15854 _Decimal64 __builtin_dscli (_Decimal64, int);
15855 _Decimal128 __builtin_dscliq (_Decimal128, int);
15856 _Decimal64 __builtin_dscri (_Decimal64, int);
15857 _Decimal128 __builtin_dscriq (_Decimal128, int);
15858 long long __builtin_dxex (_Decimal64);
15859 long long __builtin_dxexq (_Decimal128);
15860 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15861 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15862 @end smallexample
15863
15864 The following functions require @option{-mhard-float},
15865 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
15866
15867 @smallexample
15868 double __builtin_recipdiv (double, double);
15869 float __builtin_recipdivf (float, float);
15870 double __builtin_rsqrt (double);
15871 float __builtin_rsqrtf (float);
15872 @end smallexample
15873
15874 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15875 @code{__builtin_rsqrtf} functions generate multiple instructions to
15876 implement the reciprocal sqrt functionality using reciprocal sqrt
15877 estimate instructions.
15878
15879 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15880 functions generate multiple instructions to implement division using
15881 the reciprocal estimate instructions.
15882
15883 The following functions require @option{-mhard-float} and
15884 @option{-mmultiple} options.
15885
15886 @smallexample
15887 long double __builtin_pack_longdouble (double, double);
15888 double __builtin_unpack_longdouble (long double, int);
15889 @end smallexample
15890
15891 @node Basic PowerPC Built-in Functions Available on ISA 2.06
15892 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
15893
15894 The basic built-in functions described in this section are
15895 available on the PowerPC family of processors starting with ISA 2.05
15896 or later. Unless specific options are explicitly disabled on the
15897 command line, specifying option @option{-mcpu=power7} has the effect of
15898 enabling all the same options as for @option{-mcpu=power6} in
15899 addition to the @option{-maltivec}, @option{-mpopcntd}, and
15900 @option{-mvsx} options.
15901
15902 The following basic built-in functions require @option{-mpopcntd}:
15903 @smallexample
15904 unsigned int __builtin_addg6s (unsigned int, unsigned int);
15905 long long __builtin_bpermd (long long, long long);
15906 unsigned int __builtin_cbcdtd (unsigned int);
15907 unsigned int __builtin_cdtbcd (unsigned int);
15908 long long __builtin_divde (long long, long long);
15909 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
15910 int __builtin_divwe (int, int);
15911 unsigned int __builtin_divweu (unsigned int, unsigned int);
15912 vector __int128_t __builtin_pack_vector_int128 (long long, long long);
15913 void __builtin_rs6000_speculation_barrier (void);
15914 long long __builtin_unpack_vector_int128 (vector __int128_t, signed char);
15915 @end smallexample
15916
15917 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
15918 require a 64-bit environment.
15919
15920 The following basic built-in functions, which are also supported on
15921 x86 targets, require @option{-mfloat128}.
15922 @smallexample
15923 __float128 __builtin_fabsq (__float128);
15924 __float128 __builtin_copysignq (__float128, __float128);
15925 __float128 __builtin_infq (void);
15926 __float128 __builtin_huge_valq (void);
15927 __float128 __builtin_nanq (void);
15928 __float128 __builtin_nansq (void);
15929
15930 __float128 __builtin_sqrtf128 (__float128);
15931 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
15932 @end smallexample
15933
15934 @node Basic PowerPC Built-in Functions Available on ISA 2.07
15935 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
15936
15937 The basic built-in functions described in this section are
15938 available on the PowerPC family of processors starting with ISA 2.07
15939 or later. Unless specific options are explicitly disabled on the
15940 command line, specifying option @option{-mcpu=power8} has the effect of
15941 enabling all the same options as for @option{-mcpu=power7} in
15942 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
15943 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
15944 @option{-mquad-memory-atomic} options.
15945
15946 This section intentionally empty.
15947
15948 @node Basic PowerPC Built-in Functions Available on ISA 3.0
15949 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
15950
15951 The basic built-in functions described in this section are
15952 available on the PowerPC family of processors starting with ISA 3.0
15953 or later. Unless specific options are explicitly disabled on the
15954 command line, specifying option @option{-mcpu=power9} has the effect of
15955 enabling all the same options as for @option{-mcpu=power8} in
15956 addition to the @option{-misel} option.
15957
15958 The following built-in functions are available on Linux 64-bit systems
15959 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
15960
15961 @table @code
15962 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
15963 Perform a 128-bit IEEE floating point add using round to odd as the
15964 rounding mode.
15965 @findex __builtin_addf128_round_to_odd
15966
15967 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
15968 Perform a 128-bit IEEE floating point subtract using round to odd as
15969 the rounding mode.
15970 @findex __builtin_subf128_round_to_odd
15971
15972 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
15973 Perform a 128-bit IEEE floating point multiply using round to odd as
15974 the rounding mode.
15975 @findex __builtin_mulf128_round_to_odd
15976
15977 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
15978 Perform a 128-bit IEEE floating point divide using round to odd as
15979 the rounding mode.
15980 @findex __builtin_divf128_round_to_odd
15981
15982 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
15983 Perform a 128-bit IEEE floating point square root using round to odd
15984 as the rounding mode.
15985 @findex __builtin_sqrtf128_round_to_odd
15986
15987 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
15988 Perform a 128-bit IEEE floating point fused multiply and add operation
15989 using round to odd as the rounding mode.
15990 @findex __builtin_fmaf128_round_to_odd
15991
15992 @item double __builtin_truncf128_round_to_odd (__float128)
15993 Convert a 128-bit IEEE floating point value to @code{double} using
15994 round to odd as the rounding mode.
15995 @findex __builtin_truncf128_round_to_odd
15996 @end table
15997
15998 The following additional built-in functions are also available for the
15999 PowerPC family of processors, starting with ISA 3.0 or later:
16000 @smallexample
16001 long long __builtin_darn (void);
16002 long long __builtin_darn_raw (void);
16003 int __builtin_darn_32 (void);
16004 @end smallexample
16005
16006 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16007 functions require a
16008 64-bit environment supporting ISA 3.0 or later.
16009 The @code{__builtin_darn} function provides a 64-bit conditioned
16010 random number. The @code{__builtin_darn_raw} function provides a
16011 64-bit raw random number. The @code{__builtin_darn_32} function
16012 provides a 32-bit conditioned random number.
16013
16014 The following additional built-in functions are also available for the
16015 PowerPC family of processors, starting with ISA 3.0 or later:
16016
16017 @smallexample
16018 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
16019 int __builtin_byte_in_range (unsigned char u, unsigned int range);
16020 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
16021
16022 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
16023 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
16024 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
16025 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
16026
16027 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
16028 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
16029 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
16030 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
16031
16032 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
16033 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
16034 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
16035 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
16036
16037 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
16038 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
16039 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
16040 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
16041 @end smallexample
16042 The @code{__builtin_byte_in_set} function requires a
16043 64-bit environment supporting ISA 3.0 or later. This function returns
16044 a non-zero value if and only if its @code{u} argument exactly equals one of
16045 the eight bytes contained within its 64-bit @code{set} argument.
16046
16047 The @code{__builtin_byte_in_range} and
16048 @code{__builtin_byte_in_either_range} require an environment
16049 supporting ISA 3.0 or later. For these two functions, the
16050 @code{range} argument is encoded as 4 bytes, organized as
16051 @code{hi_1:lo_1:hi_2:lo_2}.
16052 The @code{__builtin_byte_in_range} function returns a
16053 non-zero value if and only if its @code{u} argument is within the
16054 range bounded between @code{lo_2} and @code{hi_2} inclusive.
16055 The @code{__builtin_byte_in_either_range} function returns non-zero if
16056 and only if its @code{u} argument is within either the range bounded
16057 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16058 between @code{lo_2} and @code{hi_2} inclusive.
16059
16060 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16061 if and only if the number of signficant digits of its @code{value} argument
16062 is less than its @code{comparison} argument. The
16063 @code{__builtin_dfp_dtstsfi_lt_dd} and
16064 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16065 require that the type of the @code{value} argument be
16066 @code{__Decimal64} and @code{__Decimal128} respectively.
16067
16068 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16069 if and only if the number of signficant digits of its @code{value} argument
16070 is greater than its @code{comparison} argument. The
16071 @code{__builtin_dfp_dtstsfi_gt_dd} and
16072 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16073 require that the type of the @code{value} argument be
16074 @code{__Decimal64} and @code{__Decimal128} respectively.
16075
16076 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16077 if and only if the number of signficant digits of its @code{value} argument
16078 equals its @code{comparison} argument. The
16079 @code{__builtin_dfp_dtstsfi_eq_dd} and
16080 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16081 require that the type of the @code{value} argument be
16082 @code{__Decimal64} and @code{__Decimal128} respectively.
16083
16084 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16085 if and only if its @code{value} argument has an undefined number of
16086 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16087 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16088 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16089 require that the type of the @code{value} argument be
16090 @code{__Decimal64} and @code{__Decimal128} respectively.
16091
16092
16093
16094 @node PowerPC AltiVec/VSX Built-in Functions
16095 @subsection PowerPC AltiVec Built-in Functions
16096
16097 GCC provides an interface for the PowerPC family of processors to access
16098 the AltiVec operations described in Motorola's AltiVec Programming
16099 Interface Manual. The interface is made available by including
16100 @code{<altivec.h>} and using @option{-maltivec} and
16101 @option{-mabi=altivec}. The interface supports the following vector
16102 types.
16103
16104 @smallexample
16105 vector unsigned char
16106 vector signed char
16107 vector bool char
16108
16109 vector unsigned short
16110 vector signed short
16111 vector bool short
16112 vector pixel
16113
16114 vector unsigned int
16115 vector signed int
16116 vector bool int
16117 vector float
16118 @end smallexample
16119
16120 If @option{-mvsx} is used the following additional vector types are
16121 implemented.
16122
16123 @smallexample
16124 vector unsigned long
16125 vector signed long
16126 vector double
16127 @end smallexample
16128
16129 The long types are only implemented for 64-bit code generation, and
16130 the long type is only used in the floating point/integer conversion
16131 instructions.
16132
16133 GCC's implementation of the high-level language interface available from
16134 C and C++ code differs from Motorola's documentation in several ways.
16135
16136 @itemize @bullet
16137
16138 @item
16139 A vector constant is a list of constant expressions within curly braces.
16140
16141 @item
16142 A vector initializer requires no cast if the vector constant is of the
16143 same type as the variable it is initializing.
16144
16145 @item
16146 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16147 vector type is the default signedness of the base type. The default
16148 varies depending on the operating system, so a portable program should
16149 always specify the signedness.
16150
16151 @item
16152 Compiling with @option{-maltivec} adds keywords @code{__vector},
16153 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16154 @code{bool}. When compiling ISO C, the context-sensitive substitution
16155 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16156 disabled. To use them, you must include @code{<altivec.h>} instead.
16157
16158 @item
16159 GCC allows using a @code{typedef} name as the type specifier for a
16160 vector type.
16161
16162 @item
16163 For C, overloaded functions are implemented with macros so the following
16164 does not work:
16165
16166 @smallexample
16167 vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16168 @end smallexample
16169
16170 @noindent
16171 Since @code{vec_add} is a macro, the vector constant in the example
16172 is treated as four separate arguments. Wrap the entire argument in
16173 parentheses for this to work.
16174 @end itemize
16175
16176 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16177 Internally, GCC uses built-in functions to achieve the functionality in
16178 the aforementioned header file, but they are not supported and are
16179 subject to change without notice.
16180
16181 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16182 which may be found at
16183 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16184 Appendix A of this document lists the vector API interfaces that must be
16185 provided by compliant compilers. Programmers should preferentially use
16186 the interfaces described therein. However, historically GCC has provided
16187 additional interfaces for access to vector instructions. These are
16188 briefly described below.
16189
16190 The following interfaces are supported for the generic and specific
16191 AltiVec operations and the AltiVec predicates. In cases where there
16192 is a direct mapping between generic and specific operations, only the
16193 generic names are shown here, although the specific operations can also
16194 be used.
16195
16196 Arguments that are documented as @code{const int} require literal
16197 integral values within the range required for that operation.
16198
16199 @smallexample
16200 vector signed char vec_abs (vector signed char);
16201 vector signed short vec_abs (vector signed short);
16202 vector signed int vec_abs (vector signed int);
16203 vector float vec_abs (vector float);
16204
16205 vector signed char vec_abss (vector signed char);
16206 vector signed short vec_abss (vector signed short);
16207 vector signed int vec_abss (vector signed int);
16208
16209 vector signed char vec_add (vector bool char, vector signed char);
16210 vector signed char vec_add (vector signed char, vector bool char);
16211 vector signed char vec_add (vector signed char, vector signed char);
16212 vector unsigned char vec_add (vector bool char, vector unsigned char);
16213 vector unsigned char vec_add (vector unsigned char, vector bool char);
16214 vector unsigned char vec_add (vector unsigned char,
16215 vector unsigned char);
16216 vector signed short vec_add (vector bool short, vector signed short);
16217 vector signed short vec_add (vector signed short, vector bool short);
16218 vector signed short vec_add (vector signed short, vector signed short);
16219 vector unsigned short vec_add (vector bool short,
16220 vector unsigned short);
16221 vector unsigned short vec_add (vector unsigned short,
16222 vector bool short);
16223 vector unsigned short vec_add (vector unsigned short,
16224 vector unsigned short);
16225 vector signed int vec_add (vector bool int, vector signed int);
16226 vector signed int vec_add (vector signed int, vector bool int);
16227 vector signed int vec_add (vector signed int, vector signed int);
16228 vector unsigned int vec_add (vector bool int, vector unsigned int);
16229 vector unsigned int vec_add (vector unsigned int, vector bool int);
16230 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16231 vector float vec_add (vector float, vector float);
16232
16233 vector float vec_vaddfp (vector float, vector float);
16234
16235 vector signed int vec_vadduwm (vector bool int, vector signed int);
16236 vector signed int vec_vadduwm (vector signed int, vector bool int);
16237 vector signed int vec_vadduwm (vector signed int, vector signed int);
16238 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
16239 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
16240 vector unsigned int vec_vadduwm (vector unsigned int,
16241 vector unsigned int);
16242
16243 vector signed short vec_vadduhm (vector bool short,
16244 vector signed short);
16245 vector signed short vec_vadduhm (vector signed short,
16246 vector bool short);
16247 vector signed short vec_vadduhm (vector signed short,
16248 vector signed short);
16249 vector unsigned short vec_vadduhm (vector bool short,
16250 vector unsigned short);
16251 vector unsigned short vec_vadduhm (vector unsigned short,
16252 vector bool short);
16253 vector unsigned short vec_vadduhm (vector unsigned short,
16254 vector unsigned short);
16255
16256 vector signed char vec_vaddubm (vector bool char, vector signed char);
16257 vector signed char vec_vaddubm (vector signed char, vector bool char);
16258 vector signed char vec_vaddubm (vector signed char, vector signed char);
16259 vector unsigned char vec_vaddubm (vector bool char,
16260 vector unsigned char);
16261 vector unsigned char vec_vaddubm (vector unsigned char,
16262 vector bool char);
16263 vector unsigned char vec_vaddubm (vector unsigned char,
16264 vector unsigned char);
16265
16266 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16267
16268 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16269 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16270 vector unsigned char vec_adds (vector unsigned char,
16271 vector unsigned char);
16272 vector signed char vec_adds (vector bool char, vector signed char);
16273 vector signed char vec_adds (vector signed char, vector bool char);
16274 vector signed char vec_adds (vector signed char, vector signed char);
16275 vector unsigned short vec_adds (vector bool short,
16276 vector unsigned short);
16277 vector unsigned short vec_adds (vector unsigned short,
16278 vector bool short);
16279 vector unsigned short vec_adds (vector unsigned short,
16280 vector unsigned short);
16281 vector signed short vec_adds (vector bool short, vector signed short);
16282 vector signed short vec_adds (vector signed short, vector bool short);
16283 vector signed short vec_adds (vector signed short, vector signed short);
16284 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16285 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16286 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16287 vector signed int vec_adds (vector bool int, vector signed int);
16288 vector signed int vec_adds (vector signed int, vector bool int);
16289 vector signed int vec_adds (vector signed int, vector signed int);
16290
16291 vector signed int vec_vaddsws (vector bool int, vector signed int);
16292 vector signed int vec_vaddsws (vector signed int, vector bool int);
16293 vector signed int vec_vaddsws (vector signed int, vector signed int);
16294
16295 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
16296 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
16297 vector unsigned int vec_vadduws (vector unsigned int,
16298 vector unsigned int);
16299
16300 vector signed short vec_vaddshs (vector bool short,
16301 vector signed short);
16302 vector signed short vec_vaddshs (vector signed short,
16303 vector bool short);
16304 vector signed short vec_vaddshs (vector signed short,
16305 vector signed short);
16306
16307 vector unsigned short vec_vadduhs (vector bool short,
16308 vector unsigned short);
16309 vector unsigned short vec_vadduhs (vector unsigned short,
16310 vector bool short);
16311 vector unsigned short vec_vadduhs (vector unsigned short,
16312 vector unsigned short);
16313
16314 vector signed char vec_vaddsbs (vector bool char, vector signed char);
16315 vector signed char vec_vaddsbs (vector signed char, vector bool char);
16316 vector signed char vec_vaddsbs (vector signed char, vector signed char);
16317
16318 vector unsigned char vec_vaddubs (vector bool char,
16319 vector unsigned char);
16320 vector unsigned char vec_vaddubs (vector unsigned char,
16321 vector bool char);
16322 vector unsigned char vec_vaddubs (vector unsigned char,
16323 vector unsigned char);
16324
16325 vector float vec_and (vector float, vector float);
16326 vector float vec_and (vector float, vector bool int);
16327 vector float vec_and (vector bool int, vector float);
16328 vector bool long long vec_and (vector bool long long int,
16329 vector bool long long);
16330 vector bool int vec_and (vector bool int, vector bool int);
16331 vector signed int vec_and (vector bool int, vector signed int);
16332 vector signed int vec_and (vector signed int, vector bool int);
16333 vector signed int vec_and (vector signed int, vector signed int);
16334 vector unsigned int vec_and (vector bool int, vector unsigned int);
16335 vector unsigned int vec_and (vector unsigned int, vector bool int);
16336 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16337 vector bool short vec_and (vector bool short, vector bool short);
16338 vector signed short vec_and (vector bool short, vector signed short);
16339 vector signed short vec_and (vector signed short, vector bool short);
16340 vector signed short vec_and (vector signed short, vector signed short);
16341 vector unsigned short vec_and (vector bool short,
16342 vector unsigned short);
16343 vector unsigned short vec_and (vector unsigned short,
16344 vector bool short);
16345 vector unsigned short vec_and (vector unsigned short,
16346 vector unsigned short);
16347 vector signed char vec_and (vector bool char, vector signed char);
16348 vector bool char vec_and (vector bool char, vector bool char);
16349 vector signed char vec_and (vector signed char, vector bool char);
16350 vector signed char vec_and (vector signed char, vector signed char);
16351 vector unsigned char vec_and (vector bool char, vector unsigned char);
16352 vector unsigned char vec_and (vector unsigned char, vector bool char);
16353 vector unsigned char vec_and (vector unsigned char,
16354 vector unsigned char);
16355
16356 vector float vec_andc (vector float, vector float);
16357 vector float vec_andc (vector float, vector bool int);
16358 vector float vec_andc (vector bool int, vector float);
16359 vector bool int vec_andc (vector bool int, vector bool int);
16360 vector signed int vec_andc (vector bool int, vector signed int);
16361 vector signed int vec_andc (vector signed int, vector bool int);
16362 vector signed int vec_andc (vector signed int, vector signed int);
16363 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16364 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16365 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16366 vector bool short vec_andc (vector bool short, vector bool short);
16367 vector signed short vec_andc (vector bool short, vector signed short);
16368 vector signed short vec_andc (vector signed short, vector bool short);
16369 vector signed short vec_andc (vector signed short, vector signed short);
16370 vector unsigned short vec_andc (vector bool short,
16371 vector unsigned short);
16372 vector unsigned short vec_andc (vector unsigned short,
16373 vector bool short);
16374 vector unsigned short vec_andc (vector unsigned short,
16375 vector unsigned short);
16376 vector signed char vec_andc (vector bool char, vector signed char);
16377 vector bool char vec_andc (vector bool char, vector bool char);
16378 vector signed char vec_andc (vector signed char, vector bool char);
16379 vector signed char vec_andc (vector signed char, vector signed char);
16380 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16381 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16382 vector unsigned char vec_andc (vector unsigned char,
16383 vector unsigned char);
16384
16385 vector unsigned char vec_avg (vector unsigned char,
16386 vector unsigned char);
16387 vector signed char vec_avg (vector signed char, vector signed char);
16388 vector unsigned short vec_avg (vector unsigned short,
16389 vector unsigned short);
16390 vector signed short vec_avg (vector signed short, vector signed short);
16391 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16392 vector signed int vec_avg (vector signed int, vector signed int);
16393
16394 vector signed int vec_vavgsw (vector signed int, vector signed int);
16395
16396 vector unsigned int vec_vavguw (vector unsigned int,
16397 vector unsigned int);
16398
16399 vector signed short vec_vavgsh (vector signed short,
16400 vector signed short);
16401
16402 vector unsigned short vec_vavguh (vector unsigned short,
16403 vector unsigned short);
16404
16405 vector signed char vec_vavgsb (vector signed char, vector signed char);
16406
16407 vector unsigned char vec_vavgub (vector unsigned char,
16408 vector unsigned char);
16409
16410 vector float vec_ceil (vector float);
16411
16412 vector signed int vec_cmpb (vector float, vector float);
16413
16414 vector bool char vec_cmpeq (vector bool char, vector bool char);
16415 vector bool short vec_cmpeq (vector bool short, vector bool short);
16416 vector bool int vec_cmpeq (vector bool int, vector bool int);
16417 vector bool char vec_cmpeq (vector signed char, vector signed char);
16418 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16419 vector bool short vec_cmpeq (vector signed short, vector signed short);
16420 vector bool short vec_cmpeq (vector unsigned short,
16421 vector unsigned short);
16422 vector bool int vec_cmpeq (vector signed int, vector signed int);
16423 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16424 vector bool int vec_cmpeq (vector float, vector float);
16425
16426 vector bool int vec_vcmpeqfp (vector float, vector float);
16427
16428 vector bool int vec_vcmpequw (vector signed int, vector signed int);
16429 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
16430
16431 vector bool short vec_vcmpequh (vector signed short,
16432 vector signed short);
16433 vector bool short vec_vcmpequh (vector unsigned short,
16434 vector unsigned short);
16435
16436 vector bool char vec_vcmpequb (vector signed char, vector signed char);
16437 vector bool char vec_vcmpequb (vector unsigned char,
16438 vector unsigned char);
16439
16440 vector bool int vec_cmpge (vector float, vector float);
16441
16442 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16443 vector bool char vec_cmpgt (vector signed char, vector signed char);
16444 vector bool short vec_cmpgt (vector unsigned short,
16445 vector unsigned short);
16446 vector bool short vec_cmpgt (vector signed short, vector signed short);
16447 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16448 vector bool int vec_cmpgt (vector signed int, vector signed int);
16449 vector bool int vec_cmpgt (vector float, vector float);
16450
16451 vector bool int vec_vcmpgtfp (vector float, vector float);
16452
16453 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
16454
16455 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
16456
16457 vector bool short vec_vcmpgtsh (vector signed short,
16458 vector signed short);
16459
16460 vector bool short vec_vcmpgtuh (vector unsigned short,
16461 vector unsigned short);
16462
16463 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
16464
16465 vector bool char vec_vcmpgtub (vector unsigned char,
16466 vector unsigned char);
16467
16468 vector bool int vec_cmple (vector float, vector float);
16469
16470 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16471 vector bool char vec_cmplt (vector signed char, vector signed char);
16472 vector bool short vec_cmplt (vector unsigned short,
16473 vector unsigned short);
16474 vector bool short vec_cmplt (vector signed short, vector signed short);
16475 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16476 vector bool int vec_cmplt (vector signed int, vector signed int);
16477 vector bool int vec_cmplt (vector float, vector float);
16478
16479 vector float vec_cpsgn (vector float, vector float);
16480
16481 vector float vec_ctf (vector unsigned int, const int);
16482 vector float vec_ctf (vector signed int, const int);
16483 vector double vec_ctf (vector unsigned long, const int);
16484 vector double vec_ctf (vector signed long, const int);
16485
16486 vector float vec_vcfsx (vector signed int, const int);
16487
16488 vector float vec_vcfux (vector unsigned int, const int);
16489
16490 vector signed int vec_cts (vector float, const int);
16491 vector signed long vec_cts (vector double, const int);
16492
16493 vector unsigned int vec_ctu (vector float, const int);
16494 vector unsigned long vec_ctu (vector double, const int);
16495
16496 vector double vec_doublee (vector float);
16497 vector double vec_doublee (vector signed int);
16498 vector double vec_doublee (vector unsigned int);
16499
16500 vector double vec_doubleo (vector float);
16501 vector double vec_doubleo (vector signed int);
16502 vector double vec_doubleo (vector unsigned int);
16503
16504 vector double vec_doubleh (vector float);
16505 vector double vec_doubleh (vector signed int);
16506 vector double vec_doubleh (vector unsigned int);
16507
16508 vector double vec_doublel (vector float);
16509 vector double vec_doublel (vector signed int);
16510 vector double vec_doublel (vector unsigned int);
16511
16512 void vec_dss (const int);
16513
16514 void vec_dssall (void);
16515
16516 void vec_dst (const vector unsigned char *, int, const int);
16517 void vec_dst (const vector signed char *, int, const int);
16518 void vec_dst (const vector bool char *, int, const int);
16519 void vec_dst (const vector unsigned short *, int, const int);
16520 void vec_dst (const vector signed short *, int, const int);
16521 void vec_dst (const vector bool short *, int, const int);
16522 void vec_dst (const vector pixel *, int, const int);
16523 void vec_dst (const vector unsigned int *, int, const int);
16524 void vec_dst (const vector signed int *, int, const int);
16525 void vec_dst (const vector bool int *, int, const int);
16526 void vec_dst (const vector float *, int, const int);
16527 void vec_dst (const unsigned char *, int, const int);
16528 void vec_dst (const signed char *, int, const int);
16529 void vec_dst (const unsigned short *, int, const int);
16530 void vec_dst (const short *, int, const int);
16531 void vec_dst (const unsigned int *, int, const int);
16532 void vec_dst (const int *, int, const int);
16533 void vec_dst (const unsigned long *, int, const int);
16534 void vec_dst (const long *, int, const int);
16535 void vec_dst (const float *, int, const int);
16536
16537 void vec_dstst (const vector unsigned char *, int, const int);
16538 void vec_dstst (const vector signed char *, int, const int);
16539 void vec_dstst (const vector bool char *, int, const int);
16540 void vec_dstst (const vector unsigned short *, int, const int);
16541 void vec_dstst (const vector signed short *, int, const int);
16542 void vec_dstst (const vector bool short *, int, const int);
16543 void vec_dstst (const vector pixel *, int, const int);
16544 void vec_dstst (const vector unsigned int *, int, const int);
16545 void vec_dstst (const vector signed int *, int, const int);
16546 void vec_dstst (const vector bool int *, int, const int);
16547 void vec_dstst (const vector float *, int, const int);
16548 void vec_dstst (const unsigned char *, int, const int);
16549 void vec_dstst (const signed char *, int, const int);
16550 void vec_dstst (const unsigned short *, int, const int);
16551 void vec_dstst (const short *, int, const int);
16552 void vec_dstst (const unsigned int *, int, const int);
16553 void vec_dstst (const int *, int, const int);
16554 void vec_dstst (const unsigned long *, int, const int);
16555 void vec_dstst (const long *, int, const int);
16556 void vec_dstst (const float *, int, const int);
16557
16558 void vec_dststt (const vector unsigned char *, int, const int);
16559 void vec_dststt (const vector signed char *, int, const int);
16560 void vec_dststt (const vector bool char *, int, const int);
16561 void vec_dststt (const vector unsigned short *, int, const int);
16562 void vec_dststt (const vector signed short *, int, const int);
16563 void vec_dststt (const vector bool short *, int, const int);
16564 void vec_dststt (const vector pixel *, int, const int);
16565 void vec_dststt (const vector unsigned int *, int, const int);
16566 void vec_dststt (const vector signed int *, int, const int);
16567 void vec_dststt (const vector bool int *, int, const int);
16568 void vec_dststt (const vector float *, int, const int);
16569 void vec_dststt (const unsigned char *, int, const int);
16570 void vec_dststt (const signed char *, int, const int);
16571 void vec_dststt (const unsigned short *, int, const int);
16572 void vec_dststt (const short *, int, const int);
16573 void vec_dststt (const unsigned int *, int, const int);
16574 void vec_dststt (const int *, int, const int);
16575 void vec_dststt (const unsigned long *, int, const int);
16576 void vec_dststt (const long *, int, const int);
16577 void vec_dststt (const float *, int, const int);
16578
16579 void vec_dstt (const vector unsigned char *, int, const int);
16580 void vec_dstt (const vector signed char *, int, const int);
16581 void vec_dstt (const vector bool char *, int, const int);
16582 void vec_dstt (const vector unsigned short *, int, const int);
16583 void vec_dstt (const vector signed short *, int, const int);
16584 void vec_dstt (const vector bool short *, int, const int);
16585 void vec_dstt (const vector pixel *, int, const int);
16586 void vec_dstt (const vector unsigned int *, int, const int);
16587 void vec_dstt (const vector signed int *, int, const int);
16588 void vec_dstt (const vector bool int *, int, const int);
16589 void vec_dstt (const vector float *, int, const int);
16590 void vec_dstt (const unsigned char *, int, const int);
16591 void vec_dstt (const signed char *, int, const int);
16592 void vec_dstt (const unsigned short *, int, const int);
16593 void vec_dstt (const short *, int, const int);
16594 void vec_dstt (const unsigned int *, int, const int);
16595 void vec_dstt (const int *, int, const int);
16596 void vec_dstt (const unsigned long *, int, const int);
16597 void vec_dstt (const long *, int, const int);
16598 void vec_dstt (const float *, int, const int);
16599
16600 vector float vec_expte (vector float);
16601
16602 vector float vec_floor (vector float);
16603
16604 vector float vec_float (vector signed int);
16605 vector float vec_float (vector unsigned int);
16606
16607 vector float vec_float2 (vector signed long long, vector signed long long);
16608 vector float vec_float2 (vector unsigned long long, vector signed long long);
16609
16610 vector float vec_floate (vector double);
16611 vector float vec_floate (vector signed long long);
16612 vector float vec_floate (vector unsigned long long);
16613
16614 vector float vec_floato (vector double);
16615 vector float vec_floato (vector signed long long);
16616 vector float vec_floato (vector unsigned long long);
16617
16618 vector float vec_ld (int, const vector float *);
16619 vector float vec_ld (int, const float *);
16620 vector bool int vec_ld (int, const vector bool int *);
16621 vector signed int vec_ld (int, const vector signed int *);
16622 vector signed int vec_ld (int, const int *);
16623 vector unsigned int vec_ld (int, const vector unsigned int *);
16624 vector unsigned int vec_ld (int, const unsigned int *);
16625 vector bool short vec_ld (int, const vector bool short *);
16626 vector pixel vec_ld (int, const vector pixel *);
16627 vector signed short vec_ld (int, const vector signed short *);
16628 vector signed short vec_ld (int, const short *);
16629 vector unsigned short vec_ld (int, const vector unsigned short *);
16630 vector unsigned short vec_ld (int, const unsigned short *);
16631 vector bool char vec_ld (int, const vector bool char *);
16632 vector signed char vec_ld (int, const vector signed char *);
16633 vector signed char vec_ld (int, const signed char *);
16634 vector unsigned char vec_ld (int, const vector unsigned char *);
16635 vector unsigned char vec_ld (int, const unsigned char *);
16636
16637 vector signed char vec_lde (int, const signed char *);
16638 vector unsigned char vec_lde (int, const unsigned char *);
16639 vector signed short vec_lde (int, const short *);
16640 vector unsigned short vec_lde (int, const unsigned short *);
16641 vector float vec_lde (int, const float *);
16642 vector signed int vec_lde (int, const int *);
16643 vector unsigned int vec_lde (int, const unsigned int *);
16644
16645 vector float vec_lvewx (int, float *);
16646 vector signed int vec_lvewx (int, int *);
16647 vector unsigned int vec_lvewx (int, unsigned int *);
16648
16649 vector signed short vec_lvehx (int, short *);
16650 vector unsigned short vec_lvehx (int, unsigned short *);
16651
16652 vector signed char vec_lvebx (int, char *);
16653 vector unsigned char vec_lvebx (int, unsigned char *);
16654
16655 vector float vec_ldl (int, const vector float *);
16656 vector float vec_ldl (int, const float *);
16657 vector bool int vec_ldl (int, const vector bool int *);
16658 vector signed int vec_ldl (int, const vector signed int *);
16659 vector signed int vec_ldl (int, const int *);
16660 vector unsigned int vec_ldl (int, const vector unsigned int *);
16661 vector unsigned int vec_ldl (int, const unsigned int *);
16662 vector bool short vec_ldl (int, const vector bool short *);
16663 vector pixel vec_ldl (int, const vector pixel *);
16664 vector signed short vec_ldl (int, const vector signed short *);
16665 vector signed short vec_ldl (int, const short *);
16666 vector unsigned short vec_ldl (int, const vector unsigned short *);
16667 vector unsigned short vec_ldl (int, const unsigned short *);
16668 vector bool char vec_ldl (int, const vector bool char *);
16669 vector signed char vec_ldl (int, const vector signed char *);
16670 vector signed char vec_ldl (int, const signed char *);
16671 vector unsigned char vec_ldl (int, const vector unsigned char *);
16672 vector unsigned char vec_ldl (int, const unsigned char *);
16673
16674 vector float vec_loge (vector float);
16675
16676 vector unsigned char vec_lvsl (int, const unsigned char *);
16677 vector unsigned char vec_lvsl (int, const signed char *);
16678 vector unsigned char vec_lvsl (int, const unsigned short *);
16679 vector unsigned char vec_lvsl (int, const short *);
16680 vector unsigned char vec_lvsl (int, const unsigned int *);
16681 vector unsigned char vec_lvsl (int, const int *);
16682 vector unsigned char vec_lvsl (int, const unsigned long *);
16683 vector unsigned char vec_lvsl (int, const long *);
16684 vector unsigned char vec_lvsl (int, const float *);
16685
16686 vector unsigned char vec_lvsr (int, const unsigned char *);
16687 vector unsigned char vec_lvsr (int, const signed char *);
16688 vector unsigned char vec_lvsr (int, const unsigned short *);
16689 vector unsigned char vec_lvsr (int, const short *);
16690 vector unsigned char vec_lvsr (int, const unsigned int *);
16691 vector unsigned char vec_lvsr (int, const int *);
16692 vector unsigned char vec_lvsr (int, const unsigned long *);
16693 vector unsigned char vec_lvsr (int, const long *);
16694 vector unsigned char vec_lvsr (int, const float *);
16695
16696 vector float vec_madd (vector float, vector float, vector float);
16697
16698 vector signed short vec_madds (vector signed short,
16699 vector signed short,
16700 vector signed short);
16701
16702 vector unsigned char vec_max (vector bool char, vector unsigned char);
16703 vector unsigned char vec_max (vector unsigned char, vector bool char);
16704 vector unsigned char vec_max (vector unsigned char,
16705 vector unsigned char);
16706 vector signed char vec_max (vector bool char, vector signed char);
16707 vector signed char vec_max (vector signed char, vector bool char);
16708 vector signed char vec_max (vector signed char, vector signed char);
16709 vector unsigned short vec_max (vector bool short,
16710 vector unsigned short);
16711 vector unsigned short vec_max (vector unsigned short,
16712 vector bool short);
16713 vector unsigned short vec_max (vector unsigned short,
16714 vector unsigned short);
16715 vector signed short vec_max (vector bool short, vector signed short);
16716 vector signed short vec_max (vector signed short, vector bool short);
16717 vector signed short vec_max (vector signed short, vector signed short);
16718 vector unsigned int vec_max (vector bool int, vector unsigned int);
16719 vector unsigned int vec_max (vector unsigned int, vector bool int);
16720 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16721 vector signed int vec_max (vector bool int, vector signed int);
16722 vector signed int vec_max (vector signed int, vector bool int);
16723 vector signed int vec_max (vector signed int, vector signed int);
16724 vector float vec_max (vector float, vector float);
16725
16726 vector float vec_vmaxfp (vector float, vector float);
16727
16728 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16729 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16730 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16731
16732 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16733 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16734 vector unsigned int vec_vmaxuw (vector unsigned int,
16735 vector unsigned int);
16736
16737 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16738 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16739 vector signed short vec_vmaxsh (vector signed short,
16740 vector signed short);
16741
16742 vector unsigned short vec_vmaxuh (vector bool short,
16743 vector unsigned short);
16744 vector unsigned short vec_vmaxuh (vector unsigned short,
16745 vector bool short);
16746 vector unsigned short vec_vmaxuh (vector unsigned short,
16747 vector unsigned short);
16748
16749 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16750 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16751 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16752
16753 vector unsigned char vec_vmaxub (vector bool char,
16754 vector unsigned char);
16755 vector unsigned char vec_vmaxub (vector unsigned char,
16756 vector bool char);
16757 vector unsigned char vec_vmaxub (vector unsigned char,
16758 vector unsigned char);
16759
16760 vector bool char vec_mergeh (vector bool char, vector bool char);
16761 vector signed char vec_mergeh (vector signed char, vector signed char);
16762 vector unsigned char vec_mergeh (vector unsigned char,
16763 vector unsigned char);
16764 vector bool short vec_mergeh (vector bool short, vector bool short);
16765 vector pixel vec_mergeh (vector pixel, vector pixel);
16766 vector signed short vec_mergeh (vector signed short,
16767 vector signed short);
16768 vector unsigned short vec_mergeh (vector unsigned short,
16769 vector unsigned short);
16770 vector float vec_mergeh (vector float, vector float);
16771 vector bool int vec_mergeh (vector bool int, vector bool int);
16772 vector signed int vec_mergeh (vector signed int, vector signed int);
16773 vector unsigned int vec_mergeh (vector unsigned int,
16774 vector unsigned int);
16775
16776 vector float vec_vmrghw (vector float, vector float);
16777 vector bool int vec_vmrghw (vector bool int, vector bool int);
16778 vector signed int vec_vmrghw (vector signed int, vector signed int);
16779 vector unsigned int vec_vmrghw (vector unsigned int,
16780 vector unsigned int);
16781
16782 vector bool short vec_vmrghh (vector bool short, vector bool short);
16783 vector signed short vec_vmrghh (vector signed short,
16784 vector signed short);
16785 vector unsigned short vec_vmrghh (vector unsigned short,
16786 vector unsigned short);
16787 vector pixel vec_vmrghh (vector pixel, vector pixel);
16788
16789 vector bool char vec_vmrghb (vector bool char, vector bool char);
16790 vector signed char vec_vmrghb (vector signed char, vector signed char);
16791 vector unsigned char vec_vmrghb (vector unsigned char,
16792 vector unsigned char);
16793
16794 vector bool char vec_mergel (vector bool char, vector bool char);
16795 vector signed char vec_mergel (vector signed char, vector signed char);
16796 vector unsigned char vec_mergel (vector unsigned char,
16797 vector unsigned char);
16798 vector bool short vec_mergel (vector bool short, vector bool short);
16799 vector pixel vec_mergel (vector pixel, vector pixel);
16800 vector signed short vec_mergel (vector signed short,
16801 vector signed short);
16802 vector unsigned short vec_mergel (vector unsigned short,
16803 vector unsigned short);
16804 vector float vec_mergel (vector float, vector float);
16805 vector bool int vec_mergel (vector bool int, vector bool int);
16806 vector signed int vec_mergel (vector signed int, vector signed int);
16807 vector unsigned int vec_mergel (vector unsigned int,
16808 vector unsigned int);
16809
16810 vector float vec_vmrglw (vector float, vector float);
16811 vector signed int vec_vmrglw (vector signed int, vector signed int);
16812 vector unsigned int vec_vmrglw (vector unsigned int,
16813 vector unsigned int);
16814 vector bool int vec_vmrglw (vector bool int, vector bool int);
16815
16816 vector bool short vec_vmrglh (vector bool short, vector bool short);
16817 vector signed short vec_vmrglh (vector signed short,
16818 vector signed short);
16819 vector unsigned short vec_vmrglh (vector unsigned short,
16820 vector unsigned short);
16821 vector pixel vec_vmrglh (vector pixel, vector pixel);
16822
16823 vector bool char vec_vmrglb (vector bool char, vector bool char);
16824 vector signed char vec_vmrglb (vector signed char, vector signed char);
16825 vector unsigned char vec_vmrglb (vector unsigned char,
16826 vector unsigned char);
16827
16828 vector unsigned short vec_mfvscr (void);
16829
16830 vector unsigned char vec_min (vector bool char, vector unsigned char);
16831 vector unsigned char vec_min (vector unsigned char, vector bool char);
16832 vector unsigned char vec_min (vector unsigned char,
16833 vector unsigned char);
16834 vector signed char vec_min (vector bool char, vector signed char);
16835 vector signed char vec_min (vector signed char, vector bool char);
16836 vector signed char vec_min (vector signed char, vector signed char);
16837 vector unsigned short vec_min (vector bool short,
16838 vector unsigned short);
16839 vector unsigned short vec_min (vector unsigned short,
16840 vector bool short);
16841 vector unsigned short vec_min (vector unsigned short,
16842 vector unsigned short);
16843 vector signed short vec_min (vector bool short, vector signed short);
16844 vector signed short vec_min (vector signed short, vector bool short);
16845 vector signed short vec_min (vector signed short, vector signed short);
16846 vector unsigned int vec_min (vector bool int, vector unsigned int);
16847 vector unsigned int vec_min (vector unsigned int, vector bool int);
16848 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16849 vector signed int vec_min (vector bool int, vector signed int);
16850 vector signed int vec_min (vector signed int, vector bool int);
16851 vector signed int vec_min (vector signed int, vector signed int);
16852 vector float vec_min (vector float, vector float);
16853
16854 vector float vec_vminfp (vector float, vector float);
16855
16856 vector signed int vec_vminsw (vector bool int, vector signed int);
16857 vector signed int vec_vminsw (vector signed int, vector bool int);
16858 vector signed int vec_vminsw (vector signed int, vector signed int);
16859
16860 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16861 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16862 vector unsigned int vec_vminuw (vector unsigned int,
16863 vector unsigned int);
16864
16865 vector signed short vec_vminsh (vector bool short, vector signed short);
16866 vector signed short vec_vminsh (vector signed short, vector bool short);
16867 vector signed short vec_vminsh (vector signed short,
16868 vector signed short);
16869
16870 vector unsigned short vec_vminuh (vector bool short,
16871 vector unsigned short);
16872 vector unsigned short vec_vminuh (vector unsigned short,
16873 vector bool short);
16874 vector unsigned short vec_vminuh (vector unsigned short,
16875 vector unsigned short);
16876
16877 vector signed char vec_vminsb (vector bool char, vector signed char);
16878 vector signed char vec_vminsb (vector signed char, vector bool char);
16879 vector signed char vec_vminsb (vector signed char, vector signed char);
16880
16881 vector unsigned char vec_vminub (vector bool char,
16882 vector unsigned char);
16883 vector unsigned char vec_vminub (vector unsigned char,
16884 vector bool char);
16885 vector unsigned char vec_vminub (vector unsigned char,
16886 vector unsigned char);
16887
16888 vector signed short vec_mladd (vector signed short,
16889 vector signed short,
16890 vector signed short);
16891 vector signed short vec_mladd (vector signed short,
16892 vector unsigned short,
16893 vector unsigned short);
16894 vector signed short vec_mladd (vector unsigned short,
16895 vector signed short,
16896 vector signed short);
16897 vector unsigned short vec_mladd (vector unsigned short,
16898 vector unsigned short,
16899 vector unsigned short);
16900
16901 vector signed short vec_mradds (vector signed short,
16902 vector signed short,
16903 vector signed short);
16904
16905 vector unsigned int vec_msum (vector unsigned char,
16906 vector unsigned char,
16907 vector unsigned int);
16908 vector signed int vec_msum (vector signed char,
16909 vector unsigned char,
16910 vector signed int);
16911 vector unsigned int vec_msum (vector unsigned short,
16912 vector unsigned short,
16913 vector unsigned int);
16914 vector signed int vec_msum (vector signed short,
16915 vector signed short,
16916 vector signed int);
16917
16918 vector signed int vec_vmsumshm (vector signed short,
16919 vector signed short,
16920 vector signed int);
16921
16922 vector unsigned int vec_vmsumuhm (vector unsigned short,
16923 vector unsigned short,
16924 vector unsigned int);
16925
16926 vector signed int vec_vmsummbm (vector signed char,
16927 vector unsigned char,
16928 vector signed int);
16929
16930 vector unsigned int vec_vmsumubm (vector unsigned char,
16931 vector unsigned char,
16932 vector unsigned int);
16933
16934 vector unsigned int vec_msums (vector unsigned short,
16935 vector unsigned short,
16936 vector unsigned int);
16937 vector signed int vec_msums (vector signed short,
16938 vector signed short,
16939 vector signed int);
16940
16941 vector signed int vec_vmsumshs (vector signed short,
16942 vector signed short,
16943 vector signed int);
16944
16945 vector unsigned int vec_vmsumuhs (vector unsigned short,
16946 vector unsigned short,
16947 vector unsigned int);
16948
16949 void vec_mtvscr (vector signed int);
16950 void vec_mtvscr (vector unsigned int);
16951 void vec_mtvscr (vector bool int);
16952 void vec_mtvscr (vector signed short);
16953 void vec_mtvscr (vector unsigned short);
16954 void vec_mtvscr (vector bool short);
16955 void vec_mtvscr (vector pixel);
16956 void vec_mtvscr (vector signed char);
16957 void vec_mtvscr (vector unsigned char);
16958 void vec_mtvscr (vector bool char);
16959
16960 vector unsigned short vec_mule (vector unsigned char,
16961 vector unsigned char);
16962 vector signed short vec_mule (vector signed char,
16963 vector signed char);
16964 vector unsigned int vec_mule (vector unsigned short,
16965 vector unsigned short);
16966 vector signed int vec_mule (vector signed short, vector signed short);
16967 vector unsigned long long vec_mule (vector unsigned int,
16968 vector unsigned int);
16969 vector signed long long vec_mule (vector signed int,
16970 vector signed int);
16971
16972 vector signed int vec_vmulesh (vector signed short,
16973 vector signed short);
16974
16975 vector unsigned int vec_vmuleuh (vector unsigned short,
16976 vector unsigned short);
16977
16978 vector signed short vec_vmulesb (vector signed char,
16979 vector signed char);
16980
16981 vector unsigned short vec_vmuleub (vector unsigned char,
16982 vector unsigned char);
16983
16984 vector unsigned short vec_mulo (vector unsigned char,
16985 vector unsigned char);
16986 vector signed short vec_mulo (vector signed char, vector signed char);
16987 vector unsigned int vec_mulo (vector unsigned short,
16988 vector unsigned short);
16989 vector signed int vec_mulo (vector signed short, vector signed short);
16990 vector unsigned long long vec_mulo (vector unsigned int,
16991 vector unsigned int);
16992 vector signed long long vec_mulo (vector signed int,
16993 vector signed int);
16994
16995 vector signed int vec_vmulosh (vector signed short,
16996 vector signed short);
16997
16998 vector unsigned int vec_vmulouh (vector unsigned short,
16999 vector unsigned short);
17000
17001 vector signed short vec_vmulosb (vector signed char,
17002 vector signed char);
17003
17004 vector unsigned short vec_vmuloub (vector unsigned char,
17005 vector unsigned char);
17006
17007 vector float vec_nmsub (vector float, vector float, vector float);
17008
17009 vector signed char vec_nabs (vector signed char);
17010 vector signed short vec_nabs (vector signed short);
17011 vector signed int vec_nabs (vector signed int);
17012 vector float vec_nabs (vector float);
17013 vector double vec_nabs (vector double);
17014
17015 vector signed char vec_neg (vector signed char);
17016 vector signed short vec_neg (vector signed short);
17017 vector signed int vec_neg (vector signed int);
17018 vector signed long long vec_neg (vector signed long long);
17019 vector float char vec_neg (vector float);
17020 vector double vec_neg (vector double);
17021
17022 vector float vec_nor (vector float, vector float);
17023 vector signed int vec_nor (vector signed int, vector signed int);
17024 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17025 vector bool int vec_nor (vector bool int, vector bool int);
17026 vector signed short vec_nor (vector signed short, vector signed short);
17027 vector unsigned short vec_nor (vector unsigned short,
17028 vector unsigned short);
17029 vector bool short vec_nor (vector bool short, vector bool short);
17030 vector signed char vec_nor (vector signed char, vector signed char);
17031 vector unsigned char vec_nor (vector unsigned char,
17032 vector unsigned char);
17033 vector bool char vec_nor (vector bool char, vector bool char);
17034
17035 vector float vec_or (vector float, vector float);
17036 vector float vec_or (vector float, vector bool int);
17037 vector float vec_or (vector bool int, vector float);
17038 vector bool int vec_or (vector bool int, vector bool int);
17039 vector signed int vec_or (vector bool int, vector signed int);
17040 vector signed int vec_or (vector signed int, vector bool int);
17041 vector signed int vec_or (vector signed int, vector signed int);
17042 vector unsigned int vec_or (vector bool int, vector unsigned int);
17043 vector unsigned int vec_or (vector unsigned int, vector bool int);
17044 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17045 vector bool short vec_or (vector bool short, vector bool short);
17046 vector signed short vec_or (vector bool short, vector signed short);
17047 vector signed short vec_or (vector signed short, vector bool short);
17048 vector signed short vec_or (vector signed short, vector signed short);
17049 vector unsigned short vec_or (vector bool short, vector unsigned short);
17050 vector unsigned short vec_or (vector unsigned short, vector bool short);
17051 vector unsigned short vec_or (vector unsigned short,
17052 vector unsigned short);
17053 vector signed char vec_or (vector bool char, vector signed char);
17054 vector bool char vec_or (vector bool char, vector bool char);
17055 vector signed char vec_or (vector signed char, vector bool char);
17056 vector signed char vec_or (vector signed char, vector signed char);
17057 vector unsigned char vec_or (vector bool char, vector unsigned char);
17058 vector unsigned char vec_or (vector unsigned char, vector bool char);
17059 vector unsigned char vec_or (vector unsigned char,
17060 vector unsigned char);
17061
17062 vector signed char vec_pack (vector signed short, vector signed short);
17063 vector unsigned char vec_pack (vector unsigned short,
17064 vector unsigned short);
17065 vector bool char vec_pack (vector bool short, vector bool short);
17066 vector signed short vec_pack (vector signed int, vector signed int);
17067 vector unsigned short vec_pack (vector unsigned int,
17068 vector unsigned int);
17069 vector bool short vec_pack (vector bool int, vector bool int);
17070
17071 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17072 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17073 vector unsigned short vec_vpkuwum (vector unsigned int,
17074 vector unsigned int);
17075
17076 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17077 vector signed char vec_vpkuhum (vector signed short,
17078 vector signed short);
17079 vector unsigned char vec_vpkuhum (vector unsigned short,
17080 vector unsigned short);
17081
17082 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17083
17084 vector unsigned char vec_packs (vector unsigned short,
17085 vector unsigned short);
17086 vector signed char vec_packs (vector signed short, vector signed short);
17087 vector unsigned short vec_packs (vector unsigned int,
17088 vector unsigned int);
17089 vector signed short vec_packs (vector signed int, vector signed int);
17090
17091 vector signed short vec_vpkswss (vector signed int, vector signed int);
17092
17093 vector unsigned short vec_vpkuwus (vector unsigned int,
17094 vector unsigned int);
17095
17096 vector signed char vec_vpkshss (vector signed short,
17097 vector signed short);
17098
17099 vector unsigned char vec_vpkuhus (vector unsigned short,
17100 vector unsigned short);
17101
17102 vector unsigned char vec_packsu (vector unsigned short,
17103 vector unsigned short);
17104 vector unsigned char vec_packsu (vector signed short,
17105 vector signed short);
17106 vector unsigned short vec_packsu (vector unsigned int,
17107 vector unsigned int);
17108 vector unsigned short vec_packsu (vector signed int, vector signed int);
17109
17110 vector unsigned short vec_vpkswus (vector signed int,
17111 vector signed int);
17112
17113 vector unsigned char vec_vpkshus (vector signed short,
17114 vector signed short);
17115
17116 vector float vec_perm (vector float,
17117 vector float,
17118 vector unsigned char);
17119 vector signed int vec_perm (vector signed int,
17120 vector signed int,
17121 vector unsigned char);
17122 vector unsigned int vec_perm (vector unsigned int,
17123 vector unsigned int,
17124 vector unsigned char);
17125 vector bool int vec_perm (vector bool int,
17126 vector bool int,
17127 vector unsigned char);
17128 vector signed short vec_perm (vector signed short,
17129 vector signed short,
17130 vector unsigned char);
17131 vector unsigned short vec_perm (vector unsigned short,
17132 vector unsigned short,
17133 vector unsigned char);
17134 vector bool short vec_perm (vector bool short,
17135 vector bool short,
17136 vector unsigned char);
17137 vector pixel vec_perm (vector pixel,
17138 vector pixel,
17139 vector unsigned char);
17140 vector signed char vec_perm (vector signed char,
17141 vector signed char,
17142 vector unsigned char);
17143 vector unsigned char vec_perm (vector unsigned char,
17144 vector unsigned char,
17145 vector unsigned char);
17146 vector bool char vec_perm (vector bool char,
17147 vector bool char,
17148 vector unsigned char);
17149
17150 vector float vec_re (vector float);
17151
17152 vector bool char vec_reve (vector bool char);
17153 vector signed char vec_reve (vector signed char);
17154 vector unsigned char vec_reve (vector unsigned char);
17155 vector bool int vec_reve (vector bool int);
17156 vector signed int vec_reve (vector signed int);
17157 vector unsigned int vec_reve (vector unsigned int);
17158 vector bool long long vec_reve (vector bool long long);
17159 vector signed long long vec_reve (vector signed long long);
17160 vector unsigned long long vec_reve (vector unsigned long long);
17161 vector bool short vec_reve (vector bool short);
17162 vector signed short vec_reve (vector signed short);
17163 vector unsigned short vec_reve (vector unsigned short);
17164
17165 vector signed char vec_rl (vector signed char,
17166 vector unsigned char);
17167 vector unsigned char vec_rl (vector unsigned char,
17168 vector unsigned char);
17169 vector signed short vec_rl (vector signed short, vector unsigned short);
17170 vector unsigned short vec_rl (vector unsigned short,
17171 vector unsigned short);
17172 vector signed int vec_rl (vector signed int, vector unsigned int);
17173 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17174
17175 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17176 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17177
17178 vector signed short vec_vrlh (vector signed short,
17179 vector unsigned short);
17180 vector unsigned short vec_vrlh (vector unsigned short,
17181 vector unsigned short);
17182
17183 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17184 vector unsigned char vec_vrlb (vector unsigned char,
17185 vector unsigned char);
17186
17187 vector float vec_round (vector float);
17188
17189 vector float vec_rsqrt (vector float);
17190
17191 vector float vec_rsqrte (vector float);
17192
17193 vector float vec_sel (vector float, vector float, vector bool int);
17194 vector float vec_sel (vector float, vector float, vector unsigned int);
17195 vector signed int vec_sel (vector signed int,
17196 vector signed int,
17197 vector bool int);
17198 vector signed int vec_sel (vector signed int,
17199 vector signed int,
17200 vector unsigned int);
17201 vector unsigned int vec_sel (vector unsigned int,
17202 vector unsigned int,
17203 vector bool int);
17204 vector unsigned int vec_sel (vector unsigned int,
17205 vector unsigned int,
17206 vector unsigned int);
17207 vector bool int vec_sel (vector bool int,
17208 vector bool int,
17209 vector bool int);
17210 vector bool int vec_sel (vector bool int,
17211 vector bool int,
17212 vector unsigned int);
17213 vector signed short vec_sel (vector signed short,
17214 vector signed short,
17215 vector bool short);
17216 vector signed short vec_sel (vector signed short,
17217 vector signed short,
17218 vector unsigned short);
17219 vector unsigned short vec_sel (vector unsigned short,
17220 vector unsigned short,
17221 vector bool short);
17222 vector unsigned short vec_sel (vector unsigned short,
17223 vector unsigned short,
17224 vector unsigned short);
17225 vector bool short vec_sel (vector bool short,
17226 vector bool short,
17227 vector bool short);
17228 vector bool short vec_sel (vector bool short,
17229 vector bool short,
17230 vector unsigned short);
17231 vector signed char vec_sel (vector signed char,
17232 vector signed char,
17233 vector bool char);
17234 vector signed char vec_sel (vector signed char,
17235 vector signed char,
17236 vector unsigned char);
17237 vector unsigned char vec_sel (vector unsigned char,
17238 vector unsigned char,
17239 vector bool char);
17240 vector unsigned char vec_sel (vector unsigned char,
17241 vector unsigned char,
17242 vector unsigned char);
17243 vector bool char vec_sel (vector bool char,
17244 vector bool char,
17245 vector bool char);
17246 vector bool char vec_sel (vector bool char,
17247 vector bool char,
17248 vector unsigned char);
17249
17250 vector signed long long vec_signed (vector double);
17251 vector signed int vec_signed (vector float);
17252
17253 vector signed int vec_signede (vector double);
17254 vector signed int vec_signedo (vector double);
17255 vector signed int vec_signed2 (vector double, vector double);
17256
17257 vector signed char vec_sl (vector signed char,
17258 vector unsigned char);
17259 vector unsigned char vec_sl (vector unsigned char,
17260 vector unsigned char);
17261 vector signed short vec_sl (vector signed short, vector unsigned short);
17262 vector unsigned short vec_sl (vector unsigned short,
17263 vector unsigned short);
17264 vector signed int vec_sl (vector signed int, vector unsigned int);
17265 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17266
17267 vector signed int vec_vslw (vector signed int, vector unsigned int);
17268 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17269
17270 vector signed short vec_vslh (vector signed short,
17271 vector unsigned short);
17272 vector unsigned short vec_vslh (vector unsigned short,
17273 vector unsigned short);
17274
17275 vector signed char vec_vslb (vector signed char, vector unsigned char);
17276 vector unsigned char vec_vslb (vector unsigned char,
17277 vector unsigned char);
17278
17279 vector float vec_sld (vector float, vector float, const int);
17280 vector double vec_sld (vector double, vector double, const int);
17281
17282 vector signed int vec_sld (vector signed int,
17283 vector signed int,
17284 const int);
17285 vector unsigned int vec_sld (vector unsigned int,
17286 vector unsigned int,
17287 const int);
17288 vector bool int vec_sld (vector bool int,
17289 vector bool int,
17290 const int);
17291 vector signed short vec_sld (vector signed short,
17292 vector signed short,
17293 const int);
17294 vector unsigned short vec_sld (vector unsigned short,
17295 vector unsigned short,
17296 const int);
17297 vector bool short vec_sld (vector bool short,
17298 vector bool short,
17299 const int);
17300 vector pixel vec_sld (vector pixel,
17301 vector pixel,
17302 const int);
17303 vector signed char vec_sld (vector signed char,
17304 vector signed char,
17305 const int);
17306 vector unsigned char vec_sld (vector unsigned char,
17307 vector unsigned char,
17308 const int);
17309 vector bool char vec_sld (vector bool char,
17310 vector bool char,
17311 const int);
17312 vector bool long long int vec_sld (vector bool long long int,
17313 vector bool long long int, const int);
17314 vector long long int vec_sld (vector long long int,
17315 vector long long int, const int);
17316 vector unsigned long long int vec_sld (vector unsigned long long int,
17317 vector unsigned long long int,
17318 const int);
17319
17320 vector signed char vec_sldw (vector signed char,
17321 vector signed char,
17322 const int);
17323 vector unsigned char vec_sldw (vector unsigned char,
17324 vector unsigned char,
17325 const int);
17326 vector signed short vec_sldw (vector signed short,
17327 vector signed short,
17328 const int);
17329 vector unsigned short vec_sldw (vector unsigned short,
17330 vector unsigned short,
17331 const int);
17332 vector signed int vec_sldw (vector signed int,
17333 vector signed int,
17334 const int);
17335 vector unsigned int vec_sldw (vector unsigned int,
17336 vector unsigned int,
17337 const int);
17338 vector signed long long vec_sldw (vector signed long long,
17339 vector signed long long,
17340 const int);
17341 vector unsigned long long vec_sldw (vector unsigned long long,
17342 vector unsigned long long,
17343 const int);
17344
17345 vector signed int vec_sll (vector signed int,
17346 vector unsigned int);
17347 vector signed int vec_sll (vector signed int,
17348 vector unsigned short);
17349 vector signed int vec_sll (vector signed int,
17350 vector unsigned char);
17351 vector unsigned int vec_sll (vector unsigned int,
17352 vector unsigned int);
17353 vector unsigned int vec_sll (vector unsigned int,
17354 vector unsigned short);
17355 vector unsigned int vec_sll (vector unsigned int,
17356 vector unsigned char);
17357 vector bool int vec_sll (vector bool int,
17358 vector unsigned int);
17359 vector bool int vec_sll (vector bool int,
17360 vector unsigned short);
17361 vector bool int vec_sll (vector bool int,
17362 vector unsigned char);
17363 vector signed short vec_sll (vector signed short,
17364 vector unsigned int);
17365 vector signed short vec_sll (vector signed short,
17366 vector unsigned short);
17367 vector signed short vec_sll (vector signed short,
17368 vector unsigned char);
17369 vector unsigned short vec_sll (vector unsigned short,
17370 vector unsigned int);
17371 vector unsigned short vec_sll (vector unsigned short,
17372 vector unsigned short);
17373 vector unsigned short vec_sll (vector unsigned short,
17374 vector unsigned char);
17375 vector long long int vec_sll (vector long long int,
17376 vector unsigned char);
17377 vector unsigned long long int vec_sll (vector unsigned long long int,
17378 vector unsigned char);
17379 vector bool short vec_sll (vector bool short, vector unsigned int);
17380 vector bool short vec_sll (vector bool short, vector unsigned short);
17381 vector bool short vec_sll (vector bool short, vector unsigned char);
17382 vector pixel vec_sll (vector pixel, vector unsigned int);
17383 vector pixel vec_sll (vector pixel, vector unsigned short);
17384 vector pixel vec_sll (vector pixel, vector unsigned char);
17385 vector signed char vec_sll (vector signed char, vector unsigned int);
17386 vector signed char vec_sll (vector signed char, vector unsigned short);
17387 vector signed char vec_sll (vector signed char, vector unsigned char);
17388 vector unsigned char vec_sll (vector unsigned char,
17389 vector unsigned int);
17390 vector unsigned char vec_sll (vector unsigned char,
17391 vector unsigned short);
17392 vector unsigned char vec_sll (vector unsigned char,
17393 vector unsigned char);
17394 vector bool char vec_sll (vector bool char, vector unsigned int);
17395 vector bool char vec_sll (vector bool char, vector unsigned short);
17396 vector bool char vec_sll (vector bool char, vector unsigned char);
17397
17398 vector float vec_slo (vector float, vector signed char);
17399 vector float vec_slo (vector float, vector unsigned char);
17400 vector signed int vec_slo (vector signed int, vector signed char);
17401 vector signed int vec_slo (vector signed int, vector unsigned char);
17402 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17403 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17404 vector signed short vec_slo (vector signed short, vector signed char);
17405 vector signed short vec_slo (vector signed short, vector unsigned char);
17406 vector unsigned short vec_slo (vector unsigned short,
17407 vector signed char);
17408 vector unsigned short vec_slo (vector unsigned short,
17409 vector unsigned char);
17410 vector pixel vec_slo (vector pixel, vector signed char);
17411 vector pixel vec_slo (vector pixel, vector unsigned char);
17412 vector signed char vec_slo (vector signed char, vector signed char);
17413 vector signed char vec_slo (vector signed char, vector unsigned char);
17414 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17415 vector unsigned char vec_slo (vector unsigned char,
17416 vector unsigned char);
17417 vector signed long long vec_slo (vector signed long long, vector signed char);
17418 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17419 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17420 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17421
17422 vector signed char vec_splat (vector signed char, const int);
17423 vector unsigned char vec_splat (vector unsigned char, const int);
17424 vector bool char vec_splat (vector bool char, const int);
17425 vector signed short vec_splat (vector signed short, const int);
17426 vector unsigned short vec_splat (vector unsigned short, const int);
17427 vector bool short vec_splat (vector bool short, const int);
17428 vector pixel vec_splat (vector pixel, const int);
17429 vector float vec_splat (vector float, const int);
17430 vector signed int vec_splat (vector signed int, const int);
17431 vector unsigned int vec_splat (vector unsigned int, const int);
17432 vector bool int vec_splat (vector bool int, const int);
17433 vector signed long vec_splat (vector signed long, const int);
17434 vector unsigned long vec_splat (vector unsigned long, const int);
17435
17436 vector signed char vec_splats (signed char);
17437 vector unsigned char vec_splats (unsigned char);
17438 vector signed short vec_splats (signed short);
17439 vector unsigned short vec_splats (unsigned short);
17440 vector signed int vec_splats (signed int);
17441 vector unsigned int vec_splats (unsigned int);
17442 vector float vec_splats (float);
17443
17444 vector float vec_vspltw (vector float, const int);
17445 vector signed int vec_vspltw (vector signed int, const int);
17446 vector unsigned int vec_vspltw (vector unsigned int, const int);
17447 vector bool int vec_vspltw (vector bool int, const int);
17448
17449 vector bool short vec_vsplth (vector bool short, const int);
17450 vector signed short vec_vsplth (vector signed short, const int);
17451 vector unsigned short vec_vsplth (vector unsigned short, const int);
17452 vector pixel vec_vsplth (vector pixel, const int);
17453
17454 vector signed char vec_vspltb (vector signed char, const int);
17455 vector unsigned char vec_vspltb (vector unsigned char, const int);
17456 vector bool char vec_vspltb (vector bool char, const int);
17457
17458 vector signed char vec_splat_s8 (const int);
17459
17460 vector signed short vec_splat_s16 (const int);
17461
17462 vector signed int vec_splat_s32 (const int);
17463
17464 vector unsigned char vec_splat_u8 (const int);
17465
17466 vector unsigned short vec_splat_u16 (const int);
17467
17468 vector unsigned int vec_splat_u32 (const int);
17469
17470 vector signed char vec_sr (vector signed char, vector unsigned char);
17471 vector unsigned char vec_sr (vector unsigned char,
17472 vector unsigned char);
17473 vector signed short vec_sr (vector signed short,
17474 vector unsigned short);
17475 vector unsigned short vec_sr (vector unsigned short,
17476 vector unsigned short);
17477 vector signed int vec_sr (vector signed int, vector unsigned int);
17478 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17479
17480 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17481 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17482
17483 vector signed short vec_vsrh (vector signed short,
17484 vector unsigned short);
17485 vector unsigned short vec_vsrh (vector unsigned short,
17486 vector unsigned short);
17487
17488 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17489 vector unsigned char vec_vsrb (vector unsigned char,
17490 vector unsigned char);
17491
17492 vector signed char vec_sra (vector signed char, vector unsigned char);
17493 vector unsigned char vec_sra (vector unsigned char,
17494 vector unsigned char);
17495 vector signed short vec_sra (vector signed short,
17496 vector unsigned short);
17497 vector unsigned short vec_sra (vector unsigned short,
17498 vector unsigned short);
17499 vector signed int vec_sra (vector signed int, vector unsigned int);
17500 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17501
17502 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17503 vector unsigned int vec_vsraw (vector unsigned int,
17504 vector unsigned int);
17505
17506 vector signed short vec_vsrah (vector signed short,
17507 vector unsigned short);
17508 vector unsigned short vec_vsrah (vector unsigned short,
17509 vector unsigned short);
17510
17511 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17512 vector unsigned char vec_vsrab (vector unsigned char,
17513 vector unsigned char);
17514
17515 vector signed int vec_srl (vector signed int, vector unsigned int);
17516 vector signed int vec_srl (vector signed int, vector unsigned short);
17517 vector signed int vec_srl (vector signed int, vector unsigned char);
17518 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17519 vector unsigned int vec_srl (vector unsigned int,
17520 vector unsigned short);
17521 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17522 vector bool int vec_srl (vector bool int, vector unsigned int);
17523 vector bool int vec_srl (vector bool int, vector unsigned short);
17524 vector bool int vec_srl (vector bool int, vector unsigned char);
17525 vector signed short vec_srl (vector signed short, vector unsigned int);
17526 vector signed short vec_srl (vector signed short,
17527 vector unsigned short);
17528 vector signed short vec_srl (vector signed short, vector unsigned char);
17529 vector unsigned short vec_srl (vector unsigned short,
17530 vector unsigned int);
17531 vector unsigned short vec_srl (vector unsigned short,
17532 vector unsigned short);
17533 vector unsigned short vec_srl (vector unsigned short,
17534 vector unsigned char);
17535 vector long long int vec_srl (vector long long int,
17536 vector unsigned char);
17537 vector unsigned long long int vec_srl (vector unsigned long long int,
17538 vector unsigned char);
17539 vector bool short vec_srl (vector bool short, vector unsigned int);
17540 vector bool short vec_srl (vector bool short, vector unsigned short);
17541 vector bool short vec_srl (vector bool short, vector unsigned char);
17542 vector pixel vec_srl (vector pixel, vector unsigned int);
17543 vector pixel vec_srl (vector pixel, vector unsigned short);
17544 vector pixel vec_srl (vector pixel, vector unsigned char);
17545 vector signed char vec_srl (vector signed char, vector unsigned int);
17546 vector signed char vec_srl (vector signed char, vector unsigned short);
17547 vector signed char vec_srl (vector signed char, vector unsigned char);
17548 vector unsigned char vec_srl (vector unsigned char,
17549 vector unsigned int);
17550 vector unsigned char vec_srl (vector unsigned char,
17551 vector unsigned short);
17552 vector unsigned char vec_srl (vector unsigned char,
17553 vector unsigned char);
17554 vector bool char vec_srl (vector bool char, vector unsigned int);
17555 vector bool char vec_srl (vector bool char, vector unsigned short);
17556 vector bool char vec_srl (vector bool char, vector unsigned char);
17557
17558 vector float vec_sro (vector float, vector signed char);
17559 vector float vec_sro (vector float, vector unsigned char);
17560 vector signed int vec_sro (vector signed int, vector signed char);
17561 vector signed int vec_sro (vector signed int, vector unsigned char);
17562 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17563 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17564 vector signed short vec_sro (vector signed short, vector signed char);
17565 vector signed short vec_sro (vector signed short, vector unsigned char);
17566 vector unsigned short vec_sro (vector unsigned short,
17567 vector signed char);
17568 vector unsigned short vec_sro (vector unsigned short,
17569 vector unsigned char);
17570 vector long long int vec_sro (vector long long int,
17571 vector char);
17572 vector long long int vec_sro (vector long long int,
17573 vector unsigned char);
17574 vector unsigned long long int vec_sro (vector unsigned long long int,
17575 vector char);
17576 vector unsigned long long int vec_sro (vector unsigned long long int,
17577 vector unsigned char);
17578 vector pixel vec_sro (vector pixel, vector signed char);
17579 vector pixel vec_sro (vector pixel, vector unsigned char);
17580 vector signed char vec_sro (vector signed char, vector signed char);
17581 vector signed char vec_sro (vector signed char, vector unsigned char);
17582 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17583 vector unsigned char vec_sro (vector unsigned char,
17584 vector unsigned char);
17585
17586 void vec_st (vector float, int, vector float *);
17587 void vec_st (vector float, int, float *);
17588 void vec_st (vector signed int, int, vector signed int *);
17589 void vec_st (vector signed int, int, int *);
17590 void vec_st (vector unsigned int, int, vector unsigned int *);
17591 void vec_st (vector unsigned int, int, unsigned int *);
17592 void vec_st (vector bool int, int, vector bool int *);
17593 void vec_st (vector bool int, int, unsigned int *);
17594 void vec_st (vector bool int, int, int *);
17595 void vec_st (vector signed short, int, vector signed short *);
17596 void vec_st (vector signed short, int, short *);
17597 void vec_st (vector unsigned short, int, vector unsigned short *);
17598 void vec_st (vector unsigned short, int, unsigned short *);
17599 void vec_st (vector bool short, int, vector bool short *);
17600 void vec_st (vector bool short, int, unsigned short *);
17601 void vec_st (vector pixel, int, vector pixel *);
17602 void vec_st (vector bool short, int, short *);
17603 void vec_st (vector signed char, int, vector signed char *);
17604 void vec_st (vector signed char, int, signed char *);
17605 void vec_st (vector unsigned char, int, vector unsigned char *);
17606 void vec_st (vector unsigned char, int, unsigned char *);
17607 void vec_st (vector bool char, int, vector bool char *);
17608 void vec_st (vector bool char, int, unsigned char *);
17609 void vec_st (vector bool char, int, signed char *);
17610
17611 void vec_ste (vector signed char, int, signed char *);
17612 void vec_ste (vector unsigned char, int, unsigned char *);
17613 void vec_ste (vector bool char, int, signed char *);
17614 void vec_ste (vector bool char, int, unsigned char *);
17615 void vec_ste (vector signed short, int, short *);
17616 void vec_ste (vector unsigned short, int, unsigned short *);
17617 void vec_ste (vector bool short, int, short *);
17618 void vec_ste (vector bool short, int, unsigned short *);
17619 void vec_ste (vector pixel, int, short *);
17620 void vec_ste (vector pixel, int, unsigned short *);
17621 void vec_ste (vector float, int, float *);
17622 void vec_ste (vector signed int, int, int *);
17623 void vec_ste (vector unsigned int, int, unsigned int *);
17624 void vec_ste (vector bool int, int, int *);
17625 void vec_ste (vector bool int, int, unsigned int *);
17626
17627 void vec_stvewx (vector float, int, float *);
17628 void vec_stvewx (vector signed int, int, int *);
17629 void vec_stvewx (vector unsigned int, int, unsigned int *);
17630 void vec_stvewx (vector bool int, int, int *);
17631 void vec_stvewx (vector bool int, int, unsigned int *);
17632
17633 void vec_stvehx (vector signed short, int, short *);
17634 void vec_stvehx (vector unsigned short, int, unsigned short *);
17635 void vec_stvehx (vector bool short, int, short *);
17636 void vec_stvehx (vector bool short, int, unsigned short *);
17637
17638 void vec_stvebx (vector signed char, int, signed char *);
17639 void vec_stvebx (vector unsigned char, int, unsigned char *);
17640 void vec_stvebx (vector bool char, int, signed char *);
17641 void vec_stvebx (vector bool char, int, unsigned char *);
17642
17643 void vec_stl (vector float, int, vector float *);
17644 void vec_stl (vector float, int, float *);
17645 void vec_stl (vector signed int, int, vector signed int *);
17646 void vec_stl (vector signed int, int, int *);
17647 void vec_stl (vector unsigned int, int, vector unsigned int *);
17648 void vec_stl (vector unsigned int, int, unsigned int *);
17649 void vec_stl (vector bool int, int, vector bool int *);
17650 void vec_stl (vector bool int, int, unsigned int *);
17651 void vec_stl (vector bool int, int, int *);
17652 void vec_stl (vector signed short, int, vector signed short *);
17653 void vec_stl (vector signed short, int, short *);
17654 void vec_stl (vector unsigned short, int, vector unsigned short *);
17655 void vec_stl (vector unsigned short, int, unsigned short *);
17656 void vec_stl (vector bool short, int, vector bool short *);
17657 void vec_stl (vector bool short, int, unsigned short *);
17658 void vec_stl (vector bool short, int, short *);
17659 void vec_stl (vector pixel, int, vector pixel *);
17660 void vec_stl (vector signed char, int, vector signed char *);
17661 void vec_stl (vector signed char, int, signed char *);
17662 void vec_stl (vector unsigned char, int, vector unsigned char *);
17663 void vec_stl (vector unsigned char, int, unsigned char *);
17664 void vec_stl (vector bool char, int, vector bool char *);
17665 void vec_stl (vector bool char, int, unsigned char *);
17666 void vec_stl (vector bool char, int, signed char *);
17667
17668 vector signed char vec_sub (vector bool char, vector signed char);
17669 vector signed char vec_sub (vector signed char, vector bool char);
17670 vector signed char vec_sub (vector signed char, vector signed char);
17671 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17672 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17673 vector unsigned char vec_sub (vector unsigned char,
17674 vector unsigned char);
17675 vector signed short vec_sub (vector bool short, vector signed short);
17676 vector signed short vec_sub (vector signed short, vector bool short);
17677 vector signed short vec_sub (vector signed short, vector signed short);
17678 vector unsigned short vec_sub (vector bool short,
17679 vector unsigned short);
17680 vector unsigned short vec_sub (vector unsigned short,
17681 vector bool short);
17682 vector unsigned short vec_sub (vector unsigned short,
17683 vector unsigned short);
17684 vector signed int vec_sub (vector bool int, vector signed int);
17685 vector signed int vec_sub (vector signed int, vector bool int);
17686 vector signed int vec_sub (vector signed int, vector signed int);
17687 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17688 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17689 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17690 vector float vec_sub (vector float, vector float);
17691
17692 vector float vec_vsubfp (vector float, vector float);
17693
17694 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17695 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17696 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17697 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17698 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17699 vector unsigned int vec_vsubuwm (vector unsigned int,
17700 vector unsigned int);
17701
17702 vector signed short vec_vsubuhm (vector bool short,
17703 vector signed short);
17704 vector signed short vec_vsubuhm (vector signed short,
17705 vector bool short);
17706 vector signed short vec_vsubuhm (vector signed short,
17707 vector signed short);
17708 vector unsigned short vec_vsubuhm (vector bool short,
17709 vector unsigned short);
17710 vector unsigned short vec_vsubuhm (vector unsigned short,
17711 vector bool short);
17712 vector unsigned short vec_vsubuhm (vector unsigned short,
17713 vector unsigned short);
17714
17715 vector signed char vec_vsububm (vector bool char, vector signed char);
17716 vector signed char vec_vsububm (vector signed char, vector bool char);
17717 vector signed char vec_vsububm (vector signed char, vector signed char);
17718 vector unsigned char vec_vsububm (vector bool char,
17719 vector unsigned char);
17720 vector unsigned char vec_vsububm (vector unsigned char,
17721 vector bool char);
17722 vector unsigned char vec_vsububm (vector unsigned char,
17723 vector unsigned char);
17724
17725 vector signed int vec_subc (vector signed int, vector signed int);
17726 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17727 vector signed __int128 vec_subc (vector signed __int128,
17728 vector signed __int128);
17729 vector unsigned __int128 vec_subc (vector unsigned __int128,
17730 vector unsigned __int128);
17731
17732 vector signed int vec_sube (vector signed int, vector signed int,
17733 vector signed int);
17734 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17735 vector unsigned int);
17736 vector signed __int128 vec_sube (vector signed __int128,
17737 vector signed __int128,
17738 vector signed __int128);
17739 vector unsigned __int128 vec_sube (vector unsigned __int128,
17740 vector unsigned __int128,
17741 vector unsigned __int128);
17742
17743 vector signed int vec_subec (vector signed int, vector signed int,
17744 vector signed int);
17745 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17746 vector unsigned int);
17747 vector signed __int128 vec_subec (vector signed __int128,
17748 vector signed __int128,
17749 vector signed __int128);
17750 vector unsigned __int128 vec_subec (vector unsigned __int128,
17751 vector unsigned __int128,
17752 vector unsigned __int128);
17753
17754 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17755 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17756 vector unsigned char vec_subs (vector unsigned char,
17757 vector unsigned char);
17758 vector signed char vec_subs (vector bool char, vector signed char);
17759 vector signed char vec_subs (vector signed char, vector bool char);
17760 vector signed char vec_subs (vector signed char, vector signed char);
17761 vector unsigned short vec_subs (vector bool short,
17762 vector unsigned short);
17763 vector unsigned short vec_subs (vector unsigned short,
17764 vector bool short);
17765 vector unsigned short vec_subs (vector unsigned short,
17766 vector unsigned short);
17767 vector signed short vec_subs (vector bool short, vector signed short);
17768 vector signed short vec_subs (vector signed short, vector bool short);
17769 vector signed short vec_subs (vector signed short, vector signed short);
17770 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17771 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17772 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17773 vector signed int vec_subs (vector bool int, vector signed int);
17774 vector signed int vec_subs (vector signed int, vector bool int);
17775 vector signed int vec_subs (vector signed int, vector signed int);
17776
17777 vector signed int vec_vsubsws (vector bool int, vector signed int);
17778 vector signed int vec_vsubsws (vector signed int, vector bool int);
17779 vector signed int vec_vsubsws (vector signed int, vector signed int);
17780
17781 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17782 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17783 vector unsigned int vec_vsubuws (vector unsigned int,
17784 vector unsigned int);
17785
17786 vector signed short vec_vsubshs (vector bool short,
17787 vector signed short);
17788 vector signed short vec_vsubshs (vector signed short,
17789 vector bool short);
17790 vector signed short vec_vsubshs (vector signed short,
17791 vector signed short);
17792
17793 vector unsigned short vec_vsubuhs (vector bool short,
17794 vector unsigned short);
17795 vector unsigned short vec_vsubuhs (vector unsigned short,
17796 vector bool short);
17797 vector unsigned short vec_vsubuhs (vector unsigned short,
17798 vector unsigned short);
17799
17800 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17801 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17802 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17803
17804 vector unsigned char vec_vsububs (vector bool char,
17805 vector unsigned char);
17806 vector unsigned char vec_vsububs (vector unsigned char,
17807 vector bool char);
17808 vector unsigned char vec_vsububs (vector unsigned char,
17809 vector unsigned char);
17810
17811 vector unsigned int vec_sum4s (vector unsigned char,
17812 vector unsigned int);
17813 vector signed int vec_sum4s (vector signed char, vector signed int);
17814 vector signed int vec_sum4s (vector signed short, vector signed int);
17815
17816 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17817
17818 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17819
17820 vector unsigned int vec_vsum4ubs (vector unsigned char,
17821 vector unsigned int);
17822
17823 vector signed int vec_sum2s (vector signed int, vector signed int);
17824
17825 vector signed int vec_sums (vector signed int, vector signed int);
17826
17827 vector float vec_trunc (vector float);
17828
17829 vector signed long long vec_unsigned (vector double);
17830 vector signed int vec_unsigned (vector float);
17831
17832 vector signed int vec_unsignede (vector double);
17833 vector signed int vec_unsignedo (vector double);
17834 vector signed int vec_unsigned2 (vector double, vector double);
17835
17836 vector signed short vec_unpackh (vector signed char);
17837 vector bool short vec_unpackh (vector bool char);
17838 vector signed int vec_unpackh (vector signed short);
17839 vector bool int vec_unpackh (vector bool short);
17840 vector unsigned int vec_unpackh (vector pixel);
17841 vector double vec_unpackh (vector float);
17842
17843 vector bool int vec_vupkhsh (vector bool short);
17844 vector signed int vec_vupkhsh (vector signed short);
17845
17846 vector unsigned int vec_vupkhpx (vector pixel);
17847
17848 vector bool short vec_vupkhsb (vector bool char);
17849 vector signed short vec_vupkhsb (vector signed char);
17850
17851 vector signed short vec_unpackl (vector signed char);
17852 vector bool short vec_unpackl (vector bool char);
17853 vector unsigned int vec_unpackl (vector pixel);
17854 vector signed int vec_unpackl (vector signed short);
17855 vector bool int vec_unpackl (vector bool short);
17856 vector double vec_unpackl (vector float);
17857
17858 vector unsigned int vec_vupklpx (vector pixel);
17859
17860 vector bool int vec_vupklsh (vector bool short);
17861 vector signed int vec_vupklsh (vector signed short);
17862
17863 vector bool short vec_vupklsb (vector bool char);
17864 vector signed short vec_vupklsb (vector signed char);
17865
17866 vector float vec_xor (vector float, vector float);
17867 vector float vec_xor (vector float, vector bool int);
17868 vector float vec_xor (vector bool int, vector float);
17869 vector bool int vec_xor (vector bool int, vector bool int);
17870 vector signed int vec_xor (vector bool int, vector signed int);
17871 vector signed int vec_xor (vector signed int, vector bool int);
17872 vector signed int vec_xor (vector signed int, vector signed int);
17873 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17874 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17875 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17876 vector bool short vec_xor (vector bool short, vector bool short);
17877 vector signed short vec_xor (vector bool short, vector signed short);
17878 vector signed short vec_xor (vector signed short, vector bool short);
17879 vector signed short vec_xor (vector signed short, vector signed short);
17880 vector unsigned short vec_xor (vector bool short,
17881 vector unsigned short);
17882 vector unsigned short vec_xor (vector unsigned short,
17883 vector bool short);
17884 vector unsigned short vec_xor (vector unsigned short,
17885 vector unsigned short);
17886 vector signed char vec_xor (vector bool char, vector signed char);
17887 vector bool char vec_xor (vector bool char, vector bool char);
17888 vector signed char vec_xor (vector signed char, vector bool char);
17889 vector signed char vec_xor (vector signed char, vector signed char);
17890 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17891 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17892 vector unsigned char vec_xor (vector unsigned char,
17893 vector unsigned char);
17894
17895 int vec_all_eq (vector signed char, vector bool char);
17896 int vec_all_eq (vector signed char, vector signed char);
17897 int vec_all_eq (vector unsigned char, vector bool char);
17898 int vec_all_eq (vector unsigned char, vector unsigned char);
17899 int vec_all_eq (vector bool char, vector bool char);
17900 int vec_all_eq (vector bool char, vector unsigned char);
17901 int vec_all_eq (vector bool char, vector signed char);
17902 int vec_all_eq (vector signed short, vector bool short);
17903 int vec_all_eq (vector signed short, vector signed short);
17904 int vec_all_eq (vector unsigned short, vector bool short);
17905 int vec_all_eq (vector unsigned short, vector unsigned short);
17906 int vec_all_eq (vector bool short, vector bool short);
17907 int vec_all_eq (vector bool short, vector unsigned short);
17908 int vec_all_eq (vector bool short, vector signed short);
17909 int vec_all_eq (vector pixel, vector pixel);
17910 int vec_all_eq (vector signed int, vector bool int);
17911 int vec_all_eq (vector signed int, vector signed int);
17912 int vec_all_eq (vector unsigned int, vector bool int);
17913 int vec_all_eq (vector unsigned int, vector unsigned int);
17914 int vec_all_eq (vector bool int, vector bool int);
17915 int vec_all_eq (vector bool int, vector unsigned int);
17916 int vec_all_eq (vector bool int, vector signed int);
17917 int vec_all_eq (vector float, vector float);
17918
17919 int vec_all_ge (vector bool char, vector unsigned char);
17920 int vec_all_ge (vector unsigned char, vector bool char);
17921 int vec_all_ge (vector unsigned char, vector unsigned char);
17922 int vec_all_ge (vector bool char, vector signed char);
17923 int vec_all_ge (vector signed char, vector bool char);
17924 int vec_all_ge (vector signed char, vector signed char);
17925 int vec_all_ge (vector bool short, vector unsigned short);
17926 int vec_all_ge (vector unsigned short, vector bool short);
17927 int vec_all_ge (vector unsigned short, vector unsigned short);
17928 int vec_all_ge (vector signed short, vector signed short);
17929 int vec_all_ge (vector bool short, vector signed short);
17930 int vec_all_ge (vector signed short, vector bool short);
17931 int vec_all_ge (vector bool int, vector unsigned int);
17932 int vec_all_ge (vector unsigned int, vector bool int);
17933 int vec_all_ge (vector unsigned int, vector unsigned int);
17934 int vec_all_ge (vector bool int, vector signed int);
17935 int vec_all_ge (vector signed int, vector bool int);
17936 int vec_all_ge (vector signed int, vector signed int);
17937 int vec_all_ge (vector float, vector float);
17938
17939 int vec_all_gt (vector bool char, vector unsigned char);
17940 int vec_all_gt (vector unsigned char, vector bool char);
17941 int vec_all_gt (vector unsigned char, vector unsigned char);
17942 int vec_all_gt (vector bool char, vector signed char);
17943 int vec_all_gt (vector signed char, vector bool char);
17944 int vec_all_gt (vector signed char, vector signed char);
17945 int vec_all_gt (vector bool short, vector unsigned short);
17946 int vec_all_gt (vector unsigned short, vector bool short);
17947 int vec_all_gt (vector unsigned short, vector unsigned short);
17948 int vec_all_gt (vector bool short, vector signed short);
17949 int vec_all_gt (vector signed short, vector bool short);
17950 int vec_all_gt (vector signed short, vector signed short);
17951 int vec_all_gt (vector bool int, vector unsigned int);
17952 int vec_all_gt (vector unsigned int, vector bool int);
17953 int vec_all_gt (vector unsigned int, vector unsigned int);
17954 int vec_all_gt (vector bool int, vector signed int);
17955 int vec_all_gt (vector signed int, vector bool int);
17956 int vec_all_gt (vector signed int, vector signed int);
17957 int vec_all_gt (vector float, vector float);
17958
17959 int vec_all_in (vector float, vector float);
17960
17961 int vec_all_le (vector bool char, vector unsigned char);
17962 int vec_all_le (vector unsigned char, vector bool char);
17963 int vec_all_le (vector unsigned char, vector unsigned char);
17964 int vec_all_le (vector bool char, vector signed char);
17965 int vec_all_le (vector signed char, vector bool char);
17966 int vec_all_le (vector signed char, vector signed char);
17967 int vec_all_le (vector bool short, vector unsigned short);
17968 int vec_all_le (vector unsigned short, vector bool short);
17969 int vec_all_le (vector unsigned short, vector unsigned short);
17970 int vec_all_le (vector bool short, vector signed short);
17971 int vec_all_le (vector signed short, vector bool short);
17972 int vec_all_le (vector signed short, vector signed short);
17973 int vec_all_le (vector bool int, vector unsigned int);
17974 int vec_all_le (vector unsigned int, vector bool int);
17975 int vec_all_le (vector unsigned int, vector unsigned int);
17976 int vec_all_le (vector bool int, vector signed int);
17977 int vec_all_le (vector signed int, vector bool int);
17978 int vec_all_le (vector signed int, vector signed int);
17979 int vec_all_le (vector float, vector float);
17980
17981 int vec_all_lt (vector bool char, vector unsigned char);
17982 int vec_all_lt (vector unsigned char, vector bool char);
17983 int vec_all_lt (vector unsigned char, vector unsigned char);
17984 int vec_all_lt (vector bool char, vector signed char);
17985 int vec_all_lt (vector signed char, vector bool char);
17986 int vec_all_lt (vector signed char, vector signed char);
17987 int vec_all_lt (vector bool short, vector unsigned short);
17988 int vec_all_lt (vector unsigned short, vector bool short);
17989 int vec_all_lt (vector unsigned short, vector unsigned short);
17990 int vec_all_lt (vector bool short, vector signed short);
17991 int vec_all_lt (vector signed short, vector bool short);
17992 int vec_all_lt (vector signed short, vector signed short);
17993 int vec_all_lt (vector bool int, vector unsigned int);
17994 int vec_all_lt (vector unsigned int, vector bool int);
17995 int vec_all_lt (vector unsigned int, vector unsigned int);
17996 int vec_all_lt (vector bool int, vector signed int);
17997 int vec_all_lt (vector signed int, vector bool int);
17998 int vec_all_lt (vector signed int, vector signed int);
17999 int vec_all_lt (vector float, vector float);
18000
18001 int vec_all_nan (vector float);
18002
18003 int vec_all_ne (vector signed char, vector bool char);
18004 int vec_all_ne (vector signed char, vector signed char);
18005 int vec_all_ne (vector unsigned char, vector bool char);
18006 int vec_all_ne (vector unsigned char, vector unsigned char);
18007 int vec_all_ne (vector bool char, vector bool char);
18008 int vec_all_ne (vector bool char, vector unsigned char);
18009 int vec_all_ne (vector bool char, vector signed char);
18010 int vec_all_ne (vector signed short, vector bool short);
18011 int vec_all_ne (vector signed short, vector signed short);
18012 int vec_all_ne (vector unsigned short, vector bool short);
18013 int vec_all_ne (vector unsigned short, vector unsigned short);
18014 int vec_all_ne (vector bool short, vector bool short);
18015 int vec_all_ne (vector bool short, vector unsigned short);
18016 int vec_all_ne (vector bool short, vector signed short);
18017 int vec_all_ne (vector pixel, vector pixel);
18018 int vec_all_ne (vector signed int, vector bool int);
18019 int vec_all_ne (vector signed int, vector signed int);
18020 int vec_all_ne (vector unsigned int, vector bool int);
18021 int vec_all_ne (vector unsigned int, vector unsigned int);
18022 int vec_all_ne (vector bool int, vector bool int);
18023 int vec_all_ne (vector bool int, vector unsigned int);
18024 int vec_all_ne (vector bool int, vector signed int);
18025 int vec_all_ne (vector float, vector float);
18026
18027 int vec_all_nge (vector float, vector float);
18028
18029 int vec_all_ngt (vector float, vector float);
18030
18031 int vec_all_nle (vector float, vector float);
18032
18033 int vec_all_nlt (vector float, vector float);
18034
18035 int vec_all_numeric (vector float);
18036
18037 int vec_any_eq (vector signed char, vector bool char);
18038 int vec_any_eq (vector signed char, vector signed char);
18039 int vec_any_eq (vector unsigned char, vector bool char);
18040 int vec_any_eq (vector unsigned char, vector unsigned char);
18041 int vec_any_eq (vector bool char, vector bool char);
18042 int vec_any_eq (vector bool char, vector unsigned char);
18043 int vec_any_eq (vector bool char, vector signed char);
18044 int vec_any_eq (vector signed short, vector bool short);
18045 int vec_any_eq (vector signed short, vector signed short);
18046 int vec_any_eq (vector unsigned short, vector bool short);
18047 int vec_any_eq (vector unsigned short, vector unsigned short);
18048 int vec_any_eq (vector bool short, vector bool short);
18049 int vec_any_eq (vector bool short, vector unsigned short);
18050 int vec_any_eq (vector bool short, vector signed short);
18051 int vec_any_eq (vector pixel, vector pixel);
18052 int vec_any_eq (vector signed int, vector bool int);
18053 int vec_any_eq (vector signed int, vector signed int);
18054 int vec_any_eq (vector unsigned int, vector bool int);
18055 int vec_any_eq (vector unsigned int, vector unsigned int);
18056 int vec_any_eq (vector bool int, vector bool int);
18057 int vec_any_eq (vector bool int, vector unsigned int);
18058 int vec_any_eq (vector bool int, vector signed int);
18059 int vec_any_eq (vector float, vector float);
18060
18061 int vec_any_ge (vector signed char, vector bool char);
18062 int vec_any_ge (vector unsigned char, vector bool char);
18063 int vec_any_ge (vector unsigned char, vector unsigned char);
18064 int vec_any_ge (vector signed char, vector signed char);
18065 int vec_any_ge (vector bool char, vector unsigned char);
18066 int vec_any_ge (vector bool char, vector signed char);
18067 int vec_any_ge (vector unsigned short, vector bool short);
18068 int vec_any_ge (vector unsigned short, vector unsigned short);
18069 int vec_any_ge (vector signed short, vector signed short);
18070 int vec_any_ge (vector signed short, vector bool short);
18071 int vec_any_ge (vector bool short, vector unsigned short);
18072 int vec_any_ge (vector bool short, vector signed short);
18073 int vec_any_ge (vector signed int, vector bool int);
18074 int vec_any_ge (vector unsigned int, vector bool int);
18075 int vec_any_ge (vector unsigned int, vector unsigned int);
18076 int vec_any_ge (vector signed int, vector signed int);
18077 int vec_any_ge (vector bool int, vector unsigned int);
18078 int vec_any_ge (vector bool int, vector signed int);
18079 int vec_any_ge (vector float, vector float);
18080
18081 int vec_any_gt (vector bool char, vector unsigned char);
18082 int vec_any_gt (vector unsigned char, vector bool char);
18083 int vec_any_gt (vector unsigned char, vector unsigned char);
18084 int vec_any_gt (vector bool char, vector signed char);
18085 int vec_any_gt (vector signed char, vector bool char);
18086 int vec_any_gt (vector signed char, vector signed char);
18087 int vec_any_gt (vector bool short, vector unsigned short);
18088 int vec_any_gt (vector unsigned short, vector bool short);
18089 int vec_any_gt (vector unsigned short, vector unsigned short);
18090 int vec_any_gt (vector bool short, vector signed short);
18091 int vec_any_gt (vector signed short, vector bool short);
18092 int vec_any_gt (vector signed short, vector signed short);
18093 int vec_any_gt (vector bool int, vector unsigned int);
18094 int vec_any_gt (vector unsigned int, vector bool int);
18095 int vec_any_gt (vector unsigned int, vector unsigned int);
18096 int vec_any_gt (vector bool int, vector signed int);
18097 int vec_any_gt (vector signed int, vector bool int);
18098 int vec_any_gt (vector signed int, vector signed int);
18099 int vec_any_gt (vector float, vector float);
18100
18101 int vec_any_le (vector bool char, vector unsigned char);
18102 int vec_any_le (vector unsigned char, vector bool char);
18103 int vec_any_le (vector unsigned char, vector unsigned char);
18104 int vec_any_le (vector bool char, vector signed char);
18105 int vec_any_le (vector signed char, vector bool char);
18106 int vec_any_le (vector signed char, vector signed char);
18107 int vec_any_le (vector bool short, vector unsigned short);
18108 int vec_any_le (vector unsigned short, vector bool short);
18109 int vec_any_le (vector unsigned short, vector unsigned short);
18110 int vec_any_le (vector bool short, vector signed short);
18111 int vec_any_le (vector signed short, vector bool short);
18112 int vec_any_le (vector signed short, vector signed short);
18113 int vec_any_le (vector bool int, vector unsigned int);
18114 int vec_any_le (vector unsigned int, vector bool int);
18115 int vec_any_le (vector unsigned int, vector unsigned int);
18116 int vec_any_le (vector bool int, vector signed int);
18117 int vec_any_le (vector signed int, vector bool int);
18118 int vec_any_le (vector signed int, vector signed int);
18119 int vec_any_le (vector float, vector float);
18120
18121 int vec_any_lt (vector bool char, vector unsigned char);
18122 int vec_any_lt (vector unsigned char, vector bool char);
18123 int vec_any_lt (vector unsigned char, vector unsigned char);
18124 int vec_any_lt (vector bool char, vector signed char);
18125 int vec_any_lt (vector signed char, vector bool char);
18126 int vec_any_lt (vector signed char, vector signed char);
18127 int vec_any_lt (vector bool short, vector unsigned short);
18128 int vec_any_lt (vector unsigned short, vector bool short);
18129 int vec_any_lt (vector unsigned short, vector unsigned short);
18130 int vec_any_lt (vector bool short, vector signed short);
18131 int vec_any_lt (vector signed short, vector bool short);
18132 int vec_any_lt (vector signed short, vector signed short);
18133 int vec_any_lt (vector bool int, vector unsigned int);
18134 int vec_any_lt (vector unsigned int, vector bool int);
18135 int vec_any_lt (vector unsigned int, vector unsigned int);
18136 int vec_any_lt (vector bool int, vector signed int);
18137 int vec_any_lt (vector signed int, vector bool int);
18138 int vec_any_lt (vector signed int, vector signed int);
18139 int vec_any_lt (vector float, vector float);
18140
18141 int vec_any_nan (vector float);
18142
18143 int vec_any_ne (vector signed char, vector bool char);
18144 int vec_any_ne (vector signed char, vector signed char);
18145 int vec_any_ne (vector unsigned char, vector bool char);
18146 int vec_any_ne (vector unsigned char, vector unsigned char);
18147 int vec_any_ne (vector bool char, vector bool char);
18148 int vec_any_ne (vector bool char, vector unsigned char);
18149 int vec_any_ne (vector bool char, vector signed char);
18150 int vec_any_ne (vector signed short, vector bool short);
18151 int vec_any_ne (vector signed short, vector signed short);
18152 int vec_any_ne (vector unsigned short, vector bool short);
18153 int vec_any_ne (vector unsigned short, vector unsigned short);
18154 int vec_any_ne (vector bool short, vector bool short);
18155 int vec_any_ne (vector bool short, vector unsigned short);
18156 int vec_any_ne (vector bool short, vector signed short);
18157 int vec_any_ne (vector pixel, vector pixel);
18158 int vec_any_ne (vector signed int, vector bool int);
18159 int vec_any_ne (vector signed int, vector signed int);
18160 int vec_any_ne (vector unsigned int, vector bool int);
18161 int vec_any_ne (vector unsigned int, vector unsigned int);
18162 int vec_any_ne (vector bool int, vector bool int);
18163 int vec_any_ne (vector bool int, vector unsigned int);
18164 int vec_any_ne (vector bool int, vector signed int);
18165 int vec_any_ne (vector float, vector float);
18166
18167 int vec_any_nge (vector float, vector float);
18168
18169 int vec_any_ngt (vector float, vector float);
18170
18171 int vec_any_nle (vector float, vector float);
18172
18173 int vec_any_nlt (vector float, vector float);
18174
18175 int vec_any_numeric (vector float);
18176
18177 int vec_any_out (vector float, vector float);
18178 @end smallexample
18179
18180 If the vector/scalar (VSX) instruction set is available, the following
18181 additional functions are available:
18182
18183 @smallexample
18184 vector double vec_abs (vector double);
18185 vector double vec_add (vector double, vector double);
18186 vector double vec_and (vector double, vector double);
18187 vector double vec_and (vector double, vector bool long);
18188 vector double vec_and (vector bool long, vector double);
18189 vector long vec_and (vector long, vector long);
18190 vector long vec_and (vector long, vector bool long);
18191 vector long vec_and (vector bool long, vector long);
18192 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18193 vector unsigned long vec_and (vector unsigned long, vector bool long);
18194 vector unsigned long vec_and (vector bool long, vector unsigned long);
18195 vector double vec_andc (vector double, vector double);
18196 vector double vec_andc (vector double, vector bool long);
18197 vector double vec_andc (vector bool long, vector double);
18198 vector long vec_andc (vector long, vector long);
18199 vector long vec_andc (vector long, vector bool long);
18200 vector long vec_andc (vector bool long, vector long);
18201 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18202 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18203 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18204 vector double vec_ceil (vector double);
18205 vector bool long vec_cmpeq (vector double, vector double);
18206 vector bool long vec_cmpge (vector double, vector double);
18207 vector bool long vec_cmpgt (vector double, vector double);
18208 vector bool long vec_cmple (vector double, vector double);
18209 vector bool long vec_cmplt (vector double, vector double);
18210 vector double vec_cpsgn (vector double, vector double);
18211 vector float vec_div (vector float, vector float);
18212 vector double vec_div (vector double, vector double);
18213 vector long vec_div (vector long, vector long);
18214 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18215 vector double vec_floor (vector double);
18216 vector __int128 vec_ld (int, const vector __int128 *);
18217 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18218 vector __int128 vec_ld (int, const __int128 *);
18219 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18220 vector double vec_ld (int, const vector double *);
18221 vector double vec_ld (int, const double *);
18222 vector double vec_ldl (int, const vector double *);
18223 vector double vec_ldl (int, const double *);
18224 vector unsigned char vec_lvsl (int, const double *);
18225 vector unsigned char vec_lvsr (int, const double *);
18226 vector double vec_madd (vector double, vector double, vector double);
18227 vector double vec_max (vector double, vector double);
18228 vector signed long vec_mergeh (vector signed long, vector signed long);
18229 vector signed long vec_mergeh (vector signed long, vector bool long);
18230 vector signed long vec_mergeh (vector bool long, vector signed long);
18231 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18232 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18233 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18234 vector signed long vec_mergel (vector signed long, vector signed long);
18235 vector signed long vec_mergel (vector signed long, vector bool long);
18236 vector signed long vec_mergel (vector bool long, vector signed long);
18237 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18238 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18239 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18240 vector double vec_min (vector double, vector double);
18241 vector float vec_msub (vector float, vector float, vector float);
18242 vector double vec_msub (vector double, vector double, vector double);
18243 vector float vec_mul (vector float, vector float);
18244 vector double vec_mul (vector double, vector double);
18245 vector long vec_mul (vector long, vector long);
18246 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18247 vector float vec_nearbyint (vector float);
18248 vector double vec_nearbyint (vector double);
18249 vector float vec_nmadd (vector float, vector float, vector float);
18250 vector double vec_nmadd (vector double, vector double, vector double);
18251 vector double vec_nmsub (vector double, vector double, vector double);
18252 vector double vec_nor (vector double, vector double);
18253 vector long vec_nor (vector long, vector long);
18254 vector long vec_nor (vector long, vector bool long);
18255 vector long vec_nor (vector bool long, vector long);
18256 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18257 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18258 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18259 vector double vec_or (vector double, vector double);
18260 vector double vec_or (vector double, vector bool long);
18261 vector double vec_or (vector bool long, vector double);
18262 vector long vec_or (vector long, vector long);
18263 vector long vec_or (vector long, vector bool long);
18264 vector long vec_or (vector bool long, vector long);
18265 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18266 vector unsigned long vec_or (vector unsigned long, vector bool long);
18267 vector unsigned long vec_or (vector bool long, vector unsigned long);
18268 vector double vec_perm (vector double, vector double, vector unsigned char);
18269 vector long vec_perm (vector long, vector long, vector unsigned char);
18270 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18271 vector unsigned char);
18272 vector bool char vec_permxor (vector bool char, vector bool char,
18273 vector bool char);
18274 vector unsigned char vec_permxor (vector signed char, vector signed char,
18275 vector signed char);
18276 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
18277 vector unsigned char);
18278 vector double vec_rint (vector double);
18279 vector double vec_recip (vector double, vector double);
18280 vector double vec_rsqrt (vector double);
18281 vector double vec_rsqrte (vector double);
18282 vector double vec_sel (vector double, vector double, vector bool long);
18283 vector double vec_sel (vector double, vector double, vector unsigned long);
18284 vector long vec_sel (vector long, vector long, vector long);
18285 vector long vec_sel (vector long, vector long, vector unsigned long);
18286 vector long vec_sel (vector long, vector long, vector bool long);
18287 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18288 vector long);
18289 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18290 vector unsigned long);
18291 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18292 vector bool long);
18293 vector double vec_splats (double);
18294 vector signed long vec_splats (signed long);
18295 vector unsigned long vec_splats (unsigned long);
18296 vector float vec_sqrt (vector float);
18297 vector double vec_sqrt (vector double);
18298 void vec_st (vector double, int, vector double *);
18299 void vec_st (vector double, int, double *);
18300 vector double vec_sub (vector double, vector double);
18301 vector double vec_trunc (vector double);
18302 vector double vec_xl (int, vector double *);
18303 vector double vec_xl (int, double *);
18304 vector long long vec_xl (int, vector long long *);
18305 vector long long vec_xl (int, long long *);
18306 vector unsigned long long vec_xl (int, vector unsigned long long *);
18307 vector unsigned long long vec_xl (int, unsigned long long *);
18308 vector float vec_xl (int, vector float *);
18309 vector float vec_xl (int, float *);
18310 vector int vec_xl (int, vector int *);
18311 vector int vec_xl (int, int *);
18312 vector unsigned int vec_xl (int, vector unsigned int *);
18313 vector unsigned int vec_xl (int, unsigned int *);
18314 vector double vec_xor (vector double, vector double);
18315 vector double vec_xor (vector double, vector bool long);
18316 vector double vec_xor (vector bool long, vector double);
18317 vector long vec_xor (vector long, vector long);
18318 vector long vec_xor (vector long, vector bool long);
18319 vector long vec_xor (vector bool long, vector long);
18320 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18321 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18322 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18323 void vec_xst (vector double, int, vector double *);
18324 void vec_xst (vector double, int, double *);
18325 void vec_xst (vector long long, int, vector long long *);
18326 void vec_xst (vector long long, int, long long *);
18327 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18328 void vec_xst (vector unsigned long long, int, unsigned long long *);
18329 void vec_xst (vector float, int, vector float *);
18330 void vec_xst (vector float, int, float *);
18331 void vec_xst (vector int, int, vector int *);
18332 void vec_xst (vector int, int, int *);
18333 void vec_xst (vector unsigned int, int, vector unsigned int *);
18334 void vec_xst (vector unsigned int, int, unsigned int *);
18335 int vec_all_eq (vector double, vector double);
18336 int vec_all_ge (vector double, vector double);
18337 int vec_all_gt (vector double, vector double);
18338 int vec_all_le (vector double, vector double);
18339 int vec_all_lt (vector double, vector double);
18340 int vec_all_nan (vector double);
18341 int vec_all_ne (vector double, vector double);
18342 int vec_all_nge (vector double, vector double);
18343 int vec_all_ngt (vector double, vector double);
18344 int vec_all_nle (vector double, vector double);
18345 int vec_all_nlt (vector double, vector double);
18346 int vec_all_numeric (vector double);
18347 int vec_any_eq (vector double, vector double);
18348 int vec_any_ge (vector double, vector double);
18349 int vec_any_gt (vector double, vector double);
18350 int vec_any_le (vector double, vector double);
18351 int vec_any_lt (vector double, vector double);
18352 int vec_any_nan (vector double);
18353 int vec_any_ne (vector double, vector double);
18354 int vec_any_nge (vector double, vector double);
18355 int vec_any_ngt (vector double, vector double);
18356 int vec_any_nle (vector double, vector double);
18357 int vec_any_nlt (vector double, vector double);
18358 int vec_any_numeric (vector double);
18359
18360 vector double vec_vsx_ld (int, const vector double *);
18361 vector double vec_vsx_ld (int, const double *);
18362 vector float vec_vsx_ld (int, const vector float *);
18363 vector float vec_vsx_ld (int, const float *);
18364 vector bool int vec_vsx_ld (int, const vector bool int *);
18365 vector signed int vec_vsx_ld (int, const vector signed int *);
18366 vector signed int vec_vsx_ld (int, const int *);
18367 vector signed int vec_vsx_ld (int, const long *);
18368 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18369 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18370 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18371 vector bool short vec_vsx_ld (int, const vector bool short *);
18372 vector pixel vec_vsx_ld (int, const vector pixel *);
18373 vector signed short vec_vsx_ld (int, const vector signed short *);
18374 vector signed short vec_vsx_ld (int, const short *);
18375 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18376 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18377 vector bool char vec_vsx_ld (int, const vector bool char *);
18378 vector signed char vec_vsx_ld (int, const vector signed char *);
18379 vector signed char vec_vsx_ld (int, const signed char *);
18380 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18381 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18382
18383 void vec_vsx_st (vector double, int, vector double *);
18384 void vec_vsx_st (vector double, int, double *);
18385 void vec_vsx_st (vector float, int, vector float *);
18386 void vec_vsx_st (vector float, int, float *);
18387 void vec_vsx_st (vector signed int, int, vector signed int *);
18388 void vec_vsx_st (vector signed int, int, int *);
18389 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18390 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18391 void vec_vsx_st (vector bool int, int, vector bool int *);
18392 void vec_vsx_st (vector bool int, int, unsigned int *);
18393 void vec_vsx_st (vector bool int, int, int *);
18394 void vec_vsx_st (vector signed short, int, vector signed short *);
18395 void vec_vsx_st (vector signed short, int, short *);
18396 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18397 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18398 void vec_vsx_st (vector bool short, int, vector bool short *);
18399 void vec_vsx_st (vector bool short, int, unsigned short *);
18400 void vec_vsx_st (vector pixel, int, vector pixel *);
18401 void vec_vsx_st (vector pixel, int, unsigned short *);
18402 void vec_vsx_st (vector pixel, int, short *);
18403 void vec_vsx_st (vector bool short, int, short *);
18404 void vec_vsx_st (vector signed char, int, vector signed char *);
18405 void vec_vsx_st (vector signed char, int, signed char *);
18406 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18407 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18408 void vec_vsx_st (vector bool char, int, vector bool char *);
18409 void vec_vsx_st (vector bool char, int, unsigned char *);
18410 void vec_vsx_st (vector bool char, int, signed char *);
18411
18412 vector double vec_xxpermdi (vector double, vector double, const int);
18413 vector float vec_xxpermdi (vector float, vector float, const int);
18414 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18415 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18416 vector unsigned long long, const int);
18417 vector int vec_xxpermdi (vector int, vector int, const int);
18418 vector unsigned int vec_xxpermdi (vector unsigned int,
18419 vector unsigned int, const int);
18420 vector short vec_xxpermdi (vector short, vector short, const int);
18421 vector unsigned short vec_xxpermdi (vector unsigned short,
18422 vector unsigned short, const int);
18423 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18424 const int);
18425 vector unsigned char vec_xxpermdi (vector unsigned char,
18426 vector unsigned char, const int);
18427
18428 vector double vec_xxsldi (vector double, vector double, int);
18429 vector float vec_xxsldi (vector float, vector float, int);
18430 vector long long vec_xxsldi (vector long long, vector long long, int);
18431 vector unsigned long long vec_xxsldi (vector unsigned long long,
18432 vector unsigned long long, int);
18433 vector int vec_xxsldi (vector int, vector int, int);
18434 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18435 vector short vec_xxsldi (vector short, vector short, int);
18436 vector unsigned short vec_xxsldi (vector unsigned short,
18437 vector unsigned short, int);
18438 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18439 vector unsigned char vec_xxsldi (vector unsigned char,
18440 vector unsigned char, int);
18441 @end smallexample
18442
18443 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18444 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18445 if the VSX instruction set is available. The @samp{vec_vsx_ld} and
18446 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18447 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18448
18449 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18450 instruction set are available, the following additional functions are
18451 available for both 32-bit and 64-bit targets. For 64-bit targets, you
18452 can use @var{vector long} instead of @var{vector long long},
18453 @var{vector bool long} instead of @var{vector bool long long}, and
18454 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18455
18456 @smallexample
18457 vector long long vec_abs (vector long long);
18458
18459 vector long long vec_add (vector long long, vector long long);
18460 vector unsigned long long vec_add (vector unsigned long long,
18461 vector unsigned long long);
18462
18463 int vec_all_eq (vector long long, vector long long);
18464 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18465 int vec_all_ge (vector long long, vector long long);
18466 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18467 int vec_all_gt (vector long long, vector long long);
18468 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18469 int vec_all_le (vector long long, vector long long);
18470 int vec_all_le (vector unsigned long long, vector unsigned long long);
18471 int vec_all_lt (vector long long, vector long long);
18472 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18473 int vec_all_ne (vector long long, vector long long);
18474 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18475
18476 int vec_any_eq (vector long long, vector long long);
18477 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18478 int vec_any_ge (vector long long, vector long long);
18479 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18480 int vec_any_gt (vector long long, vector long long);
18481 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18482 int vec_any_le (vector long long, vector long long);
18483 int vec_any_le (vector unsigned long long, vector unsigned long long);
18484 int vec_any_lt (vector long long, vector long long);
18485 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18486 int vec_any_ne (vector long long, vector long long);
18487 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18488
18489 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18490
18491 vector long long vec_eqv (vector long long, vector long long);
18492 vector long long vec_eqv (vector bool long long, vector long long);
18493 vector long long vec_eqv (vector long long, vector bool long long);
18494 vector unsigned long long vec_eqv (vector unsigned long long,
18495 vector unsigned long long);
18496 vector unsigned long long vec_eqv (vector bool long long,
18497 vector unsigned long long);
18498 vector unsigned long long vec_eqv (vector unsigned long long,
18499 vector bool long long);
18500 vector int vec_eqv (vector int, vector int);
18501 vector int vec_eqv (vector bool int, vector int);
18502 vector int vec_eqv (vector int, vector bool int);
18503 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18504 vector unsigned int vec_eqv (vector bool unsigned int,
18505 vector unsigned int);
18506 vector unsigned int vec_eqv (vector unsigned int,
18507 vector bool unsigned int);
18508 vector short vec_eqv (vector short, vector short);
18509 vector short vec_eqv (vector bool short, vector short);
18510 vector short vec_eqv (vector short, vector bool short);
18511 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18512 vector unsigned short vec_eqv (vector bool unsigned short,
18513 vector unsigned short);
18514 vector unsigned short vec_eqv (vector unsigned short,
18515 vector bool unsigned short);
18516 vector signed char vec_eqv (vector signed char, vector signed char);
18517 vector signed char vec_eqv (vector bool signed char, vector signed char);
18518 vector signed char vec_eqv (vector signed char, vector bool signed char);
18519 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18520 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18521 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18522
18523 vector long long vec_max (vector long long, vector long long);
18524 vector unsigned long long vec_max (vector unsigned long long,
18525 vector unsigned long long);
18526
18527 vector signed int vec_mergee (vector signed int, vector signed int);
18528 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18529 vector bool int vec_mergee (vector bool int, vector bool int);
18530
18531 vector signed int vec_mergeo (vector signed int, vector signed int);
18532 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18533 vector bool int vec_mergeo (vector bool int, vector bool int);
18534
18535 vector long long vec_min (vector long long, vector long long);
18536 vector unsigned long long vec_min (vector unsigned long long,
18537 vector unsigned long long);
18538
18539 vector signed long long vec_nabs (vector signed long long);
18540
18541 vector long long vec_nand (vector long long, vector long long);
18542 vector long long vec_nand (vector bool long long, vector long long);
18543 vector long long vec_nand (vector long long, vector bool long long);
18544 vector unsigned long long vec_nand (vector unsigned long long,
18545 vector unsigned long long);
18546 vector unsigned long long vec_nand (vector bool long long,
18547 vector unsigned long long);
18548 vector unsigned long long vec_nand (vector unsigned long long,
18549 vector bool long long);
18550 vector int vec_nand (vector int, vector int);
18551 vector int vec_nand (vector bool int, vector int);
18552 vector int vec_nand (vector int, vector bool int);
18553 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18554 vector unsigned int vec_nand (vector bool unsigned int,
18555 vector unsigned int);
18556 vector unsigned int vec_nand (vector unsigned int,
18557 vector bool unsigned int);
18558 vector short vec_nand (vector short, vector short);
18559 vector short vec_nand (vector bool short, vector short);
18560 vector short vec_nand (vector short, vector bool short);
18561 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18562 vector unsigned short vec_nand (vector bool unsigned short,
18563 vector unsigned short);
18564 vector unsigned short vec_nand (vector unsigned short,
18565 vector bool unsigned short);
18566 vector signed char vec_nand (vector signed char, vector signed char);
18567 vector signed char vec_nand (vector bool signed char, vector signed char);
18568 vector signed char vec_nand (vector signed char, vector bool signed char);
18569 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18570 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18571 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18572
18573 vector long long vec_orc (vector long long, vector long long);
18574 vector long long vec_orc (vector bool long long, vector long long);
18575 vector long long vec_orc (vector long long, vector bool long long);
18576 vector unsigned long long vec_orc (vector unsigned long long,
18577 vector unsigned long long);
18578 vector unsigned long long vec_orc (vector bool long long,
18579 vector unsigned long long);
18580 vector unsigned long long vec_orc (vector unsigned long long,
18581 vector bool long long);
18582 vector int vec_orc (vector int, vector int);
18583 vector int vec_orc (vector bool int, vector int);
18584 vector int vec_orc (vector int, vector bool int);
18585 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18586 vector unsigned int vec_orc (vector bool unsigned int,
18587 vector unsigned int);
18588 vector unsigned int vec_orc (vector unsigned int,
18589 vector bool unsigned int);
18590 vector short vec_orc (vector short, vector short);
18591 vector short vec_orc (vector bool short, vector short);
18592 vector short vec_orc (vector short, vector bool short);
18593 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18594 vector unsigned short vec_orc (vector bool unsigned short,
18595 vector unsigned short);
18596 vector unsigned short vec_orc (vector unsigned short,
18597 vector bool unsigned short);
18598 vector signed char vec_orc (vector signed char, vector signed char);
18599 vector signed char vec_orc (vector bool signed char, vector signed char);
18600 vector signed char vec_orc (vector signed char, vector bool signed char);
18601 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18602 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18603 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18604
18605 vector int vec_pack (vector long long, vector long long);
18606 vector unsigned int vec_pack (vector unsigned long long,
18607 vector unsigned long long);
18608 vector bool int vec_pack (vector bool long long, vector bool long long);
18609 vector float vec_pack (vector double, vector double);
18610
18611 vector int vec_packs (vector long long, vector long long);
18612 vector unsigned int vec_packs (vector unsigned long long,
18613 vector unsigned long long);
18614
18615 vector unsigned char vec_packsu (vector signed short, vector signed short )
18616 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short )
18617 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18618 vector unsigned short int vec_packsu (vector unsigned int,
18619 vector unsigned int);
18620 vector unsigned int vec_packsu (vector long long, vector long long);
18621 vector unsigned int vec_packsu (vector unsigned long long,
18622 vector unsigned long long);
18623 vector unsigned int vec_packsu (vector signed long long,
18624 vector signed long long);
18625
18626 vector unsigned char vec_popcnt (vector signed char);
18627 vector unsigned char vec_popcnt (vector unsigned char);
18628 vector unsigned short vec_popcnt (vector signed short);
18629 vector unsigned short vec_popcnt (vector unsigned short);
18630 vector unsigned int vec_popcnt (vector signed int);
18631 vector unsigned int vec_popcnt (vector unsigned int);
18632 vector unsigned long long vec_popcnt (vector signed long long);
18633 vector unsigned long long vec_popcnt (vector unsigned long long);
18634
18635 vector long long vec_rl (vector long long,
18636 vector unsigned long long);
18637 vector long long vec_rl (vector unsigned long long,
18638 vector unsigned long long);
18639
18640 vector long long vec_sl (vector long long, vector unsigned long long);
18641 vector long long vec_sl (vector unsigned long long,
18642 vector unsigned long long);
18643
18644 vector long long vec_sr (vector long long, vector unsigned long long);
18645 vector unsigned long long char vec_sr (vector unsigned long long,
18646 vector unsigned long long);
18647
18648 vector long long vec_sra (vector long long, vector unsigned long long);
18649 vector unsigned long long vec_sra (vector unsigned long long,
18650 vector unsigned long long);
18651
18652 vector long long vec_sub (vector long long, vector long long);
18653 vector unsigned long long vec_sub (vector unsigned long long,
18654 vector unsigned long long);
18655
18656 vector long long vec_unpackh (vector int);
18657 vector unsigned long long vec_unpackh (vector unsigned int);
18658
18659 vector long long vec_unpackl (vector int);
18660 vector unsigned long long vec_unpackl (vector unsigned int);
18661
18662 vector long long vec_vaddudm (vector long long, vector long long);
18663 vector long long vec_vaddudm (vector bool long long, vector long long);
18664 vector long long vec_vaddudm (vector long long, vector bool long long);
18665 vector unsigned long long vec_vaddudm (vector unsigned long long,
18666 vector unsigned long long);
18667 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18668 vector unsigned long long);
18669 vector unsigned long long vec_vaddudm (vector unsigned long long,
18670 vector bool unsigned long long);
18671
18672 vector long long vec_vbpermq (vector signed char, vector signed char);
18673 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18674
18675 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18676 vector unsigned char vec_bperm (vector unsigned long long,
18677 vector unsigned char);
18678 vector unsigned long long vec_bperm (vector unsigned __int128,
18679 vector unsigned char);
18680
18681 vector long long vec_cntlz (vector long long);
18682 vector unsigned long long vec_cntlz (vector unsigned long long);
18683 vector int vec_cntlz (vector int);
18684 vector unsigned int vec_cntlz (vector int);
18685 vector short vec_cntlz (vector short);
18686 vector unsigned short vec_cntlz (vector unsigned short);
18687 vector signed char vec_cntlz (vector signed char);
18688 vector unsigned char vec_cntlz (vector unsigned char);
18689
18690 vector long long vec_vclz (vector long long);
18691 vector unsigned long long vec_vclz (vector unsigned long long);
18692 vector int vec_vclz (vector int);
18693 vector unsigned int vec_vclz (vector int);
18694 vector short vec_vclz (vector short);
18695 vector unsigned short vec_vclz (vector unsigned short);
18696 vector signed char vec_vclz (vector signed char);
18697 vector unsigned char vec_vclz (vector unsigned char);
18698
18699 vector signed char vec_vclzb (vector signed char);
18700 vector unsigned char vec_vclzb (vector unsigned char);
18701
18702 vector long long vec_vclzd (vector long long);
18703 vector unsigned long long vec_vclzd (vector unsigned long long);
18704
18705 vector short vec_vclzh (vector short);
18706 vector unsigned short vec_vclzh (vector unsigned short);
18707
18708 vector int vec_vclzw (vector int);
18709 vector unsigned int vec_vclzw (vector int);
18710
18711 vector signed char vec_vgbbd (vector signed char);
18712 vector unsigned char vec_vgbbd (vector unsigned char);
18713
18714 vector long long vec_vmaxsd (vector long long, vector long long);
18715
18716 vector unsigned long long vec_vmaxud (vector unsigned long long,
18717 unsigned vector long long);
18718
18719 vector long long vec_vminsd (vector long long, vector long long);
18720
18721 vector unsigned long long vec_vminud (vector long long,
18722 vector long long);
18723
18724 vector int vec_vpksdss (vector long long, vector long long);
18725 vector unsigned int vec_vpksdss (vector long long, vector long long);
18726
18727 vector unsigned int vec_vpkudus (vector unsigned long long,
18728 vector unsigned long long);
18729
18730 vector int vec_vpkudum (vector long long, vector long long);
18731 vector unsigned int vec_vpkudum (vector unsigned long long,
18732 vector unsigned long long);
18733 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18734
18735 vector long long vec_vpopcnt (vector long long);
18736 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18737 vector int vec_vpopcnt (vector int);
18738 vector unsigned int vec_vpopcnt (vector int);
18739 vector short vec_vpopcnt (vector short);
18740 vector unsigned short vec_vpopcnt (vector unsigned short);
18741 vector signed char vec_vpopcnt (vector signed char);
18742 vector unsigned char vec_vpopcnt (vector unsigned char);
18743
18744 vector signed char vec_vpopcntb (vector signed char);
18745 vector unsigned char vec_vpopcntb (vector unsigned char);
18746
18747 vector long long vec_vpopcntd (vector long long);
18748 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18749
18750 vector short vec_vpopcnth (vector short);
18751 vector unsigned short vec_vpopcnth (vector unsigned short);
18752
18753 vector int vec_vpopcntw (vector int);
18754 vector unsigned int vec_vpopcntw (vector int);
18755
18756 vector long long vec_vrld (vector long long, vector unsigned long long);
18757 vector unsigned long long vec_vrld (vector unsigned long long,
18758 vector unsigned long long);
18759
18760 vector long long vec_vsld (vector long long, vector unsigned long long);
18761 vector long long vec_vsld (vector unsigned long long,
18762 vector unsigned long long);
18763
18764 vector long long vec_vsrad (vector long long, vector unsigned long long);
18765 vector unsigned long long vec_vsrad (vector unsigned long long,
18766 vector unsigned long long);
18767
18768 vector long long vec_vsrd (vector long long, vector unsigned long long);
18769 vector unsigned long long char vec_vsrd (vector unsigned long long,
18770 vector unsigned long long);
18771
18772 vector long long vec_vsubudm (vector long long, vector long long);
18773 vector long long vec_vsubudm (vector bool long long, vector long long);
18774 vector long long vec_vsubudm (vector long long, vector bool long long);
18775 vector unsigned long long vec_vsubudm (vector unsigned long long,
18776 vector unsigned long long);
18777 vector unsigned long long vec_vsubudm (vector bool long long,
18778 vector unsigned long long);
18779 vector unsigned long long vec_vsubudm (vector unsigned long long,
18780 vector bool long long);
18781
18782 vector long long vec_vupkhsw (vector int);
18783 vector unsigned long long vec_vupkhsw (vector unsigned int);
18784
18785 vector long long vec_vupklsw (vector int);
18786 vector unsigned long long vec_vupklsw (vector int);
18787 @end smallexample
18788
18789 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18790 instruction set are available, the following additional functions are
18791 available for 64-bit targets. New vector types
18792 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18793 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18794 builtins.
18795
18796 The normal vector extract, and set operations work on
18797 @var{vector __int128_t} and @var{vector __uint128_t} types,
18798 but the index value must be 0.
18799
18800 @smallexample
18801 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18802 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18803
18804 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18805 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18806
18807 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18808 vector __int128_t);
18809 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18810 vector __uint128_t);
18811
18812 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18813 vector __int128_t);
18814 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18815 vector __uint128_t);
18816
18817 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18818 vector __int128_t);
18819 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18820 vector __uint128_t);
18821
18822 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18823 vector __int128_t);
18824 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18825 vector __uint128_t);
18826
18827 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18828 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18829
18830 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18831 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18832
18833 vector __int128_t __builtin_bcdadd (vector __int128_t, vector __int128_t);
18834 int __builtin_bcdadd_lt (vector __int128_t, vector __int128_t);
18835 int __builtin_bcdadd_eq (vector __int128_t, vector __int128_t);
18836 int __builtin_bcdadd_gt (vector __int128_t, vector __int128_t);
18837 int __builtin_bcdadd_ov (vector __int128_t, vector __int128_t);
18838 vector __int128_t bcdsub (vector __int128_t, vector __int128_t);
18839 int __builtin_bcdsub_lt (vector __int128_t, vector __int128_t);
18840 int __builtin_bcdsub_eq (vector __int128_t, vector __int128_t);
18841 int __builtin_bcdsub_gt (vector __int128_t, vector __int128_t);
18842 int __builtin_bcdsub_ov (vector __int128_t, vector __int128_t);
18843 @end smallexample
18844
18845 The following additional built-in functions are also available for the
18846 PowerPC family of processors, starting with ISA 3.0
18847 (@option{-mcpu=power9}) or later:
18848 @smallexample
18849 unsigned int scalar_extract_exp (double source);
18850 unsigned long long int scalar_extract_exp (__ieee128 source);
18851
18852 unsigned long long int scalar_extract_sig (double source);
18853 unsigned __int128 scalar_extract_sig (__ieee128 source);
18854
18855 double
18856 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
18857 double
18858 scalar_insert_exp (double significand, unsigned long long int exponent);
18859
18860 ieee_128
18861 scalar_insert_exp (unsigned __int128 significand, unsigned long long int exponent);
18862 ieee_128
18863 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18864
18865 int scalar_cmp_exp_gt (double arg1, double arg2);
18866 int scalar_cmp_exp_lt (double arg1, double arg2);
18867 int scalar_cmp_exp_eq (double arg1, double arg2);
18868 int scalar_cmp_exp_unordered (double arg1, double arg2);
18869
18870 bool scalar_test_data_class (float source, const int condition);
18871 bool scalar_test_data_class (double source, const int condition);
18872 bool scalar_test_data_class (__ieee128 source, const int condition);
18873
18874 bool scalar_test_neg (float source);
18875 bool scalar_test_neg (double source);
18876 bool scalar_test_neg (__ieee128 source);
18877 @end smallexample
18878
18879 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18880 functions require a 64-bit environment supporting ISA 3.0 or later.
18881 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18882 functions return the significand and the biased exponent value
18883 respectively of their @code{source} arguments.
18884 When supplied with a 64-bit @code{source} argument, the
18885 result returned by @code{scalar_extract_sig} has
18886 the @code{0x0010000000000000} bit set if the
18887 function's @code{source} argument is in normalized form.
18888 Otherwise, this bit is set to 0.
18889 When supplied with a 128-bit @code{source} argument, the
18890 @code{0x00010000000000000000000000000000} bit of the result is
18891 treated similarly.
18892 Note that the sign of the significand is not represented in the result
18893 returned from the @code{scalar_extract_sig} function. Use the
18894 @code{scalar_test_neg} function to test the sign of its @code{double}
18895 argument.
18896
18897 The @code{scalar_insert_exp}
18898 functions require a 64-bit environment supporting ISA 3.0 or later.
18899 When supplied with a 64-bit first argument, the
18900 @code{scalar_insert_exp} built-in function returns a double-precision
18901 floating point value that is constructed by assembling the values of its
18902 @code{significand} and @code{exponent} arguments. The sign of the
18903 result is copied from the most significant bit of the
18904 @code{significand} argument. The significand and exponent components
18905 of the result are composed of the least significant 11 bits of the
18906 @code{exponent} argument and the least significant 52 bits of the
18907 @code{significand} argument respectively.
18908
18909 When supplied with a 128-bit first argument, the
18910 @code{scalar_insert_exp} built-in function returns a quad-precision
18911 ieee floating point value. The sign bit of the result is copied from
18912 the most significant bit of the @code{significand} argument.
18913 The significand and exponent components of the result are composed of
18914 the least significant 15 bits of the @code{exponent} argument and the
18915 least significant 112 bits of the @code{significand} argument respectively.
18916
18917 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18918 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18919 functions return a non-zero value if @code{arg1} is greater than, less
18920 than, equal to, or not comparable to @code{arg2} respectively. The
18921 arguments are not comparable if one or the other equals NaN (not a
18922 number).
18923
18924 The @code{scalar_test_data_class} built-in function returns 1
18925 if any of the condition tests enabled by the value of the
18926 @code{condition} variable are true, and 0 otherwise. The
18927 @code{condition} argument must be a compile-time constant integer with
18928 value not exceeding 127. The
18929 @code{condition} argument is encoded as a bitmask with each bit
18930 enabling the testing of a different condition, as characterized by the
18931 following:
18932 @smallexample
18933 0x40 Test for NaN
18934 0x20 Test for +Infinity
18935 0x10 Test for -Infinity
18936 0x08 Test for +Zero
18937 0x04 Test for -Zero
18938 0x02 Test for +Denormal
18939 0x01 Test for -Denormal
18940 @end smallexample
18941
18942 The @code{scalar_test_neg} built-in function returns 1 if its
18943 @code{source} argument holds a negative value, 0 otherwise.
18944
18945 The following built-in functions are also available for the PowerPC family
18946 of processors, starting with ISA 3.0 or later
18947 (@option{-mcpu=power9}). These string functions are described
18948 separately in order to group the descriptions closer to the function
18949 prototypes:
18950 @smallexample
18951 int vec_all_nez (vector signed char, vector signed char);
18952 int vec_all_nez (vector unsigned char, vector unsigned char);
18953 int vec_all_nez (vector signed short, vector signed short);
18954 int vec_all_nez (vector unsigned short, vector unsigned short);
18955 int vec_all_nez (vector signed int, vector signed int);
18956 int vec_all_nez (vector unsigned int, vector unsigned int);
18957
18958 int vec_any_eqz (vector signed char, vector signed char);
18959 int vec_any_eqz (vector unsigned char, vector unsigned char);
18960 int vec_any_eqz (vector signed short, vector signed short);
18961 int vec_any_eqz (vector unsigned short, vector unsigned short);
18962 int vec_any_eqz (vector signed int, vector signed int);
18963 int vec_any_eqz (vector unsigned int, vector unsigned int);
18964
18965 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
18966 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
18967 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
18968 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
18969 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
18970 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
18971
18972 vector signed char vec_cnttz (vector signed char);
18973 vector unsigned char vec_cnttz (vector unsigned char);
18974 vector signed short vec_cnttz (vector signed short);
18975 vector unsigned short vec_cnttz (vector unsigned short);
18976 vector signed int vec_cnttz (vector signed int);
18977 vector unsigned int vec_cnttz (vector unsigned int);
18978 vector signed long long vec_cnttz (vector signed long long);
18979 vector unsigned long long vec_cnttz (vector unsigned long long);
18980
18981 signed int vec_cntlz_lsbb (vector signed char);
18982 signed int vec_cntlz_lsbb (vector unsigned char);
18983
18984 signed int vec_cnttz_lsbb (vector signed char);
18985 signed int vec_cnttz_lsbb (vector unsigned char);
18986
18987 unsigned int vec_first_match_index (vector signed char, vector signed char);
18988 unsigned int vec_first_match_index (vector unsigned char,
18989 vector unsigned char);
18990 unsigned int vec_first_match_index (vector signed int, vector signed int);
18991 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
18992 unsigned int vec_first_match_index (vector signed short, vector signed short);
18993 unsigned int vec_first_match_index (vector unsigned short,
18994 vector unsigned short);
18995 unsigned int vec_first_match_or_eos_index (vector signed char,
18996 vector signed char);
18997 unsigned int vec_first_match_or_eos_index (vector unsigned char,
18998 vector unsigned char);
18999 unsigned int vec_first_match_or_eos_index (vector signed int,
19000 vector signed int);
19001 unsigned int vec_first_match_or_eos_index (vector unsigned int,
19002 vector unsigned int);
19003 unsigned int vec_first_match_or_eos_index (vector signed short,
19004 vector signed short);
19005 unsigned int vec_first_match_or_eos_index (vector unsigned short,
19006 vector unsigned short);
19007 unsigned int vec_first_mismatch_index (vector signed char,
19008 vector signed char);
19009 unsigned int vec_first_mismatch_index (vector unsigned char,
19010 vector unsigned char);
19011 unsigned int vec_first_mismatch_index (vector signed int,
19012 vector signed int);
19013 unsigned int vec_first_mismatch_index (vector unsigned int,
19014 vector unsigned int);
19015 unsigned int vec_first_mismatch_index (vector signed short,
19016 vector signed short);
19017 unsigned int vec_first_mismatch_index (vector unsigned short,
19018 vector unsigned short);
19019 unsigned int vec_first_mismatch_or_eos_index (vector signed char,
19020 vector signed char);
19021 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
19022 vector unsigned char);
19023 unsigned int vec_first_mismatch_or_eos_index (vector signed int,
19024 vector signed int);
19025 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int,
19026 vector unsigned int);
19027 unsigned int vec_first_mismatch_or_eos_index (vector signed short,
19028 vector signed short);
19029 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
19030 vector unsigned short);
19031
19032 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
19033
19034 vector signed char vec_xl_be (signed long long, signed char *);
19035 vector unsigned char vec_xl_be (signed long long, unsigned char *);
19036 vector signed int vec_xl_be (signed long long, signed int *);
19037 vector unsigned int vec_xl_be (signed long long, unsigned int *);
19038 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
19039 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
19040 vector signed long long vec_xl_be (signed long long, signed long long *);
19041 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
19042 vector signed short vec_xl_be (signed long long, signed short *);
19043 vector unsigned short vec_xl_be (signed long long, unsigned short *);
19044 vector double vec_xl_be (signed long long, double *);
19045 vector float vec_xl_be (signed long long, float *);
19046
19047 vector signed char vec_xl_len (signed char *addr, size_t len);
19048 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
19049 vector signed int vec_xl_len (signed int *addr, size_t len);
19050 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
19051 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
19052 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
19053 vector signed long long vec_xl_len (signed long long *addr, size_t len);
19054 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
19055 vector signed short vec_xl_len (signed short *addr, size_t len);
19056 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
19057 vector double vec_xl_len (double *addr, size_t len);
19058 vector float vec_xl_len (float *addr, size_t len);
19059
19060 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
19061
19062 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
19063 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
19064 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
19065 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
19066 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
19067 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
19068 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
19069 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
19070 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
19071 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
19072 void vec_xst_len (vector double data, double *addr, size_t len);
19073 void vec_xst_len (vector float data, float *addr, size_t len);
19074
19075 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
19076
19077 signed char vec_xlx (unsigned int index, vector signed char data);
19078 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
19079 signed short vec_xlx (unsigned int index, vector signed short data);
19080 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
19081 signed int vec_xlx (unsigned int index, vector signed int data);
19082 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
19083 float vec_xlx (unsigned int index, vector float data);
19084
19085 signed char vec_xrx (unsigned int index, vector signed char data);
19086 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
19087 signed short vec_xrx (unsigned int index, vector signed short data);
19088 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
19089 signed int vec_xrx (unsigned int index, vector signed int data);
19090 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
19091 float vec_xrx (unsigned int index, vector float data);
19092 @end smallexample
19093
19094 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
19095 perform pairwise comparisons between the elements at the same
19096 positions within their two vector arguments.
19097 The @code{vec_all_nez} function returns a
19098 non-zero value if and only if all pairwise comparisons are not
19099 equal and no element of either vector argument contains a zero.
19100 The @code{vec_any_eqz} function returns a
19101 non-zero value if and only if at least one pairwise comparison is equal
19102 or if at least one element of either vector argument contains a zero.
19103 The @code{vec_cmpnez} function returns a vector of the same type as
19104 its two arguments, within which each element consists of all ones to
19105 denote that either the corresponding elements of the incoming arguments are
19106 not equal or that at least one of the corresponding elements contains
19107 zero. Otherwise, the element of the returned vector contains all zeros.
19108
19109 The @code{vec_cntlz_lsbb} function returns the count of the number of
19110 consecutive leading byte elements (starting from position 0 within the
19111 supplied vector argument) for which the least-significant bit
19112 equals zero. The @code{vec_cnttz_lsbb} function returns the count of
19113 the number of consecutive trailing byte elements (starting from
19114 position 15 and counting backwards within the supplied vector
19115 argument) for which the least-significant bit equals zero.
19116
19117 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
19118 64-bit environment supporting ISA 3.0 or later. The @code{vec_xl_len}
19119 function loads a variable length vector from memory. The
19120 @code{vec_xst_len} function stores a variable length vector to memory.
19121 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
19122 @code{addr} argument represents the memory address to or from which
19123 data will be transferred, and the
19124 @code{len} argument represents the number of bytes to be
19125 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
19126 If this expression's value is not a multiple of the vector element's
19127 size, the behavior of this function is undefined.
19128 In the case that the underlying computer is configured to run in
19129 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
19130 the corresponding vector. In little-endian mode, the data transfer
19131 moves bytes @code{(16 - len)} to @code{15} of the corresponding
19132 vector. For the load function, any bytes of the result vector that
19133 are not loaded from memory are set to zero.
19134 The value of the @code{addr} argument need not be aligned on a
19135 multiple of the vector's element size.
19136
19137 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
19138 element selected by the @code{index} argument from the vector
19139 represented by the @code{data} argument. The @code{index} argument
19140 always specifies a byte offset, regardless of the size of the vector
19141 element. With @code{vec_xlx}, @code{index} is the offset of the first
19142 byte of the element to be extracted. With @code{vec_xrx}, @code{index}
19143 represents the last byte of the element to be extracted, measured
19144 from the right end of the vector. In other words, the last byte of
19145 the element to be extracted is found at position @code{(15 - index)}.
19146 There is no requirement that @code{index} be a multiple of the vector
19147 element size. However, if the size of the vector element added to
19148 @code{index} is greater than 15, the content of the returned value is
19149 undefined.
19150
19151 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19152 are available:
19153
19154 @smallexample
19155 vector unsigned long long vec_bperm (vector unsigned long long,
19156 vector unsigned char);
19157
19158 vector bool char vec_cmpne (vector bool char, vector bool char);
19159 vector bool char vec_cmpne (vector signed char, vector signed char);
19160 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19161 vector bool int vec_cmpne (vector bool int, vector bool int);
19162 vector bool int vec_cmpne (vector signed int, vector signed int);
19163 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19164 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19165 vector bool long long vec_cmpne (vector signed long long,
19166 vector signed long long);
19167 vector bool long long vec_cmpne (vector unsigned long long,
19168 vector unsigned long long);
19169 vector bool short vec_cmpne (vector bool short, vector bool short);
19170 vector bool short vec_cmpne (vector signed short, vector signed short);
19171 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19172 vector bool long long vec_cmpne (vector double, vector double);
19173 vector bool int vec_cmpne (vector float, vector float);
19174
19175 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19176 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19177
19178 vector long long vec_vctz (vector long long);
19179 vector unsigned long long vec_vctz (vector unsigned long long);
19180 vector int vec_vctz (vector int);
19181 vector unsigned int vec_vctz (vector int);
19182 vector short vec_vctz (vector short);
19183 vector unsigned short vec_vctz (vector unsigned short);
19184 vector signed char vec_vctz (vector signed char);
19185 vector unsigned char vec_vctz (vector unsigned char);
19186
19187 vector signed char vec_vctzb (vector signed char);
19188 vector unsigned char vec_vctzb (vector unsigned char);
19189
19190 vector long long vec_vctzd (vector long long);
19191 vector unsigned long long vec_vctzd (vector unsigned long long);
19192
19193 vector short vec_vctzh (vector short);
19194 vector unsigned short vec_vctzh (vector unsigned short);
19195
19196 vector int vec_vctzw (vector int);
19197 vector unsigned int vec_vctzw (vector int);
19198
19199 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19200
19201 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19202 const int);
19203 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19204 const int);
19205
19206 vector unsigned int vec_parity_lsbb (vector signed int);
19207 vector unsigned int vec_parity_lsbb (vector unsigned int);
19208 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19209 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19210 vector unsigned long long vec_parity_lsbb (vector signed long long);
19211 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19212
19213 vector int vec_vprtyb (vector int);
19214 vector unsigned int vec_vprtyb (vector unsigned int);
19215 vector long long vec_vprtyb (vector long long);
19216 vector unsigned long long vec_vprtyb (vector unsigned long long);
19217
19218 vector int vec_vprtybw (vector int);
19219 vector unsigned int vec_vprtybw (vector unsigned int);
19220
19221 vector long long vec_vprtybd (vector long long);
19222 vector unsigned long long vec_vprtybd (vector unsigned long long);
19223 @end smallexample
19224
19225 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19226 are available:
19227
19228 @smallexample
19229 vector long vec_vprtyb (vector long);
19230 vector unsigned long vec_vprtyb (vector unsigned long);
19231 vector __int128_t vec_vprtyb (vector __int128_t);
19232 vector __uint128_t vec_vprtyb (vector __uint128_t);
19233
19234 vector long vec_vprtybd (vector long);
19235 vector unsigned long vec_vprtybd (vector unsigned long);
19236
19237 vector __int128_t vec_vprtybq (vector __int128_t);
19238 vector __uint128_t vec_vprtybd (vector __uint128_t);
19239 @end smallexample
19240
19241 The following built-in vector functions are available for the PowerPC family
19242 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19243 @smallexample
19244 __vector unsigned char
19245 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19246 __vector unsigned char
19247 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19248 @end smallexample
19249
19250 The @code{vec_slv} and @code{vec_srv} functions operate on
19251 all of the bytes of their @code{src} and @code{shift_distance}
19252 arguments in parallel. The behavior of the @code{vec_slv} is as if
19253 there existed a temporary array of 17 unsigned characters
19254 @code{slv_array} within which elements 0 through 15 are the same as
19255 the entries in the @code{src} array and element 16 equals 0. The
19256 result returned from the @code{vec_slv} function is a
19257 @code{__vector} of 16 unsigned characters within which element
19258 @code{i} is computed using the C expression
19259 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19260 shift_distance[i]))},
19261 with this resulting value coerced to the @code{unsigned char} type.
19262 The behavior of the @code{vec_srv} is as if
19263 there existed a temporary array of 17 unsigned characters
19264 @code{srv_array} within which element 0 equals zero and
19265 elements 1 through 16 equal the elements 0 through 15 of
19266 the @code{src} array. The
19267 result returned from the @code{vec_srv} function is a
19268 @code{__vector} of 16 unsigned characters within which element
19269 @code{i} is computed using the C expression
19270 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19271 (0x07 & shift_distance[i]))},
19272 with this resulting value coerced to the @code{unsigned char} type.
19273
19274 The following built-in functions are available for the PowerPC family
19275 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19276 @smallexample
19277 __vector unsigned char
19278 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19279 __vector unsigned short
19280 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19281 __vector unsigned int
19282 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19283
19284 __vector unsigned char
19285 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19286 __vector unsigned short
19287 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19288 __vector unsigned int
19289 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19290 @end smallexample
19291
19292 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19293 @code{vec_absdw} built-in functions each computes the absolute
19294 differences of the pairs of vector elements supplied in its two vector
19295 arguments, placing the absolute differences into the corresponding
19296 elements of the vector result.
19297
19298 The following built-in functions are available for the PowerPC family
19299 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19300 @smallexample
19301 __vector unsigned int
19302 vec_extract_exp (__vector float source);
19303 __vector unsigned long long int
19304 vec_extract_exp (__vector double source);
19305
19306 __vector unsigned int
19307 vec_extract_sig (__vector float source);
19308 __vector unsigned long long int
19309 vec_extract_sig (__vector double source);
19310
19311 __vector float
19312 vec_insert_exp (__vector unsigned int significands,
19313 __vector unsigned int exponents);
19314 __vector float
19315 vec_insert_exp (__vector unsigned float significands,
19316 __vector unsigned int exponents);
19317 __vector double
19318 vec_insert_exp (__vector unsigned long long int significands,
19319 __vector unsigned long long int exponents);
19320 __vector double
19321 vec_insert_exp (__vector unsigned double significands,
19322 __vector unsigned long long int exponents);
19323
19324 __vector bool int vec_test_data_class (__vector float source,
19325 const int condition);
19326 __vector bool long long int vec_test_data_class (__vector double source,
19327 const int condition);
19328 @end smallexample
19329
19330 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19331 functions return vectors representing the significands and biased
19332 exponent values of their @code{source} arguments respectively.
19333 Within the result vector returned by @code{vec_extract_sig}, the
19334 @code{0x800000} bit of each vector element returned when the
19335 function's @code{source} argument is of type @code{float} is set to 1
19336 if the corresponding floating point value is in normalized form.
19337 Otherwise, this bit is set to 0. When the @code{source} argument is
19338 of type @code{double}, the @code{0x10000000000000} bit within each of
19339 the result vector's elements is set according to the same rules.
19340 Note that the sign of the significand is not represented in the result
19341 returned from the @code{vec_extract_sig} function. To extract the
19342 sign bits, use the
19343 @code{vec_cpsgn} function, which returns a new vector within which all
19344 of the sign bits of its second argument vector are overwritten with the
19345 sign bits copied from the coresponding elements of its first argument
19346 vector, and all other (non-sign) bits of the second argument vector
19347 are copied unchanged into the result vector.
19348
19349 The @code{vec_insert_exp} built-in functions return a vector of
19350 single- or double-precision floating
19351 point values constructed by assembling the values of their
19352 @code{significands} and @code{exponents} arguments into the
19353 corresponding elements of the returned vector.
19354 The sign of each
19355 element of the result is copied from the most significant bit of the
19356 corresponding entry within the @code{significands} argument.
19357 Note that the relevant
19358 bits of the @code{significands} argument are the same, for both integer
19359 and floating point types.
19360 The
19361 significand and exponent components of each element of the result are
19362 composed of the least significant bits of the corresponding
19363 @code{significands} element and the least significant bits of the
19364 corresponding @code{exponents} element.
19365
19366 The @code{vec_test_data_class} built-in function returns a vector
19367 representing the results of testing the @code{source} vector for the
19368 condition selected by the @code{condition} argument. The
19369 @code{condition} argument must be a compile-time constant integer with
19370 value not exceeding 127. The
19371 @code{condition} argument is encoded as a bitmask with each bit
19372 enabling the testing of a different condition, as characterized by the
19373 following:
19374 @smallexample
19375 0x40 Test for NaN
19376 0x20 Test for +Infinity
19377 0x10 Test for -Infinity
19378 0x08 Test for +Zero
19379 0x04 Test for -Zero
19380 0x02 Test for +Denormal
19381 0x01 Test for -Denormal
19382 @end smallexample
19383
19384 If any of the enabled test conditions is true, the corresponding entry
19385 in the result vector is -1. Otherwise (all of the enabled test
19386 conditions are false), the corresponding entry of the result vector is 0.
19387
19388 The following built-in functions are available for the PowerPC family
19389 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19390 @smallexample
19391 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19392 vector unsigned int);
19393 vector unsigned long long vec_rlmi (vector unsigned long long,
19394 vector unsigned long long,
19395 vector unsigned long long);
19396 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19397 vector unsigned int);
19398 vector unsigned long long vec_rlnm (vector unsigned long long,
19399 vector unsigned long long,
19400 vector unsigned long long);
19401 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19402 vector unsigned long long vec_vrlnm (vector unsigned long long,
19403 vector unsigned long long);
19404 @end smallexample
19405
19406 The result of @code{vec_rlmi} is obtained by rotating each element of
19407 the first argument vector left and inserting it under mask into the
19408 second argument vector. The third argument vector contains the mask
19409 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19410 count in bits 27:31, of each element.
19411
19412 The result of @code{vec_rlnm} is obtained by rotating each element of
19413 the first argument vector left and ANDing it with a mask specified by
19414 the second and third argument vectors. The second argument vector
19415 contains the shift count for each element in the low-order byte. The
19416 third argument vector contains the mask end for each element in the
19417 low-order byte, with the mask begin in the next higher byte.
19418
19419 The result of @code{vec_vrlnm} is obtained by rotating each element
19420 of the first argument vector left and ANDing it with a mask. The
19421 second argument vector contains the mask beginning in bits 11:15,
19422 the mask end in bits 19:23, and the shift count in bits 27:31,
19423 of each element.
19424
19425 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19426 are available:
19427 @smallexample
19428 vector signed bool char vec_revb (vector signed char);
19429 vector signed char vec_revb (vector signed char);
19430 vector unsigned char vec_revb (vector unsigned char);
19431 vector bool short vec_revb (vector bool short);
19432 vector short vec_revb (vector short);
19433 vector unsigned short vec_revb (vector unsigned short);
19434 vector bool int vec_revb (vector bool int);
19435 vector int vec_revb (vector int);
19436 vector unsigned int vec_revb (vector unsigned int);
19437 vector float vec_revb (vector float);
19438 vector bool long long vec_revb (vector bool long long);
19439 vector long long vec_revb (vector long long);
19440 vector unsigned long long vec_revb (vector unsigned long long);
19441 vector double vec_revb (vector double);
19442 @end smallexample
19443
19444 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19445 are available:
19446 @smallexample
19447 vector long vec_revb (vector long);
19448 vector unsigned long vec_revb (vector unsigned long);
19449 vector __int128_t vec_revb (vector __int128_t);
19450 vector __uint128_t vec_revb (vector __uint128_t);
19451 @end smallexample
19452
19453 The @code{vec_revb} built-in function reverses the bytes on an element
19454 by element basis. A vector of @code{vector unsigned char} or
19455 @code{vector signed char} reverses the bytes in the whole word.
19456
19457 If the cryptographic instructions are enabled (@option{-mcrypto} or
19458 @option{-mcpu=power8}), the following builtins are enabled.
19459
19460 @smallexample
19461 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19462
19463 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19464 vector unsigned long long);
19465
19466 vector unsigned long long __builtin_crypto_vcipherlast
19467 (vector unsigned long long,
19468 vector unsigned long long);
19469
19470 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19471 vector unsigned long long);
19472
19473 vector unsigned long long __builtin_crypto_vncipherlast
19474 (vector unsigned long long,
19475 vector unsigned long long);
19476
19477 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19478 vector unsigned char,
19479 vector unsigned char);
19480
19481 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19482 vector unsigned short,
19483 vector unsigned short);
19484
19485 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19486 vector unsigned int,
19487 vector unsigned int);
19488
19489 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19490 vector unsigned long long,
19491 vector unsigned long long);
19492
19493 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19494 vector unsigned char);
19495
19496 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19497 vector unsigned short);
19498
19499 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19500 vector unsigned int);
19501
19502 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19503 vector unsigned long long);
19504
19505 vector unsigned long long __builtin_crypto_vshasigmad
19506 (vector unsigned long long, int, int);
19507
19508 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
19509 int, int);
19510 @end smallexample
19511
19512 The second argument to @var{__builtin_crypto_vshasigmad} and
19513 @var{__builtin_crypto_vshasigmaw} must be a constant
19514 integer that is 0 or 1. The third argument to these built-in functions
19515 must be a constant integer in the range of 0 to 15.
19516
19517 If the ISA 3.0 instruction set additions
19518 are enabled (@option{-mcpu=power9}), the following additional
19519 functions are available for both 32-bit and 64-bit targets.
19520
19521 vector short vec_xl (int, vector short *);
19522 vector short vec_xl (int, short *);
19523 vector unsigned short vec_xl (int, vector unsigned short *);
19524 vector unsigned short vec_xl (int, unsigned short *);
19525 vector char vec_xl (int, vector char *);
19526 vector char vec_xl (int, char *);
19527 vector unsigned char vec_xl (int, vector unsigned char *);
19528 vector unsigned char vec_xl (int, unsigned char *);
19529
19530 void vec_xst (vector short, int, vector short *);
19531 void vec_xst (vector short, int, short *);
19532 void vec_xst (vector unsigned short, int, vector unsigned short *);
19533 void vec_xst (vector unsigned short, int, unsigned short *);
19534 void vec_xst (vector char, int, vector char *);
19535 void vec_xst (vector char, int, char *);
19536 void vec_xst (vector unsigned char, int, vector unsigned char *);
19537 void vec_xst (vector unsigned char, int, unsigned char *);
19538
19539 @node PowerPC Hardware Transactional Memory Built-in Functions
19540 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19541 GCC provides two interfaces for accessing the Hardware Transactional
19542 Memory (HTM) instructions available on some of the PowerPC family
19543 of processors (eg, POWER8). The two interfaces come in a low level
19544 interface, consisting of built-in functions specific to PowerPC and a
19545 higher level interface consisting of inline functions that are common
19546 between PowerPC and S/390.
19547
19548 @subsubsection PowerPC HTM Low Level Built-in Functions
19549
19550 The following low level built-in functions are available with
19551 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19552 They all generate the machine instruction that is part of the name.
19553
19554 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19555 the full 4-bit condition register value set by their associated hardware
19556 instruction. The header file @code{htmintrin.h} defines some macros that can
19557 be used to decipher the return value. The @code{__builtin_tbegin} builtin
19558 returns a simple true or false value depending on whether a transaction was
19559 successfully started or not. The arguments of the builtins match exactly the
19560 type and order of the associated hardware instruction's operands, except for
19561 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19562 Refer to the ISA manual for a description of each instruction's operands.
19563
19564 @smallexample
19565 unsigned int __builtin_tbegin (unsigned int)
19566 unsigned int __builtin_tend (unsigned int)
19567
19568 unsigned int __builtin_tabort (unsigned int)
19569 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19570 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19571 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19572 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19573
19574 unsigned int __builtin_tcheck (void)
19575 unsigned int __builtin_treclaim (unsigned int)
19576 unsigned int __builtin_trechkpt (void)
19577 unsigned int __builtin_tsr (unsigned int)
19578 @end smallexample
19579
19580 In addition to the above HTM built-ins, we have added built-ins for
19581 some common extended mnemonics of the HTM instructions:
19582
19583 @smallexample
19584 unsigned int __builtin_tendall (void)
19585 unsigned int __builtin_tresume (void)
19586 unsigned int __builtin_tsuspend (void)
19587 @end smallexample
19588
19589 Note that the semantics of the above HTM builtins are required to mimic
19590 the locking semantics used for critical sections. Builtins that are used
19591 to create a new transaction or restart a suspended transaction must have
19592 lock acquisition like semantics while those builtins that end or suspend a
19593 transaction must have lock release like semantics. Specifically, this must
19594 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19595 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19596 that returns 0, and lock release is as-if an execution of
19597 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19598 implicit implementation-defined lock used for all transactions. The HTM
19599 instructions associated with with the builtins inherently provide the
19600 correct acquisition and release hardware barriers required. However,
19601 the compiler must also be prohibited from moving loads and stores across
19602 the builtins in a way that would violate their semantics. This has been
19603 accomplished by adding memory barriers to the associated HTM instructions
19604 (which is a conservative approach to provide acquire and release semantics).
19605 Earlier versions of the compiler did not treat the HTM instructions as
19606 memory barriers. A @code{__TM_FENCE__} macro has been added, which can
19607 be used to determine whether the current compiler treats HTM instructions
19608 as memory barriers or not. This allows the user to explicitly add memory
19609 barriers to their code when using an older version of the compiler.
19610
19611 The following set of built-in functions are available to gain access
19612 to the HTM specific special purpose registers.
19613
19614 @smallexample
19615 unsigned long __builtin_get_texasr (void)
19616 unsigned long __builtin_get_texasru (void)
19617 unsigned long __builtin_get_tfhar (void)
19618 unsigned long __builtin_get_tfiar (void)
19619
19620 void __builtin_set_texasr (unsigned long);
19621 void __builtin_set_texasru (unsigned long);
19622 void __builtin_set_tfhar (unsigned long);
19623 void __builtin_set_tfiar (unsigned long);
19624 @end smallexample
19625
19626 Example usage of these low level built-in functions may look like:
19627
19628 @smallexample
19629 #include <htmintrin.h>
19630
19631 int num_retries = 10;
19632
19633 while (1)
19634 @{
19635 if (__builtin_tbegin (0))
19636 @{
19637 /* Transaction State Initiated. */
19638 if (is_locked (lock))
19639 __builtin_tabort (0);
19640 ... transaction code...
19641 __builtin_tend (0);
19642 break;
19643 @}
19644 else
19645 @{
19646 /* Transaction State Failed. Use locks if the transaction
19647 failure is "persistent" or we've tried too many times. */
19648 if (num_retries-- <= 0
19649 || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19650 @{
19651 acquire_lock (lock);
19652 ... non transactional fallback path...
19653 release_lock (lock);
19654 break;
19655 @}
19656 @}
19657 @}
19658 @end smallexample
19659
19660 One final built-in function has been added that returns the value of
19661 the 2-bit Transaction State field of the Machine Status Register (MSR)
19662 as stored in @code{CR0}.
19663
19664 @smallexample
19665 unsigned long __builtin_ttest (void)
19666 @end smallexample
19667
19668 This built-in can be used to determine the current transaction state
19669 using the following code example:
19670
19671 @smallexample
19672 #include <htmintrin.h>
19673
19674 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19675
19676 if (tx_state == _HTM_TRANSACTIONAL)
19677 @{
19678 /* Code to use in transactional state. */
19679 @}
19680 else if (tx_state == _HTM_NONTRANSACTIONAL)
19681 @{
19682 /* Code to use in non-transactional state. */
19683 @}
19684 else if (tx_state == _HTM_SUSPENDED)
19685 @{
19686 /* Code to use in transaction suspended state. */
19687 @}
19688 @end smallexample
19689
19690 @subsubsection PowerPC HTM High Level Inline Functions
19691
19692 The following high level HTM interface is made available by including
19693 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19694 where CPU is `power8' or later. This interface is common between PowerPC
19695 and S/390, allowing users to write one HTM source implementation that
19696 can be compiled and executed on either system.
19697
19698 @smallexample
19699 long __TM_simple_begin (void)
19700 long __TM_begin (void* const TM_buff)
19701 long __TM_end (void)
19702 void __TM_abort (void)
19703 void __TM_named_abort (unsigned char const code)
19704 void __TM_resume (void)
19705 void __TM_suspend (void)
19706
19707 long __TM_is_user_abort (void* const TM_buff)
19708 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19709 long __TM_is_illegal (void* const TM_buff)
19710 long __TM_is_footprint_exceeded (void* const TM_buff)
19711 long __TM_nesting_depth (void* const TM_buff)
19712 long __TM_is_nested_too_deep(void* const TM_buff)
19713 long __TM_is_conflict(void* const TM_buff)
19714 long __TM_is_failure_persistent(void* const TM_buff)
19715 long __TM_failure_address(void* const TM_buff)
19716 long long __TM_failure_code(void* const TM_buff)
19717 @end smallexample
19718
19719 Using these common set of HTM inline functions, we can create
19720 a more portable version of the HTM example in the previous
19721 section that will work on either PowerPC or S/390:
19722
19723 @smallexample
19724 #include <htmxlintrin.h>
19725
19726 int num_retries = 10;
19727 TM_buff_type TM_buff;
19728
19729 while (1)
19730 @{
19731 if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19732 @{
19733 /* Transaction State Initiated. */
19734 if (is_locked (lock))
19735 __TM_abort ();
19736 ... transaction code...
19737 __TM_end ();
19738 break;
19739 @}
19740 else
19741 @{
19742 /* Transaction State Failed. Use locks if the transaction
19743 failure is "persistent" or we've tried too many times. */
19744 if (num_retries-- <= 0
19745 || __TM_is_failure_persistent (TM_buff))
19746 @{
19747 acquire_lock (lock);
19748 ... non transactional fallback path...
19749 release_lock (lock);
19750 break;
19751 @}
19752 @}
19753 @}
19754 @end smallexample
19755
19756 @node PowerPC Atomic Memory Operation Functions
19757 @subsection PowerPC Atomic Memory Operation Functions
19758 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19759 instructions. GCC provides support for these instructions in 64-bit
19760 environments. All of the functions are declared in the include file
19761 @code{amo.h}.
19762
19763 The functions supported are:
19764
19765 @smallexample
19766 #include <amo.h>
19767
19768 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19769 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19770 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19771 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19772 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19773 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19774 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19775
19776 int32_t amo_lwat_sadd (int32_t *, int32_t);
19777 int32_t amo_lwat_smax (int32_t *, int32_t);
19778 int32_t amo_lwat_smin (int32_t *, int32_t);
19779 int32_t amo_lwat_sswap (int32_t *, int32_t);
19780
19781 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19782 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19783 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19784 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19785 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19786 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19787 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19788
19789 int64_t amo_ldat_sadd (int64_t *, int64_t);
19790 int64_t amo_ldat_smax (int64_t *, int64_t);
19791 int64_t amo_ldat_smin (int64_t *, int64_t);
19792 int64_t amo_ldat_sswap (int64_t *, int64_t);
19793
19794 void amo_stwat_add (uint32_t *, uint32_t);
19795 void amo_stwat_xor (uint32_t *, uint32_t);
19796 void amo_stwat_ior (uint32_t *, uint32_t);
19797 void amo_stwat_and (uint32_t *, uint32_t);
19798 void amo_stwat_umax (uint32_t *, uint32_t);
19799 void amo_stwat_umin (uint32_t *, uint32_t);
19800
19801 void amo_stwat_sadd (int32_t *, int32_t);
19802 void amo_stwat_smax (int32_t *, int32_t);
19803 void amo_stwat_smin (int32_t *, int32_t);
19804
19805 void amo_stdat_add (uint64_t *, uint64_t);
19806 void amo_stdat_xor (uint64_t *, uint64_t);
19807 void amo_stdat_ior (uint64_t *, uint64_t);
19808 void amo_stdat_and (uint64_t *, uint64_t);
19809 void amo_stdat_umax (uint64_t *, uint64_t);
19810 void amo_stdat_umin (uint64_t *, uint64_t);
19811
19812 void amo_stdat_sadd (int64_t *, int64_t);
19813 void amo_stdat_smax (int64_t *, int64_t);
19814 void amo_stdat_smin (int64_t *, int64_t);
19815 @end smallexample
19816
19817 @node RX Built-in Functions
19818 @subsection RX Built-in Functions
19819 GCC supports some of the RX instructions which cannot be expressed in
19820 the C programming language via the use of built-in functions. The
19821 following functions are supported:
19822
19823 @deftypefn {Built-in Function} void __builtin_rx_brk (void)
19824 Generates the @code{brk} machine instruction.
19825 @end deftypefn
19826
19827 @deftypefn {Built-in Function} void __builtin_rx_clrpsw (int)
19828 Generates the @code{clrpsw} machine instruction to clear the specified
19829 bit in the processor status word.
19830 @end deftypefn
19831
19832 @deftypefn {Built-in Function} void __builtin_rx_int (int)
19833 Generates the @code{int} machine instruction to generate an interrupt
19834 with the specified value.
19835 @end deftypefn
19836
19837 @deftypefn {Built-in Function} void __builtin_rx_machi (int, int)
19838 Generates the @code{machi} machine instruction to add the result of
19839 multiplying the top 16 bits of the two arguments into the
19840 accumulator.
19841 @end deftypefn
19842
19843 @deftypefn {Built-in Function} void __builtin_rx_maclo (int, int)
19844 Generates the @code{maclo} machine instruction to add the result of
19845 multiplying the bottom 16 bits of the two arguments into the
19846 accumulator.
19847 @end deftypefn
19848
19849 @deftypefn {Built-in Function} void __builtin_rx_mulhi (int, int)
19850 Generates the @code{mulhi} machine instruction to place the result of
19851 multiplying the top 16 bits of the two arguments into the
19852 accumulator.
19853 @end deftypefn
19854
19855 @deftypefn {Built-in Function} void __builtin_rx_mullo (int, int)
19856 Generates the @code{mullo} machine instruction to place the result of
19857 multiplying the bottom 16 bits of the two arguments into the
19858 accumulator.
19859 @end deftypefn
19860
19861 @deftypefn {Built-in Function} int __builtin_rx_mvfachi (void)
19862 Generates the @code{mvfachi} machine instruction to read the top
19863 32 bits of the accumulator.
19864 @end deftypefn
19865
19866 @deftypefn {Built-in Function} int __builtin_rx_mvfacmi (void)
19867 Generates the @code{mvfacmi} machine instruction to read the middle
19868 32 bits of the accumulator.
19869 @end deftypefn
19870
19871 @deftypefn {Built-in Function} int __builtin_rx_mvfc (int)
19872 Generates the @code{mvfc} machine instruction which reads the control
19873 register specified in its argument and returns its value.
19874 @end deftypefn
19875
19876 @deftypefn {Built-in Function} void __builtin_rx_mvtachi (int)
19877 Generates the @code{mvtachi} machine instruction to set the top
19878 32 bits of the accumulator.
19879 @end deftypefn
19880
19881 @deftypefn {Built-in Function} void __builtin_rx_mvtaclo (int)
19882 Generates the @code{mvtaclo} machine instruction to set the bottom
19883 32 bits of the accumulator.
19884 @end deftypefn
19885
19886 @deftypefn {Built-in Function} void __builtin_rx_mvtc (int reg, int val)
19887 Generates the @code{mvtc} machine instruction which sets control
19888 register number @code{reg} to @code{val}.
19889 @end deftypefn
19890
19891 @deftypefn {Built-in Function} void __builtin_rx_mvtipl (int)
19892 Generates the @code{mvtipl} machine instruction set the interrupt
19893 priority level.
19894 @end deftypefn
19895
19896 @deftypefn {Built-in Function} void __builtin_rx_racw (int)
19897 Generates the @code{racw} machine instruction to round the accumulator
19898 according to the specified mode.
19899 @end deftypefn
19900
19901 @deftypefn {Built-in Function} int __builtin_rx_revw (int)
19902 Generates the @code{revw} machine instruction which swaps the bytes in
19903 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19904 and also bits 16--23 occupy bits 24--31 and vice versa.
19905 @end deftypefn
19906
19907 @deftypefn {Built-in Function} void __builtin_rx_rmpa (void)
19908 Generates the @code{rmpa} machine instruction which initiates a
19909 repeated multiply and accumulate sequence.
19910 @end deftypefn
19911
19912 @deftypefn {Built-in Function} void __builtin_rx_round (float)
19913 Generates the @code{round} machine instruction which returns the
19914 floating-point argument rounded according to the current rounding mode
19915 set in the floating-point status word register.
19916 @end deftypefn
19917
19918 @deftypefn {Built-in Function} int __builtin_rx_sat (int)
19919 Generates the @code{sat} machine instruction which returns the
19920 saturated value of the argument.
19921 @end deftypefn
19922
19923 @deftypefn {Built-in Function} void __builtin_rx_setpsw (int)
19924 Generates the @code{setpsw} machine instruction to set the specified
19925 bit in the processor status word.
19926 @end deftypefn
19927
19928 @deftypefn {Built-in Function} void __builtin_rx_wait (void)
19929 Generates the @code{wait} machine instruction.
19930 @end deftypefn
19931
19932 @node S/390 System z Built-in Functions
19933 @subsection S/390 System z Built-in Functions
19934 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19935 Generates the @code{tbegin} machine instruction starting a
19936 non-constrained hardware transaction. If the parameter is non-NULL the
19937 memory area is used to store the transaction diagnostic buffer and
19938 will be passed as first operand to @code{tbegin}. This buffer can be
19939 defined using the @code{struct __htm_tdb} C struct defined in
19940 @code{htmintrin.h} and must reside on a double-word boundary. The
19941 second tbegin operand is set to @code{0xff0c}. This enables
19942 save/restore of all GPRs and disables aborts for FPR and AR
19943 manipulations inside the transaction body. The condition code set by
19944 the tbegin instruction is returned as integer value. The tbegin
19945 instruction by definition overwrites the content of all FPRs. The
19946 compiler will generate code which saves and restores the FPRs. For
19947 soft-float code it is recommended to used the @code{*_nofloat}
19948 variant. In order to prevent a TDB from being written it is required
19949 to pass a constant zero value as parameter. Passing a zero value
19950 through a variable is not sufficient. Although modifications of
19951 access registers inside the transaction will not trigger an
19952 transaction abort it is not supported to actually modify them. Access
19953 registers do not get saved when entering a transaction. They will have
19954 undefined state when reaching the abort code.
19955 @end deftypefn
19956
19957 Macros for the possible return codes of tbegin are defined in the
19958 @code{htmintrin.h} header file:
19959
19960 @table @code
19961 @item _HTM_TBEGIN_STARTED
19962 @code{tbegin} has been executed as part of normal processing. The
19963 transaction body is supposed to be executed.
19964 @item _HTM_TBEGIN_INDETERMINATE
19965 The transaction was aborted due to an indeterminate condition which
19966 might be persistent.
19967 @item _HTM_TBEGIN_TRANSIENT
19968 The transaction aborted due to a transient failure. The transaction
19969 should be re-executed in that case.
19970 @item _HTM_TBEGIN_PERSISTENT
19971 The transaction aborted due to a persistent failure. Re-execution
19972 under same circumstances will not be productive.
19973 @end table
19974
19975 @defmac _HTM_FIRST_USER_ABORT_CODE
19976 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19977 specifies the first abort code which can be used for
19978 @code{__builtin_tabort}. Values below this threshold are reserved for
19979 machine use.
19980 @end defmac
19981
19982 @deftp {Data type} {struct __htm_tdb}
19983 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19984 the structure of the transaction diagnostic block as specified in the
19985 Principles of Operation manual chapter 5-91.
19986 @end deftp
19987
19988 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19989 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19990 Using this variant in code making use of FPRs will leave the FPRs in
19991 undefined state when entering the transaction abort handler code.
19992 @end deftypefn
19993
19994 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19995 In addition to @code{__builtin_tbegin} a loop for transient failures
19996 is generated. If tbegin returns a condition code of 2 the transaction
19997 will be retried as often as specified in the second argument. The
19998 perform processor assist instruction is used to tell the CPU about the
19999 number of fails so far.
20000 @end deftypefn
20001
20002 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
20003 Same as @code{__builtin_tbegin_retry} but without FPR saves and
20004 restores. Using this variant in code making use of FPRs will leave
20005 the FPRs in undefined state when entering the transaction abort
20006 handler code.
20007 @end deftypefn
20008
20009 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
20010 Generates the @code{tbeginc} machine instruction starting a constrained
20011 hardware transaction. The second operand is set to @code{0xff08}.
20012 @end deftypefn
20013
20014 @deftypefn {Built-in Function} int __builtin_tend (void)
20015 Generates the @code{tend} machine instruction finishing a transaction
20016 and making the changes visible to other threads. The condition code
20017 generated by tend is returned as integer value.
20018 @end deftypefn
20019
20020 @deftypefn {Built-in Function} void __builtin_tabort (int)
20021 Generates the @code{tabort} machine instruction with the specified
20022 abort code. Abort codes from 0 through 255 are reserved and will
20023 result in an error message.
20024 @end deftypefn
20025
20026 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
20027 Generates the @code{ppa rX,rY,1} machine instruction. Where the
20028 integer parameter is loaded into rX and a value of zero is loaded into
20029 rY. The integer parameter specifies the number of times the
20030 transaction repeatedly aborted.
20031 @end deftypefn
20032
20033 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
20034 Generates the @code{etnd} machine instruction. The current nesting
20035 depth is returned as integer value. For a nesting depth of 0 the code
20036 is not executed as part of an transaction.
20037 @end deftypefn
20038
20039 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
20040
20041 Generates the @code{ntstg} machine instruction. The second argument
20042 is written to the first arguments location. The store operation will
20043 not be rolled-back in case of an transaction abort.
20044 @end deftypefn
20045
20046 @node SH Built-in Functions
20047 @subsection SH Built-in Functions
20048 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
20049 families of processors:
20050
20051 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
20052 Sets the @samp{GBR} register to the specified value @var{ptr}. This is usually
20053 used by system code that manages threads and execution contexts. The compiler
20054 normally does not generate code that modifies the contents of @samp{GBR} and
20055 thus the value is preserved across function calls. Changing the @samp{GBR}
20056 value in user code must be done with caution, since the compiler might use
20057 @samp{GBR} in order to access thread local variables.
20058
20059 @end deftypefn
20060
20061 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
20062 Returns the value that is currently set in the @samp{GBR} register.
20063 Memory loads and stores that use the thread pointer as a base address are
20064 turned into @samp{GBR} based displacement loads and stores, if possible.
20065 For example:
20066 @smallexample
20067 struct my_tcb
20068 @{
20069 int a, b, c, d, e;
20070 @};
20071
20072 int get_tcb_value (void)
20073 @{
20074 // Generate @samp{mov.l @@(8,gbr),r0} instruction
20075 return ((my_tcb*)__builtin_thread_pointer ())->c;
20076 @}
20077
20078 @end smallexample
20079 @end deftypefn
20080
20081 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
20082 Returns the value that is currently set in the @samp{FPSCR} register.
20083 @end deftypefn
20084
20085 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
20086 Sets the @samp{FPSCR} register to the specified value @var{val}, while
20087 preserving the current values of the FR, SZ and PR bits.
20088 @end deftypefn
20089
20090 @node SPARC VIS Built-in Functions
20091 @subsection SPARC VIS Built-in Functions
20092
20093 GCC supports SIMD operations on the SPARC using both the generic vector
20094 extensions (@pxref{Vector Extensions}) as well as built-in functions for
20095 the SPARC Visual Instruction Set (VIS). When you use the @option{-mvis}
20096 switch, the VIS extension is exposed as the following built-in functions:
20097
20098 @smallexample
20099 typedef int v1si __attribute__ ((vector_size (4)));
20100 typedef int v2si __attribute__ ((vector_size (8)));
20101 typedef short v4hi __attribute__ ((vector_size (8)));
20102 typedef short v2hi __attribute__ ((vector_size (4)));
20103 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
20104 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
20105
20106 void __builtin_vis_write_gsr (int64_t);
20107 int64_t __builtin_vis_read_gsr (void);
20108
20109 void * __builtin_vis_alignaddr (void *, long);
20110 void * __builtin_vis_alignaddrl (void *, long);
20111 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
20112 v2si __builtin_vis_faligndatav2si (v2si, v2si);
20113 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
20114 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
20115
20116 v4hi __builtin_vis_fexpand (v4qi);
20117
20118 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
20119 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
20120 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
20121 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
20122 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
20123 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
20124 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
20125
20126 v4qi __builtin_vis_fpack16 (v4hi);
20127 v8qi __builtin_vis_fpack32 (v2si, v8qi);
20128 v2hi __builtin_vis_fpackfix (v2si);
20129 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
20130
20131 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
20132
20133 long __builtin_vis_edge8 (void *, void *);
20134 long __builtin_vis_edge8l (void *, void *);
20135 long __builtin_vis_edge16 (void *, void *);
20136 long __builtin_vis_edge16l (void *, void *);
20137 long __builtin_vis_edge32 (void *, void *);
20138 long __builtin_vis_edge32l (void *, void *);
20139
20140 long __builtin_vis_fcmple16 (v4hi, v4hi);
20141 long __builtin_vis_fcmple32 (v2si, v2si);
20142 long __builtin_vis_fcmpne16 (v4hi, v4hi);
20143 long __builtin_vis_fcmpne32 (v2si, v2si);
20144 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
20145 long __builtin_vis_fcmpgt32 (v2si, v2si);
20146 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
20147 long __builtin_vis_fcmpeq32 (v2si, v2si);
20148
20149 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
20150 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
20151 v2si __builtin_vis_fpadd32 (v2si, v2si);
20152 v1si __builtin_vis_fpadd32s (v1si, v1si);
20153 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
20154 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
20155 v2si __builtin_vis_fpsub32 (v2si, v2si);
20156 v1si __builtin_vis_fpsub32s (v1si, v1si);
20157
20158 long __builtin_vis_array8 (long, long);
20159 long __builtin_vis_array16 (long, long);
20160 long __builtin_vis_array32 (long, long);
20161 @end smallexample
20162
20163 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20164 functions also become available:
20165
20166 @smallexample
20167 long __builtin_vis_bmask (long, long);
20168 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20169 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20170 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20171 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20172
20173 long __builtin_vis_edge8n (void *, void *);
20174 long __builtin_vis_edge8ln (void *, void *);
20175 long __builtin_vis_edge16n (void *, void *);
20176 long __builtin_vis_edge16ln (void *, void *);
20177 long __builtin_vis_edge32n (void *, void *);
20178 long __builtin_vis_edge32ln (void *, void *);
20179 @end smallexample
20180
20181 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20182 functions also become available:
20183
20184 @smallexample
20185 void __builtin_vis_cmask8 (long);
20186 void __builtin_vis_cmask16 (long);
20187 void __builtin_vis_cmask32 (long);
20188
20189 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20190
20191 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20192 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20193 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20194 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20195 v2si __builtin_vis_fsll16 (v2si, v2si);
20196 v2si __builtin_vis_fslas16 (v2si, v2si);
20197 v2si __builtin_vis_fsrl16 (v2si, v2si);
20198 v2si __builtin_vis_fsra16 (v2si, v2si);
20199
20200 long __builtin_vis_pdistn (v8qi, v8qi);
20201
20202 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20203
20204 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20205 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20206
20207 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20208 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20209 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20210 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20211 v2si __builtin_vis_fpadds32 (v2si, v2si);
20212 v1si __builtin_vis_fpadds32s (v1si, v1si);
20213 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20214 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20215
20216 long __builtin_vis_fucmple8 (v8qi, v8qi);
20217 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20218 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20219 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20220
20221 float __builtin_vis_fhadds (float, float);
20222 double __builtin_vis_fhaddd (double, double);
20223 float __builtin_vis_fhsubs (float, float);
20224 double __builtin_vis_fhsubd (double, double);
20225 float __builtin_vis_fnhadds (float, float);
20226 double __builtin_vis_fnhaddd (double, double);
20227
20228 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20229 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20230 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20231 @end smallexample
20232
20233 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20234 functions also become available:
20235
20236 @smallexample
20237 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20238 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20239 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20240 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20241
20242 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20243 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20244 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20245 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20246
20247 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20248 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20249 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20250 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20251 long __builtin_vis_fpcmpule32 (v2si, v2si);
20252 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20253
20254 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20255 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20256 v2si __builtin_vis_fpmax32 (v2si, v2si);
20257
20258 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20259 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20260 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20261
20262
20263 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20264 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20265 v2si __builtin_vis_fpmin32 (v2si, v2si);
20266
20267 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20268 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20269 v2si __builtin_vis_fpminu32 (v2si, v2si);
20270 @end smallexample
20271
20272 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20273 built-in functions also become available:
20274
20275 @smallexample
20276 v8qi __builtin_vis_dictunpack8 (double, int);
20277 v4hi __builtin_vis_dictunpack16 (double, int);
20278 v2si __builtin_vis_dictunpack32 (double, int);
20279
20280 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20281 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20282 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20283 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20284
20285 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20286 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20287 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20288 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20289
20290 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20291 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20292 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20293 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20294
20295 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20296 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20297 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20298 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20299 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20300 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20301
20302 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20303 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20304 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20305
20306 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20307 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20308 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20309 @end smallexample
20310
20311 @node SPU Built-in Functions
20312 @subsection SPU Built-in Functions
20313
20314 GCC provides extensions for the SPU processor as described in the
20315 Sony/Toshiba/IBM SPU Language Extensions Specification. GCC's
20316 implementation differs in several ways.
20317
20318 @itemize @bullet
20319
20320 @item
20321 The optional extension of specifying vector constants in parentheses is
20322 not supported.
20323
20324 @item
20325 A vector initializer requires no cast if the vector constant is of the
20326 same type as the variable it is initializing.
20327
20328 @item
20329 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20330 vector type is the default signedness of the base type. The default
20331 varies depending on the operating system, so a portable program should
20332 always specify the signedness.
20333
20334 @item
20335 By default, the keyword @code{__vector} is added. The macro
20336 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20337 undefined.
20338
20339 @item
20340 GCC allows using a @code{typedef} name as the type specifier for a
20341 vector type.
20342
20343 @item
20344 For C, overloaded functions are implemented with macros so the following
20345 does not work:
20346
20347 @smallexample
20348 spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20349 @end smallexample
20350
20351 @noindent
20352 Since @code{spu_add} is a macro, the vector constant in the example
20353 is treated as four separate arguments. Wrap the entire argument in
20354 parentheses for this to work.
20355
20356 @item
20357 The extended version of @code{__builtin_expect} is not supported.
20358
20359 @end itemize
20360
20361 @emph{Note:} Only the interface described in the aforementioned
20362 specification is supported. Internally, GCC uses built-in functions to
20363 implement the required functionality, but these are not supported and
20364 are subject to change without notice.
20365
20366 @node TI C6X Built-in Functions
20367 @subsection TI C6X Built-in Functions
20368
20369 GCC provides intrinsics to access certain instructions of the TI C6X
20370 processors. These intrinsics, listed below, are available after
20371 inclusion of the @code{c6x_intrinsics.h} header file. They map directly
20372 to C6X instructions.
20373
20374 @smallexample
20375
20376 int _sadd (int, int)
20377 int _ssub (int, int)
20378 int _sadd2 (int, int)
20379 int _ssub2 (int, int)
20380 long long _mpy2 (int, int)
20381 long long _smpy2 (int, int)
20382 int _add4 (int, int)
20383 int _sub4 (int, int)
20384 int _saddu4 (int, int)
20385
20386 int _smpy (int, int)
20387 int _smpyh (int, int)
20388 int _smpyhl (int, int)
20389 int _smpylh (int, int)
20390
20391 int _sshl (int, int)
20392 int _subc (int, int)
20393
20394 int _avg2 (int, int)
20395 int _avgu4 (int, int)
20396
20397 int _clrr (int, int)
20398 int _extr (int, int)
20399 int _extru (int, int)
20400 int _abs (int)
20401 int _abs2 (int)
20402
20403 @end smallexample
20404
20405 @node TILE-Gx Built-in Functions
20406 @subsection TILE-Gx Built-in Functions
20407
20408 GCC provides intrinsics to access every instruction of the TILE-Gx
20409 processor. The intrinsics are of the form:
20410
20411 @smallexample
20412
20413 unsigned long long __insn_@var{op} (...)
20414
20415 @end smallexample
20416
20417 Where @var{op} is the name of the instruction. Refer to the ISA manual
20418 for the complete list of instructions.
20419
20420 GCC also provides intrinsics to directly access the network registers.
20421 The intrinsics are:
20422
20423 @smallexample
20424
20425 unsigned long long __tile_idn0_receive (void)
20426 unsigned long long __tile_idn1_receive (void)
20427 unsigned long long __tile_udn0_receive (void)
20428 unsigned long long __tile_udn1_receive (void)
20429 unsigned long long __tile_udn2_receive (void)
20430 unsigned long long __tile_udn3_receive (void)
20431 void __tile_idn_send (unsigned long long)
20432 void __tile_udn_send (unsigned long long)
20433
20434 @end smallexample
20435
20436 The intrinsic @code{void __tile_network_barrier (void)} is used to
20437 guarantee that no network operations before it are reordered with
20438 those after it.
20439
20440 @node TILEPro Built-in Functions
20441 @subsection TILEPro Built-in Functions
20442
20443 GCC provides intrinsics to access every instruction of the TILEPro
20444 processor. The intrinsics are of the form:
20445
20446 @smallexample
20447
20448 unsigned __insn_@var{op} (...)
20449
20450 @end smallexample
20451
20452 @noindent
20453 where @var{op} is the name of the instruction. Refer to the ISA manual
20454 for the complete list of instructions.
20455
20456 GCC also provides intrinsics to directly access the network registers.
20457 The intrinsics are:
20458
20459 @smallexample
20460
20461 unsigned __tile_idn0_receive (void)
20462 unsigned __tile_idn1_receive (void)
20463 unsigned __tile_sn_receive (void)
20464 unsigned __tile_udn0_receive (void)
20465 unsigned __tile_udn1_receive (void)
20466 unsigned __tile_udn2_receive (void)
20467 unsigned __tile_udn3_receive (void)
20468 void __tile_idn_send (unsigned)
20469 void __tile_sn_send (unsigned)
20470 void __tile_udn_send (unsigned)
20471
20472 @end smallexample
20473
20474 The intrinsic @code{void __tile_network_barrier (void)} is used to
20475 guarantee that no network operations before it are reordered with
20476 those after it.
20477
20478 @node x86 Built-in Functions
20479 @subsection x86 Built-in Functions
20480
20481 These built-in functions are available for the x86-32 and x86-64 family
20482 of computers, depending on the command-line switches used.
20483
20484 If you specify command-line switches such as @option{-msse},
20485 the compiler could use the extended instruction sets even if the built-ins
20486 are not used explicitly in the program. For this reason, applications
20487 that perform run-time CPU detection must compile separate files for each
20488 supported architecture, using the appropriate flags. In particular,
20489 the file containing the CPU detection code should be compiled without
20490 these options.
20491
20492 The following machine modes are available for use with MMX built-in functions
20493 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20494 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20495 vector of eight 8-bit integers. Some of the built-in functions operate on
20496 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20497
20498 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20499 of two 32-bit floating-point values.
20500
20501 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20502 floating-point values. Some instructions use a vector of four 32-bit
20503 integers, these use @code{V4SI}. Finally, some instructions operate on an
20504 entire vector register, interpreting it as a 128-bit integer, these use mode
20505 @code{TI}.
20506
20507 The x86-32 and x86-64 family of processors use additional built-in
20508 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20509 floating point and @code{TC} 128-bit complex floating-point values.
20510
20511 The following floating-point built-in functions are always available. All
20512 of them implement the function that is part of the name.
20513
20514 @smallexample
20515 __float128 __builtin_fabsq (__float128)
20516 __float128 __builtin_copysignq (__float128, __float128)
20517 @end smallexample
20518
20519 The following built-in functions are always available.
20520
20521 @table @code
20522 @item __float128 __builtin_infq (void)
20523 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20524 @findex __builtin_infq
20525
20526 @item __float128 __builtin_huge_valq (void)
20527 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20528 @findex __builtin_huge_valq
20529
20530 @item __float128 __builtin_nanq (void)
20531 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20532 @findex __builtin_nanq
20533
20534 @item __float128 __builtin_nansq (void)
20535 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20536 @findex __builtin_nansq
20537 @end table
20538
20539 The following built-in function is always available.
20540
20541 @table @code
20542 @item void __builtin_ia32_pause (void)
20543 Generates the @code{pause} machine instruction with a compiler memory
20544 barrier.
20545 @end table
20546
20547 The following built-in functions are always available and can be used to
20548 check the target platform type.
20549
20550 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20551 This function runs the CPU detection code to check the type of CPU and the
20552 features supported. This built-in function needs to be invoked along with the built-in functions
20553 to check CPU type and features, @code{__builtin_cpu_is} and
20554 @code{__builtin_cpu_supports}, only when used in a function that is
20555 executed before any constructors are called. The CPU detection code is
20556 automatically executed in a very high priority constructor.
20557
20558 For example, this function has to be used in @code{ifunc} resolvers that
20559 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20560 and @code{__builtin_cpu_supports}, or in constructors on targets that
20561 don't support constructor priority.
20562 @smallexample
20563
20564 static void (*resolve_memcpy (void)) (void)
20565 @{
20566 // ifunc resolvers fire before constructors, explicitly call the init
20567 // function.
20568 __builtin_cpu_init ();
20569 if (__builtin_cpu_supports ("ssse3"))
20570 return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20571 else
20572 return default_memcpy;
20573 @}
20574
20575 void *memcpy (void *, const void *, size_t)
20576 __attribute__ ((ifunc ("resolve_memcpy")));
20577 @end smallexample
20578
20579 @end deftypefn
20580
20581 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20582 This function returns a positive integer if the run-time CPU
20583 is of type @var{cpuname}
20584 and returns @code{0} otherwise. The following CPU names can be detected:
20585
20586 @table @samp
20587 @item intel
20588 Intel CPU.
20589
20590 @item atom
20591 Intel Atom CPU.
20592
20593 @item core2
20594 Intel Core 2 CPU.
20595
20596 @item corei7
20597 Intel Core i7 CPU.
20598
20599 @item nehalem
20600 Intel Core i7 Nehalem CPU.
20601
20602 @item westmere
20603 Intel Core i7 Westmere CPU.
20604
20605 @item sandybridge
20606 Intel Core i7 Sandy Bridge CPU.
20607
20608 @item amd
20609 AMD CPU.
20610
20611 @item amdfam10h
20612 AMD Family 10h CPU.
20613
20614 @item barcelona
20615 AMD Family 10h Barcelona CPU.
20616
20617 @item shanghai
20618 AMD Family 10h Shanghai CPU.
20619
20620 @item istanbul
20621 AMD Family 10h Istanbul CPU.
20622
20623 @item btver1
20624 AMD Family 14h CPU.
20625
20626 @item amdfam15h
20627 AMD Family 15h CPU.
20628
20629 @item bdver1
20630 AMD Family 15h Bulldozer version 1.
20631
20632 @item bdver2
20633 AMD Family 15h Bulldozer version 2.
20634
20635 @item bdver3
20636 AMD Family 15h Bulldozer version 3.
20637
20638 @item bdver4
20639 AMD Family 15h Bulldozer version 4.
20640
20641 @item btver2
20642 AMD Family 16h CPU.
20643
20644 @item amdfam17h
20645 AMD Family 17h CPU.
20646
20647 @item znver1
20648 AMD Family 17h Zen version 1.
20649 @end table
20650
20651 Here is an example:
20652 @smallexample
20653 if (__builtin_cpu_is ("corei7"))
20654 @{
20655 do_corei7 (); // Core i7 specific implementation.
20656 @}
20657 else
20658 @{
20659 do_generic (); // Generic implementation.
20660 @}
20661 @end smallexample
20662 @end deftypefn
20663
20664 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20665 This function returns a positive integer if the run-time CPU
20666 supports @var{feature}
20667 and returns @code{0} otherwise. The following features can be detected:
20668
20669 @table @samp
20670 @item cmov
20671 CMOV instruction.
20672 @item mmx
20673 MMX instructions.
20674 @item popcnt
20675 POPCNT instruction.
20676 @item sse
20677 SSE instructions.
20678 @item sse2
20679 SSE2 instructions.
20680 @item sse3
20681 SSE3 instructions.
20682 @item ssse3
20683 SSSE3 instructions.
20684 @item sse4.1
20685 SSE4.1 instructions.
20686 @item sse4.2
20687 SSE4.2 instructions.
20688 @item avx
20689 AVX instructions.
20690 @item avx2
20691 AVX2 instructions.
20692 @item avx512f
20693 AVX512F instructions.
20694 @end table
20695
20696 Here is an example:
20697 @smallexample
20698 if (__builtin_cpu_supports ("popcnt"))
20699 @{
20700 asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20701 @}
20702 else
20703 @{
20704 count = generic_countbits (n); //generic implementation.
20705 @}
20706 @end smallexample
20707 @end deftypefn
20708
20709
20710 The following built-in functions are made available by @option{-mmmx}.
20711 All of them generate the machine instruction that is part of the name.
20712
20713 @smallexample
20714 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20715 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20716 v2si __builtin_ia32_paddd (v2si, v2si)
20717 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20718 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20719 v2si __builtin_ia32_psubd (v2si, v2si)
20720 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20721 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20722 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20723 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20724 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20725 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20726 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20727 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20728 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20729 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20730 di __builtin_ia32_pand (di, di)
20731 di __builtin_ia32_pandn (di,di)
20732 di __builtin_ia32_por (di, di)
20733 di __builtin_ia32_pxor (di, di)
20734 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20735 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20736 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20737 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20738 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20739 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20740 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20741 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20742 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20743 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20744 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20745 v2si __builtin_ia32_punpckldq (v2si, v2si)
20746 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20747 v4hi __builtin_ia32_packssdw (v2si, v2si)
20748 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20749
20750 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20751 v2si __builtin_ia32_pslld (v2si, v2si)
20752 v1di __builtin_ia32_psllq (v1di, v1di)
20753 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20754 v2si __builtin_ia32_psrld (v2si, v2si)
20755 v1di __builtin_ia32_psrlq (v1di, v1di)
20756 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20757 v2si __builtin_ia32_psrad (v2si, v2si)
20758 v4hi __builtin_ia32_psllwi (v4hi, int)
20759 v2si __builtin_ia32_pslldi (v2si, int)
20760 v1di __builtin_ia32_psllqi (v1di, int)
20761 v4hi __builtin_ia32_psrlwi (v4hi, int)
20762 v2si __builtin_ia32_psrldi (v2si, int)
20763 v1di __builtin_ia32_psrlqi (v1di, int)
20764 v4hi __builtin_ia32_psrawi (v4hi, int)
20765 v2si __builtin_ia32_psradi (v2si, int)
20766
20767 @end smallexample
20768
20769 The following built-in functions are made available either with
20770 @option{-msse}, or with @option{-m3dnowa}. All of them generate
20771 the machine instruction that is part of the name.
20772
20773 @smallexample
20774 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20775 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20776 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20777 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20778 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20779 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20780 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20781 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20782 int __builtin_ia32_pmovmskb (v8qi)
20783 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20784 void __builtin_ia32_movntq (di *, di)
20785 void __builtin_ia32_sfence (void)
20786 @end smallexample
20787
20788 The following built-in functions are available when @option{-msse} is used.
20789 All of them generate the machine instruction that is part of the name.
20790
20791 @smallexample
20792 int __builtin_ia32_comieq (v4sf, v4sf)
20793 int __builtin_ia32_comineq (v4sf, v4sf)
20794 int __builtin_ia32_comilt (v4sf, v4sf)
20795 int __builtin_ia32_comile (v4sf, v4sf)
20796 int __builtin_ia32_comigt (v4sf, v4sf)
20797 int __builtin_ia32_comige (v4sf, v4sf)
20798 int __builtin_ia32_ucomieq (v4sf, v4sf)
20799 int __builtin_ia32_ucomineq (v4sf, v4sf)
20800 int __builtin_ia32_ucomilt (v4sf, v4sf)
20801 int __builtin_ia32_ucomile (v4sf, v4sf)
20802 int __builtin_ia32_ucomigt (v4sf, v4sf)
20803 int __builtin_ia32_ucomige (v4sf, v4sf)
20804 v4sf __builtin_ia32_addps (v4sf, v4sf)
20805 v4sf __builtin_ia32_subps (v4sf, v4sf)
20806 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20807 v4sf __builtin_ia32_divps (v4sf, v4sf)
20808 v4sf __builtin_ia32_addss (v4sf, v4sf)
20809 v4sf __builtin_ia32_subss (v4sf, v4sf)
20810 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20811 v4sf __builtin_ia32_divss (v4sf, v4sf)
20812 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20813 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20814 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20815 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20816 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20817 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20818 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20819 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20820 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20821 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20822 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20823 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20824 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20825 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20826 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20827 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20828 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20829 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20830 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20831 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20832 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20833 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20834 v4sf __builtin_ia32_minps (v4sf, v4sf)
20835 v4sf __builtin_ia32_minss (v4sf, v4sf)
20836 v4sf __builtin_ia32_andps (v4sf, v4sf)
20837 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20838 v4sf __builtin_ia32_orps (v4sf, v4sf)
20839 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20840 v4sf __builtin_ia32_movss (v4sf, v4sf)
20841 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20842 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20843 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20844 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20845 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20846 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20847 v2si __builtin_ia32_cvtps2pi (v4sf)
20848 int __builtin_ia32_cvtss2si (v4sf)
20849 v2si __builtin_ia32_cvttps2pi (v4sf)
20850 int __builtin_ia32_cvttss2si (v4sf)
20851 v4sf __builtin_ia32_rcpps (v4sf)
20852 v4sf __builtin_ia32_rsqrtps (v4sf)
20853 v4sf __builtin_ia32_sqrtps (v4sf)
20854 v4sf __builtin_ia32_rcpss (v4sf)
20855 v4sf __builtin_ia32_rsqrtss (v4sf)
20856 v4sf __builtin_ia32_sqrtss (v4sf)
20857 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20858 void __builtin_ia32_movntps (float *, v4sf)
20859 int __builtin_ia32_movmskps (v4sf)
20860 @end smallexample
20861
20862 The following built-in functions are available when @option{-msse} is used.
20863
20864 @table @code
20865 @item v4sf __builtin_ia32_loadups (float *)
20866 Generates the @code{movups} machine instruction as a load from memory.
20867 @item void __builtin_ia32_storeups (float *, v4sf)
20868 Generates the @code{movups} machine instruction as a store to memory.
20869 @item v4sf __builtin_ia32_loadss (float *)
20870 Generates the @code{movss} machine instruction as a load from memory.
20871 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20872 Generates the @code{movhps} machine instruction as a load from memory.
20873 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20874 Generates the @code{movlps} machine instruction as a load from memory
20875 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20876 Generates the @code{movhps} machine instruction as a store to memory.
20877 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20878 Generates the @code{movlps} machine instruction as a store to memory.
20879 @end table
20880
20881 The following built-in functions are available when @option{-msse2} is used.
20882 All of them generate the machine instruction that is part of the name.
20883
20884 @smallexample
20885 int __builtin_ia32_comisdeq (v2df, v2df)
20886 int __builtin_ia32_comisdlt (v2df, v2df)
20887 int __builtin_ia32_comisdle (v2df, v2df)
20888 int __builtin_ia32_comisdgt (v2df, v2df)
20889 int __builtin_ia32_comisdge (v2df, v2df)
20890 int __builtin_ia32_comisdneq (v2df, v2df)
20891 int __builtin_ia32_ucomisdeq (v2df, v2df)
20892 int __builtin_ia32_ucomisdlt (v2df, v2df)
20893 int __builtin_ia32_ucomisdle (v2df, v2df)
20894 int __builtin_ia32_ucomisdgt (v2df, v2df)
20895 int __builtin_ia32_ucomisdge (v2df, v2df)
20896 int __builtin_ia32_ucomisdneq (v2df, v2df)
20897 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20898 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20899 v2df __builtin_ia32_cmplepd (v2df, v2df)
20900 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20901 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20902 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20903 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20904 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20905 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20906 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20907 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20908 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20909 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20910 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20911 v2df __builtin_ia32_cmplesd (v2df, v2df)
20912 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20913 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20914 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20915 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20916 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20917 v2di __builtin_ia32_paddq (v2di, v2di)
20918 v2di __builtin_ia32_psubq (v2di, v2di)
20919 v2df __builtin_ia32_addpd (v2df, v2df)
20920 v2df __builtin_ia32_subpd (v2df, v2df)
20921 v2df __builtin_ia32_mulpd (v2df, v2df)
20922 v2df __builtin_ia32_divpd (v2df, v2df)
20923 v2df __builtin_ia32_addsd (v2df, v2df)
20924 v2df __builtin_ia32_subsd (v2df, v2df)
20925 v2df __builtin_ia32_mulsd (v2df, v2df)
20926 v2df __builtin_ia32_divsd (v2df, v2df)
20927 v2df __builtin_ia32_minpd (v2df, v2df)
20928 v2df __builtin_ia32_maxpd (v2df, v2df)
20929 v2df __builtin_ia32_minsd (v2df, v2df)
20930 v2df __builtin_ia32_maxsd (v2df, v2df)
20931 v2df __builtin_ia32_andpd (v2df, v2df)
20932 v2df __builtin_ia32_andnpd (v2df, v2df)
20933 v2df __builtin_ia32_orpd (v2df, v2df)
20934 v2df __builtin_ia32_xorpd (v2df, v2df)
20935 v2df __builtin_ia32_movsd (v2df, v2df)
20936 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20937 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20938 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20939 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20940 v4si __builtin_ia32_paddd128 (v4si, v4si)
20941 v2di __builtin_ia32_paddq128 (v2di, v2di)
20942 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20943 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20944 v4si __builtin_ia32_psubd128 (v4si, v4si)
20945 v2di __builtin_ia32_psubq128 (v2di, v2di)
20946 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20947 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20948 v2di __builtin_ia32_pand128 (v2di, v2di)
20949 v2di __builtin_ia32_pandn128 (v2di, v2di)
20950 v2di __builtin_ia32_por128 (v2di, v2di)
20951 v2di __builtin_ia32_pxor128 (v2di, v2di)
20952 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20953 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20954 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20955 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20956 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20957 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20958 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20959 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20960 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20961 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20962 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20963 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20964 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20965 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20966 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20967 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20968 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20969 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20970 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20971 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20972 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20973 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20974 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20975 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20976 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20977 v2df __builtin_ia32_loadupd (double *)
20978 void __builtin_ia32_storeupd (double *, v2df)
20979 v2df __builtin_ia32_loadhpd (v2df, double const *)
20980 v2df __builtin_ia32_loadlpd (v2df, double const *)
20981 int __builtin_ia32_movmskpd (v2df)
20982 int __builtin_ia32_pmovmskb128 (v16qi)
20983 void __builtin_ia32_movnti (int *, int)
20984 void __builtin_ia32_movnti64 (long long int *, long long int)
20985 void __builtin_ia32_movntpd (double *, v2df)
20986 void __builtin_ia32_movntdq (v2df *, v2df)
20987 v4si __builtin_ia32_pshufd (v4si, int)
20988 v8hi __builtin_ia32_pshuflw (v8hi, int)
20989 v8hi __builtin_ia32_pshufhw (v8hi, int)
20990 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20991 v2df __builtin_ia32_sqrtpd (v2df)
20992 v2df __builtin_ia32_sqrtsd (v2df)
20993 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20994 v2df __builtin_ia32_cvtdq2pd (v4si)
20995 v4sf __builtin_ia32_cvtdq2ps (v4si)
20996 v4si __builtin_ia32_cvtpd2dq (v2df)
20997 v2si __builtin_ia32_cvtpd2pi (v2df)
20998 v4sf __builtin_ia32_cvtpd2ps (v2df)
20999 v4si __builtin_ia32_cvttpd2dq (v2df)
21000 v2si __builtin_ia32_cvttpd2pi (v2df)
21001 v2df __builtin_ia32_cvtpi2pd (v2si)
21002 int __builtin_ia32_cvtsd2si (v2df)
21003 int __builtin_ia32_cvttsd2si (v2df)
21004 long long __builtin_ia32_cvtsd2si64 (v2df)
21005 long long __builtin_ia32_cvttsd2si64 (v2df)
21006 v4si __builtin_ia32_cvtps2dq (v4sf)
21007 v2df __builtin_ia32_cvtps2pd (v4sf)
21008 v4si __builtin_ia32_cvttps2dq (v4sf)
21009 v2df __builtin_ia32_cvtsi2sd (v2df, int)
21010 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
21011 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
21012 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
21013 void __builtin_ia32_clflush (const void *)
21014 void __builtin_ia32_lfence (void)
21015 void __builtin_ia32_mfence (void)
21016 v16qi __builtin_ia32_loaddqu (const char *)
21017 void __builtin_ia32_storedqu (char *, v16qi)
21018 v1di __builtin_ia32_pmuludq (v2si, v2si)
21019 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
21020 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
21021 v4si __builtin_ia32_pslld128 (v4si, v4si)
21022 v2di __builtin_ia32_psllq128 (v2di, v2di)
21023 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
21024 v4si __builtin_ia32_psrld128 (v4si, v4si)
21025 v2di __builtin_ia32_psrlq128 (v2di, v2di)
21026 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
21027 v4si __builtin_ia32_psrad128 (v4si, v4si)
21028 v2di __builtin_ia32_pslldqi128 (v2di, int)
21029 v8hi __builtin_ia32_psllwi128 (v8hi, int)
21030 v4si __builtin_ia32_pslldi128 (v4si, int)
21031 v2di __builtin_ia32_psllqi128 (v2di, int)
21032 v2di __builtin_ia32_psrldqi128 (v2di, int)
21033 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
21034 v4si __builtin_ia32_psrldi128 (v4si, int)
21035 v2di __builtin_ia32_psrlqi128 (v2di, int)
21036 v8hi __builtin_ia32_psrawi128 (v8hi, int)
21037 v4si __builtin_ia32_psradi128 (v4si, int)
21038 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
21039 v2di __builtin_ia32_movq128 (v2di)
21040 @end smallexample
21041
21042 The following built-in functions are available when @option{-msse3} is used.
21043 All of them generate the machine instruction that is part of the name.
21044
21045 @smallexample
21046 v2df __builtin_ia32_addsubpd (v2df, v2df)
21047 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
21048 v2df __builtin_ia32_haddpd (v2df, v2df)
21049 v4sf __builtin_ia32_haddps (v4sf, v4sf)
21050 v2df __builtin_ia32_hsubpd (v2df, v2df)
21051 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
21052 v16qi __builtin_ia32_lddqu (char const *)
21053 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
21054 v4sf __builtin_ia32_movshdup (v4sf)
21055 v4sf __builtin_ia32_movsldup (v4sf)
21056 void __builtin_ia32_mwait (unsigned int, unsigned int)
21057 @end smallexample
21058
21059 The following built-in functions are available when @option{-mssse3} is used.
21060 All of them generate the machine instruction that is part of the name.
21061
21062 @smallexample
21063 v2si __builtin_ia32_phaddd (v2si, v2si)
21064 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21065 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21066 v2si __builtin_ia32_phsubd (v2si, v2si)
21067 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21068 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21069 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21070 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21071 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21072 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21073 v2si __builtin_ia32_psignd (v2si, v2si)
21074 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21075 v1di __builtin_ia32_palignr (v1di, v1di, int)
21076 v8qi __builtin_ia32_pabsb (v8qi)
21077 v2si __builtin_ia32_pabsd (v2si)
21078 v4hi __builtin_ia32_pabsw (v4hi)
21079 @end smallexample
21080
21081 The following built-in functions are available when @option{-mssse3} is used.
21082 All of them generate the machine instruction that is part of the name.
21083
21084 @smallexample
21085 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21086 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21087 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21088 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21089 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21090 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21091 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21092 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21093 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21094 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21095 v4si __builtin_ia32_psignd128 (v4si, v4si)
21096 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21097 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21098 v16qi __builtin_ia32_pabsb128 (v16qi)
21099 v4si __builtin_ia32_pabsd128 (v4si)
21100 v8hi __builtin_ia32_pabsw128 (v8hi)
21101 @end smallexample
21102
21103 The following built-in functions are available when @option{-msse4.1} is
21104 used. All of them generate the machine instruction that is part of the
21105 name.
21106
21107 @smallexample
21108 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21109 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21110 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21111 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21112 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21113 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21114 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21115 v2di __builtin_ia32_movntdqa (v2di *);
21116 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21117 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21118 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21119 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21120 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21121 v8hi __builtin_ia32_phminposuw128 (v8hi)
21122 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21123 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21124 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21125 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21126 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21127 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21128 v4si __builtin_ia32_pminud128 (v4si, v4si)
21129 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21130 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21131 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21132 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21133 v2di __builtin_ia32_pmovsxdq128 (v4si)
21134 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21135 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21136 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21137 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21138 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21139 v2di __builtin_ia32_pmovzxdq128 (v4si)
21140 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21141 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21142 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21143 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21144 int __builtin_ia32_ptestc128 (v2di, v2di)
21145 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21146 int __builtin_ia32_ptestz128 (v2di, v2di)
21147 v2df __builtin_ia32_roundpd (v2df, const int)
21148 v4sf __builtin_ia32_roundps (v4sf, const int)
21149 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21150 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21151 @end smallexample
21152
21153 The following built-in functions are available when @option{-msse4.1} is
21154 used.
21155
21156 @table @code
21157 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21158 Generates the @code{insertps} machine instruction.
21159 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21160 Generates the @code{pextrb} machine instruction.
21161 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21162 Generates the @code{pinsrb} machine instruction.
21163 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21164 Generates the @code{pinsrd} machine instruction.
21165 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21166 Generates the @code{pinsrq} machine instruction in 64bit mode.
21167 @end table
21168
21169 The following built-in functions are changed to generate new SSE4.1
21170 instructions when @option{-msse4.1} is used.
21171
21172 @table @code
21173 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
21174 Generates the @code{extractps} machine instruction.
21175 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
21176 Generates the @code{pextrd} machine instruction.
21177 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
21178 Generates the @code{pextrq} machine instruction in 64bit mode.
21179 @end table
21180
21181 The following built-in functions are available when @option{-msse4.2} is
21182 used. All of them generate the machine instruction that is part of the
21183 name.
21184
21185 @smallexample
21186 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21187 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21188 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21189 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21190 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21191 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21192 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21193 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
21194 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
21195 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
21196 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
21197 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
21198 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
21199 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
21200 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
21201 @end smallexample
21202
21203 The following built-in functions are available when @option{-msse4.2} is
21204 used.
21205
21206 @table @code
21207 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
21208 Generates the @code{crc32b} machine instruction.
21209 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
21210 Generates the @code{crc32w} machine instruction.
21211 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
21212 Generates the @code{crc32l} machine instruction.
21213 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
21214 Generates the @code{crc32q} machine instruction.
21215 @end table
21216
21217 The following built-in functions are changed to generate new SSE4.2
21218 instructions when @option{-msse4.2} is used.
21219
21220 @table @code
21221 @item int __builtin_popcount (unsigned int)
21222 Generates the @code{popcntl} machine instruction.
21223 @item int __builtin_popcountl (unsigned long)
21224 Generates the @code{popcntl} or @code{popcntq} machine instruction,
21225 depending on the size of @code{unsigned long}.
21226 @item int __builtin_popcountll (unsigned long long)
21227 Generates the @code{popcntq} machine instruction.
21228 @end table
21229
21230 The following built-in functions are available when @option{-mavx} is
21231 used. All of them generate the machine instruction that is part of the
21232 name.
21233
21234 @smallexample
21235 v4df __builtin_ia32_addpd256 (v4df,v4df)
21236 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
21237 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
21238 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
21239 v4df __builtin_ia32_andnpd256 (v4df,v4df)
21240 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
21241 v4df __builtin_ia32_andpd256 (v4df,v4df)
21242 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
21243 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
21244 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
21245 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
21246 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
21247 v2df __builtin_ia32_cmppd (v2df,v2df,int)
21248 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
21249 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
21250 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
21251 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
21252 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
21253 v4df __builtin_ia32_cvtdq2pd256 (v4si)
21254 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
21255 v4si __builtin_ia32_cvtpd2dq256 (v4df)
21256 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
21257 v8si __builtin_ia32_cvtps2dq256 (v8sf)
21258 v4df __builtin_ia32_cvtps2pd256 (v4sf)
21259 v4si __builtin_ia32_cvttpd2dq256 (v4df)
21260 v8si __builtin_ia32_cvttps2dq256 (v8sf)
21261 v4df __builtin_ia32_divpd256 (v4df,v4df)
21262 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
21263 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
21264 v4df __builtin_ia32_haddpd256 (v4df,v4df)
21265 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
21266 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
21267 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
21268 v32qi __builtin_ia32_lddqu256 (pcchar)
21269 v32qi __builtin_ia32_loaddqu256 (pcchar)
21270 v4df __builtin_ia32_loadupd256 (pcdouble)
21271 v8sf __builtin_ia32_loadups256 (pcfloat)
21272 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
21273 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
21274 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
21275 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
21276 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
21277 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
21278 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
21279 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
21280 v4df __builtin_ia32_maxpd256 (v4df,v4df)
21281 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
21282 v4df __builtin_ia32_minpd256 (v4df,v4df)
21283 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
21284 v4df __builtin_ia32_movddup256 (v4df)
21285 int __builtin_ia32_movmskpd256 (v4df)
21286 int __builtin_ia32_movmskps256 (v8sf)
21287 v8sf __builtin_ia32_movshdup256 (v8sf)
21288 v8sf __builtin_ia32_movsldup256 (v8sf)
21289 v4df __builtin_ia32_mulpd256 (v4df,v4df)
21290 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
21291 v4df __builtin_ia32_orpd256 (v4df,v4df)
21292 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
21293 v2df __builtin_ia32_pd_pd256 (v4df)
21294 v4df __builtin_ia32_pd256_pd (v2df)
21295 v4sf __builtin_ia32_ps_ps256 (v8sf)
21296 v8sf __builtin_ia32_ps256_ps (v4sf)
21297 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21298 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21299 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21300 v8sf __builtin_ia32_rcpps256 (v8sf)
21301 v4df __builtin_ia32_roundpd256 (v4df,int)
21302 v8sf __builtin_ia32_roundps256 (v8sf,int)
21303 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21304 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21305 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21306 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21307 v4si __builtin_ia32_si_si256 (v8si)
21308 v8si __builtin_ia32_si256_si (v4si)
21309 v4df __builtin_ia32_sqrtpd256 (v4df)
21310 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21311 v8sf __builtin_ia32_sqrtps256 (v8sf)
21312 void __builtin_ia32_storedqu256 (pchar,v32qi)
21313 void __builtin_ia32_storeupd256 (pdouble,v4df)
21314 void __builtin_ia32_storeups256 (pfloat,v8sf)
21315 v4df __builtin_ia32_subpd256 (v4df,v4df)
21316 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21317 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21318 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21319 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21320 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21321 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21322 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21323 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21324 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21325 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21326 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21327 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21328 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21329 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21330 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21331 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21332 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21333 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21334 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21335 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21336 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21337 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21338 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21339 v2df __builtin_ia32_vpermilpd (v2df,int)
21340 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21341 v4sf __builtin_ia32_vpermilps (v4sf,int)
21342 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21343 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21344 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21345 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21346 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21347 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21348 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21349 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21350 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21351 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21352 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21353 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21354 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21355 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21356 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21357 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21358 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21359 void __builtin_ia32_vzeroall (void)
21360 void __builtin_ia32_vzeroupper (void)
21361 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21362 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21363 @end smallexample
21364
21365 The following built-in functions are available when @option{-mavx2} is
21366 used. All of them generate the machine instruction that is part of the
21367 name.
21368
21369 @smallexample
21370 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21371 v32qi __builtin_ia32_pabsb256 (v32qi)
21372 v16hi __builtin_ia32_pabsw256 (v16hi)
21373 v8si __builtin_ia32_pabsd256 (v8si)
21374 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21375 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21376 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21377 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21378 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21379 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21380 v8si __builtin_ia32_paddd256 (v8si,v8si)
21381 v4di __builtin_ia32_paddq256 (v4di,v4di)
21382 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21383 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21384 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21385 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21386 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21387 v4di __builtin_ia32_andsi256 (v4di,v4di)
21388 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21389 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21390 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21391 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21392 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21393 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21394 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21395 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21396 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21397 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21398 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21399 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21400 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21401 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21402 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21403 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21404 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21405 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21406 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21407 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21408 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21409 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21410 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21411 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21412 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21413 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21414 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21415 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21416 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21417 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21418 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21419 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21420 v8si __builtin_ia32_pminud256 (v8si,v8si)
21421 int __builtin_ia32_pmovmskb256 (v32qi)
21422 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21423 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21424 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21425 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21426 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21427 v4di __builtin_ia32_pmovsxdq256 (v4si)
21428 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21429 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21430 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21431 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21432 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21433 v4di __builtin_ia32_pmovzxdq256 (v4si)
21434 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21435 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21436 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21437 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21438 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21439 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21440 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21441 v4di __builtin_ia32_por256 (v4di,v4di)
21442 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21443 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21444 v8si __builtin_ia32_pshufd256 (v8si,int)
21445 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21446 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21447 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21448 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21449 v8si __builtin_ia32_psignd256 (v8si,v8si)
21450 v4di __builtin_ia32_pslldqi256 (v4di,int)
21451 v16hi __builtin_ia32_psllwi256 (16hi,int)
21452 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21453 v8si __builtin_ia32_pslldi256 (v8si,int)
21454 v8si __builtin_ia32_pslld256(v8si,v4si)
21455 v4di __builtin_ia32_psllqi256 (v4di,int)
21456 v4di __builtin_ia32_psllq256(v4di,v2di)
21457 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21458 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21459 v8si __builtin_ia32_psradi256 (v8si,int)
21460 v8si __builtin_ia32_psrad256 (v8si,v4si)
21461 v4di __builtin_ia32_psrldqi256 (v4di, int)
21462 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21463 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21464 v8si __builtin_ia32_psrldi256 (v8si,int)
21465 v8si __builtin_ia32_psrld256 (v8si,v4si)
21466 v4di __builtin_ia32_psrlqi256 (v4di,int)
21467 v4di __builtin_ia32_psrlq256(v4di,v2di)
21468 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21469 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21470 v8si __builtin_ia32_psubd256 (v8si,v8si)
21471 v4di __builtin_ia32_psubq256 (v4di,v4di)
21472 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21473 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21474 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21475 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21476 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21477 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21478 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21479 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21480 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21481 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21482 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21483 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21484 v4di __builtin_ia32_pxor256 (v4di,v4di)
21485 v4di __builtin_ia32_movntdqa256 (pv4di)
21486 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21487 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21488 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21489 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21490 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21491 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21492 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21493 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21494 v8si __builtin_ia32_pbroadcastd256 (v4si)
21495 v4di __builtin_ia32_pbroadcastq256 (v2di)
21496 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21497 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21498 v4si __builtin_ia32_pbroadcastd128 (v4si)
21499 v2di __builtin_ia32_pbroadcastq128 (v2di)
21500 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21501 v4df __builtin_ia32_permdf256 (v4df,int)
21502 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21503 v4di __builtin_ia32_permdi256 (v4di,int)
21504 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21505 v4di __builtin_ia32_extract128i256 (v4di,int)
21506 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21507 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21508 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21509 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21510 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21511 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21512 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21513 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21514 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21515 v8si __builtin_ia32_psllv8si (v8si,v8si)
21516 v4si __builtin_ia32_psllv4si (v4si,v4si)
21517 v4di __builtin_ia32_psllv4di (v4di,v4di)
21518 v2di __builtin_ia32_psllv2di (v2di,v2di)
21519 v8si __builtin_ia32_psrav8si (v8si,v8si)
21520 v4si __builtin_ia32_psrav4si (v4si,v4si)
21521 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21522 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21523 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21524 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21525 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21526 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21527 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21528 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21529 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21530 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21531 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21532 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21533 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21534 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21535 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21536 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21537 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21538 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21539 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21540 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21541 @end smallexample
21542
21543 The following built-in functions are available when @option{-maes} is
21544 used. All of them generate the machine instruction that is part of the
21545 name.
21546
21547 @smallexample
21548 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21549 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21550 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21551 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21552 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21553 v2di __builtin_ia32_aesimc128 (v2di)
21554 @end smallexample
21555
21556 The following built-in function is available when @option{-mpclmul} is
21557 used.
21558
21559 @table @code
21560 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21561 Generates the @code{pclmulqdq} machine instruction.
21562 @end table
21563
21564 The following built-in function is available when @option{-mfsgsbase} is
21565 used. All of them generate the machine instruction that is part of the
21566 name.
21567
21568 @smallexample
21569 unsigned int __builtin_ia32_rdfsbase32 (void)
21570 unsigned long long __builtin_ia32_rdfsbase64 (void)
21571 unsigned int __builtin_ia32_rdgsbase32 (void)
21572 unsigned long long __builtin_ia32_rdgsbase64 (void)
21573 void _writefsbase_u32 (unsigned int)
21574 void _writefsbase_u64 (unsigned long long)
21575 void _writegsbase_u32 (unsigned int)
21576 void _writegsbase_u64 (unsigned long long)
21577 @end smallexample
21578
21579 The following built-in function is available when @option{-mrdrnd} is
21580 used. All of them generate the machine instruction that is part of the
21581 name.
21582
21583 @smallexample
21584 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21585 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21586 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21587 @end smallexample
21588
21589 The following built-in functions are available when @option{-msse4a} is used.
21590 All of them generate the machine instruction that is part of the name.
21591
21592 @smallexample
21593 void __builtin_ia32_movntsd (double *, v2df)
21594 void __builtin_ia32_movntss (float *, v4sf)
21595 v2di __builtin_ia32_extrq (v2di, v16qi)
21596 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21597 v2di __builtin_ia32_insertq (v2di, v2di)
21598 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21599 @end smallexample
21600
21601 The following built-in functions are available when @option{-mxop} is used.
21602 @smallexample
21603 v2df __builtin_ia32_vfrczpd (v2df)
21604 v4sf __builtin_ia32_vfrczps (v4sf)
21605 v2df __builtin_ia32_vfrczsd (v2df)
21606 v4sf __builtin_ia32_vfrczss (v4sf)
21607 v4df __builtin_ia32_vfrczpd256 (v4df)
21608 v8sf __builtin_ia32_vfrczps256 (v8sf)
21609 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21610 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21611 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21612 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21613 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21614 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21615 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21616 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21617 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21618 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21619 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21620 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21621 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21622 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21623 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21624 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21625 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21626 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21627 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21628 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21629 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21630 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21631 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21632 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21633 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21634 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21635 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21636 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21637 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21638 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21639 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21640 v4si __builtin_ia32_vpcomged (v4si, v4si)
21641 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21642 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21643 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21644 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21645 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21646 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21647 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21648 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21649 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21650 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21651 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21652 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21653 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21654 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21655 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21656 v4si __builtin_ia32_vpcomled (v4si, v4si)
21657 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21658 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21659 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21660 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21661 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21662 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21663 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21664 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21665 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21666 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21667 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21668 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21669 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21670 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21671 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21672 v4si __builtin_ia32_vpcomned (v4si, v4si)
21673 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21674 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21675 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21676 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21677 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21678 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21679 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21680 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21681 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21682 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21683 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21684 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21685 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21686 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21687 v4si __builtin_ia32_vphaddbd (v16qi)
21688 v2di __builtin_ia32_vphaddbq (v16qi)
21689 v8hi __builtin_ia32_vphaddbw (v16qi)
21690 v2di __builtin_ia32_vphadddq (v4si)
21691 v4si __builtin_ia32_vphaddubd (v16qi)
21692 v2di __builtin_ia32_vphaddubq (v16qi)
21693 v8hi __builtin_ia32_vphaddubw (v16qi)
21694 v2di __builtin_ia32_vphaddudq (v4si)
21695 v4si __builtin_ia32_vphadduwd (v8hi)
21696 v2di __builtin_ia32_vphadduwq (v8hi)
21697 v4si __builtin_ia32_vphaddwd (v8hi)
21698 v2di __builtin_ia32_vphaddwq (v8hi)
21699 v8hi __builtin_ia32_vphsubbw (v16qi)
21700 v2di __builtin_ia32_vphsubdq (v4si)
21701 v4si __builtin_ia32_vphsubwd (v8hi)
21702 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21703 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21704 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21705 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21706 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21707 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21708 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21709 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21710 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21711 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21712 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21713 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21714 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21715 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21716 v4si __builtin_ia32_vprotd (v4si, v4si)
21717 v2di __builtin_ia32_vprotq (v2di, v2di)
21718 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21719 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21720 v4si __builtin_ia32_vpshad (v4si, v4si)
21721 v2di __builtin_ia32_vpshaq (v2di, v2di)
21722 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21723 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21724 v4si __builtin_ia32_vpshld (v4si, v4si)
21725 v2di __builtin_ia32_vpshlq (v2di, v2di)
21726 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21727 @end smallexample
21728
21729 The following built-in functions are available when @option{-mfma4} is used.
21730 All of them generate the machine instruction that is part of the name.
21731
21732 @smallexample
21733 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21734 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21735 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21736 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21737 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21738 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21739 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21740 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21741 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21742 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21743 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21744 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21745 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21746 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21747 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21748 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21749 v2df __builtin_ia32_vfmaddsubpd (v2df, v2df, v2df)
21750 v4sf __builtin_ia32_vfmaddsubps (v4sf, v4sf, v4sf)
21751 v2df __builtin_ia32_vfmsubaddpd (v2df, v2df, v2df)
21752 v4sf __builtin_ia32_vfmsubaddps (v4sf, v4sf, v4sf)
21753 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21754 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21755 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21756 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21757 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21758 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21759 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21760 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21761 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21762 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21763 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21764 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21765
21766 @end smallexample
21767
21768 The following built-in functions are available when @option{-mlwp} is used.
21769
21770 @smallexample
21771 void __builtin_ia32_llwpcb16 (void *);
21772 void __builtin_ia32_llwpcb32 (void *);
21773 void __builtin_ia32_llwpcb64 (void *);
21774 void * __builtin_ia32_llwpcb16 (void);
21775 void * __builtin_ia32_llwpcb32 (void);
21776 void * __builtin_ia32_llwpcb64 (void);
21777 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21778 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21779 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21780 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21781 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21782 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21783 @end smallexample
21784
21785 The following built-in functions are available when @option{-mbmi} is used.
21786 All of them generate the machine instruction that is part of the name.
21787 @smallexample
21788 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21789 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21790 @end smallexample
21791
21792 The following built-in functions are available when @option{-mbmi2} is used.
21793 All of them generate the machine instruction that is part of the name.
21794 @smallexample
21795 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21796 unsigned int _pdep_u32 (unsigned int, unsigned int)
21797 unsigned int _pext_u32 (unsigned int, unsigned int)
21798 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21799 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21800 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21801 @end smallexample
21802
21803 The following built-in functions are available when @option{-mlzcnt} is used.
21804 All of them generate the machine instruction that is part of the name.
21805 @smallexample
21806 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21807 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21808 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21809 @end smallexample
21810
21811 The following built-in functions are available when @option{-mfxsr} is used.
21812 All of them generate the machine instruction that is part of the name.
21813 @smallexample
21814 void __builtin_ia32_fxsave (void *)
21815 void __builtin_ia32_fxrstor (void *)
21816 void __builtin_ia32_fxsave64 (void *)
21817 void __builtin_ia32_fxrstor64 (void *)
21818 @end smallexample
21819
21820 The following built-in functions are available when @option{-mxsave} is used.
21821 All of them generate the machine instruction that is part of the name.
21822 @smallexample
21823 void __builtin_ia32_xsave (void *, long long)
21824 void __builtin_ia32_xrstor (void *, long long)
21825 void __builtin_ia32_xsave64 (void *, long long)
21826 void __builtin_ia32_xrstor64 (void *, long long)
21827 @end smallexample
21828
21829 The following built-in functions are available when @option{-mxsaveopt} is used.
21830 All of them generate the machine instruction that is part of the name.
21831 @smallexample
21832 void __builtin_ia32_xsaveopt (void *, long long)
21833 void __builtin_ia32_xsaveopt64 (void *, long long)
21834 @end smallexample
21835
21836 The following built-in functions are available when @option{-mtbm} is used.
21837 Both of them generate the immediate form of the bextr machine instruction.
21838 @smallexample
21839 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21840 const unsigned int);
21841 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21842 const unsigned long long);
21843 @end smallexample
21844
21845
21846 The following built-in functions are available when @option{-m3dnow} is used.
21847 All of them generate the machine instruction that is part of the name.
21848
21849 @smallexample
21850 void __builtin_ia32_femms (void)
21851 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21852 v2si __builtin_ia32_pf2id (v2sf)
21853 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21854 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21855 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21856 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21857 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21858 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21859 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21860 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21861 v2sf __builtin_ia32_pfrcp (v2sf)
21862 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21863 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21864 v2sf __builtin_ia32_pfrsqrt (v2sf)
21865 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21866 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21867 v2sf __builtin_ia32_pi2fd (v2si)
21868 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21869 @end smallexample
21870
21871 The following built-in functions are available when @option{-m3dnowa} is used.
21872 All of them generate the machine instruction that is part of the name.
21873
21874 @smallexample
21875 v2si __builtin_ia32_pf2iw (v2sf)
21876 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21877 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21878 v2sf __builtin_ia32_pi2fw (v2si)
21879 v2sf __builtin_ia32_pswapdsf (v2sf)
21880 v2si __builtin_ia32_pswapdsi (v2si)
21881 @end smallexample
21882
21883 The following built-in functions are available when @option{-mrtm} is used
21884 They are used for restricted transactional memory. These are the internal
21885 low level functions. Normally the functions in
21886 @ref{x86 transactional memory intrinsics} should be used instead.
21887
21888 @smallexample
21889 int __builtin_ia32_xbegin ()
21890 void __builtin_ia32_xend ()
21891 void __builtin_ia32_xabort (status)
21892 int __builtin_ia32_xtest ()
21893 @end smallexample
21894
21895 The following built-in functions are available when @option{-mmwaitx} is used.
21896 All of them generate the machine instruction that is part of the name.
21897 @smallexample
21898 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21899 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21900 @end smallexample
21901
21902 The following built-in functions are available when @option{-mclzero} is used.
21903 All of them generate the machine instruction that is part of the name.
21904 @smallexample
21905 void __builtin_i32_clzero (void *)
21906 @end smallexample
21907
21908 The following built-in functions are available when @option{-mpku} is used.
21909 They generate reads and writes to PKRU.
21910 @smallexample
21911 void __builtin_ia32_wrpkru (unsigned int)
21912 unsigned int __builtin_ia32_rdpkru ()
21913 @end smallexample
21914
21915 The following built-in functions are available when @option{-mcet} or
21916 @option{-mshstk} option is used. They support shadow stack
21917 machine instructions from Intel Control-flow Enforcement Technology (CET).
21918 Each built-in function generates the machine instruction that is part
21919 of the function's name. These are the internal low-level functions.
21920 Normally the functions in @ref{x86 control-flow protection intrinsics}
21921 should be used instead.
21922
21923 @smallexample
21924 unsigned int __builtin_ia32_rdsspd (void)
21925 unsigned long long __builtin_ia32_rdsspq (void)
21926 void __builtin_ia32_incsspd (unsigned int)
21927 void __builtin_ia32_incsspq (unsigned long long)
21928 void __builtin_ia32_saveprevssp(void);
21929 void __builtin_ia32_rstorssp(void *);
21930 void __builtin_ia32_wrssd(unsigned int, void *);
21931 void __builtin_ia32_wrssq(unsigned long long, void *);
21932 void __builtin_ia32_wrussd(unsigned int, void *);
21933 void __builtin_ia32_wrussq(unsigned long long, void *);
21934 void __builtin_ia32_setssbsy(void);
21935 void __builtin_ia32_clrssbsy(void *);
21936 @end smallexample
21937
21938 @node x86 transactional memory intrinsics
21939 @subsection x86 Transactional Memory Intrinsics
21940
21941 These hardware transactional memory intrinsics for x86 allow you to use
21942 memory transactions with RTM (Restricted Transactional Memory).
21943 This support is enabled with the @option{-mrtm} option.
21944 For using HLE (Hardware Lock Elision) see
21945 @ref{x86 specific memory model extensions for transactional memory} instead.
21946
21947 A memory transaction commits all changes to memory in an atomic way,
21948 as visible to other threads. If the transaction fails it is rolled back
21949 and all side effects discarded.
21950
21951 Generally there is no guarantee that a memory transaction ever succeeds
21952 and suitable fallback code always needs to be supplied.
21953
21954 @deftypefn {RTM Function} {unsigned} _xbegin ()
21955 Start a RTM (Restricted Transactional Memory) transaction.
21956 Returns @code{_XBEGIN_STARTED} when the transaction
21957 started successfully (note this is not 0, so the constant has to be
21958 explicitly tested).
21959
21960 If the transaction aborts, all side effects
21961 are undone and an abort code encoded as a bit mask is returned.
21962 The following macros are defined:
21963
21964 @table @code
21965 @item _XABORT_EXPLICIT
21966 Transaction was explicitly aborted with @code{_xabort}. The parameter passed
21967 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21968 @item _XABORT_RETRY
21969 Transaction retry is possible.
21970 @item _XABORT_CONFLICT
21971 Transaction abort due to a memory conflict with another thread.
21972 @item _XABORT_CAPACITY
21973 Transaction abort due to the transaction using too much memory.
21974 @item _XABORT_DEBUG
21975 Transaction abort due to a debug trap.
21976 @item _XABORT_NESTED
21977 Transaction abort in an inner nested transaction.
21978 @end table
21979
21980 There is no guarantee
21981 any transaction ever succeeds, so there always needs to be a valid
21982 fallback path.
21983 @end deftypefn
21984
21985 @deftypefn {RTM Function} {void} _xend ()
21986 Commit the current transaction. When no transaction is active this faults.
21987 All memory side effects of the transaction become visible
21988 to other threads in an atomic manner.
21989 @end deftypefn
21990
21991 @deftypefn {RTM Function} {int} _xtest ()
21992 Return a nonzero value if a transaction is currently active, otherwise 0.
21993 @end deftypefn
21994
21995 @deftypefn {RTM Function} {void} _xabort (status)
21996 Abort the current transaction. When no transaction is active this is a no-op.
21997 The @var{status} is an 8-bit constant; its value is encoded in the return
21998 value from @code{_xbegin}.
21999 @end deftypefn
22000
22001 Here is an example showing handling for @code{_XABORT_RETRY}
22002 and a fallback path for other failures:
22003
22004 @smallexample
22005 #include <immintrin.h>
22006
22007 int n_tries, max_tries;
22008 unsigned status = _XABORT_EXPLICIT;
22009 ...
22010
22011 for (n_tries = 0; n_tries < max_tries; n_tries++)
22012 @{
22013 status = _xbegin ();
22014 if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
22015 break;
22016 @}
22017 if (status == _XBEGIN_STARTED)
22018 @{
22019 ... transaction code...
22020 _xend ();
22021 @}
22022 else
22023 @{
22024 ... non-transactional fallback path...
22025 @}
22026 @end smallexample
22027
22028 @noindent
22029 Note that, in most cases, the transactional and non-transactional code
22030 must synchronize together to ensure consistency.
22031
22032 @node x86 control-flow protection intrinsics
22033 @subsection x86 Control-Flow Protection Intrinsics
22034
22035 @deftypefn {CET Function} {ret_type} _get_ssp (void)
22036 Get the current value of shadow stack pointer if shadow stack support
22037 from Intel CET is enabled in the hardware or @code{0} otherwise.
22038 The @code{ret_type} is @code{unsigned long long} for 64-bit targets
22039 and @code{unsigned int} for 32-bit targets.
22040 @end deftypefn
22041
22042 @deftypefn {CET Function} void _inc_ssp (unsigned int)
22043 Increment the current shadow stack pointer by the size specified by the
22044 function argument. The argument is masked to a byte value for security
22045 reasons, so to increment by more than 255 bytes you must call the function
22046 multiple times.
22047 @end deftypefn
22048
22049 The shadow stack unwind code looks like:
22050
22051 @smallexample
22052 #include <immintrin.h>
22053
22054 /* Unwind the shadow stack for EH. */
22055 #define _Unwind_Frames_Extra(x) \
22056 do \
22057 @{ \
22058 _Unwind_Word ssp = _get_ssp (); \
22059 if (ssp != 0) \
22060 @{ \
22061 _Unwind_Word tmp = (x); \
22062 while (tmp > 255) \
22063 @{ \
22064 _inc_ssp (tmp); \
22065 tmp -= 255; \
22066 @} \
22067 _inc_ssp (tmp); \
22068 @} \
22069 @} \
22070 while (0)
22071 @end smallexample
22072
22073 @noindent
22074 This code runs unconditionally on all 64-bit processors. For 32-bit
22075 processors the code runs on those that support multi-byte NOP instructions.
22076
22077 @node Target Format Checks
22078 @section Format Checks Specific to Particular Target Machines
22079
22080 For some target machines, GCC supports additional options to the
22081 format attribute
22082 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22083
22084 @menu
22085 * Solaris Format Checks::
22086 * Darwin Format Checks::
22087 @end menu
22088
22089 @node Solaris Format Checks
22090 @subsection Solaris Format Checks
22091
22092 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22093 check. @code{cmn_err} accepts a subset of the standard @code{printf}
22094 conversions, and the two-argument @code{%b} conversion for displaying
22095 bit-fields. See the Solaris man page for @code{cmn_err} for more information.
22096
22097 @node Darwin Format Checks
22098 @subsection Darwin Format Checks
22099
22100 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
22101 attribute context. Declarations made with such attribution are parsed for correct syntax
22102 and format argument types. However, parsing of the format string itself is currently undefined
22103 and is not carried out by this version of the compiler.
22104
22105 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22106 also be used as format arguments. Note that the relevant headers are only likely to be
22107 available on Darwin (OSX) installations. On such installations, the XCode and system
22108 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22109 associated functions.
22110
22111 @node Pragmas
22112 @section Pragmas Accepted by GCC
22113 @cindex pragmas
22114 @cindex @code{#pragma}
22115
22116 GCC supports several types of pragmas, primarily in order to compile
22117 code originally written for other compilers. Note that in general
22118 we do not recommend the use of pragmas; @xref{Function Attributes},
22119 for further explanation.
22120
22121 @menu
22122 * AArch64 Pragmas::
22123 * ARM Pragmas::
22124 * M32C Pragmas::
22125 * MeP Pragmas::
22126 * RS/6000 and PowerPC Pragmas::
22127 * S/390 Pragmas::
22128 * Darwin Pragmas::
22129 * Solaris Pragmas::
22130 * Symbol-Renaming Pragmas::
22131 * Structure-Layout Pragmas::
22132 * Weak Pragmas::
22133 * Diagnostic Pragmas::
22134 * Visibility Pragmas::
22135 * Push/Pop Macro Pragmas::
22136 * Function Specific Option Pragmas::
22137 * Loop-Specific Pragmas::
22138 @end menu
22139
22140 @node AArch64 Pragmas
22141 @subsection AArch64 Pragmas
22142
22143 The pragmas defined by the AArch64 target correspond to the AArch64
22144 target function attributes. They can be specified as below:
22145 @smallexample
22146 #pragma GCC target("string")
22147 @end smallexample
22148
22149 where @code{@var{string}} can be any string accepted as an AArch64 target
22150 attribute. @xref{AArch64 Function Attributes}, for more details
22151 on the permissible values of @code{string}.
22152
22153 @node ARM Pragmas
22154 @subsection ARM Pragmas
22155
22156 The ARM target defines pragmas for controlling the default addition of
22157 @code{long_call} and @code{short_call} attributes to functions.
22158 @xref{Function Attributes}, for information about the effects of these
22159 attributes.
22160
22161 @table @code
22162 @item long_calls
22163 @cindex pragma, long_calls
22164 Set all subsequent functions to have the @code{long_call} attribute.
22165
22166 @item no_long_calls
22167 @cindex pragma, no_long_calls
22168 Set all subsequent functions to have the @code{short_call} attribute.
22169
22170 @item long_calls_off
22171 @cindex pragma, long_calls_off
22172 Do not affect the @code{long_call} or @code{short_call} attributes of
22173 subsequent functions.
22174 @end table
22175
22176 @node M32C Pragmas
22177 @subsection M32C Pragmas
22178
22179 @table @code
22180 @item GCC memregs @var{number}
22181 @cindex pragma, memregs
22182 Overrides the command-line option @code{-memregs=} for the current
22183 file. Use with care! This pragma must be before any function in the
22184 file, and mixing different memregs values in different objects may
22185 make them incompatible. This pragma is useful when a
22186 performance-critical function uses a memreg for temporary values,
22187 as it may allow you to reduce the number of memregs used.
22188
22189 @item ADDRESS @var{name} @var{address}
22190 @cindex pragma, address
22191 For any declared symbols matching @var{name}, this does three things
22192 to that symbol: it forces the symbol to be located at the given
22193 address (a number), it forces the symbol to be volatile, and it
22194 changes the symbol's scope to be static. This pragma exists for
22195 compatibility with other compilers, but note that the common
22196 @code{1234H} numeric syntax is not supported (use @code{0x1234}
22197 instead). Example:
22198
22199 @smallexample
22200 #pragma ADDRESS port3 0x103
22201 char port3;
22202 @end smallexample
22203
22204 @end table
22205
22206 @node MeP Pragmas
22207 @subsection MeP Pragmas
22208
22209 @table @code
22210
22211 @item custom io_volatile (on|off)
22212 @cindex pragma, custom io_volatile
22213 Overrides the command-line option @code{-mio-volatile} for the current
22214 file. Note that for compatibility with future GCC releases, this
22215 option should only be used once before any @code{io} variables in each
22216 file.
22217
22218 @item GCC coprocessor available @var{registers}
22219 @cindex pragma, coprocessor available
22220 Specifies which coprocessor registers are available to the register
22221 allocator. @var{registers} may be a single register, register range
22222 separated by ellipses, or comma-separated list of those. Example:
22223
22224 @smallexample
22225 #pragma GCC coprocessor available $c0...$c10, $c28
22226 @end smallexample
22227
22228 @item GCC coprocessor call_saved @var{registers}
22229 @cindex pragma, coprocessor call_saved
22230 Specifies which coprocessor registers are to be saved and restored by
22231 any function using them. @var{registers} may be a single register,
22232 register range separated by ellipses, or comma-separated list of
22233 those. Example:
22234
22235 @smallexample
22236 #pragma GCC coprocessor call_saved $c4...$c6, $c31
22237 @end smallexample
22238
22239 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
22240 @cindex pragma, coprocessor subclass
22241 Creates and defines a register class. These register classes can be
22242 used by inline @code{asm} constructs. @var{registers} may be a single
22243 register, register range separated by ellipses, or comma-separated
22244 list of those. Example:
22245
22246 @smallexample
22247 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
22248
22249 asm ("cpfoo %0" : "=B" (x));
22250 @end smallexample
22251
22252 @item GCC disinterrupt @var{name} , @var{name} @dots{}
22253 @cindex pragma, disinterrupt
22254 For the named functions, the compiler adds code to disable interrupts
22255 for the duration of those functions. If any functions so named
22256 are not encountered in the source, a warning is emitted that the pragma is
22257 not used. Examples:
22258
22259 @smallexample
22260 #pragma disinterrupt foo
22261 #pragma disinterrupt bar, grill
22262 int foo () @{ @dots{} @}
22263 @end smallexample
22264
22265 @item GCC call @var{name} , @var{name} @dots{}
22266 @cindex pragma, call
22267 For the named functions, the compiler always uses a register-indirect
22268 call model when calling the named functions. Examples:
22269
22270 @smallexample
22271 extern int foo ();
22272 #pragma call foo
22273 @end smallexample
22274
22275 @end table
22276
22277 @node RS/6000 and PowerPC Pragmas
22278 @subsection RS/6000 and PowerPC Pragmas
22279
22280 The RS/6000 and PowerPC targets define one pragma for controlling
22281 whether or not the @code{longcall} attribute is added to function
22282 declarations by default. This pragma overrides the @option{-mlongcall}
22283 option, but not the @code{longcall} and @code{shortcall} attributes.
22284 @xref{RS/6000 and PowerPC Options}, for more information about when long
22285 calls are and are not necessary.
22286
22287 @table @code
22288 @item longcall (1)
22289 @cindex pragma, longcall
22290 Apply the @code{longcall} attribute to all subsequent function
22291 declarations.
22292
22293 @item longcall (0)
22294 Do not apply the @code{longcall} attribute to subsequent function
22295 declarations.
22296 @end table
22297
22298 @c Describe h8300 pragmas here.
22299 @c Describe sh pragmas here.
22300 @c Describe v850 pragmas here.
22301
22302 @node S/390 Pragmas
22303 @subsection S/390 Pragmas
22304
22305 The pragmas defined by the S/390 target correspond to the S/390
22306 target function attributes and some the additional options:
22307
22308 @table @samp
22309 @item zvector
22310 @itemx no-zvector
22311 @end table
22312
22313 Note that options of the pragma, unlike options of the target
22314 attribute, do change the value of preprocessor macros like
22315 @code{__VEC__}. They can be specified as below:
22316
22317 @smallexample
22318 #pragma GCC target("string[,string]...")
22319 #pragma GCC target("string"[,"string"]...)
22320 @end smallexample
22321
22322 @node Darwin Pragmas
22323 @subsection Darwin Pragmas
22324
22325 The following pragmas are available for all architectures running the
22326 Darwin operating system. These are useful for compatibility with other
22327 Mac OS compilers.
22328
22329 @table @code
22330 @item mark @var{tokens}@dots{}
22331 @cindex pragma, mark
22332 This pragma is accepted, but has no effect.
22333
22334 @item options align=@var{alignment}
22335 @cindex pragma, options align
22336 This pragma sets the alignment of fields in structures. The values of
22337 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22338 @code{power}, to emulate PowerPC alignment. Uses of this pragma nest
22339 properly; to restore the previous setting, use @code{reset} for the
22340 @var{alignment}.
22341
22342 @item segment @var{tokens}@dots{}
22343 @cindex pragma, segment
22344 This pragma is accepted, but has no effect.
22345
22346 @item unused (@var{var} [, @var{var}]@dots{})
22347 @cindex pragma, unused
22348 This pragma declares variables to be possibly unused. GCC does not
22349 produce warnings for the listed variables. The effect is similar to
22350 that of the @code{unused} attribute, except that this pragma may appear
22351 anywhere within the variables' scopes.
22352 @end table
22353
22354 @node Solaris Pragmas
22355 @subsection Solaris Pragmas
22356
22357 The Solaris target supports @code{#pragma redefine_extname}
22358 (@pxref{Symbol-Renaming Pragmas}). It also supports additional
22359 @code{#pragma} directives for compatibility with the system compiler.
22360
22361 @table @code
22362 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22363 @cindex pragma, align
22364
22365 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22366 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22367 Attributes}). Macro expansion occurs on the arguments to this pragma
22368 when compiling C and Objective-C@. It does not currently occur when
22369 compiling C++, but this is a bug which may be fixed in a future
22370 release.
22371
22372 @item fini (@var{function} [, @var{function}]...)
22373 @cindex pragma, fini
22374
22375 This pragma causes each listed @var{function} to be called after
22376 main, or during shared module unloading, by adding a call to the
22377 @code{.fini} section.
22378
22379 @item init (@var{function} [, @var{function}]...)
22380 @cindex pragma, init
22381
22382 This pragma causes each listed @var{function} to be called during
22383 initialization (before @code{main}) or during shared module loading, by
22384 adding a call to the @code{.init} section.
22385
22386 @end table
22387
22388 @node Symbol-Renaming Pragmas
22389 @subsection Symbol-Renaming Pragmas
22390
22391 GCC supports a @code{#pragma} directive that changes the name used in
22392 assembly for a given declaration. While this pragma is supported on all
22393 platforms, it is intended primarily to provide compatibility with the
22394 Solaris system headers. This effect can also be achieved using the asm
22395 labels extension (@pxref{Asm Labels}).
22396
22397 @table @code
22398 @item redefine_extname @var{oldname} @var{newname}
22399 @cindex pragma, redefine_extname
22400
22401 This pragma gives the C function @var{oldname} the assembly symbol
22402 @var{newname}. The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22403 is defined if this pragma is available (currently on all platforms).
22404 @end table
22405
22406 This pragma and the asm labels extension interact in a complicated
22407 manner. Here are some corner cases you may want to be aware of:
22408
22409 @enumerate
22410 @item This pragma silently applies only to declarations with external
22411 linkage. Asm labels do not have this restriction.
22412
22413 @item In C++, this pragma silently applies only to declarations with
22414 ``C'' linkage. Again, asm labels do not have this restriction.
22415
22416 @item If either of the ways of changing the assembly name of a
22417 declaration are applied to a declaration whose assembly name has
22418 already been determined (either by a previous use of one of these
22419 features, or because the compiler needed the assembly name in order to
22420 generate code), and the new name is different, a warning issues and
22421 the name does not change.
22422
22423 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22424 always the C-language name.
22425 @end enumerate
22426
22427 @node Structure-Layout Pragmas
22428 @subsection Structure-Layout Pragmas
22429
22430 For compatibility with Microsoft Windows compilers, GCC supports a
22431 set of @code{#pragma} directives that change the maximum alignment of
22432 members of structures (other than zero-width bit-fields), unions, and
22433 classes subsequently defined. The @var{n} value below always is required
22434 to be a small power of two and specifies the new alignment in bytes.
22435
22436 @enumerate
22437 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22438 @item @code{#pragma pack()} sets the alignment to the one that was in
22439 effect when compilation started (see also command-line option
22440 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22441 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22442 setting on an internal stack and then optionally sets the new alignment.
22443 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22444 saved at the top of the internal stack (and removes that stack entry).
22445 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22446 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22447 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22448 @code{#pragma pack(pop)}.
22449 @end enumerate
22450
22451 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22452 directive which lays out structures and unions subsequently defined as the
22453 documented @code{__attribute__ ((ms_struct))}.
22454
22455 @enumerate
22456 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22457 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22458 @item @code{#pragma ms_struct reset} goes back to the default layout.
22459 @end enumerate
22460
22461 Most targets also support the @code{#pragma scalar_storage_order} directive
22462 which lays out structures and unions subsequently defined as the documented
22463 @code{__attribute__ ((scalar_storage_order))}.
22464
22465 @enumerate
22466 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22467 of the scalar fields to big-endian.
22468 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22469 of the scalar fields to little-endian.
22470 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22471 that was in effect when compilation started (see also command-line option
22472 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22473 @end enumerate
22474
22475 @node Weak Pragmas
22476 @subsection Weak Pragmas
22477
22478 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22479 directives for declaring symbols to be weak, and defining weak
22480 aliases.
22481
22482 @table @code
22483 @item #pragma weak @var{symbol}
22484 @cindex pragma, weak
22485 This pragma declares @var{symbol} to be weak, as if the declaration
22486 had the attribute of the same name. The pragma may appear before
22487 or after the declaration of @var{symbol}. It is not an error for
22488 @var{symbol} to never be defined at all.
22489
22490 @item #pragma weak @var{symbol1} = @var{symbol2}
22491 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22492 It is an error if @var{symbol2} is not defined in the current
22493 translation unit.
22494 @end table
22495
22496 @node Diagnostic Pragmas
22497 @subsection Diagnostic Pragmas
22498
22499 GCC allows the user to selectively enable or disable certain types of
22500 diagnostics, and change the kind of the diagnostic. For example, a
22501 project's policy might require that all sources compile with
22502 @option{-Werror} but certain files might have exceptions allowing
22503 specific types of warnings. Or, a project might selectively enable
22504 diagnostics and treat them as errors depending on which preprocessor
22505 macros are defined.
22506
22507 @table @code
22508 @item #pragma GCC diagnostic @var{kind} @var{option}
22509 @cindex pragma, diagnostic
22510
22511 Modifies the disposition of a diagnostic. Note that not all
22512 diagnostics are modifiable; at the moment only warnings (normally
22513 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22514 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22515 are controllable and which option controls them.
22516
22517 @var{kind} is @samp{error} to treat this diagnostic as an error,
22518 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22519 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22520 @var{option} is a double quoted string that matches the command-line
22521 option.
22522
22523 @smallexample
22524 #pragma GCC diagnostic warning "-Wformat"
22525 #pragma GCC diagnostic error "-Wformat"
22526 #pragma GCC diagnostic ignored "-Wformat"
22527 @end smallexample
22528
22529 Note that these pragmas override any command-line options. GCC keeps
22530 track of the location of each pragma, and issues diagnostics according
22531 to the state as of that point in the source file. Thus, pragmas occurring
22532 after a line do not affect diagnostics caused by that line.
22533
22534 @item #pragma GCC diagnostic push
22535 @itemx #pragma GCC diagnostic pop
22536
22537 Causes GCC to remember the state of the diagnostics as of each
22538 @code{push}, and restore to that point at each @code{pop}. If a
22539 @code{pop} has no matching @code{push}, the command-line options are
22540 restored.
22541
22542 @smallexample
22543 #pragma GCC diagnostic error "-Wuninitialized"
22544 foo(a); /* error is given for this one */
22545 #pragma GCC diagnostic push
22546 #pragma GCC diagnostic ignored "-Wuninitialized"
22547 foo(b); /* no diagnostic for this one */
22548 #pragma GCC diagnostic pop
22549 foo(c); /* error is given for this one */
22550 #pragma GCC diagnostic pop
22551 foo(d); /* depends on command-line options */
22552 @end smallexample
22553
22554 @end table
22555
22556 GCC also offers a simple mechanism for printing messages during
22557 compilation.
22558
22559 @table @code
22560 @item #pragma message @var{string}
22561 @cindex pragma, diagnostic
22562
22563 Prints @var{string} as a compiler message on compilation. The message
22564 is informational only, and is neither a compilation warning nor an error.
22565
22566 @smallexample
22567 #pragma message "Compiling " __FILE__ "..."
22568 @end smallexample
22569
22570 @var{string} may be parenthesized, and is printed with location
22571 information. For example,
22572
22573 @smallexample
22574 #define DO_PRAGMA(x) _Pragma (#x)
22575 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22576
22577 TODO(Remember to fix this)
22578 @end smallexample
22579
22580 @noindent
22581 prints @samp{/tmp/file.c:4: note: #pragma message:
22582 TODO - Remember to fix this}.
22583
22584 @end table
22585
22586 @node Visibility Pragmas
22587 @subsection Visibility Pragmas
22588
22589 @table @code
22590 @item #pragma GCC visibility push(@var{visibility})
22591 @itemx #pragma GCC visibility pop
22592 @cindex pragma, visibility
22593
22594 This pragma allows the user to set the visibility for multiple
22595 declarations without having to give each a visibility attribute
22596 (@pxref{Function Attributes}).
22597
22598 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22599 declarations. Class members and template specializations are not
22600 affected; if you want to override the visibility for a particular
22601 member or instantiation, you must use an attribute.
22602
22603 @end table
22604
22605
22606 @node Push/Pop Macro Pragmas
22607 @subsection Push/Pop Macro Pragmas
22608
22609 For compatibility with Microsoft Windows compilers, GCC supports
22610 @samp{#pragma push_macro(@var{"macro_name"})}
22611 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22612
22613 @table @code
22614 @item #pragma push_macro(@var{"macro_name"})
22615 @cindex pragma, push_macro
22616 This pragma saves the value of the macro named as @var{macro_name} to
22617 the top of the stack for this macro.
22618
22619 @item #pragma pop_macro(@var{"macro_name"})
22620 @cindex pragma, pop_macro
22621 This pragma sets the value of the macro named as @var{macro_name} to
22622 the value on top of the stack for this macro. If the stack for
22623 @var{macro_name} is empty, the value of the macro remains unchanged.
22624 @end table
22625
22626 For example:
22627
22628 @smallexample
22629 #define X 1
22630 #pragma push_macro("X")
22631 #undef X
22632 #define X -1
22633 #pragma pop_macro("X")
22634 int x [X];
22635 @end smallexample
22636
22637 @noindent
22638 In this example, the definition of X as 1 is saved by @code{#pragma
22639 push_macro} and restored by @code{#pragma pop_macro}.
22640
22641 @node Function Specific Option Pragmas
22642 @subsection Function Specific Option Pragmas
22643
22644 @table @code
22645 @item #pragma GCC target (@var{"string"}...)
22646 @cindex pragma GCC target
22647
22648 This pragma allows you to set target specific options for functions
22649 defined later in the source file. One or more strings can be
22650 specified. Each function that is defined after this point is as
22651 if @code{attribute((target("STRING")))} was specified for that
22652 function. The parenthesis around the options is optional.
22653 @xref{Function Attributes}, for more information about the
22654 @code{target} attribute and the attribute syntax.
22655
22656 The @code{#pragma GCC target} pragma is presently implemented for
22657 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22658
22659 @item #pragma GCC optimize (@var{"string"}...)
22660 @cindex pragma GCC optimize
22661
22662 This pragma allows you to set global optimization options for functions
22663 defined later in the source file. One or more strings can be
22664 specified. Each function that is defined after this point is as
22665 if @code{attribute((optimize("STRING")))} was specified for that
22666 function. The parenthesis around the options is optional.
22667 @xref{Function Attributes}, for more information about the
22668 @code{optimize} attribute and the attribute syntax.
22669
22670 @item #pragma GCC push_options
22671 @itemx #pragma GCC pop_options
22672 @cindex pragma GCC push_options
22673 @cindex pragma GCC pop_options
22674
22675 These pragmas maintain a stack of the current target and optimization
22676 options. It is intended for include files where you temporarily want
22677 to switch to using a different @samp{#pragma GCC target} or
22678 @samp{#pragma GCC optimize} and then to pop back to the previous
22679 options.
22680
22681 @item #pragma GCC reset_options
22682 @cindex pragma GCC reset_options
22683
22684 This pragma clears the current @code{#pragma GCC target} and
22685 @code{#pragma GCC optimize} to use the default switches as specified
22686 on the command line.
22687
22688 @end table
22689
22690 @node Loop-Specific Pragmas
22691 @subsection Loop-Specific Pragmas
22692
22693 @table @code
22694 @item #pragma GCC ivdep
22695 @cindex pragma GCC ivdep
22696
22697 With this pragma, the programmer asserts that there are no loop-carried
22698 dependencies which would prevent consecutive iterations of
22699 the following loop from executing concurrently with SIMD
22700 (single instruction multiple data) instructions.
22701
22702 For example, the compiler can only unconditionally vectorize the following
22703 loop with the pragma:
22704
22705 @smallexample
22706 void foo (int n, int *a, int *b, int *c)
22707 @{
22708 int i, j;
22709 #pragma GCC ivdep
22710 for (i = 0; i < n; ++i)
22711 a[i] = b[i] + c[i];
22712 @}
22713 @end smallexample
22714
22715 @noindent
22716 In this example, using the @code{restrict} qualifier had the same
22717 effect. In the following example, that would not be possible. Assume
22718 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22719 that it can unconditionally vectorize the following loop:
22720
22721 @smallexample
22722 void ignore_vec_dep (int *a, int k, int c, int m)
22723 @{
22724 #pragma GCC ivdep
22725 for (int i = 0; i < m; i++)
22726 a[i] = a[i + k] * c;
22727 @}
22728 @end smallexample
22729
22730 @item #pragma GCC unroll @var{n}
22731 @cindex pragma GCC unroll @var{n}
22732
22733 You can use this pragma to control how many times a loop should be unrolled.
22734 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22735 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22736 @var{n} is an integer constant expression specifying the unrolling factor.
22737 The values of @math{0} and @math{1} block any unrolling of the loop.
22738
22739 @end table
22740
22741 @node Unnamed Fields
22742 @section Unnamed Structure and Union Fields
22743 @cindex @code{struct}
22744 @cindex @code{union}
22745
22746 As permitted by ISO C11 and for compatibility with other compilers,
22747 GCC allows you to define
22748 a structure or union that contains, as fields, structures and unions
22749 without names. For example:
22750
22751 @smallexample
22752 struct @{
22753 int a;
22754 union @{
22755 int b;
22756 float c;
22757 @};
22758 int d;
22759 @} foo;
22760 @end smallexample
22761
22762 @noindent
22763 In this example, you are able to access members of the unnamed
22764 union with code like @samp{foo.b}. Note that only unnamed structs and
22765 unions are allowed, you may not have, for example, an unnamed
22766 @code{int}.
22767
22768 You must never create such structures that cause ambiguous field definitions.
22769 For example, in this structure:
22770
22771 @smallexample
22772 struct @{
22773 int a;
22774 struct @{
22775 int a;
22776 @};
22777 @} foo;
22778 @end smallexample
22779
22780 @noindent
22781 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22782 The compiler gives errors for such constructs.
22783
22784 @opindex fms-extensions
22785 Unless @option{-fms-extensions} is used, the unnamed field must be a
22786 structure or union definition without a tag (for example, @samp{struct
22787 @{ int a; @};}). If @option{-fms-extensions} is used, the field may
22788 also be a definition with a tag such as @samp{struct foo @{ int a;
22789 @};}, a reference to a previously defined structure or union such as
22790 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22791 previously defined structure or union type.
22792
22793 @opindex fplan9-extensions
22794 The option @option{-fplan9-extensions} enables
22795 @option{-fms-extensions} as well as two other extensions. First, a
22796 pointer to a structure is automatically converted to a pointer to an
22797 anonymous field for assignments and function calls. For example:
22798
22799 @smallexample
22800 struct s1 @{ int a; @};
22801 struct s2 @{ struct s1; @};
22802 extern void f1 (struct s1 *);
22803 void f2 (struct s2 *p) @{ f1 (p); @}
22804 @end smallexample
22805
22806 @noindent
22807 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22808 converted into a pointer to the anonymous field.
22809
22810 Second, when the type of an anonymous field is a @code{typedef} for a
22811 @code{struct} or @code{union}, code may refer to the field using the
22812 name of the @code{typedef}.
22813
22814 @smallexample
22815 typedef struct @{ int a; @} s1;
22816 struct s2 @{ s1; @};
22817 s1 f1 (struct s2 *p) @{ return p->s1; @}
22818 @end smallexample
22819
22820 These usages are only permitted when they are not ambiguous.
22821
22822 @node Thread-Local
22823 @section Thread-Local Storage
22824 @cindex Thread-Local Storage
22825 @cindex @acronym{TLS}
22826 @cindex @code{__thread}
22827
22828 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22829 are allocated such that there is one instance of the variable per extant
22830 thread. The runtime model GCC uses to implement this originates
22831 in the IA-64 processor-specific ABI, but has since been migrated
22832 to other processors as well. It requires significant support from
22833 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22834 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22835 is not available everywhere.
22836
22837 At the user level, the extension is visible with a new storage
22838 class keyword: @code{__thread}. For example:
22839
22840 @smallexample
22841 __thread int i;
22842 extern __thread struct state s;
22843 static __thread char *p;
22844 @end smallexample
22845
22846 The @code{__thread} specifier may be used alone, with the @code{extern}
22847 or @code{static} specifiers, but with no other storage class specifier.
22848 When used with @code{extern} or @code{static}, @code{__thread} must appear
22849 immediately after the other storage class specifier.
22850
22851 The @code{__thread} specifier may be applied to any global, file-scoped
22852 static, function-scoped static, or static data member of a class. It may
22853 not be applied to block-scoped automatic or non-static data member.
22854
22855 When the address-of operator is applied to a thread-local variable, it is
22856 evaluated at run time and returns the address of the current thread's
22857 instance of that variable. An address so obtained may be used by any
22858 thread. When a thread terminates, any pointers to thread-local variables
22859 in that thread become invalid.
22860
22861 No static initialization may refer to the address of a thread-local variable.
22862
22863 In C++, if an initializer is present for a thread-local variable, it must
22864 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22865 standard.
22866
22867 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22868 ELF Handling For Thread-Local Storage} for a detailed explanation of
22869 the four thread-local storage addressing models, and how the runtime
22870 is expected to function.
22871
22872 @menu
22873 * C99 Thread-Local Edits::
22874 * C++98 Thread-Local Edits::
22875 @end menu
22876
22877 @node C99 Thread-Local Edits
22878 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22879
22880 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22881 that document the exact semantics of the language extension.
22882
22883 @itemize @bullet
22884 @item
22885 @cite{5.1.2 Execution environments}
22886
22887 Add new text after paragraph 1
22888
22889 @quotation
22890 Within either execution environment, a @dfn{thread} is a flow of
22891 control within a program. It is implementation defined whether
22892 or not there may be more than one thread associated with a program.
22893 It is implementation defined how threads beyond the first are
22894 created, the name and type of the function called at thread
22895 startup, and how threads may be terminated. However, objects
22896 with thread storage duration shall be initialized before thread
22897 startup.
22898 @end quotation
22899
22900 @item
22901 @cite{6.2.4 Storage durations of objects}
22902
22903 Add new text before paragraph 3
22904
22905 @quotation
22906 An object whose identifier is declared with the storage-class
22907 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22908 Its lifetime is the entire execution of the thread, and its
22909 stored value is initialized only once, prior to thread startup.
22910 @end quotation
22911
22912 @item
22913 @cite{6.4.1 Keywords}
22914
22915 Add @code{__thread}.
22916
22917 @item
22918 @cite{6.7.1 Storage-class specifiers}
22919
22920 Add @code{__thread} to the list of storage class specifiers in
22921 paragraph 1.
22922
22923 Change paragraph 2 to
22924
22925 @quotation
22926 With the exception of @code{__thread}, at most one storage-class
22927 specifier may be given [@dots{}]. The @code{__thread} specifier may
22928 be used alone, or immediately following @code{extern} or
22929 @code{static}.
22930 @end quotation
22931
22932 Add new text after paragraph 6
22933
22934 @quotation
22935 The declaration of an identifier for a variable that has
22936 block scope that specifies @code{__thread} shall also
22937 specify either @code{extern} or @code{static}.
22938
22939 The @code{__thread} specifier shall be used only with
22940 variables.
22941 @end quotation
22942 @end itemize
22943
22944 @node C++98 Thread-Local Edits
22945 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22946
22947 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22948 that document the exact semantics of the language extension.
22949
22950 @itemize @bullet
22951 @item
22952 @b{[intro.execution]}
22953
22954 New text after paragraph 4
22955
22956 @quotation
22957 A @dfn{thread} is a flow of control within the abstract machine.
22958 It is implementation defined whether or not there may be more than
22959 one thread.
22960 @end quotation
22961
22962 New text after paragraph 7
22963
22964 @quotation
22965 It is unspecified whether additional action must be taken to
22966 ensure when and whether side effects are visible to other threads.
22967 @end quotation
22968
22969 @item
22970 @b{[lex.key]}
22971
22972 Add @code{__thread}.
22973
22974 @item
22975 @b{[basic.start.main]}
22976
22977 Add after paragraph 5
22978
22979 @quotation
22980 The thread that begins execution at the @code{main} function is called
22981 the @dfn{main thread}. It is implementation defined how functions
22982 beginning threads other than the main thread are designated or typed.
22983 A function so designated, as well as the @code{main} function, is called
22984 a @dfn{thread startup function}. It is implementation defined what
22985 happens if a thread startup function returns. It is implementation
22986 defined what happens to other threads when any thread calls @code{exit}.
22987 @end quotation
22988
22989 @item
22990 @b{[basic.start.init]}
22991
22992 Add after paragraph 4
22993
22994 @quotation
22995 The storage for an object of thread storage duration shall be
22996 statically initialized before the first statement of the thread startup
22997 function. An object of thread storage duration shall not require
22998 dynamic initialization.
22999 @end quotation
23000
23001 @item
23002 @b{[basic.start.term]}
23003
23004 Add after paragraph 3
23005
23006 @quotation
23007 The type of an object with thread storage duration shall not have a
23008 non-trivial destructor, nor shall it be an array type whose elements
23009 (directly or indirectly) have non-trivial destructors.
23010 @end quotation
23011
23012 @item
23013 @b{[basic.stc]}
23014
23015 Add ``thread storage duration'' to the list in paragraph 1.
23016
23017 Change paragraph 2
23018
23019 @quotation
23020 Thread, static, and automatic storage durations are associated with
23021 objects introduced by declarations [@dots{}].
23022 @end quotation
23023
23024 Add @code{__thread} to the list of specifiers in paragraph 3.
23025
23026 @item
23027 @b{[basic.stc.thread]}
23028
23029 New section before @b{[basic.stc.static]}
23030
23031 @quotation
23032 The keyword @code{__thread} applied to a non-local object gives the
23033 object thread storage duration.
23034
23035 A local variable or class data member declared both @code{static}
23036 and @code{__thread} gives the variable or member thread storage
23037 duration.
23038 @end quotation
23039
23040 @item
23041 @b{[basic.stc.static]}
23042
23043 Change paragraph 1
23044
23045 @quotation
23046 All objects that have neither thread storage duration, dynamic
23047 storage duration nor are local [@dots{}].
23048 @end quotation
23049
23050 @item
23051 @b{[dcl.stc]}
23052
23053 Add @code{__thread} to the list in paragraph 1.
23054
23055 Change paragraph 1
23056
23057 @quotation
23058 With the exception of @code{__thread}, at most one
23059 @var{storage-class-specifier} shall appear in a given
23060 @var{decl-specifier-seq}. The @code{__thread} specifier may
23061 be used alone, or immediately following the @code{extern} or
23062 @code{static} specifiers. [@dots{}]
23063 @end quotation
23064
23065 Add after paragraph 5
23066
23067 @quotation
23068 The @code{__thread} specifier can be applied only to the names of objects
23069 and to anonymous unions.
23070 @end quotation
23071
23072 @item
23073 @b{[class.mem]}
23074
23075 Add after paragraph 6
23076
23077 @quotation
23078 Non-@code{static} members shall not be @code{__thread}.
23079 @end quotation
23080 @end itemize
23081
23082 @node Binary constants
23083 @section Binary Constants using the @samp{0b} Prefix
23084 @cindex Binary constants using the @samp{0b} prefix
23085
23086 Integer constants can be written as binary constants, consisting of a
23087 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23088 @samp{0B}. This is particularly useful in environments that operate a
23089 lot on the bit level (like microcontrollers).
23090
23091 The following statements are identical:
23092
23093 @smallexample
23094 i = 42;
23095 i = 0x2a;
23096 i = 052;
23097 i = 0b101010;
23098 @end smallexample
23099
23100 The type of these constants follows the same rules as for octal or
23101 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23102 can be applied.
23103
23104 @node C++ Extensions
23105 @chapter Extensions to the C++ Language
23106 @cindex extensions, C++ language
23107 @cindex C++ language extensions
23108
23109 The GNU compiler provides these extensions to the C++ language (and you
23110 can also use most of the C language extensions in your C++ programs). If you
23111 want to write code that checks whether these features are available, you can
23112 test for the GNU compiler the same way as for C programs: check for a
23113 predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
23114 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23115 Predefined Macros,cpp,The GNU C Preprocessor}).
23116
23117 @menu
23118 * C++ Volatiles:: What constitutes an access to a volatile object.
23119 * Restricted Pointers:: C99 restricted pointers and references.
23120 * Vague Linkage:: Where G++ puts inlines, vtables and such.
23121 * C++ Interface:: You can use a single C++ header file for both
23122 declarations and definitions.
23123 * Template Instantiation:: Methods for ensuring that exactly one copy of
23124 each needed template instantiation is emitted.
23125 * Bound member functions:: You can extract a function pointer to the
23126 method denoted by a @samp{->*} or @samp{.*} expression.
23127 * C++ Attributes:: Variable, function, and type attributes for C++ only.
23128 * Function Multiversioning:: Declaring multiple function versions.
23129 * Type Traits:: Compiler support for type traits.
23130 * C++ Concepts:: Improved support for generic programming.
23131 * Deprecated Features:: Things will disappear from G++.
23132 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
23133 @end menu
23134
23135 @node C++ Volatiles
23136 @section When is a Volatile C++ Object Accessed?
23137 @cindex accessing volatiles
23138 @cindex volatile read
23139 @cindex volatile write
23140 @cindex volatile access
23141
23142 The C++ standard differs from the C standard in its treatment of
23143 volatile objects. It fails to specify what constitutes a volatile
23144 access, except to say that C++ should behave in a similar manner to C
23145 with respect to volatiles, where possible. However, the different
23146 lvalueness of expressions between C and C++ complicate the behavior.
23147 G++ behaves the same as GCC for volatile access, @xref{C
23148 Extensions,,Volatiles}, for a description of GCC's behavior.
23149
23150 The C and C++ language specifications differ when an object is
23151 accessed in a void context:
23152
23153 @smallexample
23154 volatile int *src = @var{somevalue};
23155 *src;
23156 @end smallexample
23157
23158 The C++ standard specifies that such expressions do not undergo lvalue
23159 to rvalue conversion, and that the type of the dereferenced object may
23160 be incomplete. The C++ standard does not specify explicitly that it
23161 is lvalue to rvalue conversion that is responsible for causing an
23162 access. There is reason to believe that it is, because otherwise
23163 certain simple expressions become undefined. However, because it
23164 would surprise most programmers, G++ treats dereferencing a pointer to
23165 volatile object of complete type as GCC would do for an equivalent
23166 type in C@. When the object has incomplete type, G++ issues a
23167 warning; if you wish to force an error, you must force a conversion to
23168 rvalue with, for instance, a static cast.
23169
23170 When using a reference to volatile, G++ does not treat equivalent
23171 expressions as accesses to volatiles, but instead issues a warning that
23172 no volatile is accessed. The rationale for this is that otherwise it
23173 becomes difficult to determine where volatile access occur, and not
23174 possible to ignore the return value from functions returning volatile
23175 references. Again, if you wish to force a read, cast the reference to
23176 an rvalue.
23177
23178 G++ implements the same behavior as GCC does when assigning to a
23179 volatile object---there is no reread of the assigned-to object, the
23180 assigned rvalue is reused. Note that in C++ assignment expressions
23181 are lvalues, and if used as an lvalue, the volatile object is
23182 referred to. For instance, @var{vref} refers to @var{vobj}, as
23183 expected, in the following example:
23184
23185 @smallexample
23186 volatile int vobj;
23187 volatile int &vref = vobj = @var{something};
23188 @end smallexample
23189
23190 @node Restricted Pointers
23191 @section Restricting Pointer Aliasing
23192 @cindex restricted pointers
23193 @cindex restricted references
23194 @cindex restricted this pointer
23195
23196 As with the C front end, G++ understands the C99 feature of restricted pointers,
23197 specified with the @code{__restrict__}, or @code{__restrict} type
23198 qualifier. Because you cannot compile C++ by specifying the @option{-std=c99}
23199 language flag, @code{restrict} is not a keyword in C++.
23200
23201 In addition to allowing restricted pointers, you can specify restricted
23202 references, which indicate that the reference is not aliased in the local
23203 context.
23204
23205 @smallexample
23206 void fn (int *__restrict__ rptr, int &__restrict__ rref)
23207 @{
23208 /* @r{@dots{}} */
23209 @}
23210 @end smallexample
23211
23212 @noindent
23213 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
23214 @var{rref} refers to a (different) unaliased integer.
23215
23216 You may also specify whether a member function's @var{this} pointer is
23217 unaliased by using @code{__restrict__} as a member function qualifier.
23218
23219 @smallexample
23220 void T::fn () __restrict__
23221 @{
23222 /* @r{@dots{}} */
23223 @}
23224 @end smallexample
23225
23226 @noindent
23227 Within the body of @code{T::fn}, @var{this} has the effective
23228 definition @code{T *__restrict__ const this}. Notice that the
23229 interpretation of a @code{__restrict__} member function qualifier is
23230 different to that of @code{const} or @code{volatile} qualifier, in that it
23231 is applied to the pointer rather than the object. This is consistent with
23232 other compilers that implement restricted pointers.
23233
23234 As with all outermost parameter qualifiers, @code{__restrict__} is
23235 ignored in function definition matching. This means you only need to
23236 specify @code{__restrict__} in a function definition, rather than
23237 in a function prototype as well.
23238
23239 @node Vague Linkage
23240 @section Vague Linkage
23241 @cindex vague linkage
23242
23243 There are several constructs in C++ that require space in the object
23244 file but are not clearly tied to a single translation unit. We say that
23245 these constructs have ``vague linkage''. Typically such constructs are
23246 emitted wherever they are needed, though sometimes we can be more
23247 clever.
23248
23249 @table @asis
23250 @item Inline Functions
23251 Inline functions are typically defined in a header file which can be
23252 included in many different compilations. Hopefully they can usually be
23253 inlined, but sometimes an out-of-line copy is necessary, if the address
23254 of the function is taken or if inlining fails. In general, we emit an
23255 out-of-line copy in all translation units where one is needed. As an
23256 exception, we only emit inline virtual functions with the vtable, since
23257 it always requires a copy.
23258
23259 Local static variables and string constants used in an inline function
23260 are also considered to have vague linkage, since they must be shared
23261 between all inlined and out-of-line instances of the function.
23262
23263 @item VTables
23264 @cindex vtable
23265 C++ virtual functions are implemented in most compilers using a lookup
23266 table, known as a vtable. The vtable contains pointers to the virtual
23267 functions provided by a class, and each object of the class contains a
23268 pointer to its vtable (or vtables, in some multiple-inheritance
23269 situations). If the class declares any non-inline, non-pure virtual
23270 functions, the first one is chosen as the ``key method'' for the class,
23271 and the vtable is only emitted in the translation unit where the key
23272 method is defined.
23273
23274 @emph{Note:} If the chosen key method is later defined as inline, the
23275 vtable is still emitted in every translation unit that defines it.
23276 Make sure that any inline virtuals are declared inline in the class
23277 body, even if they are not defined there.
23278
23279 @item @code{type_info} objects
23280 @cindex @code{type_info}
23281 @cindex RTTI
23282 C++ requires information about types to be written out in order to
23283 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23284 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23285 object is written out along with the vtable so that @samp{dynamic_cast}
23286 can determine the dynamic type of a class object at run time. For all
23287 other types, we write out the @samp{type_info} object when it is used: when
23288 applying @samp{typeid} to an expression, throwing an object, or
23289 referring to a type in a catch clause or exception specification.
23290
23291 @item Template Instantiations
23292 Most everything in this section also applies to template instantiations,
23293 but there are other options as well.
23294 @xref{Template Instantiation,,Where's the Template?}.
23295
23296 @end table
23297
23298 When used with GNU ld version 2.8 or later on an ELF system such as
23299 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23300 these constructs will be discarded at link time. This is known as
23301 COMDAT support.
23302
23303 On targets that don't support COMDAT, but do support weak symbols, GCC
23304 uses them. This way one copy overrides all the others, but
23305 the unused copies still take up space in the executable.
23306
23307 For targets that do not support either COMDAT or weak symbols,
23308 most entities with vague linkage are emitted as local symbols to
23309 avoid duplicate definition errors from the linker. This does not happen
23310 for local statics in inlines, however, as having multiple copies
23311 almost certainly breaks things.
23312
23313 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23314 another way to control placement of these constructs.
23315
23316 @node C++ Interface
23317 @section C++ Interface and Implementation Pragmas
23318
23319 @cindex interface and implementation headers, C++
23320 @cindex C++ interface and implementation headers
23321 @cindex pragmas, interface and implementation
23322
23323 @code{#pragma interface} and @code{#pragma implementation} provide the
23324 user with a way of explicitly directing the compiler to emit entities
23325 with vague linkage (and debugging information) in a particular
23326 translation unit.
23327
23328 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23329 by COMDAT support and the ``key method'' heuristic
23330 mentioned in @ref{Vague Linkage}. Using them can actually cause your
23331 program to grow due to unnecessary out-of-line copies of inline
23332 functions.
23333
23334 @table @code
23335 @item #pragma interface
23336 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23337 @kindex #pragma interface
23338 Use this directive in @emph{header files} that define object classes, to save
23339 space in most of the object files that use those classes. Normally,
23340 local copies of certain information (backup copies of inline member
23341 functions, debugging information, and the internal tables that implement
23342 virtual functions) must be kept in each object file that includes class
23343 definitions. You can use this pragma to avoid such duplication. When a
23344 header file containing @samp{#pragma interface} is included in a
23345 compilation, this auxiliary information is not generated (unless
23346 the main input source file itself uses @samp{#pragma implementation}).
23347 Instead, the object files contain references to be resolved at link
23348 time.
23349
23350 The second form of this directive is useful for the case where you have
23351 multiple headers with the same name in different directories. If you
23352 use this form, you must specify the same string to @samp{#pragma
23353 implementation}.
23354
23355 @item #pragma implementation
23356 @itemx #pragma implementation "@var{objects}.h"
23357 @kindex #pragma implementation
23358 Use this pragma in a @emph{main input file}, when you want full output from
23359 included header files to be generated (and made globally visible). The
23360 included header file, in turn, should use @samp{#pragma interface}.
23361 Backup copies of inline member functions, debugging information, and the
23362 internal tables used to implement virtual functions are all generated in
23363 implementation files.
23364
23365 @cindex implied @code{#pragma implementation}
23366 @cindex @code{#pragma implementation}, implied
23367 @cindex naming convention, implementation headers
23368 If you use @samp{#pragma implementation} with no argument, it applies to
23369 an include file with the same basename@footnote{A file's @dfn{basename}
23370 is the name stripped of all leading path information and of trailing
23371 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23372 file. For example, in @file{allclass.cc}, giving just
23373 @samp{#pragma implementation}
23374 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23375
23376 Use the string argument if you want a single implementation file to
23377 include code from multiple header files. (You must also use
23378 @samp{#include} to include the header file; @samp{#pragma
23379 implementation} only specifies how to use the file---it doesn't actually
23380 include it.)
23381
23382 There is no way to split up the contents of a single header file into
23383 multiple implementation files.
23384 @end table
23385
23386 @cindex inlining and C++ pragmas
23387 @cindex C++ pragmas, effect on inlining
23388 @cindex pragmas in C++, effect on inlining
23389 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23390 effect on function inlining.
23391
23392 If you define a class in a header file marked with @samp{#pragma
23393 interface}, the effect on an inline function defined in that class is
23394 similar to an explicit @code{extern} declaration---the compiler emits
23395 no code at all to define an independent version of the function. Its
23396 definition is used only for inlining with its callers.
23397
23398 @opindex fno-implement-inlines
23399 Conversely, when you include the same header file in a main source file
23400 that declares it as @samp{#pragma implementation}, the compiler emits
23401 code for the function itself; this defines a version of the function
23402 that can be found via pointers (or by callers compiled without
23403 inlining). If all calls to the function can be inlined, you can avoid
23404 emitting the function by compiling with @option{-fno-implement-inlines}.
23405 If any calls are not inlined, you will get linker errors.
23406
23407 @node Template Instantiation
23408 @section Where's the Template?
23409 @cindex template instantiation
23410
23411 C++ templates were the first language feature to require more
23412 intelligence from the environment than was traditionally found on a UNIX
23413 system. Somehow the compiler and linker have to make sure that each
23414 template instance occurs exactly once in the executable if it is needed,
23415 and not at all otherwise. There are two basic approaches to this
23416 problem, which are referred to as the Borland model and the Cfront model.
23417
23418 @table @asis
23419 @item Borland model
23420 Borland C++ solved the template instantiation problem by adding the code
23421 equivalent of common blocks to their linker; the compiler emits template
23422 instances in each translation unit that uses them, and the linker
23423 collapses them together. The advantage of this model is that the linker
23424 only has to consider the object files themselves; there is no external
23425 complexity to worry about. The disadvantage is that compilation time
23426 is increased because the template code is being compiled repeatedly.
23427 Code written for this model tends to include definitions of all
23428 templates in the header file, since they must be seen to be
23429 instantiated.
23430
23431 @item Cfront model
23432 The AT&T C++ translator, Cfront, solved the template instantiation
23433 problem by creating the notion of a template repository, an
23434 automatically maintained place where template instances are stored. A
23435 more modern version of the repository works as follows: As individual
23436 object files are built, the compiler places any template definitions and
23437 instantiations encountered in the repository. At link time, the link
23438 wrapper adds in the objects in the repository and compiles any needed
23439 instances that were not previously emitted. The advantages of this
23440 model are more optimal compilation speed and the ability to use the
23441 system linker; to implement the Borland model a compiler vendor also
23442 needs to replace the linker. The disadvantages are vastly increased
23443 complexity, and thus potential for error; for some code this can be
23444 just as transparent, but in practice it can been very difficult to build
23445 multiple programs in one directory and one program in multiple
23446 directories. Code written for this model tends to separate definitions
23447 of non-inline member templates into a separate file, which should be
23448 compiled separately.
23449 @end table
23450
23451 G++ implements the Borland model on targets where the linker supports it,
23452 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23453 Otherwise G++ implements neither automatic model.
23454
23455 You have the following options for dealing with template instantiations:
23456
23457 @enumerate
23458 @item
23459 Do nothing. Code written for the Borland model works fine, but
23460 each translation unit contains instances of each of the templates it
23461 uses. The duplicate instances will be discarded by the linker, but in
23462 a large program, this can lead to an unacceptable amount of code
23463 duplication in object files or shared libraries.
23464
23465 Duplicate instances of a template can be avoided by defining an explicit
23466 instantiation in one object file, and preventing the compiler from doing
23467 implicit instantiations in any other object files by using an explicit
23468 instantiation declaration, using the @code{extern template} syntax:
23469
23470 @smallexample
23471 extern template int max (int, int);
23472 @end smallexample
23473
23474 This syntax is defined in the C++ 2011 standard, but has been supported by
23475 G++ and other compilers since well before 2011.
23476
23477 Explicit instantiations can be used for the largest or most frequently
23478 duplicated instances, without having to know exactly which other instances
23479 are used in the rest of the program. You can scatter the explicit
23480 instantiations throughout your program, perhaps putting them in the
23481 translation units where the instances are used or the translation units
23482 that define the templates themselves; you can put all of the explicit
23483 instantiations you need into one big file; or you can create small files
23484 like
23485
23486 @smallexample
23487 #include "Foo.h"
23488 #include "Foo.cc"
23489
23490 template class Foo<int>;
23491 template ostream& operator <<
23492 (ostream&, const Foo<int>&);
23493 @end smallexample
23494
23495 @noindent
23496 for each of the instances you need, and create a template instantiation
23497 library from those.
23498
23499 This is the simplest option, but also offers flexibility and
23500 fine-grained control when necessary. It is also the most portable
23501 alternative and programs using this approach will work with most modern
23502 compilers.
23503
23504 @item
23505 @opindex frepo
23506 Compile your template-using code with @option{-frepo}. The compiler
23507 generates files with the extension @samp{.rpo} listing all of the
23508 template instantiations used in the corresponding object files that
23509 could be instantiated there; the link wrapper, @samp{collect2},
23510 then updates the @samp{.rpo} files to tell the compiler where to place
23511 those instantiations and rebuild any affected object files. The
23512 link-time overhead is negligible after the first pass, as the compiler
23513 continues to place the instantiations in the same files.
23514
23515 This can be a suitable option for application code written for the Borland
23516 model, as it usually just works. Code written for the Cfront model
23517 needs to be modified so that the template definitions are available at
23518 one or more points of instantiation; usually this is as simple as adding
23519 @code{#include <tmethods.cc>} to the end of each template header.
23520
23521 For library code, if you want the library to provide all of the template
23522 instantiations it needs, just try to link all of its object files
23523 together; the link will fail, but cause the instantiations to be
23524 generated as a side effect. Be warned, however, that this may cause
23525 conflicts if multiple libraries try to provide the same instantiations.
23526 For greater control, use explicit instantiation as described in the next
23527 option.
23528
23529 @item
23530 @opindex fno-implicit-templates
23531 Compile your code with @option{-fno-implicit-templates} to disable the
23532 implicit generation of template instances, and explicitly instantiate
23533 all the ones you use. This approach requires more knowledge of exactly
23534 which instances you need than do the others, but it's less
23535 mysterious and allows greater control if you want to ensure that only
23536 the intended instances are used.
23537
23538 If you are using Cfront-model code, you can probably get away with not
23539 using @option{-fno-implicit-templates} when compiling files that don't
23540 @samp{#include} the member template definitions.
23541
23542 If you use one big file to do the instantiations, you may want to
23543 compile it without @option{-fno-implicit-templates} so you get all of the
23544 instances required by your explicit instantiations (but not by any
23545 other files) without having to specify them as well.
23546
23547 In addition to forward declaration of explicit instantiations
23548 (with @code{extern}), G++ has extended the template instantiation
23549 syntax to support instantiation of the compiler support data for a
23550 template class (i.e.@: the vtable) without instantiating any of its
23551 members (with @code{inline}), and instantiation of only the static data
23552 members of a template class, without the support data or member
23553 functions (with @code{static}):
23554
23555 @smallexample
23556 inline template class Foo<int>;
23557 static template class Foo<int>;
23558 @end smallexample
23559 @end enumerate
23560
23561 @node Bound member functions
23562 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23563 @cindex pmf
23564 @cindex pointer to member function
23565 @cindex bound pointer to member function
23566
23567 In C++, pointer to member functions (PMFs) are implemented using a wide
23568 pointer of sorts to handle all the possible call mechanisms; the PMF
23569 needs to store information about how to adjust the @samp{this} pointer,
23570 and if the function pointed to is virtual, where to find the vtable, and
23571 where in the vtable to look for the member function. If you are using
23572 PMFs in an inner loop, you should really reconsider that decision. If
23573 that is not an option, you can extract the pointer to the function that
23574 would be called for a given object/PMF pair and call it directly inside
23575 the inner loop, to save a bit of time.
23576
23577 Note that you still pay the penalty for the call through a
23578 function pointer; on most modern architectures, such a call defeats the
23579 branch prediction features of the CPU@. This is also true of normal
23580 virtual function calls.
23581
23582 The syntax for this extension is
23583
23584 @smallexample
23585 extern A a;
23586 extern int (A::*fp)();
23587 typedef int (*fptr)(A *);
23588
23589 fptr p = (fptr)(a.*fp);
23590 @end smallexample
23591
23592 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23593 no object is needed to obtain the address of the function. They can be
23594 converted to function pointers directly:
23595
23596 @smallexample
23597 fptr p1 = (fptr)(&A::foo);
23598 @end smallexample
23599
23600 @opindex Wno-pmf-conversions
23601 You must specify @option{-Wno-pmf-conversions} to use this extension.
23602
23603 @node C++ Attributes
23604 @section C++-Specific Variable, Function, and Type Attributes
23605
23606 Some attributes only make sense for C++ programs.
23607
23608 @table @code
23609 @item abi_tag ("@var{tag}", ...)
23610 @cindex @code{abi_tag} function attribute
23611 @cindex @code{abi_tag} variable attribute
23612 @cindex @code{abi_tag} type attribute
23613 The @code{abi_tag} attribute can be applied to a function, variable, or class
23614 declaration. It modifies the mangled name of the entity to
23615 incorporate the tag name, in order to distinguish the function or
23616 class from an earlier version with a different ABI; perhaps the class
23617 has changed size, or the function has a different return type that is
23618 not encoded in the mangled name.
23619
23620 The attribute can also be applied to an inline namespace, but does not
23621 affect the mangled name of the namespace; in this case it is only used
23622 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23623 variables. Tagging inline namespaces is generally preferable to
23624 tagging individual declarations, but the latter is sometimes
23625 necessary, such as when only certain members of a class need to be
23626 tagged.
23627
23628 The argument can be a list of strings of arbitrary length. The
23629 strings are sorted on output, so the order of the list is
23630 unimportant.
23631
23632 A redeclaration of an entity must not add new ABI tags,
23633 since doing so would change the mangled name.
23634
23635 The ABI tags apply to a name, so all instantiations and
23636 specializations of a template have the same tags. The attribute will
23637 be ignored if applied to an explicit specialization or instantiation.
23638
23639 The @option{-Wabi-tag} flag enables a warning about a class which does
23640 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23641 that needs to coexist with an earlier ABI, using this option can help
23642 to find all affected types that need to be tagged.
23643
23644 When a type involving an ABI tag is used as the type of a variable or
23645 return type of a function where that tag is not already present in the
23646 signature of the function, the tag is automatically applied to the
23647 variable or function. @option{-Wabi-tag} also warns about this
23648 situation; this warning can be avoided by explicitly tagging the
23649 variable or function or moving it into a tagged inline namespace.
23650
23651 @item init_priority (@var{priority})
23652 @cindex @code{init_priority} variable attribute
23653
23654 In Standard C++, objects defined at namespace scope are guaranteed to be
23655 initialized in an order in strict accordance with that of their definitions
23656 @emph{in a given translation unit}. No guarantee is made for initializations
23657 across translation units. However, GNU C++ allows users to control the
23658 order of initialization of objects defined at namespace scope with the
23659 @code{init_priority} attribute by specifying a relative @var{priority},
23660 a constant integral expression currently bounded between 101 and 65535
23661 inclusive. Lower numbers indicate a higher priority.
23662
23663 In the following example, @code{A} would normally be created before
23664 @code{B}, but the @code{init_priority} attribute reverses that order:
23665
23666 @smallexample
23667 Some_Class A __attribute__ ((init_priority (2000)));
23668 Some_Class B __attribute__ ((init_priority (543)));
23669 @end smallexample
23670
23671 @noindent
23672 Note that the particular values of @var{priority} do not matter; only their
23673 relative ordering.
23674
23675 @item warn_unused
23676 @cindex @code{warn_unused} type attribute
23677
23678 For C++ types with non-trivial constructors and/or destructors it is
23679 impossible for the compiler to determine whether a variable of this
23680 type is truly unused if it is not referenced. This type attribute
23681 informs the compiler that variables of this type should be warned
23682 about if they appear to be unused, just like variables of fundamental
23683 types.
23684
23685 This attribute is appropriate for types which just represent a value,
23686 such as @code{std::string}; it is not appropriate for types which
23687 control a resource, such as @code{std::lock_guard}.
23688
23689 This attribute is also accepted in C, but it is unnecessary because C
23690 does not have constructors or destructors.
23691
23692 @end table
23693
23694 @node Function Multiversioning
23695 @section Function Multiversioning
23696 @cindex function versions
23697
23698 With the GNU C++ front end, for x86 targets, you may specify multiple
23699 versions of a function, where each function is specialized for a
23700 specific target feature. At runtime, the appropriate version of the
23701 function is automatically executed depending on the characteristics of
23702 the execution platform. Here is an example.
23703
23704 @smallexample
23705 __attribute__ ((target ("default")))
23706 int foo ()
23707 @{
23708 // The default version of foo.
23709 return 0;
23710 @}
23711
23712 __attribute__ ((target ("sse4.2")))
23713 int foo ()
23714 @{
23715 // foo version for SSE4.2
23716 return 1;
23717 @}
23718
23719 __attribute__ ((target ("arch=atom")))
23720 int foo ()
23721 @{
23722 // foo version for the Intel ATOM processor
23723 return 2;
23724 @}
23725
23726 __attribute__ ((target ("arch=amdfam10")))
23727 int foo ()
23728 @{
23729 // foo version for the AMD Family 0x10 processors.
23730 return 3;
23731 @}
23732
23733 int main ()
23734 @{
23735 int (*p)() = &foo;
23736 assert ((*p) () == foo ());
23737 return 0;
23738 @}
23739 @end smallexample
23740
23741 In the above example, four versions of function foo are created. The
23742 first version of foo with the target attribute "default" is the default
23743 version. This version gets executed when no other target specific
23744 version qualifies for execution on a particular platform. A new version
23745 of foo is created by using the same function signature but with a
23746 different target string. Function foo is called or a pointer to it is
23747 taken just like a regular function. GCC takes care of doing the
23748 dispatching to call the right version at runtime. Refer to the
23749 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23750 Function Multiversioning} for more details.
23751
23752 @node Type Traits
23753 @section Type Traits
23754
23755 The C++ front end implements syntactic extensions that allow
23756 compile-time determination of
23757 various characteristics of a type (or of a
23758 pair of types).
23759
23760 @table @code
23761 @item __has_nothrow_assign (type)
23762 If @code{type} is const qualified or is a reference type then the trait is
23763 false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23764 is true, else if @code{type} is a cv class or union type with copy assignment
23765 operators that are known not to throw an exception then the trait is true,
23766 else it is false. Requires: @code{type} shall be a complete type,
23767 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23768
23769 @item __has_nothrow_copy (type)
23770 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23771 @code{type} is a cv class or union type with copy constructors that
23772 are known not to throw an exception then the trait is true, else it is false.
23773 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23774 @code{void}, or an array of unknown bound.
23775
23776 @item __has_nothrow_constructor (type)
23777 If @code{__has_trivial_constructor (type)} is true then the trait is
23778 true, else if @code{type} is a cv class or union type (or array
23779 thereof) with a default constructor that is known not to throw an
23780 exception then the trait is true, else it is false. Requires:
23781 @code{type} shall be a complete type, (possibly cv-qualified)
23782 @code{void}, or an array of unknown bound.
23783
23784 @item __has_trivial_assign (type)
23785 If @code{type} is const qualified or is a reference type then the trait is
23786 false. Otherwise if @code{__is_pod (type)} is true then the trait is
23787 true, else if @code{type} is a cv class or union type with a trivial
23788 copy assignment ([class.copy]) then the trait is true, else it is
23789 false. Requires: @code{type} shall be a complete type, (possibly
23790 cv-qualified) @code{void}, or an array of unknown bound.
23791
23792 @item __has_trivial_copy (type)
23793 If @code{__is_pod (type)} is true or @code{type} is a reference type
23794 then the trait is true, else if @code{type} is a cv class or union type
23795 with a trivial copy constructor ([class.copy]) then the trait
23796 is true, else it is false. Requires: @code{type} shall be a complete
23797 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23798
23799 @item __has_trivial_constructor (type)
23800 If @code{__is_pod (type)} is true then the trait is true, else if
23801 @code{type} is a cv class or union type (or array thereof) with a
23802 trivial default constructor ([class.ctor]) then the trait is true,
23803 else it is false. Requires: @code{type} shall be a complete
23804 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23805
23806 @item __has_trivial_destructor (type)
23807 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23808 the trait is true, else if @code{type} is a cv class or union type (or
23809 array thereof) with a trivial destructor ([class.dtor]) then the trait
23810 is true, else it is false. Requires: @code{type} shall be a complete
23811 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23812
23813 @item __has_virtual_destructor (type)
23814 If @code{type} is a class type with a virtual destructor
23815 ([class.dtor]) then the trait is true, else it is false. Requires:
23816 @code{type} shall be a complete type, (possibly cv-qualified)
23817 @code{void}, or an array of unknown bound.
23818
23819 @item __is_abstract (type)
23820 If @code{type} is an abstract class ([class.abstract]) then the trait
23821 is true, else it is false. Requires: @code{type} shall be a complete
23822 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23823
23824 @item __is_base_of (base_type, derived_type)
23825 If @code{base_type} is a base class of @code{derived_type}
23826 ([class.derived]) then the trait is true, otherwise it is false.
23827 Top-level cv qualifications of @code{base_type} and
23828 @code{derived_type} are ignored. For the purposes of this trait, a
23829 class type is considered is own base. Requires: if @code{__is_class
23830 (base_type)} and @code{__is_class (derived_type)} are true and
23831 @code{base_type} and @code{derived_type} are not the same type
23832 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23833 type. A diagnostic is produced if this requirement is not met.
23834
23835 @item __is_class (type)
23836 If @code{type} is a cv class type, and not a union type
23837 ([basic.compound]) the trait is true, else it is false.
23838
23839 @item __is_empty (type)
23840 If @code{__is_class (type)} is false then the trait is false.
23841 Otherwise @code{type} is considered empty if and only if: @code{type}
23842 has no non-static data members, or all non-static data members, if
23843 any, are bit-fields of length 0, and @code{type} has no virtual
23844 members, and @code{type} has no virtual base classes, and @code{type}
23845 has no base classes @code{base_type} for which
23846 @code{__is_empty (base_type)} is false. Requires: @code{type} shall
23847 be a complete type, (possibly cv-qualified) @code{void}, or an array
23848 of unknown bound.
23849
23850 @item __is_enum (type)
23851 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23852 true, else it is false.
23853
23854 @item __is_literal_type (type)
23855 If @code{type} is a literal type ([basic.types]) the trait is
23856 true, else it is false. Requires: @code{type} shall be a complete type,
23857 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23858
23859 @item __is_pod (type)
23860 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23861 else it is false. Requires: @code{type} shall be a complete type,
23862 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23863
23864 @item __is_polymorphic (type)
23865 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23866 is true, else it is false. Requires: @code{type} shall be a complete
23867 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23868
23869 @item __is_standard_layout (type)
23870 If @code{type} is a standard-layout type ([basic.types]) the trait is
23871 true, else it is false. Requires: @code{type} shall be a complete
23872 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23873
23874 @item __is_trivial (type)
23875 If @code{type} is a trivial type ([basic.types]) the trait is
23876 true, else it is false. Requires: @code{type} shall be a complete
23877 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23878
23879 @item __is_union (type)
23880 If @code{type} is a cv union type ([basic.compound]) the trait is
23881 true, else it is false.
23882
23883 @item __underlying_type (type)
23884 The underlying type of @code{type}. Requires: @code{type} shall be
23885 an enumeration type ([dcl.enum]).
23886
23887 @item __integer_pack (length)
23888 When used as the pattern of a pack expansion within a template
23889 definition, expands to a template argument pack containing integers
23890 from @code{0} to @code{length-1}. This is provided for efficient
23891 implementation of @code{std::make_integer_sequence}.
23892
23893 @end table
23894
23895
23896 @node C++ Concepts
23897 @section C++ Concepts
23898
23899 C++ concepts provide much-improved support for generic programming. In
23900 particular, they allow the specification of constraints on template arguments.
23901 The constraints are used to extend the usual overloading and partial
23902 specialization capabilities of the language, allowing generic data structures
23903 and algorithms to be ``refined'' based on their properties rather than their
23904 type names.
23905
23906 The following keywords are reserved for concepts.
23907
23908 @table @code
23909 @item assumes
23910 States an expression as an assumption, and if possible, verifies that the
23911 assumption is valid. For example, @code{assume(n > 0)}.
23912
23913 @item axiom
23914 Introduces an axiom definition. Axioms introduce requirements on values.
23915
23916 @item forall
23917 Introduces a universally quantified object in an axiom. For example,
23918 @code{forall (int n) n + 0 == n}).
23919
23920 @item concept
23921 Introduces a concept definition. Concepts are sets of syntactic and semantic
23922 requirements on types and their values.
23923
23924 @item requires
23925 Introduces constraints on template arguments or requirements for a member
23926 function of a class template.
23927
23928 @end table
23929
23930 The front end also exposes a number of internal mechanism that can be used
23931 to simplify the writing of type traits. Note that some of these traits are
23932 likely to be removed in the future.
23933
23934 @table @code
23935 @item __is_same (type1, type2)
23936 A binary type trait: true whenever the type arguments are the same.
23937
23938 @end table
23939
23940
23941 @node Deprecated Features
23942 @section Deprecated Features
23943
23944 In the past, the GNU C++ compiler was extended to experiment with new
23945 features, at a time when the C++ language was still evolving. Now that
23946 the C++ standard is complete, some of those features are superseded by
23947 superior alternatives. Using the old features might cause a warning in
23948 some cases that the feature will be dropped in the future. In other
23949 cases, the feature might be gone already.
23950
23951 G++ allows a virtual function returning @samp{void *} to be overridden
23952 by one returning a different pointer type. This extension to the
23953 covariant return type rules is now deprecated and will be removed from a
23954 future version.
23955
23956 The use of default arguments in function pointers, function typedefs
23957 and other places where they are not permitted by the standard is
23958 deprecated and will be removed from a future version of G++.
23959
23960 G++ allows floating-point literals to appear in integral constant expressions,
23961 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23962 This extension is deprecated and will be removed from a future version.
23963
23964 G++ allows static data members of const floating-point type to be declared
23965 with an initializer in a class definition. The standard only allows
23966 initializers for static members of const integral types and const
23967 enumeration types so this extension has been deprecated and will be removed
23968 from a future version.
23969
23970 G++ allows attributes to follow a parenthesized direct initializer,
23971 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
23972 has been ignored since G++ 3.3 and is deprecated.
23973
23974 G++ allows anonymous structs and unions to have members that are not
23975 public non-static data members (i.e.@: fields). These extensions are
23976 deprecated.
23977
23978 @node Backwards Compatibility
23979 @section Backwards Compatibility
23980 @cindex Backwards Compatibility
23981 @cindex ARM [Annotated C++ Reference Manual]
23982
23983 Now that there is a definitive ISO standard C++, G++ has a specification
23984 to adhere to. The C++ language evolved over time, and features that
23985 used to be acceptable in previous drafts of the standard, such as the ARM
23986 [Annotated C++ Reference Manual], are no longer accepted. In order to allow
23987 compilation of C++ written to such drafts, G++ contains some backwards
23988 compatibilities. @emph{All such backwards compatibility features are
23989 liable to disappear in future versions of G++.} They should be considered
23990 deprecated. @xref{Deprecated Features}.
23991
23992 @table @code
23993
23994 @item Implicit C language
23995 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23996 scope to set the language. On such systems, all header files are
23997 implicitly scoped inside a C language scope. Also, an empty prototype
23998 @code{()} is treated as an unspecified number of arguments, rather
23999 than no arguments, as C++ demands.
24000
24001 @end table
24002
24003 @c LocalWords: emph deftypefn builtin ARCv2EM SIMD builtins msimd
24004 @c LocalWords: typedef v4si v8hi DMA dma vdiwr vdowr